/**
  * Checks if Yoast SEO is installed for the first time.
  */
 public function __construct()
 {
     $is_first_install = $this->is_first_install();
     if ($is_first_install && WPSEO_Utils::is_api_available()) {
         add_action('wpseo_activate', array($this, 'set_first_install_options'));
     }
 }
 /**
  * Get Home URL
  *
  * This has been moved from the constructor because wp_rewrite is not available on plugins_loaded in multisite.
  * It will now be requested on need and not on initialization.
  *
  * @return string
  */
 protected function get_home_url()
 {
     if (!isset($this->home_url)) {
         $this->home_url = WPSEO_Utils::home_url();
     }
     return $this->home_url;
 }
 /**
  * Get Home URL
  *
  * This has been moved from the constructor because wp_rewrite is not available on plugins_loaded in multisite.
  * It will now be requested on need and not on initialization.
  *
  * @return string
  */
 protected function get_home_url()
 {
     if (!isset(self::$home_url)) {
         self::$home_url = WPSEO_Utils::home_url();
     }
     return self::$home_url;
 }
Ejemplo n.º 4
0
 /**
  * Adding a new admin
  *
  * @param string $admin_name Name string.
  * @param string $admin_id   ID string.
  *
  * @return string
  */
 public function add_admin($admin_name, $admin_id)
 {
     $success = 0;
     // If one of the fields is empty.
     if (empty($admin_name) || empty($admin_id)) {
         $response_body = $this->get_response_body('not_present');
     } else {
         $admin_id = $this->parse_admin_id($admin_id);
         if (!isset($this->options['fb_admins'][$admin_id])) {
             $name = sanitize_text_field(urldecode($admin_name));
             $admin_id = sanitize_text_field($admin_id);
             if (preg_match('/[0-9]+?/', $admin_id) && preg_match('/[\\w\\s]+?/', $name)) {
                 $this->options['fb_admins'][$admin_id]['name'] = $name;
                 $this->options['fb_admins'][$admin_id]['link'] = urldecode('http://www.facebook.com/' . $admin_id);
                 $this->save_options();
                 $success = 1;
                 $response_body = $this->form->get_admin_link($admin_id, $this->options['fb_admins'][$admin_id]);
             } else {
                 $response_body = $this->get_response_body('invalid_format');
             }
         } else {
             $response_body = $this->get_response_body('already_exists');
         }
     }
     return WPSEO_Utils::json_encode(array('success' => $success, 'html' => $response_body));
 }
Ejemplo n.º 5
0
 /**
  * Constructor for the WPSEO_Local_Core class.
  *
  * @since 1.0
  */
 function __construct()
 {
     $this->options = get_option("wpseo_local");
     $this->days = array('monday' => __('Monday', 'yoast-local-seo'), 'tuesday' => __('Tuesday', 'yoast-local-seo'), 'wednesday' => __('Wednesday', 'yoast-local-seo'), 'thursday' => __('Thursday', 'yoast-local-seo'), 'friday' => __('Friday', 'yoast-local-seo'), 'saturday' => __('Saturday', 'yoast-local-seo'), 'sunday' => __('Sunday', 'yoast-local-seo'));
     if (wpseo_has_multiple_locations()) {
         add_action('init', array($this, 'create_custom_post_type'), 10, 1);
         add_action('init', array($this, 'create_taxonomies'), 10, 1);
         add_action('init', array($this, 'exclude_taxonomy'), 10, 1);
     }
     if (is_admin()) {
         $this->license_manager = $this->get_license_manager();
         $this->license_manager->setup_hooks();
         add_action('wpseo_licenses_forms', array($this->license_manager, 'show_license_form'));
         add_action('update_option_wpseo_local', array($this, 'save_permalinks_on_option_save'), 10, 2);
         // Setting action for removing the transient on update options
         if (method_exists('WPSEO_Utils', 'register_cache_clear_option')) {
             WPSEO_Utils::register_cache_clear_option('wpseo_local', 'kml');
         }
     } else {
         // XML Sitemap Index addition
         add_action('template_redirect', array($this, 'redirect_old_sitemap'));
         add_action('init', array($this, 'init'), 11);
         add_filter('wpseo_sitemap_index', array($this, 'add_to_index'));
     }
     // Add support for Jetpack's Omnisearch
     add_action('init', array($this, 'support_jetpack_omnisearch'));
     add_action('save_post', array($this, 'invalidate_sitemap'));
     // Run update if needed
     add_action('plugins_loaded', array(&$this, 'do_upgrade'), 14);
     // Extend the search with metafields
     add_action('pre_get_posts', array(&$this, 'enhance_search'));
     add_filter('the_excerpt', array(&$this, 'enhance_location_search_results'));
 }
 /**
  * Filter POST variables.
  *
  * @param string $var_name
  *
  * @return mixed
  */
 private function filter_input_post($var_name)
 {
     $val = filter_input(INPUT_POST, $var_name);
     if ($val) {
         return WPSEO_Utils::sanitize_text_field($val);
     }
     return '';
 }
