@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $this->webfonts = $webfonts; |
| 75 | 75 | $this->googlefonts = $googlefonts; |
| 76 | 76 | |
| 77 | - if ( ! isset( $args['enqueue'] ) || false !== $args['enqueue'] ) { |
|
| 77 | + if ( ! isset( $args[ 'enqueue' ] ) || false !== $args[ 'enqueue' ] ) { |
|
| 78 | 78 | add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ), 105 ); |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -124,15 +124,15 @@ discard block |
||
| 124 | 124 | if ( ! empty( $variants ) ) { |
| 125 | 125 | $link_font .= ':' . $variants; |
| 126 | 126 | } |
| 127 | - $link_fonts[] = $link_font; |
|
| 127 | + $link_fonts[ ] = $link_font; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | // Are we force-loading all subsets? |
| 131 | 131 | if ( true === Kirki_Fonts_Google::$force_load_all_subsets ) { |
| 132 | 132 | |
| 133 | - if ( isset( $this->googlefonts->fonts[ $font ]['subsets'] ) ) { |
|
| 134 | - foreach ( $this->googlefonts->fonts[ $font ]['subsets'] as $subset ) { |
|
| 135 | - $this->subsets[] = $subset; |
|
| 133 | + if ( isset( $this->googlefonts->fonts[ $font ][ 'subsets' ] ) ) { |
|
| 134 | + foreach ( $this->googlefonts->fonts[ $font ][ 'subsets' ] as $subset ) { |
|
| 135 | + $this->subsets[ ] = $subset; |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | } |
| 64 | 64 | // Allow disabling the custom loader using the kirki/config filter. |
| 65 | 65 | $config = apply_filters( 'kirki/config', array() ); |
| 66 | - if ( isset( $config['disable_loader'] ) && true === $config['disable_loader'] ) { |
|
| 66 | + if ( isset( $config[ 'disable_loader' ] ) && true === $config[ 'disable_loader' ] ) { |
|
| 67 | 67 | return; |
| 68 | 68 | } |
| 69 | 69 | // Add the "loading" icon. |
@@ -72,8 +72,8 @@ |
||
| 72 | 72 | $collapsible_fields = array(); |
| 73 | 73 | $fields = Kirki::$fields; |
| 74 | 74 | foreach ( $fields as $field ) { |
| 75 | - if ( isset( $field['collapsible'] ) && true === $field['collapsible'] && isset( $field['settings'] ) && isset( $field['label'] ) ) { |
|
| 76 | - $collapsible_fields[ $field['settings'] ] = $field['label']; |
|
| 75 | + if ( isset( $field[ 'collapsible' ] ) && true === $field[ 'collapsible' ] && isset( $field[ 'settings' ] ) && isset( $field[ 'label' ] ) ) { |
|
| 76 | + $collapsible_fields[ $field[ 'settings' ] ] = $field[ 'label' ]; |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | $collapsible_fields = array_unique( $collapsible_fields ); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | wp_enqueue_script( 'kirki_auto_postmessage', trailingslashit( Kirki::$url ) . 'modules/postmessage/postmessage.js', array( 'jquery', 'customize-preview' ), KIRKI_VERSION, true ); |
| 75 | 75 | $fields = Kirki::$fields; |
| 76 | 76 | foreach ( $fields as $field ) { |
| 77 | - if ( isset( $field['transport'] ) && 'postMessage' === $field['transport'] && isset( $field['js_vars'] ) && ! empty( $field['js_vars'] ) && is_array( $field['js_vars'] ) && isset( $field['settings'] ) ) { |
|
| 77 | + if ( isset( $field[ 'transport' ] ) && 'postMessage' === $field[ 'transport' ] && isset( $field[ 'js_vars' ] ) && ! empty( $field[ 'js_vars' ] ) && is_array( $field[ 'js_vars' ] ) && isset( $field[ 'settings' ] ) ) { |
|
| 78 | 78 | $this->script .= $this->script( $field ); |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | protected function script( $args ) { |
| 94 | 94 | |
| 95 | - $script = 'wp.customize(\'' . $args['settings'] . '\',function(value){value.bind(function(newval){'; |
|
| 95 | + $script = 'wp.customize(\'' . $args[ 'settings' ] . '\',function(value){value.bind(function(newval){'; |
|
| 96 | 96 | |
| 97 | 97 | $add_css = false; |
| 98 | - foreach ( $args['js_vars'] as $js_var ) { |
|
| 99 | - if ( ! isset( $js_var['function'] ) || 'html' !== $js_var['function'] ) { |
|
| 98 | + foreach ( $args[ 'js_vars' ] as $js_var ) { |
|
| 99 | + if ( ! isset( $js_var[ 'function' ] ) || 'html' !== $js_var[ 'function' ] ) { |
|
| 100 | 100 | $add_css = true; |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | // append unique style tag if not exist |
| 107 | 107 | // The style ID. |
| 108 | - $style_id = 'kirki-postmessage-' . str_replace( array( '[', ']' ), '', $args['settings'] ); |
|
| 108 | + $style_id = 'kirki-postmessage-' . str_replace( array( '[', ']' ), '', $args[ 'settings' ] ); |
|
| 109 | 109 | $script .= 'if(null===document.getElementById(\'' . $style_id . '\')||\'undefined\'===typeof document.getElementById(\'' . $style_id . '\')){jQuery(\'head\').append(\'<style id="' . $style_id . '"></style>\');}'; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -116,46 +116,46 @@ discard block |
||
| 116 | 116 | 'scripts' => array(), |
| 117 | 117 | ); |
| 118 | 118 | // Loop through the js_vars and generate the script. |
| 119 | - foreach ( $args['js_vars'] as $key => $js_var ) { |
|
| 119 | + foreach ( $args[ 'js_vars' ] as $key => $js_var ) { |
|
| 120 | 120 | |
| 121 | 121 | // Skip styles if "exclude" is defined and value is excluded. |
| 122 | - if ( isset( $js_var['exclude'] ) ) { |
|
| 123 | - $js_var['exclude'] = (array) $js_var['exclude']; |
|
| 122 | + if ( isset( $js_var[ 'exclude' ] ) ) { |
|
| 123 | + $js_var[ 'exclude' ] = (array) $js_var[ 'exclude' ]; |
|
| 124 | 124 | $script .= 'exclude=false;'; |
| 125 | - foreach ( $js_var['exclude'] as $exclussion ) { |
|
| 125 | + foreach ( $js_var[ 'exclude' ] as $exclussion ) { |
|
| 126 | 126 | $script .= "if(newval=='{$exclussion}'||(''==='{$exclussion}'&&_.isObject(newval)&&_.isEmpty(newval))){exclude=true;}"; |
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | - if ( isset( $js_var['element'] ) ) { |
|
| 129 | + if ( isset( $js_var[ 'element' ] ) ) { |
|
| 130 | 130 | // Array to string. |
| 131 | - if ( is_array( $js_var['element'] ) ) { |
|
| 132 | - $js_var['element'] = implode( ',', $js_var['element'] ); |
|
| 131 | + if ( is_array( $js_var[ 'element' ] ) ) { |
|
| 132 | + $js_var[ 'element' ] = implode( ',', $js_var[ 'element' ] ); |
|
| 133 | 133 | } |
| 134 | 134 | // Replace single quotes with double quotes to avoid issues with the compiled JS. |
| 135 | - $js_var['element'] = str_replace( '\'', '"', $js_var['element'] ); |
|
| 135 | + $js_var[ 'element' ] = str_replace( '\'', '"', $js_var[ 'element' ] ); |
|
| 136 | 136 | } |
| 137 | - if ( isset( $js_var['function'] ) && 'html' === $js_var['function'] ) { |
|
| 137 | + if ( isset( $js_var[ 'function' ] ) && 'html' === $js_var[ 'function' ] ) { |
|
| 138 | 138 | $script .= $this->script_html_var( $js_var ); |
| 139 | 139 | continue; |
| 140 | 140 | } |
| 141 | - $js_var['index_key'] = $key; |
|
| 141 | + $js_var[ 'index_key' ] = $key; |
|
| 142 | 142 | $callback = $this->get_callback( $args ); |
| 143 | 143 | if ( is_callable( $callback ) ) { |
| 144 | - $field['scripts'][ $key ] = call_user_func_array( $callback, array( $js_var, $args ) ); |
|
| 144 | + $field[ 'scripts' ][ $key ] = call_user_func_array( $callback, array( $js_var, $args ) ); |
|
| 145 | 145 | continue; |
| 146 | 146 | } |
| 147 | - $field['scripts'][ $key ] = $this->script_var( $js_var ); |
|
| 147 | + $field[ 'scripts' ][ $key ] = $this->script_var( $js_var ); |
|
| 148 | 148 | } |
| 149 | 149 | $combo_extra_script = ''; |
| 150 | 150 | $combo_css_script = ''; |
| 151 | - foreach ( $field['scripts'] as $script_array ) { |
|
| 152 | - $combo_extra_script .= $script_array['script']; |
|
| 153 | - $combo_css_script .= ( 'css' !== $combo_css_script ) ? $script_array['css'] : ''; |
|
| 151 | + foreach ( $field[ 'scripts' ] as $script_array ) { |
|
| 152 | + $combo_extra_script .= $script_array[ 'script' ]; |
|
| 153 | + $combo_css_script .= ( 'css' !== $combo_css_script ) ? $script_array[ 'css' ] : ''; |
|
| 154 | 154 | } |
| 155 | 155 | $text = ( 'css' === $combo_css_script ) ? 'css' : '\'' . $combo_css_script . '\''; |
| 156 | 156 | |
| 157 | 157 | $script .= $combo_extra_script . "var cssContent={$text};"; |
| 158 | - if ( isset( $js_var['exclude'] ) ) { |
|
| 158 | + if ( isset( $js_var[ 'exclude' ] ) ) { |
|
| 159 | 159 | $script .= 'if(true===exclude){cssContent="";}'; |
| 160 | 160 | } |
| 161 | 161 | if ( $add_css ) { |
@@ -174,18 +174,18 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | protected function script_html_var( $args ) { |
| 176 | 176 | |
| 177 | - $script = ( isset( $args['choice'] ) ) ? "newval=newval['{$args['choice']}'];" : ''; |
|
| 177 | + $script = ( isset( $args[ 'choice' ] ) ) ? "newval=newval['{$args[ 'choice' ]}'];" : ''; |
|
| 178 | 178 | |
| 179 | 179 | // Apply the value_pattern. |
| 180 | - if ( isset( $args['value_pattern'] ) && '' !== $args['value_pattern'] ) { |
|
| 180 | + if ( isset( $args[ 'value_pattern' ] ) && '' !== $args[ 'value_pattern' ] ) { |
|
| 181 | 181 | $script .= $this->value_pattern_replacements( 'newval', $args ); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if ( isset( $args['attr'] ) ) { |
|
| 185 | - $script .= "jQuery('{$args['element']}').attr('{$args['attr']}',newval);"; |
|
| 184 | + if ( isset( $args[ 'attr' ] ) ) { |
|
| 185 | + $script .= "jQuery('{$args[ 'element' ]}').attr('{$args[ 'attr' ]}',newval);"; |
|
| 186 | 186 | return $script; |
| 187 | 187 | } |
| 188 | - $script .= "jQuery('{$args['element']}').html(newval);"; |
|
| 188 | + $script .= "jQuery('{$args[ 'element' ]}').html(newval);"; |
|
| 189 | 189 | return $script; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -200,34 +200,34 @@ discard block |
||
| 200 | 200 | $script = ''; |
| 201 | 201 | $property_script = ''; |
| 202 | 202 | |
| 203 | - $value_key = 'newval' . $args['index_key']; |
|
| 203 | + $value_key = 'newval' . $args[ 'index_key' ]; |
|
| 204 | 204 | $property_script .= $value_key . '=newval;'; |
| 205 | 205 | |
| 206 | 206 | $args = $this->get_args( $args ); |
| 207 | 207 | |
| 208 | 208 | // Apply callback to the value if a callback is defined. |
| 209 | - if ( ! empty( $args['js_callback'] ) && is_array( $args['js_callback'] ) && isset( $args['js_callback'][0] ) && ! empty( $args['js_callback'][0] ) ) { |
|
| 210 | - $script .= $value_key . '=' . $args['js_callback'][0] . '(' . $value_key . ',' . $args['js_callback'][1] . ');'; |
|
| 209 | + if ( ! empty( $args[ 'js_callback' ] ) && is_array( $args[ 'js_callback' ] ) && isset( $args[ 'js_callback' ][ 0 ] ) && ! empty( $args[ 'js_callback' ][ 0 ] ) ) { |
|
| 210 | + $script .= $value_key . '=' . $args[ 'js_callback' ][ 0 ] . '(' . $value_key . ',' . $args[ 'js_callback' ][ 1 ] . ');'; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | // Apply the value_pattern. |
| 214 | - if ( '' !== $args['value_pattern'] ) { |
|
| 214 | + if ( '' !== $args[ 'value_pattern' ] ) { |
|
| 215 | 215 | $script .= $this->value_pattern_replacements( $value_key, $args ); |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // Tweak to add url() for background-images. |
| 219 | - if ( 'background-image' === $args['property'] && ( ! isset( $args['value_pattern'] ) || false === strpos( $args['value_pattern'], 'gradient' ) ) ) { |
|
| 219 | + if ( 'background-image' === $args[ 'property' ] && ( ! isset( $args[ 'value_pattern' ] ) || false === strpos( $args[ 'value_pattern' ], 'gradient' ) ) ) { |
|
| 220 | 220 | $script .= 'if(-1===' . $value_key . '.indexOf(\'url(\')){' . $value_key . '=\'url("\'+' . $value_key . '+\'")\';}'; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // Apply prefix. |
| 224 | 224 | $value = $value_key; |
| 225 | - if ( '' !== $args['prefix'] ) { |
|
| 226 | - $value = "'" . $args['prefix'] . "'+" . $value_key; |
|
| 225 | + if ( '' !== $args[ 'prefix' ] ) { |
|
| 226 | + $value = "'" . $args[ 'prefix' ] . "'+" . $value_key; |
|
| 227 | 227 | } |
| 228 | - $css = $args['element'] . '{' . $args['property'] . ':\'+' . $value . '+\'' . $args['units'] . $args['suffix'] . ';}'; |
|
| 229 | - if ( isset( $args['media_query'] ) ) { |
|
| 230 | - $css = $args['media_query'] . '{' . $css . '}'; |
|
| 228 | + $css = $args[ 'element' ] . '{' . $args[ 'property' ] . ':\'+' . $value . '+\'' . $args[ 'units' ] . $args[ 'suffix' ] . ';}'; |
|
| 229 | + if ( isset( $args[ 'media_query' ] ) ) { |
|
| 230 | + $css = $args[ 'media_query' ] . '{' . $css . '}'; |
|
| 231 | 231 | } |
| 232 | 232 | return array( |
| 233 | 233 | 'script' => $property_script . $script, |
@@ -244,59 +244,59 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | protected function script_var_array( $args ) { |
| 246 | 246 | |
| 247 | - $script = ( 0 === $args['index_key'] ) ? 'css=\'\';' : ''; |
|
| 247 | + $script = ( 0 === $args[ 'index_key' ] ) ? 'css=\'\';' : ''; |
|
| 248 | 248 | $property_script = ''; |
| 249 | 249 | |
| 250 | 250 | // Define choice. |
| 251 | - $choice = ( isset( $args['choice'] ) && '' !== $args['choice'] ) ? $args['choice'] : ''; |
|
| 251 | + $choice = ( isset( $args[ 'choice' ] ) && '' !== $args[ 'choice' ] ) ? $args[ 'choice' ] : ''; |
|
| 252 | 252 | |
| 253 | - $value_key = 'newval' . $args['index_key']; |
|
| 253 | + $value_key = 'newval' . $args[ 'index_key' ]; |
|
| 254 | 254 | $property_script .= $value_key . '=newval;'; |
| 255 | 255 | |
| 256 | 256 | $args = $this->get_args( $args ); |
| 257 | 257 | |
| 258 | 258 | // Apply callback to the value if a callback is defined. |
| 259 | - if ( ! empty( $args['js_callback'] ) && is_array( $args['js_callback'] ) && isset( $args['js_callback'][0] ) && ! empty( $args['js_callback'][0] ) ) { |
|
| 260 | - $script .= $value_key . '=' . $args['js_callback'][0] . '(' . $value_key . ',' . $args['js_callback'][1] . ');'; |
|
| 259 | + if ( ! empty( $args[ 'js_callback' ] ) && is_array( $args[ 'js_callback' ] ) && isset( $args[ 'js_callback' ][ 0 ] ) && ! empty( $args[ 'js_callback' ][ 0 ] ) ) { |
|
| 260 | + $script .= $value_key . '=' . $args[ 'js_callback' ][ 0 ] . '(' . $value_key . ',' . $args[ 'js_callback' ][ 1 ] . ');'; |
|
| 261 | 261 | } |
| 262 | 262 | $script .= '_.each(' . $value_key . ', function(subValue,subKey){'; |
| 263 | 263 | |
| 264 | 264 | // Apply the value_pattern. |
| 265 | - if ( '' !== $args['value_pattern'] ) { |
|
| 265 | + if ( '' !== $args[ 'value_pattern' ] ) { |
|
| 266 | 266 | $script .= $this->value_pattern_replacements( 'subValue', $args ); |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | // Tweak to add url() for background-images. |
| 270 | 270 | if ( '' === $choice || 'background-image' === $choice ) { |
| 271 | - $script .= 'if(\'background-image\'===\'' . $args['property'] . '\'||\'background-image\'===subKey){if(-1===subValue.indexOf(\'url(\')){subValue=\'url("\'+subValue+\'")\';}}'; |
|
| 271 | + $script .= 'if(\'background-image\'===\'' . $args[ 'property' ] . '\'||\'background-image\'===subKey){if(-1===subValue.indexOf(\'url(\')){subValue=\'url("\'+subValue+\'")\';}}'; |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | // Apply prefix. |
| 275 | 275 | $value = $value_key; |
| 276 | - if ( '' !== $args['prefix'] ) { |
|
| 277 | - $value = '\'' . $args['prefix'] . '\'+subValue'; |
|
| 276 | + if ( '' !== $args[ 'prefix' ] ) { |
|
| 277 | + $value = '\'' . $args[ 'prefix' ] . '\'+subValue'; |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | // Mostly used for padding, margin & position properties. |
| 281 | 281 | $direction_script = 'if(_.contains([\'top\',\'bottom\',\'left\',\'right\'],subKey)){'; |
| 282 | - $direction_script .= 'css+=\'' . $args['element'] . '{' . $args['property'] . '-\'+subKey+\':\'+subValue+\'' . $args['units'] . $args['suffix'] . ';}\';}'; |
|
| 282 | + $direction_script .= 'css+=\'' . $args[ 'element' ] . '{' . $args[ 'property' ] . '-\'+subKey+\':\'+subValue+\'' . $args[ 'units' ] . $args[ 'suffix' ] . ';}\';}'; |
|
| 283 | 283 | // Allows us to apply this just for a specific choice in the array of the values. |
| 284 | 284 | if ( '' !== $choice ) { |
| 285 | 285 | $choice_is_direction = ( false !== strpos( $choice, 'top' ) || false !== strpos( $choice, 'bottom' ) || false !== strpos( $choice, 'left' ) || false !== strpos( $choice, 'right' ) ); |
| 286 | 286 | $script .= 'if(\'' . $choice . '\'===subKey){'; |
| 287 | 287 | $script .= ( $choice_is_direction ) ? $direction_script . 'else{' : ''; |
| 288 | - $script .= 'css+=\'' . $args['element'] . '{' . $args['property'] . ':\'+subValue+\';}\';'; |
|
| 288 | + $script .= 'css+=\'' . $args[ 'element' ] . '{' . $args[ 'property' ] . ':\'+subValue+\';}\';'; |
|
| 289 | 289 | $script .= ( $choice_is_direction ) ? '}' : ''; |
| 290 | 290 | $script .= '}'; |
| 291 | 291 | } else { |
| 292 | 292 | |
| 293 | 293 | // This is where most object-based fields will go. |
| 294 | - $script .= $direction_script . 'else{css+=\'' . $args['element'] . '{\'+subKey+\':\'+subValue+\'' . $args['units'] . $args['suffix'] . ';}\';}'; |
|
| 294 | + $script .= $direction_script . 'else{css+=\'' . $args[ 'element' ] . '{\'+subKey+\':\'+subValue+\'' . $args[ 'units' ] . $args[ 'suffix' ] . ';}\';}'; |
|
| 295 | 295 | } |
| 296 | 296 | $script .= '});'; |
| 297 | 297 | |
| 298 | - if ( isset( $args['media_query'] ) ) { |
|
| 299 | - $script .= 'css=\'' . $args['media_query'] . '{\'+css+\'}\';'; |
|
| 298 | + if ( isset( $args[ 'media_query' ] ) ) { |
|
| 299 | + $script .= 'css=\'' . $args[ 'media_query' ] . '{\'+css+\'}\';'; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | return array( |
@@ -338,41 +338,41 @@ discard block |
||
| 338 | 338 | 'font-weight' => 'fontWeight', |
| 339 | 339 | 'font-style' => 'fontStyle', |
| 340 | 340 | ); |
| 341 | - $choice_condition = ( isset( $args['choice'] ) && '' !== $args['choice'] && isset( $css_build_array[ $args['choice'] ] ) ); |
|
| 341 | + $choice_condition = ( isset( $args[ 'choice' ] ) && '' !== $args[ 'choice' ] && isset( $css_build_array[ $args[ 'choice' ] ] ) ); |
|
| 342 | 342 | $script .= ( ! $choice_condition ) ? $webfont_loader : ''; |
| 343 | 343 | foreach ( $css_build_array as $property => $var ) { |
| 344 | - if ( $choice_condition && $property !== $args['choice'] ) { |
|
| 344 | + if ( $choice_condition && $property !== $args[ 'choice' ] ) { |
|
| 345 | 345 | continue; |
| 346 | 346 | } |
| 347 | 347 | // Fixes https://github.com/aristath/kirki/issues/1436. |
| 348 | - if ( ! isset( $field['default'] ) || ( |
|
| 349 | - ( 'font-family' === $property && ! isset( $field['default']['font-family'] ) ) || |
|
| 350 | - ( 'font-size' === $property && ! isset( $field['default']['font-size'] ) ) || |
|
| 351 | - ( 'line-height' === $property && ! isset( $field['default']['line-height'] ) ) || |
|
| 352 | - ( 'letter-spacing' === $property && ! isset( $field['default']['letter-spacing'] ) ) || |
|
| 353 | - ( 'word-spacing' === $property && ! isset( $field['default']['word-spacing'] ) ) || |
|
| 354 | - ( 'text-align' === $property && ! isset( $field['default']['text-align'] ) ) || |
|
| 355 | - ( 'text-transform' === $property && ! isset( $field['default']['text-transform'] ) ) || |
|
| 356 | - ( 'text-decoration' === $property && ! isset( $field['default']['text-decoration'] ) ) || |
|
| 357 | - ( 'color' === $property && ! isset( $field['default']['color'] ) ) || |
|
| 358 | - ( 'font-weight' === $property && ! isset( $field['default']['variant'] ) && ! isset( $field['default']['font-weight'] ) ) || |
|
| 359 | - ( 'font-style' === $property && ! isset( $field['default']['variant'] ) && ! isset( $field['default']['font-style'] ) ) |
|
| 348 | + if ( ! isset( $field[ 'default' ] ) || ( |
|
| 349 | + ( 'font-family' === $property && ! isset( $field[ 'default' ][ 'font-family' ] ) ) || |
|
| 350 | + ( 'font-size' === $property && ! isset( $field[ 'default' ][ 'font-size' ] ) ) || |
|
| 351 | + ( 'line-height' === $property && ! isset( $field[ 'default' ][ 'line-height' ] ) ) || |
|
| 352 | + ( 'letter-spacing' === $property && ! isset( $field[ 'default' ][ 'letter-spacing' ] ) ) || |
|
| 353 | + ( 'word-spacing' === $property && ! isset( $field[ 'default' ][ 'word-spacing' ] ) ) || |
|
| 354 | + ( 'text-align' === $property && ! isset( $field[ 'default' ][ 'text-align' ] ) ) || |
|
| 355 | + ( 'text-transform' === $property && ! isset( $field[ 'default' ][ 'text-transform' ] ) ) || |
|
| 356 | + ( 'text-decoration' === $property && ! isset( $field[ 'default' ][ 'text-decoration' ] ) ) || |
|
| 357 | + ( 'color' === $property && ! isset( $field[ 'default' ][ 'color' ] ) ) || |
|
| 358 | + ( 'font-weight' === $property && ! isset( $field[ 'default' ][ 'variant' ] ) && ! isset( $field[ 'default' ][ 'font-weight' ] ) ) || |
|
| 359 | + ( 'font-style' === $property && ! isset( $field[ 'default' ][ 'variant' ] ) && ! isset( $field[ 'default' ][ 'font-style' ] ) ) |
|
| 360 | 360 | ) ) { |
| 361 | 361 | continue; |
| 362 | 362 | } |
| 363 | - $script .= ( $choice_condition && 'font-family' === $args['choice'] ) ? $webfont_loader : ''; |
|
| 363 | + $script .= ( $choice_condition && 'font-family' === $args[ 'choice' ] ) ? $webfont_loader : ''; |
|
| 364 | 364 | |
| 365 | - if ( 'font-family' === $property || ( isset( $args['choice'] ) && 'font-family' === $args['choice'] ) ) { |
|
| 365 | + if ( 'font-family' === $property || ( isset( $args[ 'choice' ] ) && 'font-family' === $args[ 'choice' ] ) ) { |
|
| 366 | 366 | $css .= 'fontFamilyCSS=fontFamily;if(0<fontFamily.indexOf(\' \')&&-1===fontFamily.indexOf(\'"\')){fontFamilyCSS=\'"\'+fontFamily+\'"\';}'; |
| 367 | 367 | $var = 'fontFamilyCSS'; |
| 368 | 368 | } |
| 369 | - $var = ( ( empty( $args['prefix'] ) ) ? '' : '\'' . $args['prefix'] . '\'+' ) . $var . ( ( empty( $args['units'] ) ) ? '' : '+\'' . $args['units'] . '\'' ) . ( ( empty( $args['suffix'] ) ) ? '' : '+\'' . $args['suffix'] . '\'' ); |
|
| 370 | - $css .= 'css+=(\'\'!==' . $var . ')?\'' . $args['element'] . '\'+\'{' . $property . ':\'+' . $var . '+\';}\':\'\';'; |
|
| 369 | + $var = ( ( empty( $args[ 'prefix' ] ) ) ? '' : '\'' . $args[ 'prefix' ] . '\'+' ) . $var . ( ( empty( $args[ 'units' ] ) ) ? '' : '+\'' . $args[ 'units' ] . '\'' ) . ( ( empty( $args[ 'suffix' ] ) ) ? '' : '+\'' . $args[ 'suffix' ] . '\'' ); |
|
| 370 | + $css .= 'css+=(\'\'!==' . $var . ')?\'' . $args[ 'element' ] . '\'+\'{' . $property . ':\'+' . $var . '+\';}\':\'\';'; |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | $script .= $css; |
| 374 | - if ( isset( $args['media_query'] ) ) { |
|
| 375 | - $script .= 'css=\'' . $args['media_query'] . '{\'+css+\'}\';'; |
|
| 374 | + if ( isset( $args[ 'media_query' ] ) ) { |
|
| 375 | + $script .= 'css=\'' . $args[ 'media_query' ] . '{\'+css+\'}\';'; |
|
| 376 | 376 | } |
| 377 | 377 | return array( |
| 378 | 378 | 'script' => $script, |
@@ -390,8 +390,8 @@ discard block |
||
| 390 | 390 | protected function script_var_image( $args ) { |
| 391 | 391 | $return = $this->script_var( $args ); |
| 392 | 392 | return array( |
| 393 | - 'script' => 'newval=(!_.isUndefined(newval.url))?newval.url:newval;' . $return['script'], |
|
| 394 | - 'css' => $return['css'], |
|
| 393 | + 'script' => 'newval=(!_.isUndefined(newval.url))?newval.url:newval;' . $return[ 'script' ], |
|
| 394 | + 'css' => $return[ 'css' ], |
|
| 395 | 395 | ); |
| 396 | 396 | } |
| 397 | 397 | |
@@ -407,8 +407,8 @@ discard block |
||
| 407 | 407 | |
| 408 | 408 | $script = ''; |
| 409 | 409 | |
| 410 | - if ( isset( $args['type'] ) ) { |
|
| 411 | - switch ( $args['type'] ) { |
|
| 410 | + if ( isset( $args[ 'type' ] ) ) { |
|
| 411 | + switch ( $args[ 'type' ] ) { |
|
| 412 | 412 | case 'kirki-typography': |
| 413 | 413 | $script .= 'fontFamily=(_.isUndefined(newval[\'font-family\']))?\'\':newval[\'font-family\'];variant=(_.isUndefined(newval.variant))?\'400\':newval.variant;subsets=(_.isUndefined(newval.subsets))?[]:newval.subsets;subsetsString=(_.isObject(newval.subsets))?\':\'+newval.subsets.join(\',\'):\'\';fontSize=(_.isUndefined(newval[\'font-size\']))?\'\':newval[\'font-size\'];lineHeight=(_.isUndefined(newval[\'line-height\']))?\'\':newval[\'line-height\'];letterSpacing=(_.isUndefined(newval[\'letter-spacing\']))?\'\':newval[\'letter-spacing\'];wordSpacing=(_.isUndefined(newval[\'word-spacing\']))?\'\':newval[\'word-spacing\'];textAlign=(_.isUndefined(newval[\'text-align\']))?\'\':newval[\'text-align\'];textTransform=(_.isUndefined(newval[\'text-transform\']))?\'\':newval[\'text-transform\'];textDecoration=(_.isUndefined(newval[\'text-decoration\']))?\'\':newval[\'text-decoration\'];color=(_.isUndefined(newval.color))?\'\':newval.color;fw=(!_.isString(newval.variant))?\'400\':newval.variant.match(/\d/g);fontWeight=(!_.isObject(fw))?400:fw.join(\'\');fontStyle=(-1!==variant.indexOf(\'italic\'))?\'italic\':\'normal\';css=\'\';'; |
| 414 | 414 | break; |
@@ -441,17 +441,17 @@ discard block |
||
| 441 | 441 | ); |
| 442 | 442 | |
| 443 | 443 | // Element should be a string. |
| 444 | - if ( is_array( $args['element'] ) ) { |
|
| 445 | - $args['element'] = implode( ',', $args['element'] ); |
|
| 444 | + if ( is_array( $args[ 'element' ] ) ) { |
|
| 445 | + $args[ 'element' ] = implode( ',', $args[ 'element' ] ); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | // Make sure arguments that are passed-on to callbacks are strings. |
| 449 | - if ( is_array( $args['js_callback'] ) && isset( $args['js_callback'][1] ) && is_array( $args['js_callback'][1] ) ) { |
|
| 450 | - $args['js_callback'][1] = wp_json_encode( $args['js_callback'][1] ); |
|
| 449 | + if ( is_array( $args[ 'js_callback' ] ) && isset( $args[ 'js_callback' ][ 1 ] ) && is_array( $args[ 'js_callback' ][ 1 ] ) ) { |
|
| 450 | + $args[ 'js_callback' ][ 1 ] = wp_json_encode( $args[ 'js_callback' ][ 1 ] ); |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - if ( ! isset( $args['js_callback'][1] ) ) { |
|
| 454 | - $args['js_callback'][1] = ''; |
|
| 453 | + if ( ! isset( $args[ 'js_callback' ][ 1 ] ) ) { |
|
| 454 | + $args[ 'js_callback' ][ 1 ] = ''; |
|
| 455 | 455 | } |
| 456 | 456 | return $args; |
| 457 | 457 | |
@@ -469,15 +469,15 @@ discard block |
||
| 469 | 469 | private function value_pattern_replacements( $value, $js_vars ) { |
| 470 | 470 | $script = ''; |
| 471 | 471 | $alias = $value; |
| 472 | - if ( ! isset( $js_vars['value_pattern'] ) ) { |
|
| 472 | + if ( ! isset( $js_vars[ 'value_pattern' ] ) ) { |
|
| 473 | 473 | return $value; |
| 474 | 474 | } |
| 475 | - $value = $js_vars['value_pattern']; |
|
| 476 | - if ( isset( $js_vars['pattern_replace'] ) ) { |
|
| 475 | + $value = $js_vars[ 'value_pattern' ]; |
|
| 476 | + if ( isset( $js_vars[ 'pattern_replace' ] ) ) { |
|
| 477 | 477 | $script .= 'settings=window.wp.customize.get();'; |
| 478 | - foreach ( $js_vars['pattern_replace'] as $search => $replace ) { |
|
| 478 | + foreach ( $js_vars[ 'pattern_replace' ] as $search => $replace ) { |
|
| 479 | 479 | $replace = '\'+settings["' . $replace . '"]+\''; |
| 480 | - $value = str_replace( $search, $replace, $js_vars['value_pattern'] ); |
|
| 480 | + $value = str_replace( $search, $replace, $js_vars[ 'value_pattern' ] ); |
|
| 481 | 481 | $value = trim( $value, '+' ); |
| 482 | 482 | } |
| 483 | 483 | } |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | */ |
| 498 | 498 | protected function get_callback( $args ) { |
| 499 | 499 | |
| 500 | - switch ( $args['type'] ) { |
|
| 500 | + switch ( $args[ 'type' ] ) { |
|
| 501 | 501 | case 'kirki-background': |
| 502 | 502 | case 'kirki-dimensions': |
| 503 | 503 | case 'kirki-multicolor': |
@@ -89,15 +89,15 @@ |
||
| 89 | 89 | |
| 90 | 90 | // Parse sections and find ones with icons. |
| 91 | 91 | foreach ( $sections as $section ) { |
| 92 | - if ( isset( $section['icon'] ) ) { |
|
| 93 | - $this->add_icon( $section['id'], $section['icon'], 'section' ); |
|
| 92 | + if ( isset( $section[ 'icon' ] ) ) { |
|
| 93 | + $this->add_icon( $section[ 'id' ], $section[ 'icon' ], 'section' ); |
|
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | // Parse panels and find ones with icons. |
| 98 | 98 | foreach ( $panels as $panel ) { |
| 99 | - if ( isset( $panel['icon'] ) ) { |
|
| 100 | - $this->add_icon( $panel['id'], $panel['icon'], 'panel' ); |
|
| 99 | + if ( isset( $panel[ 'icon' ] ) ) { |
|
| 100 | + $this->add_icon( $panel[ 'id' ], $panel[ 'icon' ], 'panel' ); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
@@ -76,11 +76,11 @@ |
||
| 76 | 76 | |
| 77 | 77 | $fields = Kirki::$fields; |
| 78 | 78 | foreach ( $fields as $field ) { |
| 79 | - if ( isset( $field['tooltip'] ) && ! empty( $field['tooltip'] ) ) { |
|
| 80 | - $id = str_replace( '[', '-', str_replace( ']', '', $field['settings'] ) ); |
|
| 79 | + if ( isset( $field[ 'tooltip' ] ) && ! empty( $field[ 'tooltip' ] ) ) { |
|
| 80 | + $id = str_replace( '[', '-', str_replace( ']', '', $field[ 'settings' ] ) ); |
|
| 81 | 81 | $this->tooltips_content[ $id ] = array( |
| 82 | 82 | 'id' => $id, |
| 83 | - 'content' => wp_kses_post( $field['tooltip'] ), |
|
| 83 | + 'content' => wp_kses_post( $field[ 'tooltip' ] ), |
|
| 84 | 84 | ); |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -53,8 +53,8 @@ |
||
| 53 | 53 | public function to_json() { |
| 54 | 54 | parent::to_json(); |
| 55 | 55 | |
| 56 | - $this->json['palette'] = $this->palette; |
|
| 57 | - $this->json['choices']['alpha'] = ( isset( $this->choices['alpha'] ) && $this->choices['alpha'] ) ? 'true' : 'false'; |
|
| 58 | - $this->json['mode'] = $this->mode; |
|
| 56 | + $this->json[ 'palette' ] = $this->palette; |
|
| 57 | + $this->json[ 'choices' ][ 'alpha' ] = ( isset( $this->choices[ 'alpha' ] ) && $this->choices[ 'alpha' ] ) ? 'true' : 'false'; |
|
| 58 | + $this->json[ 'mode' ] = $this->mode; |
|
| 59 | 59 | } |
| 60 | 60 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | public function to_json() { |
| 36 | 36 | parent::to_json(); |
| 37 | 37 | |
| 38 | - $this->json['icons'] = Kirki_Helper::get_dashicons(); |
|
| 38 | + $this->json[ 'icons' ] = Kirki_Helper::get_dashicons(); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -37,10 +37,10 @@ |
||
| 37 | 37 | |
| 38 | 38 | foreach ( $this->input_attrs as $attr => $value ) { |
| 39 | 39 | if ( 'style' !== $attr ) { |
| 40 | - $this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
| 40 | + $this->json[ 'inputAttrs' ] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
| 41 | 41 | continue; |
| 42 | 42 | } |
| 43 | - $this->json['labelStyle'] = 'style="' . esc_attr( $value ) . '" '; |
|
| 43 | + $this->json[ 'labelStyle' ] = 'style="' . esc_attr( $value ) . '" '; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | } |