PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.2.4.1
Adminify – White Label, Admin Menu Editor, Login Customizer v3.2.4.1
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
← All changes | Libs/adminify-framework/fields/background/background.php +316 -285 4.2.113.2.4.1 View file →
@@ -1,5 +1,6 @@
1 -<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
1 +<?php if ( ! defined( 'ABSPATH' ) ) {
2 + die; } // Cannot access directly.
2 3 /**
3 4 *
4 5 * Field: background
5 6 *
@@ -4,337 +5,367 @@
4 5 * Field: background
5 6 *
6 7 * @since 1.0.0
7 8 * @version 1.0.0
8 - *
9 9 */
10 10 if ( ! class_exists( 'ADMINIFY_Field_background' ) ) {
11 - class ADMINIFY_Field_background extends ADMINIFY_Fields {
11 + class ADMINIFY_Field_background extends ADMINIFY_Fields {
12 12
13 - public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 - parent::__construct( $field, $value, $unique, $where, $parent );
15 - }
13 + public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
14 + parent::__construct( $field, $value, $unique, $where, $parent );
15 + }
16 16
17 - public function render() {
17 + public function render() {
18 + $args = wp_parse_args(
19 + $this->field,
20 + [
21 + 'background_color' => true,
22 + 'background_image' => true,
23 + 'background_position' => true,
24 + 'background_repeat' => true,
25 + 'background_attachment' => true,
26 + 'background_size' => true,
27 + 'background_origin' => false,
28 + 'background_clip' => false,
29 + 'background_blend_mode' => false,
30 + 'background_gradient' => false,
31 + 'background_gradient_color' => true,
32 + 'background_gradient_direction' => true,
33 + 'background_image_preview' => true,
34 + 'background_auto_attributes' => false,
35 + 'compact' => false,
36 + 'background_image_library' => 'image',
37 + 'background_image_placeholder' => esc_html__( 'Not selected', 'adminify' ),
38 + ]
39 + );
18 40
19 - $args = wp_parse_args( $this->field, array(
20 - 'background_color' => true,
21 - 'background_image' => true,
22 - 'background_position' => true,
23 - 'background_repeat' => true,
24 - 'background_attachment' => true,
25 - 'background_size' => true,
26 - 'background_origin' => false,
27 - 'background_clip' => false,
28 - 'background_blend_mode' => false,
29 - 'background_gradient' => false,
30 - 'background_gradient_color' => true,
31 - 'background_gradient_direction' => true,
32 - 'background_image_preview' => true,
33 - 'background_auto_attributes' => false,
34 - 'compact' => false,
35 - 'background_image_library' => 'image',
36 - 'background_image_placeholder' => esc_html__( 'Not selected', 'adminify' ),
37 - ) );
41 + if ( $args['compact'] ) {
42 + $args['background_color'] = false;
43 + $args['background_auto_attributes'] = true;
44 + }
38 45
39 - if ( $args['compact'] ) {
40 - $args['background_color'] = false;
41 - $args['background_auto_attributes'] = true;
42 - }
46 + $default_value = [
47 + 'background-color' => '',
48 + 'background-image' => '',
49 + 'background-position' => '',
50 + 'background-repeat' => '',
51 + 'background-attachment' => '',
52 + 'background-size' => '',
53 + 'background-origin' => '',
54 + 'background-clip' => '',
55 + 'background-blend-mode' => '',
56 + 'background-gradient-color' => '',
57 + 'background-gradient-direction' => '',
58 + ];
43 59
44 - $default_value = array(
45 - 'background-color' => '',
46 - 'background-image' => '',
47 - 'background-position' => '',
48 - 'background-repeat' => '',
49 - 'background-attachment' => '',
50 - 'background-size' => '',
51 - 'background-origin' => '',
52 - 'background-clip' => '',
53 - 'background-blend-mode' => '',
54 - 'background-gradient-color' => '',
55 - 'background-gradient-direction' => '',
56 - );
60 + $default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value;
57 61
58 - $default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value;
62 + $this->value = wp_parse_args( $this->value, $default_value );
59 63
60 - $this->value = wp_parse_args( $this->value, $default_value );
64 + echo wp_kses_post( $this->field_before() );
61 65
62 - echo wp_kses_post( $this->field_before() );
66 + echo '<div class="adminify--background-colors">';
63 67
64 - echo '<div class="adminify--background-colors">';
68 + //
69 + // Background Color
70 + if ( ! empty( $args['background_color'] ) ) {
71 + echo '<div class="adminify--color">';
65 72
66 - //
67 - // Background Color
68 - if ( ! empty( $args['background_color'] ) ) {
73 + echo ( ! empty( $args['background_gradient'] ) ) ? '<div class="adminify--title">' . esc_html__( 'From', 'adminify' ) . '</div>' : '';
69 74
70 - echo '<div class="adminify--color">';
75 + ADMINIFY::field(
76 + [
77 + 'id' => 'background-color',
78 + 'type' => 'color',
79 + 'default' => $default_value['background-color'],
80 + ],
81 + $this->value['background-color'],
82 + $this->field_name(),
83 + 'field/background'
84 + );
71 85
72 - echo ( ! empty( $args['background_gradient'] ) ) ? '<div class="adminify--title">'. esc_html__( 'From', 'adminify' ) .'</div>' : '';
86 + echo '</div>';
87 + }
73 88
74 - ADMINIFY::field( array(
75 - 'id' => 'background-color',
76 - 'type' => 'color',
77 - 'default' => $default_value['background-color'],
78 - ), $this->value['background-color'], $this->field_name(), 'field/background' );
89 + //
90 + // Background Gradient Color
91 + if ( ! empty( $args['background_gradient_color'] ) && ! empty( $args['background_gradient'] ) ) {
92 + echo '<div class="adminify--color">';
79 93
80 - echo '</div>';
94 + echo ( ! empty( $args['background_gradient'] ) ) ? '<div class="adminify--title">' . esc_html__( 'To', 'adminify' ) . '</div>' : '';
81 95
82 - }
96 + ADMINIFY::field(
97 + [
98 + 'id' => 'background-gradient-color',
99 + 'type' => 'color',
100 + 'default' => $default_value['background-gradient-color'],
101 + ],
102 + $this->value['background-gradient-color'],
103 + $this->field_name(),
104 + 'field/background'
105 + );
83 106
84 - //
85 - // Background Gradient Color
86 - if ( ! empty( $args['background_gradient_color'] ) && ! empty( $args['background_gradient'] ) ) {
107 + echo '</div>';
108 + }
87 109
88 - echo '<div class="adminify--color">';
110 + //
111 + // Background Gradient Direction
112 + if ( ! empty( $args['background_gradient_direction'] ) && ! empty( $args['background_gradient'] ) ) {
113 + echo '<div class="adminify--color">';
89 114
90 - echo ( ! empty( $args['background_gradient'] ) ) ? '<div class="adminify--title">'. esc_html__( 'To', 'adminify' ) .'</div>' : '';
115 + echo ( ! empty( $args['background_gradient'] ) ) ? '<div class="adminify---title">' . esc_html__( 'Direction', 'adminify' ) . '</div>' : '';
91 116
92 - ADMINIFY::field( array(
93 - 'id' => 'background-gradient-color',
94 - 'type' => 'color',
95 - 'default' => $default_value['background-gradient-color'],
96 - ), $this->value['background-gradient-color'], $this->field_name(), 'field/background' );
117 + ADMINIFY::field(
118 + [
119 + 'id' => 'background-gradient-direction',
120 + 'type' => 'select',
121 + 'options' => [
122 + '' => esc_html__( 'Gradient Direction', 'adminify' ),
123 + 'to bottom' => esc_html__( '&#8659; top to bottom', 'adminify' ),
124 + 'to right' => esc_html__( '&#8658; left to right', 'adminify' ),
125 + '135deg' => esc_html__( '&#8664; corner top to right', 'adminify' ),
126 + '-135deg' => esc_html__( '&#8665; corner top to left', 'adminify' ),
127 + ],
128 + ],
129 + $this->value['background-gradient-direction'],
130 + $this->field_name(),
131 + 'field/background'
132 + );
97 133
98 - echo '</div>';
134 + echo '</div>';
135 + }
99 136
100 - }
137 + echo '</div>';
101 138
102 - //
103 - // Background Gradient Direction
104 - if ( ! empty( $args['background_gradient_direction'] ) && ! empty( $args['background_gradient'] ) ) {
139 + //
140 + // Background Image
141 + if ( ! empty( $args['background_image'] ) ) {
142 + echo '<div class="adminify--background-image">';
105 143
106 - echo '<div class="adminify--color">';
144 + ADMINIFY::field(
145 + [
146 + 'id' => 'background-image',
147 + 'type' => 'media',
148 + 'class' => 'adminify-assign-field-background',
149 + 'library' => $args['background_image_library'],
150 + 'preview' => $args['background_image_preview'],
151 + 'placeholder' => $args['background_image_placeholder'],
152 + 'attributes' => [ 'data-depend-id' => $this->field['id'] ],
153 + ],
154 + $this->value['background-image'],
155 + $this->field_name(),
156 + 'field/background'
157 + );
107 158
108 - echo ( ! empty( $args['background_gradient'] ) ) ? '<div class="adminify---title">'. esc_html__( 'Direction', 'adminify' ) .'</div>' : '';
159 + echo '</div>';
160 + }
109 161
110 - ADMINIFY::field( array(
111 - 'id' => 'background-gradient-direction',
112 - 'type' => 'select',
113 - 'options' => array(
114 - '' => esc_html__( 'Gradient Direction', 'adminify' ),
115 - 'to bottom' => esc_html__( '&#8659; top to bottom', 'adminify' ),
116 - 'to right' => esc_html__( '&#8658; left to right', 'adminify' ),
117 - '135deg' => esc_html__( '&#8664; corner top to right', 'adminify' ),
118 - '-135deg' => esc_html__( '&#8665; corner top to left', 'adminify' ),
119 - ),
120 - ), $this->value['background-gradient-direction'], $this->field_name(), 'field/background' );
162 + $auto_class = ( ! empty( $args['background_auto_attributes'] ) ) ? ' adminify--auto-attributes' : '';
163 + $hidden_class = ( ! empty( $args['background_auto_attributes'] ) && empty( $this->value['background-image']['url'] ) ) ? ' adminify--attributes-hidden' : '';
121 164
122 - echo '</div>';
165 + echo '<div class="adminify--background-attributes' . esc_attr( $auto_class . $hidden_class ) . '">';
123 166
124 - }
167 + //
168 + // Background Position
169 + if ( ! empty( $args['background_position'] ) ) {
170 + ADMINIFY::field(
171 + [
172 + 'id' => 'background-position',
173 + 'type' => 'select',
174 + 'options' => [
175 + '' => esc_html__( 'Background Position', 'adminify' ),
176 + 'left top' => esc_html__( 'Left Top', 'adminify' ),
177 + 'left center' => esc_html__( 'Left Center', 'adminify' ),
178 + 'left bottom' => esc_html__( 'Left Bottom', 'adminify' ),
179 + 'center top' => esc_html__( 'Center Top', 'adminify' ),
180 + 'center center' => esc_html__( 'Center Center', 'adminify' ),
181 + 'center bottom' => esc_html__( 'Center Bottom', 'adminify' ),
182 + 'right top' => esc_html__( 'Right Top', 'adminify' ),
183 + 'right center' => esc_html__( 'Right Center', 'adminify' ),
184 + 'right bottom' => esc_html__( 'Right Bottom', 'adminify' ),
185 + ],
186 + ],
187 + $this->value['background-position'],
188 + $this->field_name(),
189 + 'field/background'
190 + );
191 + }
125 192
126 - echo '</div>';
193 + //
194 + // Background Repeat
195 + if ( ! empty( $args['background_repeat'] ) ) {
196 + ADMINIFY::field(
197 + [
198 + 'id' => 'background-repeat',
199 + 'type' => 'select',
200 + 'options' => [
201 + '' => esc_html__( 'Background Repeat', 'adminify' ),
202 + 'repeat' => esc_html__( 'Repeat', 'adminify' ),
203 + 'no-repeat' => esc_html__( 'No Repeat', 'adminify' ),
204 + 'repeat-x' => esc_html__( 'Repeat Horizontally', 'adminify' ),
205 + 'repeat-y' => esc_html__( 'Repeat Vertically', 'adminify' ),
206 + ],
207 + ],
208 + $this->value['background-repeat'],
209 + $this->field_name(),
210 + 'field/background'
211 + );
212 + }
127 213
128 - //
129 - // Background Image
130 - if ( ! empty( $args['background_image'] ) ) {
214 + //
215 + // Background Attachment
216 + if ( ! empty( $args['background_attachment'] ) ) {
217 + ADMINIFY::field(
218 + [
219 + 'id' => 'background-attachment',
220 + 'type' => 'select',
221 + 'options' => [
222 + '' => esc_html__( 'Background Attachment', 'adminify' ),
223 + 'scroll' => esc_html__( 'Scroll', 'adminify' ),
224 + 'fixed' => esc_html__( 'Fixed', 'adminify' ),
225 + ],
226 + ],
227 + $this->value['background-attachment'],
228 + $this->field_name(),
229 + 'field/background'
230 + );
231 + }
131 232
132 - echo '<div class="adminify--background-image">';
233 + //
234 + // Background Size
235 + if ( ! empty( $args['background_size'] ) ) {
236 + ADMINIFY::field(
237 + [
238 + 'id' => 'background-size',
239 + 'type' => 'select',
240 + 'options' => [
241 + '' => esc_html__( 'Background Size', 'adminify' ),
242 + 'cover' => esc_html__( 'Cover', 'adminify' ),
243 + 'contain' => esc_html__( 'Contain', 'adminify' ),
244 + 'auto' => esc_html__( 'Auto', 'adminify' ),
245 + ],
246 + ],
247 + $this->value['background-size'],
248 + $this->field_name(),
249 + 'field/background'
250 + );
251 + }
133 252
134 - ADMINIFY::field( array(
135 - 'id' => 'background-image',
136 - 'type' => 'media',
137 - 'class' => 'adminify-assign-field-background adminify-one-col',
138 - 'library' => $args['background_image_library'],
139 - 'preview' => $args['background_image_preview'],
140 - 'placeholder' => $args['background_image_placeholder'],
141 - 'attributes' => array( 'data-depend-id' => $this->field['id'] ),
142 - ), $this->value['background-image'], $this->field_name(), 'field/background' );
253 + //
254 + // Background Origin
255 + if ( ! empty( $args['background_origin'] ) ) {
256 + ADMINIFY::field(
257 + [
258 + 'id' => 'background-origin',
259 + 'type' => 'select',
260 + 'options' => [
261 + '' => esc_html__( 'Background Origin', 'adminify' ),
262 + 'padding-box' => esc_html__( 'Padding Box', 'adminify' ),
263 + 'border-box' => esc_html__( 'Border Box', 'adminify' ),
264 + 'content-box' => esc_html__( 'Content Box', 'adminify' ),
265 + ],
266 + ],
267 + $this->value['background-origin'],
268 + $this->field_name(),
269 + 'field/background'
270 + );
271 + }
143 272
144 - echo '</div>';
273 + //
274 + // Background Clip
275 + if ( ! empty( $args['background_clip'] ) ) {
276 + ADMINIFY::field(
277 + [
278 + 'id' => 'background-clip',
279 + 'type' => 'select',
280 + 'options' => [
281 + '' => esc_html__( 'Background Clip', 'adminify' ),
282 + 'border-box' => esc_html__( 'Border Box', 'adminify' ),
283 + 'padding-box' => esc_html__( 'Padding Box', 'adminify' ),
284 + 'content-box' => esc_html__( 'Content Box', 'adminify' ),
285 + ],
286 + ],
287 + $this->value['background-clip'],
288 + $this->field_name(),
289 + 'field/background'
290 + );
291 + }
145 292
146 - }
293 + //
294 + // Background Blend Mode
295 + if ( ! empty( $args['background_blend_mode'] ) ) {
296 + ADMINIFY::field(
297 + [
298 + 'id' => 'background-blend-mode',
299 + 'type' => 'select',
300 + 'options' => [
301 + '' => esc_html__( 'Background Blend Mode', 'adminify' ),
302 + 'normal' => esc_html__( 'Normal', 'adminify' ),
303 + 'multiply' => esc_html__( 'Multiply', 'adminify' ),
304 + 'screen' => esc_html__( 'Screen', 'adminify' ),
305 + 'overlay' => esc_html__( 'Overlay', 'adminify' ),
306 + 'darken' => esc_html__( 'Darken', 'adminify' ),
307 + 'lighten' => esc_html__( 'Lighten', 'adminify' ),
308 + 'color-dodge' => esc_html__( 'Color Dodge', 'adminify' ),
309 + 'saturation' => esc_html__( 'Saturation', 'adminify' ),
310 + 'color' => esc_html__( 'Color', 'adminify' ),
311 + 'luminosity' => esc_html__( 'Luminosity', 'adminify' ),
312 + ],
313 + ],
314 + $this->value['background-blend-mode'],
315 + $this->field_name(),
316 + 'field/background'
317 + );
318 + }
147 319
148 - $auto_class = ( ! empty( $args['background_auto_attributes'] ) ) ? ' adminify--auto-attributes' : '';
149 - $hidden_class = ( ! empty( $args['background_auto_attributes'] ) && empty( $this->value['background-image']['url'] ) ) ? ' adminify--attributes-hidden' : '';
320 + echo '</div>';
150 321
151 - echo '<div class="adminify--background-attributes'. esc_attr( $auto_class . $hidden_class ) .'">';
322 + echo wp_kses_post( $this->field_after() );
323 + }
152 324
153 - //
154 - // Background Position
155 - if ( ! empty( $args['background_position'] ) ) {
325 + public function output() {
326 + $output = '';
327 + $bg_image = [];
328 + $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
329 + $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
156 330
157 - ADMINIFY::field( array(
158 - 'id' => 'background-position',
159 - 'type' => 'select',
160 - 'options' => array(
161 - '' => esc_html__( 'Background Position', 'adminify' ),
162 - 'left top' => esc_html__( 'Left Top', 'adminify' ),
163 - 'left center' => esc_html__( 'Left Center', 'adminify' ),
164 - 'left bottom' => esc_html__( 'Left Bottom', 'adminify' ),
165 - 'center top' => esc_html__( 'Center Top', 'adminify' ),
166 - 'center center' => esc_html__( 'Center Center', 'adminify' ),
167 - 'center bottom' => esc_html__( 'Center Bottom', 'adminify' ),
168 - 'right top' => esc_html__( 'Right Top', 'adminify' ),
169 - 'right center' => esc_html__( 'Right Center', 'adminify' ),
170 - 'right bottom' => esc_html__( 'Right Bottom', 'adminify' ),
171 - ),
172 - ), $this->value['background-position'], $this->field_name(), 'field/background' );
331 + // Background image and gradient
332 + $background_color = ( ! empty( $this->value['background-color'] ) ) ? $this->value['background-color'] : '';
333 + $background_gd_color = ( ! empty( $this->value['background-gradient-color'] ) ) ? $this->value['background-gradient-color'] : '';
334 + $background_gd_direction = ( ! empty( $this->value['background-gradient-direction'] ) ) ? $this->value['background-gradient-direction'] : '';
335 + $background_image = ( ! empty( $this->value['background-image']['url'] ) ) ? $this->value['background-image']['url'] : '';
173 336
174 - }
337 + if ( $background_color && $background_gd_color ) {
338 + $gd_direction = ( $background_gd_direction ) ? $background_gd_direction . ',' : '';
339 + $bg_image[] = 'linear-gradient(' . $gd_direction . $background_color . ',' . $background_gd_color . ')';
340 + unset( $this->value['background-color'] );
341 + }
175 342
176 - //
177 - // Background Repeat
178 - if ( ! empty( $args['background_repeat'] ) ) {
343 + if ( $background_image ) {
344 + $bg_image[] = 'url(' . $background_image . ')';
345 + }
179 346
180 - ADMINIFY::field( array(
181 - 'id' => 'background-repeat',
182 - 'type' => 'select',
183 - 'options' => array(
184 - '' => esc_html__( 'Background Repeat', 'adminify' ),
185 - 'repeat' => esc_html__( 'Repeat', 'adminify' ),
186 - 'no-repeat' => esc_html__( 'No Repeat', 'adminify' ),
187 - 'repeat-x' => esc_html__( 'Repeat Horizontally', 'adminify' ),
188 - 'repeat-y' => esc_html__( 'Repeat Vertically', 'adminify' ),
189 - ),
190 - ), $this->value['background-repeat'], $this->field_name(), 'field/background' );
347 + if ( ! empty( $bg_image ) ) {
348 + $output .= 'background-image:' . implode( ',', $bg_image ) . $important . ';';
349 + }
191 350
192 - }
351 + // Common background properties
352 + $properties = [ 'color', 'position', 'repeat', 'attachment', 'size', 'origin', 'clip', 'blend-mode' ];
193 353
194 - //
195 - // Background Attachment
196 - if ( ! empty( $args['background_attachment'] ) ) {
354 + foreach ( $properties as $property ) {
355 + $property = 'background-' . $property;
356 + if ( ! empty( $this->value[ $property ] ) ) {
357 + $output .= $property . ':' . $this->value[ $property ] . $important . ';';
358 + }
359 + }
197 360
198 - ADMINIFY::field( array(
199 - 'id' => 'background-attachment',
200 - 'type' => 'select',
201 - 'options' => array(
202 - '' => esc_html__( 'Background Attachment', 'adminify' ),
203 - 'scroll' => esc_html__( 'Scroll', 'adminify' ),
204 - 'fixed' => esc_html__( 'Fixed', 'adminify' ),
205 - ),
206 - ), $this->value['background-attachment'], $this->field_name(), 'field/background' );
361 + if ( $output ) {
362 + $output = $element . '{' . $output . '}';
363 + }
207 364
208 - }
365 + $this->parent->output_css .= $output;
209 366
210 - //
211 - // Background Size
212 - if ( ! empty( $args['background_size'] ) ) {
367 + return $output;
368 + }
213 369
214 - ADMINIFY::field( array(
215 - 'id' => 'background-size',
216 - 'type' => 'select',
217 - 'options' => array(
218 - '' => esc_html__( 'Background Size', 'adminify' ),
219 - 'cover' => esc_html__( 'Cover', 'adminify' ),
220 - 'contain' => esc_html__( 'Contain', 'adminify' ),
221 - 'auto' => esc_html__( 'Auto', 'adminify' ),
222 - ),
223 - ), $this->value['background-size'], $this->field_name(), 'field/background' );
224 -
225 - }
226 -
227 - //
228 - // Background Origin
229 - if ( ! empty( $args['background_origin'] ) ) {
230 -
231 - ADMINIFY::field( array(
232 - 'id' => 'background-origin',
233 - 'type' => 'select',
234 - 'options' => array(
235 - '' => esc_html__( 'Background Origin', 'adminify' ),
236 - 'padding-box' => esc_html__( 'Padding Box', 'adminify' ),
237 - 'border-box' => esc_html__( 'Border Box', 'adminify' ),
238 - 'content-box' => esc_html__( 'Content Box', 'adminify' ),
239 - ),
240 - ), $this->value['background-origin'], $this->field_name(), 'field/background' );
241 -
242 - }
243 -
244 - //
245 - // Background Clip
246 - if ( ! empty( $args['background_clip'] ) ) {
247 -
248 - ADMINIFY::field( array(
249 - 'id' => 'background-clip',
250 - 'type' => 'select',
251 - 'options' => array(
252 - '' => esc_html__( 'Background Clip', 'adminify' ),
253 - 'border-box' => esc_html__( 'Border Box', 'adminify' ),
254 - 'padding-box' => esc_html__( 'Padding Box', 'adminify' ),
255 - 'content-box' => esc_html__( 'Content Box', 'adminify' ),
256 - ),
257 - ), $this->value['background-clip'], $this->field_name(), 'field/background' );
258 -
259 - }
260 -
261 - //
262 - // Background Blend Mode
263 - if ( ! empty( $args['background_blend_mode'] ) ) {
264 -
265 - ADMINIFY::field( array(
266 - 'id' => 'background-blend-mode',
267 - 'type' => 'select',
268 - 'options' => array(
269 - '' => esc_html__( 'Background Blend Mode', 'adminify' ),
270 - 'normal' => esc_html__( 'Normal', 'adminify' ),
271 - 'multiply' => esc_html__( 'Multiply', 'adminify' ),
272 - 'screen' => esc_html__( 'Screen', 'adminify' ),
273 - 'overlay' => esc_html__( 'Overlay', 'adminify' ),
274 - 'darken' => esc_html__( 'Darken', 'adminify' ),
275 - 'lighten' => esc_html__( 'Lighten', 'adminify' ),
276 - 'color-dodge' => esc_html__( 'Color Dodge', 'adminify' ),
277 - 'saturation' => esc_html__( 'Saturation', 'adminify' ),
278 - 'color' => esc_html__( 'Color', 'adminify' ),
279 - 'luminosity' => esc_html__( 'Luminosity', 'adminify' ),
280 - ),
281 - ), $this->value['background-blend-mode'], $this->field_name(), 'field/background' );
282 -
283 - }
284 -
285 - echo '</div>';
286 -
287 - echo wp_kses_post( $this->field_after() );
288 -
289 - }
290 -
291 - public function output() {
292 -
293 - $output = '';
294 - $bg_image = array();
295 - $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
296 - $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
297 -
298 - // Background image and gradient
299 - $background_color = ( ! empty( $this->value['background-color'] ) ) ? $this->value['background-color'] : '';
300 - $background_gd_color = ( ! empty( $this->value['background-gradient-color'] ) ) ? $this->value['background-gradient-color'] : '';
301 - $background_gd_direction = ( ! empty( $this->value['background-gradient-direction'] ) ) ? $this->value['background-gradient-direction'] : '';
302 - $background_image = ( ! empty( $this->value['background-image']['url'] ) ) ? $this->value['background-image']['url'] : '';
303 -
304 -
305 - if ( $background_color && $background_gd_color ) {
306 - $gd_direction = ( $background_gd_direction ) ? $background_gd_direction .',' : '';
307 - $bg_image[] = 'linear-gradient('. $gd_direction . $background_color .','. $background_gd_color .')';
308 - unset( $this->value['background-color'] );
309 - }
310 -
311 - if ( $background_image ) {
312 - $bg_image[] = 'url('. $background_image .')';
313 - }
314 -
315 - if ( ! empty( $bg_image ) ) {
316 - $output .= 'background-image:'. implode( ',', $bg_image ) . $important .';';
317 - }
318 -
319 - // Common background properties
320 - $properties = array( 'color', 'position', 'repeat', 'attachment', 'size', 'origin', 'clip', 'blend-mode' );
321 -
322 - foreach ( $properties as $property ) {
323 - $property = 'background-'. $property;
324 - if ( ! empty( $this->value[$property] ) ) {
325 - $output .= $property .':'. $this->value[$property] . $important .';';
326 - }
327 - }
328 -
329 - if ( $output ) {
330 - $output = $element .'{'. $output .'}';
331 - }
332 -
333 - $this->parent->output_css .= $output;
334 -
335 - return $output;
336 -
337 - }
338 -
339 - }
370 + }
340 371 }