Пример #1
0
 /**
  * Translate text strings for use in the meta box
  *
  * IMPORTANT: if you want to add a new string (option) somewhere, make sure you add that array key to
  * the main meta box definition array in the class YMBESEO_Meta() as well!!!!
  */
 public static function translate_meta_boxes()
 {
     /* translators: %s expands to the social network's name */
     $title_text = __('If you don\'t want to use the post title for sharing the post on %s but instead want another title there, write it here.', 'ymbeseo');
     /* translators: %s expands to the social network's name */
     $description_text = __('If you don\'t want to use the meta description for sharing the post on %s but want another description there, write it here.', 'ymbeseo');
     /* translators: %s expands to the social network's name */
     $image_text = __('If you want to override the image used on %s for this post, upload / choose an image or add the URL here.', 'ymbeseo');
     /* translators: %1$s expands to the social network, %2$s to the recommended image size */
     $image_size_text = __('The recommended image size for %1$s is %2$spx.', 'ymbeseo');
     $options = YMBESEO_Options::get_all();
     $social_networks = array('opengraph' => __('Facebook', 'ymbeseo'), 'twitter' => __('Twitter', 'ymbeseo'), 'googleplus' => __('Google+', 'ymbeseo'));
     // Source: https://blog.bufferapp.com/ideal-image-sizes-social-media-posts.
     $recommended_image_sizes = array('opengraph' => '1200 x 628', 'twitter' => '1024 x 512', 'google-plus' => '800 x 1200');
     foreach ($social_networks as $network => $label) {
         if (true === $options[$network]) {
             if ('googleplus' == $network) {
                 $network = 'google-plus';
                 // Yuck, I know.
             }
             self::$meta_fields['social'][$network . '-title']['title'] = sprintf(__('%s Title', 'ymbeseo'), $label);
             self::$meta_fields['social'][$network . '-title']['description'] = sprintf($title_text, $label);
             self::$meta_fields['social'][$network . '-description']['title'] = sprintf(__('%s Description', 'ymbeseo'), $label);
             self::$meta_fields['social'][$network . '-description']['description'] = sprintf($description_text, $label);
             self::$meta_fields['social'][$network . '-image']['title'] = sprintf(__('%s Image', 'ymbeseo'), $label);
             self::$meta_fields['social'][$network . '-image']['description'] = sprintf($image_text, $label) . ' ' . sprintf($image_size_text, $label, $recommended_image_sizes[$network]);
         }
     }
 }
Пример #2
0
 /**
  * Class constructor
  */
 public function __construct()
 {
     $this->options = YMBESEO_Options::get_all();
     add_action('YMBESEO_head', array($this, 'json_ld'), 90);
     add_action('YMBESEO_json_ld', array($this, 'website'), 10);
     add_action('YMBESEO_json_ld', array($this, 'organization_or_person'), 20);
 }
Пример #3
0
 /**
  * Class constructor.
  */
 public function __construct()
 {
     $this->options = YMBESEO_Options::get_all();
     if (isset($GLOBALS['fb_ver']) || class_exists('Facebook_Loader', false)) {
         add_filter('fb_meta_tags', array($this, 'facebook_filter'), 10, 1);
     } else {
         add_filter('language_attributes', array($this, 'add_opengraph_namespace'));
         add_action('YMBESEO_opengraph', array($this, 'locale'), 1);
         add_action('YMBESEO_opengraph', array($this, 'type'), 5);
         add_action('YMBESEO_opengraph', array($this, 'og_title'), 10);
         add_action('YMBESEO_opengraph', array($this, 'site_owner'), 20);
         add_action('YMBESEO_opengraph', array($this, 'description'), 11);
         add_action('YMBESEO_opengraph', array($this, 'url'), 12);
         add_action('YMBESEO_opengraph', array($this, 'site_name'), 13);
         add_action('YMBESEO_opengraph', array($this, 'website_facebook'), 14);
         if (is_singular() && !is_front_page()) {
             add_action('YMBESEO_opengraph', array($this, 'article_author_facebook'), 15);
             add_action('YMBESEO_opengraph', array($this, 'tags'), 16);
             add_action('YMBESEO_opengraph', array($this, 'category'), 17);
             add_action('YMBESEO_opengraph', array($this, 'publish_date'), 19);
         }
         add_action('YMBESEO_opengraph', array($this, 'image'), 30);
     }
     add_filter('jetpack_enable_open_graph', '__return_false');
     add_action('YMBESEO_head', array($this, 'opengraph'), 30);
 }
