PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 2.4.2
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v2.4.2
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / admin / views / sp-framework / fields / box_shadow / box_shadow.php

box_shadow.php in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 2.4.2, at admin/views/sp-framework/fields/box_shadow/box_shadow.php

140 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) {
2 die; } // Cannot access directly.
3 /**
4 *
5 * Field: border
6 *
7 * @since 2.0
8 * @version 2.0
9 */
10 if ( ! class_exists( 'SP_PC_Field_box_shadow' ) ) {
11 class SP_PC_Field_box_shadow extends SP_PC_Fields {
12
13 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 parent::__construct( $field, $value, $unique, $where, $parent );
15 }
16
17 public function render() {
18
19 $args = wp_parse_args(
20 $this->field,
21 array(
22 'horizontal_icon' => __( 'X offset', 'smart-post-show' ),
23 'vertical_icon' => __( 'Y offset', 'smart-post-show' ),
24 'blur_icon' => __( 'Blur', 'smart-post-show' ),
25 'spread_icon' => __( 'Spread', 'smart-post-show' ),
26 'horizontal_placeholder' => 'h-offset',
27 'vertical_placeholder' => 'v-offset',
28 'blur_placeholder' => 'blur',
29 'spread_placeholder' => 'spread',
30 'horizontal' => true,
31 'vertical' => true,
32 'blur' => true,
33 'spread' => true,
34 'color' => true,
35 'style' => true,
36 'unit' => 'px',
37 )
38 );
39
40 $default_value = array(
41 'horizontal' => '0',
42 'vertical' => '0',
43 'blur' => '0',
44 'spread' => '0',
45 'color' => '#ddd',
46 'style' => 'outset',
47 );
48
49 $default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value;
50
51 $value = wp_parse_args( $this->value, $default_value );
52
53 echo wp_kses_post( $this->field_before() );
54
55 echo '<div class="spf--inputs">';
56
57 $properties = array();
58
59 foreach ( array( 'horizontal', 'vertical', 'blur', 'spread' ) as $prop ) {
60 if ( ! empty( $args[ $prop ] ) ) {
61 $properties[] = $prop;
62 }
63 }
64
65 foreach ( $properties as $property ) {
66
67 $placeholder = ( ! empty( $args[ $property . '_placeholder' ] ) ) ? ' placeholder="' . $args[ $property . '_placeholder' ] . '"' : '';
68
69 echo '<div class="spf--input">';
70 echo ( ! empty( $args[ $property . '_icon' ] ) ) ? '<span class="spf--label spf--icon">' . wp_kses_post( $args[ $property . '_icon' ] ) . '</span>' : '';
71 echo '<input type="number" name="' . esc_attr( $this->field_name( '[' . $property . ']' ) ) . '" value="' . esc_attr( $value[ $property ] ) . '"' . wp_kses_post( $placeholder ) . ' class="spf-input-number spf--is-unit" />';
72 echo ( ! empty( $args['unit'] ) ) ? '<span class="spf--label spf--unit">' . esc_html( $args['unit'] ) . '</span>' : '';
73 echo '</div>';
74
75 }
76
77 if ( ! empty( $args['style'] ) ) {
78 echo '<div class="spf--input">';
79 echo '<select name="' . esc_attr( $this->field_name( '[style]' ) ) . '">';
80 foreach ( array( 'inset', 'outset' ) as $style ) {
81 $selected = ( $value['style'] === $style ) ? ' selected' : '';
82 echo '<option value="' . esc_attr( $style ) . '"' . esc_attr( $selected ) . '>' . esc_html( ucfirst( $style ) ) . '</option>';
83 }
84 echo '</select>';
85 echo '</div>';
86 }
87
88 echo '</div>';
89
90 if ( ! empty( $args['color'] ) ) {
91 $default_color_attr = ( ! empty( $default_value['color'] ) ) ? ' data-default-color="' . $default_value['color'] . '"' : '';
92 echo '<div class="spf-field-color">';
93 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 ) . ' />';
94 echo '</div>';
95 }
96
97 echo '<div class="clear"></div>';
98
99 echo wp_kses_post( $this->field_after() );
100
101 }
102
103 /**
104 * The output function
105 *
106 * @return mixed
107 */
108 public function output() {
109
110 $output = '';
111 $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
112 $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
113 $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
114
115 // properties.
116 $horizontal = ( isset( $this->value['horizontal'] ) && '' !== $this->value['horizontal'] ) ? $this->value['horizontal'] : '';
117 $vertical = ( isset( $this->value['vertical'] ) && '' !== $this->value['vertical'] ) ? $this->value['vertical'] : '';
118 $blur = ( isset( $this->value['blur'] ) && '' !== $this->value['blur'] ) ? $this->value['blur'] : '';
119 $spread = ( isset( $this->value['spread'] ) && '' !== $this->value['spread'] ) ? $this->value['spread'] : '';
120 $style = ( isset( $this->value['style'] ) && '' !== $this->value['style'] && 'outset' !== $this->value['style'] ) ? $this->value['style'] : '';
121 $color = ( isset( $this->value['color'] ) && '' !== $this->value['color'] ) ? $this->value['color'] : '';
122
123 $output = $element . '{ box-shadow: ';
124 $output .= ( '' !== $horizontal ) ? $horizontal . $unit : '0' . $unit;
125 $output .= ( '' !== $vertical ) ? $vertical . $unit : '0' . $unit;
126 $output .= ( '' !== $blur ) ? $blur . $unit : '0' . $unit;
127 $output .= ( '' !== $spread ) ? $spread . $unit : '0' . $unit;
128 $output .= ( '' !== $color ) ? $color : '';
129 $output .= ( '' !== $style ) ? $style : '';
130 $output .= ';' . $important . ' }';
131
132 $this->parent->output_css .= $output;
133
134 return $output;
135
136 }
137
138 }
139 }
140