+ public function validate( $value ) {
+ if ( is_wp_error( $value ) ) {
+ return $value;
+ }
+ if ( is_null( $value ) ) {
+ return new WP_Error( 'invalid_value', __( 'Invalid value.' ) );
+ }
+
+ $validity = new WP_Error();
+
+ /**
+ * Validates a Customize setting value.
+ *
+ * Plugins should amend the `$validity` object via its `WP_Error::add()` method.
+ *
+ * The dynamic portion of the hook name, `$this->ID`, refers to the setting ID.
+ *
+ * @since 4.6.0
+ *
+ * @param WP_Error $validity Filtered from `true` to `WP_Error` when invalid.
+ * @param mixed $value Value of the setting.
+ * @param WP_Customize_Setting $this WP_Customize_Setting instance.
+ */
+ $validity = apply_filters( "customize_validate_{$this->id}", $validity, $value, $this );
+
+ if ( is_wp_error( $validity ) && empty( $validity->errors ) ) {
+ $validity = true;
+ }
+ return $validity;
+ }
+
+ /**
+ * Get the root value for a setting, especially for multidimensional ones.
+ *
+ * @since 4.4.0
+ * @access protected
+ *
+ * @param mixed $default Value to return if root does not exist.
+ * @return mixed
+ */
+ protected function get_root_value( $default = null ) {
+ $id_base = $this->id_data['base'];
+ if ( 'option' === $this->type ) {
+ return get_option( $id_base, $default );
+ } else if ( 'theme_mod' ) {
+ return get_theme_mod( $id_base, $default );
+ } else {
+ /*
+ * Any WP_Customize_Setting subclass implementing aggregate multidimensional
+ * will need to override this method to obtain the data from the appropriate
+ * location.
+ */
+ return $default;
+ }
+ }
+
+ /**
+ * Set the root value for a setting, especially for multidimensional ones.
+ *
+ * @since 4.4.0
+ * @access protected
+ *
+ * @param mixed $value Value to set as root of multidimensional setting.
+ * @return bool Whether the multidimensional root was updated successfully.
+ */
+ protected function set_root_value( $value ) {
+ $id_base = $this->id_data['base'];
+ if ( 'option' === $this->type ) {
+ $autoload = true;
+ if ( isset( self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'] ) ) {
+ $autoload = self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'];
+ }
+ return update_option( $id_base, $value, $autoload );
+ } else if ( 'theme_mod' ) {
+ set_theme_mod( $id_base, $value );
+ return true;
+ } else {
+ /*
+ * Any WP_Customize_Setting subclass implementing aggregate multidimensional
+ * will need to override this method to obtain the data from the appropriate
+ * location.
+ */
+ return false;