From 7f10ff07d6fc916a2e5a415f0308206db9156e86 Mon Sep 17 00:00:00 2001 From: Aristeides Stathopoulos Date: Thu, 5 Oct 2017 20:42:36 +0300 Subject: [PATCH] fixes #1521, #1560 --- .../class-kirki-control-typography.php | 18 +++++++++++++++--- controls/typography/typography.js | 2 +- field/class-kirki-field-typography.php | 15 --------------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/controls/typography/class-kirki-control-typography.php b/controls/typography/class-kirki-control-typography.php index 5235c444f..3d03c869a 100644 --- a/controls/typography/class-kirki-control-typography.php +++ b/controls/typography/class-kirki-control-typography.php @@ -136,7 +136,10 @@ public function to_json() { $this->json['default'] = $this->default; } $this->json['output'] = $this->output; - $this->json['value'] = Kirki_Field_Typography::sanitize( $this->value() ); + $this->json['value'] = wp_parse_args( + Kirki_Field_Typography::sanitize( $this->value() ), + $this->json['default'] + ); $this->json['choices'] = $this->choices; $this->json['link'] = $this->get_link(); $this->json['id'] = $this->id; @@ -183,7 +186,7 @@ protected function content_template() {
<# if ( data.default['font-family'] ) { #> - <# if ( '' == data.value['font-family'] ) { data.value['font-family'] = data.default['font-family']; } #> + <# data.value['font-family'] = data.value['font-family'] || data['default']['font-family']; #> <# if ( data.choices['fonts'] ) { data.fonts = data.choices['fonts']; } #>
@@ -214,6 +217,7 @@ protected function content_template() { <# } #> <# if ( data.default['font-size'] ) { #> + <# data.value['font-size'] = data.value['font-size'] || data['default']['font-size']; #>
@@ -221,6 +225,7 @@ protected function content_template() { <# } #> <# if ( data.default['line-height'] ) { #> + <# data.value['line-height'] = data.value['line-height'] || data['default']['line-height']; #>
@@ -228,6 +233,7 @@ protected function content_template() { <# } #> <# if ( data.default['letter-spacing'] ) { #> + <# data.value['letter-spacing'] = data.value['letter-spacing'] || data['default']['letter-spacing']; #>
@@ -235,6 +241,7 @@ protected function content_template() { <# } #> <# if ( data.default['word-spacing'] ) { #> + <# data.value['word-spacing'] = data.value['word-spacing'] || data['default']['word-spacing']; #>
@@ -242,6 +249,7 @@ protected function content_template() { <# } #> <# if ( data.default['text-align'] ) { #> + <# data.value['text-align'] = data.value['text-align'] || data['default']['text-align']; #>
checked="checked"<# } #>> @@ -278,6 +286,7 @@ protected function content_template() { <# } #> <# if ( data.default['text-transform'] ) { #> + <# data.value['text-transform'] = data.value['text-transform'] || data['default']['text-transform']; #>
+
<# } #> <# if ( data.default['margin-top'] ) { #> + <# data.value['margin-top'] = data.value['margin-top'] || data['default']['margin-top']; #>
@@ -306,6 +317,7 @@ protected function content_template() { <# } #> <# if ( data.default['margin-bottom'] ) { #> + <# data.value['margin-bottom'] = data.value['margin-bottom'] || data['default']['margin-bottom']; #>
diff --git a/controls/typography/typography.js b/controls/typography/typography.js index 11e0a8711..c3bc2ad6b 100644 --- a/controls/typography/typography.js +++ b/controls/typography/typography.js @@ -414,7 +414,7 @@ wp.customize.controlConstructor['kirki-typography'] = wp.customize.Control.exten valueObj = JSON.parse( valueJSON ); valueObj[ property ] = value; + wp.customize.control( control.id ).setting.set( valueObj ); jQuery( input ).attr( 'value', JSON.stringify( valueObj ) ).trigger( 'change' ); - control.setting.set( valueObj ); } }); diff --git a/field/class-kirki-field-typography.php b/field/class-kirki-field-typography.php index b52614371..0b9c6a707 100644 --- a/field/class-kirki-field-typography.php +++ b/field/class-kirki-field-typography.php @@ -25,15 +25,6 @@ protected function set_type() { } - /** - * Helper for the static sanitization. - * - * @static - * @since 3.0.10 - * @var array - */ - private static $static_default = array(); - /** * The class constructor. * Parses and sanitizes all field arguments. @@ -48,7 +39,6 @@ protected function set_type() { public function __construct( $config_id = 'global', $args = array() ) { parent::__construct( $config_id, $args ); $this->set_default(); - self::$static_default = $this->default; } /** @@ -223,11 +213,6 @@ public static function sanitize( $value ) { } // End switch(). } // End foreach(). - foreach ( array( 'font-size', 'letter-spacing', 'word-spacing', 'line-height', 'text-align', 'color' ) as $property ) { - if ( is_array( self::$static_default ) && ! isset( self::$static_default[ $property ] ) ) { - unset( $value[ $property ] ); - } - } return $value; }