PluginProbe
Floating Button – Easily Create Sticky, Fixed & Floating Buttons / 6.0.1
Floating Button – Easily Create Sticky, Fixed & Floating Buttons v6.0.1
trunk 2.0.2 3.0 4.0 4.1.2 4.3 5.0 5.0.1 5.1 5.1.1 5.2 5.3 5.3.1 6.0 6.0.1 6.0.10 6.0.11 6.0.12 6.0.13 6.0.2 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 All 31 releases
floating-button / classes / Publisher / EnqueueStyle.php

EnqueueStyle.php in Floating Button – Easily Create Sticky, Fixed & Floating Buttons 6.0.1, at classes/Publisher/EnqueueStyle.php

203 lines 5.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FloatingButton\Publisher;
4
5 defined( 'ABSPATH' ) || exit;
6
7 use FloatingButton\Dashboard\FolderManager;
8 use FloatingButton\Optimization\CSSMinifier;
9 use FloatingButton\WOW_Plugin;
10
11 class EnqueueStyle {
12
13 public function __construct( $result ) {
14 $this->id = $result->id;
15 $this->param = maybe_unserialize( $result->param );
16 }
17
18 public function init(): void {
19 $param = $this->param;
20 $slug = WOW_Plugin::SLUG;
21 $version = WOW_Plugin::info( 'version' );
22 $asset = WOW_Plugin::url() . 'assets/';
23
24 $pre_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
25
26 $url_style = $asset . 'css/frontend' . $pre_suffix . '.css';
27 wp_enqueue_style( $slug, $url_style, null, $version );
28
29 $inline_style = $this->inline();
30 wp_add_inline_style( $slug, $inline_style );
31
32 if ( empty( $param['disable_fontawesome'] ) ) {
33 $url_icons = $asset . 'vendors/fontawesome/css/fontawesome-all' . $pre_suffix . '.css';
34 wp_enqueue_style( $slug . '-fontawesome', $url_icons, null, '6.4.2' );
35 }
36
37 if ( ! empty( $param['button_animation'] ) ) {
38 $url_animation = $asset . 'css/animation' . $pre_suffix . '.css';
39 wp_enqueue_style( $slug . '-animation', $url_animation, null, $version );
40 }
41
42 }
43
44 public function inline(): string {
45 $css = $this->main_btn();
46 $css .= $this->size();
47 $css .= $this->tooltip_size();
48 $css .= $this->main_btn_anim();
49 $css .= $this->offset();
50 $css .= $this->items();
51 $css .= $this->small_screen();
52 $css .= $this->large_screen();
53 $css .= $this->extra_style();
54
55 return trim( preg_replace( '~\s+~s', ' ', $css ) );
56 }
57
58
59 public function items(): string {
60 $param = $this->param;
61 $css = '';
62 $menus = [ 'menu_1' => 'flBtn-first', 'menu_2' => 'flBtn-second' ];
63 foreach ( $menus as $key => $class ) {
64 $count = isset( $param[ $key ]['item_type'] ) ? count( $param[ $key ]['item_type'] ) : 0;
65 for ( $i = 0; $i < $count; $i ++ ) {
66 $item = $i + 1;
67 $css .= '#floatBtn-' . absint( $this->id ) . ' .' . esc_attr( $class ) . ' li:nth-child(' . absint( $item ) . ') {';
68 $css .= '--flBtn-color: ' . esc_attr( $param[ $key ]['icon_color'][ $i ] ) . ';';
69 $css .= '--flBtn-h-color: ' . esc_attr( $param[ $key ]['icon_hcolor'][ $i ] ) . ';';
70 $css .= '--flBtn-bg: ' . esc_attr( $param[ $key ]['button_color'][ $i ] ) . ';';
71 $css .= '--flBtn-h-bg: ' . esc_attr( $param[ $key ]['button_hcolor'][ $i ] ) . ';';
72 $css .= '}';
73 }
74 }
75
76 return $css;
77 }
78
79 public function main_btn(): string {
80 $param = $this->param;
81
82 return '
83 #floatBtn-' . absint( $this->id ) . ' > a,
84 #floatBtn-' . absint( $this->id ) . ' > .flBtn-label {
85 --flBtn-bg: ' . esc_attr( $param['button_color'] ) . ';
86 --flBtn-color: ' . esc_attr( $param['icon_color'] ) . ';
87 --flBtn-h-color: ' . esc_attr( $param['icon_hcolor'] ) . ';
88 --flBtn-h-bg: ' . esc_attr( $param['button_hcolor'] ) . ';
89 }
90 #floatBtn-' . absint( $this->id ) . ' [data-tooltip] {
91 --flBtn-tooltip-bg: ' . esc_attr( $param['tooltip_background'] ) . ';
92 --flBtn-tooltip-color: ' . esc_attr( $param['tooltip_color'] ) . ';
93 }';
94 }
95
96 public function main_btn_anim(): string {
97 $param = $this->param;
98 $css = '';
99 if ( ! empty( $param['btn_anim_count'] ) ) {
100 $css .= '
101 #floatBtn-' . absint( $this->id ) . '.flBtn-animated {
102 animation-iteration-count: ' . absint( $param['btn_anim_count'] ) . ';
103 }
104 ';
105 }
106
107 if ( ! empty( $param['btn_anim_delay'] ) ) {
108 $css .= '
109 #floatBtn-' . absint( $this->id ) . '.flBtn-animated {
110 animation-delay: ' . absint( $param['btn_anim_delay'] ) . 'ms;
111 }
112 ';
113 }
114
115 return $css;
116
117 }
118
119 public function size(): string {
120 $param = $this->param;
121
122 if ( $param['size'] !== 'flBtn-custom' ) {
123 return '';
124 }
125
126 $css = '
127 #floatBtn-' . absint( $this->id ) . ' {
128 --flBtn-size: ' . absint( $param['ul_size'] ) . 'px;
129 --flBtn-box: ' . absint( $param['ul_box'] ) . 'px;
130 --flBtn-label-size: ' . absint( $param['label_size'] ) . 'px;
131 --flBtn-label-box: ' . absint( $param['label_box'] ) . 'px;
132 }';
133
134
135 return $css;
136 }
137
138 public function tooltip_size(): string {
139 $param = $this->param;
140 $css = '';
141 if ( ! empty( $param['tooltip_size_check'] ) && $param['tooltip_size_check'] === 'custom' ) {
142 $css = '#floatBtn-' . absint( $this->id ) . ' {
143 --flBtn-tooltip-size: ' . absint( $param['tooltip_size'] ) . 'px;
144 --flBtn-tooltip-ul-size: ' . absint( $param['tooltip_ul_size'] ) . 'px;
145 }';
146 }
147 return $css;
148 }
149
150 public function offset(): string {
151 $param = $this->param;
152 $v_offset = ! empty( $param['v_offset'] ) ? $param['v_offset'] . 'px' : '0';
153 $h_offset = ! empty( $param['h_offset'] ) ? $param['h_offset'] . 'px' : '0';
154 $css = '';
155 if ( ! empty( $v_offset ) || ! empty( $h_offset ) ) {
156 $css .= '#floatBtn-' . absint( $this->id ) . ' {
157 --flBtn-v-offset: ' . esc_attr( $v_offset ) . ';
158 --flBtn-h-offset: ' . esc_attr( $h_offset ) . ';
159 }';
160
161 }
162
163 return $css;
164 }
165
166 public function small_screen(): string {
167 if ( empty( $this->param['include_mobile'] ) ) {
168 return '';
169 }
170 $screen = ! empty( $this->param['screen'] ) ? $this->param['screen'] : 480;
171
172 return '
173 @media only screen and (max-width: ' . esc_attr( $screen ) . 'px){
174 #floatBtn-' . absint( $this->id ) . ' {
175 display:none;
176 }
177 }';
178 }
179
180 public function large_screen(): string {
181 if ( empty( $this->param['include_more_screen'] ) ) {
182 return '';
183 }
184 $screen = ! empty( $this->param['screen_more'] ) ? $this->param['screen_more'] : 1200;
185
186 return '
187 @media only screen and (min-width: ' . esc_attr( $screen ) . 'px){
188 #floatBtn-' . absint( $this->id ) . ' {
189 display:none;
190 }
191 }';
192 }
193
194 public function extra_style() {
195 if ( empty( $this->param['extra_style'] ) ) {
196 return '';
197 }
198
199 return $this->param['extra_style'];
200
201 }
202
203 }