2012-03-28 06:14:09 +02:00
< ? php
/**
2015-02-25 08:56:25 +01:00
* WordPress Customize Control classes
2012-03-28 06:14:09 +02:00
*
* @ package WordPress
* @ subpackage Customize
* @ since 3.4 . 0
*/
2015-02-25 08:56:25 +01:00
/**
* Customize Control class .
*
* @ since 3.4 . 0
*/
2012-03-28 06:14:09 +02:00
class WP_Customize_Control {
2014-11-03 22:35:23 +01:00
/**
* Incremented with each new class instantiation , then stored in $instance_number .
*
* Used when sorting two instances whose priorities are equal .
*
* @ since 4.1 . 0
2015-05-29 17:43:29 +02:00
*
* @ static
2014-11-03 22:35:23 +01:00
* @ var int
*/
protected static $instance_count = 0 ;
/**
* Order in which this instance was created in relation to other instances .
*
* @ since 4.1 . 0
* @ var int
*/
public $instance_number ;
2012-07-26 23:45:33 +02:00
/**
2017-05-19 22:25:41 +02:00
* Customizer manager .
*
* @ since 3.4 . 0
2012-07-26 23:45:33 +02:00
* @ var WP_Customize_Manager
*/
2012-03-28 06:14:09 +02:00
public $manager ;
2012-08-01 04:30:02 +02:00
2012-07-26 23:45:33 +02:00
/**
2017-05-19 22:25:41 +02:00
* Control ID .
*
* @ since 3.4 . 0
2012-07-26 23:45:33 +02:00
* @ var string
*/
2012-03-28 06:14:09 +02:00
public $id ;
2012-07-26 23:45:33 +02:00
/**
* All settings tied to the control .
*
2017-05-19 22:25:41 +02:00
* @ since 3.4 . 0
2012-07-26 23:45:33 +02:00
* @ var array
*/
2012-03-28 06:14:09 +02:00
public $settings ;
2012-06-10 02:32:19 +02:00
2012-07-26 23:45:33 +02:00
/**
* The primary setting for the control ( if there is one ) .
*
2017-05-19 22:25:41 +02:00
* @ since 3.4 . 0
2012-07-26 23:45:33 +02:00
* @ var string
*/
2012-06-10 02:32:19 +02:00
public $setting = 'default' ;
2012-03-28 06:14:09 +02:00
2016-02-24 19:28:28 +01:00
/**
* Capability required to use this control .
*
* Normally this is empty and the capability is derived from the capabilities
* of the associated `$settings` .
*
* @ since 4.5 . 0
* @ var string
*/
public $capability ;
2012-07-26 23:45:33 +02:00
/**
2017-05-19 22:25:41 +02:00
* Order priority to load the control in Customizer .
*
* @ since 3.4 . 0
2012-07-26 23:45:33 +02:00
* @ var int
*/
2014-03-04 21:21:14 +01:00
public $priority = 10 ;
2012-08-01 04:30:02 +02:00
2012-07-26 23:45:33 +02:00
/**
2017-05-19 22:25:41 +02:00
* Section the control belongs to .
*
* @ since 3.4 . 0
2012-07-26 23:45:33 +02:00
* @ var string
*/
2014-03-04 21:21:14 +01:00
public $section = '' ;
2012-08-01 04:30:02 +02:00
2012-07-26 23:45:33 +02:00
/**
2017-05-19 22:25:41 +02:00
* Label for the control .
*
* @ since 3.4 . 0
2012-07-26 23:45:33 +02:00
* @ var string
*/
2014-03-04 21:21:14 +01:00
public $label = '' ;
2012-08-01 04:30:02 +02:00
2014-06-30 17:55:17 +02:00
/**
2017-05-19 22:25:41 +02:00
* Description for the control .
*
* @ since 4.0 . 0
2014-06-30 17:55:17 +02:00
* @ var string
*/
public $description = '' ;
2012-07-26 23:45:33 +02:00
/**
2017-05-19 22:25:41 +02:00
* List of choices for 'radio' or 'select' type controls , where values are the keys , and labels are the values .
2012-07-26 23:45:33 +02:00
*
2017-05-19 22:25:41 +02:00
* @ since 3.4 . 0
2012-07-26 23:45:33 +02:00
* @ var array
*/
2014-03-04 21:21:14 +01:00
public $choices = array ();
2012-03-28 06:14:09 +02:00
2014-06-30 21:48:13 +02:00
/**
2017-05-19 22:25:41 +02:00
* List of custom input attributes for control output , where attribute names are the keys and values are the values .
*
* Not used for 'checkbox' , 'radio' , 'select' , 'textarea' , or 'dropdown-pages' control types .
*
* @ since 4.0 . 0
2014-06-30 21:48:13 +02:00
* @ var array
*/
public $input_attrs = array ();
2016-10-25 08:31:31 +02:00
/**
* Show UI for adding new content , currently only used for the dropdown - pages control .
*
* @ since 4.7 . 0
2016-11-23 07:05:32 +01:00
* @ var bool
2016-10-25 08:31:31 +02:00
*/
public $allow_addition = false ;
2012-07-26 23:45:33 +02:00
/**
Improve/introduce Customizer JavaScript models for Controls, Sections, and Panels.
* Introduce models for panels and sections.
* Introduce API to expand and focus a control, section or panel.
* Allow deep-linking to panels, sections, and controls inside of the Customizer.
* Clean up `accordion.js`, removing all Customizer-specific logic.
* Add initial unit tests for `wp.customize.Class` in `customize-base.js`.
https://make.wordpress.org/core/2014/10/27/toward-a-complete-javascript-api-for-the-customizer/ provides an overview of how to use the JavaScript API.
props westonruter, celloexpressions, ryankienstra.
see #28032, #28579, #28580, #28650, #28709, #29758.
fixes #29529.
Built from https://develop.svn.wordpress.org/trunk@30102
git-svn-id: http://core.svn.wordpress.org/trunk@30102 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-29 23:51:22 +01:00
* @ deprecated It is better to just call the json () method
2017-05-19 22:25:41 +02:00
* @ since 3.4 . 0
2012-07-26 23:45:33 +02:00
* @ var array
*/
2012-03-29 08:35:54 +02:00
public $json = array ();
2012-07-26 23:45:33 +02:00
/**
2017-05-19 22:25:41 +02:00
* Control ' s Type .
*
* @ since 3.4 . 0
2012-07-26 23:45:33 +02:00
* @ var string
*/
2012-03-28 06:14:09 +02:00
public $type = 'text' ;
2014-07-10 01:58:16 +02:00
/**
2014-07-14 02:32:16 +02:00
* Callback .
2014-07-10 01:58:16 +02:00
*
* @ since 4.0 . 0
2014-07-14 02:32:16 +02:00
*
2014-07-10 01:58:16 +02:00
* @ see WP_Customize_Control :: active ()
2014-07-14 02:32:16 +02:00
*
* @ var callable Callback is called with one argument , the instance of
* WP_Customize_Control , and returns bool to indicate whether
* the control is active ( such as it relates to the URL
* currently being previewed ) .
2014-07-10 01:58:16 +02:00
*/
public $active_callback = '' ;
2012-03-28 06:14:09 +02:00
/**
* Constructor .
*
2015-12-28 21:10:35 +01:00
* Supplied `$args` override class property defaults .
2014-03-04 21:21:14 +01:00
*
2015-12-28 21:10:35 +01:00
* If `$args['settings']` is not defined , use the $id as the setting ID .
2012-03-28 06:14:09 +02:00
*
* @ since 3.4 . 0
2012-07-26 23:45:33 +02:00
*
2015-07-13 22:25:24 +02:00
* @ param WP_Customize_Manager $manager Customizer bootstrap instance .
* @ param string $id Control ID .
2015-12-28 21:10:35 +01:00
* @ param array $args {
* Optional . Arguments to override class property defaults .
*
* @ type int $instance_number Order in which this instance was created in relation
* to other instances .
* @ type WP_Customize_Manager $manager Customizer bootstrap instance .
* @ type string $id Control ID .
* @ type array $settings All settings tied to the control . If undefined , `$id` will
* be used .
* @ type string $setting The primary setting for the control ( if there is one ) .
* Default 'default' .
* @ type int $priority Order priority to load the control . Default 10.
* @ type string $section Section the control belongs to . Default empty .
* @ type string $label Label for the control . Default empty .
* @ type string $description Description for the control . Default empty .
* @ type array $choices List of choices for 'radio' or 'select' type controls , where
* values are the keys , and labels are the values .
* Default empty array .
* @ type array $input_attrs List of custom input attributes for control output , where
* attribute names are the keys and values are the values . Not
* used for 'checkbox' , 'radio' , 'select' , 'textarea' , or
* 'dropdown-pages' control types . Default empty array .
2016-05-01 19:28:27 +02:00
* @ type array $json Deprecated . Use WP_Customize_Control :: json () instead .
2015-12-28 21:10:35 +01:00
* @ type string $type Control type . Core controls include 'text' , 'checkbox' ,
* 'textarea' , 'radio' , 'select' , and 'dropdown-pages' . Additional
* input types such as 'email' , 'url' , 'number' , 'hidden' , and
* 'date' are supported implicitly . Default 'text' .
* }
2012-03-28 06:14:09 +02:00
*/
2014-05-19 07:45:16 +02:00
public function __construct ( $manager , $id , $args = array () ) {
2012-03-29 08:35:54 +02:00
$keys = array_keys ( get_object_vars ( $this ) );
2012-03-28 06:14:09 +02:00
foreach ( $keys as $key ) {
2014-07-10 01:58:16 +02:00
if ( isset ( $args [ $key ] ) ) {
2012-03-28 06:14:09 +02:00
$this -> $key = $args [ $key ];
2014-07-10 01:58:16 +02:00
}
2012-03-28 06:14:09 +02:00
}
$this -> manager = $manager ;
$this -> id = $id ;
2014-07-10 01:58:16 +02:00
if ( empty ( $this -> active_callback ) ) {
$this -> active_callback = array ( $this , 'active_callback' );
}
2014-11-03 22:35:23 +01:00
self :: $instance_count += 1 ;
$this -> instance_number = self :: $instance_count ;
2012-03-28 06:14:09 +02:00
// Process settings.
2016-02-24 19:28:28 +01:00
if ( ! isset ( $this -> settings ) ) {
2012-03-28 06:14:09 +02:00
$this -> settings = $id ;
2014-07-10 01:58:16 +02:00
}
2012-03-28 06:14:09 +02:00
$settings = array ();
if ( is_array ( $this -> settings ) ) {
foreach ( $this -> settings as $key => $setting ) {
$settings [ $key ] = $this -> manager -> get_setting ( $setting );
}
2016-02-24 19:28:28 +01:00
} else if ( is_string ( $this -> settings ) ) {
2012-03-28 06:14:09 +02:00
$this -> setting = $this -> manager -> get_setting ( $this -> settings );
$settings [ 'default' ] = $this -> setting ;
}
$this -> settings = $settings ;
}
/**
* Enqueue control related scripts / styles .
*
* @ since 3.4 . 0
*/
2012-04-25 23:03:29 +02:00
public function enqueue () {}
2012-03-28 06:14:09 +02:00
2014-07-10 01:58:16 +02:00
/**
2014-10-15 19:21:19 +02:00
* Check whether control is active to current Customizer preview .
2014-07-10 01:58:16 +02:00
*
* @ since 4.0 . 0
*
2014-07-14 02:32:16 +02:00
* @ return bool Whether the control is active to the current preview .
2014-07-10 01:58:16 +02:00
*/
2015-01-08 07:02:24 +01:00
final public function active () {
2014-07-10 01:58:16 +02:00
$control = $this ;
$active = call_user_func ( $this -> active_callback , $this );
/**
2016-05-22 20:10:29 +02:00
* Filters response of WP_Customize_Control :: active () .
2014-07-10 01:58:16 +02:00
*
* @ since 4.0 . 0
*
2014-07-14 02:32:16 +02:00
* @ param bool $active Whether the Customizer control is active .
* @ param WP_Customize_Control $control WP_Customize_Control instance .
2014-07-10 01:58:16 +02:00
*/
$active = apply_filters ( 'customize_control_active' , $active , $control );
return $active ;
}
/**
* Default callback used when invoking WP_Customize_Control :: active () .
*
* Subclasses can override this with their specific logic , or they may
* provide an 'active_callback' argument to the constructor .
*
2014-07-14 02:32:16 +02:00
* @ since 4.0 . 0
*
2015-05-22 00:05:24 +02:00
* @ return true Always true .
2014-07-10 01:58:16 +02:00
*/
public function active_callback () {
return true ;
}
2012-03-28 06:14:09 +02:00
/**
* Fetch a setting ' s value .
* Grabs the main setting by default .
*
* @ since 3.4 . 0
2012-07-26 23:45:33 +02:00
*
* @ param string $setting_key
* @ return mixed The requested setting ' s value , if the setting exists .
2012-03-28 06:14:09 +02:00
*/
2015-01-08 07:02:24 +01:00
final public function value ( $setting_key = 'default' ) {
2014-07-10 01:58:16 +02:00
if ( isset ( $this -> settings [ $setting_key ] ) ) {
2012-03-28 06:14:09 +02:00
return $this -> settings [ $setting_key ] -> value ();
2014-07-10 01:58:16 +02:00
}
2012-03-28 06:14:09 +02:00
}
2012-03-29 08:35:54 +02:00
/**
* Refresh the parameters passed to the JavaScript via JSON .
*
* @ since 3.4 . 0
*/
public function to_json () {
$this -> json [ 'settings' ] = array ();
2012-03-28 06:14:09 +02:00
foreach ( $this -> settings as $key => $setting ) {
2012-03-29 08:35:54 +02:00
$this -> json [ 'settings' ][ $key ] = $setting -> id ;
2012-03-28 06:14:09 +02:00
}
2014-11-03 22:35:23 +01:00
$this -> json [ 'type' ] = $this -> type ;
$this -> json [ 'priority' ] = $this -> priority ;
$this -> json [ 'active' ] = $this -> active ();
$this -> json [ 'section' ] = $this -> section ;
$this -> json [ 'content' ] = $this -> get_content ();
$this -> json [ 'label' ] = $this -> label ;
2014-10-24 18:32:18 +02:00
$this -> json [ 'description' ] = $this -> description ;
2014-11-03 22:35:23 +01:00
$this -> json [ 'instanceNumber' ] = $this -> instance_number ;
2016-10-25 08:31:31 +02:00
if ( 'dropdown-pages' === $this -> type ) {
$this -> json [ 'allow_addition' ] = $this -> allow_addition ;
}
Improve/introduce Customizer JavaScript models for Controls, Sections, and Panels.
* Introduce models for panels and sections.
* Introduce API to expand and focus a control, section or panel.
* Allow deep-linking to panels, sections, and controls inside of the Customizer.
* Clean up `accordion.js`, removing all Customizer-specific logic.
* Add initial unit tests for `wp.customize.Class` in `customize-base.js`.
https://make.wordpress.org/core/2014/10/27/toward-a-complete-javascript-api-for-the-customizer/ provides an overview of how to use the JavaScript API.
props westonruter, celloexpressions, ryankienstra.
see #28032, #28579, #28580, #28650, #28709, #29758.
fixes #29529.
Built from https://develop.svn.wordpress.org/trunk@30102
git-svn-id: http://core.svn.wordpress.org/trunk@30102 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-29 23:51:22 +01:00
}
/**
* Get the data to export to the client via JSON .
*
* @ since 4.1 . 0
*
2014-11-28 10:20:23 +01:00
* @ return array Array of parameters passed to the JavaScript .
Improve/introduce Customizer JavaScript models for Controls, Sections, and Panels.
* Introduce models for panels and sections.
* Introduce API to expand and focus a control, section or panel.
* Allow deep-linking to panels, sections, and controls inside of the Customizer.
* Clean up `accordion.js`, removing all Customizer-specific logic.
* Add initial unit tests for `wp.customize.Class` in `customize-base.js`.
https://make.wordpress.org/core/2014/10/27/toward-a-complete-javascript-api-for-the-customizer/ provides an overview of how to use the JavaScript API.
props westonruter, celloexpressions, ryankienstra.
see #28032, #28579, #28580, #28650, #28709, #29758.
fixes #29529.
Built from https://develop.svn.wordpress.org/trunk@30102
git-svn-id: http://core.svn.wordpress.org/trunk@30102 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-29 23:51:22 +01:00
*/
public function json () {
$this -> to_json ();
return $this -> json ;
2012-03-28 06:14:09 +02:00
}
/**
2016-02-24 19:28:28 +01:00
* Checks if the user can use this control .
*
* Returns false if the user cannot manipulate one of the associated settings ,
* or if one of the associated settings does not exist . Also returns false if
* the associated section does not exist or if its capability check returns
* false .
2012-03-28 06:14:09 +02:00
*
* @ since 3.4 . 0
*
* @ return bool False if theme doesn 't support the control or user doesn' t have the required permissions , otherwise true .
*/
2015-01-08 07:02:24 +01:00
final public function check_capabilities () {
2016-02-24 19:28:28 +01:00
if ( ! empty ( $this -> capability ) && ! current_user_can ( $this -> capability ) ) {
return false ;
}
2012-03-28 06:14:09 +02:00
foreach ( $this -> settings as $setting ) {
2016-02-24 19:28:28 +01:00
if ( ! $setting || ! $setting -> check_capabilities () ) {
2012-03-28 06:14:09 +02:00
return false ;
2016-02-24 19:28:28 +01:00
}
2012-03-28 06:14:09 +02:00
}
$section = $this -> manager -> get_section ( $this -> section );
2016-02-24 19:28:28 +01:00
if ( isset ( $section ) && ! $section -> check_capabilities () ) {
2012-03-28 06:14:09 +02:00
return false ;
2016-02-24 19:28:28 +01:00
}
2012-03-28 06:14:09 +02:00
return true ;
}
Improve/introduce Customizer JavaScript models for Controls, Sections, and Panels.
* Introduce models for panels and sections.
* Introduce API to expand and focus a control, section or panel.
* Allow deep-linking to panels, sections, and controls inside of the Customizer.
* Clean up `accordion.js`, removing all Customizer-specific logic.
* Add initial unit tests for `wp.customize.Class` in `customize-base.js`.
https://make.wordpress.org/core/2014/10/27/toward-a-complete-javascript-api-for-the-customizer/ provides an overview of how to use the JavaScript API.
props westonruter, celloexpressions, ryankienstra.
see #28032, #28579, #28580, #28650, #28709, #29758.
fixes #29529.
Built from https://develop.svn.wordpress.org/trunk@30102
git-svn-id: http://core.svn.wordpress.org/trunk@30102 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-29 23:51:22 +01:00
/**
* Get the control ' s content for insertion into the Customizer pane .
*
* @ since 4.1 . 0
*
2014-11-28 10:20:23 +01:00
* @ return string Contents of the control .
Improve/introduce Customizer JavaScript models for Controls, Sections, and Panels.
* Introduce models for panels and sections.
* Introduce API to expand and focus a control, section or panel.
* Allow deep-linking to panels, sections, and controls inside of the Customizer.
* Clean up `accordion.js`, removing all Customizer-specific logic.
* Add initial unit tests for `wp.customize.Class` in `customize-base.js`.
https://make.wordpress.org/core/2014/10/27/toward-a-complete-javascript-api-for-the-customizer/ provides an overview of how to use the JavaScript API.
props westonruter, celloexpressions, ryankienstra.
see #28032, #28579, #28580, #28650, #28709, #29758.
fixes #29529.
Built from https://develop.svn.wordpress.org/trunk@30102
git-svn-id: http://core.svn.wordpress.org/trunk@30102 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-29 23:51:22 +01:00
*/
2015-01-08 07:02:24 +01:00
final public function get_content () {
Improve/introduce Customizer JavaScript models for Controls, Sections, and Panels.
* Introduce models for panels and sections.
* Introduce API to expand and focus a control, section or panel.
* Allow deep-linking to panels, sections, and controls inside of the Customizer.
* Clean up `accordion.js`, removing all Customizer-specific logic.
* Add initial unit tests for `wp.customize.Class` in `customize-base.js`.
https://make.wordpress.org/core/2014/10/27/toward-a-complete-javascript-api-for-the-customizer/ provides an overview of how to use the JavaScript API.
props westonruter, celloexpressions, ryankienstra.
see #28032, #28579, #28580, #28650, #28709, #29758.
fixes #29529.
Built from https://develop.svn.wordpress.org/trunk@30102
git-svn-id: http://core.svn.wordpress.org/trunk@30102 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-29 23:51:22 +01:00
ob_start ();
$this -> maybe_render ();
2015-06-27 03:12:24 +02:00
return trim ( ob_get_clean () );
Improve/introduce Customizer JavaScript models for Controls, Sections, and Panels.
* Introduce models for panels and sections.
* Introduce API to expand and focus a control, section or panel.
* Allow deep-linking to panels, sections, and controls inside of the Customizer.
* Clean up `accordion.js`, removing all Customizer-specific logic.
* Add initial unit tests for `wp.customize.Class` in `customize-base.js`.
https://make.wordpress.org/core/2014/10/27/toward-a-complete-javascript-api-for-the-customizer/ provides an overview of how to use the JavaScript API.
props westonruter, celloexpressions, ryankienstra.
see #28032, #28579, #28580, #28650, #28709, #29758.
fixes #29529.
Built from https://develop.svn.wordpress.org/trunk@30102
git-svn-id: http://core.svn.wordpress.org/trunk@30102 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-29 23:51:22 +01:00
}
2012-03-28 06:14:09 +02:00
/**
2012-04-04 19:32:03 +02:00
* Check capabilities and render the control .
2012-03-28 06:14:09 +02:00
*
* @ since 3.4 . 0
2012-07-26 23:45:33 +02:00
* @ uses WP_Customize_Control :: render ()
2012-03-28 06:14:09 +02:00
*/
2015-01-08 07:02:24 +01:00
final public function maybe_render () {
2012-03-28 06:14:09 +02:00
if ( ! $this -> check_capabilities () )
return ;
2014-03-06 14:51:14 +01:00
/**
* Fires just before the current Customizer control is rendered .
*
* @ since 3.4 . 0
*
* @ param WP_Customize_Control $this WP_Customize_Control instance .
*/
2012-03-28 06:14:09 +02:00
do_action ( 'customize_render_control' , $this );
2014-03-06 14:51:14 +01:00
/**
* Fires just before a specific Customizer control is rendered .
*
2014-11-30 13:10:23 +01:00
* The dynamic portion of the hook name , `$this->id` , refers to
2014-03-06 14:51:14 +01:00
* the control ID .
*
* @ since 3.4 . 0
*
2016-05-02 06:00:28 +02:00
* @ param WP_Customize_Control $this WP_Customize_Control instance .
2014-03-06 14:51:14 +01:00
*/
2016-08-22 20:25:31 +02:00
do_action ( " customize_render_control_ { $this -> id } " , $this );
2012-03-28 06:14:09 +02:00
$this -> render ();
}
/**
2014-03-04 21:21:14 +01:00
* Renders the control wrapper and calls $this -> render_content () for the internals .
2012-03-28 06:14:09 +02:00
*
* @ since 3.4 . 0
*/
protected function render () {
2015-10-20 22:15:26 +02:00
$id = 'customize-control-' . str_replace ( array ( '[' , ']' ), array ( '-' , '' ), $this -> id );
2012-03-28 06:14:09 +02:00
$class = 'customize-control customize-control-' . $this -> type ;
2012-04-18 19:13:31 +02:00
?> <li id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $class ); ?>">
2012-03-28 06:14:09 +02:00
< ? php $this -> render_content (); ?>
</ li >< ? php
}
2012-08-01 04:30:02 +02:00
2012-07-26 23:45:33 +02:00
/**
2014-03-04 21:21:14 +01:00
* Get the data link attribute for a setting .
2012-07-26 23:45:33 +02:00
*
* @ since 3.4 . 0
Customize: Allow controls to be created with pre-instantiated `Setting` object(s), or even with plain `Value` object(s).
* Allow passing settings in keyed object (e.g. `settings: { default: 'id' } ), or as an array (e.g. `settings: [ 'id' ]`) with first being default; again, `Setting`/`Value` objects may be supplied instead of IDs.
* Allow a single setting to be supplied with just a single `setting` param, either a string or a `Setting`/`Value` object.
* Update `changeset_status` and `scheduled_changeset_date` to be added dynamically with JS and simply passing of `api.state()` instances as `setting`.
* Introduce a `data-customize-setting-key-link` attribute which, unlike `data-customize-setting-link`, allows passing the setting key (e.g. `default`) as opposed to the setting ID.
* Allow `WP_Customize_Control::get_link()` to return `data-customize-setting-key-link` when setting is not registered.
* Eliminate `default_value` from `WP_Customize_Date_Time_Control` since now comes from supplied `Value`.
* Export status choices as `wp.customize.settings.changeset.statusChoices`.
* Export date and time formats as `wp.customize.settings.dateFormat` and `wp.customize.settings.timeFormat` respectively.
Props westonruter, sayedwp.
See #39896, #30738, #30741, #42083.
Fixes #37964, #36167.
Built from https://develop.svn.wordpress.org/trunk@41750
git-svn-id: http://core.svn.wordpress.org/trunk@41584 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-04 22:02:49 +02:00
* @ since 4.9 . 0 Return a `data-customize-setting-key-link` attribute if a setting is not registered for the supplied setting key .
2012-07-26 23:45:33 +02:00
*
* @ param string $setting_key
Customize: Allow controls to be created with pre-instantiated `Setting` object(s), or even with plain `Value` object(s).
* Allow passing settings in keyed object (e.g. `settings: { default: 'id' } ), or as an array (e.g. `settings: [ 'id' ]`) with first being default; again, `Setting`/`Value` objects may be supplied instead of IDs.
* Allow a single setting to be supplied with just a single `setting` param, either a string or a `Setting`/`Value` object.
* Update `changeset_status` and `scheduled_changeset_date` to be added dynamically with JS and simply passing of `api.state()` instances as `setting`.
* Introduce a `data-customize-setting-key-link` attribute which, unlike `data-customize-setting-link`, allows passing the setting key (e.g. `default`) as opposed to the setting ID.
* Allow `WP_Customize_Control::get_link()` to return `data-customize-setting-key-link` when setting is not registered.
* Eliminate `default_value` from `WP_Customize_Date_Time_Control` since now comes from supplied `Value`.
* Export status choices as `wp.customize.settings.changeset.statusChoices`.
* Export date and time formats as `wp.customize.settings.dateFormat` and `wp.customize.settings.timeFormat` respectively.
Props westonruter, sayedwp.
See #39896, #30738, #30741, #42083.
Fixes #37964, #36167.
Built from https://develop.svn.wordpress.org/trunk@41750
git-svn-id: http://core.svn.wordpress.org/trunk@41584 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-04 22:02:49 +02:00
* @ return string Data link parameter , a `data-customize-setting-link` attribute if the `$setting_key` refers to a pre - registered setting ,
* and a `data-customize-setting-key-link` attribute if the setting is not yet registered .
2012-07-26 23:45:33 +02:00
*/
2012-03-28 11:45:51 +02:00
public function get_link ( $setting_key = 'default' ) {
Customize: Allow controls to be created with pre-instantiated `Setting` object(s), or even with plain `Value` object(s).
* Allow passing settings in keyed object (e.g. `settings: { default: 'id' } ), or as an array (e.g. `settings: [ 'id' ]`) with first being default; again, `Setting`/`Value` objects may be supplied instead of IDs.
* Allow a single setting to be supplied with just a single `setting` param, either a string or a `Setting`/`Value` object.
* Update `changeset_status` and `scheduled_changeset_date` to be added dynamically with JS and simply passing of `api.state()` instances as `setting`.
* Introduce a `data-customize-setting-key-link` attribute which, unlike `data-customize-setting-link`, allows passing the setting key (e.g. `default`) as opposed to the setting ID.
* Allow `WP_Customize_Control::get_link()` to return `data-customize-setting-key-link` when setting is not registered.
* Eliminate `default_value` from `WP_Customize_Date_Time_Control` since now comes from supplied `Value`.
* Export status choices as `wp.customize.settings.changeset.statusChoices`.
* Export date and time formats as `wp.customize.settings.dateFormat` and `wp.customize.settings.timeFormat` respectively.
Props westonruter, sayedwp.
See #39896, #30738, #30741, #42083.
Fixes #37964, #36167.
Built from https://develop.svn.wordpress.org/trunk@41750
git-svn-id: http://core.svn.wordpress.org/trunk@41584 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-04 22:02:49 +02:00
if ( isset ( $this -> settings [ $setting_key ] ) && $this -> settings [ $setting_key ] instanceof WP_Customize_Setting ) {
return 'data-customize-setting-link="' . esc_attr ( $this -> settings [ $setting_key ] -> id ) . '"' ;
} else {
return 'data-customize-setting-key-link="' . esc_attr ( $setting_key ) . '"' ;
}
2012-03-28 11:45:51 +02:00
}
2012-08-01 04:30:02 +02:00
2012-07-26 23:45:33 +02:00
/**
2014-03-04 21:21:14 +01:00
* Render the data link attribute for the control ' s input element .
2012-07-26 23:45:33 +02:00
*
* @ since 3.4 . 0
* @ uses WP_Customize_Control :: get_link ()
*
* @ param string $setting_key
*/
2012-03-28 11:45:51 +02:00
public function link ( $setting_key = 'default' ) {
echo $this -> get_link ( $setting_key );
2012-03-28 06:14:09 +02:00
}
2014-07-10 01:58:16 +02:00
/**
2014-06-30 21:48:13 +02:00
* Render the custom attributes for the control ' s input element .
*
* @ since 4.0 . 0
*/
public function input_attrs () {
2015-08-25 22:28:22 +02:00
foreach ( $this -> input_attrs as $attr => $value ) {
2014-06-30 21:48:13 +02:00
echo $attr . '="' . esc_attr ( $value ) . '" ' ;
}
}
2012-03-28 06:14:09 +02:00
/**
* Render the control ' s content .
*
2016-10-31 07:28:32 +01:00
* Allows the content to be overridden without having to rewrite the wrapper in `$this::render()` .
2014-03-04 21:21:14 +01:00
*
2014-06-30 21:48:13 +02:00
* Supports basic input types `text` , `checkbox` , `textarea` , `radio` , `select` and `dropdown-pages` .
* Additional input types such as `email` , `url` , `number` , `hidden` and `date` are supported implicitly .
2012-03-28 06:14:09 +02:00
*
2016-05-01 19:28:27 +02:00
* Control content can alternately be rendered in JS . See WP_Customize_Control :: print_template () .
2014-10-24 18:32:18 +02:00
*
2012-03-28 06:14:09 +02:00
* @ since 3.4 . 0
*/
protected function render_content () {
2017-10-04 20:12:46 +02:00
$input_id = '_customize-input-' . $this -> id ;
$description_id = '_customize-description-' . $this -> id ;
$describedby_attr = ( ! empty ( $this -> description ) ) ? 'aria-describedby="' . esc_attr ( $description_id ) . '"' : '' ;
switch ( $this -> type ) {
2012-03-28 06:14:09 +02:00
case 'checkbox' :
?>
2017-10-04 20:12:46 +02:00
< span class = " customize-inside-control-row " >
< input
id = " <?php echo esc_attr( $input_id ); ?> "
< ? php echo $describedby_attr ; ?>
type = " checkbox "
value = " <?php echo esc_attr( $this->value () ); ?> "
< ? php $this -> link (); ?>
< ? php checked ( $this -> value () ); ?>
/>
< label for = " <?php echo esc_attr( $input_id ); ?> " >< ? php echo esc_html ( $this -> label ); ?> </label>
2014-06-30 17:55:17 +02:00
< ? php if ( ! empty ( $this -> description ) ) : ?>
2017-10-04 20:12:46 +02:00
< span id = " <?php echo esc_attr( $description_id ); ?> " class = " description customize-control-description " >< ? php echo $this -> description ; ?> </span>
2014-06-30 17:55:17 +02:00
< ? php endif ; ?>
2017-10-04 20:12:46 +02:00
</ span >
2012-03-28 06:14:09 +02:00
< ? php
break ;
case 'radio' :
2017-10-04 20:12:46 +02:00
if ( empty ( $this -> choices ) ) {
2012-03-28 06:14:09 +02:00
return ;
2017-10-04 20:12:46 +02:00
}
2012-03-28 06:14:09 +02:00
$name = '_customize-radio-' . $this -> id ;
2017-10-04 20:12:46 +02:00
?>
< ? php if ( ! empty ( $this -> label ) ) : ?>
2014-06-30 17:55:17 +02:00
< span class = " customize-control-title " >< ? php echo esc_html ( $this -> label ); ?> </span>
2017-10-04 20:12:46 +02:00
< ? php endif ; ?>
< ? php if ( ! empty ( $this -> description ) ) : ?>
< span id = " <?php echo esc_attr( $description_id ); ?> " class = " description customize-control-description " >< ? php echo $this -> description ; ?> </span>
< ? php endif ; ?>
2014-06-30 17:55:17 +02:00
2017-10-04 20:12:46 +02:00
< ? php foreach ( $this -> choices as $value => $label ) : ?>
< span class = " customize-inside-control-row " >
< input
id = " <?php echo esc_attr( $input_id . '-radio-' . $value ); ?> "
type = " radio " < ? php echo $describedby_attr ; ?>
value = " <?php echo esc_attr( $value ); ?> "
name = " <?php echo esc_attr( $name ); ?> "
< ? php $this -> link (); ?>
< ? php checked ( $this -> value (), $value ); ?>
/>
< label for = " <?php echo esc_attr( $input_id . '-radio-' . $value ); ?> " >< ? php echo esc_html ( $label ); ?> </label>
</ span >
< ? php endforeach ; ?>
< ? php
2012-03-28 06:14:09 +02:00
break ;
case 'select' :
2017-10-04 20:12:46 +02:00
if ( empty ( $this -> choices ) ) {
2012-03-28 06:14:09 +02:00
return ;
2017-10-04 20:12:46 +02:00
}
2012-03-28 06:14:09 +02:00
?>
2017-10-04 20:12:46 +02:00
< ? php if ( ! empty ( $this -> label ) ) : ?>
< label for = " <?php echo esc_attr( $input_id ); ?> " class = " customize-control-title " >< ? php echo esc_html ( $this -> label ); ?> </label>
< ? php endif ; ?>
< ? php if ( ! empty ( $this -> description ) ) : ?>
< span id = " <?php echo esc_attr( $description_id ); ?> " class = " description customize-control-description " >< ? php echo $this -> description ; ?> </span>
< ? php endif ; ?>
2014-06-30 17:55:17 +02:00
2017-10-04 20:12:46 +02:00
< select id = " <?php echo esc_attr( $input_id ); ?> " < ? php echo $describedby_attr ; ?> <?php $this->link(); ?>>
< ? php
foreach ( $this -> choices as $value => $label ) {
echo '<option value="' . esc_attr ( $value ) . '"' . selected ( $this -> value (), $value , false ) . '>' . $label . '</option>' ;
}
?>
</ select >
2012-03-28 06:14:09 +02:00
< ? php
break ;
2014-06-30 21:48:13 +02:00
case 'textarea' :
?>
2017-10-04 20:12:46 +02:00
< ? php if ( ! empty ( $this -> label ) ) : ?>
< label for = " <?php echo esc_attr( $input_id ); ?> " class = " customize-control-title " >< ? php echo esc_html ( $this -> label ); ?> </label>
< ? php endif ; ?>
< ? php if ( ! empty ( $this -> description ) ) : ?>
< span id = " <?php echo esc_attr( $description_id ); ?> " class = " description customize-control-description " >< ? php echo $this -> description ; ?> </span>
< ? php endif ; ?>
< textarea
id = " <?php echo esc_attr( $input_id ); ?> "
rows = " 5 "
< ? php echo $describedby_attr ; ?>
< ? php $this -> input_attrs (); ?>
< ? php $this -> link (); ?> >
< ? php echo esc_textarea ( $this -> value () ); ?>
</ textarea >
2014-06-30 21:48:13 +02:00
< ? php
break ;
2012-03-28 06:14:09 +02:00
case 'dropdown-pages' :
2015-10-20 05:48:26 +02:00
?>
< ? php if ( ! empty ( $this -> label ) ) : ?>
2017-10-04 20:12:46 +02:00
< label for = " <?php echo esc_attr( $input_id ); ?> " class = " customize-control-title " >< ? php echo esc_html ( $this -> label ); ?> </label>
< ? php endif ; ?>
< ? php if ( ! empty ( $this -> description ) ) : ?>
< span id = " <?php echo esc_attr( $description_id ); ?> " class = " description customize-control-description " >< ? php echo $this -> description ; ?> </span>
2015-10-20 05:48:26 +02:00
< ? php endif ; ?>
2016-09-20 02:47:30 +02:00
< ? php
$dropdown_name = '_customize-dropdown-pages-' . $this -> id ;
$show_option_none = __ ( '— Select —' );
$option_none_value = '0' ;
$dropdown = wp_dropdown_pages (
2012-03-28 11:45:51 +02:00
array (
2016-09-20 02:47:30 +02:00
'name' => $dropdown_name ,
2012-03-28 11:45:51 +02:00
'echo' => 0 ,
2016-09-20 02:47:30 +02:00
'show_option_none' => $show_option_none ,
'option_none_value' => $option_none_value ,
2012-03-28 11:45:51 +02:00
'selected' => $this -> value (),
)
);
2016-09-20 02:47:30 +02:00
if ( empty ( $dropdown ) ) {
$dropdown = sprintf ( '<select id="%1$s" name="%1$s">' , esc_attr ( $dropdown_name ) );
$dropdown .= sprintf ( '<option value="%1$s">%2$s</option>' , esc_attr ( $option_none_value ), esc_html ( $show_option_none ) );
$dropdown .= '</select>' ;
}
2012-03-28 11:45:51 +02:00
// Hackily add in the data link parameter.
2017-10-04 20:12:46 +02:00
$dropdown = str_replace ( '<select' , '<select ' . $this -> get_link () . ' id="' . esc_attr ( $input_id ) . '" ' . $describedby_attr , $dropdown );
2016-10-25 08:31:31 +02:00
// Even more hacikly add auto-draft page stubs.
// @todo Eventually this should be removed in favor of the pages being injected into the underlying get_pages() call. See <https://github.com/xwp/wp-customize-posts/pull/250>.
$nav_menus_created_posts_setting = $this -> manager -> get_setting ( 'nav_menus_created_posts' );
if ( $nav_menus_created_posts_setting && current_user_can ( 'publish_pages' ) ) {
$auto_draft_page_options = '' ;
foreach ( $nav_menus_created_posts_setting -> value () as $auto_draft_page_id ) {
$post = get_post ( $auto_draft_page_id );
if ( $post && 'page' === $post -> post_type ) {
$auto_draft_page_options .= sprintf ( '<option value="%1$s">%2$s</option>' , esc_attr ( $post -> ID ), esc_html ( $post -> post_title ) );
}
}
if ( $auto_draft_page_options ) {
$dropdown = str_replace ( '</select>' , $auto_draft_page_options . '</select>' , $dropdown );
}
}
2015-10-20 05:48:26 +02:00
echo $dropdown ;
?>
2016-10-25 08:31:31 +02:00
< ? php if ( $this -> allow_addition && current_user_can ( 'publish_pages' ) && current_user_can ( 'edit_theme_options' ) ) : // Currently tied to menus functionality. ?>
2017-10-04 20:12:46 +02:00
< button type = " button " class = " button-link add-new-toggle " >
< ? php
2016-11-10 03:56:30 +01:00
/* translators: %s: add new page label */
printf ( __ ( '+ %s' ), get_post_type_object ( 'page' ) -> labels -> add_new_item );
2017-10-04 20:12:46 +02:00
?>
</ button >
2016-10-25 08:31:31 +02:00
< div class = " new-content-item " >
< label for = " create-input-<?php echo $this->id ; ?> " >< span class = " screen-reader-text " >< ? php _e ( 'New page title' ); ?> </span></label>
< input type = " text " id = " create-input-<?php echo $this->id ; ?> " class = " create-item-input " placeholder = " <?php esc_attr_e( 'New page title…' ); ?> " >
< button type = " button " class = " button add-content " >< ? php _e ( 'Add' ); ?> </button>
</ div >
2017-10-04 20:12:46 +02:00
< ? php endif ; ?>
< ? php
2012-03-28 06:14:09 +02:00
break ;
2014-06-30 21:48:13 +02:00
default :
?>
2017-10-04 20:12:46 +02:00
< ? php if ( ! empty ( $this -> label ) ) : ?>
< label for = " <?php echo esc_attr( $input_id ); ?> " class = " customize-control-title " >< ? php echo esc_html ( $this -> label ); ?> </label>
< ? php endif ; ?>
< ? php if ( ! empty ( $this -> description ) ) : ?>
< span id = " <?php echo esc_attr( $description_id ); ?> " class = " description customize-control-description " >< ? php echo $this -> description ; ?> </span>
< ? php endif ; ?>
< input
id = " <?php echo esc_attr( $input_id ); ?> "
type = " <?php echo esc_attr( $this->type ); ?> "
< ? php echo $describedby_attr ; ?>
< ? php $this -> input_attrs (); ?>
value = " <?php echo esc_attr( $this->value () ); ?> "
< ? php $this -> link (); ?>
/>
2014-06-30 21:48:13 +02:00
< ? php
break ;
2012-03-28 06:14:09 +02:00
}
}
2014-10-24 18:32:18 +02:00
/**
* Render the control ' s JS template .
*
2014-11-28 10:20:23 +01:00
* This function is only run for control types that have been registered with
2016-05-02 06:00:28 +02:00
* WP_Customize_Manager :: register_control_type () .
2014-10-24 18:32:18 +02:00
*
2014-11-28 10:20:23 +01:00
* In the future , this will also print the template for the control ' s container
* element and be override - able .
2014-10-24 18:32:18 +02:00
*
* @ since 4.1 . 0
*/
final public function print_template () {
2015-03-10 19:02:28 +01:00
?>
< script type = " text/html " id = " tmpl-customize-control-<?php echo $this->type ; ?>-content " >
< ? php $this -> content_template (); ?>
</ script >
< ? php
2014-10-24 18:32:18 +02:00
}
/**
* An Underscore ( JS ) template for this control ' s content ( but not its container ) .
*
* Class variables for this control class are available in the `data` JS object ;
2016-05-02 06:00:28 +02:00
* export custom variables by overriding WP_Customize_Control :: to_json () .
2014-10-24 18:32:18 +02:00
*
* @ see WP_Customize_Control :: print_template ()
*
* @ since 4.1 . 0
*/
protected function content_template () {}
2012-03-29 08:35:54 +02:00
}
2016-08-31 18:31:29 +02:00
2017-05-19 22:25:41 +02:00
/**
* WP_Customize_Color_Control class .
*/
2016-08-31 18:31:29 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-customize-color-control.php' );
2017-05-19 22:25:41 +02:00
/**
* WP_Customize_Media_Control class .
*/
2016-08-31 18:31:29 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-customize-media-control.php' );
2017-05-19 22:25:41 +02:00
/**
* WP_Customize_Upload_Control class .
*/
2016-08-31 18:31:29 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-customize-upload-control.php' );
2017-05-19 22:25:41 +02:00
/**
* WP_Customize_Image_Control class .
*/
2016-08-31 18:31:29 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-customize-image-control.php' );
2017-05-19 22:25:41 +02:00
/**
* WP_Customize_Background_Image_Control class .
*/
2016-08-31 18:31:29 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-customize-background-image-control.php' );
2017-05-19 22:25:41 +02:00
/**
* WP_Customize_Background_Position_Control class .
*/
Customize: Improve custom background properties UI.
Introduces new control for managing the background position. Adds control for setting the `background-size`.
Props cdog, celloexpressions, grapplerulrich, MikeHansenMe, FolioVision, afercia, helen, melchoyce, karmatosed, westonruter, Kelderic, sebastian.pisula.
Fixes #22058.
Built from https://develop.svn.wordpress.org/trunk@38948
git-svn-id: http://core.svn.wordpress.org/trunk@38891 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-26 08:52:29 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-customize-background-position-control.php' );
2017-05-19 22:25:41 +02:00
/**
* WP_Customize_Cropped_Image_Control class .
*/
2016-08-31 18:31:29 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-customize-cropped-image-control.php' );
2017-05-19 22:25:41 +02:00
/**
* WP_Customize_Site_Icon_Control class .
*/
2016-08-31 18:31:29 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-customize-site-icon-control.php' );
2017-05-19 22:25:41 +02:00
/**
* WP_Customize_Header_Image_Control class .
*/
2016-08-31 18:31:29 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-customize-header-image-control.php' );
2017-05-19 22:25:41 +02:00
/**
* WP_Customize_Theme_Control class .
*/
2016-08-31 18:31:29 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-customize-theme-control.php' );
2017-05-19 22:25:41 +02:00
/**
* WP_Widget_Area_Customize_Control class .
*/
2016-08-31 18:31:29 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-widget-area-customize-control.php' );
2017-05-19 22:25:41 +02:00
/**
* WP_Widget_Form_Customize_Control class .
*/
2016-08-31 18:31:29 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-widget-form-customize-control.php' );
2017-05-19 22:25:41 +02:00
/**
* WP_Customize_Nav_Menu_Control class .
*/
2016-08-31 18:31:29 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-control.php' );
2017-05-19 22:25:41 +02:00
/**
* WP_Customize_Nav_Menu_Item_Control class .
*/
2016-08-31 18:31:29 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-control.php' );
2017-05-19 22:25:41 +02:00
/**
* WP_Customize_Nav_Menu_Location_Control class .
*/
2016-08-31 18:31:29 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-location-control.php' );
2017-05-19 22:25:41 +02:00
/**
* WP_Customize_Nav_Menu_Name_Control class .
*/
2016-08-31 18:31:29 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-name-control.php' );
2017-05-19 22:25:41 +02:00
/**
Customize: Improve the menu creation flow.
Often, folks run into two issues when they create new menus: they click "Add a Menu" thinking it will add a new page to their menu, or they forget to assign their new menu to a location, and then wonder why it doesn't show up on their site.
This commit rearranges the order of items in the menu panel, and updates the flow for creating a menu by breaking it up into steps. Additionally, more help text has been added to guide people through the process of creating a menu.
Also adds default `type` lookups for Panel and Section instances. See #30741.
Props bpayton, obenland, westonruter, celloexpessions, afercia, melchoyce, zoonini, michelleweber.
Fixes #40104.
Built from https://develop.svn.wordpress.org/trunk@41768
git-svn-id: http://core.svn.wordpress.org/trunk@41602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-05 04:22:49 +02:00
* WP_Customize_Nav_Menu_Locations_Control class .
2017-05-19 22:25:41 +02:00
*/
Customize: Improve the menu creation flow.
Often, folks run into two issues when they create new menus: they click "Add a Menu" thinking it will add a new page to their menu, or they forget to assign their new menu to a location, and then wonder why it doesn't show up on their site.
This commit rearranges the order of items in the menu panel, and updates the flow for creating a menu by breaking it up into steps. Additionally, more help text has been added to guide people through the process of creating a menu.
Also adds default `type` lookups for Panel and Section instances. See #30741.
Props bpayton, obenland, westonruter, celloexpessions, afercia, melchoyce, zoonini, michelleweber.
Fixes #40104.
Built from https://develop.svn.wordpress.org/trunk@41768
git-svn-id: http://core.svn.wordpress.org/trunk@41602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-05 04:22:49 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-locations-control.php' );
2016-08-31 18:31:29 +02:00
2017-05-19 22:25:41 +02:00
/**
Customize: Improve the menu creation flow.
Often, folks run into two issues when they create new menus: they click "Add a Menu" thinking it will add a new page to their menu, or they forget to assign their new menu to a location, and then wonder why it doesn't show up on their site.
This commit rearranges the order of items in the menu panel, and updates the flow for creating a menu by breaking it up into steps. Additionally, more help text has been added to guide people through the process of creating a menu.
Also adds default `type` lookups for Panel and Section instances. See #30741.
Props bpayton, obenland, westonruter, celloexpessions, afercia, melchoyce, zoonini, michelleweber.
Fixes #40104.
Built from https://develop.svn.wordpress.org/trunk@41768
git-svn-id: http://core.svn.wordpress.org/trunk@41602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-05 04:22:49 +02:00
* WP_Customize_Nav_Menu_Auto_Add_Control class .
2017-05-19 22:25:41 +02:00
*/
Customize: Improve the menu creation flow.
Often, folks run into two issues when they create new menus: they click "Add a Menu" thinking it will add a new page to their menu, or they forget to assign their new menu to a location, and then wonder why it doesn't show up on their site.
This commit rearranges the order of items in the menu panel, and updates the flow for creating a menu by breaking it up into steps. Additionally, more help text has been added to guide people through the process of creating a menu.
Also adds default `type` lookups for Panel and Section instances. See #30741.
Props bpayton, obenland, westonruter, celloexpessions, afercia, melchoyce, zoonini, michelleweber.
Fixes #40104.
Built from https://develop.svn.wordpress.org/trunk@41768
git-svn-id: http://core.svn.wordpress.org/trunk@41602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-05 04:22:49 +02:00
require_once ( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-auto-add-control.php' );
Customize: Introduce drafting and scheduling for Customizer changesets.
* Incorporates code from the Customize Snapshots and Customize Posts feature plugins.
* Adds a new Publish Settings section for managing the changeset status, scheduled date, and frontend preview link.
* Updates Publish button to reflect the status selected in the Publish Settings (including Save Draft and Schedule).
* Deactivates the Themes section when a non-publish status selected, and deactivates the Publish Settings section when previewing a theme switch.
* Introduces an `outer` section type (`wp.customize.OuterSection` in JS) for the Publish Settings section to use and for available widgets and available nav menu panels to use in the future. These sections can be expanded while other sections are expanded.
* Introduces `WP_Customize_Date_Time_Control` in PHP and `wp.customize.DateTimeControl` in JS for managing a date/time value.
* Keeps track of scheduled time and proactively publish from the client when the time arrives, as opposed to waiting for WP Cron.
* Auto-publishes a scheduled changeset when attempting to access one that missed its schedule.
* Starts a new changeset if attempting to save a changeset that was previously publish.
* Adds `force` arg to `requestChangesetUpdate()` to force an update request even when there are no pending changes.
* Adds utils methods for `getCurrentTimestamp` and `getRemainingTime`.
* Adds new state values for `selectedChangesetStatus`, `changesetDate`, `selectedChangesetDate`.
* Fixes logic for when to short-circuit check to close Customizer when there are unsaved changes.
* Adds getter methods for `autosaved` and `branching` parameters, with the latter applying the `customize_changeset_branching` filter.
* Call to `establish_loaded_changeset` on the fly when `changeset_uuid()` is called if no changeset UUID was specififed.
* De-duplicates logic for dismissing auto-draft changesets.
* Includes unit tests.
Builds on [41597].
Props sayedwp, westonruter, melchoyce, JoshuaWold, folletto, stubgo, karmatosed, dlh, paaljoachim, afercia, johnregan3, utkarshpatel, valendesigns.
See #30937.
Fixes #39896, #28721, #39275.
Built from https://develop.svn.wordpress.org/trunk@41626
git-svn-id: http://core.svn.wordpress.org/trunk@41461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-28 00:25:46 +02:00
/**
* WP_Customize_Date_Time_Control class .
*/
require_once ( ABSPATH . WPINC . '/customize/class-wp-customize-date-time-control.php' );