get_panel() 공개 메소드

Retrieve a customize panel.
부터: 4.0.0
public get_panel ( string $id ) : WP_Customize_Panel | void
$id string Panel ID to get.
리턴 WP_Customize_Panel | void Requested panel instance, if set.
	/**
	 * Render the widget form control templates into the DOM.
	 *
	 * @since 3.9.0
	 * @access public
	 */
	public function output_widget_control_templates() {
		?>
		<div id="widgets-left"><!-- compatibility with JS which looks for widget templates here -->
		<div id="available-widgets">
			<div class="customize-section-title">
				<button class="customize-section-back" tabindex="-1">
					<span class="screen-reader-text"><?php _e( 'Back' ); ?></span>
				</button>
				<h3>
					<span class="customize-action"><?php
						/* translators: &#9656; is the unicode right-pointing triangle, and %s is the section title in the Customizer */
						echo sprintf( __( 'Customizing &#9656; %s' ), esc_html( $this->manager->get_panel( 'widgets' )->title ) );
					?></span>
					<?php _e( 'Add a Widget' ); ?>
				</h3>
			</div>
			<div id="available-widgets-filter">
				<label class="screen-reader-text" for="widgets-search"><?php _e( 'Search Widgets' ); ?></label>
				<input type="search" id="widgets-search" placeholder="<?php esc_attr_e( 'Search widgets&hellip;' ) ?>" />
			</div>
			<div id="available-widgets-list">
			<?php foreach ( $this->get_available_widgets() as $available_widget ): ?>
				<div id="widget-tpl-<?php echo esc_attr( $available_widget['id'] ) ?>" data-widget-id="<?php echo esc_attr( $available_widget['id'] ) ?>" class="widget-tpl <?php echo esc_attr( $available_widget['id'] ) ?>" tabindex="0">
					<?php echo $available_widget['control_tpl']; ?>
				</div>
			<?php endforeach; ?>
			</div><!-- #available-widgets-list -->
		</div><!-- #available-widgets -->
		</div><!-- #widgets-left -->
		<?php
	}
 /**
  * Handle a panel entry
  *
  * @param $id
  * @param array $data
  * @param array|null $sections
  */
 public function setPanel($id, array $data, array $sections = null)
 {
     $panel_data = $this->getPanelData($data);
     if (is_null($sections) && isset($data['sections'])) {
         $sections = $data['sections'];
     }
     $item = $this->customizer->get_panel($id);
     if ($item) {
         foreach ($data as $var => $val) {
             if (array_key_exists($var, $panel_data)) {
                 $item->{$var} = $val;
             }
         }
         if (isset($data['delete']) && $data['delete'] === true) {
             $this->customizer->remove_panel($id);
         }
     } else {
         $this->customizer->add_panel(new WP_Customize_Panel($this->customizer, $id, $panel_data));
     }
     if (!is_null($sections)) {
         $sections['object'] = 'sections';
         $sections['panel'] = $id;
         $this->processData($sections);
     }
 }
예제 #3
0
 /**
  * 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 &#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-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);
         }
     }
     $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('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);
 }
예제 #4
0
 /**
  * @see WP_Customize_Widgets::is_panel_active()
  */
 function test_is_panel_active()
 {
     global $wp_registered_sidebars;
     $this->do_customize_boot_actions();
     $this->assertNotEmpty($wp_registered_sidebars);
     $this->assertTrue($this->manager->widgets->is_panel_active());
     $this->assertTrue($this->manager->get_panel('widgets')->active());
     $wp_registered_sidebars = array();
     $this->assertFalse($this->manager->widgets->is_panel_active());
     $this->assertFalse($this->manager->get_panel('widgets')->active());
 }
 /**
  * Register the base Panel for Events Calendar Sections to be attached to
  *
  * @since 4.0
  *
  * @return WP_Customize_Panel
  */
 private function register_panel()
 {
     $panel = $this->manager->get_panel($this->ID);
     // If the Panel already exists we leave returning it's instance
     if (!empty($panel)) {
         return $panel;
     }
     $panel_args = apply_filters('tribe_events_pro_customizer_panel_args', array('title' => esc_html__('The Events Calendar', 'tribe-events-calendar-pro'), 'description' => esc_html__('Use the following panel of your customizer to change the styling of your Calendar and Event pages.', 'tribe-events-calendar-pro'), 'priority' => 125), $this->ID, $this);
     // Actually Register the Panel
     $this->manager->add_panel($this->ID, $panel_args);
     // Return the Panel instance
     return $this->manager->get_panel($this->ID);
 }
 /**
  * Gather the parameters passed to client JavaScript via JSON.
  *
  * @since 4.1.0
  *
  * @return array The array to be exported to the client as JSON.
  */
 public function json()
 {
     $array = wp_array_slice_assoc((array) $this, array('id', 'title', 'description', 'priority', 'panel', 'type'));
     $array['content'] = $this->get_content();
     $array['active'] = $this->active();
     $array['instanceNumber'] = $this->instance_number;
     if ($this->panel) {
         /* translators: &#9656; is the unicode right-pointing triangle, and %s is the section title in the Customizer */
         $array['customizeAction'] = sprintf(__('Customizing &#9656; %s'), esc_html($this->manager->get_panel($this->panel)->title));
     } else {
         $array['customizeAction'] = __('Customizing');
     }
     return $array;
 }
 public function customize_register(WP_Customize_Manager $customizeManager)
 {
     // this field will be checked in settings method
     PP_Customizer_Customizer()->settings->customizeManager = $customizeManager;
     $settings = PP_Customizer_Customizer()->settings->get_settings();
     foreach ($settings as $sectionID => $isEnabled) {
         if ($isEnabled == 'false') {
             $panel = $customizeManager->get_panel($sectionID);
             if (isset($panel) && $panel != null) {
                 // is a panel, remove it
                 $customizeManager->remove_panel($sectionID);
             } else {
                 $customizeManager->remove_section($sectionID);
             }
         }
     }
 }
 /**
  * Gather the parameters passed to client JavaScript via JSON.
  *
  * @return array The array to be exported to the client as JSON.
  */
 public function json()
 {
     $array = parent::json();
     if ($this->screen) {
         /* translators: &#9656; is the unicode right-pointing triangle, and %s is the section title in the Customizer */
         $array['customizeAction'] = sprintf(__('Customizing &#9656; %s'), esc_html($this->manager->get_panel($this->screen)->title));
     } else {
         $array['customizeAction'] = __('Customizing');
     }
     // Backwards compatibility for old property names
     foreach ($this->property_map as $backcompat_arg => $actual_arg) {
         if (isset($array[$actual_arg])) {
             $array[$backcompat_arg] = $array[$actual_arg];
         }
     }
     return $array;
 }
예제 #9
0
파일: bootstrap.php 프로젝트: jalex403/make
 /**
  * Register Customizer panels
  *
  * @since  1.3.0.
  *
  * @param  WP_Customize_Manager    $wp_customize    Customizer object.
  * @return void
  */
 function ttfmake_customizer_add_panels($wp_customize)
 {
     $priority = new TTFMAKE_Prioritizer(1000, 100);
     $theme_prefix = 'ttfmake_';
     // Get panel definitions
     $panels = ttfmake_customizer_get_panels();
     // Add panels
     foreach ($panels as $panel => $data) {
         // Determine priority
         if (!isset($data['priority'])) {
             $data['priority'] = $priority->add();
         }
         // Add panel
         $wp_customize->add_panel($theme_prefix . $panel, $data);
     }
     // Re-prioritize and rename the Widgets panel
     if (!isset($wp_customize->get_panel('widgets')->priority)) {
         $wp_customize->add_panel('widgets');
     }
     $wp_customize->get_panel('widgets')->priority = $priority->add();
     $wp_customize->get_panel('widgets')->title = __('Sidebars & Widgets', 'make');
 }
    /**
     * Print the html template used to render the add-menu-item frame.
     *
     * @since 4.3.0
     * @access public
     */
    public function available_items_template()
    {
        ?>
		<div id="available-menu-items" class="accordion-container">
			<div class="customize-section-title">
				<button type="button" class="customize-section-back" tabindex="-1">
					<span class="screen-reader-text"><?php 
        _e('Back');
        ?>
</span>
				</button>
				<h3>
					<span class="customize-action">
						<?php 
        /* translators: &#9656; is the unicode right-pointing triangle, and %s is the section title in the Customizer */
        printf(__('Customizing &#9656; %s'), esc_html($this->manager->get_panel('nav_menus')->title));
        ?>
					</span>
					<?php 
        _e('Add Menu Items');
        ?>
				</h3>
			</div>
			<div id="available-menu-items-search" class="accordion-section cannot-expand">
				<div class="accordion-section-title">
					<label class="screen-reader-text" for="menu-items-search"><?php 
        _e('Search Menu Items');
        ?>
</label>
					<input type="text" id="menu-items-search" placeholder="<?php 
        esc_attr_e('Search menu items&hellip;');
        ?>
" aria-describedby="menu-items-search-desc" />
					<p class="screen-reader-text" id="menu-items-search-desc"><?php 
        _e('The search results will be updated as you type.');
        ?>
</p>
					<span class="spinner"></span>
					<span class="clear-results"><span class="screen-reader-text"><?php 
        _e('Clear Results');
        ?>
</span></span>
				</div>
				<ul class="accordion-section-content" data-type="search"></ul>
			</div>
			<div id="new-custom-menu-item" class="accordion-section">
				<h4 class="accordion-section-title" role="presentation">
					<?php 
        _e('Custom Links');
        ?>
					<button type="button" class="button-link" aria-expanded="false">
						<span class="screen-reader-text"><?php 
        _e('Toggle section: Custom Links');
        ?>
</span>
						<span class="toggle-indicator" aria-hidden="true"></span>
					</button>
				</h4>
				<div class="accordion-section-content customlinkdiv">
					<input type="hidden" value="custom" id="custom-menu-item-type" name="menu-item[-1][menu-item-type]" />
					<p id="menu-item-url-wrap">
						<label class="howto" for="custom-menu-item-url"><?php 
        _e('URL');
        ?>
</label>
						<input id="custom-menu-item-url" name="menu-item[-1][menu-item-url]" type="text" class="code menu-item-textbox" value="http://">
					</p>
					<p id="menu-item-name-wrap">
						<label class="howto" for="custom-menu-item-name"><?php 
        _e('Link Text');
        ?>
</label>
						<input id="custom-menu-item-name" name="menu-item[-1][menu-item-title]" type="text" class="regular-text menu-item-textbox">
					</p>
					<p class="button-controls">
						<span class="add-to-menu">
							<input type="submit" class="button-secondary submit-add-to-menu right" value="<?php 
        esc_attr_e('Add to Menu');
        ?>
" name="add-custom-menu-item" id="custom-menu-item-submit">
							<span class="spinner"></span>
						</span>
					</p>
				</div>
			</div>
			<?php 
        // Containers for per-post-type item browsing; items added with JS.
        foreach ($this->available_item_types() as $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>
					<ul class="accordion-section-content" data-type="<?php 
            echo esc_attr($available_item_type['type']);
            ?>
" data-object="<?php 
            echo esc_attr($available_item_type['object']);
            ?>
"></ul>
				</div>
				<?php 
        }
        ?>
		</div><!-- #available-menu-items -->
	<?php 
    }
	/**
	 * Print the html template used to render the add-menu-item frame.
	 *
	 * @since 4.3.0
	 */
	public function available_items_template() {
		?>
		<div id="available-menu-items" class="accordion-container">
			<div class="customize-section-title">
				<button type="button" class="customize-section-back" tabindex="-1">
					<span class="screen-reader-text"><?php _e( 'Back' ); ?></span>
				</button>
				<h3>
					<span class="customize-action">
						<?php
							/* translators: &#9656; is the unicode right-pointing triangle, and %s is the section title in the Customizer */
							printf( __( 'Customizing &#9656; %s' ), esc_html( $this->manager->get_panel( 'nav_menus' )->title ) );
						?>
					</span>
					<?php _e( 'Add Menu Items' ); ?>
				</h3>
			</div>
			<div id="available-menu-items-search" class="accordion-section cannot-expand">
				<div class="accordion-section-title">
					<label class="screen-reader-text" for="menu-items-search"><?php _e( 'Search Menu Items' ); ?></label>
					<input type="text" id="menu-items-search" placeholder="<?php esc_attr_e( 'Search menu items&hellip;' ) ?>" aria-describedby="menu-items-search-desc" />
					<p class="screen-reader-text" id="menu-items-search-desc"><?php _e( 'The search results will be updated as you type.' ); ?></p>
					<span class="spinner"></span>
				</div>
				<div class="accordion-section-content" data-type="search"></div>
			</div>
			<div id="new-custom-menu-item" class="accordion-section">
				<h4 class="accordion-section-title"><?php _e( 'Custom Links' ); ?><button type="button" class="not-a-button"><span class="screen-reader-text"><?php _e( 'Toggle' ); ?></span></button></h4>
				<div class="accordion-section-content">
					<input type="hidden" value="custom" id="custom-menu-item-type" name="menu-item[-1][menu-item-type]" />
					<p id="menu-item-url-wrap">
						<label class="howto" for="custom-menu-item-url">
							<span><?php _e( 'URL' ); ?></span>
							<input id="custom-menu-item-url" name="menu-item[-1][menu-item-url]" type="text" class="code menu-item-textbox" value="http://">
						</label>
					</p>
					<p id="menu-item-name-wrap">
						<label class="howto" for="custom-menu-item-name">
							<span><?php _e( 'Link Text' ); ?></span>
							<input id="custom-menu-item-name" name="menu-item[-1][menu-item-title]" type="text" class="regular-text menu-item-textbox">
						</label>
					</p>
					<p class="button-controls">
						<span class="add-to-menu">
							<input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-custom-menu-item" id="custom-menu-item-submit">
							<span class="spinner"></span>
						</span>
					</p>
				</div>
			</div>
			<?php

			// @todo: consider using add_meta_box/do_accordion_section and making screen-optional?
			// Containers for per-post-type item browsing; items added with JS.
			$post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
			if ( $post_types ) :
				foreach ( $post_types as $type ) :
					?>
					<div id="available-menu-items-<?php echo esc_attr( $type->name ); ?>" class="accordion-section">
						<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>
						<div class="accordion-section-content" data-type="<?php echo esc_attr( $type->name ); ?>" data-obj_type="post_type"></div>
					</div>
				<?php
				endforeach;
			endif;

			$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' );
			if ( $taxonomies ) :
				foreach ( $taxonomies as $tax ) :
					?>
					<div id="available-menu-items-<?php echo esc_attr( $tax->name ); ?>" class="accordion-section">
						<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>
						<div class="accordion-section-content" data-type="<?php echo esc_attr( $tax->name ); ?>" data-obj_type="taxonomy"></div>
					</div>
				<?php
				endforeach;
			endif;
			?>
		</div><!-- #available-menu-items -->
	<?php
	}
    /**
     * Print the html template used to render the add-menu-item frame.
     *
     * @since 4.3.0
     * @access public
     */
    public function available_items_template()
    {
        ?>
		<div id="available-menu-items" class="accordion-container">
			<div class="customize-section-title">
				<button type="button" class="customize-section-back" tabindex="-1">
					<span class="screen-reader-text"><?php 
        _e('Back');
        ?>
</span>
				</button>
				<h3>
					<span class="customize-action">
						<?php 
        /* translators: &#9656; is the unicode right-pointing triangle, and %s is the section title in the Customizer */
        printf(__('Customizing &#9656; %s'), esc_html($this->manager->get_panel('nav_menus')->title));
        ?>
					</span>
					<?php 
        _e('Add Menu Items');
        ?>
				</h3>
			</div>
			<div id="available-menu-items-search" class="accordion-section cannot-expand">
				<div class="accordion-section-title">
					<label class="screen-reader-text" for="menu-items-search"><?php 
        _e('Search Menu Items');
        ?>
</label>
					<input type="text" id="menu-items-search" placeholder="<?php 
        esc_attr_e('Search menu items&hellip;');
        ?>
" aria-describedby="menu-items-search-desc" />
					<p class="screen-reader-text" id="menu-items-search-desc"><?php 
        _e('The search results will be updated as you type.');
        ?>
</p>
					<span class="spinner"></span>
				</div>
				<div class="search-icon" aria-hidden="true"></div>
				<button type="button" class="clear-results"><span class="screen-reader-text"><?php 
        _e('Clear Results');
        ?>
</span></button>
				<ul class="accordion-section-content available-menu-items-list" data-type="search"></ul>
			</div>
			<?php 
        // Ensure the page post type comes first in the list.
        $item_types = $this->available_item_types();
        $page_item_type = null;
        foreach ($item_types as $i => $item_type) {
            if (isset($item_type['object']) && 'page' === $item_type['object']) {
                $page_item_type = $item_type;
                unset($item_types[$i]);
            }
        }
        $this->print_custom_links_available_menu_item();
        if ($page_item_type) {
            $this->print_post_type_container($page_item_type);
        }
        // Containers for per-post-type item browsing; items are added with JS.
        foreach ($item_types as $item_type) {
            $this->print_post_type_container($item_type);
        }
        ?>
		</div><!-- #available-menu-items -->
	<?php 
    }