wp/wp-includes/class-wp-customize-manager.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
--- a/wp/wp-includes/class-wp-customize-manager.php	Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-includes/class-wp-customize-manager.php	Tue Sep 27 16:37:53 2022 +0200
@@ -161,7 +161,7 @@
 	 * Mapping of 'panel', 'section', 'control' to the ID which should be autofocused.
 	 *
 	 * @since 4.4.0
-	 * @var array
+	 * @var string[]
 	 */
 	protected $autofocus = array();
 
@@ -346,7 +346,7 @@
 		 * @see WP_Customize_Manager::__construct()
 		 *
 		 * @param string[]             $components Array of core components to load.
-		 * @param WP_Customize_Manager $this       WP_Customize_Manager instance.
+		 * @param WP_Customize_Manager $manager    WP_Customize_Manager instance.
 		 */
 		$components = apply_filters( 'customize_loaded_components', $this->components, $this );
 
@@ -407,7 +407,7 @@
 	}
 
 	/**
-	 * Return true if it's an Ajax request.
+	 * Returns true if it's an Ajax request.
 	 *
 	 * @since 3.4.0
 	 * @since 4.2.0 Added `$action` param.
@@ -476,7 +476,7 @@
 	}
 
 	/**
-	 * Return the Ajax wp_die() handler if it's a customized request.
+	 * Returns the Ajax wp_die() handler if it's a customized request.
 	 *
 	 * @since 3.4.0
 	 * @deprecated 4.7.0
@@ -494,13 +494,13 @@
 	}
 
 	/**
-	 * Start preview and customize theme.
-	 *
-	 * Check if customize query variable exist. Init filters to filter the current theme.
+	 * Starts preview and customize theme.
+	 *
+	 * Check if customize query variable exist. Init filters to filter the active theme.
 	 *
 	 * @since 3.4.0
 	 *
-	 * @global string $pagenow
+	 * @global string $pagenow The filename of the current screen.
 	 */
 	public function setup_theme() {
 		global $pagenow;
@@ -597,7 +597,7 @@
 	}
 
 	/**
-	 * Establish the loaded changeset.
+	 * Establishes the loaded changeset.
 	 *
 	 * This method runs right at after_setup_theme and applies the 'customize_changeset_branching' filter to determine
 	 * whether concurrent changesets are allowed. Then if the Customizer is not initialized with a `changeset_uuid` param,
@@ -607,7 +607,7 @@
 	 *
 	 * @since 4.9.0
 	 *
-	 * @global string $pagenow
+	 * @global string $pagenow The filename of the current screen.
 	 */
 	public function establish_loaded_changeset() {
 		global $pagenow;
@@ -691,15 +691,15 @@
 		 *
 		 * @since 3.4.0
 		 *
-		 * @param WP_Customize_Manager $this WP_Customize_Manager instance.
+		 * @param WP_Customize_Manager $manager WP_Customize_Manager instance.
 		 */
 		do_action( 'start_previewing_theme', $this );
 	}
 
 	/**
-	 * Stop previewing the selected theme.
-	 *
-	 * Removes filters to change the current theme.
+	 * Stops previewing the selected theme.
+	 *
+	 * Removes filters to change the active theme.
 	 *
 	 * @since 3.4.0
 	 */
@@ -729,7 +729,7 @@
 		 *
 		 * @since 3.4.0
 		 *
-		 * @param WP_Customize_Manager $this WP_Customize_Manager instance.
+		 * @param WP_Customize_Manager $manager WP_Customize_Manager instance.
 		 */
 		do_action( 'stop_previewing_theme', $this );
 	}
@@ -802,7 +802,7 @@
 	}
 
 	/**
-	 * Get the changeset UUID.
+	 * Gets the changeset UUID.
 	 *
 	 * @since 4.7.0
 	 *
@@ -818,7 +818,7 @@
 	}
 
 	/**
-	 * Get the theme being customized.
+	 * Gets the theme being customized.
 	 *
 	 * @since 3.4.0
 	 *
@@ -832,7 +832,7 @@
 	}
 
 	/**
-	 * Get the registered settings.
+	 * Gets the registered settings.
 	 *
 	 * @since 3.4.0
 	 *
@@ -843,7 +843,7 @@
 	}
 
 	/**
-	 * Get the registered controls.
+	 * Gets the registered controls.
 	 *
 	 * @since 3.4.0
 	 *
@@ -854,7 +854,7 @@
 	}
 
 	/**
-	 * Get the registered containers.
+	 * Gets the registered containers.
 	 *
 	 * @since 4.0.0
 	 *
@@ -865,7 +865,7 @@
 	}
 
 	/**
-	 * Get the registered sections.
+	 * Gets the registered sections.
 	 *
 	 * @since 3.4.0
 	 *
@@ -876,7 +876,7 @@
 	}
 
 	/**
-	 * Get the registered panels.
+	 * Gets the registered panels.
 	 *
 	 * @since 4.0.0
 	 *
@@ -898,7 +898,7 @@
 	}
 
 	/**
-	 * Register styles/scripts and initialize the preview of each setting
+	 * Registers styles/scripts and initialize the preview of each setting
 	 *
 	 * @since 3.4.0
 	 */
