/** * Post Connector constructor */ public function __construct() { // Load autoloader require_once self::get_core_dir() . '/classes/class-autoloader.php'; // Setup premium autoloader $autoloader = new SP_Autoloader(self::get_premium_dir()); $autoloader = new SP_Autoloader(self::get_premium_dir()); if (version_compare(PHP_VERSION, '5.3', '>=')) { spl_autoload_register(array($autoloader, 'load'), true, true); } else { spl_autoload_register(array($autoloader, 'load'), true); } // Do the parent int parent::init(); // Load deprecated file require_once self::get_premium_dir() . 'deprecated.php'; // Setup premium manager hooks $premium_manager_hook = new SP_Manager_Hook(self::get_premium_dir() . 'classes/hooks/'); $premium_manager_hook->load_hooks(); // Setup premium manager filters $manager_filter = new SP_Manager_Filter(self::get_premium_dir() . 'classes/filters/'); $manager_filter->load_filters(); // Widgets $manager_widget = new SP_Manager_Widget(self::get_premium_dir() . 'classes/widgets/'); $manager_widget->load(); // Setup the license hooks $license_manager = new Yoast_Plugin_License_Manager(new SP_Product_Post_Connector()); $license_manager->setup_hooks(); // Plugin upgrader if (is_admin()) { $premium_upgrade_manager = new SP_Premium_Upgrade_Manager(); $premium_upgrade_manager->check_update(); } }
/** * Function that outputs the redirect page */ public static function display() { // Licensing part. $license_manager = new Yoast_Plugin_License_Manager(new WPSEO_Product_Premium()); // Setup constant name. $license_manager->set_license_constant_name('WPSEO_LICENSE'); // Admin header. Yoast_Form::get_instance()->admin_header(false); if ($license_manager->license_is_valid()) { ?> <div class="wpseo_content_cell"> <iframe src="//fast.wistia.net/embed/playlists/5t35e24abt?media_0_0%5BautoPlay%5D=false&media_0_0%5BcontrolsVisibleOnLoad%5D=false&theme=bento&version=v1&videoOptions%5BautoPlay%5D=true&videoOptions%5BvideoHeight%5D=450&videoOptions%5BvideoWidth%5D=800&videoOptions%5BvolumeControl%5D=true" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_playlist" name="wistia_playlist" allowfullscreen mozallowfullscreen webkitallowfullscreen oallowfullscreen msallowfullscreen width="1107" height="450"></iframe> <br class="clear"> </div> <br class="clear"> <?php } else { echo '<div class="wpseo-warning">'; /* translators: %s: 'Yoast SEO Premium' */ echo '<h2>' . sprintf(__('%s is inactive.', 'wordpress-seo-premium'), 'Yoast SEO Premium') . '</h2>'; if (current_user_can('manage_options')) { /* translators: %s: 'Yoast SEO Premium' */ echo '<p>' . sprintf(__('Please activate %s to be able to see the videos.', 'wordpress-seo-premium'), 'Yoast SEO Premium') . '</p></div>'; } else { /* translators: %s: 'Yoast SEO Premium' */ echo '<p>' . sprintf(__('Please ask your site administrator to activate %s to be able to see the videos.', 'wordpress-seo-premium'), 'Yoast SEO Premium') . '</p></div>'; } } // Admin footer. Yoast_Form::get_instance()->admin_footer(false); }
/** * Function that outputs the redirect page */ public static function display() { global $wpseo_admin_pages; // Licensing part $license_manager = new Yoast_Plugin_License_Manager(new WPSEO_Product_Premium()); // Setup constant name $license_manager->set_license_constant_name('WPSEO_LICENSE'); // Admin header $wpseo_admin_pages->admin_header(false); if ($license_manager->license_is_valid()) { ?> <div class="wpseo_content_cell"> <iframe src="//fast.wistia.net/embed/playlists/anhtprp59b?media_0_0%5BautoPlay%5D=false&media_0_0%5BcontrolsVisibleOnLoad%5D=false&theme=bento&version=v1&videoOptions%5BautoPlay%5D=true&videoOptions%5BvideoHeight%5D=450&videoOptions%5BvideoWidth%5D=800&videoOptions%5BvolumeControl%5D=true" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_playlist" name="wistia_playlist" allowfullscreen mozallowfullscreen webkitallowfullscreen oallowfullscreen msallowfullscreen width="1107" height="488"></iframe> <br class="clear"> </div> <br class="clear"> <?php } else { echo '<div class="wpseo-warning">'; echo '<h2>' . __('WordPress SEO Premium is inactive.', 'wordpress-seo') . '</h2>'; if (current_user_can('manage_options')) { echo '<p>' . __('Please activate WordPress SEO Premium to be able to see the videos.', 'wordpress-seo') . '</p></div>'; } else { echo '<p>' . __('Please ask your site administrator to activate WordPress SEO Premium to be able to see the videos.', 'wordpress-seo') . '</p></div>'; } } // Admin footer $wpseo_admin_pages->admin_footer(false); }
/** * Setting up the license manager * * @since 3.0 */ protected function setup_license_manager() { $license_manager = new Yoast_Plugin_License_Manager($this); $license_manager->setup_hooks(); add_filter('yst_ga_extension_status', array($this, 'filter_extension_is_active'), 10, 1); add_action('yst_ga_show_license_form', array($this, 'action_show_license_form')); $this->license_manager = $license_manager; }
/** * Returns info about the Yoast SEO plugin version and license * * @return string */ private function get_yoast_seo_info() { $license_manager = new Yoast_Plugin_License_Manager(new WPSEO_Product_Premium()); $out = '<table>'; $out .= '<tr><td>Version</td><td>' . WPSEO_VERSION . '</td></tr>'; $out .= '<tr><td>License</td><td>' . '<a href=" ' . admin_url('admin.php?page=wpseo_licenses#top#licenses') . ' ">' . $license_manager->get_license_key() . '</a>' . '</td></tr>'; $out .= '<tr><td>Status</td><td>' . $license_manager->get_license_status() . '</td></tr>'; $out .= '</table>'; return $out; }
/** * Generates the sidebar for admin pages. */ function admin_sidebar() { // No banners in Premium if (class_exists('WPSEO_Product_Premium')) { $license_manager = new Yoast_Plugin_License_Manager(new WPSEO_Product_Premium()); if ($license_manager->license_is_valid()) { return; } } $service_banners = array(array('url' => 'https://yoast.com/hire-us/website-review/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=website-review-banner', 'img' => 'banner-website-review.png', 'alt' => 'Website Review banner')); $plugin_banners = array(array('url' => 'https://yoast.com/wordpress/plugins/seo-premium/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=premium-seo-banner', 'img' => 'banner-premium-seo.png', 'alt' => 'Banner WordPress SEO Premium')); if (!class_exists('wpseo_Video_Sitemap')) { $plugin_banners[] = array('url' => 'https://yoast.com/wordpress/plugins/video-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=video-seo-banner', 'img' => 'banner-video-seo.png', 'alt' => 'Banner WordPress SEO Video SEO extension'); } if (!class_exists('wpseo_Video_Manual')) { $plugin_banners[] = array('url' => 'https://yoast.com/wordpress/plugins/video-manual-wordpress-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=video-manual-banner', 'img' => 'banner-video-seo-manual.png', 'alt' => 'Banner WordPress SEO Video manual'); } if (class_exists('Woocommerce') && !class_exists('Yoast_WooCommerce_SEO')) { $plugin_banners[] = array('url' => 'https://yoast.com/wordpress/plugins/yoast-woocommerce-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=woocommerce-seo-banner', 'img' => 'banner-woocommerce-seo.png', 'alt' => 'Banner WooCommerce SEO plugin'); } if (!defined('WPSEO_LOCAL_VERSION')) { $plugin_banners[] = array('url' => 'https://yoast.com/wordpress/plugins/local-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=local-seo-banner', 'img' => 'banner-local-seo.png', 'alt' => 'Banner Local SEO plugin'); } if (!class_exists('WPSEO_News')) { $plugin_banners[] = array('url' => 'https://yoast.com/wordpress/plugins/news-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=news-seo-banner', 'img' => 'banner-news-seo.png', 'alt' => 'Banner News SEO'); } if (!class_exists('Post_Connector')) { $plugin_banners[] = array('url' => 'https://yoast.com/wordpress/plugins/post-connector/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=post-connector-banner', 'img' => 'banner-post-connector.png', 'alt' => 'Banner Post Connector plugin'); } shuffle($service_banners); shuffle($plugin_banners); ?> <div class="wpseo_content_cell" id="sidebar-container"> <div id="sidebar"> <?php $service_banner = $service_banners[0]; echo '<a target="_blank" href="' . esc_url($service_banner['url']) . '"><img width="261" height="190" src="' . plugins_url('images/' . $service_banner['img'], WPSEO_FILE) . '" alt="' . esc_attr($service_banner['alt']) . '"/></a><br/><br/>'; $i = 0; foreach ($plugin_banners as $banner) { if ($i == 2) { break; } echo '<a target="_blank" href="' . esc_url($banner['url']) . '"><img width="261" src="' . plugins_url('images/' . $banner['img'], WPSEO_FILE) . '" alt="' . esc_attr($banner['alt']) . '"/></a><br/><br/>'; $i++; } ?> <?php echo __('Remove these ads?', 'wordpress-seo') . '<br/>'; echo '<a target="_blank" href="https://yoast.com/wordpress/plugins/seo-premium/#utm_source=wordpress-seo-config&utm_medium=textlink&utm_campaign=remove-ads-link">' . __('Upgrade to WordPress SEO Premium »', 'wordpress-seo') . '</a><br/><br/>'; ?> </div> </div> <?php }
/** * Returns info about the Yoast SEO plugin version and license * * @param Yoast_Product $product The product to return information for. * * @return string */ private function get_product_info(Yoast_Product $product) { if (!class_exists('Yoast_Plugin_License_Manager')) { return 'License manager could not be loaded'; } $license_manager = new Yoast_Plugin_License_Manager($product); $out = '<table>'; $out .= '<tr><td>Version</td><td>' . WPSEO_VERSION . '</td></tr>'; $out .= '<tr><td>License</td><td>' . '<a href=" ' . admin_url('admin.php?page=wpseo_licenses#top#licenses') . ' ">' . $license_manager->get_license_key() . '</a>' . '</td></tr>'; $out .= '<tr><td>Status</td><td>' . $license_manager->get_license_status() . '</td></tr>'; $out .= '</table>'; return $out; }
/** * An update is required, do it * * @param $current_version */ private function do_update($current_version) { // < 1.0.4 if ($current_version < 5) { /** * Upgrade to version 1.0.4 * * - Save the old license to the new license option */ // Save the old license to the new license option $license_manager = new Yoast_Plugin_License_Manager(new WPSEO_Product_Premium()); $license_manager->set_license_key(trim(get_option('wpseo_license_key', ''))); $license_manager->set_license_status(trim(get_option('wpseo_license_status', ''))); // Remove old license options delete_option('wpseo_license_key'); delete_option('wpseo_license_status'); } // Upgrade to version 1.2.0 if ($current_version < 15) { /** * Upgrade redirects */ // URL Redirects $url_redirect_manager = new WPSEO_URL_Redirect_Manager(); $url_redirects = $url_redirect_manager->get_redirects(); // Loop through the redirects foreach ($url_redirects as $old_url => $redirect) { // Check if the redirect is not an array yet if (!is_array($redirect)) { $url_redirects[$old_url] = array('url' => $redirect, 'type' => '301'); } } // Save the URL redirects $url_redirect_manager->save_redirects($url_redirects); // Regex Redirects $regex_redirect_manager = new WPSEO_REGEX_Redirect_Manager(); $regex_redirects = $regex_redirect_manager->get_redirects(); // Loop through the redirects foreach ($regex_redirects as $old_url => $redirect) { // Check if the redirect is not an array yet if (!is_array($redirect)) { $regex_redirects[$old_url] = array('url' => $redirect, 'type' => '301'); } } // Save the URL redirects $regex_redirect_manager->save_redirects($regex_redirects); } }
/** * Shows license page */ public function show_license_page() { // Instantiate license class $license_manager = new Yoast_Plugin_License_Manager(new Sample_Product()); ?> <div class="wrap"> <?php //settings_errors(); ?> <?php $license_manager->show_license_form(false); ?> </div> <?php }
/** * Perform upgrade procedures to the settings */ function upgrade() { // upgrade license options if ($this->license_manager && $this->license_manager->license_is_valid() == false) { if (isset($this->options['license-status'])) { $this->license_manager->set_license_status($this->options['license-status']); } if (isset($this->options['license'])) { $this->license_manager->set_license_key($this->options['license']); } } // upgrade to new wp seo option class $this->option_instance->clean(); }
/** * Output the screen */ public function output_screen() { ?> <div class="wrap"> <h2>Post Connector - <?php _e('License settings', 'post-connector'); ?> </h2> <?php settings_errors(); ?> <div class="pc-content"> <?php $license_manager = new Yoast_Plugin_License_Manager(new SP_Product_Post_Connector()); $license_manager->show_license_form(false); ?> </div> <?php SP_Admin_Menu::get()->sidebar(); ?> </div> <?php }
/** * Add a link to the settings page to the plugins list * * @staticvar string $this_plugin holds the directory & filename for the plugin * * @param array $links array of links for the plugins, adapted when the current plugin is found. * @param string $file the filename for the current plugin, which the filter loops through. * * @return array $links */ function add_action_link($links, $file) { if (WPSEO_BASENAME === $file && WPSEO_Options::grant_access()) { $settings_link = '<a href="' . esc_url(admin_url('admin.php?page=wpseo_dashboard')) . '">' . __('Settings', 'wordpress-seo') . '</a>'; array_unshift($links, $settings_link); } if (class_exists('Yoast_Product_WPSEO_Premium')) { $license_manager = new Yoast_Plugin_License_Manager(new Yoast_Product_WPSEO_Premium()); if ($license_manager->license_is_valid()) { return $links; } } // add link to premium support landing page $premium_link = '<a href="https://yoast.com/wordpress/plugins/seo-premium/support/#utm_source=wordpress-seo-settings-link&utm_medium=text-link&utm_campaign=support-link">' . __('Premium Support', 'wordpress-seo') . '</a>'; array_unshift($links, $premium_link); // add link to docs $faq_link = '<a href="https://yoast.com/wordpress/plugins/seo/faq/">' . __('FAQ', 'wordpress-seo') . '</a>'; array_unshift($links, $faq_link); return $links; }
/** * Setup the Yoast SEO premium plugin */ private function setup() { // Setup autoloader. require_once dirname(__FILE__) . '/classes/class-premium-autoloader.php'; $autoloader = new WPSEO_Premium_Autoloader(); spl_autoload_register(array($autoloader, 'load')); $this->load_textdomain(); $this->instantiate_redirects(); if (is_admin()) { // Disable Yoast SEO add_action('admin_init', array($this, 'disable_wordpress_seo'), 1); // Add Sub Menu page and add redirect page to admin page array. // This should be possible in one method in the future, see #535. add_filter('wpseo_submenu_pages', array($this, 'add_submenu_pages')); // Add Redirect page as admin page. add_filter('wpseo_admin_pages', array($this, 'add_admin_pages')); // Post to Get on search. add_action('admin_init', array($this, 'list_table_search_post_to_get')); // Add input fields to page meta post types. add_action('wpseo_admin_page_meta_post_types', array($this, 'admin_page_meta_post_types_checkboxes'), 10, 2); // Add page analysis fields to variable array key patterns. add_filter('wpseo_option_titles_variable_array_key_patterns', array($this, 'add_variable_array_key_pattern')); // Filter the Page Analysis content. add_filter('wpseo_pre_analysis_post_content', array($this, 'filter_page_analysis'), 10, 2); // Settings. add_action('admin_init', array($this, 'register_settings')); // Check if we need to save files after updating options. add_action('update_option_wpseo_redirect', array($this, 'save_redirect_files'), 10, 2); // Catch option save. add_action('admin_init', array($this, 'catch_option_redirect_save')); // Screen options $query_var = ($page = filter_input(INPUT_GET, 'page')) ? $page : ''; switch ($query_var) { case 'wpseo_redirects': add_filter('set-screen-option', array('WPSEO_Page_Redirect', 'set_screen_option'), 11, 3); break; } // Enqueue Post and Term overview script. add_action('admin_enqueue_scripts', array($this, 'enqueue_overview_script')); // Licensing part. $license_manager = new Yoast_Plugin_License_Manager(new WPSEO_Product_Premium()); // Setup constant name. $license_manager->set_license_constant_name('WPSEO_LICENSE'); // Setup license hooks. $license_manager->setup_hooks(); // Add this plugin to licensing form. add_action('wpseo_licenses_forms', array($license_manager, 'show_license_form')); if ($license_manager->license_is_valid()) { add_action('admin_head', array($this, 'admin_css')); } // Add Premium imports. $premium_import_manager = new WPSEO_Premium_Import_Manager(); // Allow option of importing from other 'other' plugins. add_filter('wpseo_import_other_plugins', array($premium_import_manager, 'filter_add_premium_import_options')); // Handle premium imports. add_action('wpseo_handle_import', array($premium_import_manager, 'do_premium_imports')); // Add htaccess import block. add_action('wpseo_import_tab_content', array($premium_import_manager, 'add_htaccess_import_block')); add_action('wpseo_import_tab_header', array($premium_import_manager, 'htaccess_import_header')); // Only activate post and term watcher if permalink structure is enabled. if (get_option('permalink_structure')) { add_action('admin_init', array($this, 'init_watchers')); // Check if we need to display an admin message if ($redirect_created = filter_input(INPUT_GET, 'yoast-redirect-created')) { // Message object $message = new WPSEO_Message_Redirect_Created($redirect_created); add_action('all_admin_notices', array($message, 'display')); } } } else { // Add 404 redirect link to WordPress toolbar. add_action('admin_bar_menu', array($this, 'admin_bar_menu'), 96); add_filter('redirect_canonical', array($this, 'redirect_canonical_fix'), 1, 2); } }
/** * Initialize the admin page */ private function init_admin() { // Edit Post JS global $pagenow; if ('post.php' == $pagenow || 'post-new.php' == $pagenow) { add_action('admin_head', array($this, 'edit_post_css')); add_action('admin_enqueue_scripts', array($this, 'enqueue_edit_post')); } // Upgrade Manager $upgrade_manager = new WPSEO_News_Upgrade_Manager(); $upgrade_manager->check_update(); // License Manager $license_manager = new Yoast_Plugin_License_Manager(new WPSEO_News_Product()); $license_manager->setup_hooks(); add_action('wpseo_licenses_forms', array($license_manager, 'show_license_form')); // 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_news', $this->get_sitemap_name(false)); } }
/** * Setup the premium WordPress SEO plugin */ private function setup() { // Setup autoloader require_once dirname(__FILE__) . '/classes/class-premium-autoloader.php'; $autoloader = new WPSEO_Premium_Autoloader(); spl_autoload_register(array($autoloader, 'load')); if (is_admin()) { // Upgrade Manager $plugin_updater = new WPSEO_Upgrade_Manager(); $plugin_updater->check_update(); // Create pages $this->page_gwt = new WPSEO_Page_GWT(); // Disable WordPress SEO add_action('admin_init', array($this, 'disable_wordpress_seo'), 1); // Add Sub Menu page and add redirect page to admin page array // This should be possible in one method in the future, see #535 add_filter('wpseo_submenu_pages', array($this, 'add_submenu_pages')); // Add Redirect page as admin page add_filter('wpseo_admin_pages', array($this, 'add_admin_pages')); // Post to Get on search add_action('admin_init', array($this, 'list_table_search_post_to_get')); // Add the GWT crawl error post type add_action('admin_init', array($this, 'register_gwt_crawl_error_post_type')); // Add input fields to page meta post types add_action('wpseo_admin_page_meta_post_types', array($this, 'admin_page_meta_post_types_checkboxes'), 10, 2); // Add page analysis fields to variable array key patterns add_filter('wpseo_option_titles_variable_array_key_patterns', array($this, 'add_variable_array_key_pattern')); // Filter the Page Analysis content add_filter('wpseo_pre_analysis_post_content', array($this, 'filter_page_analysis'), 10, 2); // Check if WPSEO_DISABLE_PHP_REDIRECTS is defined if (defined('WPSEO_DISABLE_PHP_REDIRECTS') && true === WPSEO_DISABLE_PHP_REDIRECTS) { // Change the normal redirect autoload option $normal_redirect_manager = new WPSEO_URL_Redirect_Manager(); $normal_redirect_manager->redirects_change_autoload(false); // Change the regex redirect autoload option $regex_redirect_manager = new WPSEO_REGEX_Redirect_Manager(); $regex_redirect_manager->redirects_change_autoload(false); } else { $options = WPSEO_Redirect_Manager::get_options(); // If the disable_php_redirect option is not enabled we should enable auto loading redirects if ('off' == $options['disable_php_redirect']) { // Change the normal redirect autoload option $normal_redirect_manager = new WPSEO_URL_Redirect_Manager(); $normal_redirect_manager->redirects_change_autoload(true); // Change the regex redirect autoload option $regex_redirect_manager = new WPSEO_REGEX_Redirect_Manager(); $regex_redirect_manager->redirects_change_autoload(true); } } // Settings add_action('admin_init', array($this, 'register_settings')); // Check if we need to save files after updating options add_action('update_option_wpseo_redirect', array($this, 'save_redirect_files'), 10, 2); // Catch option save add_action('admin_init', array($this, 'catch_option_redirect_save')); // Screen options $query_var = !empty($_GET['page']) ? $_GET['page'] : ''; switch ($query_var) { case 'wpseo_redirects': add_filter('set-screen-option', array('WPSEO_Page_Redirect', 'set_screen_option'), 11, 3); break; case 'wpseo_webmaster_tools': add_filter('set-screen-option', array($this->page_gwt, 'set_screen_option'), 11, 3); break; } // Enqueue Post and Term overview script add_action('admin_enqueue_scripts', array($this, 'enqueue_overview_script')); // Licensing part $license_manager = new Yoast_Plugin_License_Manager(new WPSEO_Product_Premium()); // Setup constant name $license_manager->set_license_constant_name('WPSEO_LICENSE'); // Setup license hooks $license_manager->setup_hooks(); // Add this plugin to licensing form add_action('wpseo_licenses_forms', array($license_manager, 'show_license_form')); if ($license_manager->license_is_valid()) { add_action('admin_head', array($this, 'admin_css')); } // Crawl Issue Manager AJAX hooks $crawl_issue_manager = new WPSEO_Crawl_Issue_Manager(); add_action('wp_ajax_wpseo_ignore_crawl_issue', array($crawl_issue_manager, 'ajax_ignore_crawl_issue')); add_action('wp_ajax_wpseo_unignore_crawl_issue', array($crawl_issue_manager, 'ajax_unignore_crawl_issue')); // Add Premium imports $premium_import_manager = new WPSEO_Premium_Import_Manager(); // Allow option of importing from other 'other' plugins add_filter('wpseo_import_other_plugins', array($premium_import_manager, 'filter_add_premium_import_options')); // Handle premium imports add_action('wpseo_handle_import', array($premium_import_manager, 'do_premium_imports')); // Add htaccess import block add_action('wpseo_import', array($premium_import_manager, 'add_htaccess_import_block')); // Only activate post and term watcher if permalink structure is enabled if (get_option('permalink_structure')) { // The Post Watcher $post_watcher = new WPSEO_Post_Watcher(); // Add old URL field to post edit screen add_action('edit_form_advanced', array($post_watcher, 'old_url_field'), 10, 1); add_action('edit_page_form', array($post_watcher, 'old_url_field'), 10, 1); // Detect a post slug change add_action('post_updated', array($post_watcher, 'detect_slug_change'), 12, 3); // Detect a post trash add_action('trashed_post', array($post_watcher, 'detect_post_trash')); // Detect a post untrash add_action('untrashed_post', array($post_watcher, 'detect_post_untrash')); // Detect a post delete add_action('delete_post', array($post_watcher, 'detect_post_delete')); // The Term Watcher $term_watcher = new WPSEO_Term_Watcher(); // Get all taxonomies $taxonomies = get_taxonomies(); // Loop through all taxonomies if (count($taxonomies) > 0) { foreach ($taxonomies as $taxonomy) { // Add old URL field to term edit screen add_action($taxonomy . '_edit_form_fields', array($term_watcher, 'old_url_field'), 10, 2); } } // Detect the term slug change add_action('edited_term', array($term_watcher, 'detect_slug_change'), 10, 3); // Detect a term delete add_action('delete_term_taxonomy', array($term_watcher, 'detect_term_delete')); // Check if we need to display an admin message if (isset($_GET['yoast-redirect-created'])) { // Message object $message = new WPSEO_Message_Redirect_Created($_GET['yoast-redirect-created']); add_action('all_admin_notices', array($message, 'display')); } } } else { // Catch redirect $normal_redirect_manager = new WPSEO_URL_Redirect_Manager(); add_action('template_redirect', array($normal_redirect_manager, 'do_redirects')); // Catch redirect $regex_redirect_manager = new WPSEO_REGEX_Redirect_Manager(); add_action('template_redirect', array($regex_redirect_manager, 'do_redirects')); // Add 404 redirect link to WordPress toolbar add_action('admin_bar_menu', array($this, 'admin_bar_menu'), 96); add_filter('redirect_canonical', array($this, 'redirect_canonical_fix'), 1, 2); } // Normal Redirect AJAX $redirect_manager = new WPSEO_URL_Redirect_Manager(); add_action('wp_ajax_wpseo_save_redirect_url', array($redirect_manager, 'ajax_handle_redirect_save')); add_action('wp_ajax_wpseo_delete_redirect_url', array($redirect_manager, 'ajax_handle_redirect_delete')); add_action('wp_ajax_wpseo_create_redirect_url', array($redirect_manager, 'ajax_handle_redirect_create')); // Regex Redirect AJAX $redirect_manager = new WPSEO_REGEX_Redirect_Manager(); add_action('wp_ajax_wpseo_save_redirect_regex', array($redirect_manager, 'ajax_handle_redirect_save')); add_action('wp_ajax_wpseo_delete_redirect_regex', array($redirect_manager, 'ajax_handle_redirect_delete')); add_action('wp_ajax_wpseo_create_redirect_regex', array($redirect_manager, 'ajax_handle_redirect_create')); // Add URL reponse code check AJAX add_action('wp_ajax_wpseo_check_url', array('WPSEO_Url_Checker', 'check_url')); }
/** * Execute upgrade actions when needed */ function upgrade() { $options = get_option('wpseo_video'); // early bail if dbversion is equal to current version if (isset($options['dbversion']) && version_compare($options['dbversion'], WPSEO_VIDEO_VERSION, '==')) { return; } $yoast_product = new Yoast_Product_WPSEO_Video(); $license_manager = new Yoast_Plugin_License_Manager($yoast_product); // upgrade to license manager if ($license_manager->get_license_key() === '') { if (isset($options['yoast-video-seo-license'])) { $license_manager->set_license_key($options['yoast-video-seo-license']); } if (isset($options['yoast-video-seo-license-status'])) { $license_manager->set_license_status($options['yoast-video-seo-license-status']); } update_option('wpseo_video', $options); } // upgrade to new option & meta classes if (!isset($options['dbversion']) || version_compare($options['dbversion'], '1.6', '<')) { $this->option_instance->clean(); WPSEO_Meta::clean_up(); // Make sure our meta values are cleaned up even if WP SEO would have been upgraded already } // Re-add missing durations if (!isset($options['dbversion']) || version_compare($options['dbversion'], '1.7', '<') && version_compare($options['dbversion'], '1.6', '>')) { WPSEO_Meta_Video::re_add_durations(); } // Recommend re-index if (isset($options['dbversion']) && version_compare($options['dbversion'], '1.8', '<')) { set_transient('video_seo_recommend_reindex', 1); } // Make sure version nr gets updated for any version without specific upgrades $options = get_option('wpseo_video'); // re-get to make sure we have the latest version if (version_compare($options['dbversion'], WPSEO_VIDEO_VERSION, '<')) { $options['dbversion'] = WPSEO_VIDEO_VERSION; update_option('wpseo_video', $options); } }
/** * Add a link to the settings page to the plugins list * * @staticvar string $this_plugin holds the directory & filename for the plugin * * @param array $links array of links for the plugins, adapted when the current plugin is found. * @param string $file the filename for the current plugin, which the filter loops through. * * @return array $links */ function add_action_link($links, $file) { if (WPSEO_BASENAME === $file && WPSEO_Utils::grant_access()) { $settings_link = '<a href="' . esc_url(admin_url('admin.php?page=' . self::PAGE_IDENTIFIER)) . '">' . __('Settings', 'wordpress-seo') . '</a>'; array_unshift($links, $settings_link); } if (class_exists('WPSEO_Product_Premium')) { $license_manager = new Yoast_Plugin_License_Manager(new WPSEO_Product_Premium()); if ($license_manager->license_is_valid()) { return $links; } } // Add link to premium support landing page. $premium_link = '<a href="https://yoast.com/wordpress/plugins/seo-premium/support/#utm_source=wordpress-seo-settings-link&utm_medium=textlink&utm_campaign=support-link">' . __('Premium Support', 'wordpress-seo') . '</a>'; array_unshift($links, $premium_link); // Add link to docs. $faq_link = '<a href="https://kb.yoast.com/kb/category/yoast-seo/#utm_source=wordpress-seo-faq-link&utm_medium=textlink&utm_campaign=faq-link">' . __('FAQ', 'wordpress-seo') . '</a>'; array_unshift($links, $faq_link); return $links; }
/** * Add a link to the settings page to the plugins list * * @staticvar string $this_plugin holds the directory & filename for the plugin * * @param array $links array of links for the plugins, adapted when the current plugin is found. * @param string $file the filename for the current plugin, which the filter loops through. * @return array $links */ function add_action_link($links, $file) { static $this_plugin; if (empty($this_plugin)) { $this_plugin = 'wordpress-seo/wp-seo.php'; } if ($file == $this_plugin) { $settings_link = '<a href="' . esc_url(admin_url('admin.php?page=wpseo_dashboard')) . '">' . __('Settings', 'wordpress-seo') . '</a>'; array_unshift($links, $settings_link); } if (class_exists('Yoast_Product_WPSEO_Premium')) { $license_manager = new Yoast_Plugin_License_Manager(new Yoast_Product_WPSEO_Premium()); if ($license_manager->license_is_valid()) { return $links; } } // add link to premium support landing page $premium_link = '<a href="https://yoast.com/wordpress/plugins/seo-premium/support/#utm_source=wordpress-seo-settings-link&utm_medium=text-link&utm_campaign=support-link">' . __('Premium Support', 'wordpress-seo') . '</a>'; array_unshift($links, $premium_link); return $links; }
/** * Render the admin page footer with sidebar for the GA Plugin */ public function content_footer() { do_action('yoast_ga_admin_footer'); if (true == WP_DEBUG) { // Show the debug information if debug is enabled in the wp_config file echo '<div id="ga-debug-info" class="postbox"><h3 class="hndle"><span>' . __('Debug information', 'google-analytics-for-wordpress') . '</span></h3><div class="inside"><pre>'; var_dump($this->options); echo '</pre></div></div>'; } if (class_exists('Yoast_Product_GA_Premium')) { $license_manager = new Yoast_Plugin_License_Manager(new Yoast_Product_GA_Premium()); if ($license_manager->license_is_valid()) { return; } } $banners = array(); $banners[] = array('url' => 'https://yoast.com/hire-us/website-review/#utm_medium=banner&utm_source=gawp-config&utm_campaign=wpgaplugin', 'banner' => $this->plugin_url . 'assets/img/banner-website-review.png', 'title' => 'Get a website review by Yoast'); $banners[] = array('url' => 'https://yoast.com/wordpress/plugins/google-analytics/#utm_medium=banner&utm_source=gawp-config&utm_campaign=wpgaplugin', 'banner' => $this->plugin_url . 'assets/img/banner-premium-ga.png', 'title' => 'Get the premium version of Google Analytics by Yoast!'); $banners[] = array('url' => 'https://yoast.com/ebook-optimize-wordpress-site/#utm_medium=banner&utm_source=gawp-config&utm_campaign=wpgaplugin', 'banner' => $this->plugin_url . 'assets/img/eBook_261x130.png', 'title' => 'Get the Yoast ebook!'); $banners[] = array('url' => 'https://yoast.com/wordpress/plugins/ga-ecommerce/#utm_medium=banner&utm_source=gawp-config&utm_campaign=wpgaplugin', 'banner' => $this->plugin_url . 'assets/img/banner-ga-ecommerce.png', 'title' => 'Get advanced eCommerce tracking for WooCommerce and Easy Digital Downloads!'); shuffle($banners); require 'views/content-footer.php'; }
/** * Generates the sidebar for admin pages. */ public function admin_sidebar() { // No banners in Premium. if (class_exists('WPSEO_Product_Premium')) { $license_manager = new Yoast_Plugin_License_Manager(new WPSEO_Product_Premium()); if ($license_manager->license_is_valid()) { return; } } $service_banners = array(array('url' => 'https://yoast.com/hire-us/website-review/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=website-review-banner', 'img' => 'banner-website-review.png', 'alt' => 'Website Review banner')); $plugin_banners = array(array('url' => 'https://yoast.com/academy/course/basic-seo-training/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=basic-seo-training-banner', 'img' => 'banner-seo-training.png', 'alt' => 'Basic SEO Training banner'), array('url' => 'https://yoast.com/wordpress/plugins/seo-premium/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=premium-seo-banner', 'img' => 'banner-premium-seo.png', 'alt' => 'Banner Yoast SEO Premium')); if (!class_exists('wpseo_Video_Sitemap')) { $plugin_banners[] = array('url' => 'https://yoast.com/wordpress/plugins/video-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=video-seo-banner', 'img' => 'banner-video-seo.png', 'alt' => 'Banner Yoast Video SEO plugin'); } if (class_exists('Woocommerce') && !class_exists('Yoast_WooCommerce_SEO')) { $plugin_banners[] = array('url' => 'https://yoast.com/wordpress/plugins/yoast-woocommerce-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=woocommerce-seo-banner', 'img' => 'banner-woocommerce-seo.png', 'alt' => 'Banner Yoast WooCommerce SEO plugin'); } if (!defined('WPSEO_LOCAL_VERSION')) { $plugin_banners[] = array('url' => 'https://yoast.com/wordpress/plugins/local-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=local-seo-banner', 'img' => 'banner-local-seo.png', 'alt' => 'Banner Yoast Local SEO plugin'); } if (!class_exists('WPSEO_News')) { $plugin_banners[] = array('url' => 'https://yoast.com/wordpress/plugins/news-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=news-seo-banner', 'img' => 'banner-news-seo.png', 'alt' => 'Banner Yoast News SEO plugin'); } shuffle($service_banners); shuffle($plugin_banners); ?> <div class="wpseo_content_cell" id="sidebar-container"> <div id="sidebar"> <?php $service_banner = $service_banners[0]; echo '<a target="_blank" href="' . esc_url($service_banner['url']) . '"><img width="261" height="190" src="' . plugins_url('images/' . $service_banner['img'], WPSEO_FILE) . '" alt="' . esc_attr($service_banner['alt']) . '"/></a><br/><br/>'; $i = 0; foreach ($plugin_banners as $banner) { if ($i == 2) { break; } echo '<a target="_blank" href="' . esc_url($banner['url']) . '"><img width="261" height="152" src="' . plugins_url('images/' . $banner['img'], WPSEO_FILE) . '" alt="' . esc_attr($banner['alt']) . '"/></a><br/><br/>'; $i++; } ?> <strong><?php _e('Remove these ads?', 'wordpress-seo'); ?> </strong><br/> <a target="_blank" href="https://yoast.com/wordpress/plugins/seo-premium/#utm_source=wordpress-seo-config&utm_medium=textlink&utm_campaign=remove-ads-link"><?php /* translators: %1$s expands to Yoast SEO Premium */ printf(__('Upgrade to %1$s »', 'wordpress-seo'), 'Yoast SEO Premium'); ?> </a><br/><br/> </div> </div> <?php }
/** * Generates the sidebar for admin pages. */ public function admin_sidebar() { // No banners in Premium. if (class_exists('WPSEO_Product_Premium')) { $license_manager = new Yoast_Plugin_License_Manager(new WPSEO_Product_Premium()); if ($license_manager->license_is_valid()) { return; } } $sidebar_renderer = new WPSEO_Admin_Banner_Sidebar_Renderer(new WPSEO_Admin_Banner_Spot_Renderer()); $banner_renderer = new WPSEO_Admin_Banner_Renderer(); $banner_renderer->set_base_path(plugins_url('images/banner/', WPSEO_FILE)); $sidebar = new WPSEO_Admin_Banner_Sidebar(sprintf('%1s recommendations', 'Yoast'), $banner_renderer); $sidebar->initialize(new WPSEO_Features()); echo $sidebar_renderer->render($sidebar); }
/** * An update is required, do it * * @param $current_version */ private function do_update($current_version) { /** * Move the current version option, a tricky upgrade. * This upgrade routine was introduced in version 1.5.2 */ if ($current_version == 1) { // Get the original option and save it as the current version. // If there is no original option the $current_version will remain 1. $current_version = get_option('sp_current_version', 1); // Only resave the version if it changed. if (1 != $current_version) { // Set the new version option update_option(SP_Constants::OPTION_CURRENT_PREMIUM_VERSION, $current_version); // Delete the old version option delete_option('sp_current_version'); } } // < 1.5.2 if ($current_version < 22) { /** * Upgrade to version 1.5.2 * * - Save the license key in the new option and remove the old license option */ // Resave the license key $license_key = get_option('post-connector_license', ''); if ('' != $license_key) { update_option('post-connector-premium_license', $license_key); delete_option('connector_license'); } } // < 1.4.0 if ($current_version < 18) { /** * Upgrade to version 1.4.0.0 * * - Change the title of all post link to the post type link slug, see #123 for more info. * - Remove 'sp_install_version' option from database, this option was and will never be used. */ // -- Remove 'sp_install_version' option from database, this option was and will never be used. delete_option('sp_install_version'); // -- Change the title of all post link to the post type link slug, see #123 for more info. // Post Type Link Manager $post_type_link_manager = new SP_Connection_Manager(); // Add post title check filter add_filter('posts_clauses', array($this, 'alter_slug_update_query'), 10, 2); // Update all link titles to new slug setup $post_links = get_posts(array('post_type' => SP_Constants::CPT_LINK, 'posts_per_page' => -1, 'suppress_filters' => false)); // Remove the check filter remove_filter('posts_clauses', array($this, 'alter_slug_update_query')); if (count($post_links) > 0) { foreach ($post_links as $post_link) { // Get Post Type Link ID $ptl_id = get_post_meta($post_link->ID, 'sp_pt_link', true); // Check if PTL ID is != '' if ('' != $ptl_id) { // Get the Connection object $ptl = $post_type_link_manager->get_connection($ptl_id); // Update the post link with the new title wp_update_post(array('ID' => $post_link->ID, 'post_title' => 'sp_' . $ptl->get_slug())); } } } } // < 1.5.0 if ($current_version < 20) { /** * Upgrade to version 1.5.0 * * - Change the title of all post link to the post type link slug, see #123 for more info. * - Remove 'sp_install_version' option from database, this option was and will never be used. */ // Migrate license key and status $license_manager = new Yoast_Plugin_License_Manager(new SP_Product_Post_Connector()); $license_manager->set_license_key(get_option('subposts_license_key', '')); $license_manager->set_license_status(get_option('subposts_license_status', '')); } }
<?php global $yoast_ga_admin; echo $yoast_ga_admin->content_head(); $has_extensions = false; $extensions = array('ecommerce' => (object) array('url' => 'https://yoast.com/wordpress/plugins/google-analytics/', 'title' => __('Google Analytics', 'google-analytics-for-wordpress') . '<br />' . __('E-Commerce tracking', 'google-analytics-for-wordpress'), 'desc' => __('Track your E-Commerce data and transactions with this E-Commerce extension for Google Analytics.', 'google-analytics-for-wordpress'), 'status' => 'uninstalled')); if (class_exists('Yoast_GA_eCommerce_Tracking')) { $has_extensions = true; $product = new Yoast_Product_GA_eCommerce(); $license_manager = new Yoast_Plugin_License_Manager($product); if ($license_manager->license_is_valid()) { $extensions['ecommerce']->status = 'active'; } else { $extensions['ecommerce']->status = 'inactive'; } } ?> <h2 id="yoast_ga_title"><?php echo __('Yoast Google Analytics: Extensions', 'google-analytics-for-wordpress'); ?> </h2> <h2 class="nav-tab-wrapper" id="ga-tabs"> <a class="nav-tab active" id="extensions-tab" href="#top#extensions"><?php _e('Extensions', 'google-analytics-for-wordpress'); ?> </a> <a class="nav-tab" id="licenses-tab" href="#top#licenses"><?php _e('Licenses', 'google-analytics-for-wordpress'); ?> </a>
/** * Generates the sidebar for admin pages. */ public function admin_sidebar() { // No banners in Premium. if (class_exists('WPSEO_Product_Premium')) { $license_manager = new Yoast_Plugin_License_Manager(new WPSEO_Product_Premium()); if ($license_manager->license_is_valid()) { return; } } $service_banners = array(array('url' => 'https://yoast.com/hire-us/website-review/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=website-review-banner', 'img' => 'banner-website-review.png', 'alt' => __('Order a Website Review and we will tell you what to improve to attract more visitors!', 'wordpress-seo')), array('url' => 'https://yoast.com/hire-us/yoast-seo-configuration/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=configuration-service-banner', 'img' => 'banner-configuration-service.png', 'alt' => __('Let our experts set up your Yoast SEO Premium plugin!', 'wordpress-seo')), array('url' => 'https://yoast.com/academy/course/seo-copywriting-training/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=seo-copywriting-training-banner', 'img' => 'banner-seo-copywriting-training.png', 'alt' => __('Take the online SEO Copywriting Training course and learn how to write awesome copy that ranks!', 'wordpress-seo')), array('url' => 'https://yoast.com/academy/course/basic-seo-training/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=basic-seo-training-banner', 'img' => 'banner-basic-seo-training.png', 'alt' => __('Take the online Basic SEO Training course and learn the fundamentals of SEO!', 'wordpress-seo')), array('url' => 'https://yoast.com/academy/course/yoast-seo-wordpress-training/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=yoast-seo-plugin-training-banner', 'img' => 'banner-yoast-seo-for-wordpress-training.png', 'alt' => __('Take the Yoast SEO for WordPress Training course and become a certified Yoast SEO for WordPress expert!', 'wordpress-seo'))); $plugin_banners = array(array('url' => 'https://yoast.com/wordpress/plugins/seo-premium/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=premium-seo-banner', 'img' => 'banner-premium-seo.png', 'alt' => __('Buy the Yoast SEO Premium plugin now and get access to extra features and 24/7 support!', 'wordpress-seo'))); if (!class_exists('wpseo_Video_Sitemap')) { $plugin_banners[] = array('url' => 'https://yoast.com/wordpress/plugins/video-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=video-seo-banner', 'img' => 'banner-video-seo.png', 'alt' => __('Buy the Yoast Video SEO plugin now and optimize your videos for video search results and social media!', 'wordpress-seo')); } if (class_exists('Woocommerce') && !class_exists('Yoast_WooCommerce_SEO')) { $plugin_banners[] = array('url' => 'https://yoast.com/wordpress/plugins/yoast-woocommerce-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=woocommerce-seo-banner', 'img' => 'banner-woocommerce-seo.png', 'alt' => __('Buy the Yoast WooCommerce SEO plugin now and optimize your shop today to improve your product promotion!', 'wordpress-seo')); } if (!defined('WPSEO_LOCAL_VERSION')) { $plugin_banners[] = array('url' => 'https://yoast.com/wordpress/plugins/local-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=local-seo-banner', 'img' => 'banner-local-seo.png', 'alt' => __('Buy the Yoast Local SEO plugin now to improve your site’s Local SEO and ranking in Google Maps!', 'wordpress-seo')); } if (!class_exists('WPSEO_News')) { $plugin_banners[] = array('url' => 'https://yoast.com/wordpress/plugins/news-seo/#utm_source=wordpress-seo-config&utm_medium=banner&utm_campaign=news-seo-banner', 'img' => 'banner-news-seo.png', 'alt' => __('Buy the Yoast News SEO plugin now and start optimizing to get your site featured in Google News!', 'wordpress-seo')); } shuffle($service_banners); shuffle($plugin_banners); ?> <div class="wpseo_content_cell" id="sidebar-container"> <div id="sidebar"> <?php $i = 0; foreach ($service_banners as $service_banner) { if ($i == 2) { break; } echo '<a target="_blank" href="' . esc_url($service_banner['url']) . '"><img width="261" height="190" src="' . plugins_url('images/' . $service_banner['img'], WPSEO_FILE) . '" alt="' . esc_attr($service_banner['alt']) . '"/></a><br/><br/>'; $i++; } $i = 0; foreach ($plugin_banners as $banner) { if ($i == 2) { break; } echo '<a target="_blank" href="' . esc_url($banner['url']) . '"><img width="261" height="152" src="' . plugins_url('images/' . $banner['img'], WPSEO_FILE) . '" alt="' . esc_attr($banner['alt']) . '"/></a><br/><br/>'; $i++; } ?> <p class="wpseo-remove-ads"> <strong><?php _e('Remove these ads?', 'wordpress-seo'); ?> </strong><br/> <a target="_blank" href="https://yoast.com/wordpress/plugins/seo-premium/#utm_source=wordpress-seo-config&utm_medium=textlink&utm_campaign=remove-ads-link"><?php /* translators: %1$s expands to Yoast SEO Premium */ printf(__('Upgrade to %1$s »', 'wordpress-seo'), 'Yoast SEO Premium'); ?> </a> </p> </div> </div> <?php }