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