@@ -928,7 +928,7 @@
 		 *
 		 * @since 3.4.0
 		 *
-		 * @param WP_Customize_Manager $this WP_Customize_Manager instance.
+		 * @param WP_Customize_Manager $manager WP_Customize_Manager instance.
 		 */
 		do_action( 'customize_register', $this );
 
@@ -966,7 +966,7 @@
 	}
 
 	/**
-	 * Find the changeset post ID for a given changeset UUID.
+	 * Finds the changeset post ID for a given changeset UUID.
 	 *
 	 * @since 4.7.0
 	 *
@@ -1004,7 +1004,7 @@
 	}
 
 	/**
-	 * Get changeset posts.
+	 * Gets changeset posts.
 	 *
 	 * @since 4.9.0
 	 *
@@ -1051,7 +1051,7 @@
 	}
 
 	/**
-	 * Dismiss all of the current user's auto-drafts (other than the present one).
+	 * Dismisses all of the current user's auto-drafts (other than the present one).
 	 *
 	 * @since 4.9.0
 	 * @return int The number of auto-drafts that were dismissed.
@@ -1077,7 +1077,7 @@
 	}
 
 	/**
-	 * Get the changeset post ID for the loaded changeset.
+	 * Gets the changeset post ID for the loaded changeset.
 	 *
 	 * @since 4.7.0
 	 *
@@ -1098,7 +1098,7 @@
 	}
 
 	/**
-	 * Get the data stored in a changeset post.
+	 * Gets the data stored in a changeset post.
 	 *
 	 * @since 4.7.0
 	 *
@@ -1132,7 +1132,7 @@
 	}
 
 	/**
-	 * Get changeset data.
+	 * Gets changeset data.
 	 *
 	 * @since 4.7.0
 	 * @since 4.9.0 This will return the changeset's data with a user's autosave revision merged on top, if one exists and $autosaved is true.
@@ -1179,13 +1179,13 @@
 	protected $pending_starter_content_settings_ids = array();
 
 	/**
-	 * Import theme starter content into the customized state.
+	 * Imports theme starter content into the customized state.
 	 *
 	 * @since 4.7.0
 	 *
 	 * @param array $starter_content Starter content. Defaults to `get_theme_starter_content()`.
 	 */
