: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// Only suppress and insert when more than just suppression pages available.
if ( ! $get_posts->post_count ) {
if ( ! empty( $suppress_page_ids ) ) {
unset( $args['post__not_in'] );
$get_posts = new WP_Query();
$posts = $get_posts->query( $args );
echo '<p>' . __( 'No items.' ) . '</p>';
} elseif ( ! empty( $important_pages ) ) {
$posts = array_merge( $important_pages, $posts );
$num_pages = $get_posts->max_num_pages;
$page_links = paginate_links(
'item-type' => 'post_type',
'item-object' => $post_type_name,
'prev_text' => '<span aria-label="' . esc_attr__( 'Previous page' ) . '">' . __( '«' ) . '</span>',
'next_text' => '<span aria-label="' . esc_attr__( 'Next page' ) . '">' . __( '»' ) . '</span>',
/* translators: Hidden accessibility text. */
'before_page_number' => '<span class="screen-reader-text">' . __( 'Page' ) . '</span> ',
if ( is_post_type_hierarchical( $post_type_name ) ) {
'parent' => 'post_parent',
$walker = new Walker_Nav_Menu_Checklist( $db_fields );
$current_tab = 'most-recent';
if ( isset( $_REQUEST[ $tab_name ] ) && in_array( $_REQUEST[ $tab_name ], array( 'all', 'search' ), true ) ) {
$current_tab = $_REQUEST[ $tab_name ];
if ( ! empty( $_REQUEST[ "quick-search-posttype-{$post_type_name}" ] ) ) {
if ( $nav_menu_selected_id ) {
$most_recent_url = add_query_arg( $tab_name, 'most-recent', remove_query_arg( $removed_args ) );
$view_all_url = add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) );
$search_url = add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) );
<div id="<?php echo esc_attr( "posttype-{$post_type_name}" ); ?>" class="posttypediv">
<ul id="<?php echo esc_attr( "posttype-{$post_type_name}-tabs" ); ?>" class="posttype-tabs add-menu-item-tabs">
<li <?php echo ( 'most-recent' === $current_tab ? ' class="tabs"' : '' ); ?>>
data-type="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-most-recent" ); ?>"
href="<?php echo esc_url( $most_recent_url . "#tabs-panel-posttype-{$post_type_name}-most-recent" ); ?>"
<?php _e( 'Most Recent' ); ?>
<li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>>
data-type="<?php echo esc_attr( "{$post_type_name}-all" ); ?>"
href="<?php echo esc_url( $view_all_url . "#{$post_type_name}-all" ); ?>"
<?php _e( 'View All' ); ?>
<li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>>
data-type="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-search" ); ?>"
href="<?php echo esc_url( $search_url . "#tabs-panel-posttype-{$post_type_name}-search" ); ?>"
</ul><!-- .posttype-tabs -->
<div id="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-most-recent" ); ?>"
class="tabs-panel <?php echo ( 'most-recent' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>"
role="region" aria-label="<?php esc_attr_e( 'Most Recent' ); ?>" tabindex="0"
<ul id="<?php echo esc_attr( "{$post_type_name}checklist-most-recent" ); ?>"
class="categorychecklist form-no-clear"
$recent_args = array_merge(
'orderby' => 'post_date',
$most_recent = $get_posts->query( $recent_args );
$args['walker'] = $walker;
* Filters the posts displayed in the 'Most Recent' tab of the current
* post type's menu items meta box.
* The dynamic portion of the hook name, `$post_type_name`, refers to the post type name.
* Possible hook names include:
* - `nav_menu_items_post_recent`
* - `nav_menu_items_page_recent`
* @since 4.9.0 Added the `$recent_args` parameter.
* @param WP_Post[] $most_recent An array of post objects being listed.
* @param array $args An array of `WP_Query` arguments for the meta box.
* @param array $box Arguments passed to `wp_nav_menu_item_post_type_meta_box()`.
* @param array $recent_args An array of `WP_Query` arguments for 'Most Recent' tab.
$most_recent = apply_filters(
"nav_menu_items_{$post_type_name}_recent",
array_map( 'wp_setup_nav_menu_item', $most_recent ),
</div><!-- /.tabs-panel -->
<div id="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-search" ); ?>"
class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>"
role="region" aria-label="<?php echo esc_attr( $post_type->labels->search_items ); ?>" tabindex="0"
if ( isset( $_REQUEST[ "quick-search-posttype-{$post_type_name}" ] ) ) {
$searched = esc_attr( $_REQUEST[ "quick-search-posttype-{$post_type_name}" ] );
$search_results = get_posts(
'post_type' => $post_type_name,
$search_results = array();
<p class="quick-search-wrap">
<label for="<?php echo esc_attr( "quick-search-posttype-{$post_type_name}" ); ?>" class="screen-reader-text">
/* translators: Hidden accessibility text. */
<input type="search"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?>
class="quick-search" value="<?php echo $searched; ?>"
name="<?php echo esc_attr( "quick-search-posttype-{$post_type_name}" ); ?>"
id="<?php echo esc_attr( "quick-search-posttype-{$post_type_name}" ); ?>"
<span class="spinner"></span>
'small quick-search-submit hide-if-js',
array( 'id' => "submit-quick-search-posttype-{$post_type_name}" )
<ul id="<?php echo esc_attr( "{$post_type_name}-search-checklist" ); ?>"
data-wp-lists="<?php echo esc_attr( "list:{$post_type_name}" ); ?>"
class="categorychecklist form-no-clear"
<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
$args['walker'] = $walker;
array_map( 'wp_setup_nav_menu_item', $search_results ),
<?php elseif ( is_wp_error( $search_results ) ) : ?>
<li><?php echo $search_results->get_error_message(); ?></li>
<?php elseif ( ! empty( $searched ) ) : ?>
<li><?php _e( 'No results found.' ); ?></li>
</div><!-- /.tabs-panel -->
<div id="<?php echo esc_attr( "{$post_type_name}-all" ); ?>"
class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>"
role="region" aria-label="<?php echo esc_attr( $post_type->labels->all_items ); ?>" tabindex="0"
<?php if ( ! empty( $page_links ) ) : ?>
<div class="add-menu-item-pagelinks">
<?php echo $page_links; ?>
<ul id="<?php echo esc_attr( "{$post_type_name}checklist" ); ?>"
data-wp-lists="<?php echo esc_attr( "list:{$post_type_name}" ); ?>"
class="categorychecklist form-no-clear"
$args['walker'] = $walker;
if ( $post_type->has_archive ) {
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? (int) $_nav_menu_placeholder - 1 : -1;
'object_id' => $_nav_menu_placeholder,
'object' => $post_type_name,
'post_title' => $post_type->labels->archives,
'post_type' => 'nav_menu_item',
'type' => 'post_type_archive',
'url' => get_post_type_archive_link( $post_type_name ),
* Filters the posts displayed in the 'View All' tab of the current
* post type's menu items meta box.
* The dynamic portion of the hook name, `$post_type_name`, refers
* to the slug of the current post type.
* Possible hook names include:
* - `nav_menu_items_post`
* - `nav_menu_items_page`
* @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object.
* @param object[] $posts The posts for the current post type. Mostly `WP_Post` objects, but
* can also contain "fake" post objects to represent other menu items.
* @param array $args An array of `WP_Query` arguments.
* @param WP_Post_Type $post_type The current post type object for this menu item meta box.
"nav_menu_items_{$post_type_name}",
$checkbox_items = walk_nav_menu_tree(
array_map( 'wp_setup_nav_menu_item', $posts ),
<?php if ( ! empty( $page_links ) ) : ?>
<div class="add-menu-item-pagelinks">
<?php echo $page_links; ?>
</div><!-- /.tabs-panel -->
<p class="button-controls wp-clearfix" data-items-type="<?php echo esc_attr( "posttype-{$post_type_name}" ); ?>">
<span class="list-controls hide-if-no-js">
<input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?>
id="<?php echo esc_attr( $tab_name ); ?>" class="select-all"
<label for="<?php echo esc_attr( $tab_name ); ?>"><?php _e( 'Select All' ); ?></label>
<span class="add-to-menu">
<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?>
class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>"
name="add-post-type-menu-item" id="<?php echo esc_attr( "submit-posttype-{$post_type_name}" ); ?>"
<span class="spinner"></span>
</div><!-- /.posttypediv -->
* Displays a meta box for a taxonomy menu item.
* @global int|string $nav_menu_selected_id
* @param string $data_object Not used.
* Taxonomy menu item meta box arguments.
* @type string $id Meta box 'id' attribute.
* @type string $title Meta box title.
* @type callable $callback Meta box display callback.
* @type object $args Extra meta box arguments (the taxonomy object for this meta box).
function wp_nav_menu_item_taxonomy_meta_box( $data_object, $box ) {
global $nav_menu_selected_id;
$taxonomy_name = $box['args']->name;
$taxonomy = get_taxonomy( $taxonomy_name );
$tab_name = $taxonomy_name . '-tab';
// Paginate browsing for large numbers of objects.
$pagenum = isset( $_REQUEST[ $tab_name ] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
$offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;
'taxonomy' => $taxonomy_name,
$terms = get_terms( $args );
if ( ! $terms || is_wp_error( $terms ) ) {
echo '<p>' . __( 'No items.' ) . '</p>';
$page_links = paginate_links(
'item-type' => 'taxonomy',
'item-object' => $taxonomy_name,
'prev_text' => '<span aria-label="' . esc_attr__( 'Previous page' ) . '">' . __( '«' ) . '</span>',
'next_text' => '<span aria-label="' . esc_attr__( 'Next page' ) . '">' . __( '»' ) . '</span>',
/* translators: Hidden accessibility text. */
'before_page_number' => '<span class="screen-reader-text">' . __( 'Page' ) . '</span> ',
if ( is_taxonomy_hierarchical( $taxonomy_name ) ) {
$walker = new Walker_Nav_Menu_Checklist( $db_fields );
$current_tab = 'most-used';
if ( isset( $_REQUEST[ $tab_name ] ) && in_array( $_REQUEST[ $tab_name ], array( 'all', 'most-used', 'search' ), true ) ) {
$current_tab = $_REQUEST[ $tab_name ];
if ( ! empty( $_REQUEST[ "quick-search-taxonomy-{$taxonomy_name}" ] ) ) {
if ( $nav_menu_selected_id ) {
$most_used_url = add_query_arg( $tab_name, 'most-used', remove_query_arg( $removed_args ) );
$view_all_url = add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) );
$search_url = add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) );
<div id="<?php echo esc_attr( "taxonomy-{$taxonomy_name}" ); ?>" class="taxonomydiv">
<ul id="<?php echo esc_attr( "taxonomy-{$taxonomy_name}-tabs" ); ?>" class="taxonomy-tabs add-menu-item-tabs">
<li <?php echo ( 'most-used' === $current_tab ? ' class="tabs"' : '' ); ?>>
data-type="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-pop" ); ?>"
href="<?php echo esc_url( $most_used_url . "#tabs-panel-{$taxonomy_name}-pop" ); ?>"
<?php echo esc_html( $taxonomy->labels->most_used ); ?>
<li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>>
data-type="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-all" ); ?>"
href="<?php echo esc_url( $view_all_url . "#tabs-panel-{$taxonomy_name}-all" ); ?>"
<?php _e( 'View All' ); ?>
<li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>>
data-type="<?php echo esc_attr( "tabs-panel-search-taxonomy-{$taxonomy_name}" ); ?>"
href="<?php echo esc_url( $search_url . "#tabs-panel-search-taxonomy-{$taxonomy_name}" ); ?>"
</ul><!-- .taxonomy-tabs -->
<div id="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-pop" ); ?>"
class="tabs-panel <?php echo ( 'most-used' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>"
role="region" aria-label="<?php echo esc_attr( $taxonomy->labels->most_used ); ?>" tabindex="0"
<ul id="<?php echo esc_attr( "{$taxonomy_name}checklist-pop" ); ?>"
class="categorychecklist form-no-clear"
$popular_terms = get_terms(
'taxonomy' => $taxonomy_name,
$args['walker'] = $walker;
array_map( 'wp_setup_nav_menu_item', $popular_terms ),