Ejemplo n.º 7
0
    /**
     * Prints the pointer script
     *
     * @param string $selector The CSS selector the pointer is attached to.
     * @param array  $options  The options for the pointer.
     */
    public function print_scripts($selector, $options)
    {
        // Button1 is the close button, which always exists.
        $button_array_defaults = array('button2' => array('text' => false, 'function' => ''), 'button3' => array('text' => false, 'function' => ''));
        $this->button_array = wp_parse_args($this->button_array, $button_array_defaults);
        ?>
		<script type="text/javascript">
			//<![CDATA[
			(function ($) {
				// Don't show the tour on screens with an effective width smaller than 1024px or an effective height smaller than 768px.
				if (jQuery(window).width() < 1024 || jQuery(window).availWidth < 1024) {
					return;
				}

				var wpseo_pointer_options = <?php 
        echo WPSEO_Utils::json_encode($options);
        ?>
, setup;

				wpseo_pointer_options = $.extend(wpseo_pointer_options, {
					buttons: function (event, t) {
						var button = jQuery('<a href="<?php 
        echo $this->get_ignore_url();
        ?>
" id="pointer-close" style="margin:0 5px;" class="button-secondary">' + '<?php 
        _e('Close', 'wordpress-seo');
        ?>
' + '</a>');
						button.bind('click.pointer', function () {
							t.element.pointer('close');
						});
						return button;
					},
					close: function () {
					}
				});

				setup = function () {
					$('<?php 
        echo $selector;
        ?>
').pointer(wpseo_pointer_options).pointer('open');
					var lastOpenedPointer = jQuery( '.wp-pointer').slice( -1 );
					<?php 
        $this->button2();
        $this->button3();
        ?>
				};

				if (wpseo_pointer_options.position && wpseo_pointer_options.position.defer_loading)
					$(window).bind('load.wp-pointers', setup);
				else
					$(document).ready(setup);
			})(jQuery);
			//]]>
		</script>
	<?php 
    }
Ejemplo n.º 8
0
 /**
  * Make sure the needed scripts are loaded for admin pages
  */
 function init()
 {
     if (filter_input(INPUT_GET, 'wpseo_reset_defaults') && wp_verify_nonce(filter_input(INPUT_GET, 'nonce'), 'wpseo_reset_defaults') && current_user_can('manage_options')) {
         WPSEO_Options::reset();
         wp_redirect(admin_url('admin.php?page=wpseo_dashboard'));
     }
     if (WPSEO_Utils::grant_access()) {
         add_action('admin_enqueue_scripts', array($this, 'config_page_scripts'));
         add_action('admin_enqueue_scripts', array($this, 'config_page_styles'));
     }
 }
 /**
  * Retrieves post data given a post ID or the global
  *
  * @return array|null|WP_Post Returns a post if found, otherwise returns an empty array.
  */
 private function get_post()
 {
     if ($post = filter_input(INPUT_GET, 'post')) {
         $post_id = (int) WPSEO_Utils::validate_int($post);
         return get_post($post_id);
     }
     if (isset($GLOBALS['post'])) {
         return $GLOBALS['post'];
     }
     return array();
 }
 /**
  * Start recalculation
  */
 public function recalculate_scores()
 {
     check_ajax_referer('wpseo_recalculate', 'nonce');
     $fetch_object = $this->get_fetch_object();
     if (!empty($fetch_object)) {
         $paged = filter_input(INPUT_POST, 'paged', FILTER_VALIDATE_INT);
         $response = $fetch_object->get_items_to_recalculate($paged);
         if (!empty($response)) {
             wp_die(WPSEO_Utils::json_encode($response));
         }
     }
     wp_die('');
 }
Ejemplo n.º 11
0
 /**
  * Get the datetime object, in site's time zone, if the datetime string was valid
  *
  * @todo This is messed up, output type changed, doc wrong. Revert, add new method for formatted. R.
  *
  * @param string $datetime_string The datetime string in UTC time zone, that needs to be converted to a DateTime object.
  * @param string $format          Date format to use.
  *
  * @return DateTime|null in site's time zone
  */
 public function get_datetime_with_timezone($datetime_string, $format = 'c')
 {
     static $utc_timezone, $local_timezone;
     if (!isset($utc_timezone)) {
         $utc_timezone = new DateTimeZone('UTC');
         $local_timezone = new DateTimeZone($this->get_timezone_string());
     }
     if (!empty($datetime_string) && WPSEO_Utils::is_valid_datetime($datetime_string)) {
         $datetime = new DateTime($datetime_string, $utc_timezone);
         $datetime->setTimezone($local_timezone);
         return $datetime->format($format);
     }
     return null;
 }
Ejemplo n.º 12
0
 /**
  * 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';
         }
     }
 }
Ejemplo n.º 13
0
 /**
  * Run init logic.
  */
 public function init()
 {
     // Setting the screen option.
     if (filter_input(INPUT_GET, 'page') === 'wpseo_search_console') {
         if (filter_input(INPUT_GET, 'tab') !== 'settings' && WPSEO_GSC_Settings::get_profile() === '') {
             wp_redirect(add_query_arg('tab', 'settings'));
             exit;
         }
         $this->set_hooks();
         $this->set_dependencies();
         $this->request_handler();
     } elseif (WPSEO_Utils::is_yoast_seo_page() && current_user_can('manage_options') && WPSEO_GSC_Settings::get_profile() === '' && get_user_option('wpseo_dismissed_gsc_notice', get_current_user_id()) !== '1') {
         add_action('admin_init', array($this, 'register_gsc_notification'));
     }
     add_action('admin_init', array($this, 'register_settings'));
 }
Ejemplo n.º 14
0
 /**
  * Loads the required scripts for the config page.
  */
 function config_page_scripts()
 {
     $this->asset_manager->enqueue_script('admin-script');
     wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'admin-script', 'wpseoAdminL10n', $this->localize_admin_script());
     wp_enqueue_script('dashboard');
     wp_enqueue_script('thickbox');
     $page = filter_input(INPUT_GET, 'page');
     wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'admin-script', 'wpseoSelect2Locale', WPSEO_Utils::get_language(get_locale()));
     if (in_array($page, array('wpseo_social', WPSEO_Admin::PAGE_IDENTIFIER))) {
         wp_enqueue_media();
         $this->asset_manager->enqueue_script('admin-media');
         wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'admin-media', 'wpseoMediaL10n', $this->localize_media_script());
     }
     if ('wpseo_tools' === $page) {
         $this->enqueue_tools_scripts();
     }
 }