Пример #4
0
 /**
  * Class constructor
  */
 function __construct()
 {
     $this->options = YMBESEO_Options::get_all();
     if (is_multisite()) {
         YMBESEO_Options::maybe_set_multisite_defaults(false);
     }
     if ($this->options['stripcategorybase'] === true) {
         add_action('created_category', array($this, 'schedule_rewrite_flush'));
         add_action('edited_category', array($this, 'schedule_rewrite_flush'));
         add_action('delete_category', array($this, 'schedule_rewrite_flush'));
     }
     $this->page_gsc = new YMBESEO_GSC();
     $this->dashboard_widget = new Yoast_Dashboard_Widget();
     // Needs the lower than default priority so other plugins can hook underneath it without issue.
     add_action('admin_menu', array($this, 'register_settings_page'), 5);
     add_action('network_admin_menu', array($this, 'register_network_settings_page'));
     add_filter('plugin_action_links_' . YMBESEO_BASENAME, array($this, 'add_action_link'), 10, 2);
     add_action('admin_enqueue_scripts', array($this, 'config_page_scripts'));
     if ('0' == get_option('blog_public')) {
         add_action('admin_footer', array($this, 'blog_public_warning'));
     }
     if ((isset($this->options['theme_has_description']) && $this->options['theme_has_description'] === true || $this->options['theme_description_found'] !== '') && $this->options['ignore_meta_description_warning'] !== true) {
         add_action('admin_footer', array($this, 'meta_description_warning'));
     }
     if ($this->options['cleanslugs'] === true) {
         add_filter('name_save_pre', array($this, 'remove_stopwords_from_slug'), 0);
     }
     add_filter('user_contactmethods', array($this, 'update_contactmethods'), 10, 1);
     add_action('after_switch_theme', array($this, 'switch_theme'));
     add_action('switch_theme', array($this, 'switch_theme'));
     add_filter('set-screen-option', array($this, 'save_bulk_edit_options'), 10, 3);
     add_action('admin_init', array('YMBESEO_Plugin_Conflict', 'hook_check_for_plugin_conflicts'), 10, 1);
     YMBESEO_Utils::register_cache_clear_option('wpseo', '');
 }
Пример #5
0
 /**
  * Class constructor
  */
 public function __construct()
 {
     $this->options = YMBESEO_Options::get_all();
     YMBESEO_Options::maybe_set_multisite_defaults(false);
     $this->init();
     if (version_compare($this->options['version'], '1.5.0', '<')) {
         $this->upgrade_15($this->options['version']);
     }
     if (version_compare($this->options['version'], '2.0', '<')) {
         $this->upgrade_20();
     }
     if (version_compare($this->options['version'], '2.1', '<')) {
         $this->upgrade_21();
     }
     if (version_compare($this->options['version'], '2.2', '<')) {
         $this->upgrade_22();
     }
     if (version_compare($this->options['version'], '2.3', '<')) {
         $this->upgrade_23();
     }
     /**
      * Filter: 'YMBESEO_run_upgrade' - Runs the upgrade hook which are dependent on Yoast SEO
      *
      * @api string - The current version of Yoast SEO
      */
     do_action('YMBESEO_run_upgrade', $this->options['version']);
     $this->finish_up();
 }
Пример #6
0
 /**
  * Update the query vars with the redirect var when stripcategorybase is active
  *
  * @param array $query_vars
  *
  * @return array
  */
 function query_vars($query_vars)
 {
     $options = YMBESEO_Options::get_all();
     if ($options['stripcategorybase'] === true) {
         $query_vars[] = 'YMBESEO_category_redirect';
     }
     return $query_vars;
 }
 /**
  * Generates the html for the snippet preview containing dynamically generated text components.
  * Those components are included as properties which are set in the constructor.
  *
  * @param object $post
  * @param string $title
  * @param string $description
  */
 public function __construct($post, $title, $description)
 {
     $this->options = YMBESEO_Options::get_all();
     $this->post = $post;
     $this->title = esc_html($title);
     $this->description = esc_html($description);
     $this->set_date();
     $this->set_url();
     $this->set_content();
 }