-	function import_theme_starter_content( $starter_content = array() ) {
+	public function import_theme_starter_content( $starter_content = array() ) {
 		if ( empty( $starter_content ) ) {
 			$starter_content = get_theme_starter_content();
 		}
@@ -1632,7 +1632,7 @@
 	}
 
 	/**
-	 * Prepare starter content attachments.
+	 * Prepares starter content attachments.
 	 *
 	 * Ensure that the attachments are valid and that they have slugs and file name/path.
 	 *
@@ -1694,7 +1694,7 @@
 	}
 
 	/**
-	 * Save starter content changeset.
+	 * Saves starter content changeset.
 	 *
 	 * @since 4.7.0
 	 */
@@ -1716,7 +1716,7 @@
 	}
 
 	/**
-	 * Get dirty pre-sanitized setting values in the current customized state.
+	 * Gets dirty pre-sanitized setting values in the current customized state.
 	 *
 	 * The returned array consists of a merge of three sources:
 	 * 1. If the theme is not currently active, then the base array is any stashed
@@ -1769,7 +1769,7 @@
 				}
 				if ( isset( $setting_params['type'] ) && 'theme_mod' === $setting_params['type'] ) {
 
-					// Ensure that theme mods values are only used if they were saved under the current theme.
+					// Ensure that theme mods values are only used if they were saved under the active theme.
 					$namespace_pattern = '/^(?P<stylesheet>.+?)::(?P<setting_id>.+)$/';
 					if ( preg_match( $namespace_pattern, $setting_id, $matches ) && $this->get_stylesheet() === $matches['stylesheet'] ) {
 						$values[ $matches['setting_id'] ] = $setting_params['value'];
@@ -1806,37 +1806,40 @@
 	 * from the current changeset post and from the incoming post data.
 	 *
 	 * @since 3.4.0
-	 * @since 4.1.1 Introduced the `$default` parameter.
-	 * @since 4.6.0 `$default` is now returned early when the setting post value is invalid.
+	 * @since 4.1.1 Introduced the `$default_value` parameter.
+	 * @since 4.6.0 `$default_value` is now returned early when the setting post value is invalid.
 	 *
 	 * @see WP_REST_Server::dispatch()
 	 * @see WP_REST_Request::sanitize_params()
 	 * @see WP_REST_Request::has_valid_params()
 	 *
-	 * @param WP_Customize_Setting $setting A WP_Customize_Setting derived object.
-	 * @param mixed                $default Value returned $setting has no post value (added in 4.2.0)
-	 *                                      or the post value is invalid (added in 4.6.0).
-	 * @return string|mixed Sanitized value or the $default provided.
+	 * @param WP_Customize_Setting $setting       A WP_Customize_Setting derived object.
+	 * @param mixed                $default_value Value returned if `$setting` has no post value (added in 4.2.0)
+	 *                                            or the post value is invalid (added in 4.6.0).
+	 * @return string|mixed Sanitized value or the `$default_value` provided.
 	 */
-	public function post_value( $setting, $default = null ) {
+	public function post_value( $setting, $default_value = null ) {
 		$post_values = $this->unsanitized_post_values();
 		if ( ! array_key_exists( $setting->id, $post_values ) ) {
-			return $default;
-		}
+			return $default_value;
+		}
+
 		$value = $post_values[ $setting->id ];
 		$valid = $setting->validate( $value );
 		if ( is_wp_error( $valid ) ) {
-			return $default;
-		}
+			return $default_value;
+		}
+
 		$value = $setting->sanitize( $value );
 		if ( is_null( $value ) || is_wp_error( $value ) ) {
-			return $default;
-		}
+			return $default_value;
+		}
+
 		return $value;
 	}
 
 	/**
-	 * Override a setting's value in the current customized state.
+	 * Overrides a setting's value in the current customized state.
 	 *
 	 * The name "post_value" is a carry-over from when the customized state was
 	 * exclusively sourced from `$_POST['customized']`.
@@ -1851,7 +1854,7 @@
 		$this->_post_values[ $setting_id ] = $value;
 
 		/**
-		 * Announce when a specific setting's unsanitized post value has been set.
+		 * Announces when a specific setting's unsanitized post value has been set.
 		 *
 		 * Fires when the WP_Customize_Manager::set_post_value() method is called.
 		 *
@@ -1859,13 +1862,13 @@
 		 *
 		 * @since 4.4.0
 		 *
-		 * @param mixed                $value Unsanitized setting post value.
-		 * @param WP_Customize_Manager $this  WP_Customize_Manager instance.
+		 * @param mixed                $value   Unsanitized setting post value.
+		 * @param WP_Customize_Manager $manager WP_Customize_Manager instance.
 		 */
 		do_action( "customize_post_value_set_{$setting_id}", $value, $this );
 
 		/**
-		 * Announce when any setting's unsanitized post value has been set.
+		 * Announces when any setting's unsanitized post value has been set.
 		 *
 		 * Fires when the WP_Customize_Manager::set_post_value() method is called.
 		 *
@@ -1876,13 +1879,13 @@
 		 *
 		 * @param string               $setting_id Setting ID.
 		 * @param mixed                $value      Unsanitized setting post value.
-		 * @param WP_Customize_Manager $this       WP_Customize_Manager instance.
+		 * @param WP_Customize_Manager $manager    WP_Customize_Manager instance.
 		 */
 		do_action( 'customize_post_value_set', $setting_id, $value, $this );
 	}
 
 	/**
-	 * Print JavaScript settings.
+	 * Prints JavaScript settings.
 	 *
 	 * @since 3.4.0
 	 */
@@ -1937,7 +1940,7 @@
 		 *
 		 * @since 3.4.0
 		 *
-		 * @param WP_Customize_Manager $this WP_Customize_Manager instance.
+		 * @param WP_Customize_Manager $manager WP_Customize_Manager instance.
 		 */
 		do_action( 'customize_preview_init', $this );
 	}
@@ -1957,7 +1960,7 @@
 	}
 
 	/**
-	 * Add customize state query params to a given URL if preview is allowed.
+	 * Adds customize state query params to a given URL if preview is allowed.
 	 *
 	 * @since 4.7.0
 	 *
@@ -2001,7 +2004,7 @@
 	}
 
 	/**
-	 * Prevent sending a 404 status when returning the response for the customize
+	 * Prevents sending a 404 status when returning the response for the customize
 	 * preview, since it causes the jQuery Ajax to fail. Send 200 instead.
 	 *
 	 * @since 4.0.0
@@ -2012,7 +2015,7 @@
 	}
 
 	/**
-	 * Print base element for preview frame.
+	 * Prints base element for preview frame.
 	 *
 	 * @since 3.4.0
 	 * @deprecated 4.7.0
@@ -2022,7 +2025,7 @@
 	}
 
 	/**
-	 * Print a workaround to handle HTML5 tags in IE < 9.
+	 * Prints a workaround to handle HTML5 tags in IE < 9.
 	 *
 	 * @since 3.4.0
 	 * @deprecated 4.7.0 Customizer no longer supports IE8, so all supported browsers recognize HTML5.
@@ -2032,7 +2035,7 @@
 	}
 
 	/**
-	 * Print CSS for loading indicators for the Customizer preview.
+	 * Prints CSS for loading indicators for the Customizer preview.
 	 *
 	 * @since 4.2.0
 	 */
@@ -2061,7 +2064,7 @@
 	}
 
 	/**
-	 * Remove customize_messenger_channel query parameter from the preview window when it is not in an iframe.
+	 * Removes customize_messenger_channel query parameter from the preview window when it is not in an iframe.
 	 *
 	 * This ensures that the admin bar will be shown. It also ensures that link navigation will
 	 * work as expected since the parent frame is not being sent the URL to navigate to.
@@ -2098,7 +2101,7 @@
 	}
 
 	/**
-	 * Print JavaScript settings for preview frame.
+	 * Prints JavaScript settings for preview frame.
 	 *
 	 * @since 3.4.0
 	 */
@@ -2232,17 +2235,18 @@
 	 * @since 3.4.0
 	 * @deprecated 4.7.0
 	 *
-	 * @param mixed $return Value passed through for {@see 'wp_die_handler'} filter.
-	 * @return mixed Value passed through for {@see 'wp_die_handler'} filter.
+	 * @param callable|null $callback Optional. Value passed through for {@see 'wp_die_handler'} filter.
+	 *                                Default null.
+	 * @return callable|null Value passed through for {@see 'wp_die_handler'} filter.
 	 */
-	public function remove_preview_signature( $return = null ) {
+	public function remove_preview_signature( $callback = null ) {
 		_deprecated_function( __METHOD__, '4.7.0' );
 
-		return $return;
+		return $callback;
 	}
 
 	/**
-	 * Is it a theme preview?
+	 * Determines whether it is a theme preview or not.
 	 *
 	 * @since 3.4.0
 	 *
@@ -2253,7 +2257,7 @@
 	}
 
 	/**
-	 * Retrieve the template name of the previewed theme.
+	 * Retrieves the template name of the previewed theme.
 	 *
 	 * @since 3.4.0
 	 *
@@ -2264,7 +2268,7 @@
 	}
 
 	/**
-	 * Retrieve the stylesheet name of the previewed theme.
+	 * Retrieves the stylesheet name of the previewed theme.
 	 *
 	 * @since 3.4.0
 	 *
@@ -2275,7 +2279,7 @@
 	}
 
 	/**
-	 * Retrieve the template root of the previewed theme.
+	 * Retrieves the template root of the previewed theme.
 	 *
 	 * @since 3.4.0
 	 *
@@ -2286,7 +2290,7 @@
 	}
 
 	/**
-	 * Retrieve the stylesheet root of the previewed theme.
+	 * Retrieves the stylesheet root of the previewed theme.
 	 *
 	 * @since 3.4.0
 	 *
@@ -2297,7 +2301,7 @@
 	}
 
 	/**
-	 * Filters the current theme and return the name of the previewed theme.
+	 * Filters the active theme and return the name of the previewed theme.
 	 *
 	 * @since 3.4.0
 	 *
@@ -2408,7 +2412,7 @@
 	}
 
 	/**
-	 * Handle customize_save WP Ajax request to save/update a changeset.
+	 * Handles customize_save WP Ajax request to save/update a changeset.
 	 *
 	 * @since 3.4.0
 	 * @since 4.7.0 The semantics of this method have changed to update a changeset, optionally to also change the status and other attributes.
@@ -2592,7 +2596,7 @@
 		 *
 		 * @param array                $response Additional information passed back to the 'saved'
 		 *                                       event on `wp.customize`.
-		 * @param WP_Customize_Manager $this     WP_Customize_Manager instance.
+		 * @param WP_Customize_Manager $manager  WP_Customize_Manager instance.
 		 */
 		$response = apply_filters( 'customize_save_response', $response, $this );
 
@@ -2604,7 +2608,7 @@
 	}
 
 	/**
-	 * Save the post for the loaded changeset.
+	 * Saves the post for the loaded changeset.
 	 *
 	 * @since 4.7.0
 	 *
@@ -2622,7 +2626,7 @@
 	 *
 	 * @return array|WP_Error Returns array on success and WP_Error with array data on error.
 	 */
-	function save_changeset_post( $args = array() ) {
+	public function save_changeset_post( $args = array() ) {
 
 		$args = array_merge(
 			array(
@@ -2760,7 +2764,7 @@
 		 *
 		 * @since 4.6.0
 		 *
-		 * @param WP_Customize_Manager $this WP_Customize_Manager instance.
+		 * @param WP_Customize_Manager $manager WP_Customize_Manager instance.
 		 */
 		do_action( 'customize_save_validation_before', $this );
 
@@ -2992,7 +2996,7 @@
 	}
 
 	/**
-	 * Preserve the initial JSON post_content passed to save into the post.
+	 * Preserves the initial JSON post_content passed to save into the post.
 	 *
 	 * This is needed to prevent KSES and other {@see 'content_save_pre'} filters
 	 * from corrupting JSON data.
@@ -3037,7 +3041,7 @@
 	}
 
 	/**
-	 * Trash or delete a changeset post.
+	 * Trashes or deletes a changeset post.
 	 *
 	 * The following re-formulates the logic from `wp_trash_post()` as done in
 	 * `wp_publish_post()`. The reason for bypassing `wp_trash_post()` is that it
@@ -3116,7 +3120,7 @@
 	}
 
 	/**
-	 * Handle request to trash a changeset.
+	 * Handles request to trash a changeset.
 	 *
 	 * @since 4.9.0
 	 */
@@ -3201,7 +3205,7 @@
 	}
 
 	/**
-	 * Re-map 'edit_post' meta cap for a customize_changeset post to be the same as 'customize' maps.
+	 * Re-maps 'edit_post' meta cap for a customize_changeset post to be the same as 'customize' maps.
 	 *
 	 * There is essentially a "meta meta" cap in play here, where 'edit_post' meta cap maps to
 	 * the 'customize' meta cap which then maps to 'edit_theme_options'. This is currently
@@ -3266,6 +3270,7 @@
 		if ( ! $changeset_post_id ) {
 			return;
 		}
+
 		$lock = get_post_meta( $changeset_post_id, '_edit_lock', true );
 		$lock = explode( ':', $lock );
 
@@ -3283,19 +3288,24 @@
 	 * Filters heartbeat settings for the Customizer.
 	 *
 	 * @since 4.9.0
+	 *
+	 * @global string $pagenow The filename of the current screen.
+	 *
 	 * @param array $settings Current settings to filter.
 	 * @return array Heartbeat settings.
 	 */
 	public function add_customize_screen_to_heartbeat_settings( $settings ) {
 		global $pagenow;
+
 		if ( 'customize.php' === $pagenow ) {
 			$settings['screenId'] = 'customize';
 		}
+
 		return $settings;
 	}
 
 	/**
-	 * Get lock user data.
+	 * Gets lock user data.
 	 *
 	 * @since 4.9.0
 	 *
@@ -3306,10 +3316,13 @@
 		if ( ! $user_id ) {
 			return null;
 		}
+
 		$lock_user = get_userdata( $user_id );
+
 		if ( ! $lock_user ) {
 			return null;
 		}
+
 		return array(
 			'id'     => $lock_user->ID,
 			'name'   => $lock_user->display_name,
@@ -3318,7 +3331,7 @@
 	}
 
 	/**
-	 * Check locked changeset with heartbeat API.
+	 * Checks locked changeset with heartbeat API.
 	 *
 	 * @since 4.9.0
 	 *
@@ -3399,7 +3412,7 @@
 	}
 
 	/**
-	 * Whether a changeset revision should be made.
+	 * Determines whether a changeset revision should be made.
 	 *
 	 * @since 4.7.0
 	 * @var bool
@@ -3427,9 +3440,9 @@
 	}
 
 	/**
-	 * Publish changeset values.
-	 *
-	 * This will the values contained in a changeset, even changesets that do not
+	 * Publishes the values of a changeset.
+	 *
+	 * This will publish the values contained in a changeset, even changesets that do not
 	 * correspond to current manager instance. This is called by
 	 * `_wp_customize_publish_changeset()` when a customize_changeset post is
 	 * transitioned to the `publish` status. As such, this method should not be
@@ -3617,7 +3630,7 @@
 	}
 
 	/**
-	 * Update stashed theme mod settings.
+	 * Updates stashed theme mod settings.
 	 *
 	 * @since 4.7.0
 	 *
@@ -3654,7 +3667,7 @@
 	}
 
 	/**
-	 * Refresh nonces for the current preview.
+	 * Refreshes nonces for the current preview.
 	 *
 	 * @since 4.2.0
 	 */
@@ -3667,7 +3680,7 @@
 	}
 
 	/**
-	 * Delete a given auto-draft changeset or the autosave revision for a given changeset or delete changeset lock.
+	 * Deletes a given auto-draft changeset or the autosave revision for a given changeset or delete changeset lock.
 	 *
 	 * @since 4.9.0
 	 */
@@ -3735,7 +3748,7 @@
 	}
 
 	/**
-	 * Add a customize setting.
+	 * Adds a customize setting.
 	 *
 	 * @since 3.4.0
 	 * @since 4.5.0 Return added WP_Customize_Setting instance.
@@ -3769,7 +3782,7 @@
 	}
 
 	/**
-	 * Register any dynamically-created settings, such as those from $_POST['customized']
+	 * Registers any dynamically-created settings, such as those from $_POST['customized']
 	 * that have no corresponding setting created.
 	 *
 	 * This is a mechanism to "wake up" settings that have been dynamically created
@@ -3830,7 +3843,7 @@
 	}
 
 	/**
-	 * Retrieve a customize setting.
+	 * Retrieves a customize setting.
 	 *
 	 * @since 3.4.0
 	 *
@@ -3844,7 +3857,7 @@
 	}
 
 	/**
-	 * Remove a customize setting.
+	 * Removes a customize setting.
 	 *
 	 * Note that removing the setting doesn't destroy the WP_Customize_Setting instance or remove its filters.
 	 *
@@ -3857,7 +3870,7 @@
 	}
 
 	/**
-	 * Add a customize panel.
+	 * Adds a customize panel.
 	 *
 	 * @since 4.0.0
 	 * @since 4.5.0 Return added WP_Customize_Panel instance.
@@ -3882,7 +3895,7 @@
 	}
 
 	/**
-	 * Retrieve a customize panel.
+	 * Retrieves a customize panel.
 	 *
 	 * @since 4.0.0
 	 *
@@ -3896,7 +3909,7 @@
 	}
 
 	/**
-	 * Remove a customize panel.
+	 * Removes a customize panel.
 	 *
 	 * Note that removing the panel doesn't destroy the WP_Customize_Panel instance or remove its filters.
 	 *
@@ -3926,7 +3939,7 @@
 	}
 
 	/**
-	 * Register a customize panel type.
+	 * Registers a customize panel type.
 	 *
 	 * Registered types are eligible to be rendered via JS and created dynamically.
 	 *
@@ -3941,7 +3954,7 @@
 	}
 
 	/**
-	 * Render JS templates for all registered panel types.
+	 * Renders JS templates for all registered panel types.
 	 *
 	 * @since 4.3.0
 	 */
