PluginProbe
Floating Button – Easily Create Sticky, Fixed & Floating Buttons / 6.0.2
Floating Button – Easily Create Sticky, Fixed & Floating Buttons v6.0.2
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.2, at classes/Publisher/EnqueueStyle.php

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