wp/wp-includes/class-wp-customize-control.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
   172 	 * @since 3.4.0
   172 	 * @since 3.4.0
   173 	 *
   173 	 *
   174 	 * @param WP_Customize_Manager $manager Customizer bootstrap instance.
   174 	 * @param WP_Customize_Manager $manager Customizer bootstrap instance.
   175 	 * @param string               $id      Control ID.
   175 	 * @param string               $id      Control ID.
   176 	 * @param array                $args    {
   176 	 * @param array                $args    {
   177 	 *     Optional. Arguments to override class property defaults.
   177 	 *     Optional. Array of properties for the new Control object. Default empty array.
   178 	 *
   178 	 *
   179 	 *     @type int                  $instance_number Order in which this instance was created in relation
   179 	 *     @type int                  $instance_number Order in which this instance was created in relation
   180 	 *                                                 to other instances.
   180 	 *                                                 to other instances.
   181 	 *     @type WP_Customize_Manager $manager         Customizer bootstrap instance.
   181 	 *     @type WP_Customize_Manager $manager         Customizer bootstrap instance.
   182 	 *     @type string               $id              Control ID.
   182 	 *     @type string               $id              Control ID.
   183 	 *     @type array                $settings        All settings tied to the control. If undefined, `$id` will
   183 	 *     @type array                $settings        All settings tied to the control. If undefined, `$id` will
   184 	 *                                                 be used.
   184 	 *                                                 be used.
   185 	 *     @type string               $setting         The primary setting for the control (if there is one).
   185 	 *     @type string               $setting         The primary setting for the control (if there is one).
   186 	 *                                                 Default 'default'.
   186 	 *                                                 Default 'default'.
       
   187 	 *     @type string               $capability      Capability required to use this control. Normally this is empty
       
   188 	 *                                                 and the capability is derived from `$settings`.
   187 	 *     @type int                  $priority        Order priority to load the control. Default 10.
   189 	 *     @type int                  $priority        Order priority to load the control. Default 10.
   188 	 *     @type string               $section         Section the control belongs to. Default empty.
   190 	 *     @type string               $section         Section the control belongs to. Default empty.
   189 	 *     @type string               $label           Label for the control. Default empty.
   191 	 *     @type string               $label           Label for the control. Default empty.
   190 	 *     @type string               $description     Description for the control. Default empty.
   192 	 *     @type string               $description     Description for the control. Default empty.
   191 	 *     @type array                $choices         List of choices for 'radio' or 'select' type controls, where
   193 	 *     @type array                $choices         List of choices for 'radio' or 'select' type controls, where
   193 	 *                                                 Default empty array.
   195 	 *                                                 Default empty array.
   194 	 *     @type array                $input_attrs     List of custom input attributes for control output, where
   196 	 *     @type array                $input_attrs     List of custom input attributes for control output, where
   195 	 *                                                 attribute names are the keys and values are the values. Not
   197 	 *                                                 attribute names are the keys and values are the values. Not
   196 	 *                                                 used for 'checkbox', 'radio', 'select', 'textarea', or
   198 	 *                                                 used for 'checkbox', 'radio', 'select', 'textarea', or
   197 	 *                                                 'dropdown-pages' control types. Default empty array.
   199 	 *                                                 'dropdown-pages' control types. Default empty array.
       
   200 	 *     @type bool                 $allow_addition  Show UI for adding new content, currently only used for the
       
   201 	 *                                                 dropdown-pages control. Default false.
   198 	 *     @type array                $json            Deprecated. Use WP_Customize_Control::json() instead.
   202 	 *     @type array                $json            Deprecated. Use WP_Customize_Control::json() instead.
   199 	 *     @type string               $type            Control type. Core controls include 'text', 'checkbox',
   203 	 *     @type string               $type            Control type. Core controls include 'text', 'checkbox',
   200 	 *                                                 'textarea', 'radio', 'select', and 'dropdown-pages'. Additional
   204 	 *                                                 'textarea', 'radio', 'select', and 'dropdown-pages'. Additional
   201 	 *                                                 input types such as 'email', 'url', 'number', 'hidden', and
   205 	 *                                                 input types such as 'email', 'url', 'number', 'hidden', and
   202 	 *                                                 'date' are supported implicitly. Default 'text'.
   206 	 *                                                 'date' are supported implicitly. Default 'text'.
       
   207 	 *     @type callable             $active_callback Active callback.
   203 	 * }
   208 	 * }
   204 	 */
   209 	 */
   205 	public function __construct( $manager, $id, $args = array() ) {
   210 	public function __construct( $manager, $id, $args = array() ) {
   206 		$keys = array_keys( get_object_vars( $this ) );
   211 		$keys = array_keys( get_object_vars( $this ) );
   207 		foreach ( $keys as $key ) {
   212 		foreach ( $keys as $key ) {
   620 				echo $dropdown;
   625 				echo $dropdown;
   621 				?>
   626 				?>
   622 				<?php if ( $this->allow_addition && current_user_can( 'publish_pages' ) && current_user_can( 'edit_theme_options' ) ) : // Currently tied to menus functionality. ?>
   627 				<?php if ( $this->allow_addition && current_user_can( 'publish_pages' ) && current_user_can( 'edit_theme_options' ) ) : // Currently tied to menus functionality. ?>
   623 					<button type="button" class="button-link add-new-toggle">
   628 					<button type="button" class="button-link add-new-toggle">
   624 						<?php
   629 						<?php
   625 						/* translators: %s: add new page label */
   630 						/* translators: %s: Add New Page label. */
   626 						printf( __( '+ %s' ), get_post_type_object( 'page' )->labels->add_new_item );
   631 						printf( __( '+ %s' ), get_post_type_object( 'page' )->labels->add_new_item );
   627 						?>
   632 						?>
   628 					</button>
   633 					</button>
   629 					<div class="new-content-item">
   634 					<div class="new-content-item">
   630 						<label for="create-input-<?php echo $this->id; ?>"><span class="screen-reader-text"><?php _e( 'New page title' ); ?></span></label>
   635 						<label for="create-input-<?php echo $this->id; ?>"><span class="screen-reader-text"><?php _e( 'New page title' ); ?></span></label>
   691 }
   696 }
   692 
   697 
   693 /**
   698 /**
   694  * WP_Customize_Color_Control class.
   699  * WP_Customize_Color_Control class.
   695  */
   700  */
   696 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-color-control.php' );
   701 require_once ABSPATH . WPINC . '/customize/class-wp-customize-color-control.php';
   697 
   702 
   698 /**
   703 /**
   699  * WP_Customize_Media_Control class.
   704  * WP_Customize_Media_Control class.
   700  */
   705  */
   701 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-media-control.php' );
   706 require_once ABSPATH . WPINC . '/customize/class-wp-customize-media-control.php';
   702 
   707 
   703 /**
   708 /**
   704  * WP_Customize_Upload_Control class.
   709  * WP_Customize_Upload_Control class.
   705  */
   710  */
   706 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-upload-control.php' );
   711 require_once ABSPATH . WPINC . '/customize/class-wp-customize-upload-control.php';
   707 
   712 
   708 /**
   713 /**
   709  * WP_Customize_Image_Control class.
   714  * WP_Customize_Image_Control class.
   710  */
   715  */
   711 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-image-control.php' );
   716 require_once ABSPATH . WPINC . '/customize/class-wp-customize-image-control.php';
   712 
   717 
   713 /**
   718 /**
   714  * WP_Customize_Background_Image_Control class.
   719  * WP_Customize_Background_Image_Control class.
   715  */
   720  */
   716 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-background-image-control.php' );
   721 require_once ABSPATH . WPINC . '/customize/class-wp-customize-background-image-control.php';
   717 
   722 
   718 /**
   723 /**
   719  * WP_Customize_Background_Position_Control class.
   724  * WP_Customize_Background_Position_Control class.
   720  */
   725  */
   721 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-background-position-control.php' );
   726 require_once ABSPATH . WPINC . '/customize/class-wp-customize-background-position-control.php';
   722 
   727 
   723 /**
   728 /**
   724  * WP_Customize_Cropped_Image_Control class.
   729  * WP_Customize_Cropped_Image_Control class.
   725  */
   730  */
   726 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-cropped-image-control.php' );
   731 require_once ABSPATH . WPINC . '/customize/class-wp-customize-cropped-image-control.php';
   727 
   732 
   728 /**
   733 /**
   729  * WP_Customize_Site_Icon_Control class.
   734  * WP_Customize_Site_Icon_Control class.
   730  */
   735  */
   731 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-site-icon-control.php' );
   736 require_once ABSPATH . WPINC . '/customize/class-wp-customize-site-icon-control.php';
   732 
   737 
   733 /**
   738 /**
   734  * WP_Customize_Header_Image_Control class.
   739  * WP_Customize_Header_Image_Control class.
   735  */
   740  */
   736 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-header-image-control.php' );
   741 require_once ABSPATH . WPINC . '/customize/class-wp-customize-header-image-control.php';
   737 
   742 
   738 /**
   743 /**
   739  * WP_Customize_Theme_Control class.
   744  * WP_Customize_Theme_Control class.
   740  */
   745  */
   741 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-theme-control.php' );
   746 require_once ABSPATH . WPINC . '/customize/class-wp-customize-theme-control.php';
   742 
   747 
   743 /**
   748 /**
   744  * WP_Widget_Area_Customize_Control class.
   749  * WP_Widget_Area_Customize_Control class.
   745  */
   750  */
   746 require_once( ABSPATH . WPINC . '/customize/class-wp-widget-area-customize-control.php' );
   751 require_once ABSPATH . WPINC . '/customize/class-wp-widget-area-customize-control.php';
   747 
   752 
   748 /**
   753 /**
   749  * WP_Widget_Form_Customize_Control class.
   754  * WP_Widget_Form_Customize_Control class.
   750  */
   755  */
   751 require_once( ABSPATH . WPINC . '/customize/class-wp-widget-form-customize-control.php' );
   756 require_once ABSPATH . WPINC . '/customize/class-wp-widget-form-customize-control.php';
   752 
   757 
   753 /**
   758 /**
   754  * WP_Customize_Nav_Menu_Control class.
   759  * WP_Customize_Nav_Menu_Control class.
   755  */
   760  */
   756 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-control.php' );
   761 require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-control.php';
   757 
   762 
   758 /**
   763 /**
   759  * WP_Customize_Nav_Menu_Item_Control class.
   764  * WP_Customize_Nav_Menu_Item_Control class.
   760  */
   765  */
   761 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-control.php' );
   766 require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-control.php';
   762 
   767 
   763 /**
   768 /**
   764  * WP_Customize_Nav_Menu_Location_Control class.
   769  * WP_Customize_Nav_Menu_Location_Control class.
   765  */
   770  */
   766 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-location-control.php' );
   771 require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-location-control.php';
   767 
   772 
   768 /**
   773 /**
   769  * WP_Customize_Nav_Menu_Name_Control class.
   774  * WP_Customize_Nav_Menu_Name_Control class.
   770  *
   775  *
   771  * As this file is deprecated, it will trigger a deprecation notice if instantiated. In a subsequent
   776  * As this file is deprecated, it will trigger a deprecation notice if instantiated. In a subsequent
   772  * release, the require_once() here will be removed and _deprecated_file() will be called if file is
   777  * release, the require_once here will be removed and _deprecated_file() will be called if file is
   773  * required at all.
   778  * required at all.
   774  *
   779  *
   775  * @deprecated 4.9.0 This file is no longer used due to new menu creation UX.
   780  * @deprecated 4.9.0 This file is no longer used due to new menu creation UX.
   776  */
   781  */
   777 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-name-control.php' );
   782 require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-name-control.php';
   778 
   783 
   779 /**
   784 /**
   780  * WP_Customize_Nav_Menu_Locations_Control class.
   785  * WP_Customize_Nav_Menu_Locations_Control class.
   781  */
   786  */
   782 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-locations-control.php' );
   787 require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-locations-control.php';
   783 
   788 
   784 /**
   789 /**
   785  * WP_Customize_Nav_Menu_Auto_Add_Control class.
   790  * WP_Customize_Nav_Menu_Auto_Add_Control class.
   786  */
   791  */
   787 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-auto-add-control.php' );
   792 require_once ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-auto-add-control.php';
   788 
   793 
   789 /**
   794 /**
   790  * WP_Customize_Date_Time_Control class.
   795  * WP_Customize_Date_Time_Control class.
   791  */
   796  */
   792 require_once( ABSPATH . WPINC . '/customize/class-wp-customize-date-time-control.php' );
   797 require_once ABSPATH . WPINC . '/customize/class-wp-customize-date-time-control.php';