@@ -3953,7 +3966,7 @@
 	}
 
 	/**
-	 * Add a customize section.
+	 * Adds a customize section.
 	 *
 	 * @since 3.4.0
 	 * @since 4.5.0 Return added WP_Customize_Section instance.
@@ -3978,7 +3991,7 @@
 	}
 
 	/**
-	 * Retrieve a customize section.
+	 * Retrieves a customize section.
 	 *
 	 * @since 3.4.0
 	 *
@@ -3992,7 +4005,7 @@
 	}
 
 	/**
-	 * Remove a customize section.
+	 * Removes a customize section.
 	 *
 	 * Note that removing the section doesn't destroy the WP_Customize_Section instance or remove its filters.
 	 *
@@ -4005,7 +4018,7 @@
 	}
 
 	/**
-	 * Register a customize section type.
+	 * Registers a customize section type.
 	 *
 	 * Registered types are eligible to be rendered via JS and created dynamically.
 	 *
@@ -4020,7 +4033,7 @@
 	}
 
 	/**
-	 * Render JS templates for all registered section types.
+	 * Renders JS templates for all registered section types.
 	 *
 	 * @since 4.3.0
 	 */
@@ -4032,7 +4045,7 @@
 	}
 
 	/**
-	 * Add a customize control.
+	 * Adds a customize control.
 	 *
 	 * @since 3.4.0
 	 * @since 4.5.0 Return added WP_Customize_Control instance.
@@ -4057,7 +4070,7 @@
 	}
 
 	/**
-	 * Retrieve a customize control.
+	 * Retrieves a customize control.
 	 *
 	 * @since 3.4.0
 	 *
@@ -4071,7 +4084,7 @@
 	}
 
 	/**
-	 * Remove a customize control.
+	 * Removes a customize control.
 	 *
 	 * Note that removing the control doesn't destroy the WP_Customize_Control instance or remove its filters.
 	 *
@@ -4084,7 +4097,7 @@
 	}
 
 	/**
-	 * Register a customize control type.
+	 * Registers a customize control type.
 	 *
 	 * Registered types are eligible to be rendered via JS and created dynamically.
 	 *
@@ -4098,7 +4111,7 @@
 	}
 
 	/**
-	 * Render JS templates for all registered control types.
+	 * Renders JS templates for all registered control types.
 	 *
 	 * @since 4.1.0
 	 */