Ejemplo n.º 15
0
 /**
  * Load the introduction tour
  */
 function intro_tour()
 {
     global $pagenow, $current_user;
     // @FIXME: Links to tabs only work with target="_blank" and thus open in a new window
     $adminpages = array('wpseo_dashboard' => array('content' => '<h3>' . __('Dashboard', 'wordpress-seo') . '</h3><p>' . __('This is the WordPress SEO Dashboard, here you can restart this tour or revert the WP SEO settings to default.', 'wordpress-seo') . '</p>' . '<p><strong>' . __('More WordPress SEO', 'wordpress-seo') . '</strong><br/>' . sprintf(__('There&#8217;s more to learn about WordPress &amp; SEO than just using this plugin. A great start is our article %1$sthe definitive guide to WordPress SEO%2$s.', 'wordpress-seo'), '<a target="_blank" href="' . esc_url('https://yoast.com/articles/wordpress-seo/#utm_source=wpseo_dashboard&utm_medium=wpseo_tour&utm_campaign=tour') . '">', '</a>') . '</p>' . '<p><strong>' . __('Tracking', 'wordpress-seo') . '</strong><br/>' . __('To provide you with the best experience possible, we need your help. Please enable tracking to help us gather anonymous usage data.', 'wordpress-seo') . '</p>' . '<p><strong>' . __('Webmaster Tools', 'wordpress-seo') . '</strong><br/>' . __('You can also add the verification codes for the different Webmaster Tools programs here, we highly encourage you to check out both Google and Bing&#8217;s Webmaster Tools.', 'wordpress-seo') . '</p>' . '<p><strong>' . __('WordPress SEO Tour', 'wordpress-seo') . '</strong><br/>' . __('This tour will show you around in the plugin, to give you a general overview of the plugin.', 'wordpress-seo') . '</p>' . '<p><strong>' . __('Newsletter', 'wordpress-seo') . '</strong><br/>' . __('If you would like us to keep you up-to-date regarding WordPress SEO and other plugins by Yoast, subscribe to our newsletter:', 'wordpress-seo') . '</p>' . '<form action="http://yoast.us1.list-manage1.com/subscribe/post?u=ffa93edfe21752c921f860358&amp;id=972f1c9122" method="post" id="newsletter-form" accept-charset="' . esc_attr(get_bloginfo('charset')) . '">' . '<p>' . '<label for="newsletter-email">' . __('Email', 'wordpress-seo') . ':</label> <input style="margin: 5px; color:#666" name="EMAIL" value="' . esc_attr($current_user->user_email) . '" id="newsletter-email" placeholder="' . __('Email', 'wordpress-seo') . '"/><br/>' . '<input type="hidden" name="group" value="2"/>' . '<button type="submit" class="button-primary">' . __('Subscribe', 'wordpress-seo') . '</button>' . '</p></form>', 'next' => __('Next', 'wordpress-seo'), 'next_function' => 'window.location="' . admin_url('admin.php?page=wpseo_titles') . '";', 'position' => array('edge' => 'top', 'align' => 'center')), 'wpseo_titles' => array('content' => '<h3>' . __('Title &amp; Metas settings', 'wordpress-seo') . '</h3>' . '<p>' . __('This is where you set the titles and meta-information for all your post types, taxonomies, archives, special pages and for your homepage. The page is divided into different tabs. Make sure you check &#8217;em all out!', 'wordpress-seo') . '</p>' . '<p><strong>' . __('Sitewide settings', 'wordpress-seo') . '</strong><br/>' . __('The first tab will show you site-wide settings. You can also set some settings for the entire site here to add specific meta tags or to remove some unneeded cruft.', 'wordpress-seo') . '</p>' . '<p><strong>' . __('Templates and settings', 'wordpress-seo') . '</strong><br/>' . sprintf(__('Now click on the &#8216;%1$sPost Types%2$s&#8217;-tab, as this will be our example.', 'wordpress-seo'), '<a target="_blank" href="' . esc_url(admin_url('admin.php?page=wpseo_titles#top#post_types')) . '">', '</a>') . '<br />' . __('The templates are built using variables. You can find all these variables in the help tab (in the top-right corner of the page). The settings allow you to set specific behavior for the post types.', 'wordpress-seo') . '</p>', 'next' => __('Next', 'wordpress-seo'), 'next_function' => 'window.location="' . admin_url('admin.php?page=wpseo_social') . '";', 'prev' => __('Previous', 'wordpress-seo'), 'prev_function' => 'window.location="' . admin_url('admin.php?page=wpseo_dashboard') . '";'), 'wpseo_social' => array('content' => '<h3>' . __('Social settings', 'wordpress-seo') . '</h3>' . '<p><strong>' . __('Facebook', 'wordpress-seo') . '</strong><br/>' . sprintf(__('On this tab you can enable the %1$sFacebook Open Graph%2$s functionality from this plugin, as well as assign a Facebook user or Application to be the admin of your site, so you can view the Facebook insights.', 'wordpress-seo'), '<a target="_blank" href="' . esc_url('https://yoast.com/facebook-open-graph-protocol/#utm_source=wpseo_social&utm_medium=wpseo_tour&utm_campaign=tour') . '">', '</a>') . '</p><p>' . __('The frontpage settings allow you to set meta-data for your homepage, whereas the default settings allow you to set a fallback for all posts/pages without images. ', 'wordpress-seo') . '</p>' . '<p><strong>' . __('Twitter', 'wordpress-seo') . '</strong><br/>' . sprintf(__('With %1$sTwitter Cards%2$s, you can attach rich photos, videos and media experience to tweets that drive traffic to your website. Simply check the box, sign up for the service, and users who Tweet links to your content will have a &#8220;Card&#8221; added to the tweet that&#8217;s visible to all of their followers.', 'wordpress-seo'), '<a target="_blank" href="' . esc_url('https://yoast.com/twitter-cards/#utm_source=wpseo_social&utm_medium=wpseo_tour&utm_campaign=tour') . '">', '</a>') . '</p>' . '<p><strong>' . __('Google+', 'wordpress-seo') . '</strong><br/>' . sprintf(__('This tab allows you to add specific post meta data for Google+. And if you have a Google+ page for your business, add that URL here and link it on your %1$sGoogle+%2$s page&#8217;s about page.', 'wordpress-seo'), '<a target="_blank" href="' . esc_url('https://plus.google.com/') . '">', '</a>') . '</p>', 'next' => __('Next', 'wordpress-seo'), 'next_function' => 'window.location="' . admin_url('admin.php?page=wpseo_xml') . '";', 'prev' => __('Previous', 'wordpress-seo'), 'prev_function' => 'window.location="' . admin_url('admin.php?page=wpseo_titles') . '";'), 'wpseo_xml' => array('content' => '<h3>' . __('XML Sitemaps', 'wordpress-seo') . '</h3>' . '<p><strong>' . __('What are XML sitemaps?', 'wordpress-seo') . '</strong><br/>' . __('A Sitemap is an XML file that lists the URLs for a site. It allows webmasters to include additional information about each URL: when it was last updated, how often it changes, and how important it is in relation to other URLs in the site. This allows search engines to crawl the site more intelligently.', 'wordpress-seo') . '</p>' . '<p><strong>' . __('What does the plugin do with XML Sitemaps?', 'wordpress-seo') . '</strong><br/>' . __('This plugin adds XML sitemaps to your site. The sitemaps are automatically updated when you publish a new post, page or custom post and Google and Bing will be automatically notified. You can also have the plugin automatically notify Yahoo! and Ask.com.', 'wordpress-seo') . '</p><p>' . __('If you want to exclude certain post types and/or taxonomies, you can also set that on this page.', 'wordpress-seo') . '</p><p>' . __('Is your webserver low on memory? Decrease the entries per sitemap (default: 1000) to reduce load.', 'wordpress-seo') . '</p>', 'next' => __('Next', 'wordpress-seo'), 'next_function' => 'window.location="' . admin_url('admin.php?page=wpseo_permalinks') . '";', 'prev' => __('Previous', 'wordpress-seo'), 'prev_function' => 'window.location="' . admin_url('admin.php?page=wpseo_social') . '";'), 'wpseo_permalinks' => array('content' => '<h3>' . __('Permalink Settings', 'wordpress-seo') . '</h3><p>' . __('All of the options here are for advanced users only, if you don&#8217;t know whether you should check any, don&#8217;t touch them.', 'wordpress-seo') . '</p>', 'next' => __('Next', 'wordpress-seo'), 'next_function' => 'window.location="' . admin_url('admin.php?page=wpseo_internal-links') . '";', 'prev' => __('Previous', 'wordpress-seo'), 'prev_function' => 'window.location="' . admin_url('admin.php?page=wpseo_xml') . '";'), 'wpseo_internal-links' => array('content' => '<h3>' . __('Breadcrumbs Settings', 'wordpress-seo') . '</h3><p>' . sprintf(__('If your theme supports my breadcrumbs, as all Genesis and WooThemes themes as well as a couple of other ones do, you can change the settings for those here. If you want to modify your theme to support them, %sfollow these instructions%s.', 'wordpress-seo'), '<a target="_blank" href="' . esc_url('https://yoast.com/wordpress/plugins/breadcrumbs/#utm_source=wpseo_permalinks&utm_medium=wpseo_tour&utm_campaign=tour') . '">', '</a>') . '</p>', 'next' => __('Next', 'wordpress-seo'), 'next_function' => 'window.location="' . admin_url('admin.php?page=wpseo_rss') . '";', 'prev' => __('Previous', 'wordpress-seo'), 'prev_function' => 'window.location="' . admin_url('admin.php?page=wpseo_permalinks') . '";'), 'wpseo_rss' => array('content' => '<h3>' . __('RSS Settings', 'wordpress-seo') . '</h3><p>' . __('This incredibly powerful function allows you to add content to the beginning and end of your posts in your RSS feed. This helps you gain links from people who steal your content!', 'wordpress-seo') . '</p>', 'next' => __('Next', 'wordpress-seo'), 'next_function' => 'window.location="' . admin_url('admin.php?page=wpseo_import') . '";', 'prev' => __('Previous', 'wordpress-seo'), 'prev_function' => 'window.location="' . admin_url('admin.php?page=wpseo_internal-links') . '";'), 'wpseo_import' => array('content' => '<h3>' . esc_html__('Import & Export', 'wordpress-seo') . '</h3>' . '<p><strong>' . __('Import from other (SEO) plugins', 'wordpress-seo') . '</strong><br/>' . __('We can imagine that you switch from another SEO plugin to WordPress SEO. If you just did, you can use these options to transfer your SEO-data. If you were using one of my older plugins like Robots Meta &amp; RSS Footer, you can import the settings here too.', 'wordpress-seo') . '</p>' . '<p><strong>' . __('Other imports', 'wordpress-seo') . '</strong><br/>' . sprintf(__('If you&#8217;re using one of our premium plugins, such as %1$sLocal SEO%2$s, you can also find specific import-options for that plugin here.', 'wordpress-seo'), '<a target="_blank" href="' . esc_url('https://yoast.com/wordpress/plugins/local-seo/#utm_source=wpseo_import&utm_medium=wpseo_tour&utm_campaign=tour') . '">', '</a>') . '</p>' . '<p><strong>' . __('Export', 'wordpress-seo') . '</strong><br/>' . __('If you have multiple blogs and you&#8217;re happy with how you&#8217;ve configured this blog, you can export the settings and import them on another blog so you don&#8217;t have to go through this process twice!', 'wordpress-seo') . '</p>', 'next' => __('Next', 'wordpress-seo'), 'next_function' => 'window.location="' . network_admin_url('admin.php?page=wpseo_bulk-editor') . '";', 'prev' => __('Previous', 'wordpress-seo'), 'prev_function' => 'window.location="' . admin_url('admin.php?page=wpseo_rss') . '";'), 'wpseo_bulk-editor' => array('content' => '<h3>' . __('Bulk Editor', 'wordpress-seo') . '</h3><p>' . __('This page lets you view and edit the titles and meta descriptions of all posts and pages on your site. This allows you to edit the title or meta description of all your pages in one place, rather than having to edit each individual page.', 'wordpress-seo') . '</p>', 'next' => __('Next', 'wordpress-seo'), 'next_function' => 'window.location="' . admin_url('admin.php?page=wpseo_files') . '";', 'prev' => __('Previous', 'wordpress-seo'), 'prev_function' => 'window.location="' . admin_url('admin.php?page=wpseo_import') . '";'), 'wpseo_files' => array('content' => '<h3>' . __('File Editor', 'wordpress-seo') . '</h3><p>' . __('Here you can edit the .htaccess and robots.txt files, two of the most powerful files in your WordPress install, if your WordPress installation has write-access to the files. But please, only touch these files if you know what you&#8217;re doing!', 'wordpress-seo') . '</p>', 'next' => __('Next', 'wordpress-seo'), 'next_function' => 'window.location="' . admin_url('admin.php?page=wpseo_licenses') . '";', 'prev' => __('Previous', 'wordpress-seo'), 'prev_function' => 'window.location="' . admin_url('admin.php?page=wpseo_bulk-editor') . '";'), 'wpseo_licenses' => array('content' => '<h3>' . __('Extensions and Licenses', 'wordpress-seo') . '</h3>' . '<p><strong>' . __('Extensions', 'wordpress-seo') . '</strong><br/>' . sprintf(__('The powerful functions of WordPress SEO can be extended with %1$sYoast premium plugins%2$s. These premium plugins require the installation of WordPress SEO or WordPress SEO Premium and add specific functionality. You can read all about the Yoast Premium Plugins on %1$shttp://yoast.com/wordpress/plugins/%2$s.', 'wordpress-seo'), '<a target="_blank" href="' . esc_url('https://yoast.com/wordpress/plugins/#utm_source=wpseo_licenses&utm_medium=wpseo_tour&utm_campaign=tour') . '">', '</a>') . '</p>' . '<p><strong>' . __('Licenses', 'wordpress-seo') . '</strong><br/>' . __('Once you&#8217;ve purchased WordPress SEO Premium or any other premium Yoast plugin, you&#8217;ll have to enter a license key. You can do so on the Licenses-tab. Once you&#8217;ve activated your premium plugin, you can use all its powerful features.', 'wordpress-seo') . '</p>' . '<p><strong>' . __('Like this plugin?', 'wordpress-seo') . '</strong><br/>' . sprintf(__('So, we&#8217;ve come to the end of the tour. If you like the plugin, please %srate it 5 stars on WordPress.org%s!', 'wordpress-seo'), '<a target="_blank" href="https://wordpress.org/plugins/wordpress-seo/">', '</a>') . '</p>' . '<p>' . sprintf(__('Thank you for using my plugin and good luck with your SEO!<br/><br/>Best,<br/>Team Yoast - %1$sYoast.com%2$s', 'wordpress-seo'), '<a target="_blank" href="' . esc_url('https://yoast.com/#utm_source=wpseo_licenses&utm_medium=wpseo_tour&utm_campaign=tour') . '">', '</a>') . '</p>', 'prev' => __('Previous', 'wordpress-seo'), 'prev_function' => 'window.location="' . admin_url('admin.php?page=wpseo_files') . '";'));
     // Skip tour about wpseo_files page if file editing is disallowed or if the site is a multisite and the current user isn't a superadmin
     if (false === WPSEO_Utils::allow_system_file_edit()) {
         unset($adminpages['wpseo_files']);
         $adminpages['wpseo_bulk-editor']['function'] = 'window.location="' . admin_url('admin.php?page=wpseo_licenses') . '";';
     }
     $page = '';
     if (isset($_GET['page'])) {
         $page = $_GET['page'];
     }
     $button_array = array('button1' => array('text' => __('Close', 'wordpress-seo'), 'function' => ''));
     $opt_arr = array();
     $id = '#wpseo-title';
     if ('admin.php' != $pagenow || !array_key_exists($page, $adminpages)) {
         $id = 'li.toplevel_page_wpseo_dashboard';
         $content = '<h3>' . __('Congratulations!', 'wordpress-seo') . '</h3>';
         $content .= '<p>' . __('You&#8217;ve just installed WordPress SEO by Yoast! Click &#8220;Start Tour&#8221; to view a quick introduction of this plugin&#8217;s core functionality.', 'wordpress-seo') . '</p>';
         $opt_arr = array('content' => $content, 'position' => array('edge' => 'bottom', 'align' => 'center'));
         $button_array['button2']['text'] = __('Start Tour', 'wordpress-seo');
         $button_array['button2']['function'] = 'document.location="' . admin_url('admin.php?page=wpseo_dashboard') . '";';
     } else {
         if ('' != $page && in_array($page, array_keys($adminpages))) {
             $align = is_rtl() ? 'left' : 'right';
             $opt_arr = array('content' => $adminpages[$page]['content'], 'position' => isset($adminpages[$page]['position']) ? $adminpages[$page]['position'] : array('edge' => 'top', 'align' => $align), 'pointerWidth' => 450);
             if (isset($adminpages[$page]['next']) && isset($adminpages[$page]['next_function'])) {
                 $button_array['button2'] = array('text' => $adminpages[$page]['next'], 'function' => $adminpages[$page]['next_function']);
             }
             if (isset($adminpages[$page]['prev']) && isset($adminpages[$page]['prev_function'])) {
                 $button_array['button3'] = array('text' => $adminpages[$page]['prev'], 'function' => $adminpages[$page]['prev_function']);
             }
         }
     }
     $this->print_scripts($id, $opt_arr, $button_array);
 }
Ejemplo n.º 16
0
 /**
  * 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';
         }
     }
 }
Ejemplo n.º 17
0
 /**
  * Validate the post meta values
  *
  * @static
  *
  * @param  mixed  $meta_value The new value.
  * @param  string $meta_key   The full meta key (including prefix).
  *
  * @return string             Validated meta value
  */
 public static function sanitize_post_meta($meta_value, $meta_key)
 {
     $field_def = self::$meta_fields[self::$fields_index[$meta_key]['subset']][self::$fields_index[$meta_key]['key']];
     $clean = self::$defaults[$meta_key];
     switch (true) {
         case $meta_key === self::$meta_prefix . 'linkdex':
             $int = WPSEO_Utils::validate_int($meta_value);
             if ($int !== false && $int >= 0) {
                 $clean = strval($int);
                 // Convert to string to make sure default check works.
             }
             break;
         case $field_def['type'] === 'checkbox':
             // Only allow value if it's one of the predefined options.
             if (in_array($meta_value, array('on', 'off'), true)) {
                 $clean = $meta_value;
             }
             break;
         case $field_def['type'] === 'select' || $field_def['type'] === 'radio':
             // Only allow value if it's one of the predefined options.
             if (isset($field_def['options'][$meta_value])) {
                 $clean = $meta_value;
             }
             break;
         case $field_def['type'] === 'multiselect' && $meta_key === self::$meta_prefix . 'meta-robots-adv':
             $clean = self::validate_meta_robots_adv($meta_value);
             break;
         case $field_def['type'] === 'text' && $meta_key === self::$meta_prefix . 'canonical':
         case $field_def['type'] === 'text' && $meta_key === self::$meta_prefix . 'redirect':
             // Validate as url(-part).
             $url = WPSEO_Utils::sanitize_url($meta_value);
             if ($url !== '') {
                 $clean = $url;
             }
             break;
         case $field_def['type'] === 'upload' && $meta_key === self::$meta_prefix . 'opengraph-image':
             // Validate as url.
             $url = WPSEO_Utils::sanitize_url($meta_value, array('http', 'https', 'ftp', 'ftps'));
             if ($url !== '') {
                 $clean = $url;
             }
             break;
         case $field_def['type'] === 'textarea':
             if (is_string($meta_value)) {
                 // Remove line breaks and tabs.
                 // @todo [JRF => Yoast] verify that line breaks and the likes aren't allowed/recommended in meta header fields.
                 $meta_value = str_replace(array("\n", "\r", "\t", '  '), ' ', $meta_value);
                 $clean = WPSEO_Utils::sanitize_text_field(trim($meta_value));
             }
             break;
         case 'multiselect' === $field_def['type']:
             $clean = $meta_value;
             break;
         case $field_def['type'] === 'text':
         default:
             if (is_string($meta_value)) {
                 $clean = WPSEO_Utils::sanitize_text_field(trim($meta_value));
             }
             if ($meta_key === self::$meta_prefix . 'focuskw') {
                 $clean = str_replace(array('&lt;', '&gt;', '&quot', '&#96', '<', '>', '"', '`'), '', $clean);
             }
             break;
     }
     $clean = apply_filters('wpseo_sanitize_post_meta_' . $meta_key, $clean, $meta_value, $field_def, $meta_key);
     return $clean;
 }
 /**
  * Validate the option
  *
  * @param  array $dirty New value for the option.
  * @param  array $clean Clean value for the option, normally the defaults.
  * @param  array $old   Old value of the option.
  *
  * @return  array      Validated clean value for the option to be saved to the database
  */
 protected function validate_option($dirty, $clean, $old)
 {
     foreach ($clean as $key => $value) {
         switch ($key) {
             case 'version':
                 $clean[$key] = WPSEO_VERSION;
                 break;
             case 'blocking_files':
                 /**
                  * @internal [JRF] to really validate this we should also do a file_exists()
                  * on each array entry and remove files which no longer exist, but that might be overkill
                  */
                 if (isset($dirty[$key]) && is_array($dirty[$key])) {
                     $clean[$key] = array_unique($dirty[$key]);
                 } elseif (isset($old[$key]) && is_array($old[$key])) {
                     $clean[$key] = array_unique($old[$key]);
                 }
                 break;
             case 'company_or_person':
                 if (isset($dirty[$key]) && $dirty[$key] !== '') {
                     if (in_array($dirty[$key], array('company', 'person'))) {
                         $clean[$key] = $dirty[$key];
                     }
                 }
                 break;
                 /* text fields */
             /* text fields */
             case 'company_name':
             case 'person_name':
             case 'website_name':
             case 'alternate_website_name':
                 if (isset($dirty[$key]) && $dirty[$key] !== '') {
                     $clean[$key] = sanitize_text_field($dirty[$key]);
                 }
                 break;
             case 'company_logo':
                 $this->validate_url($key, $dirty, $old, $clean);
                 break;
                 /* verification strings */
             /* verification strings */
             case 'googleverify':
             case 'msverify':
             case 'yandexverify':
                 $this->validate_verification_string($key, $dirty, $old, $clean);
                 break;
                 /*
                 				Boolean dismiss warnings - not fields - may not be in form
                 					   (and don't need to be either as long as the default is false)
                 */
             /*
             				Boolean dismiss warnings - not fields - may not be in form
             					   (and don't need to be either as long as the default is false)
             */
             case 'ms_defaults_set':
                 if (isset($dirty[$key])) {
                     $clean[$key] = WPSEO_Utils::validate_bool($dirty[$key]);
                 } elseif (isset($old[$key])) {
                     $clean[$key] = WPSEO_Utils::validate_bool($old[$key]);
                 }
                 break;
             case 'site_type':
                 $clean[$key] = '';
                 if (isset($dirty[$key]) && in_array($dirty[$key], $this->site_types, true)) {
                     $clean[$key] = $dirty[$key];
                 }
                 break;
             case 'environment_type':
                 $clean[$key] = '';
                 if (isset($dirty[$key]) && in_array($dirty[$key], $this->environment_types, true)) {
                     $clean[$key] = $dirty[$key];
                 }
                 break;
                 /*
                 Boolean (checkbox) fields
                 */
                 /*
                 				Covers
                 * 		'disableadvanced_meta'
                 * 		'yoast_tracking'
                 */
             /*
             Boolean (checkbox) fields
             */
             /*
             				Covers
             * 		'disableadvanced_meta'
             * 		'yoast_tracking'
             */
             default:
                 $clean[$key] = isset($dirty[$key]) ? WPSEO_Utils::validate_bool($dirty[$key]) : false;
                 break;
         }
     }
     return $clean;
 }
