PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 27.7
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v27.7
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / admin / views / tool-import-export.php

tool-import-export.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 27.7, at admin/views/tool-import-export.php

124 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPSEO plugin file.
4 *
5 * @package WPSEO\Admin
6 */
7
8 if ( ! defined( 'WPSEO_VERSION' ) ) {
9 header( 'Status: 403 Forbidden' );
10 header( 'HTTP/1.1 403 Forbidden' );
11 exit();
12 }
13
14 $yform = Yoast_Form::get_instance();
15 $yoast_seo_import = false;
16
17 /**
18 * The import method is used to determine if there should be something imported.
19 *
20 * In case of POST the user is on the Yoast SEO import page and in case of the GET the user sees a notice from
21 * Yoast SEO that we can import stuff for that plugin.
22 */
23 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are only comparing the variable so no need to sanitize.
24 if ( isset( $_POST['import_external'] ) && wp_unslash( $_POST['import_external'] ) === __( 'Import', 'wordpress-seo' ) ) {
25 check_admin_referer( 'wpseo-import-plugins' );
26 if ( isset( $_POST['import_external_plugin'] ) && is_string( $_POST['import_external_plugin'] ) ) {
27 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are using the variable as a class name.
28 $yoast_seo_class = wp_unslash( $_POST['import_external_plugin'] );
29 if ( class_exists( $yoast_seo_class ) ) {
30 $yoast_seo_import = new WPSEO_Import_Plugin( new $yoast_seo_class(), 'import' );
31 }
32 }
33 }
34 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are only comparing the variable so no need to sanitize.
35 elseif ( isset( $_POST['clean_external'] ) && wp_unslash( $_POST['clean_external'] ) === __( 'Clean up', 'wordpress-seo' ) ) {
36 check_admin_referer( 'wpseo-clean-plugins' );
37 if ( isset( $_POST['clean_external_plugin'] ) && is_string( $_POST['clean_external_plugin'] ) ) {
38 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are using the variable as a class name.
39 $yoast_seo_class = wp_unslash( $_POST['clean_external_plugin'] );
40 if ( class_exists( $yoast_seo_class ) ) {
41 $yoast_seo_import = new WPSEO_Import_Plugin( new $yoast_seo_class(), 'cleanup' );
42 }
43 }
44 }
45 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are only comparing to an empty string.
46 elseif ( isset( $_POST['settings_import'] ) && wp_unslash( $_POST['settings_import'] ) !== '' ) {
47 $yoast_seo_import = new WPSEO_Import_Settings();
48 $yoast_seo_import->import();
49 }
50
51 /**
52 * Allow custom import actions.
53 *
54 * @param WPSEO_Import_Status $yoast_seo_import Contains info about the handled import.
55 */
56 $yoast_seo_import = apply_filters( 'wpseo_handle_import', $yoast_seo_import );
57
58 if ( $yoast_seo_import ) {
59
60 $yoast_seo_message = '';
61 if ( $yoast_seo_import->status instanceof WPSEO_Import_Status ) {
62 $yoast_seo_message = $yoast_seo_import->status->get_msg();
63 }
64
65 /**
66 * Allow customization of import/export message.
67 *
68 * @param string $yoast_seo_msg The message.
69 */
70 $yoast_seo_msg = apply_filters( 'wpseo_import_message', $yoast_seo_message );
71
72 if ( ! empty( $yoast_seo_msg ) ) {
73 $yoast_seo_status = 'error';
74 if ( $yoast_seo_import->status->status ) {
75 $yoast_seo_status = 'updated';
76 }
77
78 $yoast_seo_class = 'message ' . $yoast_seo_status;
79
80 echo '<div id="message" class="', esc_attr( $yoast_seo_status ), '"><p>', esc_html( $yoast_seo_msg ), '</p></div>';
81 }
82 }
83
84 $yoast_seo_tabs = [
85 'wpseo-import' => [
86 'label' => __( 'Import settings', 'wordpress-seo' ),
87 ],
88 'wpseo-export' => [
89 'label' => __( 'Export settings', 'wordpress-seo' ),
90 ],
91 'import-seo' => [
92 'label' => __( 'Import from other SEO plugins', 'wordpress-seo' ),
93 ],
94 ];
95
96 ?>
97 <br/><br/>
98
99 <h2 class="nav-tab-wrapper" id="wpseo-tabs">
100 <?php foreach ( $yoast_seo_tabs as $identifier => $tab ) : ?>
101 <a class="nav-tab" id="<?php echo esc_attr( $identifier . '-tab' ); ?>" href="<?php echo esc_url( '#top#' . $identifier ); ?>"><?php echo esc_html( $tab['label'] ); ?></a>
102 <?php endforeach; ?>
103
104 <?php
105 /**
106 * Allow adding a custom import tab header.
107 */
108 do_action( 'wpseo_import_tab_header' );
109 ?>
110 </h2>
111
112 <?php
113
114 foreach ( $yoast_seo_tabs as $identifier => $tab ) {
115 printf( '<div id="%s" class="wpseotab">', esc_attr( $identifier ) );
116 require_once WPSEO_PATH . 'admin/views/tabs/tool/' . $identifier . '.php';
117 echo '</div>';
118 }
119
120 /**
121 * Allow adding a custom import tab.
122 */
123 do_action( 'wpseo_import_tab_content' );
124