WPSEO_Import_WooThemes_SEO

Class WPSEO_Import_WooThemes_SEO.

Defined (1)

The class is defined in the following location(s).

/admin/class-import-woothemes-seo.php  
  1. class WPSEO_Import_WooThemes_SEO extends WPSEO_Import_External { 
  2.  
  3. /** 
  4. * Class constructor 
  5. */ 
  6. public function __construct() { 
  7. parent::__construct(); 
  8.  
  9. $this->import_home(); 
  10. $this->import_option( 'seo_woo_single_layout', 'post' ); 
  11. $this->import_option( 'seo_woo_page_layout', 'page' ); 
  12. $this->import_archive_option(); 
  13. $this->import_custom_values( 'seo_woo_meta_home_desc', 'metadesc-home-wpseo' ); 
  14. $this->import_custom_values( 'seo_woo_meta_home_key', 'metakey-home-wpseo' ); 
  15. $this->import_metas(); 
  16.  
  17. update_option( 'wpseo_titles', $this->options ); 
  18.  
  19. $this->set_msg( __( 'WooThemes SEO framework settings & data successfully imported.', 'wordpress-seo' ) ); 
  20.  
  21. /** 
  22. * Holds the WPSEO Title Options 
  23. * @var array 
  24. */ 
  25. private $options; 
  26.  
  27. /** 
  28. * Import options. 
  29. * @param string $option Option key. 
  30. * @param string $post_type Post type name to import for. 
  31. */ 
  32. private function import_option( $option, $post_type ) { 
  33. switch ( get_option( $option ) ) { 
  34. case 'a': 
  35. $this->options[ 'title-' . $post_type ] = '%%title%% %%sep%% %%sitename%%'; 
  36. break; 
  37. case 'b': 
  38. $this->options[ 'title-' . $post_type ] = '%%title%%'; 
  39. break; 
  40. case 'c': 
  41. $this->options[ 'title-' . $post_type ] = '%%sitename%% %%sep%% %%title%%'; 
  42. break; 
  43. case 'd': 
  44. $this->options[ 'title-' . $post_type ] = '%%title%% %%sep%% %%sitedesc%%'; 
  45. break; 
  46. case 'e': 
  47. $this->options[ 'title-' . $post_type ] = '%%sitename%% %%sep%% %%title%% %%sep%% %%sitedesc%%'; 
  48. break; 
  49. $this->perhaps_delete( $option ); 
  50.  
  51. /** 
  52. * Import the archive layout for all taxonomies 
  53. */ 
  54. private function import_archive_option() { 
  55. $reinstate_replace = false; 
  56. if ( $this->replace ) { 
  57. $this->replace = false; 
  58. $reinstate_replace = true; 
  59. $taxonomies = get_taxonomies( array( 'public' => true ), 'names' ); 
  60. if ( is_array( $taxonomies ) && $taxonomies !== array() ) { 
  61. foreach ( $taxonomies as $tax ) { 
  62. $this->import_option( 'seo_woo_archive_layout', 'tax-' . $tax ); 
  63. if ( $reinstate_replace ) { 
  64. $this->replace = true; 
  65. $this->perhaps_delete( 'seo_woo_archive_layout' ); 
  66.  
  67. /** 
  68. * Import custom descriptions and meta keys 
  69. * @param string $option Option key. 
  70. * @param string $key Internal key to import over. 
  71. */ 
  72. private function import_custom_values( $option, $key ) { 
  73. // Import the custom homepage description. 
  74. if ( 'c' == get_option( $option ) ) { 
  75. $this->options[ $key ] = get_option( $option . '_custom' ); 
  76. $this->perhaps_delete( $option ); 
  77. $this->perhaps_delete( $option . '_custom' ); 
  78.  
  79. /** 
  80. * Imports the WooThemes SEO homepage settings 
  81. */ 
  82. private function import_home() { 
  83. switch ( get_option( 'seo_woo_home_layout' ) ) { 
  84. case 'a': 
  85. $this->options['title-home-wpseo'] = '%%sitename%% %%sep%% %%sitedesc%%'; 
  86. break; 
  87. case 'b': 
  88. $this->options['title-home-wpseo'] = '%%sitename%% ' . get_option( 'seo_woo_paged_var' ) . ' %%pagenum%%'; 
  89. break; 
  90. case 'c': 
  91. $this->options['title-home-wpseo'] = '%%sitedesc%%'; 
  92. break; 
  93. $this->perhaps_delete( 'seo_woo_home_layout' ); 
  94.  
  95. /** 
  96. * Import meta values if they're applicable 
  97. */ 
  98. private function import_metas() { 
  99. WPSEO_Meta::replace_meta( 'seo_follow', WPSEO_Meta::$meta_prefix . 'meta-robots-nofollow', $this->replace ); 
  100. WPSEO_Meta::replace_meta( 'seo_noindex', WPSEO_Meta::$meta_prefix . 'meta-robots-noindex', $this->replace ); 
  101.  
  102. // If WooSEO is set to use the Woo titles, import those. 
  103. if ( 'true' == get_option( 'seo_woo_wp_title' ) ) { 
  104. WPSEO_Meta::replace_meta( 'seo_title', WPSEO_Meta::$meta_prefix . 'title', $this->replace ); 
  105.  
  106. // If WooSEO is set to use the Woo meta descriptions, import those. 
  107. if ( 'b' == get_option( 'seo_woo_meta_single_desc' ) ) { 
  108. WPSEO_Meta::replace_meta( 'seo_description', WPSEO_Meta::$meta_prefix . 'metadesc', $this->replace ); 
  109.  
  110. // If WooSEO is set to use the Woo meta keywords, import those. 
  111. if ( 'b' == get_option( 'seo_woo_meta_single_key' ) ) { 
  112. WPSEO_Meta::replace_meta( 'seo_keywords', WPSEO_Meta::$meta_prefix . 'metakeywords', $this->replace ); 
  113.  
  114. foreach ( array( 'seo_woo_wp_title', 'seo_woo_meta_single_desc', 'seo_woo_meta_single_key' ) as $option ) { 
  115. $this->perhaps_delete( $option );