PluginProbe ʕ •ᴥ•ʔ
Kirki – Freeform Page Builder, Website Builder & Customizer / 6.0.13
Kirki – Freeform Page Builder, Website Builder & Customizer v6.0.13
6.1.1 6.1.0 6.0.14 6.0.13 6.0.12 6.0.11 6.0.10 6.0.9 6.0.8 6.0.7 6.0.6 6.0.5 6.0.4 6.0.3 6.0.2 6.0.1 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.19 4.0.20 4.0.21 4.0.22 4.0.23 4.0.24 4.1 4.2.0 5.0.0 5.1.0 5.1.1 5.2.0 5.2.1 5.2.2 5.2.3 6.0.0 trunk 3.0.40 3.0.41 3.0.42 3.0.43 3.0.44 3.0.45 3.1.0 3.1.1 3.1.2
kirki / customizer / packages / fields / background / src / CSS / Background.php
kirki / customizer / packages / fields / background / src / CSS Last commit date
Background.php 5 months ago
Background.php
52 lines
1 <?php
2 /**
3 * Handles CSS output for background fields.
4 *
5 * @package Kirki
6 * @subpackage Controls
7 * @copyright Copyright (c) 2023, Themeum
8 * @license https://opensource.org/licenses/MIT
9 * @since 3.0.0
10 */
11
12 namespace Kirki\Field\CSS;
13
14 use Kirki\Module\CSS\Output;
15
16 /**
17 * Output overrides.
18 */
19 class Background extends Output {
20
21 /**
22 * Processes a single item from the `output` array.
23 *
24 * @access protected
25 * @param array $output The `output` item.
26 * @param array $value The field's value.
27 */
28 protected function process_output( $output, $value ) {
29 $output = wp_parse_args(
30 $output,
31 [
32 'media_query' => 'global',
33 'element' => 'body',
34 'prefix' => '',
35 'suffix' => '',
36 ]
37 );
38
39 foreach ( [ 'background-image', 'background-color', 'background-repeat', 'background-position', 'background-size', 'background-attachment' ] as $property ) {
40
41 // See https://github.com/aristath/kirki/issues/1808.
42 if ( 'background-color' === $property && isset( $value['background-color'] ) && $value['background-color'] && ( ! isset( $value['background-image'] ) || empty( $value['background-image'] ) ) ) {
43 $this->styles[ $output['media_query'] ][ $output['element'] ]['background'] = $output['prefix'] . $this->process_property_value( $property, $value[ $property ] ) . $output['suffix'];
44 }
45
46 if ( isset( $value[ $property ] ) && ! empty( $value[ $property ] ) ) {
47 $this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $this->process_property_value( $property, $value[ $property ] ) . $output['suffix'];
48 }
49 }
50 }
51 }
52