available_items_template() public method

Print the html template used to render the add-menu-item frame.
Since: 4.3.0
コード例 #1
0
ファイル: nav-menus.php プロジェクト: kucrut/wordpress
 /**
  * Test the available_items_template method.
  *
  * @see WP_Customize_Nav_Menus::available_items_template()
  */
 function test_available_items_template()
 {
     add_filter('customize_nav_menu_available_item_types', array($this, 'filter_item_types'));
     do_action('customize_register', $this->wp_customize);
     $menus = new WP_Customize_Nav_Menus($this->wp_customize);
     ob_start();
     $menus->available_items_template();
     $template = ob_get_clean();
     $expected = sprintf('Customizing ▸ %s', esc_html($this->wp_customize->get_panel('nav_menus')->title));
     $this->assertContains($expected, $template);
     $post_types = get_post_types(array('show_in_nav_menus' => true), 'object');
     if ($post_types) {
         foreach ($post_types as $type) {
             $this->assertContains('available-menu-items-post_type-' . esc_attr($type->name), $template);
             $this->assertRegExp('#<h4 class="accordion-section-title".*>\\s*' . esc_html($type->labels->name) . '#', $template);
             $this->assertContains('data-type="post_type"', $template);
             $this->assertContains('data-object="' . esc_attr($type->name) . '"', $template);
             $this->assertContains('data-type_label="' . esc_attr($type->labels->singular_name) . '"', $template);
         }
     }
     $taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'object');
     if ($taxonomies) {
         foreach ($taxonomies as $tax) {
             $this->assertContains('available-menu-items-taxonomy-' . esc_attr($tax->name), $template);
             $this->assertRegExp('#<h4 class="accordion-section-title".*>\\s*' . esc_html($tax->labels->name) . '#', $template);
             $this->assertContains('data-type="taxonomy"', $template);
             $this->assertContains('data-object="' . esc_attr($tax->name) . '"', $template);
             $this->assertContains('data-type_label="' . esc_attr($tax->labels->singular_name) . '"', $template);
         }
     }
     $this->assertContains('available-menu-items-custom_type', $template);
     $this->assertRegExp('#<h4 class="accordion-section-title".*>\\s*Custom#', $template);
     $this->assertContains('data-type="custom_type"', $template);
     $this->assertContains('data-object="custom_object"', $template);
     $this->assertContains('data-type_label="Custom Type"', $template);
 }
コード例 #2
0
ファイル: nav-menus.php プロジェクト: Benrajalu/philRaj
 /**
  * Test the available_items_template method.
  *
  * @see WP_Customize_Nav_Menus::available_items_template()
  */
 function test_available_items_template()
 {
     do_action('customize_register', $this->wp_customize);
     $menus = new WP_Customize_Nav_Menus($this->wp_customize);
     ob_start();
     $menus->available_items_template();
     $template = ob_get_clean();
     $expected = sprintf('Customizing &#9656; %s', esc_html($this->wp_customize->get_panel('nav_menus')->title));
     $this->assertContains($expected, $template);
     $post_types = get_post_types(array('show_in_nav_menus' => true), 'object');
     if ($post_types) {
         foreach ($post_types as $type) {
             $this->assertContains('available-menu-items-' . esc_attr($type->name), $template);
             $this->assertContains('<h4 class="accordion-section-title">' . esc_html($type->label), $template);
             $this->assertContains('data-type="' . esc_attr($type->name) . '" data-obj_type="post_type"', $template);
         }
     }
     $taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'object');
     if ($taxonomies) {
         foreach ($taxonomies as $tax) {
             $this->assertContains('available-menu-items-' . esc_attr($tax->name), $template);
             $this->assertContains('<h4 class="accordion-section-title">' . esc_html($tax->label), $template);
             $this->assertContains('data-type="' . esc_attr($tax->name) . '" data-obj_type="taxonomy"', $template);
         }
     }
 }