/**
  * 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'));
     }
 }
 /**
  * @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() );
 }
Exemple #3
0
 /**
  * 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;
 }
 /**
  * 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();
 }
    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>';
 /**
  * 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);
     }
 }
Exemple #7
0
 /**
  * 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'))));
     }
 }
    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:
    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>';
 /**
  * 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();
 }