PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.9.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.9.1
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
ablocks / includes / controls / box-shadow.php

box-shadow.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.9.1, at includes/controls/box-shadow.php

92 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Controls;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Classes\ControlBaseAbstract;
9
10 class BoxShadow extends ControlBaseAbstract {
11 public static function get_attribute_default_value( $is_responsive = false ) {
12 return [
13 'preset' => '',
14 'shadowType' => 'default',
15 'shadow' => '',
16 'horizontal' => '',
17 'vertical' => '',
18 'blur' => '',
19 'spread' => '',
20 'color' => '',
21 'presetH' => '',
22 'shadowTypeH' => 'default',
23 'shadowH' => '',
24 'horizontalH' => '',
25 'verticalH' => '',
26 'blurH' => '',
27 'spreadH' => '',
28 'colorH' => '',
29 'transitionDuration' => '0',
30 ];
31 }
32
33 public static function get_attribute( $attributeName, $is_responsive = false ) {
34 return [
35 $attributeName => [
36 'type' => 'object',
37 'default' => self::get_attribute_default_value( true ),
38 ],
39 ];
40 }
41 public static function get_css( $attribute_value, $property = '', $device = '' ) {
42 $value = wp_parse_args( $attribute_value,
43 self::get_attribute_default_value( true )
44 );
45 $css = [];
46 $color = $value['color'] ? $value['color'] : '#000000';
47 if ( $value['shadowType'] !== 'default' && $value['shadowType'] === 'inner_shadow' ) {
48 if ( ! empty( $value['preset'] ) ) {
49 $css['box-shadow'] = 'inset ' . $value['horizontal'] . 'px ' . $value['vertical'] . 'px ' . $value['blur'] . 'px ' . $value['spread'] . 'px ' . $color;
50
51 }
52 } elseif ( $value['shadowType'] !== 'default' && $value['shadowType'] === 'outer_shadow' ) {
53 if ( ! empty( $value['preset'] ) ) {
54 $css['box-shadow'] = $value['horizontal'] . 'px ' . $value['vertical'] . 'px ' . $value['blur'] . 'px ' . $value['spread'] . 'px ' . $color;
55 }
56 } else {
57 if ( ! empty( $value['horizontal'] ) && ! empty( $value['vertical'] ) ) {
58 $css['box-shadow'] = $value['horizontal'] . 'px ' . $value['vertical'] . 'px ' . $value['blur'] . 'px ' . $value['spread'] . 'px ' . $color;
59 }
60 }
61 if ( $value['transitionDuration'] ) {
62 $css['transition'] = $property . ' ' . $value['transitionDuration'] . 's';
63 }
64 return $css;
65 }
66
67 public static function get_hover_css( $attribute, $device = '' ) {
68 $value = wp_parse_args(
69 $attribute,
70 self::get_attribute_default_value( true ),
71 );
72
73 $css = [];
74 $colorH = $value['colorH'] ? $value['colorH'] : '#000000';
75 if ( $value['shadowTypeH'] !== 'default' && $value['shadowTypeH'] === 'inner_shadow' ) {
76 if ( ! empty( $value['presetH'] ) ) {
77 $css['box-shadow'] = 'inset ' . $value['horizontalH'] . 'px ' . $value['verticalH'] . 'px ' . $value['blurH'] . 'px ' . $value['spreadH'] . 'px ' . $colorH;
78 }
79 } elseif ( $value['shadowTypeH'] !== 'default' && $value['shadowTypeH'] === 'outer_shadow' ) {
80 if ( ! empty( $value['presetH'] ) ) {
81 $css['box-shadow'] = $value['horizontalH'] . 'px ' . $value['verticalH'] . 'px ' . $value['blurH'] . 'px ' . $value['spreadH'] . 'px ' . $colorH;
82 }
83 } else {
84 if ( ! empty( $value['horizontalH'] ) && ! empty( $value['verticalH'] ) ) {
85 $css['box-shadow'] = $value['horizontalH'] . 'px ' . $value['verticalH'] . 'px ' . $value['blurH'] . 'px ' . $value['spreadH'] . 'px ' . $colorH;
86 }
87 }
88 return $css;
89 }
90
91 }
92