/** * Parses the value for the score column. * * @param integer $term_id ID of requested taxonomy. * * @return string */ private function get_score_value($term_id) { $term = get_term($term_id, $this->taxonomy); // When the term isn't indexable. if (!$this->is_indexable($term)) { return $this->create_score_icon(new WPSEO_Rank(WPSEO_Rank::NO_INDEX), __('Term is set to noindex.', 'wordpress-seo')); } // When there is a focus key word. if ($focus_keyword = $this->get_focus_keyword($term)) { $score = (int) WPSEO_Taxonomy_Meta::get_term_meta($term_id, $this->taxonomy, 'linkdex'); $rank = WPSEO_Rank::from_numeric_score($score); return $this->create_score_icon($rank, $rank->get_label()); } // Default icon. return $this->create_score_icon(new WPSEO_Rank(WPSEO_Rank::NO_FOCUS), __('Focus keyword not set.', 'wordpress-seo')); }
/** * Parsing the score column * * @param integer $post_id The ID of the post for which to show the score. * * @return string */ private function parse_column_score($post_id) { if ('1' === WPSEO_Meta::get_value('meta-robots-noindex', $post_id)) { $rank = new WPSEO_Rank(WPSEO_Rank::NO_INDEX); $title = __('Post is set to noindex.', 'wordpress-seo'); WPSEO_Meta::set_value('linkdex', 0, $post_id); } elseif ('' === WPSEO_Meta::get_value('focuskw', $post_id)) { $rank = new WPSEO_Rank(WPSEO_Rank::NO_FOCUS); $title = __('Focus keyword not set.', 'wordpress-seo'); } else { $score = (int) WPSEO_Meta::get_value('linkdex', $post_id); $rank = WPSEO_Rank::from_numeric_score($score); $title = $rank->get_label(); } return '<div aria-hidden="true" title="' . esc_attr($title) . '" class="wpseo-score-icon ' . esc_attr($rank->get_css_class()) . '"></div><span class="screen-reader-text">' . $title . '</span>'; }
/** * Translates a decimal analysis score into a textual one. * * @static * * @param int $val The decimal score to translate. * @param bool $css_value Whether to return the i18n translated score or the CSS class value. * * @return string */ public static function translate_score($val, $css_value = true) { $seo_rank = WPSEO_Rank::from_numeric_score($val); if ($css_value) { return $seo_rank->get_css_class(); } return $seo_rank->get_label(); }
/** * Parses the value for the readability score column. * * @param int $term_id ID of the requested term. * * @return string The HTML for the readability score indicator. */ private function get_score_readability_value($term_id) { $score = (int) WPSEO_Taxonomy_Meta::get_term_meta($term_id, $this->taxonomy, 'content_score'); $rank = WPSEO_Rank::from_numeric_score($score); return $this->create_score_icon($rank); }
/** * Parsing the readability score column. * * @param int $post_id The ID of the post for which to show the readability score. * * @return string The HTML for the readability score indicator. */ private function parse_column_score_readability($post_id) { $score = (int) WPSEO_Meta::get_value('content_score', $post_id); $rank = WPSEO_Rank::from_numeric_score($score); return $this->render_score_indicator($rank); }