Ejemplo n.º 19
0
/**
 * Standardize whitespace in a string
 *
 * @deprecated 1.6.1
 * @deprecated use WPSEO_Utils::standardize_whitespace()
 * @see WPSEO_Utils::standardize_whitespace()
 *
 * @since 1.6.0
 *
 * @param string $string
 *
 * @return string
 */
function wpseo_standardize_whitespace($string)
{
    _deprecated_function(__FUNCTION__, 'WPSEO 1.6.1', 'WPSEO_Utils::standardize_whitespace()');
    return WPSEO_Utils::standardize_whitespace($string);
}
 /**
  * @covers WPSEO_Utils::trim_nbsp_from_string()
  */
 public function test_wpseo_trim_nbsp_from_string()
 {
     $old_string = ' This is an old string with&nbsp;as spaces.&nbsp;';
     $expected = 'This is an old string with as spaces.';
     $this->assertEquals($expected, WPSEO_Utils::trim_nbsp_from_string($old_string));
 }
Ejemplo n.º 21
0
 /**
  * Retrieves the home URL
  *
  * @return string
  */
 private function get_home_url()
 {
     /**
      * Filter: 'wpseo_json_home_url' - Allows filtering of the home URL for Yoast SEO's JSON+LD output
      *
      * @api unsigned string
      */
     return apply_filters('wpseo_json_home_url', WPSEO_Utils::home_url());
 }
