| 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 $aPageSettings ; |
| 29 |
private $aSettings ; |
| 30 |
private $aOpeningData ; |
| 31 |
// Default settings |
| 32 |
private $bIsMobile = false ; |
| 33 |
private $bIsOpened = true ; |
| 34 |
// Current page |
| 35 |
private $sCurrentPageId = 0 ; |
| 36 |
private $sCurrentPageUrl = '' ; |
| 37 |
private $sCurrentPageTitle = '' ; |
| 38 |
private $sCurrentPageDescription = '' ; |
| 39 |
private $aAnimationSettings = array( 'default', 'circle', 'fade-left-to-right' ) ; |
| 40 |
private $aAttentionAnimationSettings = array( 'none', 'hello', 'bounce' ) ; |
| 41 |
// Output string |
| 42 |
private $iAmountOfButtons = 0 ; |
| 43 |
private $iAmountOfShareButtons = 0 ; |
| 44 |
private $sOutput = '' ; |
| 45 |
// Custom button color |
| 46 |
private $sButtonCss = '' ; |
| 47 |
public function __construct( $bIsMobile ) |
| 48 |
{ |
| 49 |
// Set some data |
| 50 |
$this->bIsMobile = (bool) $bIsMobile; |
| 51 |
add_action( 'wp_footer', function () { |
| 52 |
// Setup |
| 53 |
$this->setup(); |
| 54 |
// Share buttons |
| 55 |
$this->share_btns(); |
| 56 |
// Generate |
| 57 |
$this->generate(); |
| 58 |
// Output |
| 59 |
$this->output(); |
| 60 |
} ); |
| 61 |
add_action( 'wp_print_styles', array( &$this, 'siteLoadStyles' ) ); |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Buttonizer setup |
| 66 |
*/ |
| 67 |
private function setup() |
| 68 |
{ |
| 69 |
// Timezone |
| 70 |
date_default_timezone_set( ( get_option( 'timezone_string' ) != '' ? get_option( 'timezone_string' ) : "Europe/Amsterdam" ) ); |
| 71 |
// Get options |
| 72 |
$this->aButtons = (array) get_option( 'buttonizer_buttons' ); |
| 73 |
$this->aPageSettings = (array) get_option( 'buttonizer_page_categories' ); |
| 74 |
$this->aOpeningData = (array) get_option( 'buttonizer_opening_settings' ); |
| 75 |
$this->aSettings = (array) get_option( 'buttonizer_general_settings' ); |
| 76 |
// Current page data |
| 77 |
$this->sCurrentPageId = get_the_ID(); |
| 78 |
$this->sCurrentPageUrl = urlencode( get_permalink() ); |
| 79 |
$this->sCurrentPageTitle = get_the_title(); |
| 80 |
$this->sCurrentPageDescription = str_replace( " ", "+", get_the_content( 'Read more' ) ); |
| 81 |
// Is store opened |
| 82 |
$this->bIsOpened = $this->isOpened(); |
| 83 |
} |
| 84 |
|
| 85 |
public function siteLoadStyles() |
| 86 |
{ |
| 87 |
wp_enqueue_style( 'buttonizer', plugins_url( '/css/buttonizer.css?v=' . md5( BUTTONIZER_VERSION ), BUTTONIZER_PLUGIN_DIR ) ); |
| 88 |
wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css' ); |
| 89 |
} |
| 90 |
|
| 91 |
// Generate |
| 92 |
private function generate() |
| 93 |
{ |
| 94 |
$aButtons = ( isset( $this->aButtons['buttonorder'] ) && is_array( $this->aButtons['buttonorder'] ) ? $this->aButtons['buttonorder'] : [] ); |
| 95 |
foreach ( $aButtons as $sKey => $iId ) { |
| 96 |
if ( '-1' == $iId ) { |
| 97 |
continue; |
| 98 |
} |
| 99 |
$sButton = $this->generateB( $iId ); |
| 100 |
|
| 101 |
if ( 'continue' == $sButton ) { |
| 102 |
continue; |
| 103 |
} else { |
| 104 |
$this->sOutput = $sButton . $this->sOutput; |
| 105 |
} |
| 106 |
|
| 107 |
$this->iAmountOfButtons++; |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
/** |
| 112 |
* Button generator |
| 113 |
* |
| 114 |
* @param $bNmbr |
| 115 |
* @return string |
| 116 |
*/ |
| 117 |
private function generateB( $bNmbr ) |
| 118 |
{ |
| 119 |
// Check if this one must be showed when the company is open: |
| 120 |
if ( isset( $this->aButtons['button_' . $bNmbr . '_show_when_opened'] ) && !$this->bIsOpened ) { |
| 121 |
return 'continue'; |
| 122 |
} |
| 123 |
// Check if this one must be showed when the company is open: |
| 124 |
if ( isset( $this->aButtons['button_' . $bNmbr . '_show_not_when_opened'] ) && $this->bIsOpened ) { |
| 125 |
return 'continue'; |
| 126 |
} |
| 127 |
// Do we need to show the button? |
| 128 |
|
| 129 |
if ( !isset( $this->aButtons['button_' . $bNmbr . '_show_on_phone'] ) && !isset( $this->aButtons['button_' . $bNmbr . '_show_on_desktop'] ) ) { |
| 130 |
// Skipping because not showing on desktop AND phone |
| 131 |
return 'continue'; |
| 132 |
} else { |
| 133 |
// Is the button visble on mobile phones?: |
| 134 |
if ( $this->bIsMobile && !isset( $this->aButtons['button_' . $bNmbr . '_show_on_phone'] ) ) { |
| 135 |
// Skipping because this is a mobile |
| 136 |
return 'continue'; |
| 137 |
} |
| 138 |
// Is the button visible on desktop?: |
| 139 |
if ( !$this->bIsMobile && !isset( $this->aButtons['button_' . $bNmbr . '_show_on_desktop'] ) ) { |
| 140 |
// Skipping because this is desktop and it musn't get shown here |
| 141 |
return 'continue'; |
| 142 |
} |
| 143 |
} |
| 144 |
|
| 145 |
/* |
| 146 |
* Page categories selected or not |
| 147 |
* Check on what pages the button must be shown |
| 148 |
*/ |
| 149 |
$buttonShowOnPages = ( isset( $this->aButtons['button_' . $bNmbr . '_show_on_pages'] ) ? $this->aButtons['button_' . $bNmbr . '_show_on_pages'] : 'all' ); |
| 150 |
$buttonPagesData = ( isset( $this->aPageSettings['category_' . $buttonShowOnPages] ) ? $this->aPageSettings['category_' . $buttonShowOnPages] : 'all' ); |
| 151 |
$sCategoryType = ( isset( $this->aPageSettings['category_' . $buttonShowOnPages . '_type'] ) ? $this->aPageSettings['category_' . $buttonShowOnPages . '_type'] : 'include' ); |
| 152 |
if ( $buttonShowOnPages != 'all' && $buttonShowOnPages != -5 && $buttonPagesData != 'all' && ($sCategoryType == 'include' && !in_array( $this->sCurrentPageId, $buttonPagesData ) || $sCategoryType == 'exclude' && in_array( $this->sCurrentPageId, $buttonPagesData )) ) { |
| 153 |
return 'continue'; |
| 154 |
} |
| 155 |
/* |
| 156 |
* All button info |
| 157 |
*/ |
| 158 |
$buttonText = ( isset( $this->aButtons['button_' . $bNmbr . '_text'] ) ? $this->aButtons['button_' . $bNmbr . '_text'] : 'Button ' . $bNmbr ); |
| 159 |
$buttonTitle = ( isset( $this->aButtons['button_' . $bNmbr . '_title'] ) ? $this->aButtons['button_' . $bNmbr . '_title'] : 'Button ' . $bNmbr ); |
| 160 |
$buttonIsPhone = ( isset( $this->aButtons['button_' . $bNmbr . '_is_phonenumber'] ) ? $this->aButtons['button_' . $bNmbr . '_is_phonenumber'] : '' ); |
| 161 |
$linkNewTab = ( isset( $this->aButtons['button_' . $bNmbr . '_url_newtab'] ) ? 'target="_blank"' : '' ); |
| 162 |
$hideLabel = ( isset( $this->aButtons['button_' . $bNmbr . '_hide_label'] ) ? $this->aButtons['button_' . $bNmbr . '_hide_label'] : '' ); |
| 163 |
$sButtonAction = ( isset( $this->aButtons['button_' . $bNmbr . '_action'] ) ? $this->aButtons['button_' . $bNmbr . '_action'] : '' ); |
| 164 |
$sButtonActionLink = ( isset( $this->aButtons['button_' . $bNmbr . '_url'] ) ? $this->aButtons['button_' . $bNmbr . '_url'] : '' ); |
| 165 |
|
| 166 |
if ( 'phone' == $sButtonAction || $buttonIsPhone ) { |
| 167 |
$sButtonActionLink = 'tel:' . str_replace( [ |
| 168 |
' ', |
| 169 |
'+', |
| 170 |
'?', |
| 171 |
'#' |
| 172 |
], '', $sButtonActionLink ); |
| 173 |
} else { |
| 174 |
if ( 'mail' == $sButtonAction ) { |
| 175 |
$sButtonActionLink = 'mailto:' . $sButtonActionLink; |
| 176 |
} |
| 177 |
} |
| 178 |
|
| 179 |
// Has image |
| 180 |
|
| 181 |
if ( !isset( $this->aButtons['button_' . $bNmbr . '_image'] ) || empty($this->aButtons['button_' . $bNmbr . '_image']) ) { |
| 182 |
$sButtonIcon = '<i class="fa ' . (( isset( $this->aButtons['button_' . $bNmbr . '_icon'] ) ? $this->aButtons['button_' . $bNmbr . '_icon'] : 'plus' )) . '"></i>'; |
| 183 |
} else { |
| 184 |
$sButtonIcon = '<img src="' . $this->aButtons['button_' . $bNmbr . '_image'] . '" style="width: ' . (( count( $this->aButtons ) > 1 ? '25px' : '32px' )) . '; vertical-align: middle;" />'; |
| 185 |
} |
| 186 |
|
| 187 |
$sButtonClasses = 'is_extra bt_' . $this->iAmountOfButtons; |
| 188 |
// Show label on hover |
| 189 |
if ( isset( $this->aButtons['button_' . $bNmbr . '_show_label_on_hover'] ) && $this->aButtons['button_' . $bNmbr . '_show_label_on_hover'] == '1' ) { |
| 190 |
$sButtonClasses .= ' show_on_hover'; |
| 191 |
} |
| 192 |
// Custom classes |
| 193 |
$sButtonClasses .= ' ' . $this->getCustomClass( $bNmbr ); |
| 194 |
// Custom colors? |
| 195 |
if ( isset( $this->aButtons['button_' . $bNmbr . '_using_custom_colors'] ) && $this->aButtons['button_' . $bNmbr . '_using_custom_colors'] == '1' ) { |
| 196 |
$this->sButtonCss .= ' |
| 197 |
.buttonizer-button .buttonizer_' . $bNmbr . ' { |
| 198 |
background-color: ' . $this->aButtons['button_' . $bNmbr . '_colors_button'] . '; |
| 199 |
} |
| 200 |
|
| 201 |
.buttonizer-button .buttonizer_' . $bNmbr . ':hover,.buttonizer_' . $bNmbr . ':active { |
| 202 |
background-color: ' . $this->aButtons['button_' . $bNmbr . '_colors_pushed'] . '; |
| 203 |
} |
| 204 |
|
| 205 |
.buttonizer-button .buttonizer_' . $bNmbr . ' i { |
| 206 |
color: ' . $this->aButtons['button_' . $bNmbr . '_colors_icon'] . '; |
| 207 |
} '; |
| 208 |
} |
| 209 |
return '<a href="' . $sButtonActionLink . '" class="' . $sButtonClasses . ' is_btzn_btn buttonizer_' . $bNmbr . '" ' . $linkNewTab . ' onclick="onButtonizerClickEvent(\'' . $buttonTitle . '\')">' . (( $buttonText != "" ? '<div class="text"' . (( $hideLabel == '1' ? 'style="display: none;"' : '' )) . '><div>' . $buttonText . '</div></div>' : '' )) . $sButtonIcon . '</a>'; |
| 210 |
// Thanks, end |
| 211 |
} |
| 212 |
|
| 213 |
/** |
| 214 |
* Show on timeout |
| 215 |
* |
| 216 |
* @return float|int|string |
| 217 |
*/ |
| 218 |
private function showOnTimeout() |
| 219 |
{ |
| 220 |
return '0'; |
| 221 |
} |
| 222 |
|
| 223 |
/** |
| 224 |
* Show on scroll |
| 225 |
* |
| 226 |
* @return string|int |
| 227 |
*/ |
| 228 |
private function showOnScroll() |
| 229 |
{ |
| 230 |
return '0'; |
| 231 |
} |
| 232 |
|
| 233 |
/** |
| 234 |
* Exit intent |
| 235 |
* |
| 236 |
* @return string |
| 237 |
*/ |
| 238 |
private function enableExitIntent() |
| 239 |
{ |
| 240 |
return '0'; |
| 241 |
} |
| 242 |
|
| 243 |
/** |
| 244 |
* Exit intent |
| 245 |
* |
| 246 |
* @return mixed|string |
| 247 |
*/ |
| 248 |
private function enableExitIntentText() |
| 249 |
{ |
| 250 |
return ''; |
| 251 |
} |
| 252 |
|
| 253 |
/** |
| 254 |
* Custom class |
| 255 |
* |
| 256 |
* @param $iButtonId |
| 257 |
* @return string |
| 258 |
*/ |
| 259 |
private function getCustomClass( $iButtonId ) |
| 260 |
{ |
| 261 |
return ''; |
| 262 |
} |
| 263 |
|
| 264 |
/** |
| 265 |
* Is the store opened right now? |
| 266 |
* |
| 267 |
* @return bool |
| 268 |
*/ |
| 269 |
private function isOpened() |
| 270 |
{ |
| 271 |
$sDayOfWeek = $this->getDay( date( 'N' ) ); |
| 272 |
// Result |
| 273 |
$bTodayOpened = ( isset( $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened'] ) ? $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened'] : '' ); |
| 274 |
// If result == 1 => Opened |
| 275 |
|
| 276 |
if ( $bTodayOpened != "1" ) { |
| 277 |
$bIsOpened = false; |
| 278 |
} else { |
| 279 |
// Get the time right now |
| 280 |
$sCurentHour = date( "G" ); |
| 281 |
$sCurrentMinute = date( "i" ); |
| 282 |
// Get the opening and closing time from today. |
| 283 |
$hourOpening = explode( ':', ( isset( $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened_from'] ) ? $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened_from'] : '10:00' ) ); |
| 284 |
$hourClosing = explode( ':', ( isset( $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_closing_on'] ) ? $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_closing_on'] : '17:00' ) ); |
| 285 |
// Check if the company is opened/closed |
| 286 |
|
| 287 |
if ( $sCurentHour < $hourOpening[0] || $sCurentHour == $hourOpening[0] && $sCurrentMinute < $hourOpening[1] || $sCurentHour > $hourClosing[0] || $sCurentHour == $hourClosing[0] && $sCurrentMinute > $hourClosing[1] - 1 ) { |
| 288 |
$bIsOpened = false; |
| 289 |
} else { |
| 290 |
$bIsOpened = true; |
| 291 |
} |
| 292 |
|
| 293 |
} |
| 294 |
|
| 295 |
return $bIsOpened; |
| 296 |
} |
| 297 |
|
| 298 |
/** |
| 299 |
* Day-number to text |
| 300 |
* |
| 301 |
* @param $sDay |
| 302 |
* @return string |
| 303 |
*/ |
| 304 |
private function getDay( $sDay ) |
| 305 |
{ |
| 306 |
switch ( $sDay ) { |
| 307 |
case '1': |
| 308 |
return 'monday'; |
| 309 |
break; |
| 310 |
case '2': |
| 311 |
return 'tuesday'; |
| 312 |
break; |
| 313 |
case '3': |
| 314 |
return 'wednesday'; |
| 315 |
break; |
| 316 |
case '4': |
| 317 |
return 'thursday'; |
| 318 |
break; |
| 319 |
case '5': |
| 320 |
return 'friday'; |
| 321 |
break; |
| 322 |
case '6': |
| 323 |
return 'saturday'; |
| 324 |
break; |
| 325 |
case '7': |
| 326 |
return 'sunday'; |
| 327 |
break; |
| 328 |
default: |
| 329 |
return 'sunday'; |
| 330 |
break; |
| 331 |
} |
| 332 |
} |
| 333 |
|
| 334 |
/** |
| 335 |
* Share buttons |
| 336 |
*/ |
| 337 |
private function share_btns() |
| 338 |
{ |
| 339 |
|
| 340 |
if ( isset( $this->aSettings["share_facebook"] ) && '1' == $this->aSettings["share_facebook"] ) { |
| 341 |
$buttonText = ( isset( $this->aSettings['share_facebook_text'] ) && $this->aSettings['share_facebook_text'] != '' ? $this->aSettings['share_facebook_text'] : 'Share this on Facebok' ); |
| 342 |
$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; |
| 343 |
$this->iAmountOfShareButtons++; |
| 344 |
} |
| 345 |
|
| 346 |
|
| 347 |
if ( isset( $this->aSettings["share_twitter"] ) && '1' == $this->aSettings["share_twitter"] ) { |
| 348 |
$buttonText = ( isset( $this->aSettings['share_twitter_text'] ) && $this->aSettings['share_twitter_text'] != '' ? $this->aSettings['share_twitter_text'] : 'Share this on Twitter' ); |
| 349 |
$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; |
| 350 |
$this->iAmountOfShareButtons++; |
| 351 |
} |
| 352 |
|
| 353 |
|
| 354 |
if ( isset( $this->aSettings["share_linkedin"] ) && '1' == $this->aSettings["share_linkedin"] ) { |
| 355 |
$buttonText = ( isset( $this->aSettings['share_linkedin_text'] ) && $this->aSettings['share_linkedin_text'] != '' ? $this->aSettings['share_linkedin_text'] : 'Share this on LinkedIn' ); |
| 356 |
$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; |
| 357 |
$this->iAmountOfShareButtons++; |
| 358 |
} |
| 359 |
|
| 360 |
} |
| 361 |
|
| 362 |
/** |
| 363 |
* Get the positioning of the buttons |
| 364 |
* @param string $sPositioning |
| 365 |
* @return string |
| 366 |
*/ |
| 367 |
public function buttonPositioning( $sPositioning = '' ) |
| 368 |
{ |
| 369 |
$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' )) )) . '%;'; |
| 370 |
$sPositioning .= 'bottom: ' . (( isset( $this->aSettings['position_bottom'] ) ? $this->aSettings['position_bottom'] : '5' )) . '%;'; |
| 371 |
return $sPositioning; |
| 372 |
} |
| 373 |
|
| 374 |
/** |
| 375 |
* Output of the button |
| 376 |
*/ |
| 377 |
public function output() |
| 378 |
{ |
| 379 |
$showAfterTimeout = $this->showOnTimeout(); |
| 380 |
$showOnScroll = $this->showOnScroll(); |
| 381 |
// Main button image or icon |
| 382 |
$sImage = ( isset( $this->aSettings['custom_icon'] ) ? $this->aSettings['custom_icon'] : '' ); |
| 383 |
|
| 384 |
if ( $sImage != '' ) { |
| 385 |
$sIcon = '<img src="' . $sImage . '" style="width: 32px; vertical-align: middle;" />'; |
| 386 |
} else { |
| 387 |
$sIcon = ( !empty($this->aSettings['icon_icon']) && $this->aSettings['icon_icon'] != '+' ? '<i class="isicon-fa fa ' . $this->aSettings['icon_icon'] . '"></i>' : '<i>+</i>' ); |
| 388 |
} |
| 389 |
|
| 390 |
|
| 391 |
if ( $this->iAmountOfButtons == 1 && $this->iAmountOfShareButtons == 0 ) { |
| 392 |
$output = str_replace( "is_extra bt_0", "buttonizer_head onlyone", $this->sOutput ); |
| 393 |
} else { |
| 394 |
|
| 395 |
if ( $this->iAmountOfButtons > 1 || $this->iAmountOfShareButtons > 0 ) { |
| 396 |
$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; |
| 397 |
} else { |
| 398 |
$output = ''; |
| 399 |
} |
| 400 |
|
| 401 |
} |
| 402 |
|
| 403 |
// Google analytics toevoegen |
| 404 |
if ( isset( $this->aSettings['google_analytics'] ) && $this->aSettings['google_analytics'] != "" ) { |
| 405 |
$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>"; |
| 406 |
} |
| 407 |
|
| 408 |
if ( isset( $this->aSettings['buttons_animation'] ) && in_array( $this->aSettings['buttons_animation'], $this->aAnimationSettings ) ) { |
| 409 |
$sButtonAnimation = $this->aSettings['buttons_animation']; |
| 410 |
} else { |
| 411 |
$sButtonAnimation = 'default'; |
| 412 |
} |
| 413 |
|
| 414 |
|
| 415 |
if ( isset( $this->aSettings['attention_animation'] ) && in_array( $this->aSettings['attention_animation'], $this->aAttentionAnimationSettings ) ) { |
| 416 |
$sAttentionAnimation = $this->aSettings['attention_animation']; |
| 417 |
} else { |
| 418 |
$sAttentionAnimation = 'default'; |
| 419 |
} |
| 420 |
|
| 421 |
list( $sShadowColorRed, $sShadowColorGreen, $sShadowColorBlue ) = sscanf( $this->aSettings['button_unpushed'], "#%02x%02x%02x" ); |
| 422 |
echo '<style>.buttonizer-button a:hover, .buttonizer-button a:focus{ background:' . $this->aSettings['button_pushed'] . '; } .buttonizer-button a { background:' . $this->aSettings['button_unpushed'] . '; } .buttonizer-button a i { color: ' . $this->aSettings['icon_color'] . '; } ' . $this->sButtonCss . '</style> |
| 423 |
<div class="buttonizer-button ' . (( $showOnScroll > 0 || $showAfterTimeout > 0 ? 'hide' : '' )) . ' ' . (( isset( $this->aSettings['buttons_label_show_on_hover'] ) && $this->aSettings['buttons_label_show_on_hover'] == '1' ? ' show_labels_on_hover' : '' )) . '" |
| 424 |
button-animation="' . $sButtonAnimation . '" |
| 425 |
attention-animation="' . $sAttentionAnimation . '" |
| 426 |
label-style="' . (( isset( $this->aSettings['buttons_label_placing'] ) ? $this->aSettings['buttons_label_placing'] : 'default' )) . '" |
| 427 |
style="' . $this->buttonPositioning() . '" |
| 428 |
id="buttonizer-button"><div class="buttonizer_inner" id="buttonizer-sys">' . $output . '</div></div>' ; |
| 429 |
echo ' |
| 430 |
<script defer type="text/javascript" src="' . plugins_url( '/js/buttonizer.js?v=' . md5( BUTTONIZER_VERSION ), BUTTONIZER_PLUGIN_DIR ) . '"></script> |
| 431 |
<script type="text/javascript"> |
| 432 |
document.addEventListener(\'DOMContentLoaded\', function(){ |
| 433 |
buttonizer.init({ |
| 434 |
scrollBarTop: ' . $showOnScroll . ', |
| 435 |
showAfter: ' . $showAfterTimeout . ', |
| 436 |
' . (( ButtonizerLicense()->is__premium_only() ? 'exitIntent: ' . $this->enableExitIntent() . ',' : '' )) . ' |
| 437 |
' . (( ButtonizerLicense()->is__premium_only() ? 'exitIntentText: "' . $this->enableExitIntentText() . '",' : '' )) . ' |
| 438 |
}); |
| 439 |
}); |
| 440 |
</script>' ; |
| 441 |
} |
| 442 |
|
| 443 |
} |