: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @package WPSEO\Internals
* Holder for SEO Rank information.
* Constant used for determining a bad SEO rating.
public const BAD = 'bad';
* Constant used for determining an OK SEO rating.
* Constant used for determining a good SEO rating.
public const GOOD = 'good';
* Constant used for determining that no focus keyphrase is set.
public const NO_FOCUS = 'na';
* Constant used for determining that this content is not indexed.
public const NO_INDEX = 'noindex';
protected static $ranks = [
* Holds the translation from seo score slug to actual score range.
protected static $ranges = [
* WPSEO_Rank constructor.
* @param int $rank The actual rank.
public function __construct( $rank ) {
if ( ! in_array( $rank, self::$ranks, true ) ) {
* Returns the saved rank for this rank.
public function get_rank() {
* Returns a CSS class for this rank.
public function get_css_class() {
self::NO_INDEX => 'noindex',
return $labels[ $this->rank ];
* Returns a label for this rank.
public function get_label() {
self::NO_FOCUS => __( 'Not available', 'wordpress-seo' ),
self::NO_INDEX => __( 'No index', 'wordpress-seo' ),
self::BAD => __( 'Needs improvement', 'wordpress-seo' ),
self::OK => __( 'OK', 'wordpress-seo' ),
self::GOOD => __( 'Good', 'wordpress-seo' ),
return $labels[ $this->rank ];
* Returns an inclusive language label for this rank.
* The only difference with get_label above is that we return "Potentially non-inclusive" for an OK rank.
public function get_inclusive_language_label() {
if ( $this->rank === self::OK ) {
return __( 'Potentially non-inclusive', 'wordpress-seo' );
return $this->get_label();
* Returns a label for use in a drop down.
public function get_drop_down_label() {
self::NO_FOCUS => sprintf(
/* translators: %s expands to the SEO score */
__( 'SEO: %s', 'wordpress-seo' ),
__( 'No Focus Keyphrase', 'wordpress-seo' )
/* translators: %s expands to the SEO score */
__( 'SEO: %s', 'wordpress-seo' ),
__( 'Needs improvement', 'wordpress-seo' )
/* translators: %s expands to the SEO score */
__( 'SEO: %s', 'wordpress-seo' ),
__( 'OK', 'wordpress-seo' )
/* translators: %s expands to the SEO score */
__( 'SEO: %s', 'wordpress-seo' ),
__( 'Good', 'wordpress-seo' )
self::NO_INDEX => sprintf(
/* translators: %s expands to the SEO score */
__( 'SEO: %s', 'wordpress-seo' ),
__( 'Post Noindexed', 'wordpress-seo' )
return $labels[ $this->rank ];
* Gets the drop down labels for the readability score.
* @return string The readability rank label.
public function get_drop_down_readability_labels() {
/* translators: %s expands to the readability score */
__( 'Readability: %s', 'wordpress-seo' ),
__( 'Needs improvement', 'wordpress-seo' )
/* translators: %s expands to the readability score */
__( 'Readability: %s', 'wordpress-seo' ),
__( 'OK', 'wordpress-seo' )
/* translators: %s expands to the readability score */
__( 'Readability: %s', 'wordpress-seo' ),
__( 'Good', 'wordpress-seo' )
return $labels[ $this->rank ];
* Gets the drop down labels for the inclusive language score.
* @return string The inclusive language rank label.
public function get_drop_down_inclusive_language_labels() {
/* translators: %s expands to the inclusive language score */
__( 'Inclusive language: %s', 'wordpress-seo' ),
__( 'Needs improvement', 'wordpress-seo' )
/* translators: %s expands to the inclusive language score */
__( 'Inclusive language: %s', 'wordpress-seo' ),
__( 'Potentially non-inclusive', 'wordpress-seo' )
/* translators: %s expands to the inclusive language score */
__( 'Inclusive language: %s', 'wordpress-seo' ),
__( 'Good', 'wordpress-seo' )
return $labels[ $this->rank ];
* Get the starting score for this rank.
* @return int The start score.
public function get_starting_score() {
// No index does not have a starting score.
if ( $this->rank === self::NO_INDEX ) {
return self::$ranges[ $this->rank ]['start'];
* Get the ending score for this rank.
* @return int The end score.
public function get_end_score() {
// No index does not have an end score.
if ( $this->rank === self::NO_INDEX ) {
return self::$ranges[ $this->rank ]['end'];
* Returns a rank for a specific numeric score.
* @param int $score The score to determine a rank for.
public static function from_numeric_score( $score ) {
// Set up the default value.
$rank = new self( self::BAD );
foreach ( self::$ranges as $rank_index => $range ) {
if ( $range['start'] <= $score && $score <= $range['end'] ) {
$rank = new self( $rank_index );
* Returns a list of all possible SEO Ranks.
public static function get_all_ranks() {
return array_map( [ 'WPSEO_Rank', 'create_rank' ], self::$ranks );
* Returns a list of all possible Readability Ranks.
public static function get_all_readability_ranks() {
return array_map( [ 'WPSEO_Rank', 'create_rank' ], [ self::BAD, self::OK, self::GOOD ] );
* Returns a list of all possible Inclusive Language Ranks.
public static function get_all_inclusive_language_ranks() {
return array_map( [ 'WPSEO_Rank', 'create_rank' ], [ self::BAD, self::OK, self::GOOD ] );
* Converts a numeric rank into a WPSEO_Rank object, for use in functional array_* functions.
* @param string $rank SEO Rank.
private static function create_rank( $rank ) {
return new self( $rank );