本文整理汇总了PHP中WPSEO_Utils::translate_score方法的典型用法代码示例。如果您正苦于以下问题:PHP WPSEO_Utils::translate_score方法的具体用法?PHP WPSEO_Utils::translate_score怎么用?PHP WPSEO_Utils::translate_score使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPSEO_Utils
的用法示例。
在下文中一共展示了WPSEO_Utils::translate_score方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addPostMeta
/**
* Post Meta
*/
public function addPostMeta($post)
{
// Hidden in Nested Pages?
$np_status = get_post_meta($post->ID, 'nested_pages_status', true);
$this->post_data->np_status = $np_status == 'hide' ? 'hide' : 'show';
// Yoast Score
if (function_exists('wpseo_auto_load')) {
$yoast_score = get_post_meta($post->ID, '_yoast_wpseo_meta-robots-noindex', true);
if (!$yoast_score) {
$yoast_score = get_post_meta($post->ID, '_yoast_wpseo_linkdex', true);
$this->post_data->score = \WPSEO_Utils::translate_score($yoast_score);
} else {
$this->post_data->score = 'noindex';
}
}
}
示例2: addPostMeta
/**
* Post Meta
*/
public function addPostMeta($post)
{
$meta = get_metadata('post', $post->ID);
$this->post_data->nav_title = isset($meta['np_nav_title'][0]) ? $meta['np_nav_title'][0] : null;
$this->post_data->link_target = isset($meta['np_link_target'][0]) ? $meta['np_link_target'][0] : null;
$this->post_data->nav_title_attr = isset($meta['np_title_attribute'][0]) ? $meta['np_title_attribute'][0] : null;
$this->post_data->nav_css = isset($meta['np_nav_css_classes'][0]) ? $meta['np_nav_css_classes'][0] : null;
$this->post_data->nav_object = isset($meta['np_nav_menu_item_object'][0]) ? $meta['np_nav_menu_item_object'][0] : null;
$this->post_data->nav_object_id = isset($meta['np_nav_menu_item_object_id'][0]) ? $meta['np_nav_menu_item_object_id'][0] : null;
$this->post_data->nav_type = isset($meta['np_nav_menu_item_type'][0]) ? $meta['np_nav_menu_item_type'][0] : null;
$this->post_data->nav_status = isset($meta['np_nav_status'][0]) && $meta['np_nav_status'][0] == 'hide' ? 'hide' : 'show';
$this->post_data->np_status = isset($meta['nested_pages_status'][0]) && $meta['nested_pages_status'][0] == 'hide' ? 'hide' : 'show';
$this->post_data->template = isset($meta['_wp_page_template'][0]) ? $meta['_wp_page_template'][0] : false;
// Yoast Score
if (function_exists('wpseo_auto_load')) {
$yoast_score = get_post_meta($post->ID, '_yoast_wpseo_meta-robots-noindex', true);
if (!$yoast_score) {
$yoast_score = get_post_meta($post->ID, '_yoast_wpseo_linkdex', true);
$this->post_data->score = \WPSEO_Utils::translate_score($yoast_score);
} else {
$this->post_data->score = 'noindex';
}
}
}
示例3: wpseo_translate_score
/**
* Translates a decimal analysis score into a textual one.
*
* @deprecated 1.5.6.1
* @deprecated use WPSEO_Utils::translate_score()
* @see WPSEO_Utils::translate_score()
*
* @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
*/
function wpseo_translate_score($val, $css_value = true)
{
_deprecated_function(__FUNCTION__, 'WPSEO 1.5.6.1', 'WPSEO_Utils::translate_score()');
return WPSEO_Utils::translate_score();
}
示例4: publish_box
/**
* Outputs the page analysis score in the Publish Box.
*/
public function publish_box()
{
if ($this->is_metabox_hidden() === true) {
return;
}
$post = $this->get_metabox_post();
if (self::get_value('meta-robots-noindex', $post->ID) === '1') {
$score_label = 'noindex';
$title = __('Post is set to noindex.', 'wordpress-seo');
$score_title = $title;
} else {
$score = self::get_value('linkdex', $post->ID);
if ($score === '') {
$score_label = 'na';
$title = __('No focus keyword set.', 'wordpress-seo');
} else {
$score_label = WPSEO_Utils::translate_score($score);
}
$score_title = WPSEO_Utils::translate_score($score, false);
if (!isset($title)) {
$title = $score_title;
}
}
printf('
<div title="%s" id="wpseo-score">
' . $this->traffic_light_svg() . '
</div>', __('SEO score', 'wordpress-seo'), esc_attr('wpseo-score-icon ' . $score_label), __('SEO:', 'wordpress-seo'), $score_title, __('Check', 'wordpress-seo'));
}
示例5: linkdex_output
/**
* Output the page analysis results.
*
* @param object $post Post to output the page analysis results for.
*
* @return string
*/
function linkdex_output($post)
{
$results = $this->calculate_results($post);
if (is_wp_error($results)) {
$error = $results->get_error_messages();
return '<tr><td><div class="wpseo_msg"><p><strong>' . esc_html($error[0]) . '</strong></p></div></td></tr>';
}
$output = '';
if (is_array($results) && $results !== array()) {
$output = '<table class="wpseoanalysis">';
$perc_score = absint($results['total']);
unset($results['total']);
// Unset to prevent echoing it.
foreach ($results as $result) {
if (is_array($result)) {
$score = WPSEO_Utils::translate_score($result['val']);
$output .= '<tr><td class="score"><div class="' . esc_attr('wpseo-score-icon ' . $score) . '"></div></td><td>' . $result['msg'] . '</td></tr>';
}
}
unset($result, $score);
$output .= '</table>';
if (WP_DEBUG === true || defined('WPSEO_DEBUG') && WPSEO_DEBUG === true) {
$output .= '<p><small>(' . $perc_score . '%)</small></p>';
}
}
$output = '<div class="wpseo_msg"><p>' . __('To update this page analysis, save as draft or update and check this tab again', 'wordpress-seo') . '.</p></div>' . $output;
unset($results);
return $output;
}
示例6: publish_box
/**
* Outputs the page analysis score in the Publish Box.
*/
public function publish_box()
{
if ($this->is_metabox_hidden() === true) {
return;
}
$post = $this->get_metabox_post();
if (self::get_value('meta-robots-noindex', $post->ID) === '1') {
$score_label = 'noindex';
$title = __('Post is set to noindex.', 'wordpress-seo');
$score_title = $title;
} else {
$score = self::get_value('linkdex', $post->ID);
if ($score === '') {
$score_label = 'na';
$title = __('No focus keyword set.', 'wordpress-seo');
} else {
$score_label = WPSEO_Utils::translate_score($score);
}
$score_title = WPSEO_Utils::translate_score($score, false);
if (!isset($title)) {
$title = $score_title;
}
}
}
示例7: wpseo_translate_score
/**
* wpseo_translate_score has been deprecated in newer versions of wordpress-seo
*
* @param int $nr
*
* @return mixed
*/
protected function wpseo_translate_score($nr)
{
if (method_exists('WPSEO_Utils', 'translate_score')) {
return WPSEO_Utils::translate_score($nr);
}
return wpseo_translate_score($nr);
}