Want disable but allow json api plugin!
-
So append some maybe stupid code, but works for me:
— ilmds.php 2014-12-29 22:32:46.000000000 +0100
+++ ilmds_allowed_request_string.php 2015-10-19 22:41:01.720724176 +0200
@@ -126,13 +126,16 @@
case ($is_login_page || $is_admin_ui): // Is login page or admin UI.
case ($is_user_admin && $this->is_admin_access_enabled()): // Admin user and access is enabled.
case ($is_user_logged_in && $this->is_authenticated_user_access_enabled()): // Logged in user and access is enabled.
– case (in_array($_SERVER[‘REMOTE_ADDR’], $this->get_allowed_ips())): // IP address is allowed.
+ case (in_array($_SERVER[‘REMOTE_ADDR’], $this->get_allowed_ips())) // IP address is allowed.
+ || (
+ (!empty($this->get_allowed_request_string()))
+ && (0 === strpos($_SERVER[‘REQUEST_URI’], $this->get_allowed_request_string()))
+ ): // special request uri allowed
$show_splash_page = false;
break;
}if ($show_splash_page) {
–
// Replace the page HTML.
$buffer = $disable_site_plugin->get_output_html();@@ -223,6 +226,11 @@
$this->settings[‘namespace’] . ‘_return_503’
);+ register_setting(
+ $this->settings[‘namespace’] . ‘-settings-group’,
+ $this->settings[‘namespace’] . ‘_allowed_request_string’
+ );
+
}/**
@@ -269,6 +277,7 @@
$custom_message_html = get_option($this->settings[‘namespace’] . ‘_custom_html’, ”);
$allowed_ips = get_option($this->settings[‘namespace’] . ‘_allowed_ips’, “# These are example IPs. Feel free to remove them.\n192.168.1.0\n192.168.2.0 # Example IP with a note to help you keep track. :)”);
$return_503 = get_option($this->settings[‘namespace’] . ‘_return_503’, ‘y’) != ‘n’;
+ $custom_request_string = get_option($this->settings[‘namespace’] . ‘_allowed_request_string’, ”);echo ‘
<table class=”form-table”>
@@ -347,6 +356,15 @@
<span class=”help”>Whether or not the splash page should return a 503 (temporarily disabled) HTTP response. (Used by search engines. It is recommended that you only change this setting if you know what it does.)</span>
</td>
</tr>
+ <tr valign=”top”>
+ <th scope=”row”>
+ Custom Request String
+ </th>
+ <td>
+ <input type=”text” name=”‘ . $this->settings[‘namespace’] . ‘_allowed_request_string” value=”‘ . $custom_request_string . ‘” />
+ <span class=”help”>Type any custom string which in the request uri, i.e. /wp-json/</span>
+ </td>
+ </tr>
</table>
‘;@@ -666,6 +684,11 @@
}
+ public function get_allowed_request_string()
+ {
+ return get_option($this->settings[‘namespace’] . ‘_allowed_request_string’);
+ }
+
/**
* Explode a value into an array of lines.
*
- The topic ‘Want disable but allow json api plugin!’ is closed to new replies.