@@ -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,60 +244,60 @@ 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 | // The script. |
| 287 | 287 | $script .= 'if(\'' . $choice . '\'===subKey){'; |
| 288 | 288 | $script .= ( $choice_is_direction ) ? $direction_script . 'else{' : ''; |
| 289 | - $script .= 'css+=\'' . $args['element'] . '{' . $args['property'] . ':\'+subValue+\';}\';'; |
|
| 289 | + $script .= 'css+=\'' . $args[ 'element' ] . '{' . $args[ 'property' ] . ':\'+subValue+\';}\';'; |
|
| 290 | 290 | $script .= ( $choice_is_direction ) ? '}' : ''; |
| 291 | 291 | $script .= '}'; |
| 292 | 292 | } else { |
| 293 | 293 | |
| 294 | 294 | // This is where most object-based fields will go. |
| 295 | - $script .= $direction_script . 'else{css+=\'' . $args['element'] . '{\'+subKey+\':\'+subValue+\'' . $args['units'] . $args['suffix'] . ';}\';}'; |
|
| 295 | + $script .= $direction_script . 'else{css+=\'' . $args[ 'element' ] . '{\'+subKey+\':\'+subValue+\'' . $args[ 'units' ] . $args[ 'suffix' ] . ';}\';}'; |
|
| 296 | 296 | } |
| 297 | 297 | $script .= '});'; |
| 298 | 298 | |
| 299 | - if ( isset( $args['media_query'] ) ) { |
|
| 300 | - $script .= 'css=\'' . $args['media_query'] . '{\'+css+\'}\';'; |
|
| 299 | + if ( isset( $args[ 'media_query' ] ) ) { |
|
| 300 | + $script .= 'css=\'' . $args[ 'media_query' ] . '{\'+css+\'}\';'; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | return array( |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | $webfont_loader = 'sc=\'a\';jQuery(\'head\').append(sc.replace(\'a\',\'<\')+\'script>if(!_.isUndefined(WebFont)&&fontFamily){WebFont.load({google:{families:["\'+fontFamily.replace( /\"/g, \'"\' )+\':\'+variant+\'cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai"]}});}\'+sc.replace(\'a\',\'<\')+\'/script>\');'; |
| 327 | 327 | |
| 328 | 328 | // Add the css. |
| 329 | - $css_build_array = array( |
|
| 329 | + $css_build_array = array( |
|
| 330 | 330 | 'font-family' => 'fontFamily', |
| 331 | 331 | 'font-size' => 'fontSize', |
| 332 | 332 | 'line-height' => 'lineHeight', |
@@ -339,41 +339,41 @@ discard block |
||
| 339 | 339 | 'font-weight' => 'fontWeight', |
| 340 | 340 | 'font-style' => 'fontStyle', |
| 341 | 341 | ); |
| 342 | - $choice_condition = ( isset( $args['choice'] ) && '' !== $args['choice'] && isset( $css_build_array[ $args['choice'] ] ) ); |
|
| 342 | + $choice_condition = ( isset( $args[ 'choice' ] ) && '' !== $args[ 'choice' ] && isset( $css_build_array[ $args[ 'choice' ] ] ) ); |
|
| 343 | 343 | $script .= ( ! $choice_condition ) ? $webfont_loader : ''; |
| 344 | 344 | foreach ( $css_build_array as $property => $var ) { |
| 345 | - if ( $choice_condition && $property !== $args['choice'] ) { |
|
| 345 | + if ( $choice_condition && $property !== $args[ 'choice' ] ) { |
|
| 346 | 346 | continue; |
| 347 | 347 | } |
| 348 | 348 | // Fixes https://github.com/aristath/kirki/issues/1436. |
| 349 | - if ( ! isset( $field['default'] ) || ( |
|
| 350 | - ( 'font-family' === $property && ! isset( $field['default']['font-family'] ) ) || |
|
| 351 | - ( 'font-size' === $property && ! isset( $field['default']['font-size'] ) ) || |
|
| 352 | - ( 'line-height' === $property && ! isset( $field['default']['line-height'] ) ) || |
|
| 353 | - ( 'letter-spacing' === $property && ! isset( $field['default']['letter-spacing'] ) ) || |
|
| 354 | - ( 'word-spacing' === $property && ! isset( $field['default']['word-spacing'] ) ) || |
|
| 355 | - ( 'text-align' === $property && ! isset( $field['default']['text-align'] ) ) || |
|
| 356 | - ( 'text-transform' === $property && ! isset( $field['default']['text-transform'] ) ) || |
|
| 357 | - ( 'text-decoration' === $property && ! isset( $field['default']['text-decoration'] ) ) || |
|
| 358 | - ( 'color' === $property && ! isset( $field['default']['color'] ) ) || |
|
| 359 | - ( 'font-weight' === $property && ! isset( $field['default']['variant'] ) && ! isset( $field['default']['font-weight'] ) ) || |
|
| 360 | - ( 'font-style' === $property && ! isset( $field['default']['variant'] ) && ! isset( $field['default']['font-style'] ) ) |
|
| 349 | + if ( ! isset( $field[ 'default' ] ) || ( |
|
| 350 | + ( 'font-family' === $property && ! isset( $field[ 'default' ][ 'font-family' ] ) ) || |
|
| 351 | + ( 'font-size' === $property && ! isset( $field[ 'default' ][ 'font-size' ] ) ) || |
|
| 352 | + ( 'line-height' === $property && ! isset( $field[ 'default' ][ 'line-height' ] ) ) || |
|
| 353 | + ( 'letter-spacing' === $property && ! isset( $field[ 'default' ][ 'letter-spacing' ] ) ) || |
|
| 354 | + ( 'word-spacing' === $property && ! isset( $field[ 'default' ][ 'word-spacing' ] ) ) || |
|
| 355 | + ( 'text-align' === $property && ! isset( $field[ 'default' ][ 'text-align' ] ) ) || |
|
| 356 | + ( 'text-transform' === $property && ! isset( $field[ 'default' ][ 'text-transform' ] ) ) || |
|
| 357 | + ( 'text-decoration' === $property && ! isset( $field[ 'default' ][ 'text-decoration' ] ) ) || |
|
| 358 | + ( 'color' === $property && ! isset( $field[ 'default' ][ 'color' ] ) ) || |
|
| 359 | + ( 'font-weight' === $property && ! isset( $field[ 'default' ][ 'variant' ] ) && ! isset( $field[ 'default' ][ 'font-weight' ] ) ) || |
|
| 360 | + ( 'font-style' === $property && ! isset( $field[ 'default' ][ 'variant' ] ) && ! isset( $field[ 'default' ][ 'font-style' ] ) ) |
|
| 361 | 361 | ) ) { |
| 362 | 362 | continue; |
| 363 | 363 | } |
| 364 | - $script .= ( $choice_condition && 'font-family' === $args['choice'] ) ? $webfont_loader : ''; |
|
| 364 | + $script .= ( $choice_condition && 'font-family' === $args[ 'choice' ] ) ? $webfont_loader : ''; |
|
| 365 | 365 | |
| 366 | - if ( 'font-family' === $property || ( isset( $args['choice'] ) && 'font-family' === $args['choice'] ) ) { |
|
| 366 | + if ( 'font-family' === $property || ( isset( $args[ 'choice' ] ) && 'font-family' === $args[ 'choice' ] ) ) { |
|
| 367 | 367 | $css .= 'fontFamilyCSS=fontFamily;if(0<fontFamily.indexOf(\' \')&&-1===fontFamily.indexOf(\'"\')){fontFamilyCSS=\'"\'+fontFamily+\'"\';}'; |
| 368 | 368 | $var = 'fontFamilyCSS'; |
| 369 | 369 | } |
| 370 | - $var = ( ( empty( $args['prefix'] ) ) ? '' : '\'' . $args['prefix'] . '\'+' ) . $var . ( ( empty( $args['units'] ) ) ? '' : '+\'' . $args['units'] . '\'' ) . ( ( empty( $args['suffix'] ) ) ? '' : '+\'' . $args['suffix'] . '\'' ); |
|
| 371 | - $css .= 'css+=(\'\'!==' . $var . ')?\'' . $args['element'] . '\'+\'{' . $property . ':\'+' . $var . '+\';}\':\'\';'; |
|
| 370 | + $var = ( ( empty( $args[ 'prefix' ] ) ) ? '' : '\'' . $args[ 'prefix' ] . '\'+' ) . $var . ( ( empty( $args[ 'units' ] ) ) ? '' : '+\'' . $args[ 'units' ] . '\'' ) . ( ( empty( $args[ 'suffix' ] ) ) ? '' : '+\'' . $args[ 'suffix' ] . '\'' ); |
|
| 371 | + $css .= 'css+=(\'\'!==' . $var . ')?\'' . $args[ 'element' ] . '\'+\'{' . $property . ':\'+' . $var . '+\';}\':\'\';'; |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | $script .= $css; |
| 375 | - if ( isset( $args['media_query'] ) ) { |
|
| 376 | - $script .= 'css=\'' . $args['media_query'] . '{\'+css+\'}\';'; |
|
| 375 | + if ( isset( $args[ 'media_query' ] ) ) { |
|
| 376 | + $script .= 'css=\'' . $args[ 'media_query' ] . '{\'+css+\'}\';'; |
|
| 377 | 377 | } |
| 378 | 378 | return array( |
| 379 | 379 | 'script' => $script, |
@@ -391,8 +391,8 @@ discard block |
||
| 391 | 391 | protected function script_var_image( $args ) { |
| 392 | 392 | $return = $this->script_var( $args ); |
| 393 | 393 | return array( |
| 394 | - 'script' => 'newval=(!_.isUndefined(newval.url))?newval.url:newval;' . $return['script'], |
|
| 395 | - 'css' => $return['css'], |
|
| 394 | + 'script' => 'newval=(!_.isUndefined(newval.url))?newval.url:newval;' . $return[ 'script' ], |
|
| 395 | + 'css' => $return[ 'css' ], |
|
| 396 | 396 | ); |
| 397 | 397 | } |
| 398 | 398 | |
@@ -408,8 +408,8 @@ discard block |
||
| 408 | 408 | |
| 409 | 409 | $script = ''; |
| 410 | 410 | |
| 411 | - if ( isset( $args['type'] ) ) { |
|
| 412 | - switch ( $args['type'] ) { |
|
| 411 | + if ( isset( $args[ 'type' ] ) ) { |
|
| 412 | + switch ( $args[ 'type' ] ) { |
|
| 413 | 413 | case 'kirki-typography': |
| 414 | 414 | $script .= 'fontFamily=(_.isUndefined(newval[\'font-family\']))?\'\':newval[\'font-family\'];variant=(_.isUndefined(newval.variant))?\'400\':newval.variant;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=(variant&&-1!==variant.indexOf(\'italic\'))?\'italic\':\'normal\';css=\'\';'; |
| 415 | 415 | break; |
@@ -442,17 +442,17 @@ discard block |
||
| 442 | 442 | ); |
| 443 | 443 | |
| 444 | 444 | // Element should be a string. |
| 445 | - if ( is_array( $args['element'] ) ) { |
|
| 446 | - $args['element'] = implode( ',', $args['element'] ); |
|
| 445 | + if ( is_array( $args[ 'element' ] ) ) { |
|
| 446 | + $args[ 'element' ] = implode( ',', $args[ 'element' ] ); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | // Make sure arguments that are passed-on to callbacks are strings. |
| 450 | - if ( is_array( $args['js_callback'] ) && isset( $args['js_callback'][1] ) && is_array( $args['js_callback'][1] ) ) { |
|
| 451 | - $args['js_callback'][1] = wp_json_encode( $args['js_callback'][1] ); |
|
| 450 | + if ( is_array( $args[ 'js_callback' ] ) && isset( $args[ 'js_callback' ][ 1 ] ) && is_array( $args[ 'js_callback' ][ 1 ] ) ) { |
|
| 451 | + $args[ 'js_callback' ][ 1 ] = wp_json_encode( $args[ 'js_callback' ][ 1 ] ); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | - if ( ! isset( $args['js_callback'][1] ) ) { |
|
| 455 | - $args['js_callback'][1] = ''; |
|
| 454 | + if ( ! isset( $args[ 'js_callback' ][ 1 ] ) ) { |
|
| 455 | + $args[ 'js_callback' ][ 1 ] = ''; |
|
| 456 | 456 | } |
| 457 | 457 | return $args; |
| 458 | 458 | |
@@ -470,15 +470,15 @@ discard block |
||
| 470 | 470 | private function value_pattern_replacements( $value, $js_vars ) { |
| 471 | 471 | $script = ''; |
| 472 | 472 | $alias = $value; |
| 473 | - if ( ! isset( $js_vars['value_pattern'] ) ) { |
|
| 473 | + if ( ! isset( $js_vars[ 'value_pattern' ] ) ) { |
|
| 474 | 474 | return $value; |
| 475 | 475 | } |
| 476 | - $value = $js_vars['value_pattern']; |
|
| 477 | - if ( isset( $js_vars['pattern_replace'] ) ) { |
|
| 476 | + $value = $js_vars[ 'value_pattern' ]; |
|
| 477 | + if ( isset( $js_vars[ 'pattern_replace' ] ) ) { |
|
| 478 | 478 | $script .= 'settings=window.wp.customize.get();'; |
| 479 | - foreach ( $js_vars['pattern_replace'] as $search => $replace ) { |
|
| 479 | + foreach ( $js_vars[ 'pattern_replace' ] as $search => $replace ) { |
|
| 480 | 480 | $replace = '\'+settings["' . $replace . '"]+\''; |
| 481 | - $value = str_replace( $search, $replace, $js_vars['value_pattern'] ); |
|
| 481 | + $value = str_replace( $search, $replace, $js_vars[ 'value_pattern' ] ); |
|
| 482 | 482 | $value = trim( $value, '+' ); |
| 483 | 483 | } |
| 484 | 484 | } |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | */ |
| 499 | 499 | protected function get_callback( $args ) { |
| 500 | 500 | |
| 501 | - switch ( $args['type'] ) { |
|
| 501 | + switch ( $args[ 'type' ] ) { |
|
| 502 | 502 | case 'kirki-background': |
| 503 | 503 | case 'kirki-dimensions': |
| 504 | 504 | case 'kirki-multicolor': |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | $config = Kirki_Config::get_instance( $config_id, $args ); |
| 146 | 146 | $config_args = $config->get_config(); |
| 147 | - self::$config[ $config_args['id'] ] = $config_args; |
|
| 147 | + self::$config[ $config_args[ 'id' ] ] = $config_args; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -157,13 +157,13 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | public static function add_panel( $id = '', $args = array() ) { |
| 159 | 159 | |
| 160 | - $args['id'] = esc_attr( $id ); |
|
| 161 | - $args['description'] = ( isset( $args['description'] ) ) ? $args['description'] : ''; |
|
| 162 | - $args['priority'] = ( isset( $args['priority'] ) ) ? absint( $args['priority'] ) : 10; |
|
| 163 | - $args['type'] = ( isset( $args['type'] ) ) ? $args['type'] : 'default'; |
|
| 164 | - $args['type'] = 'kirki-' . $args['type']; |
|
| 160 | + $args[ 'id' ] = esc_attr( $id ); |
|
| 161 | + $args[ 'description' ] = ( isset( $args[ 'description' ] ) ) ? $args[ 'description' ] : ''; |
|
| 162 | + $args[ 'priority' ] = ( isset( $args[ 'priority' ] ) ) ? absint( $args[ 'priority' ] ) : 10; |
|
| 163 | + $args[ 'type' ] = ( isset( $args[ 'type' ] ) ) ? $args[ 'type' ] : 'default'; |
|
| 164 | + $args[ 'type' ] = 'kirki-' . $args[ 'type' ]; |
|
| 165 | 165 | |
| 166 | - self::$panels[ $args['id'] ] = $args; |
|
| 166 | + self::$panels[ $args[ 'id' ] ] = $args; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public static function remove_panel( $id = '' ) { |
| 178 | 178 | if ( ! in_array( $id, self::$panels_to_remove, true ) ) { |
| 179 | - self::$panels_to_remove[] = $id; |
|
| 179 | + self::$panels_to_remove[ ] = $id; |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | |
@@ -190,14 +190,14 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | public static function add_section( $id, $args ) { |
| 192 | 192 | |
| 193 | - $args['id'] = esc_attr( $id ); |
|
| 194 | - $args['panel'] = ( isset( $args['panel'] ) ) ? esc_attr( $args['panel'] ) : ''; |
|
| 195 | - $args['description'] = ( isset( $args['description'] ) ) ? $args['description'] : ''; |
|
| 196 | - $args['priority'] = ( isset( $args['priority'] ) ) ? absint( $args['priority'] ) : 10; |
|
| 197 | - $args['type'] = ( isset( $args['type'] ) ) ? $args['type'] : 'default'; |
|
| 198 | - $args['type'] = 'kirki-' . $args['type']; |
|
| 193 | + $args[ 'id' ] = esc_attr( $id ); |
|
| 194 | + $args[ 'panel' ] = ( isset( $args[ 'panel' ] ) ) ? esc_attr( $args[ 'panel' ] ) : ''; |
|
| 195 | + $args[ 'description' ] = ( isset( $args[ 'description' ] ) ) ? $args[ 'description' ] : ''; |
|
| 196 | + $args[ 'priority' ] = ( isset( $args[ 'priority' ] ) ) ? absint( $args[ 'priority' ] ) : 10; |
|
| 197 | + $args[ 'type' ] = ( isset( $args[ 'type' ] ) ) ? $args[ 'type' ] : 'default'; |
|
| 198 | + $args[ 'type' ] = 'kirki-' . $args[ 'type' ]; |
|
| 199 | 199 | |
| 200 | - self::$sections[ $args['id'] ] = $args; |
|
| 200 | + self::$sections[ $args[ 'id' ] ] = $args; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | public static function remove_section( $id = '' ) { |
| 212 | 212 | if ( ! in_array( $id, self::$sections_to_remove, true ) ) { |
| 213 | - self::$sections_to_remove[] = $id; |
|
| 213 | + self::$sections_to_remove[ ] = $id; |
|
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | 216 | |
@@ -229,16 +229,16 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // Early exit if 'type' is not defined. |
| 232 | - if ( ! isset( $args['type'] ) ) { |
|
| 232 | + if ( ! isset( $args[ 'type' ] ) ) { |
|
| 233 | 233 | return; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | // If the field is font-awesome, enqueue the icons on the frontend. |
| 237 | - if ( class_exists( 'Kirki_Modules_CSS' ) && ( 'fontawesome' === $args['type'] || 'kirki-fontawesome' === $args['type'] ) ) { |
|
| 237 | + if ( class_exists( 'Kirki_Modules_CSS' ) && ( 'fontawesome' === $args[ 'type' ] || 'kirki-fontawesome' === $args[ 'type' ] ) ) { |
|
| 238 | 238 | Kirki_Modules_CSS::add_fontawesome_script(); |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - $str = str_replace( array( '-', '_' ), ' ', $args['type'] ); |
|
| 241 | + $str = str_replace( array( '-', '_' ), ' ', $args[ 'type' ] ); |
|
| 242 | 242 | $classname = 'Kirki_Field_' . str_replace( ' ', '_', ucwords( $str ) ); |
| 243 | 243 | if ( class_exists( $classname ) ) { |
| 244 | 244 | new $classname( $config_id, $args ); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | public static function remove_control( $id ) { |
| 268 | 268 | if ( ! in_array( $id, self::$controls_to_remove, true ) ) { |
| 269 | - self::$controls_to_remove[] = $id; |
|
| 269 | + self::$controls_to_remove[ ] = $id; |
|
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | 272 | |
@@ -36,12 +36,12 @@ |
||
| 36 | 36 | foreach ( array( 'background-image', 'background-color', 'background-repeat', 'background-position', 'background-size', 'background-attachment' ) as $property ) { |
| 37 | 37 | |
| 38 | 38 | // See https://github.com/aristath/kirki/issues/1808. |
| 39 | - if ( 'background-color' === $property && ( ! isset( $value['background-image'] ) || empty( $value['background-image'] ) ) ) { |
|
| 40 | - $this->styles[ $output['media_query'] ][ $output['element'] ]['background'] = $output['prefix'] . $this->process_property_value( $property, $value[ $property ] ) . $output['suffix']; |
|
| 39 | + if ( 'background-color' === $property && ( ! isset( $value[ 'background-image' ] ) || empty( $value[ 'background-image' ] ) ) ) { |
|
| 40 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ 'background' ] = $output[ 'prefix' ] . $this->process_property_value( $property, $value[ $property ] ) . $output[ 'suffix' ]; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | if ( isset( $value[ $property ] ) && ! empty( $value[ $property ] ) ) { |
| 44 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $this->process_property_value( $property, $value[ $property ] ) . $output['suffix']; |
|
| 44 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $property ] = $output[ 'prefix' ] . $this->process_property_value( $property, $value[ $property ] ) . $output[ 'suffix' ]; |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -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 | /** |
@@ -83,13 +83,13 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | protected function apply_sanitize_callback( $output, $value ) { |
| 85 | 85 | |
| 86 | - if ( isset( $output['sanitize_callback'] ) && null !== $output['sanitize_callback'] ) { |
|
| 86 | + if ( isset( $output[ 'sanitize_callback' ] ) && null !== $output[ 'sanitize_callback' ] ) { |
|
| 87 | 87 | |
| 88 | 88 | // If the sanitize_callback is invalid, return the value. |
| 89 | - if ( ! is_callable( $output['sanitize_callback'] ) ) { |
|
| 89 | + if ( ! is_callable( $output[ 'sanitize_callback' ] ) ) { |
|
| 90 | 90 | return $value; |
| 91 | 91 | } |
| 92 | - return call_user_func( $output['sanitize_callback'], $this->value ); |
|
| 92 | + return call_user_func( $output[ 'sanitize_callback' ], $this->value ); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | return $value; |
@@ -105,22 +105,22 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | protected function apply_value_pattern( $output, $value ) { |
| 107 | 107 | |
| 108 | - if ( isset( $output['value_pattern'] ) && ! empty( $output['value_pattern'] ) && is_string( $output['value_pattern'] ) ) { |
|
| 108 | + if ( isset( $output[ 'value_pattern' ] ) && ! empty( $output[ 'value_pattern' ] ) && is_string( $output[ 'value_pattern' ] ) ) { |
|
| 109 | 109 | if ( ! is_array( $value ) ) { |
| 110 | - $value = str_replace( '$', $value, $output['value_pattern'] ); |
|
| 110 | + $value = str_replace( '$', $value, $output[ 'value_pattern' ] ); |
|
| 111 | 111 | } |
| 112 | 112 | if ( is_array( $value ) ) { |
| 113 | 113 | foreach ( array_keys( $value ) as $value_k ) { |
| 114 | 114 | if ( ! is_string( $value[ $value_k ] ) ) { |
| 115 | 115 | continue; |
| 116 | 116 | } |
| 117 | - if ( isset( $output['choice'] ) ) { |
|
| 118 | - if ( $output['choice'] === $value_k ) { |
|
| 119 | - $value[ $output['choice'] ] = str_replace( '$', $value[ $output['choice'] ], $output['value_pattern'] ); |
|
| 117 | + if ( isset( $output[ 'choice' ] ) ) { |
|
| 118 | + if ( $output[ 'choice' ] === $value_k ) { |
|
| 119 | + $value[ $output[ 'choice' ] ] = str_replace( '$', $value[ $output[ 'choice' ] ], $output[ 'value_pattern' ] ); |
|
| 120 | 120 | } |
| 121 | 121 | continue; |
| 122 | 122 | } |
| 123 | - $value[ $value_k ] = str_replace( '$', $value[ $value_k ], $output['value_pattern'] ); |
|
| 123 | + $value[ $value_k ] = str_replace( '$', $value[ $value_k ], $output[ 'value_pattern' ] ); |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | $value = $this->apply_pattern_replace( $output, $value ); |
@@ -136,14 +136,14 @@ discard block |
||
| 136 | 136 | * @return string|array |
| 137 | 137 | */ |
| 138 | 138 | protected function apply_pattern_replace( $output, $value ) { |
| 139 | - if ( isset( $output['pattern_replace'] ) && is_array( $output['pattern_replace'] ) ) { |
|
| 139 | + if ( isset( $output[ 'pattern_replace' ] ) && is_array( $output[ 'pattern_replace' ] ) ) { |
|
| 140 | 140 | $option_type = ( '' !== Kirki::get_config_param( $this->config_id, 'option_type' ) ) ? Kirki::get_config_param( $this->config_id, 'option_type' ) : 'theme_mod'; |
| 141 | 141 | $option_name = Kirki::get_config_param( $this->config_id, 'option_name' ); |
| 142 | 142 | $options = array(); |
| 143 | 143 | if ( $option_name ) { |
| 144 | 144 | $options = ( 'site_option' === $option_type ) ? get_site_option( $option_name ) : get_option( $option_name ); |
| 145 | 145 | } |
| 146 | - foreach ( $output['pattern_replace'] as $search => $replace ) { |
|
| 146 | + foreach ( $output[ 'pattern_replace' ] as $search => $replace ) { |
|
| 147 | 147 | $replacement = ''; |
| 148 | 148 | switch ( $option_type ) { |
| 149 | 149 | case 'option': |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // No need to proceed this if the current value is the same as in the "exclude" value. |
| 207 | - if ( isset( $output['exclude'] ) && is_array( $output['exclude'] ) ) { |
|
| 208 | - foreach ( $output['exclude'] as $exclude ) { |
|
| 207 | + if ( isset( $output[ 'exclude' ] ) && is_array( $output[ 'exclude' ] ) ) { |
|
| 208 | + foreach ( $output[ 'exclude' ] as $exclude ) { |
|
| 209 | 209 | if ( is_array( $value ) ) { |
| 210 | 210 | if ( is_array( $exclude ) ) { |
| 211 | 211 | $diff1 = array_diff( $value, $exclude ); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | // If 'choice' is defined check for sub-values too. |
| 219 | 219 | // Fixes https://github.com/aristath/kirki/issues/1416. |
| 220 | 220 | // @codingStandardsIgnoreLine WordPress.PHP.StrictComparisons.LooseComparison |
| 221 | - if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
| 221 | + if ( isset( $output[ 'choice' ] ) && isset( $value[ $output[ 'choice' ] ] ) && $exclude == $value[ $output[ 'choice' ] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
| 222 | 222 | $skip = true; |
| 223 | 223 | } |
| 224 | 224 | } |
@@ -239,10 +239,10 @@ discard block |
||
| 239 | 239 | // Apply any value patterns defined. |
| 240 | 240 | $value = $this->apply_value_pattern( $output, $value ); |
| 241 | 241 | |
| 242 | - if ( isset( $output['element'] ) && is_array( $output['element'] ) ) { |
|
| 243 | - $output['element'] = array_unique( $output['element'] ); |
|
| 244 | - sort( $output['element'] ); |
|
| 245 | - $output['element'] = implode( ',', $output['element'] ); |
|
| 242 | + if ( isset( $output[ 'element' ] ) && is_array( $output[ 'element' ] ) ) { |
|
| 243 | + $output[ 'element' ] = array_unique( $output[ 'element' ] ); |
|
| 244 | + sort( $output[ 'element' ] ); |
|
| 245 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | $value = $this->process_value( $value, $output ); |
@@ -260,13 +260,13 @@ discard block |
||
| 260 | 260 | * @return null |
| 261 | 261 | */ |
| 262 | 262 | protected function process_output( $output, $value ) { |
| 263 | - if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { |
|
| 263 | + if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) { |
|
| 264 | 264 | return; |
| 265 | 265 | } |
| 266 | - $output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global'; |
|
| 267 | - $output['prefix'] = ( isset( $output['prefix'] ) ) ? $output['prefix'] : ''; |
|
| 268 | - $output['units'] = ( isset( $output['units'] ) ) ? $output['units'] : ''; |
|
| 269 | - $output['suffix'] = ( isset( $output['suffix'] ) ) ? $output['suffix'] : ''; |
|
| 266 | + $output[ 'media_query' ] = ( isset( $output[ 'media_query' ] ) ) ? $output[ 'media_query' ] : 'global'; |
|
| 267 | + $output[ 'prefix' ] = ( isset( $output[ 'prefix' ] ) ) ? $output[ 'prefix' ] : ''; |
|
| 268 | + $output[ 'units' ] = ( isset( $output[ 'units' ] ) ) ? $output[ 'units' ] : ''; |
|
| 269 | + $output[ 'suffix' ] = ( isset( $output[ 'suffix' ] ) ) ? $output[ 'suffix' ] : ''; |
|
| 270 | 270 | |
| 271 | 271 | // Properties that can accept multiple values. |
| 272 | 272 | // Useful for example for gradients where all browsers use the "background-image" property |
@@ -275,15 +275,15 @@ discard block |
||
| 275 | 275 | 'background-image', |
| 276 | 276 | 'background', |
| 277 | 277 | ); |
| 278 | - if ( in_array( $output['property'], $accepts_multiple, true ) ) { |
|
| 279 | - if ( isset( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) && ! is_array( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) ) { |
|
| 280 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = (array) $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ]; |
|
| 278 | + if ( in_array( $output[ 'property' ], $accepts_multiple, true ) ) { |
|
| 279 | + if ( isset( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) && ! is_array( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) ) { |
|
| 280 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = (array) $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ]; |
|
| 281 | 281 | } |
| 282 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ][] = $output['prefix'] . $value . $output['units'] . $output['suffix']; |
|
| 282 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ][ ] = $output[ 'prefix' ] . $value . $output[ 'units' ] . $output[ 'suffix' ]; |
|
| 283 | 283 | return; |
| 284 | 284 | } |
| 285 | 285 | if ( is_string( $value ) ) { |
| 286 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value ) . $output['units'] . $output['suffix']; |
|
| 286 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value ) . $output[ 'units' ] . $output[ 'suffix' ]; |
|
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
@@ -322,8 +322,8 @@ discard block |
||
| 322 | 322 | * @return string|array |
| 323 | 323 | */ |
| 324 | 324 | protected function process_value( $value, $output ) { |
| 325 | - if ( isset( $output['property'] ) ) { |
|
| 326 | - return $this->process_property_value( $output['property'], $value ); |
|
| 325 | + if ( isset( $output[ 'property' ] ) ) { |
|
| 326 | + return $this->process_property_value( $output[ 'property' ], $value ); |
|
| 327 | 327 | } |
| 328 | 328 | return $value; |
| 329 | 329 | } |