WP_Customize_Nav_Menus::print_post_type_container()protectedWP 4.7.0

Prints the markup for new menu items.

To be used in the template #available-menu-items.

Method of the class: WP_Customize_Nav_Menus{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->print_post_type_container( $available_item_type );
$available_item_type(array) (required)
Menu item data to output, including title, type, and label.

Changelog

Since 4.7.0 Introduced.

WP_Customize_Nav_Menus::print_post_type_container() code WP 6.5.2

<?php
protected function print_post_type_container( $available_item_type ) {
	$id = sprintf( 'available-menu-items-%s-%s', $available_item_type['type'], $available_item_type['object'] );
	?>
	<div id="<?php echo esc_attr( $id ); ?>" class="accordion-section">
		<h4 class="accordion-section-title" role="presentation">
			<?php echo esc_html( $available_item_type['title'] ); ?>
			<span class="spinner"></span>
			<span class="no-items"><?php _e( 'No items' ); ?></span>
			<button type="button" class="button-link" aria-expanded="false">
				<span class="screen-reader-text">
				<?php
					/* translators: %s: Title of a section with menu items. */
					printf( __( 'Toggle section: %s' ), esc_html( $available_item_type['title'] ) );
				?>
					</span>
				<span class="toggle-indicator" aria-hidden="true"></span>
			</button>
		</h4>
		<div class="accordion-section-content">
			<?php if ( 'post_type' === $available_item_type['type'] ) : ?>
				<?php $post_type_obj = get_post_type_object( $available_item_type['object'] ); ?>
				<?php if ( current_user_can( $post_type_obj->cap->create_posts ) && current_user_can( $post_type_obj->cap->publish_posts ) ) : ?>
					<div class="new-content-item">
						<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>
						<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 ); ?>">
						<button type="button" class="button add-content"><?php _e( 'Add' ); ?></button>
					</div>
				<?php endif; ?>
			<?php endif; ?>
			<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>
		</div>
	</div>
	<?php
}