Пример #8
0
 /**
  * Create the breadcrumb
  */
 private function __construct()
 {
     $this->options = YMBESEO_Options::get_all();
     $this->post = isset($GLOBALS['post']) ? $GLOBALS['post'] : null;
     $this->show_on_front = get_option('show_on_front');
     $this->page_for_posts = get_option('page_for_posts');
     $this->filter_element();
     $this->filter_separator();
     $this->filter_wrapper();
     $this->set_crumbs();
     $this->prepare_links();
     $this->links_to_string();
     $this->wrap_breadcrumb();
 }
Пример #9
0
 /**
  * Class constructor
  */
 public function __construct()
 {
     $this->options = YMBESEO_Options::get_all();
     $GLOBALS['YMBESEO_admin'] = new YMBESEO_Admin();
     $this->pagenow = $GLOBALS['pagenow'];
     add_action('admin_enqueue_scripts', array($this, 'enqueue_dismissible'));
     add_action('admin_init', array($this, 'after_update_notice'), 15);
     add_action('admin_init', array($this, 'tagline_notice'), 15);
     add_action('admin_init', array($this, 'ga_compatibility_notice'), 15);
     $this->load_meta_boxes();
     $this->load_taxonomy_class();
     $this->load_admin_page_class();
     $this->load_admin_user_class();
     $this->ignore_tour();
     $this->load_tour();
     $this->load_xml_sitemaps_admin();
 }
 /**
  * Hooked into transition_post_status. Will initiate search engine pings
  * if the post is being published, is a post type that a sitemap is built for
  * and is a post that is included in sitemaps.
  *
  * @param string   $new_status New post status.
  * @param string   $old_status Old post status.
  * @param \WP_Post $post       Post object.
  */
 function status_transition($new_status, $old_status, $post)
 {
     if ($new_status != 'publish') {
         return;
     }
     wp_cache_delete('lastpostmodified:gmt:' . $post->post_type, 'timeinfo');
     // #17455.
     $options = YMBESEO_Options::get_all();
     if (isset($options['post_types-' . $post->post_type . '-not_in_sitemap']) && $options['post_types-' . $post->post_type . '-not_in_sitemap'] === true) {
         return;
     }
     if (WP_CACHE) {
         wp_schedule_single_event(time() + 300, 'YMBESEO_hit_sitemap_index');
     }
     // Allow the pinging to happen slightly after the hit sitemap index so the sitemap is fully regenerated when the ping happens.
     $excluded_posts = explode(',', $options['excluded-posts']);
     if (!in_array($post->ID, $excluded_posts)) {
         if (defined('YOAST_SEO_PING_IMMEDIATELY') && YOAST_SEO_PING_IMMEDIATELY) {
             YMBESEO_ping_search_engines();
         } else {
             wp_schedule_single_event(time() + 300, 'YMBESEO_ping_search_engines');
         }
     }
 }
Пример #11
0
 /**
  * Returns whether or not the breadcrumbs are active
  *
  * @return bool
  */
 public function breadcrumbs_active_callback()
 {
     $options = YMBESEO_Options::get_all();
     return true === (current_theme_supports('yoast-seo-breadcrumbs') || $options['breadcrumbs-enable']);
 }
Пример #12
0
/**
 * Instantiate the different social classes on the frontend
 */
