2019-02-10 20:21:07 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Handles CSS output for dimensions fields.
|
|
|
|
*
|
|
|
|
* @package Kirki
|
|
|
|
* @subpackage Controls
|
2019-02-17 14:28:35 +01:00
|
|
|
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
|
2020-02-25 18:04:54 +01:00
|
|
|
* @license https://opensource.org/licenses/MIT
|
2019-02-10 20:21:07 +01:00
|
|
|
* @since 2.2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Output overrides.
|
|
|
|
*/
|
|
|
|
class Kirki_Output_Field_Dimensions extends Kirki_Output {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Processes a single item from the `output` array.
|
|
|
|
*
|
|
|
|
* @access protected
|
|
|
|
* @param array $output The `output` item.
|
|
|
|
* @param array $value The field's value.
|
|
|
|
*/
|
|
|
|
protected function process_output( $output, $value ) {
|
|
|
|
$output = wp_parse_args(
|
2019-02-17 14:28:35 +01:00
|
|
|
$output,
|
|
|
|
array(
|
2019-02-10 20:21:07 +01:00
|
|
|
'element' => '',
|
|
|
|
'property' => '',
|
|
|
|
'media_query' => 'global',
|
|
|
|
'prefix' => '',
|
|
|
|
'suffix' => '',
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( ! is_array( $value ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ( array_keys( $value ) as $key ) {
|
|
|
|
|
|
|
|
$property = ( empty( $output['property'] ) ) ? $key : $output['property'] . '-' . $key;
|
|
|
|
if ( isset( $output['choice'] ) && $output['property'] ) {
|
|
|
|
if ( $key === $output['choice'] ) {
|
|
|
|
$property = $output['property'];
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( false !== strpos( $output['property'], '%%' ) ) {
|
|
|
|
$property = str_replace( '%%', $key, $output['property'] );
|
|
|
|
}
|
|
|
|
$this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $this->process_property_value( $property, $value[ $key ] ) . $output['suffix'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|