PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 1.5.1
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v1.5.1
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.5.1, at classes/Button.php

650 lines 29.8 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 krsort( $aButtons );
104 foreach ( $aButtons as $sKey => $iId ) {
105 if ( '-1' == $iId ) {
106 continue;
107 }
108 $sButton = $this->generateB( $iId );
109
110 if ( 'continue' == $sButton ) {
111 continue;
112 } else {
113 $this->sOutput .= $sButton;
114 }
115
116 $this->iAmountOfButtons++;
117 }
118 }
119
120 /**
121 * Button generator
122 *
123 * @param $bNmbr
124 * @return string
125 */
126 private function generateB( $bNmbr )
127 {
128 // Check if this one must be showed when the company is open:
129 if ( isset( $this->aButtons['button_' . $bNmbr . '_show_when_opened'] ) && !$this->bIsOpened ) {
130 return 'continue';
131 }
132 // Check if this one must be showed when the company is open:
133 if ( isset( $this->aButtons['button_' . $bNmbr . '_show_not_when_opened'] ) && $this->bIsOpened ) {
134 return 'continue';
135 }
136 // Do we need to show the button?
137
138 if ( !isset( $this->aButtons['button_' . $bNmbr . '_show_on_phone'] ) && !isset( $this->aButtons['button_' . $bNmbr . '_show_on_desktop'] ) ) {
139 // Skipping because not showing on desktop AND phone
140 return 'continue';
141 } else {
142 // Is the button visble on mobile phones?:
143 if ( $this->bIsMobile && !isset( $this->aButtons['button_' . $bNmbr . '_show_on_phone'] ) ) {
144 // Skipping because this is a mobile
145 return 'continue';
146 }
147 // Is the button visible on desktop?:
148 if ( !$this->bIsMobile && !isset( $this->aButtons['button_' . $bNmbr . '_show_on_desktop'] ) ) {
149 // Skipping because this is desktop and it musn't get shown here
150 return 'continue';
151 }
152 }
153
154 /*
155 * Page categories selected or not
156 * Check on what pages the button must be shown
157 */
158 $buttonShowOnPages = ( isset( $this->aButtons['button_' . $bNmbr . '_show_on_pages'] ) ? $this->aButtons['button_' . $bNmbr . '_show_on_pages'] : 'all' );
159 if ( $this->checkPageCategories( $buttonShowOnPages ) ) {
160 return 'continue';
161 }
162 /*
163 * All button info
164 */
165 $buttonText = ( isset( $this->aButtons['button_' . $bNmbr . '_text'] ) ? $this->aButtons['button_' . $bNmbr . '_text'] : 'Button ' . $bNmbr );
166 $buttonTitle = ( isset( $this->aButtons['button_' . $bNmbr . '_title'] ) ? $this->aButtons['button_' . $bNmbr . '_title'] : 'Button ' . $bNmbr );
167 $buttonIsPhone = ( isset( $this->aButtons['button_' . $bNmbr . '_is_phonenumber'] ) ? $this->aButtons['button_' . $bNmbr . '_is_phonenumber'] : '' );
168 $linkNewTab = ( isset( $this->aButtons['button_' . $bNmbr . '_url_newtab'] ) ? 'target="_blank"' : '' );
169 $hideLabel = ( isset( $this->aButtons['button_' . $bNmbr . '_hide_label'] ) ? $this->aButtons['button_' . $bNmbr . '_hide_label'] : '' );
170 $sButtonAction = ( isset( $this->aButtons['button_' . $bNmbr . '_action'] ) ? $this->aButtons['button_' . $bNmbr . '_action'] : '' );
171 $sButtonActionLink = str_replace( '"', "'", ( isset( $this->aButtons['button_' . $bNmbr . '_url'] ) ? $this->aButtons['button_' . $bNmbr . '_url'] : '' ) );
172 $buttonStyle = "";
173 $buttonOnClick = "";
174
175 if ( 'phone' == $sButtonAction || $buttonIsPhone ) {
176 $sButtonActionLink = 'tel:' . str_replace( [
177 ' ',
178 '+',
179 '?',
180 '#'
181 ], '', $sButtonActionLink );
182 } else {
183
184 if ( 'mail' == $sButtonAction ) {
185 $sButtonActionLink = 'mailto:' . $sButtonActionLink;
186 } else {
187
188 if ( 'backtotop' == $sButtonAction ) {
189 $sButtonActionLink = "javascript: window.scroll({top: 0, left: 0, behavior: 'smooth' });";
190 } else {
191
192 if ( 'gobackpage' == $sButtonAction ) {
193 $sButtonActionLink = "javascript: window.history.back(); ";
194 } else {
195
196 if ( 'socialsharing' == $sButtonAction ) {
197 $socialData = ( isset( $this->aButtons['button_' . $bNmbr . '_social'] ) ? $this->aButtons['button_' . $bNmbr . '_social'] : 'twitter' );
198 $sButtonActionLink = "javascript:void(0)";
199 //Share options, action buttons
200
201 if ( 'whatsapp' == $socialData ) {
202 $buttonOnClick = "onButtonizerClickEvent('Whatsapp share click'); onButtonizerButtonWhatsapp()";
203 } else {
204
205 if ( 'mail' == $socialData ) {
206 $buttonOnClick = "onButtonizerClickEvent('Email share click'); onButtonizerButtonEmail()";
207 } else {
208
209 if ( 'linkedin' == $socialData ) {
210 $buttonOnClick = "onButtonizerClickEvent('Linkedin share click'); onButtonizerButtonLinkedin()";
211 } else {
212
213 if ( 'facebook' == $socialData ) {
214 $buttonOnClick = "onButtonizerClickEvent('Facebook share click'); onButtonizerButtonFacebook()";
215 } else {
216 if ( 'twitter' == $socialData ) {
217 $buttonOnClick = "onButtonizerClickEvent('Twitter share click'); onButtonizerButtonTwitter()";
218 }
219 }
220
221 }
222
223 }
224
225 }
226
227 }
228
229 }
230
231 }
232
233 }
234
235 }
236
237 // Has image
238
239 if ( !isset( $this->aButtons['button_' . $bNmbr . '_image'] ) || empty($this->aButtons['button_' . $bNmbr . '_image']) ) {
240 $sButtonIcon = '<i class="fa ' . (( isset( $this->aButtons['button_' . $bNmbr . '_icon'] ) ? $this->aButtons['button_' . $bNmbr . '_icon'] : 'plus' )) . '"></i>';
241 } else {
242
243 if ( isset( $this->aButtons['button_' . $bNmbr . '_image_background'] ) && $this->aButtons['button_' . $bNmbr . '_image_background'] == '1' ) {
244 $sButtonIcon = "";
245 $buttonStyle = "background-image: url('" . $this->aButtons['button_' . $bNmbr . '_image'] . "'); background-size: cover; background-position: center;";
246 } else {
247 $sButtonIcon = '<img src="' . $this->aButtons['button_' . $bNmbr . '_image'] . '" style="width: ' . (( count( $this->aButtons ) > 1 ? '25px' : '32px' )) . '; vertical-align: middle;" />';
248 }
249
250 }
251
252 $sButtonClasses = 'is_extra bt_' . $this->iAmountOfButtons;
253 // Show label on hover (per button)
254 $showOnHover = ( isset( $this->aButtons['button_' . $bNmbr . '_show_label_on_hover'] ) ? $this->aButtons['button_' . $bNmbr . '_show_label_on_hover'] : '' );
255
256 if ( $showOnHover == 'showOnHover' ) {
257 $sButtonClasses .= ' show_on_hover';
258 } else {
259
260 if ( $showOnHover == 'showOnHoverDesktop' ) {
261 if ( $this->bIsMobile == false ) {
262 $sButtonClasses .= ' show_on_hover';
263 }
264 } else {
265 if ( $showOnHover == 'showOnHoverMobile' ) {
266 if ( $this->bIsMobile == true ) {
267 $sButtonClasses .= ' show_on_hover';
268 }
269 }
270 }
271
272 }
273
274 // Custom classes
275 $sButtonClasses .= ' ' . $this->getCustomClass( $bNmbr );
276 // Custom colors?
277 if ( isset( $this->aButtons['button_' . $bNmbr . '_using_custom_colors'] ) && $this->aButtons['button_' . $bNmbr . '_using_custom_colors'] == '1' ) {
278 $this->sButtonCss .= '
279 .buttonizer-button .buttonizer_' . $bNmbr . ' {
280 background-color: ' . $this->aButtons['button_' . $bNmbr . '_colors_button'] . ';
281 }
282
283 .buttonizer-button .buttonizer_' . $bNmbr . ':hover,.buttonizer_' . $bNmbr . ':active {
284 background-color: ' . $this->aButtons['button_' . $bNmbr . '_colors_pushed'] . ';
285 }
286
287 .buttonizer-button .buttonizer_' . $bNmbr . ' i {
288 color: ' . $this->aButtons['button_' . $bNmbr . '_colors_icon'] . ';
289 } ';
290 }
291 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>';
292 // Thanks, end
293 }
294
295 /**
296 * Show on timeout
297 *
298 * @return float|int|string
299 */
300 private function showOnTimeout()
301 {
302 return '0';
303 }
304
305 /**
306 * Show on scroll
307 *
308 * @return string|int
309 */
310 private function showOnScroll()
311 {
312 return '0';
313 }
314
315 /**
316 * Exit intent
317 *
318 * @return string
319 */
320 private function enableExitIntent()
321 {
322 return '0';
323 }
324
325 /**
326 * @param $categoryId
327 * @return bool
328 */
329 private function checkPageCategories( $categoryId )
330 {
331 return false;
332 }
333
334 /**
335 * Exit intent
336 *
337 * @return mixed|string
338 */
339 private function enableExitIntentText()
340 {
341 return '';
342 }
343
344 /**
345 * Custom class
346 *
347 * @param $iButtonId
348 * @return string
349 */
350 private function getCustomClass( $iButtonId )
351 {
352 return '';
353 }
354
355 /**
356 * Is the store opened right now?
357 *
358 * @return bool
359 */
360 private function isOpened()
361 {
362 $sDayOfWeek = $this->getDay( date( 'N' ) );
363 // Result
364 $bTodayOpened = ( isset( $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened'] ) ? $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened'] : '' );
365 // If result == 1 => Opened
366
367 if ( $bTodayOpened != "1" ) {
368 $bIsOpened = false;
369 } else {
370 // Get the time right now
371 $sCurentHour = date( "G" );
372 $sCurrentMinute = date( "i" );
373 // Get the opening and closing time from today.
374 $hourOpening = explode( ':', ( isset( $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened_from'] ) ? $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened_from'] : '10:00' ) );
375 $hourClosing = explode( ':', ( isset( $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_closing_on'] ) ? $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_closing_on'] : '17:00' ) );
376 // Check if the company is opened/closed
377
378 if ( $sCurentHour < $hourOpening[0] || $sCurentHour == $hourOpening[0] && $sCurrentMinute < $hourOpening[1] || $sCurentHour > $hourClosing[0] || $sCurentHour == $hourClosing[0] && $sCurrentMinute > $hourClosing[1] - 1 ) {
379 $bIsOpened = false;
380 } else {
381 $bIsOpened = true;
382 }
383
384 }
385
386 return $bIsOpened;
387 }
388
389 /**
390 * Day-number to text
391 *
392 * @param $sDay
393 * @return string
394 */
395 private function getDay( $sDay )
396 {
397 switch ( $sDay ) {
398 case '1':
399 return 'monday';
400 break;
401 case '2':
402 return 'tuesday';
403 break;
404 case '3':
405 return 'wednesday';
406 break;
407 case '4':
408 return 'thursday';
409 break;
410 case '5':
411 return 'friday';
412 break;
413 case '6':
414 return 'saturday';
415 break;
416 case '7':
417 return 'sunday';
418 break;
419 default:
420 return 'sunday';
421 break;
422 }
423 }
424
425 /**
426 * Share buttons
427 */
428 private function share_btns()
429 {
430
431 if ( isset( $this->aSettings["share_facebook"] ) && '1' == $this->aSettings["share_facebook"] ) {
432 $buttonText = ( isset( $this->aSettings['share_facebook_text'] ) && $this->aSettings['share_facebook_text'] != '' ? $this->aSettings['share_facebook_text'] : 'Share this on Facebook' );
433 $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;
434 $this->iAmountOfShareButtons++;
435 }
436
437
438 if ( isset( $this->aSettings["share_twitter"] ) && '1' == $this->aSettings["share_twitter"] ) {
439 $buttonText = ( isset( $this->aSettings['share_twitter_text'] ) && $this->aSettings['share_twitter_text'] != '' ? $this->aSettings['share_twitter_text'] : 'Share this on Twitter' );
440 $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;
441 $this->iAmountOfShareButtons++;
442 }
443
444
445 if ( isset( $this->aSettings["share_linkedin"] ) && '1' == $this->aSettings["share_linkedin"] ) {
446 $buttonText = ( isset( $this->aSettings['share_linkedin_text'] ) && $this->aSettings['share_linkedin_text'] != '' ? $this->aSettings['share_linkedin_text'] : 'Share this on LinkedIn' );
447 $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;
448 $this->iAmountOfShareButtons++;
449 }
450
451
452 if ( isset( $this->aSettings["share_email"] ) && '1' == $this->aSettings["share_email"] ) {
453 $buttonText = ( isset( $this->aSettings['share_email_text'] ) && $this->aSettings['share_email_text'] != '' ? $this->aSettings['share_email_text'] : 'Share this on Email' );
454 $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;
455 $this->iAmountOfShareButtons++;
456 }
457
458 // Coming next update: :)
459 if ( wp_is_mobile() == true ) {
460
461 if ( isset( $this->aSettings["share_whatsapp"] ) && '1' == $this->aSettings["share_whatsapp"] ) {
462 $buttonText = ( isset( $this->aSettings['share_whatsapp_text'] ) && $this->aSettings['share_whatsapp_text'] != '' ? $this->aSettings['share_whatsapp_text'] : 'Share this on Whatsapp' );
463 $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;
464 $this->iAmountOfShareButtons++;
465 }
466
467 }
468 //
469 // if(isset($this->aSettings["share_pinterest"]) && '1' == $this->aSettings["share_pinterest"]) {
470 // $buttonText = (isset($this->aSettings['share_pinterest_text']) && $this->aSettings['share_pinterest_text'] != '' ? ($this->aSettings['share_pinterest_text']) : 'Share this on Pinterest');
471 //
472 // $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;
473 //
474 // $this->iAmountOfShareButtons++;
475 // }
476 }
477
478 /**
479 * Get the positioning of the buttons
480 * @param string $sPositioning
481 * @return string
482 */
483 public function buttonPositioning( $sPositioning = '' )
484 {
485 $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' )) )) . '%;';
486 $sPositioning .= 'bottom: ' . (( isset( $this->aSettings['position_bottom'] ) ? $this->aSettings['position_bottom'] : '5' )) . '%;';
487 return $sPositioning;
488 }
489
490 /**
491 * Output of the button
492 */
493 public function output()
494 {
495 $showAfterTimeout = $this->showOnTimeout();
496 $showOnScroll = $this->showOnScroll();
497 // Main button image or icon
498 $sImage = ( isset( $this->aSettings['custom_icon'] ) ? $this->aSettings['custom_icon'] : '' );
499
500 if ( $sImage != '' ) {
501 $sIcon = '<img src="' . $sImage . '" style="width: 32px; vertical-align: middle;" />';
502 } else {
503 $sIcon = ( !empty($this->aSettings['icon_icon']) && $this->aSettings['icon_icon'] != '+' ? '<i class="isicon-fa fa ' . $this->aSettings['icon_icon'] . '"></i>' : '<i>+</i>' );
504 }
505
506
507 if ( $this->iAmountOfButtons == 1 && $this->iAmountOfShareButtons == 0 ) {
508 $output = str_replace( "is_extra bt_0", "buttonizer_head onlyone", $this->sOutput );
509 } else {
510
511 if ( $this->iAmountOfButtons > 1 || $this->iAmountOfShareButtons > 0 ) {
512 $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;
513 } else {
514 $output = '';
515 }
516
517 }
518
519 // Google analytics toevoegen
520 if ( isset( $this->aSettings['google_analytics'] ) && $this->aSettings['google_analytics'] != "" ) {
521 $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>";
522 }
523
524 if ( isset( $this->aSettings['buttons_animation'] ) && in_array( $this->aSettings['buttons_animation'], $this->aAnimationSettings ) ) {
525 $sButtonAnimation = $this->aSettings['buttons_animation'];
526 } else {
527 $sButtonAnimation = 'default';
528 }
529
530
531 if ( isset( $this->aSettings['attention_animation'] ) && in_array( $this->aSettings['attention_animation'], $this->aAttentionAnimationSettings ) ) {
532 $sAttentionAnimation = $this->aSettings['attention_animation'];
533 } else {
534 $sAttentionAnimation = 'default';
535 }
536
537 // Label hovering
538
539 if ( !isset( $this->aSettings['buttons_label_show_on_hover'] ) || $this->aSettings['buttons_label_show_on_hover'] == 'default' ) {
540 $labelStyle = 'buttonizer_label_default';
541 } else {
542
543 if ( $this->aSettings['buttons_label_show_on_hover'] == 'showOnHover' ) {
544 $labelStyle = 'buttonizer_label_hover';
545 } else {
546
547 if ( $this->aSettings['buttons_label_show_on_hover'] == 'showOnHoverDesktop' ) {
548
549 if ( $this->bIsMobile == false ) {
550 $labelStyle = 'buttonizer_label_hover';
551 } else {
552 $labelStyle = 'buttonizer_label_default';
553 }
554
555 } else {
556 if ( $this->aSettings['buttons_label_show_on_hover'] == 'showOnHoverMobile' ) {
557
558 if ( $this->bIsMobile == true ) {
559 $labelStyle = 'buttonizer_label_hover';
560 } else {
561 $labelStyle = 'buttonizer_label_default';
562 }
563
564 }
565 }
566
567 }
568
569 }
570
571 list( $sShadowColorRed, $sShadowColorGreen, $sShadowColorBlue ) = sscanf( ( isset( $this->aSettings['button_unpushed'] ) ? $this->aSettings['button_unpushed'] : '#1D9BDB' ), "#%02x%02x%02x" );
572 // Mobile button size vs Desktop button size
573
574 if ( $this->bIsMobile ) {
575 $iconSize = ( isset( $this->aSettings['mobile_icon_size'] ) ? $this->aSettings['mobile_icon_size'] : 56 );
576 } else {
577 $iconSize = ( isset( $this->aSettings['icon_size'] ) ? $this->aSettings['icon_size'] : 56 );
578 }
579
580 echo '
581 <style>
582 .buttonizer-button a:hover,
583 .buttonizer-button a:focus{ background:' . (( isset( $this->aSettings['button_pushed'] ) ? $this->aSettings['button_pushed'] : '' )) . '; }
584 .buttonizer-button a { background:' . (( isset( $this->aSettings['button_unpushed'] ) ? $this->aSettings['button_unpushed'] : '' )) . '; }
585 .buttonizer-button a i { color: ' . (( isset( $this->aSettings['icon_color'] ) ? $this->aSettings['icon_color'] : '' )) . '; }
586
587 .buttonizer-button a.buttonizer_head, .buttonizer-button a.buttonizer_head i {
588 height: ' . $iconSize . 'px !important;
589 width: ' . $iconSize . 'px !important;
590 line-height: ' . $iconSize . 'px !important;
591 }
592
593 .buttonizer-button a.buttonizer_head, .buttonizer-button a.buttonizer_head {
594 margin-left: -' . ($iconSize - 56) / 2 . 'px;
595 margin-top: -' . ($iconSize - 56) / 2 . 'px;
596 }
597
598 .buttonizer-button a.buttonizer_head, .buttonizer-button a.is_extra {
599 margin-top: -' . ($iconSize - 56) . 'px;
600 }
601 .buttonizer-button a.buttonizer_head .text{
602 right: ' . ($iconSize + 20) . 'px !important;
603 top: ' . $iconSize / 3 . 'px !important;
604 }
605
606
607 .buttonizer-button[label-style="mirrored"] a.is_extra.share {
608 margin-top: -' . ($iconSize - 56) / 2 . 'px;
609 margin-left: ' . ($iconSize - 56) . 'px;
610 }
611
612 .buttonizer-button[label-style="default"] a.is_extra.share {
613 margin-top: -' . ($iconSize - 56) / 2 . 'px;
614 margin-left: -' . ($iconSize - 56) . 'px !important;
615 }
616
617 .buttonizer-button a .text{
618 background-color: ' . (( isset( $this->aSettings['label_color'] ) ? $this->aSettings['label_color'] : '#4e4c4c' )) . ';
619 color: ' . (( isset( $this->aSettings['label_text_color'] ) ? $this->aSettings['label_text_color'] : '#FFFFFF' )) . ';
620 }
621
622
623
624 ' . $this->sButtonCss . '
625 </style>
626 <div class="buttonizer-button ' . (( $showOnScroll > 0 || $showAfterTimeout > 0 ? 'hide' : '' )) . ' ' . $labelStyle . '"
627 button-animation="' . $sButtonAnimation . '"
628 attention-animation="' . $sAttentionAnimation . '"
629
630
631 label-style="' . (( isset( $this->aSettings['buttons_label_placing'] ) ? $this->aSettings['buttons_label_placing'] : 'default' )) . '"
632
633
634 style="' . $this->buttonPositioning() . '"
635 id="buttonizer-button"><div class="buttonizer_inner" id="buttonizer-sys">' . $output . '</div></div>' ;
636 echo '
637 <script defer type="text/javascript" src="' . plugins_url( '/js/buttonizer.js?v=' . md5( BUTTONIZER_VERSION ), BUTTONIZER_PLUGIN_DIR ) . '"></script>
638 <script type="text/javascript">
639 document.addEventListener(\'DOMContentLoaded\', function(){
640 buttonizer.init({
641 scrollBarTop: ' . $showOnScroll . ',
642 showAfter: ' . $showAfterTimeout . ',
643 ' . (( ButtonizerLicense()->is__premium_only() ? 'exitIntent: ' . $this->enableExitIntent() . ',' : '' )) . '
644 ' . (( ButtonizerLicense()->is__premium_only() ? 'exitIntentText: "' . $this->enableExitIntentText() . '",' : '' )) . '
645 });
646 });
647 </script>' ;
648 }
649
650 }