本文整理汇总了PHP中WPSEO_Options::grant_access方法的典型用法代码示例。如果您正苦于以下问题:PHP WPSEO_Options::grant_access方法的具体用法?PHP WPSEO_Options::grant_access怎么用?PHP WPSEO_Options::grant_access使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPSEO_Options
的用法示例。
在下文中一共展示了WPSEO_Options::grant_access方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* 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'));
}
}
示例2: test_grant_access
/**
* @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() );
}
示例3: 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();
}
示例4: register_setting
/**
* 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);
}
}
示例5: register_setting
/**
* 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);
}
}