/**
  * 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();
 }
Ejemplo n.º 2
0
 /**
  * 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);
     }
 }
Ejemplo n.º 3
0
 /**
  * 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);
     }
 }
 /**
  * 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', ''));
     }
 }