79 | | $obj_type = sanitize_key( $_POST['obj_type'] ); |
80 | | if ( ! in_array( $obj_type, array( 'post_type', 'taxonomy' ) ) ) { |
| 79 | $obj_type = sanitize_key( $_POST['obj_type'] ); |
| 80 | $valid_obj_types = array(); |
| 81 | |
| 82 | if ( empty( $this->items ) ) { |
| 83 | $this->items = $this->available_item_types(); |
| 84 | |
| 85 | foreach ( $this->items as $item_types ) { |
| 86 | // Continue if no item types set for the item |
| 87 | if ( empty( $item_types ) ) { |
| 88 | continue; |
| 89 | } |
| 90 | |
| 91 | // Loop through item types to set valid types |
| 92 | foreach( $item_types as $item_type ) { |
| 93 | if ( isset( $item_type['type'] ) && ! in_array( $item_type['type'], $valid_obj_types ) ) { |
| 94 | $valid_obj_types[] = $item_type['type']; |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | // Defaults to post_type & taxonomy objects |
| 100 | } else { |
| 101 | $valid_obj_types = array( 'post_type', 'taxonomy' ); |
| 102 | } |
| 103 | |
| 104 | if ( ! in_array( $obj_type, $valid_obj_types ) ) { |
| 172 | |
| 173 | // Let plugins populate their custom items |
| 174 | } else { |
| 175 | $custom_obj_types = array_diff( $valid_obj_types, array( 'post_type', 'taxonomy' ) ); |
| 176 | |
| 177 | if ( ! empty( $custom_obj_types ) ) { |
| 178 | foreach( $custom_obj_types as $custom_obj_type ) { |
| 179 | /** |
| 180 | * Filter here to add your custom items |
| 181 | * |
| 182 | * @param array $items |
| 183 | * @param string $taxonomy_or_post_type the requested type |
| 184 | * @param int $page the page num being requested |
| 185 | */ |
| 186 | $items = apply_filters( "customizer_nav_menus_{$custom_obj_type}_get_items", array(), $taxonomy_or_post_type, $page ); |
| 187 | } |
| 188 | } |
655 | | $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); |
656 | | if ( $post_types ) : |
657 | | foreach ( $post_types as $type ) : |
658 | | ?> |
659 | | <div id="available-menu-items-<?php echo esc_attr( $type->name ); ?>" class="accordion-section"> |
660 | | <h4 class="accordion-section-title"><?php echo esc_html( $type->label ); ?> <span class="spinner"></span> <button type="button" class="not-a-button"><span class="screen-reader-text"><?php _e( 'Toggle' ); ?></span></button></h4> |
661 | | <div class="accordion-section-content" data-type="<?php echo esc_attr( $type->name ); ?>" data-obj_type="post_type"></div> |
662 | | </div> |
663 | | <?php |
664 | | endforeach; |
665 | | endif; |
666 | | |
667 | | $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' ); |
668 | | if ( $taxonomies ) : |
669 | | foreach ( $taxonomies as $tax ) : |
670 | | ?> |
671 | | <div id="available-menu-items-<?php echo esc_attr( $tax->name ); ?>" class="accordion-section"> |
672 | | <h4 class="accordion-section-title"><?php echo esc_html( $tax->label ); ?> <span class="spinner"></span> <button type="button" class="not-a-button"><span class="screen-reader-text"><?php _e( 'Toggle' ); ?></span></button></h4> |
673 | | <div class="accordion-section-content" data-type="<?php echo esc_attr( $tax->name ); ?>" data-obj_type="taxonomy"></div> |
| 709 | |
| 710 | // Stop if no items set |
| 711 | if ( empty( $this->items ) ) { |
| 712 | return; |
| 713 | } |
| 714 | |
| 715 | foreach ( $this->items as $item_types ) { |
| 716 | // Continue if no item types set for the item |
| 717 | if ( empty( $item_types ) ) { |
| 718 | continue; |
| 719 | } |
| 720 | |
| 721 | // Loop through item types to build templates |
| 722 | foreach( $item_types as $item_type ) : ?> |
| 723 | <div id="available-menu-items-<?php echo esc_attr( $item_type['name'] ); ?>" class="accordion-section"> |
| 724 | <h4 class="accordion-section-title"><?php echo esc_html( $item_type['label'] ); ?> <span class="spinner"></span> <button type="button" class="not-a-button"><span class="screen-reader-text"><?php _e( 'Toggle' ); ?></span></button></h4> |
| 725 | <div class="accordion-section-content" data-type="<?php echo esc_attr( $item_type['name'] ); ?>" data-obj_type="<?php echo esc_attr( $item_type['type'] ); ?>"></div> |