本文整理汇总了PHP中WPSEO_Utils::grant_access方法的典型用法代码示例。如果您正苦于以下问题:PHP WPSEO_Utils::grant_access方法的具体用法?PHP WPSEO_Utils::grant_access怎么用?PHP WPSEO_Utils::grant_access使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPSEO_Utils
的用法示例。
在下文中一共展示了WPSEO_Utils::grant_access方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Make sure the needed scripts are loaded for admin pages
*/
function init()
{
if (filter_input(INPUT_GET, 'wpseo_reset_defaults') && wp_verify_nonce(filter_input(INPUT_GET, 'nonce'), 'wpseo_reset_defaults') && current_user_can('manage_options')) {
WPSEO_Options::reset();
wp_redirect(admin_url('admin.php?page=' . WPSEO_Admin::PAGE_IDENTIFIER));
}
if (WPSEO_Utils::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_Utils::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_Utils::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: should_show_notice
/**
* Should the notice being given?
*
* @return bool
*/
protected function should_show_notice()
{
// If development note is on or the tagline notice is shown, just don't show this notice.
if (WPSEO_Utils::is_development_mode() || '0' === get_option('blog_public')) {
return false;
}
return WPSEO_Utils::grant_access() && !$this->user_has_dismissed() && $this->onpage_option->get_status() === WPSEO_OnPage_Option::IS_NOT_INDEXABLE;
}
示例4: grant_access
/**
* Check whether the current user is allowed to access the configuration.
*
* @deprecated 1.5.0
* @deprecated use WPSEO_Utils::grant_access()
* @see WPSEO_Utils::grant_access()
*
* @return boolean
*/
function grant_access()
{
_deprecated_function(__METHOD__, 'WPSEO 1.5.0', 'WPSEO_Utils::grant_access()');
return WPSEO_Utils::grant_access();
}
示例5: printf
printf($statistic['title'], intval($statistic['count']));
?>
</a>
</th>
<td class="post-count">
<?php
echo absint($statistic['count']);
?>
</td>
</tr>
<?php
}
?>
</table>
<?php
if (WPSEO_Utils::grant_access()) {
?>
<div class="onpage">
<h4 class="hide-if-no-js"><?php
printf(__('Indexability check by %1$s', 'wordpress-seo'), 'OnPage.org');
?>
</h4>
<div>
<?php
/**
* @var array $onpage Array containing the indexable and can_fetch value.
*/
switch ($onpage['indexable']) {
case WPSEO_OnPage_Option::IS_INDEXABLE:
echo '<div class="wpseo-score-icon good"></div>';
示例6: 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_Utils::grant_access()) {
register_setting($this->group_name, $this->option_name);
}
}
示例7: recalculate_notice
/**
* Shows the notice for recalculating the post. the Notice will only be shown if the user hasn't dismissed it before.
*/
public function recalculate_notice()
{
// Just a return, because we want to temporary disable this notice (#3998).
return;
if (filter_input(INPUT_GET, 'recalculate') === '1') {
update_option('wpseo_dismiss_recalculate', '1');
return;
}
$can_access = is_multisite() ? WPSEO_Utils::grant_access() : current_user_can('manage_options');
if ($can_access && !$this->is_site_notice_dismissed('wpseo_dismiss_recalculate')) {
Yoast_Notification_Center::get()->add_notification(new Yoast_Notification(sprintf(__('We\'ve updated our SEO score algorithm. %1$sClick here to recalculate the SEO scores%2$s for all posts and pages.', 'wordpress-seo'), '<a href="' . admin_url('admin.php?page=wpseo_tools&recalculate=1') . '">', '</a>'), array('type' => 'updated yoast-dismissible', 'id' => 'wpseo-dismiss-recalculate', 'nonce' => wp_create_nonce('wpseo-dismiss-recalculate'))));
}
}
示例8: printf
printf($statistic['title'], intval($statistic['count']));
?>
</a>
</th>
<td class="post-count">
<?php
echo absint($statistic['count']);
?>
</td>
</tr>
<?php
}
?>
</table>
<?php
$can_access = is_multisite() ? WPSEO_Utils::grant_access() : current_user_can('manage_options');
if (!empty($onpage) && $can_access) {
?>
<div class="onpage">
<h3 class="hide-if-no-js"><?php
printf(__('Indexability check by %1$s', 'wordpress-seo'), 'OnPage.org');
?>
</h3>
<div>
<?php
/**
* @var array $onpage Array containing the indexable and can_fetch value.
*/
switch ($onpage['indexable']) {
case WPSEO_OnPage_Option::IS_INDEXABLE:
示例9: printf
printf($statistic['title'], intval($statistic['count']));
?>
</a>
</th>
<td class="post-count">
<?php
echo absint($statistic['count']);
?>
</td>
</tr>
<?php
}
?>
</table>
<?php
if (!empty($onpage) && WPSEO_Utils::grant_access()) {
?>
<div class="onpage">
<h3 class="hide-if-no-js"><?php
printf(__('Indexability check by %1$s', 'wordpress-seo'), 'OnPage.org');
?>
</h3>
<div>
<?php
/**
* @var array $onpage Array containing the indexable and can_fetch value.
*/
switch ($onpage['indexable']) {
case WPSEO_OnPage_Option::IS_INDEXABLE:
echo '<div class="wpseo-score-icon good"></div>';
示例10: should_show_notice
/**
* Should the notice being given?
*
* @return bool
*/
protected function should_show_notice()
{
// If development note is on or the tagline notice is shown, just don't show this notice.
if (WPSEO_Utils::is_development_mode() || '0' === get_option('blog_public')) {
return false;
}
return WPSEO_Utils::grant_access() && !$this->user_has_dismissed() && !$this->onpage_option->is_indexable();
}