function YMBESEO_frontend_head_init()
{
    $options = YMBESEO_Options::get_all();
    if ($options['twitter'] === true) {
        add_action('YMBESEO_head', array('YMBESEO_Twitter', 'get_instance'), 40);
    }
    if ($options['opengraph'] === true) {
        $GLOBALS['YMBESEO_og'] = new YMBESEO_OpenGraph();
    }
    if ($options['googleplus'] === true && is_singular()) {
        add_action('YMBESEO_head', array('YMBESEO_GooglePlus', 'get_instance'), 35);
    }
}
Пример #13
0
 /**
  * Retrieve the meta box form field definitions for the given tab and post type.
  *
  * @static
  *
  * @param  string $tab       Tab for which to retrieve the field definitions.
  * @param  string $post_type Post type of the current post.
  *
  * @return array             Array containing the meta box field definitions
  */
 public static function get_meta_field_defs($tab, $post_type = 'post')
 {
     if (!isset(self::$meta_fields[$tab])) {
         return array();
     }
     $field_defs = self::$meta_fields[$tab];
     switch ($tab) {
         case 'non-form':
             // Prevent non-form fields from being passed to forms.
             $field_defs = array();
             break;
         case 'general':
             $options = get_option('YMBESEO_titles');
             if ($options['usemetakeywords'] === true) {
                 /* Adjust the link in the keywords description text string based on the post type */
                 $field_defs['metakeywords']['description'] = sprintf($field_defs['metakeywords']['description'], '<a target="_blank" href="' . esc_url(admin_url('admin.php?page=YMBESEO_titles#top#post_types')) . '">', '</a>');
             } else {
                 /* Don't show the keywords field if keywords aren't enabled */
                 unset($field_defs['metakeywords']);
             }
             /**
              * Filter the WPSEO metabox form field definitions for the general tab, backward compatibility
              *
              * @deprecated 1.5.0
              * @deprecated use the 'YMBESEO_metabox_entries_general' filter instead
              * @see        YMBESEO_Meta::get_meta_field_defs()
              *
              * @param      array $field_defs Metabox orm definitions.
              *
              * @return     array
              */
             $field_defs = apply_filters('YMBESEO_metabox_entries', $field_defs);
             break;
         case 'advanced':
             global $post;
             $options = YMBESEO_Options::get_all();
             if (!current_user_can('manage_options') && $options['disableadvanced_meta']) {
                 return array();
             }
             $post_type = '';
             if (isset($post->post_type)) {
                 $post_type = $post->post_type;
             } elseif (!isset($post->post_type) && isset($_GET['post_type'])) {
                 $post_type = sanitize_text_field($_GET['post_type']);
             }
             /* Adjust the no-index 'default for post type' text string based on the post type */
             $field_defs['meta-robots-noindex']['options']['0'] = sprintf($field_defs['meta-robots-noindex']['options']['0'], isset($options['noindex-' . $post_type]) && $options['noindex-' . $post_type] === true ? 'noindex' : 'index');
             /* Adjust the robots advanced 'site-wide default' text string based on those settings */
             if ($options['noodp'] !== false || $options['noydir'] !== false) {
                 $robots_adv = array();
                 foreach (array('noodp', 'noydir') as $robot) {
                     if ($options[$robot] === true) {
                         // Use translation from field def options - mind that $options and $field_def['options'] keys should be the same!
                         $robots_adv[] = $field_defs['meta-robots-adv']['options'][$robot];
                     }
                 }
                 unset($robot);
                 $robots_adv = implode(', ', $robots_adv);
             } else {
                 $robots_adv = __('None', 'ymbeseo');
             }
             $field_defs['meta-robots-adv']['options']['-'] = sprintf($field_defs['meta-robots-adv']['options']['-'], $robots_adv);
             unset($robots_adv);
             /* Don't show the breadcrumb title field if breadcrumbs aren't enabled */
             if ($options['breadcrumbs-enable'] !== true) {
                 unset($field_defs['bctitle']);
             }
             global $post;
             if (empty($post->ID) || !empty($post->ID) && self::get_value('redirect', $post->ID) === '') {
                 unset($field_defs['redirect']);
             }
             break;
     }
     /**
      * Filter the WPSEO metabox form field definitions for a tab
      * {tab} can be 'general', 'advanced' or 'social'
      *
      * @param  array  $field_defs Metabox form definitions.
      * @param  string $post_type  Post type of the post the metabox is for, defaults to 'post'.
      *
      * @return array
      */
     return apply_filters('YMBESEO_metabox_entries_' . $tab, $field_defs, $post_type);
 }
Пример #14
0
 /**
  * Resets the entire class so canonicals, titles etc can be regenerated.
  */
 public function reset()
 {
     foreach (get_class_vars(__CLASS__) as $name => $default) {
         if ($name == 'instance') {
             self::$instance = null;
         } else {
             $this->{$name} = $default;
         }
     }
     $this->options = YMBESEO_Options::get_all();
 }
Пример #15
0
<?php

/**
 * @package YMBESEO\Admin
 */
if (!defined('YMBESEO_VERSION')) {
    header('Status: 403 Forbidden');
    header('HTTP/1.1 403 Forbidden');
    exit;
}
$options = YMBESEO_Options::get_all();
$yform = Yoast_Form::get_instance();
$yform->admin_header(true, 'YMBESEO_titles');
?>

	<h2 class="nav-tab-wrapper" id="wpseo-tabs">
		<a class="nav-tab" id="general-tab" href="#top#general"><?php 
