WP_Customize_Nav_Menus::print_post_type_container( array $available_item_type )

In this article

Prints the markup for new menu items.

Description

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

Parameters

$available_item_typearrayrequired
Menu item data to output, including title, type, and label.

Source

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">
			<button type="button" class="accordion-trigger" aria-expanded="false" aria-controls="<?php echo esc_attr( $id ); ?>-content">
				<?php echo esc_html( $available_item_type['title'] ); ?>
				<span class="spinner"></span>
				<span class="no-items"><?php _e( 'No items' ); ?></span>
				<span class="toggle-indicator" aria-hidden="true"></span>
			</button>
		</h4>
		<div class="accordion-section-content" id="<?php echo esc_attr( $id ); ?>-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-wrapper">
						<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>
						<div class="new-content-item">
							<input type="text" id="<?php echo esc_attr( 'create-item-input-' . $available_item_type['object'] ); ?>" class="create-item-input">
							<button type="button" class="button add-content"><?php _e( 'Add' ); ?></button>
						</div>
					</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
}

Changelog

VersionDescription
4.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.