PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.8.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.8.0
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 1.2.0 1.2.1 All 78 releases
ablocks / includes / controls / box-shadow.php

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

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