_e('General', 'ymbeseo');
?>
</a>
		<a class="nav-tab" id="home-tab" href="#top#home"><?php 
_e('Homepage', 'ymbeseo');
?>
</a>
		<a class="nav-tab" id="post_types-tab" href="#top#post_types"><?php 
_e('Post Types', 'ymbeseo');
?>
</a>
		<a class="nav-tab" id="taxonomies-tab" href="#top#taxonomies"><?php 
_e('Taxonomies', 'ymbeseo');
?>
Пример #16
0
 /**
  * Class constructor
  */
 function __construct()
 {
     if (!defined('ENT_XML1')) {
         define('ENT_XML1', 16);
     }
     add_action('after_setup_theme', array($this, 'reduce_query_load'), 99);
     add_action('pre_get_posts', array($this, 'redirect'), 1);
     add_filter('redirect_canonical', array($this, 'canonical'));
     add_action('YMBESEO_hit_sitemap_index', array($this, 'hit_sitemap_index'));
     add_filter('YMBESEO_sitemap_exclude_author', array($this, 'user_sitemap_remove_excluded_authors'), 8);
     // Default stylesheet.
     $this->stylesheet = '<?xml-stylesheet type="text/xsl" href="' . preg_replace('/(^http[s]?:)/', '', esc_url(home_url('main-sitemap.xsl'))) . '"?>';
     $this->options = YMBESEO_Options::get_all();
     $this->max_entries = $this->options['entries-per-page'];
     $this->home_url = home_url();
     $this->charset = get_bloginfo('charset');
     $this->timezone = new YMBESEO_Sitemap_Timezone();
 }
Пример #17
0
 /**
  * Show the SEO inputs for term.
  *
  * @param object $term Term to show the edit boxes for.
  */
 function term_seo_form($term)
 {
     if ($this->tax_is_public() === false) {
         return;
     }
     $tax_meta = YMBESEO_Taxonomy_Meta::get_term_meta((int) $term->term_id, $term->taxonomy);
     $options = YMBESEO_Options::get_all();
     /* translators: %1$s expands to Yoast SEO */
     echo '<h3>', sprintf(__('%1$s Settings', 'ymbeseo'), 'Yoast SEO') . '</h3>';
     echo '<table class="form-table wpseo-taxonomy-form">';
     $this->form_row('YMBESEO_title', __('SEO Title', 'ymbeseo'), esc_html__('The SEO title is used on the archive page for this term.', 'ymbeseo'), $tax_meta);
     $this->form_row('YMBESEO_desc', __('SEO Description', 'ymbeseo'), esc_html__('The SEO description is used for the meta description on the archive page for this term.', 'ymbeseo'), $tax_meta);
     if ($options['usemetakeywords'] === true) {
         $this->form_row('YMBESEO_metakey', __('Meta keywords', 'ymbeseo'), esc_html__('Meta keywords used on the archive page for this term.', 'ymbeseo'), $tax_meta);
     }
     $this->form_row('YMBESEO_canonical', __('Canonical', 'ymbeseo'), esc_html__('The canonical link is shown on the archive page for this term.', 'ymbeseo'), $tax_meta);
     if ($options['breadcrumbs-enable'] === true) {
         $this->form_row('YMBESEO_bctitle', __('Breadcrumbs title', 'ymbeseo'), sprintf(esc_html__('The Breadcrumbs title is used in the breadcrumbs where this %s appears.', 'ymbeseo'), $term->taxonomy), $tax_meta);
     }
     $current = 'index';
     if (isset($options['noindex-tax-' . $term->taxonomy]) && $options['noindex-tax-' . $term->taxonomy] === true) {
         $current = 'noindex';
     }
     $noindex_options = $this->no_index_options;
     $noindex_options['default'] = sprintf($noindex_options['default'], $term->taxonomy, $current);
     $desc = sprintf(esc_html__('This %s follows the indexation rules set under Metas and Titles, you can override it here.', 'ymbeseo'), $term->taxonomy);
     if ('0' == get_option('blog_public')) {
         $desc .= '<br /><span class="error-message">' . esc_html__('Warning: even though you can set the meta robots setting here, the entire site is set to noindex in the sitewide privacy settings, so these settings won\'t have an effect.', 'ymbeseo') . '</span>';
     }
     $this->form_row('YMBESEO_noindex', sprintf(__('Noindex this %s', 'ymbeseo'), $term->taxonomy), $desc, $tax_meta, 'select', $noindex_options);
     unset($current, $no_index_options, $desc);
     $this->form_row('YMBESEO_sitemap_include', __('Include in sitemap?', 'ymbeseo'), '', $tax_meta, 'select', $this->sitemap_include_options);
     echo '</table>';
 }
