Created
January 4, 2019 14:51
-
-
Save shakeeb-mts/4499dda6230252ed45c267d17c96f39f to your computer and use it in GitHub Desktop.
New test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Notify about the default tagline if the user hasn't changed it | |
*/ | |
private function default_tagline_notice() { | |
$customize_url = add_query_arg( [ 'autofocus[control]' => 'blogdescription' ], wp_customize_url() ); | |
$info_message = sprintf( | |
/* translators: 1: link open tag; 2: link close tag. */ | |
esc_html__( 'You still have the default WordPress tagline, even an empty one is probably better. %1$sYou can fix this in the customizer%2$s.', 'rank-math' ), | |
'<a href="' . esc_attr( $customize_url ) . '">', | |
'</a>' | |
); | |
if ( $this->has_default_tagline() ) { | |
Helper::add_notification( $info_message, [ | |
'type' => 'error', | |
'id' => 'rank-math-default-tagline-notice', | |
]); | |
} else { | |
Helper::remove_notification( 'rank-math-default-tagline-notice' ); | |
} | |
} | |
/** | |
* Returns whether or not the site has the default tagline | |
* | |
* @return bool | |
*/ | |
private function has_default_tagline() { | |
$description = get_bloginfo( 'description' ); | |
$default_description = 'Just another WordPress site'; | |
// We are checking against the WordPress internal translation. | |
$translated_description = __( 'Just another WordPress site', 'default' ); // phpcs:ignore | |
return $translated_description === $description || $default_description === $description; | |
} | |
/** | |
* Add an alert if the blog is not publicly visible | |
*/ | |
private function blog_public_notice() { | |
$info_message = '<strong>' . esc_html__( 'Huge SEO Issue: You\'re blocking access to robots.', 'rank-math' ) . '</strong> '; | |
$info_message .= sprintf( | |
/* translators: %1$s resolves to the opening tag of the link to the reading settings, %1$s resolves to the closing tag for the link */ | |
esc_html__( 'You must %1$sgo to your Reading Settings%2$s and uncheck the box for Search Engine Visibility.', 'rank-math' ), | |
'<a href="' . esc_url( admin_url( 'options-reading.php' ) ) . '">', | |
'</a>' | |
); | |
if ( ! $this->is_blog_public() ) { | |
Helper::add_notification( $info_message, [ | |
'type' => 'error', | |
'id' => 'rank-math-blog-public-notice', | |
]); | |
} else { | |
Helper::remove_notification( 'rank-math-blog-public-notice' ); | |
} | |
} | |
/** | |
* Check if the site is set to be publicly visible | |
* | |
* @return bool | |
*/ | |
private function is_blog_public() { | |
return '1' === (string) get_option( 'blog_public' ); | |
} | |
/** | |
* Show alert when the permalink doesn't contain %postname% | |
*/ | |
private function permalink_notice() { | |
$info_message = __( 'You do not have your postname in the URL of your posts and pages, it is highly recommended that you do. Consider setting your permalink structure to <strong>/%postname%/</strong>.', 'rank-math' ); | |
$info_message .= '<br/>'; | |
$info_message .= sprintf( | |
/* translators: %1$s resolves to the starting tag of the link to the permalink settings page, %2$s resolves to the closing tag of the link */ | |
__( 'You can fix this on the %1$sPermalink settings page%2$s.', 'rank-math' ), | |
'<a href="' . admin_url( 'options-permalink.php' ) . '">', | |
'</a>' | |
); | |
if ( ! $this->has_postname_in_permalink() ) { | |
Helper::add_notification( $info_message, [ | |
'type' => 'warning', | |
'id' => 'rank-math-permalink-notice', | |
]); | |
} else { | |
Helper::remove_notification( 'rank-math-permalink-notice' ); | |
} | |
} | |
/** | |
* Check if the permalink uses %postname% | |
* | |
* @return bool | |
*/ | |
private function has_postname_in_permalink() { | |
return ( false !== strpos( get_option( 'permalink_structure' ), '%postname%' ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment