PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 1.4.5
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v1.4.5
3.6.0 3.5.0 trunk 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 All 110 releases
buttonizer-multifunctional-button / classes / Button.php

Button.php in Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder 1.4.5, at classes/Button.php

649 lines 29.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 Copyright 2017 Buttonizer
19 */
20 namespace Buttonizer;
21
22 # No script kiddies
23 defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
24 class Button
25 {
26 // Saved settings
27 private $aButtons ;
28 private $pageCategories ;
29 private $aSettings ;
30 private $aOpeningData ;
31 private $aVideo ;
32 // Default settings
33 private $bIsMobile = false ;
34 private $bIsOpened = true ;
35 // Current page
36 private $currentPageId = 0 ;
37 private $currentCategoryId = 0 ;
38 private $currentBlogId = 0 ;
39 private $sCurrentPageUrl = '' ;
40 private $currentPageTitle = '' ;
41 private $sCurrentPageDescription = '' ;
42 private $aAnimationSettings = array( 'default', 'circle', 'fade-left-to-right' ) ;
43 private $aAttentionAnimationSettings = array( 'none', 'hello', 'bounce' ) ;
44 // Output string
45 private $iAmountOfButtons = 0 ;
46 private $iAmountOfShareButtons = 0 ;
47 private $sOutput = '' ;
48 // Custom button color
49 // Label settings
50 private $labelStyle = '' ;
51 private $sButtonCss = '' ;
52 public function __construct( $bIsMobile )
53 {
54 // Set some data
55 $this->bIsMobile = (bool) $bIsMobile;
56 add_action( 'wp_footer', function () {
57 // Setup
58 $this->setup();
59 // Share buttons
60 $this->share_btns();
61 // Generate
62 $this->generate();
63 // Output
64 $this->output();
65 } );
66 add_action( 'wp_print_styles', array( &$this, 'siteLoadStyles' ) );
67 }
68
69 /**
70 * Buttonizer setup
71 */
72 private function setup()
73 {
74 // Timezone
75 // date_default_timezone_set(get_option('timezone_string') != '' ? get_option('timezone_string') : "Europe/Amsterdam");
76 // Get options
77 $this->aButtons = (array) get_option( 'buttonizer_buttons' );
78 $this->pageCategories = (array) get_option( 'buttonizer_page_categories' );
79 $this->aOpeningData = (array) get_option( 'buttonizer_opening_settings' );
80 $this->aSettings = (array) get_option( 'buttonizer_general_settings' );
81 $this->aVideo = (array) get_option( 'buttonizer_videos' );
82 // Current page data
83 $this->currentPageId = get_the_ID();
84 $this->currentCategoryId = get_the_category();
85 $this->currentBlogId = get_current_blog_id();
86 $this->currentPageTitle = strtolower( get_the_title() );
87 $this->sCurrentPageUrl = urlencode( get_permalink() );
88 $this->sCurrentPageDescription = str_replace( " ", "+", get_the_content( 'Read more' ) );
89 // Is store opened
90 $this->bIsOpened = $this->isOpened();
91 }
92
93 public function siteLoadStyles()
94 {
95 wp_enqueue_style( 'buttonizer', plugins_url( '/css/buttonizer.css?v=' . md5( BUTTONIZER_VERSION ), BUTTONIZER_PLUGIN_DIR ) );
96 wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css' );
97 }
98
99 // Generate
100 private function generate()
101 {
102 $aButtons = ( isset( $this->aButtons['buttonorder'] ) && is_array( $this->aButtons['buttonorder'] ) ? $this->aButtons['buttonorder'] : [] );
103 foreach ( $aButtons as $sKey => $iId ) {
104 if ( '-1' == $iId ) {
105 continue;
106 }
107 $sButton = $this->generateB( $iId );
108
109 if ( 'continue' == $sButton ) {
110 continue;
111 } else {
112 $this->sOutput = $sButton . $this->sOutput;
113 }
114
115 $this->iAmountOfButtons++;
116 }
117 }
118
119 /**
120 * Button generator
121 *
122 * @param $bNmbr
123 * @return string
124 */
125 private function generateB( $bNmbr )
126 {
127 // Check if this one must be showed when the company is open:
128 if ( isset( $this->aButtons['button_' . $bNmbr . '_show_when_opened'] ) && !$this->bIsOpened ) {
129 return 'continue';
130 }
131 // Check if this one must be showed when the company is open:
132 if ( isset( $this->aButtons['button_' . $bNmbr . '_show_not_when_opened'] ) && $this->bIsOpened ) {
133 return 'continue';
134 }
135 // Do we need to show the button?
136
137 if ( !isset( $this->aButtons['button_' . $bNmbr . '_show_on_phone'] ) && !isset( $this->aButtons['button_' . $bNmbr . '_show_on_desktop'] ) ) {
138 // Skipping because not showing on desktop AND phone
139 return 'continue';
140 } else {
141 // Is the button visble on mobile phones?:
142 if ( $this->bIsMobile && !isset( $this->aButtons['button_' . $bNmbr . '_show_on_phone'] ) ) {
143 // Skipping because this is a mobile
144 return 'continue';
145 }
146 // Is the button visible on desktop?:
147 if ( !$this->bIsMobile && !isset( $this->aButtons['button_' . $bNmbr . '_show_on_desktop'] ) ) {
148 // Skipping because this is desktop and it musn't get shown here
149 return 'continue';
150 }
151 }
152
153 /*
154 * Page categories selected or not
155 * Check on what pages the button must be shown
156 */
157 $buttonShowOnPages = ( isset( $this->aButtons['button_' . $bNmbr . '_show_on_pages'] ) ? $this->aButtons['button_' . $bNmbr . '_show_on_pages'] : 'all' );
158 if ( $this->checkPageCategories( $buttonShowOnPages ) ) {
159 return 'continue';
160 }
161 /*
162 * All button info
163 */
164 $buttonText = ( isset( $this->aButtons['button_' . $bNmbr . '_text'] ) ? $this->aButtons['button_' . $bNmbr . '_text'] : 'Button ' . $bNmbr );
165 $buttonTitle = ( isset( $this->aButtons['button_' . $bNmbr . '_title'] ) ? $this->aButtons['button_' . $bNmbr . '_title'] : 'Button ' . $bNmbr );
166 $buttonIsPhone = ( isset( $this->aButtons['button_' . $bNmbr . '_is_phonenumber'] ) ? $this->aButtons['button_' . $bNmbr . '_is_phonenumber'] : '' );
167 $linkNewTab = ( isset( $this->aButtons['button_' . $bNmbr . '_url_newtab'] ) ? 'target="_blank"' : '' );
168 $hideLabel = ( isset( $this->aButtons['button_' . $bNmbr . '_hide_label'] ) ? $this->aButtons['button_' . $bNmbr . '_hide_label'] : '' );
169 $sButtonAction = ( isset( $this->aButtons['button_' . $bNmbr . '_action'] ) ? $this->aButtons['button_' . $bNmbr . '_action'] : '' );
170 $sButtonActionLink = str_replace( '"', "'", ( isset( $this->aButtons['button_' . $bNmbr . '_url'] ) ? $this->aButtons['button_' . $bNmbr . '_url'] : '' ) );
171 $buttonStyle = "";
172 $buttonOnClick = "";
173
174 if ( 'phone' == $sButtonAction || $buttonIsPhone ) {
175 $sButtonActionLink = 'tel:' . str_replace( [
176 ' ',
177 '+',
178 '?',
179 '#'
180 ], '', $sButtonActionLink );
181 } else {
182
183 if ( 'mail' == $sButtonAction ) {
184 $sButtonActionLink = 'mailto:' . $sButtonActionLink;
185 } else {
186
187 if ( 'backtotop' == $sButtonAction ) {
188 $sButtonActionLink = "javascript: window.scroll({top: 0, left: 0, behavior: 'smooth' });";
189 } else {
190
191 if ( 'gobackpage' == $sButtonAction ) {
192 $sButtonActionLink = "javascript: window.history.back(); ";
193 } else {
194
195 if ( 'socialsharing' == $sButtonAction ) {
196 $socialData = ( isset( $this->aButtons['button_' . $bNmbr . '_social'] ) ? $this->aButtons['button_' . $bNmbr . '_social'] : 'twitter' );
197 $sButtonActionLink = "javascript:void(0)";
198 //Share options, action buttons
199
200 if ( 'whatsapp' == $socialData ) {
201 $buttonOnClick = "onButtonizerClickEvent('Whatsapp share click'); onButtonizerButtonWhatsapp()";
202 } else {
203
204 if ( 'mail' == $socialData ) {
205 $buttonOnClick = "onButtonizerClickEvent('Email share click'); onButtonizerButtonEmail()";
206 } else {
207
208 if ( 'linkedin' == $socialData ) {
209 $buttonOnClick = "onButtonizerClickEvent('Linkedin share click'); onButtonizerButtonLinkedin()";
210 } else {
211
212 if ( 'facebook' == $socialData ) {
213 $buttonOnClick = "onButtonizerClickEvent('Facebook share click'); onButtonizerButtonFacebook()";
214 } else {
215 if ( 'twitter' == $socialData ) {
216 $buttonOnClick = "onButtonizerClickEvent('Twitter share click'); onButtonizerButtonTwitter()";
217 }
218 }
219
220 }
221
222 }
223
224 }
225
226 }
227
228 }
229
230 }
231
232 }
233
234 }
235
236 // Has image
237
238 if ( !isset( $this->aButtons['button_' . $bNmbr . '_image'] ) || empty($this->aButtons['button_' . $bNmbr . '_image']) ) {
239 $sButtonIcon = '<i class="fa ' . (( isset( $this->aButtons['button_' . $bNmbr . '_icon'] ) ? $this->aButtons['button_' . $bNmbr . '_icon'] : 'plus' )) . '"></i>';
240 } else {
241
242 if ( isset( $this->aButtons['button_' . $bNmbr . '_image_background'] ) && $this->aButtons['button_' . $bNmbr . '_image_background'] == '1' ) {
243 $sButtonIcon = "";
244 $buttonStyle = "background-image: url('" . $this->aButtons['button_' . $bNmbr . '_image'] . "'); background-size: cover; background-position: center;";
245 } else {
246 $sButtonIcon = '<img src="' . $this->aButtons['button_' . $bNmbr . '_image'] . '" style="width: ' . (( count( $this->aButtons ) > 1 ? '25px' : '32px' )) . '; vertical-align: middle;" />';
247 }
248
249 }
250
251 $sButtonClasses = 'is_extra bt_' . $this->iAmountOfButtons;
252 // Show label on hover (per button)
253 $showOnHover = ( isset( $this->aButtons['button_' . $bNmbr . '_show_label_on_hover'] ) ? $this->aButtons['button_' . $bNmbr . '_show_label_on_hover'] : '' );
254
255 if ( $showOnHover == 'showOnHover' ) {
256 $sButtonClasses .= ' show_on_hover';
257 } else {
258
259 if ( $showOnHover == 'showOnHoverDesktop' ) {
260 if ( $this->bIsMobile == false ) {
261 $sButtonClasses .= ' show_on_hover';
262 }
263 } else {
264 if ( $showOnHover == 'showOnHoverMobile' ) {
265 if ( $this->bIsMobile == true ) {
266 $sButtonClasses .= ' show_on_hover';
267 }
268 }
269 }
270
271 }
272
273 // Custom classes
274 $sButtonClasses .= ' ' . $this->getCustomClass( $bNmbr );
275 // Custom colors?
276 if ( isset( $this->aButtons['button_' . $bNmbr . '_using_custom_colors'] ) && $this->aButtons['button_' . $bNmbr . '_using_custom_colors'] == '1' ) {
277 $this->sButtonCss .= '
278 .buttonizer-button .buttonizer_' . $bNmbr . ' {
279 background-color: ' . $this->aButtons['button_' . $bNmbr . '_colors_button'] . ';
280 }
281
282 .buttonizer-button .buttonizer_' . $bNmbr . ':hover,.buttonizer_' . $bNmbr . ':active {
283 background-color: ' . $this->aButtons['button_' . $bNmbr . '_colors_pushed'] . ';
284 }
285
286 .buttonizer-button .buttonizer_' . $bNmbr . ' i {
287 color: ' . $this->aButtons['button_' . $bNmbr . '_colors_icon'] . ';
288 } ';
289 }
290 return '<a href="' . $sButtonActionLink . '" class="' . $sButtonClasses . ' is_btzn_btn buttonizer_' . $bNmbr . '" ' . $linkNewTab . ' onclick="onButtonizerClickEvent(\'' . $buttonTitle . '\'); ' . $buttonOnClick . '" style="' . $buttonStyle . '">' . (( $buttonText != "" ? '<div class="text"' . (( $hideLabel == '1' ? 'style="display: none;"' : '' )) . '><div>' . $buttonText . '</div></div>' : '' )) . $sButtonIcon . '</a>';
291 // Thanks, end
292 }
293
294 /**
295 * Show on timeout
296 *
297 * @return float|int|string
298 */
299 private function showOnTimeout()
300 {
301 return '0';
302 }
303
304 /**
305 * Show on scroll
306 *
307 * @return string|int
308 */
309 private function showOnScroll()
310 {
311 return '0';
312 }
313
314 /**
315 * Exit intent
316 *
317 * @return string
318 */
319 private function enableExitIntent()
320 {
321 return '0';
322 }
323
324 /**
325 * @param $categoryId
326 * @return bool
327 */
328 private function checkPageCategories( $categoryId )
329 {
330 return false;
331 }
332
333 /**
334 * Exit intent
335 *
336 * @return mixed|string
337 */
338 private function enableExitIntentText()
339 {
340 return '';
341 }
342
343 /**
344 * Custom class
345 *
346 * @param $iButtonId
347 * @return string
348 */
349 private function getCustomClass( $iButtonId )
350 {
351 return '';
352 }
353
354 /**
355 * Is the store opened right now?
356 *
357 * @return bool
358 */
359 private function isOpened()
360 {
361 $sDayOfWeek = $this->getDay( date( 'N' ) );
362 // Result
363 $bTodayOpened = ( isset( $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened'] ) ? $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened'] : '' );
364 // If result == 1 => Opened
365
366 if ( $bTodayOpened != "1" ) {
367 $bIsOpened = false;
368 } else {
369 // Get the time right now
370 $sCurentHour = date( "G" );
371 $sCurrentMinute = date( "i" );
372 // Get the opening and closing time from today.
373 $hourOpening = explode( ':', ( isset( $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened_from'] ) ? $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened_from'] : '10:00' ) );
374 $hourClosing = explode( ':', ( isset( $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_closing_on'] ) ? $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_closing_on'] : '17:00' ) );
375 // Check if the company is opened/closed
376
377 if ( $sCurentHour < $hourOpening[0] || $sCurentHour == $hourOpening[0] && $sCurrentMinute < $hourOpening[1] || $sCurentHour > $hourClosing[0] || $sCurentHour == $hourClosing[0] && $sCurrentMinute > $hourClosing[1] - 1 ) {
378 $bIsOpened = false;
379 } else {
380 $bIsOpened = true;
381 }
382
383 }
384
385 return $bIsOpened;
386 }
387
388 /**
389 * Day-number to text
390 *
391 * @param $sDay
392 * @return string
393 */
394 private function getDay( $sDay )
395 {
396 switch ( $sDay ) {
397 case '1':
398 return 'monday';
399 break;
400 case '2':
401 return 'tuesday';
402 break;
403 case '3':
404 return 'wednesday';
405 break;
406 case '4':
407 return 'thursday';
408 break;
409 case '5':
410 return 'friday';
411 break;
412 case '6':
413 return 'saturday';
414 break;
415 case '7':
416 return 'sunday';
417 break;
418 default:
419 return 'sunday';
420 break;
421 }
422 }
423
424 /**
425 * Share buttons
426 */
427 private function share_btns()
428 {
429
430 if ( isset( $this->aSettings["share_facebook"] ) && '1' == $this->aSettings["share_facebook"] ) {
431 $buttonText = ( isset( $this->aSettings['share_facebook_text'] ) && $this->aSettings['share_facebook_text'] != '' ? $this->aSettings['share_facebook_text'] : 'Share this on Facebook' );
432 $this->sOutput = '<a href="javascript:void(0)" onclick="onButtonizerClickEvent(\'Facebook share click\'); onButtonizerButtonFacebook();" class="is_extra share share_' . ($this->iAmountOfShareButtons + 1) . '">' . (( $buttonText != "" ? '<div class="text"><div>' . $buttonText . '</div></div>' : '' )) . '<i class="fa fa-facebook"></i></a>' . $this->sOutput;
433 $this->iAmountOfShareButtons++;
434 }
435
436
437 if ( isset( $this->aSettings["share_twitter"] ) && '1' == $this->aSettings["share_twitter"] ) {
438 $buttonText = ( isset( $this->aSettings['share_twitter_text'] ) && $this->aSettings['share_twitter_text'] != '' ? $this->aSettings['share_twitter_text'] : 'Share this on Twitter' );
439 $this->sOutput = '<a href="javascript:void(0)" onclick="onButtonizerClickEvent(\'Twitter share click\'); onButtonizerButtonTwitter();" class="is_extra share share_' . ($this->iAmountOfShareButtons + 1) . '">' . (( $buttonText != "" ? '<div class="text"><div>' . $buttonText . '</div></div>' : '' )) . '<i class="fa fa-twitter"></i></a>' . $this->sOutput;
440 $this->iAmountOfShareButtons++;
441 }
442
443
444 if ( isset( $this->aSettings["share_linkedin"] ) && '1' == $this->aSettings["share_linkedin"] ) {
445 $buttonText = ( isset( $this->aSettings['share_linkedin_text'] ) && $this->aSettings['share_linkedin_text'] != '' ? $this->aSettings['share_linkedin_text'] : 'Share this on LinkedIn' );
446 $this->sOutput = '<a href="javascript:void(0)" onclick="onButtonizerClickEvent(\'Linkedin share click\'); onButtonizerButtonLinkedin();" class="is_extra share share_' . ($this->iAmountOfShareButtons + 1) . '">' . (( $buttonText != "" ? '<div class="text"><div>' . $buttonText . '</div></div>' : '' )) . '<i class="fa fa-linkedin"></i></a>' . $this->sOutput;
447 $this->iAmountOfShareButtons++;
448 }
449
450
451 if ( isset( $this->aSettings["share_email"] ) && '1' == $this->aSettings["share_email"] ) {
452 $buttonText = ( isset( $this->aSettings['share_email_text'] ) && $this->aSettings['share_email_text'] != '' ? $this->aSettings['share_email_text'] : 'Share this on Email' );
453 $this->sOutput = '<a href="javascript:void(0)" onclick="onButtonizerClickEvent(\'Email share click\'); onButtonizerButtonEmail();" class="is_extra share share_' . ($this->iAmountOfShareButtons + 1) . '">' . (( $buttonText != "" ? '<div class="text"><div>' . $buttonText . '</div></div>' : '' )) . '<i class="fa fa-envelope"></i></a>' . $this->sOutput;
454 $this->iAmountOfShareButtons++;
455 }
456
457 // Coming next update: :)
458 if ( wp_is_mobile() == true ) {
459
460 if ( isset( $this->aSettings["share_whatsapp"] ) && '1' == $this->aSettings["share_whatsapp"] ) {
461 $buttonText = ( isset( $this->aSettings['share_whatsapp_text'] ) && $this->aSettings['share_whatsapp_text'] != '' ? $this->aSettings['share_whatsapp_text'] : 'Share this on Whatsapp' );
462 $this->sOutput = '<a href="javascript:void(0)" onclick="onButtonizerClickEvent(\'Whatsapp share click\'); onButtonizerButtonWhatsapp();" class="is_extra share share_' . ($this->iAmountOfShareButtons + 1) . '">' . (( $buttonText != "" ? '<div class="text"><div>' . $buttonText . '</div></div>' : '' )) . '<i class="fa fa-whatsapp"></i></a>' . $this->sOutput;
463 $this->iAmountOfShareButtons++;
464 }
465
466 }
467 //
468 // if(isset($this->aSettings["share_pinterest"]) && '1' == $this->aSettings["share_pinterest"]) {
469 // $buttonText = (isset($this->aSettings['share_pinterest_text']) && $this->aSettings['share_pinterest_text'] != '' ? ($this->aSettings['share_pinterest_text']) : 'Share this on Pinterest');
470 //
471 // $this->sOutput = '<a href="javascript:void(0)" onclick="onButtonizerClickEvent(\'Pinterest share click\'); onButtonizerButtonPinterest();" class="is_extra share share_' . ($this->iAmountOfShareButtons + 1) . '">' . ($buttonText != "" ? '<div class="text"><div>' . $buttonText . '</div></div>' : '') . '<i class="fa fa-pinterest"></i></a>' . $this->sOutput;
472 //
473 // $this->iAmountOfShareButtons++;
474 // }
475 }
476
477 /**
478 * Get the positioning of the buttons
479 * @param string $sPositioning
480 * @return string
481 */
482 public function buttonPositioning( $sPositioning = '' )
483 {
484 $sPositioning .= (( isset( $this->aSettings['buttons_placing'] ) && $this->aSettings['buttons_placing'] == 'left' ? 'left' : 'right' )) . ': ' . (( isset( $this->aSettings['position_horizontal'] ) ? $this->aSettings['position_horizontal'] : (( isset( $this->aSettings['position_right'] ) ? $this->aSettings['position_right'] : '5' )) )) . '%;';
485 $sPositioning .= 'bottom: ' . (( isset( $this->aSettings['position_bottom'] ) ? $this->aSettings['position_bottom'] : '5' )) . '%;';
486 return $sPositioning;
487 }
488
489 /**
490 * Output of the button
491 */
492 public function output()
493 {
494 $showAfterTimeout = $this->showOnTimeout();
495 $showOnScroll = $this->showOnScroll();
496 // Main button image or icon
497 $sImage = ( isset( $this->aSettings['custom_icon'] ) ? $this->aSettings['custom_icon'] : '' );
498
499 if ( $sImage != '' ) {
500 $sIcon = '<img src="' . $sImage . '" style="width: 32px; vertical-align: middle;" />';
501 } else {
502 $sIcon = ( !empty($this->aSettings['icon_icon']) && $this->aSettings['icon_icon'] != '+' ? '<i class="isicon-fa fa ' . $this->aSettings['icon_icon'] . '"></i>' : '<i>+</i>' );
503 }
504
505
506 if ( $this->iAmountOfButtons == 1 && $this->iAmountOfShareButtons == 0 ) {
507 $output = str_replace( "is_extra bt_0", "buttonizer_head onlyone", $this->sOutput );
508 } else {
509
510 if ( $this->iAmountOfButtons > 1 || $this->iAmountOfShareButtons > 0 ) {
511 $output = '<a href="javascript:void(0)" class="buttonizer_head" onclick="onButtonizerClickEvent(\'Open/Close Buttonizer button\')">' . (( !empty($this->aSettings['icon_label']) ? '<div class="text noremove"><div>' . $this->aSettings['icon_label'] . '</div></div>' : '' )) . $sIcon . '</a>' . $this->sOutput;
512 } else {
513 $output = '';
514 }
515
516 }
517
518 // Google analytics toevoegen
519 if ( isset( $this->aSettings['google_analytics'] ) && $this->aSettings['google_analytics'] != "" ) {
520 $output .= "<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');ga('create', '" . $this->aSettings['google_analytics'] . "', 'auto');</script>";
521 }
522
523 if ( isset( $this->aSettings['buttons_animation'] ) && in_array( $this->aSettings['buttons_animation'], $this->aAnimationSettings ) ) {
524 $sButtonAnimation = $this->aSettings['buttons_animation'];
525 } else {
526 $sButtonAnimation = 'default';
527 }
528
529
530 if ( isset( $this->aSettings['attention_animation'] ) && in_array( $this->aSettings['attention_animation'], $this->aAttentionAnimationSettings ) ) {
531 $sAttentionAnimation = $this->aSettings['attention_animation'];
532 } else {
533 $sAttentionAnimation = 'default';
534 }
535
536 // Label hovering
537
538 if ( !isset( $this->aSettings['buttons_label_show_on_hover'] ) || $this->aSettings['buttons_label_show_on_hover'] == 'default' ) {
539 $labelStyle = 'buttonizer_label_default';
540 } else {
541
542 if ( $this->aSettings['buttons_label_show_on_hover'] == 'showOnHover' ) {
543 $labelStyle = 'buttonizer_label_hover';
544 } else {
545
546 if ( $this->aSettings['buttons_label_show_on_hover'] == 'showOnHoverDesktop' ) {
547
548 if ( $this->bIsMobile == false ) {
549 $labelStyle = 'buttonizer_label_hover';
550 } else {
551 $labelStyle = 'buttonizer_label_default';
552 }
553
554 } else {
555 if ( $this->aSettings['buttons_label_show_on_hover'] == 'showOnHoverMobile' ) {
556
557 if ( $this->bIsMobile == true ) {
558 $labelStyle = 'buttonizer_label_hover';
559 } else {
560 $labelStyle = 'buttonizer_label_default';
561 }
562
563 }
564 }
565
566 }
567
568 }
569
570 list( $sShadowColorRed, $sShadowColorGreen, $sShadowColorBlue ) = sscanf( $this->aSettings['button_unpushed'], "#%02x%02x%02x" );
571 // Mobile button size vs Desktop button size
572
573 if ( $this->bIsMobile ) {
574 $iconSize = ( isset( $this->aSettings['mobile_icon_size'] ) ? $this->aSettings['mobile_icon_size'] : 56 );
575 } else {
576 $iconSize = ( isset( $this->aSettings['icon_size'] ) ? $this->aSettings['icon_size'] : 56 );
577 }
578
579 echo '
580 <style>
581 .buttonizer-button a:hover,
582 .buttonizer-button a:focus{ background:' . $this->aSettings['button_pushed'] . '; }
583 .buttonizer-button a { background:' . $this->aSettings['button_unpushed'] . '; }
584 .buttonizer-button a i { color: ' . $this->aSettings['icon_color'] . '; }
585
586 .buttonizer-button a.buttonizer_head, .buttonizer-button a.buttonizer_head i {
587 height: ' . $iconSize . 'px !important;
588 width: ' . $iconSize . 'px !important;
589 line-height: ' . $iconSize . 'px !important;
590 }
591
592 .buttonizer-button a.buttonizer_head, .buttonizer-button a.buttonizer_head {
593 margin-left: -' . ($iconSize - 56) / 2 . 'px;
594 margin-top: -' . ($iconSize - 56) / 2 . 'px;
595 }
596
597 .buttonizer-button a.buttonizer_head, .buttonizer-button a.is_extra {
598 margin-top: -' . ($iconSize - 56) . 'px;
599 }
600 .buttonizer-button a.buttonizer_head .text{
601 right: ' . ($iconSize + 20) . 'px !important;
602 top: ' . $iconSize / 3 . 'px !important;
603 }
604
605
606 .buttonizer-button[label-style="mirrored"] a.is_extra.share {
607 margin-top: -' . ($iconSize - 56) / 2 . 'px;
608 margin-left: ' . ($iconSize - 56) . 'px;
609 }
610
611 .buttonizer-button[label-style="default"] a.is_extra.share {
612 margin-top: -' . ($iconSize - 56) / 2 . 'px;
613 margin-left: -' . ($iconSize - 56) . 'px !important;
614 }
615
616 .buttonizer-button a .text{
617 background-color: ' . $this->aSettings['label_color'] . ';
618 color: ' . $this->aSettings['label_text-color'] . ';
619 }
620
621
622
623 ' . $this->sButtonCss . '
624 </style>
625 <div class="buttonizer-button ' . (( $showOnScroll > 0 || $showAfterTimeout > 0 ? 'hide' : '' )) . ' ' . $labelStyle . '"
626 button-animation="' . $sButtonAnimation . '"
627 attention-animation="' . $sAttentionAnimation . '"
628
629
630 label-style="' . (( isset( $this->aSettings['buttons_label_placing'] ) ? $this->aSettings['buttons_label_placing'] : 'default' )) . '"
631
632
633 style="' . $this->buttonPositioning() . '"
634 id="buttonizer-button"><div class="buttonizer_inner" id="buttonizer-sys">' . $output . '</div></div>' ;
635 echo '
636 <script defer type="text/javascript" src="' . plugins_url( '/js/buttonizer.js?v=' . md5( BUTTONIZER_VERSION ), BUTTONIZER_PLUGIN_DIR ) . '"></script>
637 <script type="text/javascript">
638 document.addEventListener(\'DOMContentLoaded\', function(){
639 buttonizer.init({
640 scrollBarTop: ' . $showOnScroll . ',
641 showAfter: ' . $showAfterTimeout . ',
642 ' . (( ButtonizerLicense()->is__premium_only() ? 'exitIntent: ' . $this->enableExitIntent() . ',' : '' )) . '
643 ' . (( ButtonizerLicense()->is__premium_only() ? 'exitIntentText: "' . $this->enableExitIntentText() . '",' : '' )) . '
644 });
645 });
646 </script>' ;
647 }
648
649 }