tool-bulk-editor.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin
  6. * @since 1.5.0
  7. */
  8. if ( ! defined( 'WPSEO_VERSION' ) ) {
  9. header( 'Status: 403 Forbidden' );
  10. header( 'HTTP/1.1 403 Forbidden' );
  11. exit();
  12. }
  13. $wpseo_bulk_titles_table = new WPSEO_Bulk_Title_Editor_List_Table();
  14. $wpseo_bulk_description_table = new WPSEO_Bulk_Description_List_Table();
  15. get_current_screen()->set_screen_reader_content( array(
  16. 'heading_views' => __( 'Filter posts list', 'wordpress-seo' ),
  17. 'heading_pagination' => __( 'Posts list navigation', 'wordpress-seo' ),
  18. 'heading_list' => __( 'Posts list', 'wordpress-seo' ),
  19. ) );
  20. // If type is empty, fill it with value of first tab (title).
  21. $_GET['type'] = ( ! empty( $_GET['type'] ) ) ? $_GET['type'] : 'title';
  22. if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
  23. wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
  24. exit;
  25. }
  26. /**
  27. * Outputs a help center.
  28. */
  29. function wpseo_render_help_center() {
  30. $tabs = new WPSEO_Option_Tabs( '', '' );
  31. $tabs->add_tab( new WPSEO_Option_Tab( 'title', __( 'Bulk editor', 'wordpress-seo' ),
  32. array( 'video_url' => WPSEO_Shortlinker::get( 'https://yoa.st/screencast-tools-bulk-editor' ) ) ) );
  33. $tabs->add_tab( new WPSEO_Option_Tab( 'description', __( 'Bulk editor', 'wordpress-seo' ),
  34. array( 'video_url' => WPSEO_Shortlinker::get( 'https://yoa.st/screencast-tools-bulk-editor' ) ) ) );
  35. $helpcenter = new WPSEO_Help_Center( '', $tabs, WPSEO_Utils::is_yoast_seo_premium() );
  36. $helpcenter->localize_data();
  37. $helpcenter->mount();
  38. }
  39. /**
  40. * Renders a bulk editor tab.
  41. *
  42. * @param WPSEO_Bulk_List_Table $table The table to render.
  43. * @param string $id The id for the tab.
  44. */
  45. function wpseo_get_rendered_tab( $table, $id ) {
  46. ?>
  47. <div id="<?php echo esc_attr( $id ); ?>" class="wpseotab">
  48. <?php
  49. $table->show_page();
  50. ?>
  51. </div>
  52. <?php
  53. }
  54. ?>
  55. <script>
  56. var wpseoBulkEditorNonce = <?php echo wp_json_encode( wp_create_nonce( 'wpseo-bulk-editor' ) ); ?>;
  57. // eslint-disable-next-line
  58. var wpseo_bulk_editor_nonce = wpseoBulkEditorNonce;
  59. </script>
  60. <br/><br/>
  61. <div class="wpseo_table_page">
  62. <h2 class="nav-tab-wrapper" id="wpseo-tabs">
  63. <a class="nav-tab" id="title-tab" href="#top#title"><?php esc_html_e( 'Title', 'wordpress-seo' ); ?></a>
  64. <a class="nav-tab" id="description-tab"
  65. href="#top#description"><?php esc_html_e( 'Description', 'wordpress-seo' ); ?></a>
  66. </h2>
  67. <?php wpseo_render_help_center(); ?>
  68. <div class="tabwrapper">
  69. <?php wpseo_get_rendered_tab( $wpseo_bulk_titles_table, 'title' ); ?>
  70. <?php wpseo_get_rendered_tab( $wpseo_bulk_description_table, 'description' ); ?>
  71. </div>
  72. </div>