import-seo.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\Views
  6. */
  7. if ( ! defined( 'WPSEO_VERSION' ) ) {
  8. header( 'Status: 403 Forbidden' );
  9. header( 'HTTP/1.1 403 Forbidden' );
  10. exit();
  11. }
  12. // Determine if we have plugins we can import from. If so, load that tab. Otherwise, load an empty tab.
  13. $import_check = new WPSEO_Import_Plugins_Detector();
  14. $import_check->detect();
  15. if ( count( $import_check->needs_import ) === 0 ) {
  16. echo '<h2>', esc_html__( 'Import from other SEO plugins', 'wordpress-seo' ), '</h2>';
  17. echo '<p>';
  18. printf(
  19. /* translators: %s expands to Yoast SEO */
  20. esc_html__( '%s did not detect any plugin data from plugins it can import from.', 'wordpress-seo' ),
  21. 'Yoast SEO'
  22. );
  23. echo '</p>';
  24. return;
  25. }
  26. /**
  27. * Creates a select box given a name and plugins array.
  28. *
  29. * @param string $name Name field for the select field.
  30. * @param array $plugins An array of plugins and classes.
  31. *
  32. * @return void
  33. */
  34. function wpseo_import_external_select( $name, $plugins ) {
  35. esc_html_e( 'Plugin: ', 'wordpress-seo' );
  36. echo '<select name="', esc_attr( $name ), '">';
  37. foreach ( $plugins as $class => $plugin ) {
  38. /* translators: %s is replaced with the name of the plugin we're importing from. */
  39. echo '<option value="' . esc_attr( $class ) . '">' . esc_html( $plugin ) . '</option>';
  40. }
  41. echo '</select>';
  42. }
  43. ?>
  44. <h2><?php esc_html_e( 'Import from other SEO plugins', 'wordpress-seo' ); ?></h2>
  45. <p>
  46. <?php esc_html_e( 'We\'ve detected data from one or more SEO plugins on your site. Please follow the following steps to import that data:', 'wordpress-seo' ); ?>
  47. </p>
  48. <div class="tab-block">
  49. <h3><?php esc_html_e( 'Step 1: Create a backup', 'wordpress-seo' ); ?></h3>
  50. <p>
  51. <?php esc_html_e( 'Please make a backup of your database before starting this process.', 'wordpress-seo' ); ?>
  52. </p>
  53. </div>
  54. <div class="tab-block">
  55. <h3><?php esc_html_e( 'Step 2: Import', 'wordpress-seo' ); ?></h3>
  56. <p>
  57. <?php
  58. printf(
  59. /* translators: 1: expands to Yoast SEO */
  60. esc_html__( 'This will import the post metadata like SEO titles and descriptions into your %1$s metadata. It will only do this when there is no existing %1$s metadata yet. The original data will remain in place.', 'wordpress-seo' ),
  61. 'Yoast SEO'
  62. );
  63. ?>
  64. </p>
  65. <form action="<?php echo esc_url( admin_url( 'admin.php?page=wpseo_tools&tool=import-export#top#import-seo' ) ); ?>"
  66. method="post" accept-charset="<?php echo esc_attr( get_bloginfo( 'charset' ) ); ?>">
  67. <?php
  68. wp_nonce_field( 'wpseo-import-plugins', '_wpnonce', true, true );
  69. wpseo_import_external_select( 'import_external_plugin', $import_check->needs_import );
  70. ?>
  71. <?php
  72. do_action( 'wpseo_import_other_plugins' );
  73. ?>
  74. <input type="submit" class="button button-primary" name="import_external"
  75. value="<?php esc_attr_e( 'Import', 'wordpress-seo' ); ?>"/>
  76. </form>
  77. </div>
  78. <div class="tab-block">
  79. <h3><?php esc_html_e( 'Step 3: Check your data', 'wordpress-seo' ); ?></h3>
  80. <p>
  81. <?php esc_html_e( 'Please check your posts and pages and see if the metadata was successfully imported.', 'wordpress-seo' ); ?>
  82. </p>
  83. </div>
  84. <div class="tab-block">
  85. <h3><?php esc_html_e( 'Step 4: Run the configuration wizard', 'wordpress-seo' ); ?></h3>
  86. <p>
  87. <?php
  88. printf(
  89. esc_html__( 'You should run the configuration wizard, from the SEO &rarr; General &rarr; Dashboard page, to make sure all the settings for your site are correct.', 'wordpress-seo' ),
  90. '<a href="' . esc_url( admin_url( 'admin.php?page=wpseo_dashboard' ) ) . '">',
  91. '</a>'
  92. );
  93. ?>
  94. </p>
  95. </div>
  96. <div class="tab-block">
  97. <h3><?php esc_html_e( 'Step 5: Clean up', 'wordpress-seo' ); ?></h3>
  98. <p>
  99. <?php esc_html_e( 'Once you\'re certain your site is OK, you can clean up. This will remove all the original data.', 'wordpress-seo' ); ?>
  100. </p>
  101. <form action="<?php echo esc_url( admin_url( 'admin.php?page=wpseo_tools&tool=import-export#top#import-seo' ) ); ?>"
  102. method="post" accept-charset="<?php echo esc_attr( get_bloginfo( 'charset' ) ); ?>">
  103. <?php
  104. wp_nonce_field( 'wpseo-clean-plugins', '_wpnonce', true, true );
  105. wpseo_import_external_select( 'clean_external_plugin', $import_check->needs_import );
  106. ?>
  107. <input type="submit" class="button button-primary" name="clean_external"
  108. value="<?php esc_attr_e( 'Clean', 'wordpress-seo' ); ?>"/>
  109. </form>
  110. </div>