Ejemplo n.º 22
0
 /**
  * Validate the option
  *
  * @param  array $dirty New value for the option.
  * @param  array $clean Clean value for the option, normally the defaults.
  * @param  array $old   Old value of the option.
  *
  * @return  array      Validated clean value for the option to be saved to the database
  */
 protected function validate_option($dirty, $clean, $old)
 {
     foreach ($clean as $key => $value) {
         switch ($key) {
             /* Automagic Facebook connect key */
             case 'fbconnectkey':
                 if (isset($old[$key]) && $old[$key] !== '' && preg_match('`^[a-f0-9]{32}$`', $old[$key]) > 0) {
                     $clean[$key] = $old[$key];
                 } else {
                     $clean[$key] = self::get_fbconnectkey();
                 }
                 break;
                 /* Will not always exist in form */
             /* Will not always exist in form */
             case 'fb_admins':
                 if (isset($dirty[$key]) && is_array($dirty[$key])) {
                     if ($dirty[$key] === array()) {
                         $clean[$key] = array();
                     } else {
                         foreach ($dirty[$key] as $user_id => $fb_array) {
                             /*
                              * @todo [JRF/JRF => Yoast/whomever] add user_id validation -
                              * are these WP user-ids or FB user-ids ? Probably FB user-ids,
                              * if so, find out the rules for FB user-ids
                              */
                             if (is_array($fb_array) && $fb_array !== array()) {
                                 foreach ($fb_array as $fb_key => $fb_value) {
                                     switch ($fb_key) {
                                         case 'name':
                                             /**
                                              * @todo [JRF => whomever] add validation for name based
                                              * on rules if there are any
                                              * Input comes from: $_GET['userrealname']
                                              */
                                             $clean[$key][$user_id][$fb_key] = sanitize_text_field($fb_value);
                                             break;
                                         case 'link':
                                             $clean[$key][$user_id][$fb_key] = WPSEO_Utils::sanitize_url($fb_value);
                                             break;
                                     }
                                 }
                             }
                         }
                         unset($user_id, $fb_array, $fb_key, $fb_value);
                     }
                 } elseif (isset($old[$key]) && is_array($old[$key])) {
                     $clean[$key] = $old[$key];
                 }
                 break;
                 /* text fields */
             /* text fields */
             case 'og_frontpage_desc':
             case 'og_frontpage_title':
                 if (isset($dirty[$key]) && $dirty[$key] !== '') {
                     $clean[$key] = WPSEO_Utils::sanitize_text_field($dirty[$key]);
                 }
                 break;
                 /* url text fields - no ftp allowed */
             /* url text fields - no ftp allowed */
             case 'facebook_site':
             case 'instagram_url':
             case 'linkedin_url':
             case 'myspace_url':
             case 'pinterest_url':
             case 'plus-publisher':
             case 'og_default_image':
             case 'og_frontpage_image':
             case 'youtube_url':
             case 'google_plus_url':
                 $this->validate_url($key, $dirty, $old, $clean);
                 break;
             case 'pinterestverify':
                 $this->validate_verification_string($key, $dirty, $old, $clean);
                 break;
                 /* twitter user name */
             /* twitter user name */
             case 'twitter_site':
                 if (isset($dirty[$key]) && $dirty[$key] !== '') {
                     $twitter_id = sanitize_text_field(ltrim($dirty[$key], '@'));
                     /**
                      * From the Twitter documentation about twitter screen names:
                      * Typically a maximum of 15 characters long, but some historical accounts
                      * may exist with longer names.
                      * A username can only contain alphanumeric characters (letters A-Z, numbers 0-9)
                      * with the exception of underscores
                      *
                      * @link https://support.twitter.com/articles/101299-why-can-t-i-register-certain-usernames
                      * @link https://dev.twitter.com/docs/platform-objects/users
                      */
                     if (preg_match('`^[A-Za-z0-9_]{1,25}$`', $twitter_id)) {
                         $clean[$key] = $twitter_id;
                     } elseif (preg_match('`^http(?:s)?://(?:www\\.)?twitter\\.com/(?P<handle>[A-Za-z0-9_]{1,25})/?$`', $twitter_id, $matches)) {
                         $clean[$key] = $matches['handle'];
                     } else {
                         if (isset($old[$key]) && $old[$key] !== '') {
                             $twitter_id = sanitize_text_field(ltrim($old[$key], '@'));
                             if (preg_match('`^[A-Za-z0-9_]{1,25}$`', $twitter_id)) {
                                 $clean[$key] = $twitter_id;
                             }
                         }
                         if (function_exists('add_settings_error')) {
                             add_settings_error($this->group_name, '_' . $key, sprintf(__('%s does not seem to be a valid Twitter user-id. Please correct.', 'wordpress-seo'), '<strong>' . esc_html(sanitize_text_field($dirty[$key])) . '</strong>'), 'error');
                         }
                     }
                     unset($twitter_id);
                 }
                 break;
             case 'twitter_card_type':
                 if (isset($dirty[$key], self::$twitter_card_types[$dirty[$key]]) && $dirty[$key] !== '') {
                     $clean[$key] = $dirty[$key];
                 }
                 break;
                 /* boolean fields */
             /* boolean fields */
             case 'opengraph':
             case 'twitter':
                 $clean[$key] = isset($dirty[$key]) ? WPSEO_Utils::validate_bool($dirty[$key]) : false;
                 break;
         }
     }
     /**
      * Only validate 'fbadminapp', so leave the clean default.
      */
     if (isset($dirty['fbadminapp']) && !empty($dirty['fbadminapp'])) {
         $clean['fbadminapp'] = $dirty['fbadminapp'];
     }
     return $clean;
 }
