Make WordPress Core


Ignore:
Timestamp:
03/04/2014 08:20:28 PM (10 years ago)
Author:
nacin
Message:

Update the Customizer API inline docs.

props ericlewis.
fixes #27065.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r24687 r27398  
    22/**
    33 * Customize Manager.
     4 *
     5 * Bootstraps the Customize experience on the server-side.
     6 *
     7 * Sets up the theme-switching process if a theme other than the active one is
     8 * being previewed and customized.
     9 *
     10 * Serves as a factory for Customize Controls and Settings, and
     11 * instantiates default Customize Controls and Settings.
    412 *
    513 * @package WordPress
     
    816 */
    917final class WP_Customize_Manager {
     18    /**
     19     * An instance of the theme that is being customized.
     20     *
     21     * @var WP_Theme
     22     */
    1023    protected $theme;
     24
     25    /**
     26     * The directory name of the previously active theme (within the theme_root).
     27     *
     28     * @var string
     29     */
    1130    protected $original_stylesheet;
    1231
     32    /**
     33     * Whether filters have been set to change the active theme to the theme being
     34     * customized.
     35     *
     36     * @var boolean
     37     */
    1338    protected $previewing = false;
    1439
     
    2146    protected $customized;
    2247
     48    /**
     49     * $_POST values for Customize Settings.
     50     *
     51     * @var array
     52     */
    2353    private $_post_values;
    2454
     
    128158            add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ) );
    129159        } else {
     160            // If the requested theme is not the active theme and the user doesn't have the
     161            // switch_themes cap, bail.
    130162            if ( ! current_user_can( 'switch_themes' ) )
    131163                $this->wp_die( -1 );
    132164
    133             // If the theme isn't active, you can't preview it if it is not allowed or has errors.
     165            // If the theme has errors while loading, bail.
    134166            if ( $this->theme()->errors() )
    135167                $this->wp_die( -1 );
    136168
     169            // If the theme isn't allowed per multisite settings, bail.
    137170            if ( ! $this->theme()->is_allowed() )
    138171                $this->wp_die( -1 );
    139172        }
    140173
     174        // All good, let's do some internal business to preview the theme.
    141175        $this->start_previewing_theme();
    142176    }
     
    155189
    156190    /**
    157      * Start previewing the selected theme.
    158      *
    159      * Adds filters to change the current theme.
     191     * Start previewing the selected theme by adding filters to change the current theme.
    160192     *
    161193     * @since 3.4.0
     
    301333
    302334    /**
    303      * Decode the $_POST attribute used to override the WP_Customize_Setting values.
     335     * Decode the $_POST['customized'] values for a specific Customize Setting.
    304336     *
    305337     * @since 3.4.0
    306338     *
    307339     * @param mixed $setting A WP_Customize_Setting derived object
    308      * @return string Sanitized attribute
     340     * @return string $post_value Sanitized value
    309341     */
    310342    public function post_value( $setting ) {
     
    488520
    489521    /**
    490      * Switch the theme and trigger the save action of each setting.
     522     * Switch the theme and trigger the save() method on each setting.
    491523     *
    492524     * @since 3.4.0
     
    523555     * @since 3.4.0
    524556     *
    525      * @param string $id A specific ID of the setting. Can be a
    526      *                   theme mod or option name.
    527      * @param array $args Setting arguments.
     557     * @param WP_Customize_Setting|string $id Customize Setting object, or ID.
     558     * @param array $args                     Setting arguments; passed to WP_Customize_Setting
     559     *                                        constructor.
    528560     */
    529561    public function add_setting( $id, $args = array() ) {
     
    541573     * @since 3.4.0
    542574     *
    543      * @param string $id A specific ID of the setting.
    544      * @return object The settings object.
     575     * @param string $id Customize Setting ID.
     576     * @return WP_Customize_Setting
    545577     */
    546578    public function get_setting( $id ) {
     
    554586     * @since 3.4.0
    555587     *
    556      * @param string $id A specific ID of the setting.
     588     * @param string $id Customize Setting ID.
    557589     */
    558590    public function remove_setting( $id ) {
     
    565597     * @since 3.4.0
    566598     *
    567      * @param string $id A specific ID of the section.
    568      * @param array $args Section arguments.
     599     * @param WP_Customize_Section|string $id   Customize Section object, or Section ID.
     600     * @param array                       $args Section arguments.
    569601     */
    570602    public function add_section( $id, $args = array() ) {
     
    582614     * @since 3.4.0
    583615     *
    584      * @param string $id A specific ID of the section.
    585      * @return object The section object.
     616     * @param string $id Section ID.
     617     * @return WP_Customize_Section
    586618     */
    587619    public function get_section( $id ) {
     
    595627     * @since 3.4.0
    596628     *
    597      * @param string $id A specific ID of the section.
     629     * @param string $id Section ID.
    598630     */
    599631    public function remove_section( $id ) {
     
    606638     * @since 3.4.0
    607639     *
    608      * @param string $id A specific ID of the control.
    609      * @param array $args Setting arguments.
     640     * @param WP_Customize_Control|string $id   Customize Control object, or ID.
     641     * @param array                       $args Control arguments; passed to WP_Customize_Control
     642     *                                          constructor.
    610643     */
    611644    public function add_control( $id, $args = array() ) {
     
    623656     * @since 3.4.0
    624657     *
    625      * @param string $id A specific ID of the control.
    626      * @return object The settings object.
     658     * @param string $id ID of the control.
     659     * @return WP_Customize_Control $control The control object.
    627660     */
    628661    public function get_control( $id ) {
     
    632665
    633666    /**
    634      * Remove a customize setting.
    635      *
    636      * @since 3.4.0
    637      *
    638      * @param string $id A specific ID of the control.
     667     * Remove a customize control.
     668     *
     669     * @since 3.4.0
     670     *
     671     * @param string $id ID of the control.
    639672     */
    640673    public function remove_control( $id ) {
     
    663696     * Prepare settings and sections.
    664697     *
     698     * For each, check if required related components exist,
     699     * whether the user has the necessary capabilities,
     700     * and sort by priority.
     701     *
    665702     * @since 3.4.0
    666703     */
    667704    public function prepare_controls() {
    668         // Prepare controls
    669         // Reversing makes uasort sort by time added when conflicts occur.
    670705
    671706        $this->controls = array_reverse( $this->controls );
     
    681716        $this->controls = $controls;
    682717
    683         // Prepare sections
     718        // Prepare sections.
     719        // Reversing makes uasort sort by time added when conflicts occur.
    684720        $this->sections = array_reverse( $this->sections );
    685721        uasort( $this->sections, array( $this, '_cmp_priority' ) );
     
    9961032
    9971033/**
    998  * Validates a hex color.
     1034 * Sanitizes a hex color.
    9991035 *
    10001036 * Returns either '', a 3 or 6 digit hex color (with #), or null.
    1001  * For validating values without a #, see sanitize_hex_color_no_hash().
     1037 * For sanitizing values without a #, see sanitize_hex_color_no_hash().
    10021038 *
    10031039 * @since 3.4.0
Note: See TracChangeset for help on using the changeset viewer.