aristath /
kirki
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Handles CSS output for background fields. |
||
| 4 | * |
||
| 5 | * @package Kirki |
||
| 6 | * @subpackage Controls |
||
| 7 | * @copyright Copyright (c) 2017, Aristeides Stathopoulos |
||
| 8 | * @license https://opensource.org/licenses/MIT |
||
| 9 | * @since 3.0.0 |
||
| 10 | */ |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Output overrides. |
||
| 14 | */ |
||
| 15 | class Kirki_Output_Field_Background extends Kirki_Output { |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Processes a single item from the `output` array. |
||
| 19 | * |
||
| 20 | * @access protected |
||
| 21 | * @param array $output The `output` item. |
||
| 22 | * @param array $value The field's value. |
||
| 23 | */ |
||
| 24 | protected function process_output( $output, $value ) { |
||
| 25 | $output = wp_parse_args( |
||
| 26 | $output, |
||
| 27 | array( |
||
| 28 | 'media_query' => 'global', |
||
| 29 | 'element' => 'body', |
||
| 30 | 'prefix' => '', |
||
| 31 | 'suffix' => '', |
||
| 32 | ) |
||
| 33 | ); |
||
| 34 | |||
| 35 | foreach ( array( 'background-image', 'background-color', 'background-repeat', 'background-position', 'background-size', 'background-attachment' ) as $property ) { |
||
| 36 | |||
| 37 | // See https://github.com/aristath/kirki/issues/1808. |
||
| 38 | if ( 'background-color' === $property && isset( $value['background-color'] ) && $value['background-color'] && ( ! isset( $value['background-image'] ) || empty( $value['background-image'] ) ) ) { |
||
| 39 | $this->styles[ $output['media_query'] ][ $output['element'] ]['background'] = $output['prefix'] . $this->process_property_value( $property, $value[ $property ] ) . $output['suffix']; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 40 | } |
||
| 41 | |||
| 42 | if ( isset( $value[ $property ] ) && ! empty( $value[ $property ] ) ) { |
||
| 43 | $this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $this->process_property_value( $property, $value[ $property ] ) . $output['suffix']; |
||
| 44 | } |
||
| 45 | } |
||
| 46 | } |
||
| 47 | } |
||
| 48 |