wp/wp-includes/class-wp-customize-section.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 19 3d72ae0968f4
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    75 	 * @var string
    75 	 * @var string
    76 	 */
    76 	 */
    77 	public $capability = 'edit_theme_options';
    77 	public $capability = 'edit_theme_options';
    78 
    78 
    79 	/**
    79 	/**
    80 	 * Theme feature support for the section.
    80 	 * Theme features required to support the section.
    81 	 *
    81 	 *
    82 	 * @since 3.4.0
    82 	 * @since 3.4.0
    83 	 * @var string|array
    83 	 * @var string|string[]
    84 	 */
    84 	 */
    85 	public $theme_supports = '';
    85 	public $theme_supports = '';
    86 
    86 
    87 	/**
    87 	/**
    88 	 * Title of the section to show in UI.
    88 	 * Title of the section to show in UI.
   147 	 * Any supplied $args override class property defaults.
   147 	 * Any supplied $args override class property defaults.
   148 	 *
   148 	 *
   149 	 * @since 3.4.0
   149 	 * @since 3.4.0
   150 	 *
   150 	 *
   151 	 * @param WP_Customize_Manager $manager Customizer bootstrap instance.
   151 	 * @param WP_Customize_Manager $manager Customizer bootstrap instance.
   152 	 * @param string               $id      An specific ID of the section.
   152 	 * @param string               $id      A specific ID of the section.
   153 	 * @param array                $args    Section arguments.
   153 	 * @param array                $args    {
       
   154 	 *     Optional. Array of properties for the new Section object. Default empty array.
       
   155 	 *
       
   156 	 *     @type int             $priority           Priority of the section, defining the display order
       
   157 	 *                                               of panels and sections. Default 160.
       
   158 	 *     @type string          $panel              The panel this section belongs to (if any).
       
   159 	 *                                               Default empty.
       
   160 	 *     @type string          $capability         Capability required for the section.
       
   161 	 *                                               Default 'edit_theme_options'
       
   162 	 *     @type string|string[] $theme_supports     Theme features required to support the section.
       
   163 	 *     @type string          $title              Title of the section to show in UI.
       
   164 	 *     @type string          $description        Description to show in the UI.
       
   165 	 *     @type string          $type               Type of the section.
       
   166 	 *     @type callable        $active_callback    Active callback.
       
   167 	 *     @type bool            $description_hidden Hide the description behind a help icon,
       
   168 	 *                                               instead of inline above the first control.
       
   169 	 *                                               Default false.
       
   170 	 * }
   154 	 */
   171 	 */
   155 	public function __construct( $manager, $id, $args = array() ) {
   172 	public function __construct( $manager, $id, $args = array() ) {
   156 		$keys = array_keys( get_object_vars( $this ) );
   173 		$keys = array_keys( get_object_vars( $this ) );
   157 		foreach ( $keys as $key ) {
   174 		foreach ( $keys as $key ) {
   158 			if ( isset( $args[ $key ] ) ) {
   175 			if ( isset( $args[ $key ] ) ) {
   222 		$array['content']        = $this->get_content();
   239 		$array['content']        = $this->get_content();
   223 		$array['active']         = $this->active();
   240 		$array['active']         = $this->active();
   224 		$array['instanceNumber'] = $this->instance_number;
   241 		$array['instanceNumber'] = $this->instance_number;
   225 
   242 
   226 		if ( $this->panel ) {
   243 		if ( $this->panel ) {
   227 			/* translators: ▸ is the unicode right-pointing triangle, and %s is the section title in the Customizer */
   244 			/* translators: ▸ is the unicode right-pointing triangle. %s: Section title in the Customizer. */
   228 			$array['customizeAction'] = sprintf( __( 'Customizing ▸ %s' ), esc_html( $this->manager->get_panel( $this->panel )->title ) );
   245 			$array['customizeAction'] = sprintf( __( 'Customizing ▸ %s' ), esc_html( $this->manager->get_panel( $this->panel )->title ) );
   229 		} else {
   246 		} else {
   230 			$array['customizeAction'] = __( 'Customizing' );
   247 			$array['customizeAction'] = __( 'Customizing' );
   231 		}
   248 		}
   232 
   249 
   240 	 * @since 3.4.0
   257 	 * @since 3.4.0
   241 	 *
   258 	 *
   242 	 * @return bool False if theme doesn't support the section or user doesn't have the capability.
   259 	 * @return bool False if theme doesn't support the section or user doesn't have the capability.
   243 	 */
   260 	 */
   244 	final public function check_capabilities() {
   261 	final public function check_capabilities() {
   245 		if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) {
   262 		if ( $this->capability && ! current_user_can( $this->capability ) ) {
   246 			return false;
   263 			return false;
   247 		}
   264 		}
   248 
   265 
   249 		if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) ) {
   266 		if ( $this->theme_supports && ! current_theme_supports( ... (array) $this->theme_supports ) ) {
   250 			return false;
   267 			return false;
   251 		}
   268 		}
   252 
   269 
   253 		return true;
   270 		return true;
   254 	}
   271 	}
   374 		<?php
   391 		<?php
   375 	}
   392 	}
   376 }
   393 }
   377 
   394 
   378 /** WP_Customize_Themes_Section class */
   395 /** WP_Customize_Themes_Section class */
   379 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-themes-section.php' );
   396 require_once ABSPATH . WPINC . '/customize/class-wp-customize-themes-section.php';
   380 
   397 
   381 /** WP_Customize_Sidebar_Section class */
   398 /** WP_Customize_Sidebar_Section class */
   382 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-sidebar-section.php' );
   399 require_once ABSPATH . WPINC . '/customize/class-wp-customize-sidebar-section.php';
   383 
   400 
   384 /** WP_Customize_Nav_Menu_Section class */
   401 /** WP_Customize_Nav_Menu_Section class */
   385 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-section.php' );
   402 require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-section.php';
   386 
       
   387 /**
       
   388  * WP_Customize_New_Menu_Section class
       
   389  *
       
   390  * As this file is deprecated, it will trigger a deprecation notice if instantiated. In a subsequent
       
   391  * release, the require_once() here will be removed and _deprecated_file() will be called if file is
       
   392  * required at all.
       
   393  *
       
   394  * @deprecated 4.9.0 This file is no longer used due to new menu creation UX.
       
   395  */
       
   396 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-new-menu-section.php' );