@@ -4388,7 +4401,7 @@
 	}
 
 	/**
-	 * Prepare panels, sections, and controls.
+	 * Prepares panels, sections, and controls.
 	 *
 	 * For each, check if required related components exist,
 	 * whether the user has the necessary capabilities,
@@ -4500,7 +4513,7 @@
 	}
 
 	/**
-	 * Enqueue scripts for customize controls.
+	 * Enqueues scripts for customize controls.
 	 *
 	 * @since 3.4.0
 	 */
@@ -4522,7 +4535,7 @@
 	}
 
 	/**
-	 * Determine whether the user agent is iOS.
+	 * Determines whether the user agent is iOS.
 	 *
 	 * @since 4.4.0
 	 *
@@ -4533,7 +4546,7 @@
 	}
 
 	/**
-	 * Get the template string for the Customizer pane document title.
+	 * Gets the template string for the Customizer pane document title.
 	 *
 	 * @since 4.4.0
 	 *
@@ -4552,7 +4565,7 @@
 	}
 
 	/**
-	 * Set the initial URL to be previewed.
+	 * Sets the initial URL to be previewed.
 	 *
 	 * URL is validated.
 	 *
@@ -4566,7 +4579,7 @@
 	}
 
 	/**
-	 * Get the initial URL to be previewed.
+	 * Gets the initial URL to be previewed.
 	 *
 	 * @since 4.4.0
 	 *
@@ -4596,7 +4609,7 @@
 	}
 
 	/**
-	 * Get URLs allowed to be previewed.
+	 * Gets URLs allowed to be previewed.
 	 *
 	 * If the front end and the admin are served from the same domain, load the
 	 * preview over ssl if the Customizer is being loaded over ssl. This avoids
@@ -4629,7 +4642,7 @@
 	}
 
 	/**
-	 * Get messenger channel.
+	 * Gets messenger channel.
 	 *
 	 * @since 4.7.0
 	 *
@@ -4640,7 +4653,7 @@
 	}
 
 	/**
-	 * Set URL to link the user to when closing the Customizer.
+	 * Sets URL to link the user to when closing the Customizer.
 	 *
 	 * URL is validated.
 	 *
@@ -4656,7 +4669,7 @@
 	}
 
 	/**
-	 * Get URL to link the user to when closing the Customizer.
+	 * Gets URL to link the user to when closing the Customizer.
 	 *
 	 * @since 4.4.0
 	 *
@@ -4688,7 +4701,7 @@
 
 			/*
 			 * If the return URL is a page added by a theme to the Appearance menu via add_submenu_page(),
-			 * verify that belongs to the active theme, otherwise fall back to the Themes screen.
+			 * verify that it belongs to the active theme, otherwise fall back to the Themes screen.
 			 */
 			if ( isset( $query_vars['page'] ) && ! isset( $_registered_pages[ "appearance_page_{$query_vars['page']}" ] ) ) {
 				$return_url = admin_url( 'themes.php' );
@@ -4699,7 +4712,7 @@
 	}
 
 	/**
-	 * Set the autofocused constructs.
+	 * Sets the autofocused constructs.
 	 *
 	 * @since 4.4.0
 	 *
@@ -4716,11 +4729,11 @@
 	}
 
 	/**
-	 * Get the autofocused constructs.
+	 * Gets the autofocused constructs.
 	 *
 	 * @since 4.4.0
 	 *
-	 * @return array {
+	 * @return string[] {
 	 *     Mapping of 'panel', 'section', 'control' to the ID which should be autofocused.
 	 *
 	 *     @type string $control ID for control to be autofocused.
@@ -4733,7 +4746,7 @@
 	}
 
 	/**
-	 * Get nonces for the Customizer.
+	 * Gets nonces for the Customizer.
 	 *
 	 * @since 4.5.0
 	 *
@@ -4754,9 +4767,9 @@
 		 *
 		 * @since 4.2.0
 		 *
-		 * @param string[]             $nonces Array of refreshed nonces for save and
-		 *                                     preview actions.
-		 * @param WP_Customize_Manager $this   WP_Customize_Manager instance.
+		 * @param string[]             $nonces  Array of refreshed nonces for save and
+		 *                                      preview actions.
+		 * @param WP_Customize_Manager $manager WP_Customize_Manager instance.
 		 */
 		$nonces = apply_filters( 'customize_refresh_nonces', $nonces, $this );
 