Пример #18
0
 /**
  * Calculate the page analysis results for post.
  *
  * @todo [JRF => whomever] check whether the results of this method are always checked with is_wp_error()
  * @todo [JRF => whomever] check the usage of this method as it's quite intense/heavy, see if it's only
  * used when really necessary
  * @todo [JRF => whomever] see if we can get rid of the passing by reference of $results as it makes
  * the code obfuscated
  *
  * @param  object $post Post to calculate the results for.
  *
  * @return  array|WP_Error
  */
 function calculate_results($post)
 {
     $options = YMBESEO_Options::get_all();
     if (!class_exists('DOMDocument')) {
         $result = new WP_Error('no-domdocument', sprintf(__("Your hosting environment does not support PHP's %sDocument Object Model%s.", 'ymbeseo'), '<a href="http://php.net/manual/en/book.dom.php">', '</a>') . ' ' . __("To enjoy all the benefits of the page analysis feature, you'll need to (get your host to) install it.", 'ymbeseo'));
         return $result;
     }
     if (!is_array($post) && !is_object($post)) {
         $result = new WP_Error('no-post', __('No post content to analyse.', 'ymbeseo'));
         return $result;
     } elseif (self::get_value('focuskw', $post->ID) === '') {
         $result = new WP_Error('no-focuskw', sprintf(__('No focus keyword was set for this %s. If you do not set a focus keyword, no score can be calculated.', 'ymbeseo'), $post->post_type));
         self::set_value('linkdex', 0, $post->ID);
         return $result;
     } elseif (apply_filters('YMBESEO_use_page_analysis', true) !== true) {
         $result = new WP_Error('page-analysis-disabled', sprintf(__('Page Analysis has been disabled.', 'ymbeseo'), $post->post_type));
         return $result;
     }
     $results = array();
     $job = array();
     $sampleurl = $this->get_sample_permalink($post);
     $job['pageUrl'] = preg_replace('`%(?:post|page)name%`', $sampleurl[1], $sampleurl[0]);
     $job['pageSlug'] = urldecode($post->post_name);
     $job['keyword'] = self::get_value('focuskw', $post->ID);
     $job['keyword_folded'] = $this->strip_separators_and_fold($job['keyword']);
     $job['post_id'] = $post->ID;
     $job['post_type'] = $post->post_type;
     $dom = new domDocument();
     $dom->strictErrorChecking = false;
     $dom->preserveWhiteSpace = false;
     /**
      * Filter: 'YMBESEO_pre_analysis_post_content' - Make the post content filterable before calculating the page analysis
      *
      * @api string $post_content The post content
      *
      * @param object $post The post.
      */
     $post_content = apply_filters('YMBESEO_pre_analysis_post_content', $post->post_content, $post);
     // Check if the post content is not empty.
     if (!empty($post_content)) {
         @$dom->loadHTML($post_content);
     }
     unset($post_content);
     $xpath = new DOMXPath($dom);
     // Check if this focus keyword has been used already.
     $this->check_double_focus_keyword($job, $results);
     // Keyword.
     $this->score_keyword($job['keyword'], $results);
     // Title.
     $title = self::get_value('title', $post->ID);
     if ($title !== '') {
         $job['title'] = $title;
     } else {
         if (isset($options['title-' . $post->post_type]) && $options['title-' . $post->post_type] !== '') {
             $title_template = $options['title-' . $post->post_type];
         } else {
             $title_template = '%%title%% - %%sitename%%';
         }
         $job['title'] = YMBESEO_replace_vars($title_template, $post);
     }
     unset($title);
     $this->score_title($job, $results);
     // Meta description.
     $description = '';
     $desc_meta = self::get_value('metadesc', $post->ID);
     if ($desc_meta !== '') {
         $description = $desc_meta;
     } elseif (isset($options['metadesc-' . $post->post_type]) && $options['metadesc-' . $post->post_type] !== '') {
         $description = YMBESEO_replace_vars($options['metadesc-' . $post->post_type], $post);
     }
     unset($desc_meta);
     self::$meta_length = apply_filters('YMBESEO_metadesc_length', self::$meta_length, $post);
     $this->score_description($job, $results, $description, self::$meta_length);
     unset($description);
     // Body.
     $body = $this->get_body($post);
     $firstp = $this->get_first_paragraph($body);
     $this->score_body($job, $results, $body, $firstp);
     unset($firstp);
     // URL.
     $this->score_url($job, $results);
     // Headings.
     $headings = $this->get_headings($body);
     $this->score_headings($job, $results, $headings);
     unset($headings);
     // Images.
     $imgs = array();
     $imgs['count'] = substr_count($body, '<img');
     $imgs = $this->get_images_alt_text($post->ID, $body, $imgs);
     // Check featured image.
     if (function_exists('has_post_thumbnail') && has_post_thumbnail()) {
         $imgs['count'] += 1;
         if (empty($imgs['alts'])) {
             $imgs['alts'] = array();
         }
         $imgs['alts'][] = $this->strtolower_utf8(get_post_meta(get_post_thumbnail_id($post->ID), '_wp_attachment_image_alt', true));
     }
     $this->score_images_alt_text($job, $results, $imgs);
     unset($imgs);
     unset($body);
     // Anchors.
     $anchors = $this->get_anchor_texts($xpath);
     $count = $this->get_anchor_count($xpath);
     $this->score_anchor_texts($job, $results, $anchors, $count);
     unset($anchors, $count, $dom);
     $results = apply_filters('YMBESEO_linkdex_results', $results, $job, $post);
     $this->aasort($results, 'val');
     $overall = 0;
     $overall_max = 0;
     foreach ($results as $result) {
         $overall += $result['val'];
         $overall_max += 9;
     }
     unset($result);
     if ($overall < 1) {
         $overall = 1;
     }
     $score = YMBESEO_Utils::calc(YMBESEO_Utils::calc($overall, '/', $overall_max), '*', 100, true);
     if (!is_wp_error($score)) {
         self::set_value('linkdex', absint($score), $post->ID);
         $results['total'] = $score;
     }
     return $results;
 }
