260 |
260 |
261 /** |
261 /** |
262 * Check whether to disable the Menu Locations meta box submit button and inputs. |
262 * Check whether to disable the Menu Locations meta box submit button and inputs. |
263 * |
263 * |
264 * @since 3.6.0 |
264 * @since 3.6.0 |
265 * @since 5.3.1 The `$echo` parameter was added. |
265 * @since 5.3.1 The `$display` parameter was added. |
266 * |
266 * |
267 * @global bool $one_theme_location_no_menus to determine if no menus exist |
267 * @global bool $one_theme_location_no_menus to determine if no menus exist |
268 * |
268 * |
269 * @param int|string $nav_menu_selected_id ID, name, or slug of the currently selected menu. |
269 * @param int|string $nav_menu_selected_id ID, name, or slug of the currently selected menu. |
270 * @param bool $echo Whether to echo or just return the string. |
270 * @param bool $display Whether to display or just return the string. |
271 * @return string|false Disabled attribute if at least one menu exists, false if not. |
271 * @return string|false Disabled attribute if at least one menu exists, false if not. |
272 */ |
272 */ |
273 function wp_nav_menu_disabled_check( $nav_menu_selected_id, $echo = true ) { |
273 function wp_nav_menu_disabled_check( $nav_menu_selected_id, $display = true ) { |
274 global $one_theme_location_no_menus; |
274 global $one_theme_location_no_menus; |
275 |
275 |
276 if ( $one_theme_location_no_menus ) { |
276 if ( $one_theme_location_no_menus ) { |
277 return false; |
277 return false; |
278 } |
278 } |
279 |
279 |
280 return disabled( $nav_menu_selected_id, 0, $echo ); |
280 return disabled( $nav_menu_selected_id, 0, $display ); |
281 } |
281 } |
282 |
282 |
283 /** |
283 /** |
284 * Displays a meta box for the custom links menu item. |
284 * Displays a meta box for the custom links menu item. |
285 * |
285 * |
323 * @since 3.0.0 |
323 * @since 3.0.0 |
324 * |
324 * |
325 * @global int $_nav_menu_placeholder |
325 * @global int $_nav_menu_placeholder |
326 * @global int|string $nav_menu_selected_id |
326 * @global int|string $nav_menu_selected_id |
327 * |
327 * |
328 * @param string $object Not used. |
328 * @param string $data_object Not used. |
329 * @param array $box { |
329 * @param array $box { |
330 * Post type menu item meta box arguments. |
330 * Post type menu item meta box arguments. |
331 * |
331 * |
332 * @type string $id Meta box 'id' attribute. |
332 * @type string $id Meta box 'id' attribute. |
333 * @type string $title Meta box title. |
333 * @type string $title Meta box title. |
334 * @type callable $callback Meta box display callback. |
334 * @type callable $callback Meta box display callback. |
335 * @type WP_Post_Type $args Extra meta box arguments (the post type object for this meta box). |
335 * @type WP_Post_Type $args Extra meta box arguments (the post type object for this meta box). |
336 * } |
336 * } |
337 */ |
337 */ |
338 function wp_nav_menu_item_post_type_meta_box( $object, $box ) { |
338 function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) { |
339 global $_nav_menu_placeholder, $nav_menu_selected_id; |
339 global $_nav_menu_placeholder, $nav_menu_selected_id; |
340 |
340 |
341 $post_type_name = $box['args']->name; |
341 $post_type_name = $box['args']->name; |
342 $post_type = get_post_type_object( $post_type_name ); |
342 $post_type = get_post_type_object( $post_type_name ); |
343 $tab_name = $post_type_name . '-tab'; |
343 $tab_name = $post_type_name . '-tab'; |
687 * |
687 * |
688 * @since 3.0.0 |
688 * @since 3.0.0 |
689 * |
689 * |
690 * @global int|string $nav_menu_selected_id |
690 * @global int|string $nav_menu_selected_id |
691 * |
691 * |
692 * @param string $object Not used. |
692 * @param string $data_object Not used. |
693 * @param array $box { |
693 * @param array $box { |
694 * Taxonomy menu item meta box arguments. |
694 * Taxonomy menu item meta box arguments. |
695 * |
695 * |
696 * @type string $id Meta box 'id' attribute. |
696 * @type string $id Meta box 'id' attribute. |
697 * @type string $title Meta box title. |
697 * @type string $title Meta box title. |
698 * @type callable $callback Meta box display callback. |
698 * @type callable $callback Meta box display callback. |
699 * @type object $args Extra meta box arguments (the taxonomy object for this meta box). |
699 * @type object $args Extra meta box arguments (the taxonomy object for this meta box). |
700 * } |
700 * } |
701 */ |
701 */ |
702 function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) { |
702 function wp_nav_menu_item_taxonomy_meta_box( $data_object, $box ) { |
703 global $nav_menu_selected_id; |
703 global $nav_menu_selected_id; |
704 |
704 |
705 $taxonomy_name = $box['args']->name; |
705 $taxonomy_name = $box['args']->name; |
706 $taxonomy = get_taxonomy( $taxonomy_name ); |
706 $taxonomy = get_taxonomy( $taxonomy_name ); |
707 $tab_name = $taxonomy_name . '-tab'; |
707 $tab_name = $taxonomy_name . '-tab'; |
987 * |
987 * |
988 * @since 3.0.0 |
988 * @since 3.0.0 |
989 * |
989 * |
990 * @access private |
990 * @access private |
991 * |
991 * |
992 * @param object $object The post type or taxonomy meta-object. |
992 * @param object $data_object The post type or taxonomy meta-object. |
993 * @return object The post type or taxonomy object. |
993 * @return object The post type or taxonomy object. |
994 */ |
994 */ |
995 function _wp_nav_menu_meta_box_object( $object = null ) { |
995 function _wp_nav_menu_meta_box_object( $data_object = null ) { |
996 if ( isset( $object->name ) ) { |
996 if ( isset( $data_object->name ) ) { |
997 |
997 |
998 if ( 'page' === $object->name ) { |
998 if ( 'page' === $data_object->name ) { |
999 $object->_default_query = array( |
999 $data_object->_default_query = array( |
1000 'orderby' => 'menu_order title', |
1000 'orderby' => 'menu_order title', |
1001 'post_status' => 'publish', |
1001 'post_status' => 'publish', |
1002 ); |
1002 ); |
1003 |
1003 |
1004 // Posts should show only published items. |
1004 // Posts should show only published items. |
1005 } elseif ( 'post' === $object->name ) { |
1005 } elseif ( 'post' === $data_object->name ) { |
1006 $object->_default_query = array( |
1006 $data_object->_default_query = array( |
1007 'post_status' => 'publish', |
1007 'post_status' => 'publish', |
1008 ); |
1008 ); |
1009 |
1009 |
1010 // Categories should be in reverse chronological order. |
1010 // Categories should be in reverse chronological order. |
1011 } elseif ( 'category' === $object->name ) { |
1011 } elseif ( 'category' === $data_object->name ) { |
1012 $object->_default_query = array( |
1012 $data_object->_default_query = array( |
1013 'orderby' => 'id', |
1013 'orderby' => 'id', |
1014 'order' => 'DESC', |
1014 'order' => 'DESC', |
1015 ); |
1015 ); |
1016 |
1016 |
1017 // Custom post types should show only published items. |
1017 // Custom post types should show only published items. |
1018 } else { |
1018 } else { |
1019 $object->_default_query = array( |
1019 $data_object->_default_query = array( |
1020 'post_status' => 'publish', |
1020 'post_status' => 'publish', |
1021 ); |
1021 ); |
1022 } |
1022 } |
1023 } |
1023 } |
1024 |
1024 |
1025 return $object; |
1025 return $data_object; |
1026 } |
1026 } |
1027 |
1027 |
1028 /** |
1028 /** |
1029 * Returns the menu formatted to edit. |
1029 * Returns the menu formatted to edit. |
1030 * |
1030 * |