form
5 years ago
tabs
3 months ago
class-yoast-feature-toggle.php
1 year ago
class-yoast-feature-toggles.php
3 months ago
class-yoast-input-select.php
2 years ago
class-yoast-integration-toggles.php
3 months ago
interface-yoast-form-element.php
8 years ago
js-templates-primary-term.php
3 months ago
paper-collapsible.php
3 months ago
partial-notifications-errors.php
3 months ago
partial-notifications-template.php
3 months ago
partial-notifications-warnings.php
3 months ago
redirects.php
10 months ago
tool-bulk-editor.php
3 months ago
tool-file-editor.php
3 months ago
tool-import-export.php
1 year ago
tool-bulk-editor.php
121 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WPSEO plugin file. |
| 4 | * |
| 5 | * @package WPSEO\Admin |
| 6 | * @since 1.5.0 |
| 7 | */ |
| 8 | |
| 9 | if ( ! defined( 'WPSEO_VERSION' ) ) { |
| 10 | header( 'Status: 403 Forbidden' ); |
| 11 | header( 'HTTP/1.1 403 Forbidden' ); |
| 12 | exit(); |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * Sanitizes the parameters that have been sent. |
| 17 | * |
| 18 | * @return array The sanitized fields. |
| 19 | */ |
| 20 | function yoast_free_bulk_sanitize_input_fields() { |
| 21 | $possible_params = [ |
| 22 | 'type', |
| 23 | 'paged', |
| 24 | 'post_type_filter', |
| 25 | 'post_status', |
| 26 | 'order', |
| 27 | 'orderby', |
| 28 | ]; |
| 29 | |
| 30 | $input_get = []; |
| 31 | foreach ( $possible_params as $param_name ) { |
| 32 | if ( isset( $_GET[ $param_name ] ) ) { |
| 33 | $input_get[ $param_name ] = sanitize_text_field( wp_unslash( $_GET[ $param_name ] ) ); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | return $input_get; |
| 38 | } |
| 39 | |
| 40 | $yoast_free_input_fields = yoast_free_bulk_sanitize_input_fields(); |
| 41 | |
| 42 | // Verifies the nonce. |
| 43 | if ( ! empty( $yoast_free_input_fields ) ) { |
| 44 | check_admin_referer( 'bulk-editor-table', 'nonce' ); |
| 45 | } |
| 46 | |
| 47 | // If type is empty, fill it with value of first tab (title). |
| 48 | if ( ! isset( $yoast_free_input_fields['type'] ) ) { |
| 49 | $yoast_free_input_fields['type'] = 'title'; |
| 50 | } |
| 51 | |
| 52 | $yoast_bulk_editor_arguments = [ |
| 53 | 'input_fields' => $yoast_free_input_fields, |
| 54 | 'nonce' => wp_create_nonce( 'bulk-editor-table' ), |
| 55 | ]; |
| 56 | |
| 57 | $wpseo_bulk_titles_table = new WPSEO_Bulk_Title_Editor_List_Table( $yoast_bulk_editor_arguments ); |
| 58 | $wpseo_bulk_description_table = new WPSEO_Bulk_Description_List_Table( $yoast_bulk_editor_arguments ); |
| 59 | |
| 60 | $yoast_free_screen_reader_content = [ |
| 61 | 'heading_views' => __( 'Filter posts list', 'wordpress-seo' ), |
| 62 | 'heading_pagination' => __( 'Posts list navigation', 'wordpress-seo' ), |
| 63 | 'heading_list' => __( 'Posts list', 'wordpress-seo' ), |
| 64 | ]; |
| 65 | get_current_screen()->set_screen_reader_content( $yoast_free_screen_reader_content ); |
| 66 | |
| 67 | if ( ! empty( $_REQUEST['_wp_http_referer'] ) && isset( $_SERVER['REQUEST_URI'] ) ) { |
| 68 | $request_uri = sanitize_file_name( wp_unslash( $_SERVER['REQUEST_URI'] ) ); |
| 69 | |
| 70 | wp_redirect( |
| 71 | remove_query_arg( |
| 72 | [ '_wp_http_referer', '_wpnonce' ], |
| 73 | $request_uri, |
| 74 | ), |
| 75 | ); |
| 76 | exit(); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Renders a bulk editor tab. |
| 81 | * |
| 82 | * @param WPSEO_Bulk_List_Table $table The table to render. |
| 83 | * @param string $id The id for the tab. |
| 84 | * |
| 85 | * @return void |
| 86 | */ |
| 87 | function wpseo_get_rendered_tab( $table, $id ) { |
| 88 | ?> |
| 89 | <div id="<?php echo esc_attr( $id ); ?>" class="wpseotab"> |
| 90 | <?php |
| 91 | $table->show_page(); |
| 92 | ?> |
| 93 | </div> |
| 94 | <?php |
| 95 | } |
| 96 | |
| 97 | ?> |
| 98 | <script> |
| 99 | <?php /* phpcs:ignore WordPress.Security.EscapeOutput -- WPSEO_Utils::format_json_encode is safe. */ ?> |
| 100 | var wpseoBulkEditorNonce = <?php echo WPSEO_Utils::format_json_encode( wp_create_nonce( 'wpseo-bulk-editor' ) ); ?>; |
| 101 | |
| 102 | // eslint-disable-next-line |
| 103 | var wpseo_bulk_editor_nonce = wpseoBulkEditorNonce; |
| 104 | </script> |
| 105 | |
| 106 | <br/><br/> |
| 107 | |
| 108 | <div class="wpseo_table_page"> |
| 109 | |
| 110 | <h2 class="nav-tab-wrapper" id="wpseo-tabs"> |
| 111 | <a class="nav-tab" id="title-tab" href="#top#title"><?php esc_html_e( 'Title', 'wordpress-seo' ); ?></a> |
| 112 | <a class="nav-tab" id="description-tab" |
| 113 | href="#top#description"><?php esc_html_e( 'Description', 'wordpress-seo' ); ?></a> |
| 114 | </h2> |
| 115 | |
| 116 | <div class="tabwrapper"> |
| 117 | <?php wpseo_get_rendered_tab( $wpseo_bulk_titles_table, 'title' ); ?> |
| 118 | <?php wpseo_get_rendered_tab( $wpseo_bulk_description_table, 'description' ); ?> |
| 119 | </div> |
| 120 | </div> |
| 121 |