← All changes
|
admin/views/sp-framework/fields/border/border.php
+52
-76
2.4.15
→
2.2.10
View file →
| @@ -1,39 +1,20 @@ | ||
| 1 | -<?php | |
| 1 | +<?php if ( ! defined( 'ABSPATH' ) ) { | |
| 2 | + die; } // Cannot access directly. | |
| 2 | 3 | /** |
| 3 | - * The framework border fields file. | |
| 4 | 4 | * |
| 5 | - * @package Smart_Post_Show | |
| 6 | - * @subpackage Smart_Post_Show/admin | |
| 5 | + * Field: border | |
| 6 | + * | |
| 7 | + * @since 1.0.0 | |
| 8 | + * @version 1.0.0 | |
| 7 | 9 | */ |
| 8 | - | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | - die; | |
| 11 | -} // Cannot access directly. | |
| 12 | - | |
| 13 | 10 | if ( ! class_exists( 'SP_PC_Field_border' ) ) { |
| 14 | - /** | |
| 15 | - * SP_PC_Field_border | |
| 16 | - */ | |
| 17 | 11 | class SP_PC_Field_border extends SP_PC_Fields { |
| 18 | - /** | |
| 19 | - * Field constructor. | |
| 20 | - * | |
| 21 | - * @param array $field The field type. | |
| 22 | - * @param string $value The values of the field. | |
| 23 | - * @param string $unique The unique ID for the field. | |
| 24 | - * @param string $where To where show the output CSS. | |
| 25 | - * @param string $parent The parent args. | |
| 26 | - */ | |
| 12 | + | |
| 27 | 13 | public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) { |
| 28 | 14 | parent::__construct( $field, $value, $unique, $where, $parent ); |
| 29 | 15 | } |
| 30 | 16 | |
| 31 | - /** | |
| 32 | - * Render method. | |
| 33 | - * | |
| 34 | - * @return void | |
| 35 | - */ | |
| 36 | 17 | public function render() { |
| 37 | 18 | |
| 38 | 19 | $args = wp_parse_args( |
| 39 | 20 | $this->field, |
| @@ -42,13 +23,13 @@ | ||
| 42 | 23 | 'left_icon' => '<i class="fa fa-long-arrow-left"></i>', |
| 43 | 24 | 'bottom_icon' => '<i class="fa fa-long-arrow-down"></i>', |
| 44 | 25 | 'right_icon' => '<i class="fa fa-long-arrow-right"></i>', |
| 45 | 26 | 'all_icon' => '<i class="fa fa-arrows"></i>', |
| 46 | - 'top_placeholder' => esc_html__( 'top', 'post-carousel' ), | |
| 47 | - 'right_placeholder' => esc_html__( 'right', 'post-carousel' ), | |
| 48 | - 'bottom_placeholder' => esc_html__( 'bottom', 'post-carousel' ), | |
| 49 | - 'left_placeholder' => esc_html__( 'left', 'post-carousel' ), | |
| 50 | - 'all_placeholder' => esc_html__( 'all', 'post-carousel' ), | |
| 27 | + 'top_placeholder' => esc_html__( 'top', 'smart-post-show' ), | |
| 28 | + 'right_placeholder' => esc_html__( 'right', 'smart-post-show' ), | |
| 29 | + 'bottom_placeholder' => esc_html__( 'bottom', 'smart-post-show' ), | |
| 30 | + 'left_placeholder' => esc_html__( 'left', 'smart-post-show' ), | |
| 31 | + 'all_placeholder' => esc_html__( 'all', 'smart-post-show' ), | |
| 51 | 32 | 'top' => true, |
| 52 | 33 | 'left' => true, |
| 53 | 34 | 'bottom' => true, |
| 54 | 35 | 'right' => true, |
| @@ -71,17 +52,17 @@ | ||
| 71 | 52 | 'min' => '', |
| 72 | 53 | ); |
| 73 | 54 | |
| 74 | 55 | $border_props = array( |
| 75 | - 'solid' => esc_html__( 'Solid', 'post-carousel' ), | |
| 76 | - 'dashed' => esc_html__( 'Dashed', 'post-carousel' ), | |
| 77 | - 'dotted' => esc_html__( 'Dotted', 'post-carousel' ), | |
| 78 | - 'double' => esc_html__( 'Double', 'post-carousel' ), | |
| 79 | - 'inset' => esc_html__( 'Inset', 'post-carousel' ), | |
| 80 | - 'outset' => esc_html__( 'Outset', 'post-carousel' ), | |
| 81 | - 'groove' => esc_html__( 'Groove', 'post-carousel' ), | |
| 82 | - 'ridge' => esc_html__( 'ridge', 'post-carousel' ), | |
| 83 | - 'none' => esc_html__( 'None', 'post-carousel' ), | |
| 56 | + 'solid' => esc_html__( 'Solid', 'smart-post-show' ), | |
| 57 | + 'dashed' => esc_html__( 'Dashed', 'smart-post-show' ), | |
| 58 | + 'dotted' => esc_html__( 'Dotted', 'smart-post-show' ), | |
| 59 | + 'double' => esc_html__( 'Double', 'smart-post-show' ), | |
| 60 | + 'inset' => esc_html__( 'Inset', 'smart-post-show' ), | |
| 61 | + 'outset' => esc_html__( 'Outset', 'smart-post-show' ), | |
| 62 | + 'groove' => esc_html__( 'Groove', 'smart-post-show' ), | |
| 63 | + 'ridge' => esc_html__( 'ridge', 'smart-post-show' ), | |
| 64 | + 'none' => esc_html__( 'None', 'smart-post-show' ), | |
| 84 | 65 | ); |
| 85 | 66 | |
| 86 | 67 | $default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value; |
| 87 | 68 | |
| @@ -86,9 +67,9 @@ | ||
| 86 | 67 | $default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value; |
| 87 | 68 | |
| 88 | 69 | $value = wp_parse_args( $this->value, $default_value ); |
| 89 | 70 | |
| 90 | - echo wp_kses_post( $this->field_before() ); | |
| 71 | + echo $this->field_before(); | |
| 91 | 72 | |
| 92 | 73 | echo '<div class="spf--inputs">'; |
| 93 | 74 | $min = ( isset( $args['min'] ) ) ? ' min="' . $args['min'] . '"' : ''; |
| 94 | 75 | |
| @@ -96,11 +77,11 @@ | ||
| 96 | 77 | |
| 97 | 78 | $placeholder = ( ! empty( $args['all_placeholder'] ) ) ? ' placeholder="' . $args['all_placeholder'] . '"' : ''; |
| 98 | 79 | |
| 99 | 80 | echo '<div class="spf--input">'; |
| 100 | - echo ( ! empty( $args['all_icon'] ) ) ? '<span class="spf--label spf--icon">' . wp_kses_post( $args['all_icon'] ) . '</span>' : ''; | |
| 101 | - echo '<input type="number" name="' . esc_attr( $this->field_name( '[all]' ) ) . '" value="' . esc_attr( $value['all'] ) . '"' . wp_kses_post( $placeholder ) . wp_kses_post( $min ) . ' class="spf-input-number spf--is-unit" />'; | |
| 102 | - echo ( ! empty( $args['unit'] ) ) ? '<span class="spf--label spf--unit">' . esc_html( $args['unit'] ) . '</span>' : ''; | |
| 81 | + echo ( ! empty( $args['all_icon'] ) ) ? '<span class="spf--label spf--icon">' . $args['all_icon'] . '</span>' : ''; | |
| 82 | + echo '<input type="number" name="' . $this->field_name( '[all]' ) . '" value="' . $value['all'] . '"' . $placeholder . $min . ' class="spf-input-number spf--is-unit" />'; | |
| 83 | + echo ( ! empty( $args['unit'] ) ) ? '<span class="spf--label spf--unit">' . $args['unit'] . '</span>' : ''; | |
| 103 | 84 | echo '</div>'; |
| 104 | 85 | |
| 105 | 86 | } else { |
| 106 | 87 | |
| @@ -111,9 +92,9 @@ | ||
| 111 | 92 | $properties[] = $prop; |
| 112 | 93 | } |
| 113 | 94 | } |
| 114 | 95 | |
| 115 | - $properties = ( array( 'right', 'left' ) === $properties ) ? array_reverse( $properties ) : $properties; | |
| 96 | + $properties = ( $properties === array( 'right', 'left' ) ) ? array_reverse( $properties ) : $properties; | |
| 116 | 97 | |
| 117 | 98 | foreach ( $properties as $property ) { |
| 118 | 99 | |
| 119 | 100 | $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . $args[ $property . '_placeholder' ] . '"' : ''; |
| @@ -118,11 +99,11 @@ | ||
| 118 | 99 | |
| 119 | 100 | $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . $args[ $property . '_placeholder' ] . '"' : ''; |
| 120 | 101 | |
| 121 | 102 | echo '<div class="spf--input">'; |
| 122 | - echo ( ! empty( $args[ $property . '_icon' ] ) ) ? '<span class="spf--label spf--icon">' . wp_kses_post( $args[ $property . '_icon' ] ) . '</span>' : ''; | |
| 123 | - echo '<input type="number" name="' . esc_attr( $this->field_name( '[' . $property . ']' ) ) . '" value="' . esc_attr( $value[ $property ] ) . '"' . wp_kses_post( $placeholder . $min ) . ' class="spf-input-number spf--is-unit" />'; | |
| 124 | - echo ( ! empty( $args['unit'] ) ) ? '<span class="spf--label spf--unit">' . esc_html( $args['unit'] ) . '</span>' : ''; | |
| 103 | + echo ( ! empty( $args[ $property . '_icon' ] ) ) ? '<span class="spf--label spf--icon">' . $args[ $property . '_icon' ] . '</span>' : ''; | |
| 104 | + echo '<input type="number" name="' . $this->field_name( '[' . $property . ']' ) . '" value="' . $value[ $property ] . '"' . $placeholder . $min . ' class="spf-input-number spf--is-unit" />'; | |
| 105 | + echo ( ! empty( $args['unit'] ) ) ? '<span class="spf--label spf--unit">' . $args['unit'] . '</span>' : ''; | |
| 125 | 106 | echo '</div>'; |
| 126 | 107 | |
| 127 | 108 | } |
| 128 | 109 | } |
| @@ -128,12 +109,12 @@ | ||
| 128 | 109 | } |
| 129 | 110 | |
| 130 | 111 | if ( ! empty( $args['style'] ) ) { |
| 131 | 112 | echo '<div class="spf--input">'; |
| 132 | - echo '<select name="' . esc_attr( $this->field_name( '[style]' ) ) . '">'; | |
| 113 | + echo '<select name="' . $this->field_name( '[style]' ) . '">'; | |
| 133 | 114 | foreach ( $border_props as $border_prop_key => $border_prop_value ) { |
| 134 | 115 | $selected = ( $value['style'] === $border_prop_key ) ? ' selected' : ''; |
| 135 | - echo '<option value="' . esc_attr( $border_prop_key ) . '"' . esc_attr( $selected ) . '>' . esc_html( $border_prop_value ) . '</option>'; | |
| 116 | + echo '<option value="' . $border_prop_key . '"' . $selected . '>' . $border_prop_value . '</option>'; | |
| 136 | 117 | } |
| 137 | 118 | echo '</select>'; |
| 138 | 119 | echo '</div>'; |
| 139 | 120 | } |
| @@ -141,9 +122,9 @@ | ||
| 141 | 122 | if ( ! empty( $args['color'] ) ) { |
| 142 | 123 | $default_color_attr = ( ! empty( $default_value['color'] ) ) ? ' data-default-color="' . $default_value['color'] . '"' : ''; |
| 143 | 124 | echo '<div class="spf--color">'; |
| 144 | 125 | echo '<div class="spf-field-color">'; |
| 145 | - echo '<input type="text" name="' . esc_attr( $this->field_name( '[color]' ) ) . '" value="' . esc_attr( $value['color'] ) . '" class="spf-color"' . wp_kses_post( $default_color_attr ) . ' />'; | |
| 126 | + echo '<input type="text" name="' . $this->field_name( '[color]' ) . '" value="' . $value['color'] . '" class="spf-color"' . $default_color_attr . ' />'; | |
| 146 | 127 | echo '</div>'; |
| 147 | 128 | echo '</div>'; |
| 148 | 129 | } |
| 149 | 130 | |
| @@ -148,17 +129,12 @@ | ||
| 148 | 129 | } |
| 149 | 130 | |
| 150 | 131 | echo '<div class="clear"></div>'; |
| 151 | 132 | |
| 152 | - echo wp_kses_post( $this->field_after() ); | |
| 133 | + echo $this->field_after(); | |
| 153 | 134 | |
| 154 | 135 | } |
| 155 | 136 | |
| 156 | - /** | |
| 157 | - * Output method. | |
| 158 | - * | |
| 159 | - * @return mixed | |
| 160 | - */ | |
| 161 | 137 | public function output() { |
| 162 | 138 | |
| 163 | 139 | $output = ''; |
| 164 | 140 | $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px'; |
| @@ -164,34 +140,34 @@ | ||
| 164 | 140 | $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px'; |
| 165 | 141 | $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : ''; |
| 166 | 142 | $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output']; |
| 167 | 143 | |
| 168 | - // properties. | |
| 169 | - $top = ( isset( $this->value['top'] ) && $this->value['top'] ) ? $this->value['top'] : ''; | |
| 170 | - $right = ( isset( $this->value['right'] ) && $this->value['right'] ) ? $this->value['right'] : ''; | |
| 171 | - $bottom = ( isset( $this->value['bottom'] ) && $this->value['bottom'] ) ? $this->value['bottom'] : ''; | |
| 172 | - $left = ( isset( $this->value['left'] ) && $this->value['left'] ) ? $this->value['left'] : ''; | |
| 173 | - $style = ( isset( $this->value['style'] ) && $this->value['style'] ) ? $this->value['style'] : ''; | |
| 174 | - $color = ( isset( $this->value['color'] ) && $this->value['color'] ) ? $this->value['color'] : ''; | |
| 175 | - $all = ( isset( $this->value['all'] ) && $this->value['all'] ) ? $this->value['all'] : ''; | |
| 144 | + // properties | |
| 145 | + $top = ( isset( $this->value['top'] ) && $this->value['top'] !== '' ) ? $this->value['top'] : ''; | |
| 146 | + $right = ( isset( $this->value['right'] ) && $this->value['right'] !== '' ) ? $this->value['right'] : ''; | |
| 147 | + $bottom = ( isset( $this->value['bottom'] ) && $this->value['bottom'] !== '' ) ? $this->value['bottom'] : ''; | |
| 148 | + $left = ( isset( $this->value['left'] ) && $this->value['left'] !== '' ) ? $this->value['left'] : ''; | |
| 149 | + $style = ( isset( $this->value['style'] ) && $this->value['style'] !== '' ) ? $this->value['style'] : ''; | |
| 150 | + $color = ( isset( $this->value['color'] ) && $this->value['color'] !== '' ) ? $this->value['color'] : ''; | |
| 151 | + $all = ( isset( $this->value['all'] ) && $this->value['all'] !== '' ) ? $this->value['all'] : ''; | |
| 176 | 152 | |
| 177 | - if ( ! empty( $this->field['all'] ) && ( $all || $color ) ) { | |
| 153 | + if ( ! empty( $this->field['all'] ) && ( $all !== '' || $color !== '' ) ) { | |
| 178 | 154 | |
| 179 | 155 | $output = $element . '{'; |
| 180 | - $output .= ( '' !== $all ) ? 'border-width:' . $all . $unit . $important . ';' : ''; | |
| 181 | - $output .= ( '' !== $color ) ? 'border-color:' . $color . $important . ';' : ''; | |
| 182 | - $output .= ( '' !== $style ) ? 'border-style:' . $style . $important . ';' : ''; | |
| 156 | + $output .= ( $all !== '' ) ? 'border-width:' . $all . $unit . $important . ';' : ''; | |
| 157 | + $output .= ( $color !== '' ) ? 'border-color:' . $color . $important . ';' : ''; | |
| 158 | + $output .= ( $style !== '' ) ? 'border-style:' . $style . $important . ';' : ''; | |
| 183 | 159 | $output .= '}'; |
| 184 | 160 | |
| 185 | - } elseif ( '' !== $top || '' !== $right || '' !== $bottom || '' !== $left || '' !== $color ) { | |
| 161 | + } elseif ( $top !== '' || $right !== '' || $bottom !== '' || $left !== '' || $color !== '' ) { | |
| 186 | 162 | |
| 187 | 163 | $output = $element . '{'; |
| 188 | - $output .= ( '' !== $top ) ? 'border-top-width:' . $top . $unit . $important . ';' : ''; | |
| 189 | - $output .= ( '' !== $right ) ? 'border-right-width:' . $right . $unit . $important . ';' : ''; | |
| 190 | - $output .= ( '' !== $bottom ) ? 'border-bottom-width:' . $bottom . $unit . $important . ';' : ''; | |
| 191 | - $output .= ( '' !== $left ) ? 'border-left-width:' . $left . $unit . $important . ';' : ''; | |
| 192 | - $output .= ( '' !== $color ) ? 'border-color:' . $color . $important . ';' : ''; | |
| 193 | - $output .= ( '' !== $style ) ? 'border-style:' . $style . $important . ';' : ''; | |
| 164 | + $output .= ( $top !== '' ) ? 'border-top-width:' . $top . $unit . $important . ';' : ''; | |
| 165 | + $output .= ( $right !== '' ) ? 'border-right-width:' . $right . $unit . $important . ';' : ''; | |
| 166 | + $output .= ( $bottom !== '' ) ? 'border-bottom-width:' . $bottom . $unit . $important . ';' : ''; | |
| 167 | + $output .= ( $left !== '' ) ? 'border-left-width:' . $left . $unit . $important . ';' : ''; | |
| 168 | + $output .= ( $color !== '' ) ? 'border-color:' . $color . $important . ';' : ''; | |
| 169 | + $output .= ( $style !== '' ) ? 'border-style:' . $style . $important . ';' : ''; | |
| 194 | 170 | $output .= '}'; |
| 195 | 171 | |
| 196 | 172 | } |
| 197 | 173 | |