559 'moveOutFrom' => __( 'Move out from under %s' ), |
560 'moveOutFrom' => __( 'Move out from under %s' ), |
560 /* translators: %s: Previous item name. */ |
561 /* translators: %s: Previous item name. */ |
561 'under' => __( 'Under %s' ), |
562 'under' => __( 'Under %s' ), |
562 /* translators: %s: Previous item name. */ |
563 /* translators: %s: Previous item name. */ |
563 'outFrom' => __( 'Out from under %s' ), |
564 'outFrom' => __( 'Out from under %s' ), |
564 /* translators: 1: Item name, 2: Item position, 3: Total number of items. */ |
565 /* translators: 1: Item name, 2: Item type, 3: Item index, 4: Total items. */ |
565 'menuFocus' => __( '%1$s. Menu item %2$d of %3$d.' ), |
566 'menuFocus' => __( 'Edit %1$s (%2$s, %3$d of %4$d)' ), |
566 /* translators: 1: Item name, 2: Item position, 3: Parent item name. */ |
567 /* translators: 1: Item name, 2: Item type, 3: Item index, 4: Total items, 5: Item parent. */ |
567 'subMenuFocus' => __( '%1$s. Sub item number %2$d under %3$s.' ), |
568 'subMenuFocus' => __( 'Edit %1$s (%2$s, sub-item %3$d of %4$d under %5$s)' ), |
|
569 /* translators: 1: Item name, 2: Item type, 3: Item index, 4: Total items, 5: Item parent, 6: Item depth. */ |
|
570 'subMenuMoreDepthFocus' => __( 'Edit %1$s (%2$s, sub-item %3$d of %4$d under %5$s, level %6$d)' ), |
568 ); |
571 ); |
569 wp_localize_script( 'nav-menu', 'menus', $nav_menus_l10n ); |
572 wp_localize_script( 'nav-menu', 'menus', $nav_menus_l10n ); |
570 } |
573 } |
571 |
574 |
572 /** |
575 /** |
934 * @since 4.7.0 |
937 * @since 4.7.0 |
935 * |
938 * |
936 * @param array $postarr { |
939 * @param array $postarr { |
937 * Post array. Note that post_status is overridden to be `auto-draft`. |
940 * Post array. Note that post_status is overridden to be `auto-draft`. |
938 * |
941 * |
939 * @var string $post_title Post title. Required. |
942 * @type string $post_title Post title. Required. |
940 * @var string $post_type Post type. Required. |
943 * @type string $post_type Post type. Required. |
941 * @var string $post_name Post name. |
944 * @type string $post_name Post name. |
942 * @var string $post_content Post content. |
945 * @type string $post_content Post content. |
943 * } |
946 * } |
944 * @return WP_Post|WP_Error Inserted auto-draft post object or error. |
947 * @return WP_Post|WP_Error Inserted auto-draft post object or error. |
945 */ |
948 */ |
946 public function insert_auto_draft_post( $postarr ) { |
949 public function insert_auto_draft_post( $postarr ) { |
947 if ( ! isset( $postarr['post_type'] ) ) { |
950 if ( ! isset( $postarr['post_type'] ) ) { |
1073 <span class="menu-item-title<# if ( ! data.title ) { #> no-title<# } #>">{{ data.title || wp.customize.Menus.data.l10n.untitled }}</span> |
1076 <span class="menu-item-title<# if ( ! data.title ) { #> no-title<# } #>">{{ data.title || wp.customize.Menus.data.l10n.untitled }}</span> |
1074 </span> |
1077 </span> |
1075 <button type="button" class="button-link item-add"> |
1078 <button type="button" class="button-link item-add"> |
1076 <span class="screen-reader-text"> |
1079 <span class="screen-reader-text"> |
1077 <?php |
1080 <?php |
1078 /* translators: 1: Title of a menu item, 2: Type of a menu item. */ |
1081 /* translators: Hidden accessibility text. 1: Title of a menu item, 2: Type of a menu item. */ |
1079 printf( __( 'Add to menu: %1$s (%2$s)' ), '{{ data.title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.type_label }}' ); |
1082 printf( __( 'Add to menu: %1$s (%2$s)' ), '{{ data.title || wp.customize.Menus.data.l10n.untitled }}', '{{ data.type_label }}' ); |
1080 ?> |
1083 ?> |
1081 </span> |
1084 </span> |
1082 </button> |
1085 </button> |
1083 </div> |
1086 </div> |
1141 public function available_items_template() { |
1144 public function available_items_template() { |
1142 ?> |
1145 ?> |
1143 <div id="available-menu-items" class="accordion-container"> |
1146 <div id="available-menu-items" class="accordion-container"> |
1144 <div class="customize-section-title"> |
1147 <div class="customize-section-title"> |
1145 <button type="button" class="customize-section-back" tabindex="-1"> |
1148 <button type="button" class="customize-section-back" tabindex="-1"> |
1146 <span class="screen-reader-text"><?php _e( 'Back' ); ?></span> |
1149 <span class="screen-reader-text"> |
|
1150 <?php |
|
1151 /* translators: Hidden accessibility text. */ |
|
1152 _e( 'Back' ); |
|
1153 ?> |
|
1154 </span> |
1147 </button> |
1155 </button> |
1148 <h3> |
1156 <h3> |
1149 <span class="customize-action"> |
1157 <span class="customize-action"> |
1150 <?php |
1158 <?php |
1151 /* translators: ▸ is the unicode right-pointing triangle. %s: Section title in the Customizer. */ |
1159 /* translators: ▸ is the unicode right-pointing triangle. %s: Section title in the Customizer. */ |
1155 <?php _e( 'Add Menu Items' ); ?> |
1163 <?php _e( 'Add Menu Items' ); ?> |
1156 </h3> |
1164 </h3> |
1157 </div> |
1165 </div> |
1158 <div id="available-menu-items-search" class="accordion-section cannot-expand"> |
1166 <div id="available-menu-items-search" class="accordion-section cannot-expand"> |
1159 <div class="accordion-section-title"> |
1167 <div class="accordion-section-title"> |
1160 <label class="screen-reader-text" for="menu-items-search"><?php _e( 'Search Menu Items' ); ?></label> |
1168 <label for="menu-items-search"><?php _e( 'Search Menu Items' ); ?></label> |
1161 <input type="text" id="menu-items-search" placeholder="<?php esc_attr_e( 'Search menu items…' ); ?>" aria-describedby="menu-items-search-desc" /> |
1169 <input type="text" id="menu-items-search" aria-describedby="menu-items-search-desc" /> |
1162 <p class="screen-reader-text" id="menu-items-search-desc"><?php _e( 'The search results will be updated as you type.' ); ?></p> |
1170 <p class="screen-reader-text" id="menu-items-search-desc"> |
|
1171 <?php |
|
1172 /* translators: Hidden accessibility text. */ |
|
1173 _e( 'The search results will be updated as you type.' ); |
|
1174 ?> |
|
1175 </p> |
1163 <span class="spinner"></span> |
1176 <span class="spinner"></span> |
|
1177 <div class="search-icon" aria-hidden="true"></div> |
|
1178 <button type="button" class="clear-results"><span class="screen-reader-text"> |
|
1179 <?php |
|
1180 /* translators: Hidden accessibility text. */ |
|
1181 _e( 'Clear Results' ); |
|
1182 ?> |
|
1183 </span></button> |
1164 </div> |
1184 </div> |
1165 <div class="search-icon" aria-hidden="true"></div> |
|
1166 <button type="button" class="clear-results"><span class="screen-reader-text"><?php _e( 'Clear Results' ); ?></span></button> |
|
1167 <ul class="accordion-section-content available-menu-items-list" data-type="search"></ul> |
1185 <ul class="accordion-section-content available-menu-items-list" data-type="search"></ul> |
1168 </div> |
1186 </div> |
1169 <?php |
1187 <?php |
1170 |
1188 |
1171 // Ensure the page post type comes first in the list. |
1189 // Ensure the page post type comes first in the list. |
1220 </h4> |
1238 </h4> |
1221 <div class="accordion-section-content"> |
1239 <div class="accordion-section-content"> |
1222 <?php if ( 'post_type' === $available_item_type['type'] ) : ?> |
1240 <?php if ( 'post_type' === $available_item_type['type'] ) : ?> |
1223 <?php $post_type_obj = get_post_type_object( $available_item_type['object'] ); ?> |
1241 <?php $post_type_obj = get_post_type_object( $available_item_type['object'] ); ?> |
1224 <?php if ( current_user_can( $post_type_obj->cap->create_posts ) && current_user_can( $post_type_obj->cap->publish_posts ) ) : ?> |
1242 <?php if ( current_user_can( $post_type_obj->cap->create_posts ) && current_user_can( $post_type_obj->cap->publish_posts ) ) : ?> |
1225 <div class="new-content-item"> |
1243 <div class="new-content-item-wrapper"> |
1226 <label for="<?php echo esc_attr( 'create-item-input-' . $available_item_type['object'] ); ?>" class="screen-reader-text"><?php echo esc_html( $post_type_obj->labels->add_new_item ); ?></label> |
1244 <label for="<?php echo esc_attr( 'create-item-input-' . $available_item_type['object'] ); ?>"><?php echo esc_html( $post_type_obj->labels->add_new_item ); ?></label> |
1227 <input type="text" id="<?php echo esc_attr( 'create-item-input-' . $available_item_type['object'] ); ?>" class="create-item-input" placeholder="<?php echo esc_attr( $post_type_obj->labels->add_new_item ); ?>"> |
1245 <div class="new-content-item"> |
1228 <button type="button" class="button add-content"><?php _e( 'Add' ); ?></button> |
1246 <input type="text" id="<?php echo esc_attr( 'create-item-input-' . $available_item_type['object'] ); ?>" class="create-item-input"> |
|
1247 <button type="button" class="button add-content"><?php _e( 'Add' ); ?></button> |
|
1248 </div> |
1229 </div> |
1249 </div> |
1230 <?php endif; ?> |
1250 <?php endif; ?> |
1231 <?php endif; ?> |
1251 <?php endif; ?> |
1232 <ul class="available-menu-items-list" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>" data-type_label="<?php echo esc_attr( isset( $available_item_type['type_label'] ) ? $available_item_type['type_label'] : $available_item_type['type'] ); ?>"></ul> |
1252 <ul class="available-menu-items-list" data-type="<?php echo esc_attr( $available_item_type['type'] ); ?>" data-object="<?php echo esc_attr( $available_item_type['object'] ); ?>" data-type_label="<?php echo esc_attr( isset( $available_item_type['type_label'] ) ? $available_item_type['type_label'] : $available_item_type['type'] ); ?>"></ul> |
1233 </div> |
1253 </div> |
1244 ?> |
1264 ?> |
1245 <div id="new-custom-menu-item" class="accordion-section"> |
1265 <div id="new-custom-menu-item" class="accordion-section"> |
1246 <h4 class="accordion-section-title" role="presentation"> |
1266 <h4 class="accordion-section-title" role="presentation"> |
1247 <?php _e( 'Custom Links' ); ?> |
1267 <?php _e( 'Custom Links' ); ?> |
1248 <button type="button" class="button-link" aria-expanded="false"> |
1268 <button type="button" class="button-link" aria-expanded="false"> |
1249 <span class="screen-reader-text"><?php _e( 'Toggle section: Custom Links' ); ?></span> |
1269 <span class="screen-reader-text"> |
|
1270 <?php |
|
1271 /* translators: Hidden accessibility text. */ |
|
1272 _e( 'Toggle section: Custom Links' ); |
|
1273 ?> |
|
1274 </span> |
1250 <span class="toggle-indicator" aria-hidden="true"></span> |
1275 <span class="toggle-indicator" aria-hidden="true"></span> |
1251 </button> |
1276 </button> |
1252 </h4> |
1277 </h4> |
1253 <div class="accordion-section-content customlinkdiv"> |
1278 <div class="accordion-section-content customlinkdiv"> |
1254 <input type="hidden" value="custom" id="custom-menu-item-type" name="menu-item[-1][menu-item-type]" /> |
1279 <input type="hidden" value="custom" id="custom-menu-item-type" name="menu-item[-1][menu-item-type]" /> |
1320 */ |
1345 */ |
1321 public function customize_preview_init() { |
1346 public function customize_preview_init() { |
1322 add_action( 'wp_enqueue_scripts', array( $this, 'customize_preview_enqueue_deps' ) ); |
1347 add_action( 'wp_enqueue_scripts', array( $this, 'customize_preview_enqueue_deps' ) ); |
1323 add_filter( 'wp_nav_menu_args', array( $this, 'filter_wp_nav_menu_args' ), 1000 ); |
1348 add_filter( 'wp_nav_menu_args', array( $this, 'filter_wp_nav_menu_args' ), 1000 ); |
1324 add_filter( 'wp_nav_menu', array( $this, 'filter_wp_nav_menu' ), 10, 2 ); |
1349 add_filter( 'wp_nav_menu', array( $this, 'filter_wp_nav_menu' ), 10, 2 ); |
1325 add_filter( 'wp_footer', array( $this, 'export_preview_data' ), 1 ); |
1350 add_action( 'wp_footer', array( $this, 'export_preview_data' ), 1 ); |
1326 add_filter( 'customize_render_partials_response', array( $this, 'export_partial_rendered_nav_menu_instances' ) ); |
1351 add_filter( 'customize_render_partials_response', array( $this, 'export_partial_rendered_nav_menu_instances' ) ); |
1327 } |
1352 } |
1328 |
1353 |
1329 /** |
1354 /** |
1330 * Makes the auto-draft status protected so that it can be queried. |
1355 * Makes the auto-draft status protected so that it can be queried. |
1444 && |
1469 && |
1445 // ...and if the nav menu would be rendered with a wrapper container element (upon which to attach data-* attributes). |
1470 // ...and if the nav menu would be rendered with a wrapper container element (upon which to attach data-* attributes). |
1446 ( |
1471 ( |
1447 ! empty( $args['container'] ) |
1472 ! empty( $args['container'] ) |
1448 || |
1473 || |
1449 ( isset( $args['items_wrap'] ) && '<' === substr( $args['items_wrap'], 0, 1 ) ) |
1474 ( isset( $args['items_wrap'] ) && str_starts_with( $args['items_wrap'], '<' ) ) |
1450 ) |
1475 ) |
1451 ); |
1476 ); |
1452 $args['can_partial_refresh'] = $can_partial_refresh; |
1477 $args['can_partial_refresh'] = $can_partial_refresh; |
1453 |
1478 |
1454 $exported_args = $args; |
1479 $exported_args = $args; |
1531 |
1556 |
1532 // Why not wp_localize_script? Because we're not localizing, and it forces values into strings. |
1557 // Why not wp_localize_script? Because we're not localizing, and it forces values into strings. |
1533 $exports = array( |
1558 $exports = array( |
1534 'navMenuInstanceArgs' => $this->preview_nav_menu_instance_args, |
1559 'navMenuInstanceArgs' => $this->preview_nav_menu_instance_args, |
1535 ); |
1560 ); |
1536 printf( '<script>var _wpCustomizePreviewNavMenusExports = %s;</script>', wp_json_encode( $exports ) ); |
1561 wp_print_inline_script_tag( sprintf( 'var _wpCustomizePreviewNavMenusExports = %s;', wp_json_encode( $exports ) ) ); |
1537 } |
1562 } |
1538 |
1563 |
1539 /** |
1564 /** |
1540 * Exports any wp_nav_menu() calls during the rendering of any partials. |
1565 * Exports any wp_nav_menu() calls during the rendering of any partials. |
1541 * |
1566 * |