field, array( 'top_icon' => '', 'right_icon' => '', 'bottom_icon' => '', 'left_icon' => '', 'all_icon' => '', 'top_placeholder' => esc_html__( 'top', 'smart-post-show' ), 'right_placeholder' => esc_html__( 'right', 'smart-post-show' ), 'bottom_placeholder' => esc_html__( 'bottom', 'smart-post-show' ), 'left_placeholder' => esc_html__( 'left', 'smart-post-show' ), 'all_placeholder' => esc_html__( 'all', 'smart-post-show' ), 'top' => true, 'left' => true, 'bottom' => true, 'right' => true, 'unit' => true, 'min' => '0', 'show_units' => true, 'all' => false, 'units' => array( 'px', '%', 'em' ), ) ); $default_values = array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '', 'all' => '', 'unit' => 'px', 'min' => '', ); $value = wp_parse_args( $this->value, $default_values ); $unit = ( count( $args['units'] ) === 1 && ! empty( $args['unit'] ) ) ? $args['units'][0] : ''; $is_unit = ( ! empty( $unit ) ) ? ' spf--is-unit' : ''; echo wp_kses_post( $this->field_before() ); $min = ( isset( $args['min'] ) ) ? ' min="' . $args['min'] . '"' : ''; echo '
'; if ( ! empty( $args['all'] ) ) { $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . $args['all_placeholder'] . '"' : ''; echo '
'; echo ( ! empty( $args['all_icon'] ) ) ? '' . wp_kses_post( $args['all_icon'] ) . '' : ''; echo ''; echo ( $unit ) ? '' . wp_kses_post( $args['units'][0] ) . '' : ''; echo '
'; } else { $properties = array(); foreach ( array( 'top', 'right', 'bottom', 'left' ) as $prop ) { if ( ! empty( $args[ $prop ] ) ) { $properties[] = $prop; } } $properties = ( array( 'right', 'left' ) === $properties ) ? array_reverse( $properties ) : $properties; foreach ( $properties as $property ) { $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . $args[ $property . '_placeholder' ] . '"' : ''; echo '
'; echo ( ! empty( $args[ $property . '_icon' ] ) ) ? '' . wp_kses_post( $args[ $property . '_icon' ] ) . '' : ''; echo ''; echo ( $unit ) ? '' . wp_kses_post( $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() ); } /** * The output. * * @return mixed */ public function output() { $output = ''; $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output']; $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : ''; $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px'; $mode = ( ! empty( $this->field['output_mode'] ) ) ? $this->field['output_mode'] : 'padding'; $mode = ( 'relative' === $mode || 'absolute' === $mode || 'none' === $mode ) ? '' : $mode; $mode = ( ! empty( $mode ) ) ? $mode . '-' : ''; if ( ! empty( $this->field['all'] ) && isset( $this->value['all'] ) && '' !== $this->value['all'] ) { $output = $element . '{'; $output .= $mode . 'top:' . $this->value['all'] . $unit . $important . ';'; $output .= $mode . 'right:' . $this->value['all'] . $unit . $important . ';'; $output .= $mode . 'bottom:' . $this->value['all'] . $unit . $important . ';'; $output .= $mode . 'left:' . $this->value['all'] . $unit . $important . ';'; $output .= '}'; } else { $top = ( isset( $this->value['top'] ) && '' !== $this->value['top'] ) ? $mode . 'top:' . $this->value['top'] . $unit . $important . ';' : ''; $right = ( isset( $this->value['right'] ) && '' !== $this->value['right'] ) ? $mode . 'right:' . $this->value['right'] . $unit . $important . ';' : ''; $bottom = ( isset( $this->value['bottom'] ) && '' !== $this->value['bottom'] ) ? $mode . 'bottom:' . $this->value['bottom'] . $unit . $important . ';' : ''; $left = ( isset( $this->value['left'] ) && '' !== $this->value['left'] ) ? $mode . 'left:' . $this->value['left'] . $unit . $important . ';' : ''; if ( '' !== $top || '' !== $right || '' !== $bottom || '' !== $left ) { $output = $element . '{' . $top . $right . $bottom . $left . '}'; } } $this->parent->output_css .= $output; return $output; } } }