field, array( 'width_icon' => '', 'height_icon' => '', 'width_placeholder' => esc_html__('width', 'darkify'), 'height_placeholder' => esc_html__('height', 'darkify'), 'width' => true, 'height' => true, 'unit' => true, 'show_units' => true, 'units' => array('px', '%', 'em') )); $default_values = array( 'width' => '', 'height' => '', 'unit' => 'px', ); $value = wp_parse_args($this->value, $default_values); $unit = (count($args['units']) === 1 && ! empty($args['unit'])) ? $args['units'][0] : ''; $is_unit = (! empty($unit)) ? ' darkify--is-unit' : ''; echo wp_kses_post($this->field_before()); echo '
'; if (! empty($args['width'])) { $placeholder = (! empty($args['width_placeholder'])) ? ' placeholder="' . esc_attr($args['width_placeholder']) . '"' : ''; echo '
'; echo ! empty( $args['width_text'] ) ? '
' . wp_kses_post( $args['width_text'] ) . '
' : ''; echo (! empty($args['width_icon'])) ? '' . wp_kses_post($args['width_icon']) . '' : ''; echo ''; echo (! empty($unit)) ? '' . esc_attr($args['units'][0]) . '' : ''; echo '
'; } if (! empty($args['height'])) { $placeholder = (! empty($args['height_placeholder'])) ? ' placeholder="' . esc_attr($args['height_placeholder']) . '"' : ''; echo '
'; echo ( ! empty( $args['height_text'] ) ) ? '
' . wp_kses_post( $args['height_text'] ) . '
' : ''; echo (! empty($args['height_icon'])) ? '' . wp_kses_post($args['height_icon']) . '' : ''; echo ''; echo (! empty($unit)) ? '' . esc_attr($args['units'][0]) . '' : ''; echo '
'; } if (! empty($args['unit']) && ! empty($args['show_units']) && count($args['units']) > 1) { echo '
'; echo ''; echo '
'; } echo '
'; echo wp_kses_post($this->field_after()); } public function output() { $output = ''; $element = (is_array($this->field['output'])) ? join(',', $this->field['output']) : $this->field['output']; $prefix = (! empty($this->field['output_prefix'])) ? $this->field['output_prefix'] . '-' : ''; $important = (! empty($this->field['output_important'])) ? '!important' : ''; $unit = (! empty($this->value['unit'])) ? $this->value['unit'] : 'px'; $width = (isset($this->value['width']) && $this->value['width'] !== '') ? $prefix . 'width:' . $this->value['width'] . $unit . $important . ';' : ''; $height = (isset($this->value['height']) && $this->value['height'] !== '') ? $prefix . 'height:' . $this->value['height'] . $unit . $important . ';' : ''; if ($width !== '' || $height !== '') { $output = $element . '{' . $width . $height . '}'; } $this->parent->output_css .= $output; return $output; } } }