class-wp-customize-nav-menus-panel.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /**
  3. * Customize API: WP_Customize_Nav_Menus_Panel class
  4. *
  5. * @package WordPress
  6. * @subpackage Customize
  7. * @since 4.4.0
  8. */
  9. /**
  10. * Customize Nav Menus Panel Class
  11. *
  12. * Needed to add screen options.
  13. *
  14. * @since 4.3.0
  15. *
  16. * @see WP_Customize_Panel
  17. */
  18. class WP_Customize_Nav_Menus_Panel extends WP_Customize_Panel {
  19. /**
  20. * Control type.
  21. *
  22. * @since 4.3.0
  23. * @var string
  24. */
  25. public $type = 'nav_menus';
  26. /**
  27. * Render screen options for Menus.
  28. *
  29. * @since 4.3.0
  30. */
  31. public function render_screen_options() {
  32. // Adds the screen options.
  33. require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
  34. add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' );
  35. // Display screen options.
  36. $screen = WP_Screen::get( 'nav-menus.php' );
  37. $screen->render_screen_options( array( 'wrap' => false ) );
  38. }
  39. /**
  40. * Returns the advanced options for the nav menus page.
  41. *
  42. * Link title attribute added as it's a relatively advanced concept for new users.
  43. *
  44. * @since 4.3.0
  45. * @deprecated 4.5.0 Deprecated in favor of wp_nav_menu_manage_columns().
  46. */
  47. public function wp_nav_menu_manage_columns() {
  48. _deprecated_function( __METHOD__, '4.5.0', 'wp_nav_menu_manage_columns' );
  49. require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
  50. return wp_nav_menu_manage_columns();
  51. }
  52. /**
  53. * An Underscore (JS) template for this panel's content (but not its container).
  54. *
  55. * Class variables for this panel class are available in the `data` JS object;
  56. * export custom variables by overriding WP_Customize_Panel::json().
  57. *
  58. * @since 4.3.0
  59. *
  60. * @see WP_Customize_Panel::print_template()
  61. */
  62. protected function content_template() {
  63. ?>
  64. <li class="panel-meta customize-info accordion-section <# if ( ! data.description ) { #> cannot-expand<# } #>">
  65. <button type="button" class="customize-panel-back" tabindex="-1">
  66. <span class="screen-reader-text"><?php _e( 'Back' ); ?></span>
  67. </button>
  68. <div class="accordion-section-title">
  69. <span class="preview-notice">
  70. <?php
  71. /* translators: %s: The site/panel title in the Customizer. */
  72. printf( __( 'You are customizing %s' ), '<strong class="panel-title">{{ data.title }}</strong>' );
  73. ?>
  74. </span>
  75. <button type="button" class="customize-help-toggle dashicons dashicons-editor-help" aria-expanded="false">
  76. <span class="screen-reader-text"><?php _e( 'Help' ); ?></span>
  77. </button>
  78. <button type="button" class="customize-screen-options-toggle" aria-expanded="false">
  79. <span class="screen-reader-text"><?php _e( 'Menu Options' ); ?></span>
  80. </button>
  81. </div>
  82. <# if ( data.description ) { #>
  83. <div class="description customize-panel-description">{{{ data.description }}}</div>
  84. <# } #>
  85. <div id="screen-options-wrap">
  86. <?php $this->render_screen_options(); ?>
  87. </div>
  88. </li>
  89. <?php
  90. // NOTE: The following is a workaround for an inability to treat (and thus label) a list of sections as a whole.
  91. ?>
  92. <li class="customize-control-title customize-section-title-nav_menus-heading"><?php _e( 'Menus' ); ?></li>
  93. <?php
  94. }
  95. }