@@ -49,13 +49,13 @@ discard block |
||
| 49 | 49 | protected function set_default() { |
| 50 | 50 | |
| 51 | 51 | // Accomodate the use of font-weight and convert to variant. |
| 52 | - if ( isset( $this->default['font-weight'] ) ) { |
|
| 53 | - $this->default['variant'] = ( 'regular' === $this->default['font-weight'] ) ? 400 : (string) intval( $this->default['font-weight'] ); |
|
| 52 | + if ( isset( $this->default[ 'font-weight' ] ) ) { |
|
| 53 | + $this->default[ 'variant' ] = ( 'regular' === $this->default[ 'font-weight' ] ) ? 400 : (string) intval( $this->default[ 'font-weight' ] ); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // Make sure letter-spacing has units. |
| 57 | - if ( isset( $this->default['letter-spacing'] ) && is_numeric( $this->default['letter-spacing'] ) && $this->default['letter-spacing'] ) { |
|
| 58 | - $this->default['letter-spacing'] .= 'px'; |
|
| 57 | + if ( isset( $this->default[ 'letter-spacing' ] ) && is_numeric( $this->default[ 'letter-spacing' ] ) && $this->default[ 'letter-spacing' ] ) { |
|
| 58 | + $this->default[ 'letter-spacing' ] .= 'px'; |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
@@ -106,15 +106,15 @@ discard block |
||
| 106 | 106 | foreach ( $this->output as $output ) { |
| 107 | 107 | |
| 108 | 108 | // If 'element' or 'property' are not defined, skip this. |
| 109 | - if ( ! isset( $output['element'] ) ) { |
|
| 109 | + if ( ! isset( $output[ 'element' ] ) ) { |
|
| 110 | 110 | continue; |
| 111 | 111 | } |
| 112 | - if ( is_array( $output['element'] ) ) { |
|
| 113 | - $output['element'] = implode( ',', $output['element'] ); |
|
| 112 | + if ( is_array( $output[ 'element' ] ) ) { |
|
| 113 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | // If we got this far, it's safe to add this. |
| 117 | - $js_vars[] = $output; |
|
| 117 | + $js_vars[ ] = $output; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // Did we manage to get all the items from 'output'? |
@@ -146,26 +146,26 @@ discard block |
||
| 146 | 146 | foreach ( $value as $key => $val ) { |
| 147 | 147 | switch ( $key ) { |
| 148 | 148 | case 'font-family': |
| 149 | - $value['font-family'] = esc_attr( $val ); |
|
| 149 | + $value[ 'font-family' ] = esc_attr( $val ); |
|
| 150 | 150 | break; |
| 151 | 151 | case 'font-weight': |
| 152 | - if ( isset( $value['variant'] ) ) { |
|
| 152 | + if ( isset( $value[ 'variant' ] ) ) { |
|
| 153 | 153 | break; |
| 154 | 154 | } |
| 155 | - $value['variant'] = $val; |
|
| 156 | - if ( isset( $value['font-style'] ) && 'italic' === $value['font-style'] ) { |
|
| 157 | - $value['variant'] = ( '400' !== $val || 400 !== $val ) ? $value['variant'] . 'italic' : 'italic'; |
|
| 155 | + $value[ 'variant' ] = $val; |
|
| 156 | + if ( isset( $value[ 'font-style' ] ) && 'italic' === $value[ 'font-style' ] ) { |
|
| 157 | + $value[ 'variant' ] = ( '400' !== $val || 400 !== $val ) ? $value[ 'variant' ] . 'italic' : 'italic'; |
|
| 158 | 158 | } |
| 159 | 159 | break; |
| 160 | 160 | case 'variant': |
| 161 | 161 | // Use 'regular' instead of 400 for font-variant. |
| 162 | - $value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; |
|
| 162 | + $value[ 'variant' ] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; |
|
| 163 | 163 | // Get font-weight from variant. |
| 164 | - $value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
| 165 | - $value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? 400 : absint( $value['font-weight'] ); |
|
| 164 | + $value[ 'font-weight' ] = filter_var( $value[ 'variant' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
| 165 | + $value[ 'font-weight' ] = ( 'regular' === $value[ 'variant' ] || 'italic' === $value[ 'variant' ] ) ? 400 : absint( $value[ 'font-weight' ] ); |
|
| 166 | 166 | // Get font-style from variant. |
| 167 | - if ( ! isset( $value['font-style'] ) ) { |
|
| 168 | - $value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic'; |
|
| 167 | + if ( ! isset( $value[ 'font-style' ] ) ) { |
|
| 168 | + $value[ 'font-style' ] = ( false === strpos( $value[ 'variant' ], 'italic' ) ) ? 'normal' : 'italic'; |
|
| 169 | 169 | } |
| 170 | 170 | break; |
| 171 | 171 | case 'font-size': |
@@ -176,21 +176,21 @@ discard block |
||
| 176 | 176 | break; |
| 177 | 177 | case 'text-align': |
| 178 | 178 | if ( ! in_array( $val, array( '', 'inherit', 'left', 'center', 'right', 'justify' ), true ) ) { |
| 179 | - $value['text-align'] = ''; |
|
| 179 | + $value[ 'text-align' ] = ''; |
|
| 180 | 180 | } |
| 181 | 181 | break; |
| 182 | 182 | case 'text-transform': |
| 183 | 183 | if ( ! in_array( $val, array( '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ), true ) ) { |
| 184 | - $value['text-transform'] = ''; |
|
| 184 | + $value[ 'text-transform' ] = ''; |
|
| 185 | 185 | } |
| 186 | 186 | break; |
| 187 | 187 | case 'text-decoration': |
| 188 | - if ( ! in_array( $val, array( ''. 'none', 'underline', 'overline', 'line-through', 'initial', 'inherit' ), true ) ) { |
|
| 189 | - $value['text-transform'] = ''; |
|
| 188 | + if ( ! in_array( $val, array( '' . 'none', 'underline', 'overline', 'line-through', 'initial', 'inherit' ), true ) ) { |
|
| 189 | + $value[ 'text-transform' ] = ''; |
|
| 190 | 190 | } |
| 191 | 191 | break; |
| 192 | 192 | case 'color': |
| 193 | - $value['color'] = '' === $value['color'] ? '' : ariColor::newColor( $val )->toCSS( 'hex' ); |
|
| 193 | + $value[ 'color' ] = '' === $value[ 'color' ] ? '' : ariColor::newColor( $val )->toCSS( 'hex' ); |
|
| 194 | 194 | break; |
| 195 | 195 | } // End switch(). |
| 196 | 196 | } // End foreach(). |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $fonts_to_load = $this->googlefonts->fonts; |
| 88 | 88 | |
| 89 | 89 | if ( ! empty( $fonts_to_load ) && 'preconnect' === $relation_type ) { |
| 90 | - $urls[] = array( |
|
| 90 | + $urls[ ] = array( |
|
| 91 | 91 | 'href' => 'https://fonts.gstatic.com', |
| 92 | 92 | 'crossorigin', |
| 93 | 93 | ); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $weights[ $key ] = str_replace( array( 'regular', 'bold', 'italic' ), array( '400', '', 'i' ), $value ); |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | - $this->fonts_to_load[] = $font . ':' . join( ',', $weights ) . ':cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai'; |
|
| 123 | + $this->fonts_to_load[ ] = $font . ':' . join( ',', $weights ) . ':cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai'; |
|
| 124 | 124 | } |
| 125 | 125 | if ( ! empty( $this->fonts_to_load ) ) { |
| 126 | 126 | Kirki_Modules_Webfont_Loader::$load = true; |
@@ -39,18 +39,18 @@ |
||
| 39 | 39 | |
| 40 | 40 | foreach ( array_keys( $value ) as $key ) { |
| 41 | 41 | |
| 42 | - $property = ( empty( $output['property'] ) ) ? $key : $output['property'] . '-' . $key; |
|
| 43 | - if ( isset( $output['choice'] ) && $output['property'] ) { |
|
| 44 | - if ( $key === $output['choice'] ) { |
|
| 45 | - $property = $output['property']; |
|
| 42 | + $property = ( empty( $output[ 'property' ] ) ) ? $key : $output[ 'property' ] . '-' . $key; |
|
| 43 | + if ( isset( $output[ 'choice' ] ) && $output[ 'property' ] ) { |
|
| 44 | + if ( $key === $output[ 'choice' ] ) { |
|
| 45 | + $property = $output[ 'property' ]; |
|
| 46 | 46 | } else { |
| 47 | 47 | continue; |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | - if ( false !== strpos( $output['property'], '%%' ) ) { |
|
| 51 | - $property = str_replace( '%%', $key, $output['property'] ); |
|
| 50 | + if ( false !== strpos( $output[ 'property' ], '%%' ) ) { |
|
| 51 | + $property = str_replace( '%%', $key, $output[ 'property' ] ); |
|
| 52 | 52 | } |
| 53 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $this->process_property_value( $property, $value[ $key ] ) . $output['suffix']; |
|
| 53 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $property ] = $output[ 'prefix' ] . $this->process_property_value( $property, $value[ $key ] ) . $output[ 'suffix' ]; |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -149,39 +149,39 @@ |
||
| 149 | 149 | // Get the basics from the parent class. |
| 150 | 150 | parent::to_json(); |
| 151 | 151 | // Default. |
| 152 | - $this->json['default'] = $this->setting->default; |
|
| 152 | + $this->json[ 'default' ] = $this->setting->default; |
|
| 153 | 153 | if ( isset( $this->default ) ) { |
| 154 | - $this->json['default'] = $this->default; |
|
| 154 | + $this->json[ 'default' ] = $this->default; |
|
| 155 | 155 | } |
| 156 | 156 | // Required. |
| 157 | - $this->json['required'] = $this->required; |
|
| 157 | + $this->json[ 'required' ] = $this->required; |
|
| 158 | 158 | // Output. |
| 159 | - $this->json['output'] = $this->output; |
|
| 159 | + $this->json[ 'output' ] = $this->output; |
|
| 160 | 160 | // Value. |
| 161 | - $this->json['value'] = $this->value(); |
|
| 161 | + $this->json[ 'value' ] = $this->value(); |
|
| 162 | 162 | // Choices. |
| 163 | - $this->json['choices'] = $this->choices; |
|
| 163 | + $this->json[ 'choices' ] = $this->choices; |
|
| 164 | 164 | // The link. |
| 165 | - $this->json['link'] = $this->get_link(); |
|
| 165 | + $this->json[ 'link' ] = $this->get_link(); |
|
| 166 | 166 | // The ID. |
| 167 | - $this->json['id'] = $this->id; |
|
| 167 | + $this->json[ 'id' ] = $this->id; |
|
| 168 | 168 | // Translation strings. |
| 169 | - $this->json['l10n'] = $this->l10n(); |
|
| 169 | + $this->json[ 'l10n' ] = $this->l10n(); |
|
| 170 | 170 | // The ajaxurl in case we need it. |
| 171 | - $this->json['ajaxurl'] = admin_url( 'admin-ajax.php' ); |
|
| 171 | + $this->json[ 'ajaxurl' ] = admin_url( 'admin-ajax.php' ); |
|
| 172 | 172 | // Input attributes. |
| 173 | - $this->json['inputAttrs'] = ''; |
|
| 173 | + $this->json[ 'inputAttrs' ] = ''; |
|
| 174 | 174 | foreach ( $this->input_attrs as $attr => $value ) { |
| 175 | - $this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
| 175 | + $this->json[ 'inputAttrs' ] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
| 176 | 176 | } |
| 177 | 177 | // The kirki-config. |
| 178 | - $this->json['kirkiConfig'] = $this->kirki_config; |
|
| 178 | + $this->json[ 'kirkiConfig' ] = $this->kirki_config; |
|
| 179 | 179 | // The option-type. |
| 180 | - $this->json['kirkiOptionType'] = $this->option_type; |
|
| 180 | + $this->json[ 'kirkiOptionType' ] = $this->option_type; |
|
| 181 | 181 | // The option-name. |
| 182 | - $this->json['kirkiOptionName'] = $this->option_name; |
|
| 182 | + $this->json[ 'kirkiOptionName' ] = $this->option_name; |
|
| 183 | 183 | // The preset. |
| 184 | - $this->json['preset'] = $this->preset; |
|
| 184 | + $this->json[ 'preset' ] = $this->preset; |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |