tools.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin
  6. */
  7. if ( ! defined( 'WPSEO_VERSION' ) ) {
  8. header( 'Status: 403 Forbidden' );
  9. header( 'HTTP/1.1 403 Forbidden' );
  10. exit();
  11. }
  12. $tool_page = (string) filter_input( INPUT_GET, 'tool' );
  13. $yform = Yoast_Form::get_instance();
  14. $yform->admin_header( false );
  15. if ( '' === $tool_page ) {
  16. $tools = [];
  17. $tools['import-export'] = [
  18. 'title' => __( 'Import and Export', 'wordpress-seo' ),
  19. 'desc' => __( 'Import settings from other SEO plugins and export your settings for re-use on (another) blog.', 'wordpress-seo' ),
  20. ];
  21. if ( WPSEO_Utils::allow_system_file_edit() === true && ! is_multisite() ) {
  22. $tools['file-editor'] = [
  23. 'title' => __( 'File editor', 'wordpress-seo' ),
  24. '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' ),
  25. ];
  26. }
  27. $tools['bulk-editor'] = [
  28. 'title' => __( 'Bulk editor', 'wordpress-seo' ),
  29. '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' ),
  30. ];
  31. echo '<p>';
  32. printf(
  33. /* translators: %1$s expands to Yoast SEO */
  34. esc_html__( '%1$s comes with some very powerful built-in tools:', 'wordpress-seo' ),
  35. 'Yoast SEO'
  36. );
  37. echo '</p>';
  38. echo '<ul class="ul-disc">';
  39. $admin_url = admin_url( 'admin.php?page=wpseo_tools' );
  40. foreach ( $tools as $slug => $tool ) {
  41. $href = ( ! empty( $tool['href'] ) ) ? $admin_url . $tool['href'] : add_query_arg( [ 'tool' => $slug ], $admin_url );
  42. $attr = ( ! empty( $tool['attr'] ) ) ? $tool['attr'] : '';
  43. echo '<li>';
  44. echo '<strong><a href="', esc_url( $href ), '" ', esc_attr( $attr ) , '>', esc_html( $tool['title'] ), '</a></strong><br/>';
  45. echo esc_html( $tool['desc'] );
  46. echo '</li>';
  47. }
  48. /**
  49. * Action: 'wpseo_tools_overview_list_items' - Hook to add additional tools to the overview.
  50. */
  51. do_action( 'wpseo_tools_overview_list_items' );
  52. echo '</ul>';
  53. echo '<input type="hidden" id="wpseo_recalculate_nonce" name="wpseo_recalculate_nonce" value="' . esc_attr( wp_create_nonce( 'wpseo_recalculate' ) ) . '" />';
  54. }
  55. else {
  56. echo '<a href="', esc_url( admin_url( 'admin.php?page=wpseo_tools' ) ), '">', esc_html__( '&laquo; Back to Tools page', 'wordpress-seo' ), '</a>';
  57. $tool_pages = [ 'bulk-editor', 'import-export' ];
  58. if ( WPSEO_Utils::allow_system_file_edit() === true && ! is_multisite() ) {
  59. $tool_pages[] = 'file-editor';
  60. }
  61. if ( in_array( $tool_page, $tool_pages, true ) ) {
  62. require_once WPSEO_PATH . 'admin/views/tool-' . $tool_page . '.php';
  63. }
  64. }
  65. $yform->admin_footer( false );