plugin = $plugin;
}
/**
* Capability needed to view the dashboard and change settings.
*
* @return string
*/
public static function capability() {
/**
* Filters the capability for Orbitstem SEO admin screens.
*
* @param string $capability Capability name.
*/
return (string) apply_filters( 'orbitstem_seo_manage_capability', 'manage_options' );
}
/**
* Registers hooks.
*/
public function register() {
add_action( 'admin_menu', array( $this, 'menu' ) );
add_action( 'admin_init', array( $this, 'register_setting' ) );
add_filter( 'option_page_capability_orbitstem_seo', array( __CLASS__, 'capability' ) );
add_filter( 'plugin_action_links_' . plugin_basename( ORBITSTEM_SEO_FILE ), array( $this, 'action_links' ) );
add_action( 'admin_post_orbitstem_seo_review', array( $this, 'review_answer' ) );
add_action( 'admin_notices', array( $this, 'staging_notice' ) );
}
/**
* What staging protection is really doing: 'on' (pages ask not to be
* indexed), 'paused' (it would apply, but safe mode keeps Orbitstem from
* changing robots tags and robots.txt while another SEO plugin is active),
* or '' (it does not apply here).
*
* @param Plugin $plugin Plugin services.
* @return string
*/
public static function staging_state( Plugin $plugin ) {
if ( ! \Orbitstem\SEO\Frontend\Robots::guard_applies( $plugin->settings ) ) {
return '';
}
// Robots, which adds the noindex, is only registered when output is on (see Plugin::setup()).
return $plugin->output_enabled() ? 'on' : 'paused';
}
/**
* What staging protection is doing and why, in one sentence.
*
* @param string $state 'on' or 'paused', from staging_state().
* @return string
*/
public static function staging_warning( $state = 'on' ) {
if ( 'paused' === $state ) {
return sprintf(
/* translators: %s: reason, such as 'WordPress is set up as a "staging" site.' */
__( 'Staging protection is paused: another SEO plugin is active, so Orbitstem SEO is in safe mode and does not ask search engines to stay out of this copy. Why this looks like a copy: %s To keep it out of search results, use the other SEO plugin\'s settings or "Discourage search engines" in Settings > Reading.', 'orbitstem-seo' ),
\Orbitstem\SEO\Frontend\Robots::staging_reason()
);
}
return sprintf(
/* translators: %s: reason, such as 'WordPress is set up as a "staging" site.' */
__( 'Staging protection is ON: every page of this site tells search engines not to index it, and robots.txt asks all crawlers to stay out. Reason: %s If this is your live site, turn off "Staging protection" in Orbitstem SEO > Settings > Crawlers now.', 'orbitstem-seo' ),
\Orbitstem\SEO\Frontend\Robots::staging_reason()
);
}
/**
* Prints the staging protection warning as a notice ('' state: nothing).
*
* @param string $state 'on' or 'paused', from staging_state().
* @param bool $inline Inline notice inside an Orbitstem screen (WordPress leaves it where it is).
*/
public static function print_staging_warning( $state, $inline = false ) {
if ( '' === $state ) {
return;
}
printf(
'