/** * Diagnosis of admin settings. * */ private function diagnose_admin_screen() { // Check version and compatibility if (version_compare(get_bloginfo('version'), '3.7') < 0) { $this->add_admin_notice('error', __('You need WordPress 3.7+.', IP_Geo_Block::TEXT_DOMAIN)); } // Check consistency of matching rule $settings = IP_Geo_Block::get_option('settings'); if (-1 == $settings['matching_rule']) { $this->add_admin_notice('notice-warning', sprintf(__('Welcome to %s!! At first, please confirm “<strong>Matching rule</strong>” at <a href="%s">Validation rule settings</a>.', IP_Geo_Block::TEXT_DOMAIN), __('IP Geo Block', IP_Geo_Block::TEXT_DOMAIN), admin_url('options-general.php?page=' . IP_Geo_Block::PLUGIN_SLUG))); } elseif (1 == $settings['validation']['login']) { $validate = IP_Geo_Block::get_geolocation(); $validate = IP_Geo_Block::validate_country($validate, $settings); if ('passed' !== $validate['result']) { $url = admin_url('options-general.php?page=' . IP_Geo_Block::PLUGIN_SLUG . '#' . IP_Geo_Block::PLUGIN_SLUG); $this->add_admin_notice('error', sprintf(__('You\'ll be blocked after you log out. Please confirm “<strong>Matching rule</strong>” and “<strong>Country code for matching rule</strong>” at <a href="%s">Validation rule settings</a>. Otherwise select “<strong>Block by country (register, lost password)</strong>” for “<strong>Login form</strong>” at <a href="%s">Validation target settings</a>.', IP_Geo_Block::TEXT_DOMAIN), "{$url}-settings-0", "{$url}-settings-1")); } } if (defined('IP_GEO_BLOCK_DEBUG') && IP_GEO_BLOCK_DEBUG) { // Check creation of database table if ($settings['validation']['reclogs']) { require_once IP_GEO_BLOCK_PATH . 'classes/class-ip-geo-block-logs.php'; if (($warn = IP_Geo_Block_Logs::diag_table()) && FALSE === IP_Geo_Block_Logs::create_log()) { $this->add_admin_notice('notice-warning', $warn); } } } }