Ejemplo n.º 23
0
 /**
  * Display an OpenGraph image tag
  *
  * @param string $img - Source URL to the image
  *
  * @return bool
  */
 private function add_image($img)
 {
     // Filter: 'wpseo_opengraph_image' - Allow changing the OpenGraph image */
     $img = trim(apply_filters('wpseo_opengraph_image', $img));
     if (empty($img)) {
         return false;
     }
     if (WPSEO_Utils::is_url_relative($img) === true) {
         $img = $this->get_relative_path($img);
     }
     if (in_array($img, $this->images)) {
         return false;
     }
     array_push($this->images, $img);
     return true;
 }
    printf($statistic['title'], intval($statistic['count']));
    ?>
				</a>
			</th>
			<td class="post-count">
				<?php 
    echo absint($statistic['count']);
    ?>
			</td>
		</tr>
	<?php 
}
?>
</table>
<?php 
if (WPSEO_Utils::grant_access()) {
    ?>
<div class="onpage">
	<h4 class="hide-if-no-js"><?php 
    printf(__('Indexability check by %1$s', 'wordpress-seo'), 'OnPage.org');
    ?>
</h4>

	<div>
		<?php 
    /**
     * @var array $onpage Array containing the indexable and can_fetch value.
     */
    switch ($onpage['indexable']) {
        case WPSEO_OnPage_Option::IS_INDEXABLE:
            echo '<div class="wpseo-score-icon good"></div>';
/**
 * Check whether file editing is allowed for the .htaccess and robots.txt files
 *
 * @deprecated 1.5.6.1
 * @deprecated use WPSEO_Utils::allow_system_file_edit()
 * @see        WPSEO_Utils::allow_system_file_edit()
 *
 * @internal   current_user_can() checks internally whether a user is on wp-ms and adjusts accordingly.
 *
 * @return bool
 */
function wpseo_allow_system_file_edit()
{
    _deprecated_function(__FUNCTION__, 'WPSEO 1.5.6.1', 'WPSEO_Utils::allow_system_file_edit()');
    return WPSEO_Utils::allow_system_file_edit();
}
Ejemplo n.º 26
0
 /**
  * Clear rewrites
  *
  * @deprecated 1.5.0
  * @deprecated use WPSEO_Utils::clear_rewrites()
  * @see        WPSEO_Utils::clear_rewrites()
  */
 function clear_rewrites()
 {
     _deprecated_function(__METHOD__, 'WPSEO 1.5.0', 'WPSEO_Utils::clear_rewrites()');
     WPSEO_Utils::clear_rewrites();
 }
Ejemplo n.º 27
0
 /**
  * Should the notice being given?
  *
  * @return bool
  */
 protected function should_show_notice()
 {
     // If development note is on or the tagline notice is shown, just don't show this notice.
     if (WPSEO_Utils::is_development_mode() || '0' === get_option('blog_public')) {
         return false;
     }
     return WPSEO_Utils::grant_access() && !$this->user_has_dismissed() && $this->onpage_option->get_status() === WPSEO_OnPage_Option::IS_NOT_INDEXABLE;
 }
Ejemplo n.º 28
0
/**
 * On deactivation, flush the rewrite rules so XML sitemaps stop working.
 */
function _wpseo_deactivate()
{
    require_once WPSEO_PATH . 'inc/wpseo-functions.php';
    if (is_multisite() && ms_is_switched()) {
        delete_option('rewrite_rules');
    } else {
        add_action('shutdown', 'flush_rewrite_rules');
    }
    wpseo_remove_capabilities();
    // Clear cache so the changes are obvious.
    WPSEO_Utils::clear_cache();
    do_action('wpseo_deactivate');
}
Ejemplo n.º 29
0
 /**
  * Hook that runs after the 'wpseo_redirect' option is updated
  *
  * @param array $old_value
  * @param array $value
  */
 public function save_redirect_files($old_value, $value)
 {
     // Check if we need to remove the WPSEO redirect entries from the .htacccess file.
     $remove_htaccess_entries = false;
     // Check if the 'disable_php_redirect' option set to true/on.
     if (null != $value && isset($value['disable_php_redirect']) && 'on' == $value['disable_php_redirect']) {
         // Remove .htaccess entries if the 'separate_file' option is set to true.
         if (WPSEO_Utils::is_apache() && isset($value['separate_file']) && 'on' == $value['separate_file']) {
             $remove_htaccess_entries = true;
         }
         // The 'disable_php_redirect' option is set to true(on) so we need to generate a file.
         // The Redirect Manager will figure out what file needs to be created.
         $redirect_manager = new WPSEO_URL_Redirect_Manager();
         $redirect_manager->save_redirect_file();
     } else {
         if (WPSEO_Utils::is_apache()) {
             // No settings are set so we should also strip the .htaccess redirect entries in this case.
             $remove_htaccess_entries = true;
         }
     }
     // Check if we need to remove the .htaccess redirect entries.
     if ($remove_htaccess_entries) {
         // Remove the .htaccess redirect entries.
         $redirect_manager = new WPSEO_URL_Redirect_Manager();
         $redirect_manager->clear_htaccess_entries();
     }
 }
Ejemplo n.º 30
0
/**
 * On deactivation, flush the rewrite rules so XML sitemaps stop working.
 */
function _wpseo_deactivate()
{
    require_once WPSEO_PATH . 'inc/wpseo-functions.php';
    add_action('shutdown', 'flush_rewrite_rules');
    wpseo_remove_capabilities();
    // Force unschedule
    WPSEO_Utils::schedule_yoast_tracking(null, get_option('wpseo'), true);
    // Clear cache so the changes are obvious.
    WPSEO_Utils::clear_cache();
    do_action('wpseo_deactivate');
}