Skip to content

Commit

Permalink
Merge pull request #1334 from aristath/refactor/postmessage
Browse files Browse the repository at this point in the history
see #1333
  • Loading branch information
aristath authored May 27, 2017
2 parents 6cbd2de + 217c207 commit 94cfba7
Show file tree
Hide file tree
Showing 7 changed files with 367 additions and 284 deletions.
8 changes: 4 additions & 4 deletions controls/typography/class-kirki-control-typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ protected function get_standard_fonts() {
// Add fonts to our JS objects.
$standard_fonts = Kirki_Fonts::get_standard_fonts();

$standardfonts_user_keys = $this->choices['fonts']['standard'];
$std_user_keys = $this->choices['fonts']['standard'];

$standard_fonts_final = array();
$default_variants = $this->format_variants_array( array(
Expand All @@ -392,7 +392,7 @@ protected function get_standard_fonts() {
'700italic',
) );
foreach ( $standard_fonts as $key => $font ) {
if ( ! empty( $standardfonts_user_keys ) && ! in_array( $key, $standardfonts_user_keys, true ) ) {
if ( ! empty( $std_user_keys ) && ! in_array( $key, $std_user_keys, true ) ) {
continue;
}
$standard_fonts_final[] = array(
Expand All @@ -419,11 +419,11 @@ protected function get_google_fonts() {
$all_variants = Kirki_Fonts::get_all_variants();
$all_subsets = Kirki_Fonts::get_google_font_subsets();

$googlefonts_user_keys = $this->choices['fonts']['google'];
$gf_user_keys = $this->choices['fonts']['google'];

$google_fonts_final = array();
foreach ( $google_fonts as $family => $args ) {
if ( ! empty( $googlefonts_user_keys ) && ! in_array( $family, $googlefonts_user_keys, true ) ) {
if ( ! empty( $gf_user_keys ) && ! in_array( $family, $gf_user_keys, true ) ) {
continue;
}

Expand Down
9 changes: 3 additions & 6 deletions core/class-kirki-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ protected function set_js_vars() {

// Start going through each item in the $output array.
foreach ( $this->output as $output ) {
$output['function'] = 'css';
$output['function'] = ( isset( $output['function'] ) ) ? $output['function'] : 'style';

// If 'element' or 'property' are not defined, skip this.
if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) {
Expand All @@ -766,12 +766,9 @@ protected function set_js_vars() {
if ( is_array( $output['element'] ) ) {
$output['element'] = implode( ',', $output['element'] );
}
if ( false !== strpos( $output['element'], ':' ) ) {
$output['function'] = 'style';
}

// If there's a sanitize_callback defined, skip this.
if ( isset( $output['sanitize_callback'] ) && ! empty( $output['sanitize_callback'] ) ) {
// If there's a sanitize_callback defined skip this, unless we also have a js_callback defined.
if ( isset( $output['sanitize_callback'] ) && ! empty( $output['sanitize_callback'] ) && ( ! isset( $output['js_callback'] ) || empty( $output['js_callback'] ) ) ) {
continue;
}

Expand Down
1 change: 0 additions & 1 deletion core/class-kirki-setting-user-meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ protected function set_root_value( $value ) {
* @return bool The result of saving the value.
*/
protected function update( $value ) {
$id_base = $this->id_data['base'];
return $this->set_root_value( $value );
}

Expand Down
4 changes: 0 additions & 4 deletions field/class-kirki-field-background.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ protected function set_js_vars() {

// Start going through each item in the $output array.
foreach ( $this->output as $output ) {
$output['function'] = 'css';

// If 'element' is not defined, skip this.
if ( ! isset( $output['element'] ) ) {
Expand All @@ -100,9 +99,6 @@ protected function set_js_vars() {
if ( is_array( $output['element'] ) ) {
$output['element'] = implode( ',', $output['element'] );
}
if ( false !== strpos( $output['element'], ':' ) ) {
$output['function'] = 'style';
}

// If there's a sanitize_callback defined, skip this.
if ( isset( $output['sanitize_callback'] ) && ! empty( $output['sanitize_callback'] ) ) {
Expand Down
4 changes: 0 additions & 4 deletions field/class-kirki-field-typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ protected function set_js_vars() {

// Start going through each item in the $output array.
foreach ( $this->output as $output ) {
$output['function'] = 'css';

// If 'element' or 'property' are not defined, skip this.
if ( ! isset( $output['element'] ) ) {
Expand All @@ -79,9 +78,6 @@ protected function set_js_vars() {
if ( is_array( $output['element'] ) ) {
$output['element'] = implode( ',', $output['element'] );
}
if ( false !== strpos( $output['element'], ':' ) ) {
$output['function'] = 'style';
}

// If we got this far, it's safe to add this.
$js_vars[] = $output;
Expand Down
Loading

0 comments on commit 94cfba7

Please sign in to comment.