/** * Make sure the needed scripts are loaded for admin pages */ function init() { if (isset($_GET['wpseo_reset_defaults']) && wp_verify_nonce($_GET['nonce'], 'wpseo_reset_defaults') && current_user_can('manage_options')) { WPSEO_Options::reset(); wp_redirect(admin_url('admin.php?page=wpseo_dashboard')); } $this->adminpages = apply_filters('wpseo_admin_pages', $this->adminpages); if (WPSEO_Options::grant_access()) { add_action('admin_enqueue_scripts', array($this, 'config_page_scripts')); add_action('admin_enqueue_scripts', array($this, 'config_page_styles')); } }
/** * @covers WPSEO_Options::grant_access */ public function test_grant_access() { if (is_multisite()) { // should be true when not running multisite $this->assertTrue(WPSEO_Options::grant_access()); return; // stop testing, not multisite } // admins should return true $user_id = $this->factory->user->create(array('role' => 'administrator')); wp_set_current_user($user_id); $this->assertTrue(WPSEO_Options::grant_access()); // todo test for superadmins // editors should return false // $user_id = $this->factory->user->create( array( 'role' => 'editor' ) ); // wp_set_current_user( $user_id ); // $this->assertTrue( WPSEO_Options::grant_access() ); }
/** * Check whether the current user is allowed to access the configuration. * * @deprecated 1.5.0 * @deprecated use WPSEO_Options::grant_access() * @see WPSEO_Options::grant_access() * * @return boolean */ function grant_access() { _deprecated_function(__METHOD__, 'WPSEO 1.5.0', 'WPSEO_Options::grant_access()'); return WPSEO_Options::grant_access(); }
/** * Register (whitelist) the option for the configuration pages. * The validation callback is already registered separately on the sanitize_option hook, * so no need to double register. * * @return void */ public function register_setting() { if (WPSEO_Options::grant_access()) { register_setting($this->group_name, $this->option_name); } }
/** * Register (whitelist) the option for the configuration pages. * The validation callback is already registered separately on the sanitize_option hook, * so no need to double register. * * @todo [JRF] if the extra bit below is no longer needed, move the if combined with a check * for $this->multisite_only to the abstract class * * @return void */ public function register_setting() { if (function_exists('is_multisite') && is_multisite() && WPSEO_Options::grant_access()) { register_setting($this->group_name, $this->option_name); } }