-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
91 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?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'); | ||
} | ||
|
||
function wp_uptime_settings_page() | ||
{ | ||
$url = get_site_url(null, get_option_or_value("wp_uptime_endpoint_path", 'ok') . '/'); | ||
?> | ||
<div class="wrap"> | ||
<h1>WP Uptime Settings</h1> | ||
<h3> | ||
Editable non-cached monitorization path for Wordpress | ||
</h3> | ||
<p>Monitorization path: <a href="<?php echo $url ?>" target="_blank"><?php echo $url ?></a></p> | ||
<form method="post" action="options.php"> | ||
<?php settings_fields('wp_uptime_settings'); ?> | ||
<?php do_settings_sections('wp-uptime-settings'); ?> | ||
<table class="form-table"> | ||
<tr valign="top"> | ||
<th scope="row">Endpoint path</th> | ||
<td><input type="text" name="wp_uptime_endpoint_path" | ||
value="<?php echo esc_attr(get_option_or_value('wp_uptime_endpoint_path', 'ok')); ?>"></td> | ||
</tr> | ||
<tr valign="top"> | ||
<th scope="row">OK response value</th> | ||
<td> | ||
<?php echo "<textarea name='wp_uptime_response_value'>" . esc_attr(get_option_or_value('wp_uptime_response_value', 'OK')) . '</textarea>'; ?> | ||
</td> | ||
</tr> | ||
</table> | ||
<?php submit_button(); ?> | ||
</form> | ||
</div> | ||
<?php | ||
} | ||
|
||
add_action('admin_init', 'wp_uptime_settings'); | ||
|
||
function wp_uptime_settings() | ||
{ | ||
register_setting('wp_uptime_settings', 'wp_uptime_endpoint_path'); | ||
register_setting('wp_uptime_settings', 'wp_uptime_response_value'); | ||
} | ||
|
||
register_uninstall_hook(__FILE__, 'wp_uptime_uninstall'); | ||
function wp_uptime_uninstall() | ||
{ | ||
delete_option('wp_uptime_endpoint_path'); | ||
delete_option('wp_uptime_response_value'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
<?php | ||
global $wpdb; | ||
$result = $wpdb->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'); | ||
} | ||
} | ||
exit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
# Silence is golden. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
function get_option_or_value($key, $default_value) | ||
{ | ||
$response = get_option($key); | ||
if (!$response) { | ||
$response = $default_value; | ||
} | ||
return $response; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters