From 837f1f9bfc78d0071604e4d017d37c86c676d67c Mon Sep 17 00:00:00 2001 From: bipoza Date: Fri, 11 Oct 2024 12:30:40 +0200 Subject: [PATCH] Change path to rewrite-rule --- admin.php | 55 +++++++++++++++++++++++++++++ check-connection.php | 10 +++--- index.php | 2 ++ utils.php | 9 +++++ wp-uptime.php | 83 ++++++++++---------------------------------- 5 files changed, 91 insertions(+), 68 deletions(-) create mode 100644 admin.php create mode 100644 index.php create mode 100644 utils.php diff --git a/admin.php b/admin.php new file mode 100644 index 0000000..d7289ce --- /dev/null +++ b/admin.php @@ -0,0 +1,55 @@ + +
+

WP Uptime Settings

+

+ Editable non-cached monitorization path for Wordpress +

+

Monitorization path:

+
+ + + + + + + + + + + +
Endpoint path
OK response value + " . esc_attr(get_option_or_value('wp_uptime_response_value', 'OK')) . ''; ?> +
+ +
+
+check_connection(); - -if ($result) { +// Check the connection: +if (!$wpdb->check_connection($allow_bail = false)) { + die(__("No DB connection")); +} else { header('Content-Type: text/plain; charset=utf-8'); header('Cache-Control: no-cache, no-store, must-revalidate'); header('Pragma: no-cache'); header('Expires: 0'); echo get_option_or_value("wp_uptime_response_value", 'OK'); -} \ No newline at end of file +} +exit; diff --git a/index.php b/index.php new file mode 100644 index 0000000..cf879a5 --- /dev/null +++ b/index.php @@ -0,0 +1,2 @@ +flush_rules(); + $public_query_vars[] = "wp_uptime"; + return $public_query_vars; } -function wpUptimeResponse() +function wp_uptime_request($wp) { - include('check-connection.php'); -} - -add_action('admin_menu', 'wp_uptime_menu'); -function wp_uptime_menu() -{ - add_options_page('WP Uptime Settings', 'WP Uptime', 'manage_options', 'wp-uptime-settings', 'wp_uptime_settings_page'); + if (isset($wp->query_vars["wp_uptime"]) && "true" === $wp->query_vars["wp_uptime"]) { + include('check-connection.php'); + } } -function wp_uptime_settings_page() +function wp_uptime_endpoint_rewrite() { - $url = get_site_url(null, get_option_or_value("wp_uptime_endpoint_path", 'ok') . '/'); - + add_rewrite_rule("^" . get_option_or_value("wp_uptime_endpoint_path", 'ok') . "$", "index.php?wp_uptime=true", "top"); - ?> -
-

WP Uptime Settings

-

- Editable non-cached monitorization path for Wordpress -

-

Monitorization path:

-
- - - - - - - - - - - -
Endpoint path
OK response value - " . esc_attr(get_option_or_value('wp_uptime_response_value', 'OK')) . ''; ?> -
- -
-
-