| 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 |
$tool_page = ''; |
| 15 |
|
| 16 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information. |
| 17 |
if ( isset( $_GET['tool'] ) && is_string( $_GET['tool'] ) ) { |
| 18 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information. |
| 19 |
$tool_page = sanitize_text_field( wp_unslash( $_GET['tool'] ) ); |
| 20 |
} |
| 21 |
|
| 22 |
$yform = Yoast_Form::get_instance(); |
| 23 |
$yform->admin_header( false ); |
| 24 |
|
| 25 |
if ( $tool_page === '' ) { |
| 26 |
|
| 27 |
$tools = []; |
| 28 |
|
| 29 |
$tools['import-export'] = [ |
| 30 |
'title' => __( 'Import and Export', 'wordpress-seo' ), |
| 31 |
'desc' => __( 'Import settings from other SEO plugins and export your settings for re-use on (another) site.', 'wordpress-seo' ), |
| 32 |
]; |
| 33 |
|
| 34 |
if ( WPSEO_Utils::allow_system_file_edit() === true && ! is_multisite() ) { |
| 35 |
$tools['file-editor'] = [ |
| 36 |
'title' => __( 'File editor', 'wordpress-seo' ), |
| 37 |
'desc' => __( 'This tool allows you to quickly change important files for your SEO, like your robots.txt and, if you have one, your .htaccess file.', 'wordpress-seo' ), |
| 38 |
]; |
| 39 |
} |
| 40 |
|
| 41 |
$tools['bulk-editor'] = [ |
| 42 |
'title' => __( 'Bulk editor', 'wordpress-seo' ), |
| 43 |
'desc' => __( 'This tool allows you to quickly change titles and descriptions of your posts and pages without having to go into the editor for each page.', 'wordpress-seo' ), |
| 44 |
'url' => admin_url( 'admin.php?page=wpseo_page_bulk_edit' ), |
| 45 |
]; |
| 46 |
|
| 47 |
echo '<p>'; |
| 48 |
printf( |
| 49 |
/* translators: %1$s expands to Yoast SEO */ |
| 50 |
esc_html__( '%1$s comes with some very powerful built-in tools:', 'wordpress-seo' ), |
| 51 |
'Yoast SEO', |
| 52 |
); |
| 53 |
echo '</p>'; |
| 54 |
|
| 55 |
echo '<ul class="ul-disc">'; |
| 56 |
|
| 57 |
$admin_url = admin_url( 'admin.php?page=wpseo_tools' ); |
| 58 |
|
| 59 |
foreach ( $tools as $slug => $tool ) { |
| 60 |
if ( ! empty( $tool['url'] ) ) { |
| 61 |
$href = $tool['url']; |
| 62 |
} |
| 63 |
elseif ( ! empty( $tool['href'] ) ) { |
| 64 |
$href = $admin_url . $tool['href']; |
| 65 |
} |
| 66 |
else { |
| 67 |
$href = add_query_arg( [ 'tool' => $slug ], $admin_url ); |
| 68 |
} |
| 69 |
$attr = ( ! empty( $tool['attr'] ) ) ? $tool['attr'] : ''; |
| 70 |
|
| 71 |
echo '<li>'; |
| 72 |
echo '<strong><a href="', esc_url( $href ), '" ', esc_attr( $attr ), '>', esc_html( $tool['title'] ), '</a></strong><br/>'; |
| 73 |
echo esc_html( $tool['desc'] ); |
| 74 |
echo '</li>'; |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* WARNING: This hook is intended for internal use only. |
| 79 |
* Don't use it in your code as it will be removed shortly. |
| 80 |
*/ |
| 81 |
do_action( 'wpseo_tools_overview_list_items_internal' ); |
| 82 |
|
| 83 |
echo '</ul>'; |
| 84 |
} |
| 85 |
else { |
| 86 |
echo '<a href="', esc_url( admin_url( 'admin.php?page=wpseo_tools' ) ), '">', esc_html__( '« Back to Tools page', 'wordpress-seo' ), '</a>'; |
| 87 |
|
| 88 |
$tool_pages = [ 'import-export' ]; |
| 89 |
|
| 90 |
if ( WPSEO_Utils::allow_system_file_edit() === true && ! is_multisite() ) { |
| 91 |
$tool_pages[] = 'file-editor'; |
| 92 |
} |
| 93 |
|
| 94 |
if ( in_array( $tool_page, $tool_pages, true ) ) { |
| 95 |
require_once WPSEO_PATH . 'admin/views/tool-' . $tool_page . '.php'; |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
$yform->admin_footer( false ); |
| 100 |
|