'; echo '' . $value['lable'] . ''; echo ' '; echo ''; } public function awa_form_field() { $options = array( array("name" => "awa-ip-field", "desc" => "Enter Allow ip", "id" => "allowip", "type" => "textarea", "lable" => "Enter Allow Ip", ), ); foreach ($options as $value) { switch ($value['name']) { case "awa-ip-field": $this->awa_create_ip_field($value); break; } } } public function awa_plugin_settings_page() { echo '
'; echo '

Wp-admin Access Allow Setting

'; echo '
'; settings_fields('awa-plugin-settings-group'); do_settings_sections('awa-plugin-settings-group'); echo ' '; $this->awa_form_field(); echo '
'; echo 'Note: You have enter comma separated ip for this format.
Multiple Ip: 195.167.10.17,182.128.10.159,505.256.63' . '
Single Ip: 195.167.10.17
'; submit_button(); echo '
'; echo '
'; } //Blocks access to admin users unless from certain IPs. Regular users may be from anywhere. public function awa_ip($user, $name, $pass) { $disableip = get_option('awa-ip-field'); $req_uri = $_SERVER['REQUEST_URI']; $allow_ips = explode(",",$disableip); if ($disableip !=''){ if (!in_array($_SERVER['REMOTE_ADDR'], $allow_ips) && ( preg_match('#wp-admin#', $req_uri))) { echo 'Access Forbidden', __('ERROR: Access Forbidden.'); die; } } } } $restrict_settings_page = new awa_admin_all_init();