Пример #19
0
 /**
  * Clear entire XML sitemap cache
  *
  * @param array $types
  */
 public static function clear_sitemap_cache($types = array())
 {
     global $wpdb;
     if (wp_using_ext_object_cache()) {
         return;
     }
     if (!apply_filters('YMBESEO_enable_xml_sitemap_transient_caching', true)) {
         return;
     }
     // Not sure about efficiency, but that's what code elsewhere does R.
     $options = YMBESEO_Options::get_all();
     if (true !== $options['enablexmlsitemap']) {
         return;
     }
     $query = "DELETE FROM {$wpdb->options} WHERE";
     if (!empty($types)) {
         $first = true;
         foreach ($types as $sitemap_type) {
             if (!$first) {
                 $query .= ' OR ';
             }
             $query .= " option_name LIKE '_transient_YMBESEO_sitemap_cache_" . $sitemap_type . "_%' OR option_name LIKE '_transient_timeout_YMBESEO_sitemap_cache_" . $sitemap_type . "_%'";
             $first = false;
         }
     } else {
         $query .= " option_name LIKE '_transient_YMBESEO_sitemap_%' OR option_name LIKE '_transient_timeout_YMBESEO_sitemap_%'";
     }
     $wpdb->query($query);
 }
 /**
  * Add the inputs needed for SEO values to the User Profile page
  *
  * @param    object $user
  */
 public function user_profile($user)
 {
     $options = YMBESEO_Options::get_all();
     wp_nonce_field('YMBESEO_user_profile_update', 'YMBESEO_nonce');
     require_once 'views/user-profile.php';
 }
Пример #21
0
 /**
  * Class constructor
  */
 public function __construct()
 {
     $this->options = YMBESEO_Options::get_all();
     $this->twitter();
 }
Пример #22
0
/**
 * Retrieve all the options for the SEO plugin in one go.
 *
 * @deprecated 1.5.0
 * @deprecated use YMBESEO_Options::get_all()
 * @see        YMBESEO_Options::get_all()
 *
 * @return array of options
 */
function get_YMBESEO_options()
{
    _deprecated_function(__FUNCTION__, 'WPSEO 1.5.0', 'YMBESEO_Options::get_all()');
    return YMBESEO_Options::get_all();
}