Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

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

    r42171 r42343  
    284284
    285285        $this->original_stylesheet = get_stylesheet();
    286         $this->theme = wp_get_theme( 0 === validate_file( $args['theme'] ) ? $args['theme'] : null );
    287         $this->messenger_channel = $args['messenger_channel'];
    288         $this->_changeset_uuid = $args['changeset_uuid'];
     286        $this->theme               = wp_get_theme( 0 === validate_file( $args['theme'] ) ? $args['theme'] : null );
     287        $this->messenger_channel   = $args['messenger_channel'];
     288        $this->_changeset_uuid     = $args['changeset_uuid'];
    289289
    290290        foreach ( array( 'settings_previewed', 'autosaved', 'branching' ) as $key ) {
     
    366366
    367367        add_action( 'setup_theme', array( $this, 'setup_theme' ) );
    368         add_action( 'wp_loaded',   array( $this, 'wp_loaded' ) );
     368        add_action( 'wp_loaded', array( $this, 'wp_loaded' ) );
    369369
    370370        // Do not spawn cron (especially the alternate cron) while running the Customizer.
     
    376376        remove_action( 'admin_init', '_maybe_update_themes' );
    377377
    378         add_action( 'wp_ajax_customize_save',                     array( $this, 'save' ) );
    379         add_action( 'wp_ajax_customize_trash',                    array( $this, 'handle_changeset_trash_request' ) );
    380         add_action( 'wp_ajax_customize_refresh_nonces',           array( $this, 'refresh_nonces' ) );
    381         add_action( 'wp_ajax_customize_load_themes',              array( $this, 'handle_load_themes_request' ) );
    382         add_filter( 'heartbeat_settings',                         array( $this, 'add_customize_screen_to_heartbeat_settings' ) );
    383         add_filter( 'heartbeat_received',                         array( $this, 'check_changeset_lock_with_heartbeat' ), 10, 3 );
    384         add_action( 'wp_ajax_customize_override_changeset_lock',  array( $this, 'handle_override_changeset_lock_request' ) );
     378        add_action( 'wp_ajax_customize_save', array( $this, 'save' ) );
     379        add_action( 'wp_ajax_customize_trash', array( $this, 'handle_changeset_trash_request' ) );
     380        add_action( 'wp_ajax_customize_refresh_nonces', array( $this, 'refresh_nonces' ) );
     381        add_action( 'wp_ajax_customize_load_themes', array( $this, 'handle_load_themes_request' ) );
     382        add_filter( 'heartbeat_settings', array( $this, 'add_customize_screen_to_heartbeat_settings' ) );
     383        add_filter( 'heartbeat_received', array( $this, 'check_changeset_lock_with_heartbeat' ), 10, 3 );
     384        add_action( 'wp_ajax_customize_override_changeset_lock', array( $this, 'handle_override_changeset_lock_request' ) );
    385385        add_action( 'wp_ajax_customize_dismiss_autosave_or_lock', array( $this, 'handle_dismiss_autosave_or_lock_request' ) );
    386386
    387         add_action( 'customize_register',                 array( $this, 'register_controls' ) );
    388         add_action( 'customize_register',                 array( $this, 'register_dynamic_settings' ), 11 ); // allow code to create settings first
    389         add_action( 'customize_controls_init',            array( $this, 'prepare_controls' ) );
     387        add_action( 'customize_register', array( $this, 'register_controls' ) );
     388        add_action( 'customize_register', array( $this, 'register_dynamic_settings' ), 11 ); // allow code to create settings first
     389        add_action( 'customize_controls_init', array( $this, 'prepare_controls' ) );
    390390        add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ) );
    391391
     
    459459                'messengerArgs' => array(
    460460                    'channel' => $this->messenger_channel,
    461                     'url' => wp_customize_url(),
     461                    'url'     => wp_customize_url(),
    462462                ),
    463                 'error' => $ajax_message,
     463                'error'         => $ajax_message,
    464464            );
    465465            ?>
     
    468468                var preview = new api.Messenger( settings.messengerArgs );
    469469                preview.send( 'iframe-loading-error', settings.error );
    470             } )( wp.customize, <?php echo wp_json_encode( $settings ) ?> );
     470            } )( wp.customize, <?php echo wp_json_encode( $settings ); ?> );
    471471            </script>
    472472            <?php
     
    614614
    615615            if ( ! $this->branching() && $this->is_theme_active() ) {
    616                 $unpublished_changeset_posts = $this->get_changeset_posts( array(
    617                     'post_status' => array_diff( get_post_stati(), array( 'auto-draft', 'publish', 'trash', 'inherit', 'private' ) ),
    618                     'exclude_restore_dismissed' => false,
    619                     'author' => 'any',
    620                     'posts_per_page' => 1,
    621                     'order' => 'DESC',
    622                     'orderby' => 'date',
    623                 ) );
    624                 $unpublished_changeset_post = array_shift( $unpublished_changeset_posts );
     616                $unpublished_changeset_posts = $this->get_changeset_posts(
     617                    array(
     618                        'post_status'               => array_diff( get_post_stati(), array( 'auto-draft', 'publish', 'trash', 'inherit', 'private' ) ),
     619                        'exclude_restore_dismissed' => false,
     620                        'author'                    => 'any',
     621                        'posts_per_page'            => 1,
     622                        'order'                     => 'DESC',
     623                        'orderby'                   => 'date',
     624                    )
     625                );
     626                $unpublished_changeset_post  = array_shift( $unpublished_changeset_posts );
    625627                if ( ! empty( $unpublished_changeset_post ) && wp_is_uuid( $unpublished_changeset_post->post_name ) ) {
    626628                    $changeset_uuid = $unpublished_changeset_post->post_name;
     
    963965     */
    964966    public function find_changeset_post_id( $uuid ) {
    965         $cache_group = 'customize_changeset_post';
     967        $cache_group       = 'customize_changeset_post';
    966968        $changeset_post_id = wp_cache_get( $uuid, $cache_group );
    967969        if ( $changeset_post_id && 'customize_changeset' === get_post_type( $changeset_post_id ) ) {
     
    969971        }
    970972
    971         $changeset_post_query = new WP_Query( array(
    972             'post_type' => 'customize_changeset',
    973             'post_status' => get_post_stati(),
    974             'name' => $uuid,
    975             'posts_per_page' => 1,
    976             'no_found_rows' => true,
    977             'cache_results' => true,
    978             'update_post_meta_cache' => false,
    979             'update_post_term_cache' => false,
    980             'lazy_load_term_meta' => false,
    981         ) );
     973        $changeset_post_query = new WP_Query(
     974            array(
     975                'post_type'              => 'customize_changeset',
     976                'post_status'            => get_post_stati(),
     977                'name'                   => $uuid,
     978                'posts_per_page'         => 1,
     979                'no_found_rows'          => true,
     980                'cache_results'          => true,
     981                'update_post_meta_cache' => false,
     982                'update_post_term_cache' => false,
     983                'lazy_load_term_meta'    => false,
     984            )
     985        );
    982986        if ( ! empty( $changeset_post_query->posts ) ) {
    983987            // Note: 'fields'=>'ids' is not being used in order to cache the post object as it will be needed.
     
    10081012        $default_args = array(
    10091013            'exclude_restore_dismissed' => true,
    1010             'posts_per_page' => -1,
    1011             'post_type' => 'customize_changeset',
    1012             'post_status' => 'auto-draft',
    1013             'order' => 'DESC',
    1014             'orderby' => 'date',
    1015             'no_found_rows' => true,
    1016             'cache_results' => true,
    1017             'update_post_meta_cache' => false,
    1018             'update_post_term_cache' => false,
    1019             'lazy_load_term_meta' => false,
     1014            'posts_per_page'            => -1,
     1015            'post_type'                 => 'customize_changeset',
     1016            'post_status'               => 'auto-draft',
     1017            'order'                     => 'DESC',
     1018            'orderby'                   => 'date',
     1019            'no_found_rows'             => true,
     1020            'cache_results'             => true,
     1021            'update_post_meta_cache'    => false,
     1022            'update_post_term_cache'    => false,
     1023            'lazy_load_term_meta'       => false,
    10201024        );
    10211025        if ( get_current_user_id() ) {
     
    10281032            $args['meta_query'] = array(
    10291033                array(
    1030                     'key' => '_customize_restore_dismissed',
     1034                    'key'     => '_customize_restore_dismissed',
    10311035                    'compare' => 'NOT EXISTS',
    10321036                ),
     
    10441048     */
    10451049    protected function dismiss_user_auto_draft_changesets() {
    1046         $changeset_autodraft_posts = $this->get_changeset_posts( array(
    1047             'post_status' => 'auto-draft',
    1048             'exclude_restore_dismissed' => true,
    1049             'posts_per_page' => -1,
    1050         ) );
    1051         $dismissed = 0;
     1050        $changeset_autodraft_posts = $this->get_changeset_posts(
     1051            array(
     1052                'post_status'               => 'auto-draft',
     1053                'exclude_restore_dismissed' => true,
     1054                'posts_per_page'            => -1,
     1055            )
     1056        );
     1057        $dismissed                 = 0;
    10521058        foreach ( $changeset_autodraft_posts as $autosave_autodraft_post ) {
    10531059            if ( $autosave_autodraft_post->ID === $this->changeset_post_id() ) {
     
    11941200
    11951201        $sidebars_widgets = isset( $starter_content['widgets'] ) && ! empty( $this->widgets ) ? $starter_content['widgets'] : array();
    1196         $attachments = isset( $starter_content['attachments'] ) && ! empty( $this->nav_menus ) ? $starter_content['attachments'] : array();
    1197         $posts = isset( $starter_content['posts'] ) && ! empty( $this->nav_menus ) ? $starter_content['posts'] : array();
    1198         $options = isset( $starter_content['options'] ) ? $starter_content['options'] : array();
    1199         $nav_menus = isset( $starter_content['nav_menus'] ) && ! empty( $this->nav_menus ) ? $starter_content['nav_menus'] : array();
    1200         $theme_mods = isset( $starter_content['theme_mods'] ) ? $starter_content['theme_mods'] : array();
     1202        $attachments      = isset( $starter_content['attachments'] ) && ! empty( $this->nav_menus ) ? $starter_content['attachments'] : array();
     1203        $posts            = isset( $starter_content['posts'] ) && ! empty( $this->nav_menus ) ? $starter_content['posts'] : array();
     1204        $options          = isset( $starter_content['options'] ) ? $starter_content['options'] : array();
     1205        $nav_menus        = isset( $starter_content['nav_menus'] ) && ! empty( $this->nav_menus ) ? $starter_content['nav_menus'] : array();
     1206        $theme_mods       = isset( $starter_content['theme_mods'] ) ? $starter_content['theme_mods'] : array();
    12011207
    12021208        // Widgets.
     
    12181224                    $widget_numbers = array_keys( $settings );
    12191225                    if ( count( $widget_numbers ) > 0 ) {
    1220                         $widget_numbers[] = 1;
     1226                        $widget_numbers[]               = 1;
    12211227                        $max_widget_numbers[ $id_base ] = call_user_func_array( 'max', $widget_numbers );
    12221228                    } else {
     
    12261232                $max_widget_numbers[ $id_base ] += 1;
    12271233
    1228                 $widget_id = sprintf( '%s-%d', $id_base, $max_widget_numbers[ $id_base ] );
     1234                $widget_id  = sprintf( '%s-%d', $id_base, $max_widget_numbers[ $id_base ] );
    12291235                $setting_id = sprintf( 'widget_%s[%d]', $id_base, $max_widget_numbers[ $id_base ] );
    12301236
     
    12511257        // Make an index of all the posts needed and what their slugs are.
    12521258        $needed_posts = array();
    1253         $attachments = $this->prepare_starter_content_attachments( $attachments );
     1259        $attachments  = $this->prepare_starter_content_attachments( $attachments );
    12541260        foreach ( $attachments as $attachment ) {
    1255             $key = 'attachment:' . $attachment['post_name'];
     1261            $key                  = 'attachment:' . $attachment['post_name'];
    12561262            $needed_posts[ $key ] = true;
    12571263        }
     
    12831289        $existing_starter_content_posts = array();
    12841290        if ( ! empty( $starter_content_auto_draft_post_ids ) ) {
    1285             $existing_posts_query = new WP_Query( array(
    1286                 'post__in' => $starter_content_auto_draft_post_ids,
    1287                 'post_status' => 'auto-draft',
    1288                 'post_type' => $post_types,
    1289                 'posts_per_page' => -1,
    1290             ) );
     1291            $existing_posts_query = new WP_Query(
     1292                array(
     1293                    'post__in'       => $starter_content_auto_draft_post_ids,
     1294                    'post_status'    => 'auto-draft',
     1295                    'post_type'      => $post_types,
     1296                    'posts_per_page' => -1,
     1297                )
     1298            );
    12911299            foreach ( $existing_posts_query->posts as $existing_post ) {
    12921300                $post_name = $existing_post->post_name;
     
    13001308        // Re-use non-auto-draft posts.
    13011309        if ( ! empty( $all_post_slugs ) ) {
    1302             $existing_posts_query = new WP_Query( array(
    1303                 'post_name__in' => $all_post_slugs,
    1304                 'post_status' => array_diff( get_post_stati(), array( 'auto-draft' ) ),
    1305                 'post_type' => 'any',
    1306                 'posts_per_page' => -1,
    1307             ) );
     1310            $existing_posts_query = new WP_Query(
     1311                array(
     1312                    'post_name__in'  => $all_post_slugs,
     1313                    'post_status'    => array_diff( get_post_stati(), array( 'auto-draft' ) ),
     1314                    'post_type'      => 'any',
     1315                    'posts_per_page' => -1,
     1316                )
     1317            );
    13081318            foreach ( $existing_posts_query->posts as $existing_post ) {
    13091319                $key = $existing_post->post_type . ':' . $existing_post->post_name;
     
    13201330
    13211331            foreach ( $attachments as $symbol => $attachment ) {
    1322                 $file_array = array(
     1332                $file_array    = array(
    13231333                    'name' => $attachment['file_name'],
    13241334                );
    1325                 $file_path = $attachment['file_path'];
     1335                $file_path     = $attachment['file_path'];
    13261336                $attachment_id = null;
    13271337                $attached_file = null;
    13281338                if ( isset( $existing_starter_content_posts[ 'attachment:' . $attachment['post_name'] ] ) ) {
    13291339                    $attachment_post = $existing_starter_content_posts[ 'attachment:' . $attachment['post_name'] ];
    1330                     $attachment_id = $attachment_post->ID;
    1331                     $attached_file = get_attached_file( $attachment_id );
     1340                    $attachment_id   = $attachment_post->ID;
     1341                    $attached_file   = get_attached_file( $attachment_id );
    13321342                    if ( empty( $attached_file ) || ! file_exists( $attached_file ) ) {
    13331343                        $attachment_id = null;
     
    14301440
    14311441        // Nav menus.
    1432         $placeholder_id = -1;
     1442        $placeholder_id              = -1;
    14331443        $reused_nav_menu_setting_ids = array();
    14341444        foreach ( $nav_menus as $nav_menu_location => $nav_menu ) {
    14351445
    1436             $nav_menu_term_id = null;
     1446            $nav_menu_term_id    = null;
    14371447            $nav_menu_setting_id = null;
    1438             $matches = array();
     1448            $matches             = array();
    14391449
    14401450            // Look for an existing placeholder menu with starter content to re-use.
     
    14481458                );
    14491459                if ( $can_reuse ) {
    1450                     $nav_menu_term_id = intval( $matches['nav_menu_id'] );
    1451                     $nav_menu_setting_id = $setting_id;
     1460                    $nav_menu_term_id              = intval( $matches['nav_menu_id'] );
     1461                    $nav_menu_setting_id           = $setting_id;
    14521462                    $reused_nav_menu_setting_ids[] = $setting_id;
    14531463                    break;
     
    14591469                    $placeholder_id--;
    14601470                }
    1461                 $nav_menu_term_id = $placeholder_id;
     1471                $nav_menu_term_id    = $placeholder_id;
    14621472                $nav_menu_setting_id = sprintf( 'nav_menu[%d]', $placeholder_id );
    14631473            }
    14641474
    1465             $this->set_post_value( $nav_menu_setting_id, array(
    1466                 'name' => isset( $nav_menu['name'] ) ? $nav_menu['name'] : $nav_menu_location,
    1467             ) );
     1475            $this->set_post_value(
     1476                $nav_menu_setting_id, array(
     1477                    'name' => isset( $nav_menu['name'] ) ? $nav_menu['name'] : $nav_menu_location,
     1478                )
     1479            );
    14681480            $this->pending_starter_content_settings_ids[] = $nav_menu_setting_id;
    14691481
     
    14811493                        $nav_menu_item['object_id'] = $posts[ $matches['symbol'] ]['ID'];
    14821494                        if ( empty( $nav_menu_item['title'] ) ) {
    1483                             $original_object = get_post( $nav_menu_item['object_id'] );
     1495                            $original_object        = get_post( $nav_menu_item['object_id'] );
    14841496                            $nav_menu_item['title'] = $original_object->post_title;
    14851497                        }
     
    15361548            // Handle header image as special case since setting has a legacy format.
    15371549            if ( 'header_image' === $name ) {
    1538                 $name = 'header_image_data';
     1550                $name     = 'header_image_data';
    15391551                $metadata = wp_get_attachment_metadata( $value );
    15401552                if ( empty( $metadata ) ) {
     
    15431555                $value = array(
    15441556                    'attachment_id' => $value,
    1545                     'url' => wp_get_attachment_url( $value ),
    1546                     'height' => $metadata['height'],
    1547                     'width' => $metadata['width'],
     1557                    'url'           => wp_get_attachment_url( $value ),
     1558                    'height'        => $metadata['height'],
     1559                    'width'         => $metadata['width'],
    15481560                );
    15491561            } elseif ( 'background_image' === $name ) {
     
    16211633            }
    16221634
    1623             $attachment['file_name'] = $file_name;
    1624             $attachment['file_path'] = $file_path;
     1635            $attachment['file_name']         = $file_name;
     1636            $attachment['file_path']         = $file_path;
    16251637            $prepared_attachments[ $symbol ] = $attachment;
    16261638        }
     
    16391651        }
    16401652
    1641         $this->save_changeset_post( array(
    1642             'data' => array_fill_keys( $this->pending_starter_content_settings_ids, array( 'starter_content' => true ) ),
    1643             'starter_content' => true,
    1644         ) );
     1653        $this->save_changeset_post(
     1654            array(
     1655                'data'            => array_fill_keys( $this->pending_starter_content_settings_ids, array( 'starter_content' => true ) ),
     1656                'starter_content' => true,
     1657            )
     1658        );
    16451659        $this->saved_starter_content_changeset = true;
    16461660
     
    16891703        if ( ! $this->is_theme_active() ) {
    16901704            $stashed_theme_mods = get_option( 'customize_stashed_theme_mods' );
    1691             $stylesheet = $this->get_stylesheet();
     1705            $stylesheet         = $this->get_stylesheet();
    16921706            if ( isset( $stashed_theme_mods[ $stylesheet ] ) ) {
    16931707                $values = array_merge( $values, wp_list_pluck( $stashed_theme_mods[ $stylesheet ], 'value' ) );
     
    18771891     */
    18781892    public function filter_iframe_security_headers( $headers ) {
    1879         $customize_url = admin_url( 'customize.php' );
    1880         $headers['X-Frame-Options'] = 'ALLOW-FROM ' . $customize_url;
     1893        $customize_url                      = admin_url( 'customize.php' );
     1894        $headers['X-Frame-Options']         = 'ALLOW-FROM ' . $customize_url;
    18811895        $headers['Content-Security-Policy'] = 'frame-ancestors ' . preg_replace( '#^(\w+://[^/]+).+?$#', '$1', $customize_url );
    18821896        return $headers;
     
    18951909    public function add_state_query_params( $url ) {
    18961910        $parsed_original_url = wp_parse_url( $url );
    1897         $is_allowed = false;
     1911        $is_allowed          = false;
    18981912        foreach ( $this->get_allowed_urls() as $allowed_url ) {
    18991913            $parsed_allowed_url = wp_parse_url( $allowed_url );
    1900             $is_allowed = (
     1914            $is_allowed         = (
    19011915                $parsed_allowed_url['scheme'] === $parsed_original_url['scheme']
    19021916                &&
     
    19631977     */
    19641978    public function customize_preview_loading_style() {
    1965         ?><style>
     1979        ?>
     1980        <style>
    19661981            body.wp-customizer-unloading {
    19671982                opacity: 0.25;
     
    19811996                cursor: not-allowed !important;
    19821997            }
    1983         </style><?php
     1998        </style>
     1999        <?php
    19842000    }
    19852001
     
    20272043     */
    20282044    public function customize_preview_settings() {
    2029         $post_values = $this->unsanitized_post_values( array( 'exclude_changeset' => true ) );
    2030         $setting_validities = $this->validate_setting_values( $post_values );
     2045        $post_values                 = $this->unsanitized_post_values( array( 'exclude_changeset' => true ) );
     2046        $setting_validities          = $this->validate_setting_values( $post_values );
    20312047        $exported_setting_validities = array_map( array( $this, 'prepare_setting_validity_for_js' ), $setting_validities );
    20322048
    20332049        // Note that the REQUEST_URI is not passed into home_url() since this breaks subdirectory installations.
    2034         $self_url = empty( $_SERVER['REQUEST_URI'] ) ? home_url( '/' ) : esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) );
     2050        $self_url           = empty( $_SERVER['REQUEST_URI'] ) ? home_url( '/' ) : esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) );
    20352051        $state_query_params = array(
    20362052            'customize_theme',
     
    20382054            'customize_messenger_channel',
    20392055        );
    2040         $self_url = remove_query_arg( $state_query_params, $self_url );
    2041 
    2042         $allowed_urls = $this->get_allowed_urls();
     2056        $self_url           = remove_query_arg( $state_query_params, $self_url );
     2057
     2058        $allowed_urls  = $this->get_allowed_urls();
    20432059        $allowed_hosts = array();
    20442060        foreach ( $allowed_urls as $allowed_url ) {
     
    20552071
    20562072        $switched_locale = switch_to_locale( get_user_locale() );
    2057         $l10n = array(
    2058             'shiftClickToEdit' => __( 'Shift-click to edit this element.' ),
     2073        $l10n            = array(
     2074            'shiftClickToEdit'  => __( 'Shift-click to edit this element.' ),
    20592075            'linkUnpreviewable' => __( 'This link is not live-previewable.' ),
    20602076            'formUnpreviewable' => __( 'This form is not live-previewable.' ),
     
    20652081
    20662082        $settings = array(
    2067             'changeset' => array(
    2068                 'uuid' => $this->changeset_uuid(),
     2083            'changeset'         => array(
     2084                'uuid'      => $this->changeset_uuid(),
    20692085                'autosaved' => $this->autosaved(),
    20702086            ),
    2071             'timeouts' => array(
     2087            'timeouts'          => array(
    20722088                'selectiveRefresh' => 250,
    2073                 'keepAliveSend' => 1000,
     2089                'keepAliveSend'    => 1000,
    20742090            ),
    2075             'theme' => array(
     2091            'theme'             => array(
    20762092                'stylesheet' => $this->get_stylesheet(),
    20772093                'active'     => $this->is_theme_active(),
    20782094            ),
    2079             'url' => array(
    2080                 'self' => $self_url,
    2081                 'allowed' => array_map( 'esc_url_raw', $this->get_allowed_urls() ),
    2082                 'allowedHosts' => array_unique( $allowed_hosts ),
     2095            'url'               => array(
     2096                'self'          => $self_url,
     2097                'allowed'       => array_map( 'esc_url_raw', $this->get_allowed_urls() ),
     2098                'allowedHosts'  => array_unique( $allowed_hosts ),
    20832099                'isCrossDomain' => $this->is_cross_domain(),
    20842100            ),
    2085             'channel' => $this->messenger_channel,
    2086             'activePanels' => array(),
    2087             'activeSections' => array(),
    2088             'activeControls' => array(),
     2101            'channel'           => $this->messenger_channel,
     2102            'activePanels'      => array(),
     2103            'activeSections'    => array(),
     2104            'activeControls'    => array(),
    20892105            'settingValidities' => $exported_setting_validities,
    2090             'nonce' => current_user_can( 'customize' ) ? $this->get_nonces() : array(),
    2091             'l10n' => $l10n,
    2092             '_dirty' => array_keys( $post_values ),
     2106            'nonce'             => current_user_can( 'customize' ) ? $this->get_nonces() : array(),
     2107            'l10n'              => $l10n,
     2108            '_dirty'            => array_keys( $post_values ),
    20932109        );
    20942110
     
    22292245     */
    22302246    public function current_theme( $current_theme ) {
    2231         return $this->theme()->display('Name');
     2247        return $this->theme()->display( 'Name' );
    22322248    }
    22332249
     
    22552271     */
    22562272    public function validate_setting_values( $setting_values, $options = array() ) {
    2257         $options = wp_parse_args( $options, array(
    2258             'validate_capability' => false,
    2259             'validate_existence' => false,
    2260         ) );
     2273        $options = wp_parse_args(
     2274            $options, array(
     2275                'validate_capability' => false,
     2276                'validate_existence'  => false,
     2277            )
     2278        );
    22612279
    22622280        $validities = array();
     
    23192337                $notification[ $error_code ] = array(
    23202338                    'message' => join( ' ', $error_messages ),
    2321                     'data' => $validity->get_error_data( $error_code ),
     2339                    'data'    => $validity->get_error_data( $error_code ),
    23222340                );
    23232341            }
     
    23492367
    23502368        $changeset_post_id = $this->changeset_post_id();
    2351         $is_new_changeset = empty( $changeset_post_id );
     2369        $is_new_changeset  = empty( $changeset_post_id );
    23522370        if ( $is_new_changeset ) {
    23532371            if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->create_posts ) ) {
     
    23762394
    23772395        // Validate changeset status param.
    2378         $is_publish = null;
     2396        $is_publish       = null;
    23792397        $changeset_status = null;
    23802398        if ( isset( $_POST['customize_changeset_status'] ) ) {
     
    23992417            $changeset_date = wp_unslash( $_POST['customize_changeset_date'] );
    24002418            if ( preg_match( '/^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d$/', $changeset_date ) ) {
    2401                 $mm = substr( $changeset_date, 5, 2 );
    2402                 $jj = substr( $changeset_date, 8, 2 );
    2403                 $aa = substr( $changeset_date, 0, 4 );
     2419                $mm         = substr( $changeset_date, 5, 2 );
     2420                $jj         = substr( $changeset_date, 8, 2 );
     2421                $aa         = substr( $changeset_date, 0, 4 );
    24042422                $valid_date = wp_checkdate( $mm, $jj, $aa, $changeset_date );
    24052423                if ( ! $valid_date ) {
     
    24172435
    24182436        $lock_user_id = null;
    2419         $autosave = ! empty( $_POST['customize_changeset_autosave'] );
     2437        $autosave     = ! empty( $_POST['customize_changeset_autosave'] );
    24202438        if ( ! $is_new_changeset ) {
    24212439            $lock_user_id = wp_check_post_lock( $this->changeset_post_id() );
     
    24242442        // Force request to autosave when changeset is locked.
    24252443        if ( $lock_user_id && ! $autosave ) {
    2426             $autosave = true;
    2427             $changeset_status = null;
     2444            $autosave           = true;
     2445            $changeset_status   = null;
    24282446            $changeset_date_gmt = null;
    24292447        }
     
    24342452
    24352453        $autosaved = false;
    2436         $r = $this->save_changeset_post( array(
    2437             'status' => $changeset_status,
    2438             'title' => $changeset_title,
    2439             'date_gmt' => $changeset_date_gmt,
    2440             'data' => $input_changeset_data,
    2441             'autosave' => $autosave,
    2442         ) );
     2454        $r         = $this->save_changeset_post(
     2455            array(
     2456                'status'   => $changeset_status,
     2457                'title'    => $changeset_title,
     2458                'date_gmt' => $changeset_date_gmt,
     2459                'data'     => $input_changeset_data,
     2460                'autosave' => $autosave,
     2461            )
     2462        );
    24432463        if ( $autosave && ! is_wp_error( $r ) ) {
    24442464            $autosaved = true;
     
    24592479            $response = array(
    24602480                'message' => $r->get_error_message(),
    2461                 'code' => $r->get_error_code(),
     2481                'code'    => $r->get_error_code(),
    24622482            );
    24632483            if ( is_array( $r->get_error_data() ) ) {
     
    24672487            }
    24682488        } else {
    2469             $response = $r;
     2489            $response       = $r;
    24702490            $changeset_post = get_post( $this->changeset_post_id() );
    24712491
     
    25452565        $args = array_merge(
    25462566            array(
    2547                 'status' => null,
    2548                 'title' => null,
    2549                 'data' => array(),
    2550                 'date_gmt' => null,
    2551                 'user_id' => get_current_user_id(),
     2567                'status'          => null,
     2568                'title'           => null,
     2569                'data'            => array(),
     2570                'date_gmt'        => null,
     2571                'user_id'         => get_current_user_id(),
    25522572                'starter_content' => false,
    2553                 'autosave' => false,
     2573                'autosave'        => false,
    25542574            ),
    25552575            $args
    25562576        );
    25572577
    2558         $changeset_post_id = $this->changeset_post_id();
     2578        $changeset_post_id       = $this->changeset_post_id();
    25592579        $existing_changeset_data = array();
    25602580        if ( $changeset_post_id ) {
     
    26222642        // The request was made via wp.customize.previewer.save().
    26232643        $update_transactionally = (bool) $args['status'];
    2624         $allow_revision = (bool) $args['status'];
     2644        $allow_revision         = (bool) $args['status'];
    26252645
    26262646        // Amend post values with any supplied data.
     
    26322652
    26332653        // Note that in addition to post data, this will include any stashed theme mods.
    2634         $post_values = $this->unsanitized_post_values( array(
    2635             'exclude_changeset' => true,
    2636             'exclude_post_data' => false,
    2637         ) );
     2654        $post_values = $this->unsanitized_post_values(
     2655            array(
     2656                'exclude_changeset' => true,
     2657                'exclude_post_data' => false,
     2658            )
     2659        );
    26382660        $this->add_dynamic_settings( array_keys( $post_values ) ); // Ensure settings get created even if they lack an input value.
    26392661
     
    26822704
    26832705        // Validate settings.
    2684         $validated_values = array_merge(
     2706        $validated_values      = array_merge(
    26852707            array_fill_keys( array_keys( $args['data'] ), null ), // Make sure existence/capability checks are done on value-less setting updates.
    26862708            $post_values
    26872709        );
    2688         $setting_validities = $this->validate_setting_values( $validated_values, array(
    2689             'validate_capability' => true,
    2690             'validate_existence' => true,
    2691         ) );
     2710        $setting_validities    = $this->validate_setting_values(
     2711            $validated_values, array(
     2712                'validate_capability' => true,
     2713                'validate_existence'  => true,
     2714            )
     2715        );
    26922716        $invalid_setting_count = count( array_filter( $setting_validities, 'is_wp_error' ) );
    26932717
     
    27002724                'setting_validities' => $setting_validities,
    27012725                /* translators: %s: number of invalid settings */
    2702                 'message' => sprintf( _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', $invalid_setting_count ), number_format_i18n( $invalid_setting_count ) ),
     2726                'message'            => sprintf( _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', $invalid_setting_count ), number_format_i18n( $invalid_setting_count ) ),
    27032727            );
    27042728            return new WP_Error( 'transaction_fail', '', $response );
     
    27072731        // Obtain/merge data for changeset.
    27082732        $original_changeset_data = $this->get_changeset_post_data( $changeset_post_id );
    2709         $data = $original_changeset_data;
     2733        $data                    = $original_changeset_data;
    27102734        if ( is_wp_error( $data ) ) {
    27112735            $data = array();
     
    27582782                    $merged_setting_params,
    27592783                    array(
    2760                         'type' => $setting->type,
    2761                         'user_id' => $args['user_id'],
     2784                        'type'              => $setting->type,
     2785                        'user_id'           => $args['user_id'],
    27622786                        'date_modified_gmt' => current_time( 'mysql', true ),
    27632787                    )
     
    27722796
    27732797        $filter_context = array(
    2774             'uuid' => $this->changeset_uuid(),
    2775             'title' => $args['title'],
    2776             'status' => $args['status'],
    2777             'date_gmt' => $args['date_gmt'],
    2778             'post_id' => $changeset_post_id,
     2798            'uuid'          => $this->changeset_uuid(),
     2799            'title'         => $args['title'],
     2800            'status'        => $args['status'],
     2801            'date_gmt'      => $args['date_gmt'],
     2802            'post_id'       => $changeset_post_id,
    27792803            'previous_data' => is_wp_error( $original_changeset_data ) ? array() : $original_changeset_data,
    2780             'manager' => $this,
     2804            'manager'       => $this,
    27812805        );
    27822806
     
    28182842        }
    28192843        $json_options |= JSON_PRETTY_PRINT; // Also introduced in PHP 5.4, but WP defines constant for back compat. See WP Trac #30139.
    2820         $post_array = array(
     2844        $post_array    = array(
    28212845            'post_content' => wp_json_encode( $data, $json_options ),
    28222846        );
     
    28272851            $post_array['ID'] = $changeset_post_id;
    28282852        } else {
    2829             $post_array['post_type'] = 'customize_changeset';
    2830             $post_array['post_name'] = $this->changeset_uuid();
     2853            $post_array['post_type']   = 'customize_changeset';
     2854            $post_array['post_name']   = $this->changeset_uuid();
    28312855            $post_array['post_status'] = 'auto-draft';
    28322856        }
     
    28382862        if ( 'publish' === $args['status'] ) {
    28392863            $post_array['post_date_gmt'] = '0000-00-00 00:00:00';
    2840             $post_array['post_date'] = '0000-00-00 00:00:00';
     2864            $post_array['post_date']     = '0000-00-00 00:00:00';
    28412865        } elseif ( $args['date_gmt'] ) {
    28422866            $post_array['post_date_gmt'] = $args['date_gmt'];
    2843             $post_array['post_date'] = get_date_from_gmt( $args['date_gmt'] );
     2867            $post_array['post_date']     = get_date_from_gmt( $args['date_gmt'] );
    28442868        } elseif ( $changeset_post_id && 'auto-draft' === get_post_status( $changeset_post_id ) ) {
    28452869            /*
     
    28482872             * wp_delete_auto_drafts().
    28492873             */
    2850             $post_array['post_date'] = current_time( 'mysql' );
     2874            $post_array['post_date']     = current_time( 'mysql' );
    28512875            $post_array['post_date_gmt'] = '';
    28522876        }
     
    28662890                // See _wp_translate_postdata() for why this is required as it will use the edit_post meta capability.
    28672891                add_filter( 'map_meta_cap', array( $this, 'grant_edit_post_capability_for_changeset' ), 10, 4 );
    2868                 $post_array['post_ID'] = $post_array['ID'];
     2892                $post_array['post_ID']   = $post_array['ID'];
    28692893                $post_array['post_type'] = 'customize_changeset';
    2870                 $r = wp_create_post_autosave( wp_slash( $post_array ) );
     2894                $r                       = wp_create_post_autosave( wp_slash( $post_array ) );
    28712895                remove_filter( 'map_meta_cap', array( $this, 'grant_edit_post_capability_for_changeset' ), 10 );
    28722896            } else {
    28732897                $post_array['edit_date'] = true; // Prevent date clearing.
    2874                 $r = wp_update_post( wp_slash( $post_array ), true );
     2898                $r                       = wp_update_post( wp_slash( $post_array ), true );
    28752899
    28762900                // Delete autosave revision when the changeset is updated.
     
    29933017
    29943018        if ( ! check_ajax_referer( 'trash_customize_changeset', 'nonce', false ) ) {
    2995             wp_send_json_error( array(
    2996                 'code' => 'invalid_nonce',
    2997                 'message' => __( 'There was an authentication problem. Please reload and try again.' ),
    2998             ) );
     3019            wp_send_json_error(
     3020                array(
     3021                    'code'    => 'invalid_nonce',
     3022                    'message' => __( 'There was an authentication problem. Please reload and try again.' ),
     3023                )
     3024            );
    29993025        }
    30003026
     
    30023028
    30033029        if ( ! $changeset_post_id ) {
    3004             wp_send_json_error( array(
    3005                 'message' => __( 'No changes saved yet, so there is nothing to trash.' ),
    3006                 'code' => 'non_existent_changeset',
    3007             ) );
     3030            wp_send_json_error(
     3031                array(
     3032                    'message' => __( 'No changes saved yet, so there is nothing to trash.' ),
     3033                    'code'    => 'non_existent_changeset',
     3034                )
     3035            );
    30083036            return;
    30093037        }
    30103038
    30113039        if ( $changeset_post_id && ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->delete_post, $changeset_post_id ) ) {
    3012             wp_send_json_error( array(
    3013                 'code' => 'changeset_trash_unauthorized',
    3014                 'message' => __( 'Unable to trash changes.' ),
    3015             ) );
     3040            wp_send_json_error(
     3041                array(
     3042                    'code'    => 'changeset_trash_unauthorized',
     3043                    'message' => __( 'Unable to trash changes.' ),
     3044                )
     3045            );
    30163046        }
    30173047
    30183048        if ( 'trash' === get_post_status( $changeset_post_id ) ) {
    3019             wp_send_json_error( array(
    3020                 'message' => __( 'Changes have already been trashed.' ),
    3021                 'code' => 'changeset_already_trashed',
    3022             ) );
     3049            wp_send_json_error(
     3050                array(
     3051                    'message' => __( 'Changes have already been trashed.' ),
     3052                    'code'    => 'changeset_already_trashed',
     3053                )
     3054            );
    30233055            return;
    30243056        }
     
    30263058        $r = $this->trash_changeset_post( $changeset_post_id );
    30273059        if ( ! ( $r instanceof WP_Post ) ) {
    3028             wp_send_json_error( array(
    3029                 'code' => 'changeset_trash_failure',
    3030                 'message' => __( 'Unable to trash changes.' ),
    3031             ) );
    3032         }
    3033 
    3034         wp_send_json_success( array(
    3035             'message' => __( 'Changes trashed successfully.' ),
    3036         ) );
     3060            wp_send_json_error(
     3061                array(
     3062                    'code'    => 'changeset_trash_failure',
     3063                    'message' => __( 'Unable to trash changes.' ),
     3064                )
     3065            );
     3066        }
     3067
     3068        wp_send_json_success(
     3069            array(
     3070                'message' => __( 'Changes trashed successfully.' ),
     3071            )
     3072        );
    30373073    }
    30383074
     
    30613097        if ( 'edit_post' === $cap && ! empty( $args[0] ) && 'customize_changeset' === get_post_type( $args[0] ) ) {
    30623098            $post_type_obj = get_post_type_object( 'customize_changeset' );
    3063             $caps = map_meta_cap( $post_type_obj->cap->$cap, $user_id );
     3099            $caps          = map_meta_cap( $post_type_obj->cap->$cap, $user_id );
    30643100        }
    30653101        return $caps;
     
    31063142
    31073143        if ( $lock && ! empty( $lock[1] ) ) {
    3108             $user_id = intval( $lock[1] );
     3144            $user_id         = intval( $lock[1] );
    31093145            $current_user_id = get_current_user_id();
    31103146            if ( $user_id === $current_user_id ) {
     
    31473183        }
    31483184        return array(
    3149             'id' => $lock_user->ID,
    3150             'name' => $lock_user->display_name,
     3185            'id'     => $lock_user->ID,
     3186            'name'   => $lock_user->display_name,
    31513187            'avatar' => get_avatar_url( $lock_user->ID, array( 'size' => 128 ) ),
    31523188        );
     
    31903226
    31913227        if ( ! check_ajax_referer( 'customize_override_changeset_lock', 'nonce', false ) ) {
    3192             wp_send_json_error( array(
    3193                 'code' => 'invalid_nonce',
    3194                 'message' => __( 'Security check failed.' ),
    3195             ) );
     3228            wp_send_json_error(
     3229                array(
     3230                    'code'    => 'invalid_nonce',
     3231                    'message' => __( 'Security check failed.' ),
     3232                )
     3233            );
    31963234        }
    31973235
     
    31993237
    32003238        if ( empty( $changeset_post_id ) ) {
    3201             wp_send_json_error( array(
    3202                 'code' => 'no_changeset_found_to_take_over',
    3203                 'message' => __( 'No changeset found to take over' ),
    3204             ) );
     3239            wp_send_json_error(
     3240                array(
     3241                    'code'    => 'no_changeset_found_to_take_over',
     3242                    'message' => __( 'No changeset found to take over' ),
     3243                )
     3244            );
    32053245        }
    32063246
    32073247        if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $changeset_post_id ) ) {
    3208             wp_send_json_error( array(
    3209                 'code' => 'cannot_remove_changeset_lock',
    3210                 'message' => __( 'Sorry, you are not allowed to take over.' ),
    3211             ) );
     3248            wp_send_json_error(
     3249                array(
     3250                    'code'    => 'cannot_remove_changeset_lock',
     3251                    'message' => __( 'Sorry, you are not allowed to take over.' ),
     3252                )
     3253            );
    32123254        }
    32133255
     
    32893331
    32903332        // Parse changeset data to identify theme mod settings and user IDs associated with settings to be saved.
    3291         $setting_user_ids = array();
     3333        $setting_user_ids   = array();
    32923334        $theme_mod_settings = array();
    3293         $namespace_pattern = '/^(?P<stylesheet>.+?)::(?P<setting_id>.+)$/';
    3294         $matches = array();
     3335        $namespace_pattern  = '/^(?P<stylesheet>.+?)::(?P<setting_id>.+)$/';
     3336        $matches            = array();
    32953337        foreach ( $this->_changeset_data as $raw_setting_id => $setting_params ) {
    3296             $actual_setting_id = null;
     3338            $actual_setting_id    = null;
    32973339            $is_theme_mod_setting = (
    32983340                isset( $setting_params['value'] )
     
    33233365        }
    33243366
    3325         $changeset_setting_values = $this->unsanitized_post_values( array(
    3326             'exclude_post_data' => true,
    3327             'exclude_changeset' => false,
    3328         ) );
    3329         $changeset_setting_ids = array_keys( $changeset_setting_values );
     3367        $changeset_setting_values = $this->unsanitized_post_values(
     3368            array(
     3369                'exclude_post_data' => true,
     3370                'exclude_changeset' => false,
     3371            )
     3372        );
     3373        $changeset_setting_ids    = array_keys( $changeset_setting_values );
    33303374        $this->add_dynamic_settings( $changeset_setting_ids );
    33313375
     
    33513395            if ( $setting && ! isset( $setting_user_ids[ $setting_id ] ) ) {
    33523396                $original_setting_capabilities[ $setting->id ] = $setting->capability;
    3353                 $setting->capability = 'exist';
     3397                $setting->capability                           = 'exist';
    33543398            }
    33553399        }
     
    34183462                    array(
    34193463                        'post_status' => 'auto-draft',
    3420                         'post_type' => 'customize_changeset',
    3421                         'post_name' => wp_generate_uuid4(),
     3464                        'post_type'   => 'customize_changeset',
     3465                        'post_name'   => wp_generate_uuid4(),
    34223466                        'post_parent' => 0,
    34233467                    ),
     
    34633507
    34643508        $autoload = false;
    3465         $result = update_option( 'customize_stashed_theme_mods', $stashed_theme_mod_settings, $autoload );
     3509        $result   = update_option( 'customize_stashed_theme_mods', $stashed_theme_mod_settings, $autoload );
    34663510        if ( ! $result ) {
    34673511            return false;
     
    34983542
    34993543        $changeset_post_id = $this->changeset_post_id();
    3500         $dismiss_lock = ! empty( $_POST['dismiss_lock'] );
    3501         $dismiss_autosave = ! empty( $_POST['dismiss_autosave'] );
     3544        $dismiss_lock      = ! empty( $_POST['dismiss_lock'] );
     3545        $dismiss_autosave  = ! empty( $_POST['dismiss_autosave'] );
    35023546
    35033547        if ( $dismiss_lock ) {
     
    35643608     *                                            Using 'refresh' makes the change visible by reloading the whole preview.
    35653609     *                                            Using 'postMessage' allows a custom JavaScript to handle live changes.
    3566      *                                            @link https://developer.wordpress.org/themes/customize-api
     3610     * @link https://developer.wordpress.org/themes/customize-api
    35673611     *                                            Default is 'refresh'
    35683612     *  @type callable     $validate_callback     Server-side validation callback for the setting's value.
     
    36153659            }
    36163660
    3617             $setting_args = false;
     3661            $setting_args  = false;
    36183662            $setting_class = 'WP_Customize_Setting';
    36193663
     
    37353779        if ( in_array( $id, $this->components, true ) ) {
    37363780            /* translators: 1: panel id, 2: link to 'customize_loaded_components' filter reference */
    3737             $message = sprintf( __( 'Removing %1$s manually will cause PHP warnings. Use the %2$s filter instead.' ),
     3781            $message = sprintf(
     3782                __( 'Removing %1$s manually will cause PHP warnings. Use the %2$s filter instead.' ),
    37383783                $id,
    37393784                '<a href="' . esc_url( 'https://developer.wordpress.org/reference/hooks/customize_loaded_components/' ) . '"><code>customize_loaded_components</code></a>'
     
    38143859     */
    38153860    public function get_section( $id ) {
    3816         if ( isset( $this->sections[ $id ] ) )
     3861        if ( isset( $this->sections[ $id ] ) ) {
    38173862            return $this->sections[ $id ];
     3863        }
    38183864    }
    38193865
     
    39053951     */
    39063952    public function get_control( $id ) {
    3907         if ( isset( $this->controls[ $id ] ) )
     3953        if ( isset( $this->controls[ $id ] ) ) {
    39083954            return $this->controls[ $id ];
     3955        }
    39093956    }
    39103957
     
    39413988    public function render_control_templates() {
    39423989        foreach ( $this->registered_control_types as $control_type ) {
    3943             $control = new $control_type( $this, 'temp', array(
    3944                 'settings' => array(),
    3945             ) );
     3990            $control = new $control_type(
     3991                $this, 'temp', array(
     3992                    'settings' => array(),
     3993                )
     3994            );
    39463995            $control->print_template();
    39473996        }
     
    42174266    public function prepare_controls() {
    42184267
    4219         $controls = array();
    4220         $this->controls = wp_list_sort( $this->controls, array(
    4221             'priority'        => 'ASC',
    4222             'instance_number' => 'ASC',
    4223         ), 'ASC', true );
     4268        $controls       = array();
     4269        $this->controls = wp_list_sort(
     4270            $this->controls, array(
     4271                'priority'        => 'ASC',
     4272                'instance_number' => 'ASC',
     4273            ), 'ASC', true
     4274        );
    42244275
    42254276        foreach ( $this->controls as $id => $control ) {
     
    42294280
    42304281            $this->sections[ $control->section ]->controls[] = $control;
    4231             $controls[ $id ] = $control;
     4282            $controls[ $id ]                                 = $control;
    42324283        }
    42334284        $this->controls = $controls;
    42344285
    42354286        // Prepare sections.
    4236         $this->sections = wp_list_sort( $this->sections, array(
    4237             'priority'        => 'ASC',
    4238             'instance_number' => 'ASC',
    4239         ), 'ASC', true );
    4240         $sections = array();
     4287        $this->sections = wp_list_sort(
     4288            $this->sections, array(
     4289                'priority'        => 'ASC',
     4290                'instance_number' => 'ASC',
     4291            ), 'ASC', true
     4292        );
     4293        $sections       = array();
    42414294
    42424295        foreach ( $this->sections as $section ) {
     
    42454298            }
    42464299
    4247 
    4248             $section->controls = wp_list_sort( $section->controls, array(
    4249                 'priority'        => 'ASC',
    4250                 'instance_number' => 'ASC',
    4251             ) );
     4300            $section->controls = wp_list_sort(
     4301                $section->controls, array(
     4302                    'priority'        => 'ASC',
     4303                    'instance_number' => 'ASC',
     4304                )
     4305            );
    42524306
    42534307            if ( ! $section->panel ) {
     
    42644318
    42654319        // Prepare panels.
    4266         $this->panels = wp_list_sort( $this->panels, array(
    4267             'priority'        => 'ASC',
    4268             'instance_number' => 'ASC',
    4269         ), 'ASC', true );
    4270         $panels = array();
     4320        $this->panels = wp_list_sort(
     4321            $this->panels, array(
     4322                'priority'        => 'ASC',
     4323                'instance_number' => 'ASC',
     4324            ), 'ASC', true
     4325        );
     4326        $panels       = array();
    42714327
    42724328        foreach ( $this->panels as $panel ) {
     
    42754331            }
    42764332
    4277             $panel->sections = wp_list_sort( $panel->sections, array(
     4333            $panel->sections      = wp_list_sort(
     4334                $panel->sections, array(
     4335                    'priority'        => 'ASC',
     4336                    'instance_number' => 'ASC',
     4337                ), 'ASC', true
     4338            );
     4339            $panels[ $panel->id ] = $panel;
     4340        }
     4341        $this->panels = $panels;
     4342
     4343        // Sort panels and top-level sections together.
     4344        $this->containers = array_merge( $this->panels, $this->sections );
     4345        $this->containers = wp_list_sort(
     4346            $this->containers, array(
    42784347                'priority'        => 'ASC',
    42794348                'instance_number' => 'ASC',
    4280             ), 'ASC', true );
    4281             $panels[ $panel->id ] = $panel;
    4282         }
    4283         $this->panels = $panels;
    4284 
    4285         // Sort panels and top-level sections together.
    4286         $this->containers = array_merge( $this->panels, $this->sections );
    4287         $this->containers = wp_list_sort( $this->containers, array(
    4288             'priority'        => 'ASC',
    4289             'instance_number' => 'ASC',
    4290         ), 'ASC', true );
     4349            ), 'ASC', true
     4350        );
    42914351    }
    42924352
     
    43034363        if ( ! is_multisite() && ( current_user_can( 'install_themes' ) || current_user_can( 'update_themes' ) || current_user_can( 'delete_themes' ) ) ) {
    43044364            wp_enqueue_script( 'updates' );
    4305             wp_localize_script( 'updates', '_wpUpdatesItemCounts', array(
    4306                 'totals' => wp_get_update_data(),
    4307             ) );
     4365            wp_localize_script(
     4366                'updates', '_wpUpdatesItemCounts', array(
     4367                    'totals' => wp_get_update_data(),
     4368                )
     4369            );
    43084370        }
    43094371    }
     
    43494411     */
    43504412    public function set_preview_url( $preview_url ) {
    4351         $preview_url = esc_url_raw( $preview_url );
     4413        $preview_url       = esc_url_raw( $preview_url );
    43524414        $this->preview_url = wp_validate_redirect( $preview_url, home_url( '/' ) );
    43534415    }
     
    43784440    public function is_cross_domain() {
    43794441        $admin_origin = wp_parse_url( admin_url() );
    4380         $home_origin = wp_parse_url( home_url() );
     4442        $home_origin  = wp_parse_url( home_url() );
    43814443        $cross_domain = ( strtolower( $admin_origin['host'] ) !== strtolower( $home_origin['host'] ) );
    43824444        return $cross_domain;
     
    44374499     */
    44384500    public function set_return_url( $return_url ) {
    4439         $return_url = esc_url_raw( $return_url );
    4440         $return_url = remove_query_arg( wp_removable_query_args(), $return_url );
    4441         $return_url = wp_validate_redirect( $return_url );
     4501        $return_url       = esc_url_raw( $return_url );
     4502        $return_url       = remove_query_arg( wp_removable_query_args(), $return_url );
     4503        $return_url       = wp_validate_redirect( $return_url );
    44424504        $this->return_url = $return_url;
    44434505    }
     
    44514513     */
    44524514    public function get_return_url() {
    4453         $referer = wp_get_referer();
     4515        $referer                    = wp_get_referer();
    44544516        $excluded_referer_basenames = array( 'customize.php', 'wp-login.php' );
    44554517
    44564518        if ( $this->return_url ) {
    44574519            $return_url = $this->return_url;
    4458         } else if ( $referer && ! in_array( basename( parse_url( $referer, PHP_URL_PATH ) ), $excluded_referer_basenames, true ) ) {
     4520        } elseif ( $referer && ! in_array( basename( parse_url( $referer, PHP_URL_PATH ) ), $excluded_referer_basenames, true ) ) {
    44594521            $return_url = $referer;
    4460         } else if ( $this->preview_url ) {
     4522        } elseif ( $this->preview_url ) {
    44614523            $return_url = $this->preview_url;
    44624524        } else {
     
    45094571    public function get_nonces() {
    45104572        $nonces = array(
    4511             'save' => wp_create_nonce( 'save-customize_' . $this->get_stylesheet() ),
    4512             'preview' => wp_create_nonce( 'preview-customize_' . $this->get_stylesheet() ),
    4513             'switch_themes' => wp_create_nonce( 'switch_themes' ),
     4573            'save'                     => wp_create_nonce( 'save-customize_' . $this->get_stylesheet() ),
     4574            'preview'                  => wp_create_nonce( 'preview-customize_' . $this->get_stylesheet() ),
     4575            'switch_themes'            => wp_create_nonce( 'switch_themes' ),
    45144576            'dismiss_autosave_or_lock' => wp_create_nonce( 'customize_dismiss_autosave_or_lock' ),
    4515             'override_lock' => wp_create_nonce( 'customize_override_changeset_lock' ),
    4516             'trash' => wp_create_nonce( 'trash_customize_changeset' ),
     4577            'override_lock'            => wp_create_nonce( 'customize_override_changeset_lock' ),
     4578            'trash'                    => wp_create_nonce( 'trash_customize_changeset' ),
    45174579        );
    45184580
     
    45384600    public function customize_pane_settings() {
    45394601
    4540         $login_url = add_query_arg( array(
    4541             'interim-login' => 1,
    4542             'customize-login' => 1,
    4543         ), wp_login_url() );
     4602        $login_url = add_query_arg(
     4603            array(
     4604                'interim-login'   => 1,
     4605                'customize-login' => 1,
     4606            ), wp_login_url()
     4607        );
    45444608
    45454609        // Ensure dirty flags are set for modified settings.
     
    45514615        }
    45524616
    4553         $autosave_revision_post = null;
     4617        $autosave_revision_post  = null;
    45544618        $autosave_autodraft_post = null;
    4555         $changeset_post_id = $this->changeset_post_id();
     4619        $changeset_post_id       = $this->changeset_post_id();
    45564620        if ( ! $this->saved_starter_content_changeset && ! $this->autosaved() ) {
    45574621            if ( $changeset_post_id ) {
    45584622                $autosave_revision_post = wp_get_post_autosave( $changeset_post_id, get_current_user_id() );
    45594623            } else {
    4560                 $autosave_autodraft_posts = $this->get_changeset_posts( array(
    4561                     'posts_per_page' => 1,
    4562                     'post_status' => 'auto-draft',
    4563                     'exclude_restore_dismissed' => true,
    4564                 ) );
     4624                $autosave_autodraft_posts = $this->get_changeset_posts(
     4625                    array(
     4626                        'posts_per_page'            => 1,
     4627                        'post_status'               => 'auto-draft',
     4628                        'exclude_restore_dismissed' => true,
     4629                    )
     4630                );
    45654631                if ( ! empty( $autosave_autodraft_posts ) ) {
    45664632                    $autosave_autodraft_post = array_shift( $autosave_autodraft_posts );
     
    45764642            $status_choices[] = array(
    45774643                'status' => 'publish',
    4578                 'label' => __( 'Publish' ),
     4644                'label'  => __( 'Publish' ),
    45794645            );
    45804646        }
    45814647        $status_choices[] = array(
    45824648            'status' => 'draft',
    4583             'label' => __( 'Save Draft' ),
     4649            'label'  => __( 'Save Draft' ),
    45844650        );
    45854651        if ( $current_user_can_publish ) {
    45864652            $status_choices[] = array(
    45874653                'status' => 'future',
    4588                 'label' => _x( 'Schedule', 'customizer changeset action/button label' ),
     4654                'label'  => _x( 'Schedule', 'customizer changeset action/button label' ),
    45894655            );
    45904656        }
     
    46124678
    46134679        $settings = array(
    4614             'changeset' => array(
    4615                 'uuid' => $this->changeset_uuid(),
    4616                 'branching' => $this->branching(),
    4617                 'autosaved' => $this->autosaved(),
    4618                 'hasAutosaveRevision' => ! empty( $autosave_revision_post ),
    4619                 'latestAutoDraftUuid' => $autosave_autodraft_post ? $autosave_autodraft_post->post_name : null,
    4620                 'status' => $changeset_post ? $changeset_post->post_status : '',
     4680            'changeset'              => array(
     4681                'uuid'                  => $this->changeset_uuid(),
     4682                'branching'             => $this->branching(),
     4683                'autosaved'             => $this->autosaved(),
     4684                'hasAutosaveRevision'   => ! empty( $autosave_revision_post ),
     4685                'latestAutoDraftUuid'   => $autosave_autodraft_post ? $autosave_autodraft_post->post_name : null,
     4686                'status'                => $changeset_post ? $changeset_post->post_status : '',
    46214687                'currentUserCanPublish' => $current_user_can_publish,
    4622                 'publishDate' => $initial_date,
    4623                 'statusChoices' => $status_choices,
    4624                 'lockUser' => $lock_user_id ? $this->get_lock_user_data( $lock_user_id ) : null,
     4688                'publishDate'           => $initial_date,
     4689                'statusChoices'         => $status_choices,
     4690                'lockUser'              => $lock_user_id ? $this->get_lock_user_data( $lock_user_id ) : null,
    46254691            ),
    4626             'initialServerDate' => $current_time,
    4627             'dateFormat' => get_option( 'date_format' ),
    4628             'timeFormat' => get_option( 'time_format' ),
     4692            'initialServerDate'      => $current_time,
     4693            'dateFormat'             => get_option( 'date_format' ),
     4694            'timeFormat'             => get_option( 'time_format' ),
    46294695            'initialServerTimestamp' => floor( microtime( true ) * 1000 ),
    46304696            'initialClientTimestamp' => -1, // To be set with JS below.
    4631             'timeouts' => array(
    4632                 'windowRefresh' => 250,
    4633                 'changesetAutoSave' => AUTOSAVE_INTERVAL * 1000,
    4634                 'keepAliveCheck' => 2500,
    4635                 'reflowPaneContents' => 100,
     4697            'timeouts'               => array(
     4698                'windowRefresh'           => 250,
     4699                'changesetAutoSave'       => AUTOSAVE_INTERVAL * 1000,
     4700                'keepAliveCheck'          => 2500,
     4701                'reflowPaneContents'      => 100,
    46364702                'previewFrameSensitivity' => 2000,
    46374703            ),
    4638             'theme'    => array(
     4704            'theme'                  => array(
    46394705                'stylesheet' => $this->get_stylesheet(),
    46404706                'active'     => $this->is_theme_active(),
    46414707            ),
    4642             'url'      => array(
     4708            'url'                    => array(
    46434709                'preview'       => esc_url_raw( $this->get_preview_url() ),
    46444710                'return'        => esc_url_raw( $this->get_return_url() ),
     
    46514717                'login'         => esc_url_raw( $login_url ),
    46524718            ),
    4653             'browser'  => array(
     4719            'browser'                => array(
    46544720                'mobile' => wp_is_mobile(),
    46554721                'ios'    => $this->is_ios(),
    46564722            ),
    4657             'panels'   => array(),
    4658             'sections' => array(),
    4659             'nonce'    => $this->get_nonces(),
    4660             'autofocus' => $this->get_autofocus(),
    4661             'documentTitleTmpl' => $this->get_document_title_template(),
    4662             'previewableDevices' => $this->get_previewable_devices(),
    4663             'l10n' => array(
    4664                 'confirmDeleteTheme' => __( 'Are you sure you want to delete this theme?' ),
     4723            'panels'                 => array(),
     4724            'sections'               => array(),
     4725            'nonce'                  => $this->get_nonces(),
     4726            'autofocus'              => $this->get_autofocus(),
     4727            'documentTitleTmpl'      => $this->get_document_title_template(),
     4728            'previewableDevices'     => $this->get_previewable_devices(),
     4729            'l10n'                   => array(
     4730                'confirmDeleteTheme'   => __( 'Are you sure you want to delete this theme?' ),
    46654731                /* translators: %d: number of theme search results, which cannot currently consider singular vs. plural forms */
    4666                 'themeSearchResults' => __( '%d themes found' ),
     4732                'themeSearchResults'   => __( '%d themes found' ),
    46674733                /* translators: %d: number of themes being displayed, which cannot currently consider singular vs. plural forms */
    4668                 'announceThemeCount' => __( 'Displaying %d themes' ),
     4734                'announceThemeCount'   => __( 'Displaying %d themes' ),
    46694735                /* translators: %s: theme name */
    46704736                'announceThemeDetails' => __( 'Showing details for theme: %s' ),
     
    47484814        $devices = array(
    47494815            'desktop' => array(
    4750                 'label' => __( 'Enter desktop preview mode' ),
     4816                'label'   => __( 'Enter desktop preview mode' ),
    47514817                'default' => true,
    47524818            ),
    4753             'tablet' => array(
     4819            'tablet'  => array(
    47544820                'label' => __( 'Enter tablet preview mode' ),
    47554821            ),
    4756             'mobile' => array(
     4822            'mobile'  => array(
    47574823                'label' => __( 'Enter mobile preview mode' ),
    47584824            ),
     
    47824848        /* Themes (controls are loaded via ajax) */
    47834849
    4784         $this->add_panel( new WP_Customize_Themes_Panel( $this, 'themes', array(
    4785             'title'       => $this->theme()->display( 'Name' ),
    4786             'description' => (
    4787                 '<p>' . __( 'Looking for a theme? You can search or browse the WordPress.org theme directory, install and preview themes, then activate them right here.' ) . '</p>' .
    4788                 '<p>' . __( 'While previewing a new theme, you can continue to tailor things like widgets and menus, and explore theme-specific options.' ) . '</p>'
    4789             ),
    4790             'capability'  => 'switch_themes',
    4791             'priority'    => 0,
    4792         ) ) );
    4793 
    4794         $this->add_section( new WP_Customize_Themes_Section( $this, 'installed_themes', array(
    4795             'title'       => __( 'Installed themes' ),
    4796             'action'      => 'installed',
    4797             'capability'  => 'switch_themes',
    4798             'panel'       => 'themes',
    4799             'priority'    => 0,
    4800         ) ) );
     4850        $this->add_panel(
     4851            new WP_Customize_Themes_Panel(
     4852                $this, 'themes', array(
     4853                    'title'       => $this->theme()->display( 'Name' ),
     4854                    'description' => (
     4855                    '<p>' . __( 'Looking for a theme? You can search or browse the WordPress.org theme directory, install and preview themes, then activate them right here.' ) . '</p>' .
     4856                    '<p>' . __( 'While previewing a new theme, you can continue to tailor things like widgets and menus, and explore theme-specific options.' ) . '</p>'
     4857                    ),
     4858                    'capability'  => 'switch_themes',
     4859                    'priority'    => 0,
     4860                )
     4861            )
     4862        );
     4863
     4864        $this->add_section(
     4865            new WP_Customize_Themes_Section(
     4866                $this, 'installed_themes', array(
     4867                    'title'      => __( 'Installed themes' ),
     4868                    'action'     => 'installed',
     4869                    'capability' => 'switch_themes',
     4870                    'panel'      => 'themes',
     4871                    'priority'   => 0,
     4872                )
     4873            )
     4874        );
    48014875
    48024876        if ( ! is_multisite() ) {
    4803             $this->add_section( new WP_Customize_Themes_Section( $this, 'wporg_themes', array(
    4804                 'title'       => __( 'WordPress.org themes' ),
    4805                 'action'      => 'wporg',
    4806                 'filter_type' => 'remote',
    4807                 'capability'  => 'install_themes',
    4808                 'panel'       => 'themes',
    4809                 'priority'    => 5,
    4810             ) ) );
     4877            $this->add_section(
     4878                new WP_Customize_Themes_Section(
     4879                    $this, 'wporg_themes', array(
     4880                        'title'       => __( 'WordPress.org themes' ),
     4881                        'action'      => 'wporg',
     4882                        'filter_type' => 'remote',
     4883                        'capability'  => 'install_themes',
     4884                        'panel'       => 'themes',
     4885                        'priority'    => 5,
     4886                    )
     4887                )
     4888            );
    48114889        }
    48124890
    48134891        // Themes Setting (unused - the theme is considerably more fundamental to the Customizer experience).
    4814         $this->add_setting( new WP_Customize_Filter_Setting( $this, 'active_theme', array(
    4815             'capability' => 'switch_themes',
    4816         ) ) );
     4892        $this->add_setting(
     4893            new WP_Customize_Filter_Setting(
     4894                $this, 'active_theme', array(
     4895                    'capability' => 'switch_themes',
     4896                )
     4897            )
     4898        );
    48174899
    48184900        /* Site Identity */
    48194901
    4820         $this->add_section( 'title_tagline', array(
    4821             'title'    => __( 'Site Identity' ),
    4822             'priority' => 20,
    4823         ) );
    4824 
    4825         $this->add_setting( 'blogname', array(
    4826             'default'    => get_option( 'blogname' ),
    4827             'type'       => 'option',
    4828             'capability' => 'manage_options',
    4829         ) );
    4830 
    4831         $this->add_control( 'blogname', array(
    4832             'label'      => __( 'Site Title' ),
    4833             'section'    => 'title_tagline',
    4834         ) );
    4835 
    4836         $this->add_setting( 'blogdescription', array(
    4837             'default'    => get_option( 'blogdescription' ),
    4838             'type'       => 'option',
    4839             'capability' => 'manage_options',
    4840         ) );
    4841 
    4842         $this->add_control( 'blogdescription', array(
    4843             'label'      => __( 'Tagline' ),
    4844             'section'    => 'title_tagline',
    4845         ) );
     4902        $this->add_section(
     4903            'title_tagline', array(
     4904                'title'    => __( 'Site Identity' ),
     4905                'priority' => 20,
     4906            )
     4907        );
     4908
     4909        $this->add_setting(
     4910            'blogname', array(
     4911                'default'    => get_option( 'blogname' ),
     4912                'type'       => 'option',
     4913                'capability' => 'manage_options',
     4914            )
     4915        );
     4916
     4917        $this->add_control(
     4918            'blogname', array(
     4919                'label'   => __( 'Site Title' ),
     4920                'section' => 'title_tagline',
     4921            )
     4922        );
     4923
     4924        $this->add_setting(
     4925            'blogdescription', array(
     4926                'default'    => get_option( 'blogdescription' ),
     4927                'type'       => 'option',
     4928                'capability' => 'manage_options',
     4929            )
     4930        );
     4931
     4932        $this->add_control(
     4933            'blogdescription', array(
     4934                'label'   => __( 'Tagline' ),
     4935                'section' => 'title_tagline',
     4936            )
     4937        );
    48464938
    48474939        // Add a setting to hide header text if the theme doesn't support custom headers.
    48484940        if ( ! current_theme_supports( 'custom-header', 'header-text' ) ) {
    4849             $this->add_setting( 'header_text', array(
    4850                 'theme_supports'    => array( 'custom-logo', 'header-text' ),
    4851                 'default'           => 1,
    4852                 'sanitize_callback' => 'absint',
    4853             ) );
    4854 
    4855             $this->add_control( 'header_text', array(
     4941            $this->add_setting(
     4942                'header_text', array(
     4943                    'theme_supports'    => array( 'custom-logo', 'header-text' ),
     4944                    'default'           => 1,
     4945                    'sanitize_callback' => 'absint',
     4946                )
     4947            );
     4948
     4949            $this->add_control(
     4950                'header_text', array(
     4951                    'label'    => __( 'Display Site Title and Tagline' ),
     4952                    'section'  => 'title_tagline',
     4953                    'settings' => 'header_text',
     4954                    'type'     => 'checkbox',
     4955                )
     4956            );
     4957        }
     4958
     4959        $this->add_setting(
     4960            'site_icon', array(
     4961                'type'       => 'option',
     4962                'capability' => 'manage_options',
     4963                'transport'  => 'postMessage', // Previewed with JS in the Customizer controls window.
     4964            )
     4965        );
     4966
     4967        $this->add_control(
     4968            new WP_Customize_Site_Icon_Control(
     4969                $this, 'site_icon', array(
     4970                    'label'       => __( 'Site Icon' ),
     4971                    'description' => sprintf(
     4972                        '<p>' . __( 'Site Icons are what you see in browser tabs, bookmark bars, and within the WordPress mobile apps. Upload one here!' ) . '</p>' .
     4973                        /* translators: %s: site icon size in pixels */
     4974                        '<p>' . __( 'Site Icons should be square and at least %s pixels.' ) . '</p>',
     4975                        '<strong>512 &times; 512</strong>'
     4976                    ),
     4977                    'section'     => 'title_tagline',
     4978                    'priority'    => 60,
     4979                    'height'      => 512,
     4980                    'width'       => 512,
     4981                )
     4982            )
     4983        );
     4984
     4985        $this->add_setting(
     4986            'custom_logo', array(
     4987                'theme_supports' => array( 'custom-logo' ),
     4988                'transport'      => 'postMessage',
     4989            )
     4990        );
     4991
     4992        $custom_logo_args = get_theme_support( 'custom-logo' );
     4993        $this->add_control(
     4994            new WP_Customize_Cropped_Image_Control(
     4995                $this, 'custom_logo', array(
     4996                    'label'         => __( 'Logo' ),
     4997                    'section'       => 'title_tagline',
     4998                    'priority'      => 8,
     4999                    'height'        => $custom_logo_args[0]['height'],
     5000                    'width'         => $custom_logo_args[0]['width'],
     5001                    'flex_height'   => $custom_logo_args[0]['flex-height'],
     5002                    'flex_width'    => $custom_logo_args[0]['flex-width'],
     5003                    'button_labels' => array(
     5004                        'select'       => __( 'Select logo' ),
     5005                        'change'       => __( 'Change logo' ),
     5006                        'remove'       => __( 'Remove' ),
     5007                        'default'      => __( 'Default' ),
     5008                        'placeholder'  => __( 'No logo selected' ),
     5009                        'frame_title'  => __( 'Select logo' ),
     5010                        'frame_button' => __( 'Choose logo' ),
     5011                    ),
     5012                )
     5013            )
     5014        );
     5015
     5016        $this->selective_refresh->add_partial(
     5017            'custom_logo', array(
     5018                'settings'            => array( 'custom_logo' ),
     5019                'selector'            => '.custom-logo-link',
     5020                'render_callback'     => array( $this, '_render_custom_logo_partial' ),
     5021                'container_inclusive' => true,
     5022            )
     5023        );
     5024
     5025        /* Colors */
     5026
     5027        $this->add_section(
     5028            'colors', array(
     5029                'title'    => __( 'Colors' ),
     5030                'priority' => 40,
     5031            )
     5032        );
     5033
     5034        $this->add_setting(
     5035            'header_textcolor', array(
     5036                'theme_supports'       => array( 'custom-header', 'header-text' ),
     5037                'default'              => get_theme_support( 'custom-header', 'default-text-color' ),
     5038
     5039                'sanitize_callback'    => array( $this, '_sanitize_header_textcolor' ),
     5040                'sanitize_js_callback' => 'maybe_hash_hex_color',
     5041            )
     5042        );
     5043
     5044        // Input type: checkbox
     5045        // With custom value
     5046        $this->add_control(
     5047            'display_header_text', array(
     5048                'settings' => 'header_textcolor',
    48565049                'label'    => __( 'Display Site Title and Tagline' ),
    48575050                'section'  => 'title_tagline',
    4858                 'settings' => 'header_text',
    48595051                'type'     => 'checkbox',
    4860             ) );
    4861         }
    4862 
    4863         $this->add_setting( 'site_icon', array(
    4864             'type'       => 'option',
    4865             'capability' => 'manage_options',
    4866             'transport'  => 'postMessage', // Previewed with JS in the Customizer controls window.
    4867         ) );
    4868 
    4869         $this->add_control( new WP_Customize_Site_Icon_Control( $this, 'site_icon', array(
    4870             'label'       => __( 'Site Icon' ),
    4871             'description' => sprintf(
    4872                 '<p>' . __( 'Site Icons are what you see in browser tabs, bookmark bars, and within the WordPress mobile apps. Upload one here!' ) . '</p>' .
    4873                 /* translators: %s: site icon size in pixels */
    4874                 '<p>' . __( 'Site Icons should be square and at least %s pixels.' ) . '</p>',
    4875                 '<strong>512 &times; 512</strong>'
    4876             ),
    4877             'section'     => 'title_tagline',
    4878             'priority'    => 60,
    4879             'height'      => 512,
    4880             'width'       => 512,
    4881         ) ) );
    4882 
    4883         $this->add_setting( 'custom_logo', array(
    4884             'theme_supports' => array( 'custom-logo' ),
    4885             'transport'      => 'postMessage',
    4886         ) );
    4887 
    4888         $custom_logo_args = get_theme_support( 'custom-logo' );
    4889         $this->add_control( new WP_Customize_Cropped_Image_Control( $this, 'custom_logo', array(
    4890             'label'         => __( 'Logo' ),
    4891             'section'       => 'title_tagline',
    4892             'priority'      => 8,
    4893             'height'        => $custom_logo_args[0]['height'],
    4894             'width'         => $custom_logo_args[0]['width'],
    4895             'flex_height'   => $custom_logo_args[0]['flex-height'],
    4896             'flex_width'    => $custom_logo_args[0]['flex-width'],
    4897             'button_labels' => array(
    4898                 'select'       => __( 'Select logo' ),
    4899                 'change'       => __( 'Change logo' ),
    4900                 'remove'       => __( 'Remove' ),
    4901                 'default'      => __( 'Default' ),
    4902                 'placeholder'  => __( 'No logo selected' ),
    4903                 'frame_title'  => __( 'Select logo' ),
    4904                 'frame_button' => __( 'Choose logo' ),
    4905             ),
    4906         ) ) );
    4907 
    4908         $this->selective_refresh->add_partial( 'custom_logo', array(
    4909             'settings'            => array( 'custom_logo' ),
    4910             'selector'            => '.custom-logo-link',
    4911             'render_callback'     => array( $this, '_render_custom_logo_partial' ),
    4912             'container_inclusive' => true,
    4913         ) );
    4914 
    4915         /* Colors */
    4916 
    4917         $this->add_section( 'colors', array(
    4918             'title'          => __( 'Colors' ),
    4919             'priority'       => 40,
    4920         ) );
    4921 
    4922         $this->add_setting( 'header_textcolor', array(
    4923             'theme_supports' => array( 'custom-header', 'header-text' ),
    4924             'default'        => get_theme_support( 'custom-header', 'default-text-color' ),
    4925 
    4926             'sanitize_callback'    => array( $this, '_sanitize_header_textcolor' ),
    4927             'sanitize_js_callback' => 'maybe_hash_hex_color',
    4928         ) );
    4929 
    4930         // Input type: checkbox
    4931         // With custom value
    4932         $this->add_control( 'display_header_text', array(
    4933             'settings' => 'header_textcolor',
    4934             'label'    => __( 'Display Site Title and Tagline' ),
    4935             'section'  => 'title_tagline',
    4936             'type'     => 'checkbox',
    4937             'priority' => 40,
    4938         ) );
    4939 
    4940         $this->add_control( new WP_Customize_Color_Control( $this, 'header_textcolor', array(
    4941             'label'   => __( 'Header Text Color' ),
    4942             'section' => 'colors',
    4943         ) ) );
     5052                'priority' => 40,
     5053            )
     5054        );
     5055
     5056        $this->add_control(
     5057            new WP_Customize_Color_Control(
     5058                $this, 'header_textcolor', array(
     5059                    'label'   => __( 'Header Text Color' ),
     5060                    'section' => 'colors',
     5061                )
     5062            )
     5063        );
    49445064
    49455065        // Input type: Color
    49465066        // With sanitize_callback
    4947         $this->add_setting( 'background_color', array(
    4948             'default'        => get_theme_support( 'custom-background', 'default-color' ),
    4949             'theme_supports' => 'custom-background',
    4950 
    4951             'sanitize_callback'    => 'sanitize_hex_color_no_hash',
    4952             'sanitize_js_callback' => 'maybe_hash_hex_color',
    4953         ) );
    4954 
    4955         $this->add_control( new WP_Customize_Color_Control( $this, 'background_color', array(
    4956             'label'   => __( 'Background Color' ),
    4957             'section' => 'colors',
    4958         ) ) );
     5067        $this->add_setting(
     5068            'background_color', array(
     5069                'default'              => get_theme_support( 'custom-background', 'default-color' ),
     5070                'theme_supports'       => 'custom-background',
     5071
     5072                'sanitize_callback'    => 'sanitize_hex_color_no_hash',
     5073                'sanitize_js_callback' => 'maybe_hash_hex_color',
     5074            )
     5075        );
     5076
     5077        $this->add_control(
     5078            new WP_Customize_Color_Control(
     5079                $this, 'background_color', array(
     5080                    'label'   => __( 'Background Color' ),
     5081                    'section' => 'colors',
     5082                )
     5083            )
     5084        );
    49595085
    49605086        /* Custom Header */
    49615087
    49625088        if ( current_theme_supports( 'custom-header', 'video' ) ) {
    4963             $title = __( 'Header Media' );
     5089            $title       = __( 'Header Media' );
    49645090            $description = '<p>' . __( 'If you add a video, the image will be used as a fallback while the video loads.' ) . '</p>';
    49655091
    4966             $width = absint( get_theme_support( 'custom-header', 'width' ) );
     5092            $width  = absint( get_theme_support( 'custom-header', 'width' ) );
    49675093            $height = absint( get_theme_support( 'custom-header', 'height' ) );
    49685094            if ( $width && $height ) {
     
    49895115            }
    49905116        } else {
    4991             $title = __( 'Header Image' );
    4992             $description = '';
     5117            $title               = __( 'Header Image' );
     5118            $description         = '';
    49935119            $control_description = '';
    49945120        }
    49955121
    4996         $this->add_section( 'header_image', array(
    4997             'title'          => $title,
    4998             'description'    => $description,
    4999             'theme_supports' => 'custom-header',
    5000             'priority'       => 60,
    5001         ) );
    5002 
    5003         $this->add_setting( 'header_video', array(
    5004             'theme_supports'    => array( 'custom-header', 'video' ),
    5005             'transport'         => 'postMessage',
    5006             'sanitize_callback' => 'absint',
    5007             'validate_callback' => array( $this, '_validate_header_video' ),
    5008         ) );
    5009 
    5010         $this->add_setting( 'external_header_video', array(
    5011             'theme_supports'    => array( 'custom-header', 'video' ),
    5012             'transport'         => 'postMessage',
    5013             'sanitize_callback' => array( $this, '_sanitize_external_header_video' ),
    5014             'validate_callback' => array( $this, '_validate_external_header_video' ),
    5015         ) );
    5016 
    5017         $this->add_setting( new WP_Customize_Filter_Setting( $this, 'header_image', array(
    5018             'default'        => sprintf( get_theme_support( 'custom-header', 'default-image' ), get_template_directory_uri(), get_stylesheet_directory_uri() ),
    5019             'theme_supports' => 'custom-header',
    5020         ) ) );
    5021 
    5022         $this->add_setting( new WP_Customize_Header_Image_Setting( $this, 'header_image_data', array(
    5023             'theme_supports' => 'custom-header',
    5024         ) ) );
     5122        $this->add_section(
     5123            'header_image', array(
     5124                'title'          => $title,
     5125                'description'    => $description,
     5126                'theme_supports' => 'custom-header',
     5127                'priority'       => 60,
     5128            )
     5129        );
     5130
     5131        $this->add_setting(
     5132            'header_video', array(
     5133                'theme_supports'    => array( 'custom-header', 'video' ),
     5134                'transport'         => 'postMessage',
     5135                'sanitize_callback' => 'absint',
     5136                'validate_callback' => array( $this, '_validate_header_video' ),
     5137            )
     5138        );
     5139
     5140        $this->add_setting(
     5141            'external_header_video', array(
     5142                'theme_supports'    => array( 'custom-header', 'video' ),
     5143                'transport'         => 'postMessage',
     5144                'sanitize_callback' => array( $this, '_sanitize_external_header_video' ),
     5145                'validate_callback' => array( $this, '_validate_external_header_video' ),
     5146            )
     5147        );
     5148
     5149        $this->add_setting(
     5150            new WP_Customize_Filter_Setting(
     5151                $this, 'header_image', array(
     5152                    'default'        => sprintf( get_theme_support( 'custom-header', 'default-image' ), get_template_directory_uri(), get_stylesheet_directory_uri() ),
     5153                    'theme_supports' => 'custom-header',
     5154                )
     5155            )
     5156        );
     5157
     5158        $this->add_setting(
     5159            new WP_Customize_Header_Image_Setting(
     5160                $this, 'header_image_data', array(
     5161                    'theme_supports' => 'custom-header',
     5162                )
     5163            )
     5164        );
    50255165
    50265166        /*
     
    50305170         */
    50315171        if ( current_theme_supports( 'custom-header', 'video' ) ) {
    5032             $this->get_setting( 'header_image' )->transport = 'postMessage';
     5172            $this->get_setting( 'header_image' )->transport      = 'postMessage';
    50335173            $this->get_setting( 'header_image_data' )->transport = 'postMessage';
    50345174        }
    50355175
    5036         $this->add_control( new WP_Customize_Media_Control( $this, 'header_video', array(
    5037             'theme_supports' => array( 'custom-header', 'video' ),
    5038             'label'          => __( 'Header Video' ),
    5039             'description'    => $control_description,
    5040             'section'        => 'header_image',
    5041             'mime_type'      => 'video',
    5042             'active_callback' => 'is_header_video_active',
    5043         ) ) );
    5044 
    5045         $this->add_control( 'external_header_video', array(
    5046             'theme_supports' => array( 'custom-header', 'video' ),
    5047             'type'           => 'url',
    5048             'description'    => __( 'Or, enter a YouTube URL:' ),
    5049             'section'        => 'header_image',
    5050             'active_callback' => 'is_header_video_active',
    5051         ) );
     5176        $this->add_control(
     5177            new WP_Customize_Media_Control(
     5178                $this, 'header_video', array(
     5179                    'theme_supports'  => array( 'custom-header', 'video' ),
     5180                    'label'           => __( 'Header Video' ),
     5181                    'description'     => $control_description,
     5182                    'section'         => 'header_image',
     5183                    'mime_type'       => 'video',
     5184                    'active_callback' => 'is_header_video_active',
     5185                )
     5186            )
     5187        );
     5188
     5189        $this->add_control(
     5190            'external_header_video', array(
     5191                'theme_supports'  => array( 'custom-header', 'video' ),
     5192                'type'            => 'url',
     5193                'description'     => __( 'Or, enter a YouTube URL:' ),
     5194                'section'         => 'header_image',
     5195                'active_callback' => 'is_header_video_active',
     5196            )
     5197        );
    50525198
    50535199        $this->add_control( new WP_Customize_Header_Image_Control( $this ) );
    50545200
    5055         $this->selective_refresh->add_partial( 'custom_header', array(
    5056             'selector'            => '#wp-custom-header',
    5057             'render_callback'     => 'the_custom_header_markup',
    5058             'settings'            => array( 'header_video', 'external_header_video', 'header_image' ), // The image is used as a video fallback here.
    5059             'container_inclusive' => true,
    5060         ) );
     5201        $this->selective_refresh->add_partial(
     5202            'custom_header', array(
     5203                'selector'            => '#wp-custom-header',
     5204                'render_callback'     => 'the_custom_header_markup',
     5205                'settings'            => array( 'header_video', 'external_header_video', 'header_image' ), // The image is used as a video fallback here.
     5206                'container_inclusive' => true,
     5207            )
     5208        );
    50615209
    50625210        /* Custom Background */
    50635211
    5064         $this->add_section( 'background_image', array(
    5065             'title'          => __( 'Background Image' ),
    5066             'theme_supports' => 'custom-background',
    5067             'priority'       => 80,
    5068         ) );
    5069 
    5070         $this->add_setting( 'background_image', array(
    5071             'default'        => get_theme_support( 'custom-background', 'default-image' ),
    5072             'theme_supports' => 'custom-background',
    5073             'sanitize_callback' => array( $this, '_sanitize_background_setting' ),
    5074         ) );
    5075 
    5076         $this->add_setting( new WP_Customize_Background_Image_Setting( $this, 'background_image_thumb', array(
    5077             'theme_supports' => 'custom-background',
    5078             'sanitize_callback' => array( $this, '_sanitize_background_setting' ),
    5079         ) ) );
     5212        $this->add_section(
     5213            'background_image', array(
     5214                'title'          => __( 'Background Image' ),
     5215                'theme_supports' => 'custom-background',
     5216                'priority'       => 80,
     5217            )
     5218        );
     5219
     5220        $this->add_setting(
     5221            'background_image', array(
     5222                'default'           => get_theme_support( 'custom-background', 'default-image' ),
     5223                'theme_supports'    => 'custom-background',
     5224                'sanitize_callback' => array( $this, '_sanitize_background_setting' ),
     5225            )
     5226        );
     5227
     5228        $this->add_setting(
     5229            new WP_Customize_Background_Image_Setting(
     5230                $this, 'background_image_thumb', array(
     5231                    'theme_supports'    => 'custom-background',
     5232                    'sanitize_callback' => array( $this, '_sanitize_background_setting' ),
     5233                )
     5234            )
     5235        );
    50805236
    50815237        $this->add_control( new WP_Customize_Background_Image_Control( $this ) );
    50825238
    5083         $this->add_setting( 'background_preset', array(
    5084             'default'        => get_theme_support( 'custom-background', 'default-preset' ),
    5085             'theme_supports' => 'custom-background',
    5086             'sanitize_callback' => array( $this, '_sanitize_background_setting' ),
    5087         ) );
    5088 
    5089         $this->add_control( 'background_preset', array(
    5090             'label'      => _x( 'Preset', 'Background Preset' ),
    5091             'section'    => 'background_image',
    5092             'type'       => 'select',
    5093             'choices'    => array(
    5094                 'default' => _x( 'Default', 'Default Preset' ),
    5095                 'fill'    => __( 'Fill Screen' ),
    5096                 'fit'     => __( 'Fit to Screen' ),
    5097                 'repeat'  => _x( 'Repeat', 'Repeat Image' ),
    5098                 'custom'  => _x( 'Custom', 'Custom Preset' ),
    5099             ),
    5100         ) );
    5101 
    5102         $this->add_setting( 'background_position_x', array(
    5103             'default'        => get_theme_support( 'custom-background', 'default-position-x' ),
    5104             'theme_supports' => 'custom-background',
    5105             'sanitize_callback' => array( $this, '_sanitize_background_setting' ),
    5106         ) );
    5107 
    5108         $this->add_setting( 'background_position_y', array(
    5109             'default'        => get_theme_support( 'custom-background', 'default-position-y' ),
    5110             'theme_supports' => 'custom-background',
    5111             'sanitize_callback' => array( $this, '_sanitize_background_setting' ),
    5112         ) );
    5113 
    5114         $this->add_control( new WP_Customize_Background_Position_Control( $this, 'background_position', array(
    5115             'label'    => __( 'Image Position' ),
    5116             'section'  => 'background_image',
    5117             'settings' => array(
    5118                 'x' => 'background_position_x',
    5119                 'y' => 'background_position_y',
    5120             ),
    5121         ) ) );
    5122 
    5123         $this->add_setting( 'background_size', array(
    5124             'default'        => get_theme_support( 'custom-background', 'default-size' ),
    5125             'theme_supports' => 'custom-background',
    5126             'sanitize_callback' => array( $this, '_sanitize_background_setting' ),
    5127         ) );
    5128 
    5129         $this->add_control( 'background_size', array(
    5130             'label'      => __( 'Image Size' ),
    5131             'section'    => 'background_image',
    5132             'type'       => 'select',
    5133             'choices'    => array(
    5134                 'auto'    => __( 'Original' ),
    5135                 'contain' => __( 'Fit to Screen' ),
    5136                 'cover'   => __( 'Fill Screen' ),
    5137             ),
    5138         ) );
    5139 
    5140         $this->add_setting( 'background_repeat', array(
    5141             'default'           => get_theme_support( 'custom-background', 'default-repeat' ),
    5142             'sanitize_callback' => array( $this, '_sanitize_background_setting' ),
    5143             'theme_supports'    => 'custom-background',
    5144         ) );
    5145 
    5146         $this->add_control( 'background_repeat', array(
    5147             'label'    => __( 'Repeat Background Image' ),
    5148             'section'  => 'background_image',
    5149             'type'     => 'checkbox',
    5150         ) );
    5151 
    5152         $this->add_setting( 'background_attachment', array(
    5153             'default'           => get_theme_support( 'custom-background', 'default-attachment' ),
    5154             'sanitize_callback' => array( $this, '_sanitize_background_setting' ),
    5155             'theme_supports'    => 'custom-background',
    5156         ) );
    5157 
    5158         $this->add_control( 'background_attachment', array(
    5159             'label'    => __( 'Scroll with Page' ),
    5160             'section'  => 'background_image',
    5161             'type'     => 'checkbox',
    5162         ) );
    5163 
     5239        $this->add_setting(
     5240            'background_preset', array(
     5241                'default'           => get_theme_support( 'custom-background', 'default-preset' ),
     5242                'theme_supports'    => 'custom-background',
     5243                'sanitize_callback' => array( $this, '_sanitize_background_setting' ),
     5244            )
     5245        );
     5246
     5247        $this->add_control(
     5248            'background_preset', array(
     5249                'label'   => _x( 'Preset', 'Background Preset' ),
     5250                'section' => 'background_image',
     5251                'type'    => 'select',
     5252                'choices' => array(
     5253                    'default' => _x( 'Default', 'Default Preset' ),
     5254                    'fill'    => __( 'Fill Screen' ),
     5255                    'fit'     => __( 'Fit to Screen' ),
     5256                    'repeat'  => _x( 'Repeat', 'Repeat Image' ),
     5257                    'custom'  => _x( 'Custom', 'Custom Preset' ),
     5258                ),
     5259            )
     5260        );
     5261
     5262        $this->add_setting(
     5263            'background_position_x', array(
     5264                'default'           => get_theme_support( 'custom-background', 'default-position-x' ),
     5265                'theme_supports'    => 'custom-background',
     5266                'sanitize_callback' => array( $this, '_sanitize_background_setting' ),
     5267            )
     5268        );
     5269
     5270        $this->add_setting(
     5271            'background_position_y', array(
     5272                'default'           => get_theme_support( 'custom-background', 'default-position-y' ),
     5273                'theme_supports'    => 'custom-background',
     5274                'sanitize_callback' => array( $this, '_sanitize_background_setting' ),
     5275            )
     5276        );
     5277
     5278        $this->add_control(
     5279            new WP_Customize_Background_Position_Control(
     5280                $this, 'background_position', array(
     5281                    'label'    => __( 'Image Position' ),
     5282                    'section'  => 'background_image',
     5283                    'settings' => array(
     5284                        'x' => 'background_position_x',
     5285                        'y' => 'background_position_y',
     5286                    ),
     5287                )
     5288            )
     5289        );
     5290
     5291        $this->add_setting(
     5292            'background_size', array(
     5293                'default'           => get_theme_support( 'custom-background', 'default-size' ),
     5294                'theme_supports'    => 'custom-background',
     5295                'sanitize_callback' => array( $this, '_sanitize_background_setting' ),
     5296            )
     5297        );
     5298
     5299        $this->add_control(
     5300            'background_size', array(
     5301                'label'   => __( 'Image Size' ),
     5302                'section' => 'background_image',
     5303                'type'    => 'select',
     5304                'choices' => array(
     5305                    'auto'    => __( 'Original' ),
     5306                    'contain' => __( 'Fit to Screen' ),
     5307                    'cover'   => __( 'Fill Screen' ),
     5308                ),
     5309            )
     5310        );
     5311
     5312        $this->add_setting(
     5313            'background_repeat', array(
     5314                'default'           => get_theme_support( 'custom-background', 'default-repeat' ),
     5315                'sanitize_callback' => array( $this, '_sanitize_background_setting' ),
     5316                'theme_supports'    => 'custom-background',
     5317            )
     5318        );
     5319
     5320        $this->add_control(
     5321            'background_repeat', array(
     5322                'label'   => __( 'Repeat Background Image' ),
     5323                'section' => 'background_image',
     5324                'type'    => 'checkbox',
     5325            )
     5326        );
     5327
     5328        $this->add_setting(
     5329            'background_attachment', array(
     5330                'default'           => get_theme_support( 'custom-background', 'default-attachment' ),
     5331                'sanitize_callback' => array( $this, '_sanitize_background_setting' ),
     5332                'theme_supports'    => 'custom-background',
     5333            )
     5334        );
     5335
     5336        $this->add_control(
     5337            'background_attachment', array(
     5338                'label'   => __( 'Scroll with Page' ),
     5339                'section' => 'background_image',
     5340                'type'    => 'checkbox',
     5341            )
     5342        );
    51645343
    51655344        // If the theme is using the default background callback, we can update
     
    51775356         */
    51785357
    5179         $this->add_section( 'static_front_page', array(
    5180             'title' => __( 'Homepage Settings' ),
    5181             'priority' => 120,
    5182             'description' => __( 'You can choose what&#8217;s displayed on the homepage of your site. It can be posts in reverse chronological order (classic blog), or a fixed/static page. To set a static homepage, you first need to create two Pages. One will become the homepage, and the other will be where your posts are displayed.' ),
    5183             'active_callback' => array( $this, 'has_published_pages' ),
    5184         ) );
    5185 
    5186         $this->add_setting( 'show_on_front', array(
    5187             'default' => get_option( 'show_on_front' ),
    5188             'capability' => 'manage_options',
    5189             'type' => 'option',
    5190         ) );
    5191 
    5192         $this->add_control( 'show_on_front', array(
    5193             'label' => __( 'Your homepage displays' ),
    5194             'section' => 'static_front_page',
    5195             'type' => 'radio',
    5196             'choices' => array(
    5197                 'posts' => __( 'Your latest posts' ),
    5198                 'page'  => __( 'A static page' ),
    5199             ),
    5200         ) );
    5201 
    5202         $this->add_setting( 'page_on_front', array(
    5203             'type'       => 'option',
    5204             'capability' => 'manage_options',
    5205         ) );
    5206 
    5207         $this->add_control( 'page_on_front', array(
    5208             'label' => __( 'Homepage' ),
    5209             'section' => 'static_front_page',
    5210             'type' => 'dropdown-pages',
    5211             'allow_addition' => true,
    5212         ) );
    5213 
    5214         $this->add_setting( 'page_for_posts', array(
    5215             'type' => 'option',
    5216             'capability' => 'manage_options',
    5217         ) );
    5218 
    5219         $this->add_control( 'page_for_posts', array(
    5220             'label' => __( 'Posts page' ),
    5221             'section' => 'static_front_page',
    5222             'type' => 'dropdown-pages',
    5223             'allow_addition' => true,
    5224         ) );
     5358        $this->add_section(
     5359            'static_front_page', array(
     5360                'title'           => __( 'Homepage Settings' ),
     5361                'priority'        => 120,
     5362                'description'     => __( 'You can choose what&#8217;s displayed on the homepage of your site. It can be posts in reverse chronological order (classic blog), or a fixed/static page. To set a static homepage, you first need to create two Pages. One will become the homepage, and the other will be where your posts are displayed.' ),
     5363                'active_callback' => array( $this, 'has_published_pages' ),
     5364            )
     5365        );
     5366
     5367        $this->add_setting(
     5368            'show_on_front', array(
     5369                'default'    => get_option( 'show_on_front' ),
     5370                'capability' => 'manage_options',
     5371                'type'       => 'option',
     5372            )
     5373        );
     5374
     5375        $this->add_control(
     5376            'show_on_front', array(
     5377                'label'   => __( 'Your homepage displays' ),
     5378                'section' => 'static_front_page',
     5379                'type'    => 'radio',
     5380                'choices' => array(
     5381                    'posts' => __( 'Your latest posts' ),
     5382                    'page'  => __( 'A static page' ),
     5383                ),
     5384            )
     5385        );
     5386
     5387        $this->add_setting(
     5388            'page_on_front', array(
     5389                'type'       => 'option',
     5390                'capability' => 'manage_options',
     5391            )
     5392        );
     5393
     5394        $this->add_control(
     5395            'page_on_front', array(
     5396                'label'          => __( 'Homepage' ),
     5397                'section'        => 'static_front_page',
     5398                'type'           => 'dropdown-pages',
     5399                'allow_addition' => true,
     5400            )
     5401        );
     5402
     5403        $this->add_setting(
     5404            'page_for_posts', array(
     5405                'type'       => 'option',
     5406                'capability' => 'manage_options',
     5407            )
     5408        );
     5409
     5410        $this->add_control(
     5411            'page_for_posts', array(
     5412                'label'          => __( 'Posts page' ),
     5413                'section'        => 'static_front_page',
     5414                'type'           => 'dropdown-pages',
     5415                'allow_addition' => true,
     5416            )
     5417        );
    52255418
    52265419        /* Custom CSS */
    5227         $section_description = '<p>';
     5420        $section_description  = '<p>';
    52285421        $section_description .= __( 'Add your own CSS code here to customize the appearance and layout of your site.' );
    52295422        $section_description .= sprintf(
     
    52505443                esc_url( get_edit_profile_url() ),
    52515444                'class="external-link" target="_blank"',
    5252                 sprintf( '<span class="screen-reader-text"> %s</span>',
     5445                sprintf(
     5446                    '<span class="screen-reader-text"> %s</span>',
    52535447                    /* translators: accessibility text */
    52545448                    __( '(opens in a new window)' )
     
    52625456        $section_description .= '</p>';
    52635457
    5264         $this->add_section( 'custom_css', array(
    5265             'title'              => __( 'Additional CSS' ),
    5266             'priority'           => 200,
    5267             'description_hidden' => true,
    5268             'description'        => $section_description,
    5269         ) );
    5270 
    5271         $custom_css_setting = new WP_Customize_Custom_CSS_Setting( $this, sprintf( 'custom_css[%s]', get_stylesheet() ), array(
    5272             'capability' => 'edit_css',
    5273             'default' => '',
    5274         ) );
     5458        $this->add_section(
     5459            'custom_css', array(
     5460                'title'              => __( 'Additional CSS' ),
     5461                'priority'           => 200,
     5462                'description_hidden' => true,
     5463                'description'        => $section_description,
     5464            )
     5465        );
     5466
     5467        $custom_css_setting = new WP_Customize_Custom_CSS_Setting(
     5468            $this, sprintf( 'custom_css[%s]', get_stylesheet() ), array(
     5469                'capability' => 'edit_css',
     5470                'default'    => '',
     5471            )
     5472        );
    52755473        $this->add_setting( $custom_css_setting );
    52765474
    5277         $this->add_control( new WP_Customize_Code_Editor_Control( $this, 'custom_css', array(
    5278             'label'       => __( 'CSS code' ),
    5279             'section'     => 'custom_css',
    5280             'settings'    => array( 'default' => $custom_css_setting->id ),
    5281             'code_type'   => 'text/css',
    5282             'input_attrs' => array(
    5283                 'aria-describedby' => 'editor-keyboard-trap-help-1 editor-keyboard-trap-help-2 editor-keyboard-trap-help-3 editor-keyboard-trap-help-4',
    5284             ),
    5285         ) ) );
     5475        $this->add_control(
     5476            new WP_Customize_Code_Editor_Control(
     5477                $this, 'custom_css', array(
     5478                    'label'       => __( 'CSS code' ),
     5479                    'section'     => 'custom_css',
     5480                    'settings'    => array( 'default' => $custom_css_setting->id ),
     5481                    'code_type'   => 'text/css',
     5482                    'input_attrs' => array(
     5483                        'aria-describedby' => 'editor-keyboard-trap-help-1 editor-keyboard-trap-help-2 editor-keyboard-trap-help-3 editor-keyboard-trap-help-4',
     5484                    ),
     5485                )
     5486            )
     5487        );
    52865488    }
    52875489
     
    53365538        }
    53375539        $theme_action = sanitize_key( $_POST['theme_action'] );
    5338         $themes = array();
    5339         $args = array();
     5540        $themes       = array();
     5541        $args         = array();
    53405542
    53415543        // Define query filters based on user input.
     
    53655567            $themes = array( 'themes' => wp_prepare_themes_for_js() );
    53665568            foreach ( $themes['themes'] as &$theme ) {
    5367                 $theme['type'] = 'installed';
     5569                $theme['type']   = 'installed';
    53685570                $theme['active'] = ( isset( $_POST['customized_theme'] ) && $_POST['customized_theme'] === $theme['id'] );
    53695571            }
    5370 
    53715572        } elseif ( 'wporg' === $theme_action ) {
    53725573
     
    53795580            $wporg_args = array(
    53805581                'per_page' => 100,
    5381                 'fields' => array(
     5582                'fields'   => array(
    53825583                    'screenshot_url' => true,
    5383                     'description' => true,
    5384                     'rating' => true,
    5385                     'downloaded' => true,
    5386                     'downloadlink' => true,
    5387                     'last_updated' => true,
    5388                     'homepage' => true,
    5389                     'num_ratings' => true,
    5390                     'tags' => true,
    5391                     'parent' => true,
     5584                    'description'    => true,
     5585                    'rating'         => true,
     5586                    'downloaded'     => true,
     5587                    'downloadlink'   => true,
     5588                    'last_updated'   => true,
     5589                    'homepage'       => true,
     5590                    'num_ratings'    => true,
     5591                    'tags'           => true,
     5592                    'parent'         => true,
    53925593                    // 'extended_author' => true, @todo: WordPress.org throws a 500 server error when this is here.
    53935594                ),
     
    54075608
    54085609            // This list matches the allowed tags in wp-admin/includes/theme-install.php.
    5409             $themes_allowedtags = array_fill_keys(
     5610            $themes_allowedtags                     = array_fill_keys(
    54105611                array( 'a', 'abbr', 'acronym', 'code', 'pre', 'em', 'strong', 'div', 'p', 'ul', 'ol', 'li', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'img' ),
    54115612                array()
    54125613            );
    5413             $themes_allowedtags['a'] = array_fill_keys( array( 'href', 'title', 'target' ), true );
     5614            $themes_allowedtags['a']                = array_fill_keys( array( 'href', 'title', 'target' ), true );
    54145615            $themes_allowedtags['acronym']['title'] = true;
    5415             $themes_allowedtags['abbr']['title'] = true;
    5416             $themes_allowedtags['img'] = array_fill_keys( array( 'src', 'class', 'alt' ), true );
     5616            $themes_allowedtags['abbr']['title']    = true;
     5617            $themes_allowedtags['img']              = array_fill_keys( array( 'src', 'class', 'alt' ), true );
    54175618
    54185619            // Prepare a list of installed themes to check against before the loop.
    54195620            $installed_themes = array();
    5420             $wp_themes = wp_get_themes();
     5621            $wp_themes        = wp_get_themes();
    54215622            foreach ( $wp_themes as $theme ) {
    54225623                $installed_themes[] = $theme->get_stylesheet();
     
    54265627            // Set up properties for themes available on WordPress.org.
    54275628            foreach ( $themes->themes as &$theme ) {
    5428                 $theme->install_url = add_query_arg( array(
    5429                     'theme'    => $theme->slug,
    5430                     '_wpnonce' => wp_create_nonce( 'install-theme_' . $theme->slug ),
    5431                 ), $update_php );
     5629                $theme->install_url = add_query_arg(
     5630                    array(
     5631                        'theme'    => $theme->slug,
     5632                        '_wpnonce' => wp_create_nonce( 'install-theme_' . $theme->slug ),
     5633                    ), $update_php
     5634                );
    54325635
    54335636                $theme->name        = wp_kses( $theme->name, $themes_allowedtags );
     
    54365639                $theme->description = wp_kses( $theme->description, $themes_allowedtags );
    54375640                $theme->tags        = implode( ', ', $theme->tags );
    5438                 $theme->stars       = wp_star_rating( array(
    5439                     'rating' => $theme->rating,
    5440                     'type' => 'percent',
    5441                     'number' => $theme->num_ratings,
    5442                     'echo' => false,
    5443                 ) );
     5641                $theme->stars       = wp_star_rating(
     5642                    array(
     5643                        'rating' => $theme->rating,
     5644                        'type'   => 'percent',
     5645                        'number' => $theme->num_ratings,
     5646                        'echo'   => false,
     5647                    )
     5648                );
    54445649                $theme->num_ratings = number_format_i18n( $theme->num_ratings );
    54455650                $theme->preview_url = set_url_scheme( $theme->preview_url );
     
    55065711     */
    55075712    public function _sanitize_header_textcolor( $color ) {
    5508         if ( 'blank' === $color )
     5713        if ( 'blank' === $color ) {
    55095714            return 'blank';
     5715        }
    55105716
    55115717        $color = sanitize_hex_color_no_hash( $color );
    5512         if ( empty( $color ) )
     5718        if ( empty( $color ) ) {
    55135719            $color = get_theme_support( 'custom-header', 'default-text-color' );
     5720        }
    55145721
    55155722        return $color;
     
    55925799            $size = filesize( $video );
    55935800            if ( 8 < $size / pow( 1024, 2 ) ) { // Check whether the size is larger than 8MB.
    5594                 $validity->add( 'size_too_large',
     5801                $validity->add(
     5802                    'size_too_large',
    55955803                    __( 'This video file is too large to use as a header video. Try a shorter video or optimize the compression settings and re-upload a file that is less than 8MB. Or, upload your video to YouTube and link it with the option below.' )
    55965804                );
    55975805            }
    55985806            if ( '.mp4' !== substr( $video, -4 ) && '.mov' !== substr( $video, -4 ) ) { // Check for .mp4 or .mov format, which (assuming h.264 encoding) are the only cross-browser-supported formats.
    5599                 $validity->add( 'invalid_file_type', sprintf(
    5600                     /* translators: 1: .mp4, 2: .mov */
    5601                     __( 'Only %1$s or %2$s files may be used for header video. Please convert your video file and try again, or, upload your video to YouTube and link it with the option below.' ),
    5602                     '<code>.mp4</code>',
    5603                     '<code>.mov</code>'
    5604                 ) );
     5807                $validity->add(
     5808                    'invalid_file_type', sprintf(
     5809                        /* translators: 1: .mp4, 2: .mov */
     5810                        __( 'Only %1$s or %2$s files may be used for header video. Please convert your video file and try again, or, upload your video to YouTube and link it with the option below.' ),
     5811                        '<code>.mp4</code>',
     5812                        '<code>.mov</code>'
     5813                    )
     5814                );
    56055815            }
    56065816        }
Note: See TracChangeset for help on using the changeset viewer.