field, array( 'top_icon' => '', 'left_icon' => '', 'bottom_icon' => '', 'right_icon' => '', 'all_icon' => '', 'top_placeholder' => esc_html__( 'top', 'sakurairo_csf' ), 'right_placeholder' => esc_html__( 'right', 'sakurairo_csf' ), 'bottom_placeholder' => esc_html__( 'bottom', 'sakurairo_csf' ), 'left_placeholder' => esc_html__( 'left', 'sakurairo_csf' ), 'all_placeholder' => esc_html__( 'all', 'sakurairo_csf' ), 'top' => true, 'left' => true, 'bottom' => true, 'right' => true, 'all' => false, 'color' => true, 'style' => true, 'unit' => 'px', ) ); $default_value = array( 'top' => '', 'right' => '', 'bottom' => '', 'left' => '', 'color' => '', 'style' => 'solid', 'all' => '', ); $border_props = array( 'solid' => esc_html__( 'Solid', 'sakurairo_csf' ), 'dashed' => esc_html__( 'Dashed', 'sakurairo_csf' ), 'dotted' => esc_html__( 'Dotted', 'sakurairo_csf' ), 'double' => esc_html__( 'Double', 'sakurairo_csf' ), 'inset' => esc_html__( 'Inset', 'sakurairo_csf' ), 'outset' => esc_html__( 'Outset', 'sakurairo_csf' ), 'groove' => esc_html__( 'Groove', 'sakurairo_csf' ), 'ridge' => esc_html__( 'ridge', 'sakurairo_csf' ), 'none' => esc_html__( 'None', 'sakurairo_csf' ) ); $default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value; $value = wp_parse_args( $this->value, $default_value ); echo $this->field_before(); echo '
'; if ( ! empty( $args['all'] ) ) { $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="'. esc_attr( $args['all_placeholder'] ) .'"' : ''; echo '
'; echo ( ! empty( $args['all_icon'] ) ) ? ''. $args['all_icon'] .'' : ''; echo ''; echo ( ! empty( $args['unit'] ) ) ? ''. esc_attr( $args['unit'] ) .'' : ''; echo '
'; } else { $properties = array(); foreach ( array( 'top', 'right', 'bottom', 'left' ) as $prop ) { if ( ! empty( $args[$prop] ) ) { $properties[] = $prop; } } $properties = ( $properties === array( 'right', 'left' ) ) ? array_reverse( $properties ) : $properties; foreach ( $properties as $property ) { $placeholder = ( ! empty( $args[$property.'_placeholder'] ) ) ? ' placeholder="'. esc_attr( $args[$property.'_placeholder'] ) .'"' : ''; echo '
'; echo ( ! empty( $args[$property.'_icon'] ) ) ? ''. $args[$property.'_icon'] .'' : ''; echo ''; echo ( ! empty( $args['unit'] ) ) ? ''. esc_attr( $args['unit'] ) .'' : ''; echo '
'; } } if ( ! empty( $args['style'] ) ) { echo '
'; echo ''; echo '
'; } echo '
'; if ( ! empty( $args['color'] ) ) { $default_color_attr = ( ! empty( $default_value['color'] ) ) ? ' data-default-color="'. esc_attr( $default_value['color'] ) .'"' : ''; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; } echo $this->field_after(); } public function output() { $output = ''; $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px'; $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : ''; $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output']; // properties $top = ( isset( $this->value['top'] ) && $this->value['top'] !== '' ) ? $this->value['top'] : ''; $right = ( isset( $this->value['right'] ) && $this->value['right'] !== '' ) ? $this->value['right'] : ''; $bottom = ( isset( $this->value['bottom'] ) && $this->value['bottom'] !== '' ) ? $this->value['bottom'] : ''; $left = ( isset( $this->value['left'] ) && $this->value['left'] !== '' ) ? $this->value['left'] : ''; $style = ( isset( $this->value['style'] ) && $this->value['style'] !== '' ) ? $this->value['style'] : ''; $color = ( isset( $this->value['color'] ) && $this->value['color'] !== '' ) ? $this->value['color'] : ''; $all = ( isset( $this->value['all'] ) && $this->value['all'] !== '' ) ? $this->value['all'] : ''; if ( ! empty( $this->field['all'] ) && ( $all !== '' || $color !== '' ) ) { $output = $element .'{'; $output .= ( $all !== '' ) ? 'border-width:'. $all . $unit . $important .';' : ''; $output .= ( $color !== '' ) ? 'border-color:'. $color . $important .';' : ''; $output .= ( $style !== '' ) ? 'border-style:'. $style . $important .';' : ''; $output .= '}'; } else if ( $top !== '' || $right !== '' || $bottom !== '' || $left !== '' || $color !== '' ) { $output = $element .'{'; $output .= ( $top !== '' ) ? 'border-top-width:'. $top . $unit . $important .';' : ''; $output .= ( $right !== '' ) ? 'border-right-width:'. $right . $unit . $important .';' : ''; $output .= ( $bottom !== '' ) ? 'border-bottom-width:'. $bottom . $unit . $important .';' : ''; $output .= ( $left !== '' ) ? 'border-left-width:'. $left . $unit . $important .';' : ''; $output .= ( $color !== '' ) ? 'border-color:'. $color . $important .';' : ''; $output .= ( $style !== '' ) ? 'border-style:'. $style . $important .';' : ''; $output .= '}'; } $this->parent->output_css .= $output; return $output; } } }