@@ -4764,7 +4777,7 @@
 	}
 
 	/**
-	 * Print JavaScript settings for parent window.
+	 * Prints JavaScript settings for parent window.
 	 *
 	 * @since 4.4.0
 	 */
@@ -5014,7 +5027,7 @@
 	}
 
 	/**
-	 * Register some default controls.
+	 * Registers some default controls.
 	 *
 	 * @since 3.4.0
 	 */
@@ -5732,7 +5745,7 @@
 	}
 
 	/**
-	 * Return whether there are published pages.
+	 * Returns whether there are published pages.
 	 *
 	 * Used as active callback for static front page section and controls.
 	 *
@@ -5750,11 +5763,11 @@
 				}
 			}
 		}
-		return 0 !== count( get_pages() );
+		return 0 !== count( get_pages( array( 'number' => 1 ) ) );
 	}
 
 	/**
-	 * Add settings from the POST data that were not added with code, e.g. dynamically-created settings for Widgets
+	 * Adds settings from the POST data that were not added with code, e.g. dynamically-created settings for Widgets
 	 *
 	 * @since 4.2.0
 	 *
@@ -5766,7 +5779,7 @@
 	}
 
 	/**
-	 * Load themes into the theme browsing/installation UI.
+	 * Loads themes into the theme browsing/installation UI.
 	 *
 	 * @since 4.9.0
 	 */
@@ -5808,10 +5821,11 @@
 		if ( 'installed' === $theme_action ) {
 
 			// Load all installed themes from wp_prepare_themes_for_js().
-			$themes = array( 'themes' => wp_prepare_themes_for_js() );
-			foreach ( $themes['themes'] as &$theme ) {
-				$theme['type']   = 'installed';
-				$theme['active'] = ( isset( $_POST['customized_theme'] ) && $_POST['customized_theme'] === $theme['id'] );
+			$themes = array( 'themes' => array() );
+			foreach ( wp_prepare_themes_for_js() as $theme ) {
+				$theme['type']      = 'installed';
+				$theme['active']    = ( isset( $_POST['customized_theme'] ) && $_POST['customized_theme'] === $theme['id'] );
+				$themes['themes'][] = $theme;
 			}
 		} elseif ( 'wporg' === $theme_action ) {
 
@@ -5923,7 +5937,7 @@
 		 * @see themes_api()
 		 * @see WP_Customize_Manager::__construct()
 		 *
-		 * @param array                $themes  Nested array of theme data.
+		 * @param array|stdClass       $themes  Nested array or object of theme data.
 		 * @param array                $args    List of arguments, such as page, search term, and tags to query for.
 		 * @param WP_Customize_Manager $manager Instance of Customize manager.
 		 */
@@ -6000,7 +6014,7 @@
 	}
 
 	/**
-	 * Export header video settings to facilitate selective refresh.
+	 * Exports header video settings to facilitate selective refresh.
 	 *
 	 * @since 4.7.0
 	 *