| 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 = addslashes( ( isset( $this->aButtons['button_' . $bNmbr . '_url'] ) ? $this->aButtons['button_' . $bNmbr . '_url'] : '' ) ); |
| 171 |
|
| 172 |
if ( 'phone' == $sButtonAction || $buttonIsPhone ) { |
| 173 |
$sButtonActionLink = 'tel:' . str_replace( [ |
| 174 |
' ', |
| 175 |
'+', |
| 176 |
'?', |
| 177 |
'#' |
| 178 |
], '', $sButtonActionLink ); |
| 179 |
} else { |
| 180 |
|
| 181 |
if ( 'mail' == $sButtonAction ) { |
| 182 |
$sButtonActionLink = 'mailto:' . $sButtonActionLink; |
| 183 |
} else { |
| 184 |
if ( 'backtotop' == $sButtonAction ) { |
| 185 |
$sButtonActionLink = "javascript: window.scroll({top: 0, left: 0, behavior: 'smooth' });"; |
| 186 |
} |
| 187 |
} |
| 188 |
|
| 189 |
} |
| 190 |
|
| 191 |
// Has image |
| 192 |
|
| 193 |
if ( !isset( $this->aButtons['button_' . $bNmbr . '_image'] ) || empty($this->aButtons['button_' . $bNmbr . '_image']) ) { |
| 194 |
$sButtonIcon = '<i class="fa ' . (( isset( $this->aButtons['button_' . $bNmbr . '_icon'] ) ? $this->aButtons['button_' . $bNmbr . '_icon'] : 'plus' )) . '"></i>'; |
| 195 |
} else { |
| 196 |
$sButtonIcon = '<img src="' . $this->aButtons['button_' . $bNmbr . '_image'] . '" style="width: ' . (( count( $this->aButtons ) > 1 ? '25px' : '32px' )) . '; vertical-align: middle;" />'; |
| 197 |
} |
| 198 |
|
| 199 |
$sButtonClasses = 'is_extra bt_' . $this->iAmountOfButtons; |
| 200 |
// Show label on hover |
| 201 |
// if(isset($this->aButtons['button_' . $bNmbr . '_show_label_on_hover']) && $this->aButtons['button_' . $bNmbr . '_show_label_on_hover'] == '1') { |
| 202 |
// $sButtonClasses .= ' show_on_hover'; |
| 203 |
// } |
| 204 |
|
| 205 |
if ( $this->aButtons['button_' . $bNmbr . '_show_label_on_hover'] == 'showOnHover' ) { |
| 206 |
$sButtonClasses .= ' show_on_hover'; |
| 207 |
} else { |
| 208 |
|
| 209 |
if ( $this->aButtons['button_' . $bNmbr . '_show_label_on_hover'] == 'showOnHoverDesktop' ) { |
| 210 |
if ( $this->bIsMobile == false ) { |
| 211 |
$sButtonClasses .= ' show_on_hover'; |
| 212 |
} |
| 213 |
} else { |
| 214 |
if ( $this->aButtons['button_' . $bNmbr . '_show_label_on_hover'] == 'showOnHoverMobile' ) { |
| 215 |
if ( $this->bIsMobile == true ) { |
| 216 |
$sButtonClasses .= ' show_on_hover'; |
| 217 |
} |
| 218 |
} |
| 219 |
} |
| 220 |
|
| 221 |
} |
| 222 |
|
| 223 |
// Custom classes |
| 224 |
$sButtonClasses .= ' ' . $this->getCustomClass( $bNmbr ); |
| 225 |
// Custom colors? |
| 226 |
if ( isset( $this->aButtons['button_' . $bNmbr . '_using_custom_colors'] ) && $this->aButtons['button_' . $bNmbr . '_using_custom_colors'] == '1' ) { |
| 227 |
$this->sButtonCss .= ' |
| 228 |
.buttonizer-button .buttonizer_' . $bNmbr . ' { |
| 229 |
background-color: ' . $this->aButtons['button_' . $bNmbr . '_colors_button'] . '; |
| 230 |
} |
| 231 |
|
| 232 |
.buttonizer-button .buttonizer_' . $bNmbr . ':hover,.buttonizer_' . $bNmbr . ':active { |
| 233 |
background-color: ' . $this->aButtons['button_' . $bNmbr . '_colors_pushed'] . '; |
| 234 |
} |
| 235 |
|
| 236 |
.buttonizer-button .buttonizer_' . $bNmbr . ' i { |
| 237 |
color: ' . $this->aButtons['button_' . $bNmbr . '_colors_icon'] . '; |
| 238 |
} '; |
| 239 |
} |
| 240 |
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>'; |
| 241 |
// Thanks, end |
| 242 |
} |
| 243 |
|
| 244 |
/** |
| 245 |
* Show on timeout |
| 246 |
* |
| 247 |
* @return float|int|string |
| 248 |
*/ |
| 249 |
private function showOnTimeout() |
| 250 |
{ |
| 251 |
return '0'; |
| 252 |
} |
| 253 |
|
| 254 |
/** |
| 255 |
* Show on scroll |
| 256 |
* |
| 257 |
* @return string|int |
| 258 |
*/ |
| 259 |
private function showOnScroll() |
| 260 |
{ |
| 261 |
return '0'; |
| 262 |
} |
| 263 |
|
| 264 |
/** |
| 265 |
* Exit intent |
| 266 |
* |
| 267 |
* @return string |
| 268 |
*/ |
| 269 |
private function enableExitIntent() |
| 270 |
{ |
| 271 |
return '0'; |
| 272 |
} |
| 273 |
|
| 274 |
/** |
| 275 |
* @param $categoryId |
| 276 |
* @return bool |
| 277 |
*/ |
| 278 |
private function checkPageCategories( $categoryId ) |
| 279 |
{ |
| 280 |
return false; |
| 281 |
} |
| 282 |
|
| 283 |
/** |
| 284 |
* Exit intent |
| 285 |
* |
| 286 |
* @return mixed|string |
| 287 |
*/ |
| 288 |
private function enableExitIntentText() |
| 289 |
{ |
| 290 |
return ''; |
| 291 |
} |
| 292 |
|
| 293 |
/** |
| 294 |
* Custom class |
| 295 |
* |
| 296 |
* @param $iButtonId |
| 297 |
* @return string |
| 298 |
*/ |
| 299 |
private function getCustomClass( $iButtonId ) |
| 300 |
{ |
| 301 |
return ''; |
| 302 |
} |
| 303 |
|
| 304 |
/** |
| 305 |
* Is the store opened right now? |
| 306 |
* |
| 307 |
* @return bool |
| 308 |
*/ |
| 309 |
private function isOpened() |
| 310 |
{ |
| 311 |
$sDayOfWeek = $this->getDay( date( 'N' ) ); |
| 312 |
// Result |
| 313 |
$bTodayOpened = ( isset( $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened'] ) ? $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened'] : '' ); |
| 314 |
// If result == 1 => Opened |
| 315 |
|
| 316 |
if ( $bTodayOpened != "1" ) { |
| 317 |
$bIsOpened = false; |
| 318 |
} else { |
| 319 |
// Get the time right now |
| 320 |
$sCurentHour = date( "G" ); |
| 321 |
$sCurrentMinute = date( "i" ); |
| 322 |
// Get the opening and closing time from today. |
| 323 |
$hourOpening = explode( ':', ( isset( $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened_from'] ) ? $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened_from'] : '10:00' ) ); |
| 324 |
$hourClosing = explode( ':', ( isset( $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_closing_on'] ) ? $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_closing_on'] : '17:00' ) ); |
| 325 |
// Check if the company is opened/closed |
| 326 |
|
| 327 |
if ( $sCurentHour < $hourOpening[0] || $sCurentHour == $hourOpening[0] && $sCurrentMinute < $hourOpening[1] || $sCurentHour > $hourClosing[0] || $sCurentHour == $hourClosing[0] && $sCurrentMinute > $hourClosing[1] - 1 ) { |
| 328 |
$bIsOpened = false; |
| 329 |
} else { |
| 330 |
$bIsOpened = true; |
| 331 |
} |
| 332 |
|
| 333 |
} |
| 334 |
|
| 335 |
return $bIsOpened; |
| 336 |
} |
| 337 |
|
| 338 |
/** |
| 339 |
* Day-number to text |
| 340 |
* |
| 341 |
* @param $sDay |
| 342 |
* @return string |
| 343 |
*/ |
| 344 |
private function getDay( $sDay ) |
| 345 |
{ |
| 346 |
switch ( $sDay ) { |
| 347 |
case '1': |
| 348 |
return 'monday'; |
| 349 |
break; |
| 350 |
case '2': |
| 351 |
return 'tuesday'; |
| 352 |
break; |
| 353 |
case '3': |
| 354 |
return 'wednesday'; |
| 355 |
break; |
| 356 |
case '4': |
| 357 |
return 'thursday'; |
| 358 |
break; |
| 359 |
case '5': |
| 360 |
return 'friday'; |
| 361 |
break; |
| 362 |
case '6': |
| 363 |
return 'saturday'; |
| 364 |
break; |
| 365 |
case '7': |
| 366 |
return 'sunday'; |
| 367 |
break; |
| 368 |
default: |
| 369 |
return 'sunday'; |
| 370 |
break; |
| 371 |
} |
| 372 |
} |
| 373 |
|
| 374 |
/** |
| 375 |
* Share buttons |
| 376 |
*/ |
| 377 |
private function share_btns() |
| 378 |
{ |
| 379 |
|
| 380 |
if ( isset( $this->aSettings["share_facebook"] ) && '1' == $this->aSettings["share_facebook"] ) { |
| 381 |
$buttonText = ( isset( $this->aSettings['share_facebook_text'] ) && $this->aSettings['share_facebook_text'] != '' ? $this->aSettings['share_facebook_text'] : 'Share this on Facebook' ); |
| 382 |
$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; |
| 383 |
$this->iAmountOfShareButtons++; |
| 384 |
} |
| 385 |
|
| 386 |
|
| 387 |
if ( isset( $this->aSettings["share_twitter"] ) && '1' == $this->aSettings["share_twitter"] ) { |
| 388 |
$buttonText = ( isset( $this->aSettings['share_twitter_text'] ) && $this->aSettings['share_twitter_text'] != '' ? $this->aSettings['share_twitter_text'] : 'Share this on Twitter' ); |
| 389 |
$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; |
| 390 |
$this->iAmountOfShareButtons++; |
| 391 |
} |
| 392 |
|
| 393 |
|
| 394 |
if ( isset( $this->aSettings["share_linkedin"] ) && '1' == $this->aSettings["share_linkedin"] ) { |
| 395 |
$buttonText = ( isset( $this->aSettings['share_linkedin_text'] ) && $this->aSettings['share_linkedin_text'] != '' ? $this->aSettings['share_linkedin_text'] : 'Share this on LinkedIn' ); |
| 396 |
$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; |
| 397 |
$this->iAmountOfShareButtons++; |
| 398 |
} |
| 399 |
|
| 400 |
|
| 401 |
if ( isset( $this->aSettings["share_email"] ) && '1' == $this->aSettings["share_email"] ) { |
| 402 |
$buttonText = ( isset( $this->aSettings['share_email_text'] ) && $this->aSettings['share_email_text'] != '' ? $this->aSettings['share_email_text'] : 'Share this on Email' ); |
| 403 |
$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; |
| 404 |
$this->iAmountOfShareButtons++; |
| 405 |
} |
| 406 |
|
| 407 |
// Coming next update: :) |
| 408 |
// if(isset($this->aSettings["share_whatsapp"]) && '1' == $this->aSettings["share_whatsapp"]) { |
| 409 |
// $buttonText = (isset($this->aSettings['share_whatsapp_text']) && $this->aSettings['share_whatsapp_text'] != '' ? ($this->aSettings['share_whatsapp_text']) : 'Share this on Whatsapp'); |
| 410 |
// |
| 411 |
// $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; |
| 412 |
// |
| 413 |
// $this->iAmountOfShareButtons++; |
| 414 |
// } |
| 415 |
// |
| 416 |
// if(isset($this->aSettings["share_pinterest"]) && '1' == $this->aSettings["share_pinterest"]) { |
| 417 |
// $buttonText = (isset($this->aSettings['share_pinterest_text']) && $this->aSettings['share_pinterest_text'] != '' ? ($this->aSettings['share_pinterest_text']) : 'Share this on Pinterest'); |
| 418 |
// |
| 419 |
// $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; |
| 420 |
// |
| 421 |
// $this->iAmountOfShareButtons++; |
| 422 |
// } |
| 423 |
} |
| 424 |
|
| 425 |
/** |
| 426 |
* Get the positioning of the buttons |
| 427 |
* @param string $sPositioning |
| 428 |
* @return string |
| 429 |
*/ |
| 430 |
public function buttonPositioning( $sPositioning = '' ) |
| 431 |
{ |
| 432 |
$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' )) )) . '%;'; |
| 433 |
$sPositioning .= 'bottom: ' . (( isset( $this->aSettings['position_bottom'] ) ? $this->aSettings['position_bottom'] : '5' )) . '%;'; |
| 434 |
return $sPositioning; |
| 435 |
} |
| 436 |
|
| 437 |
/** |
| 438 |
* Output of the button |
| 439 |
*/ |
| 440 |
public function output() |
| 441 |
{ |
| 442 |
$showAfterTimeout = $this->showOnTimeout(); |
| 443 |
$showOnScroll = $this->showOnScroll(); |
| 444 |
// Main button image or icon |
| 445 |
$sImage = ( isset( $this->aSettings['custom_icon'] ) ? $this->aSettings['custom_icon'] : '' ); |
| 446 |
|
| 447 |
if ( $sImage != '' ) { |
| 448 |
$sIcon = '<img src="' . $sImage . '" style="width: 32px; vertical-align: middle;" />'; |
| 449 |
} else { |
| 450 |
$sIcon = ( !empty($this->aSettings['icon_icon']) && $this->aSettings['icon_icon'] != '+' ? '<i class="isicon-fa fa ' . $this->aSettings['icon_icon'] . '"></i>' : '<i>+</i>' ); |
| 451 |
} |
| 452 |
|
| 453 |
|
| 454 |
if ( $this->iAmountOfButtons == 1 && $this->iAmountOfShareButtons == 0 ) { |
| 455 |
$output = str_replace( "is_extra bt_0", "buttonizer_head onlyone", $this->sOutput ); |
| 456 |
} else { |
| 457 |
|
| 458 |
if ( $this->iAmountOfButtons > 1 || $this->iAmountOfShareButtons > 0 ) { |
| 459 |
$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; |
| 460 |
} else { |
| 461 |
$output = ''; |
| 462 |
} |
| 463 |
|
| 464 |
} |
| 465 |
|
| 466 |
// Google analytics toevoegen |
| 467 |
if ( isset( $this->aSettings['google_analytics'] ) && $this->aSettings['google_analytics'] != "" ) { |
| 468 |
$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>"; |
| 469 |
} |
| 470 |
|
| 471 |
if ( isset( $this->aSettings['buttons_animation'] ) && in_array( $this->aSettings['buttons_animation'], $this->aAnimationSettings ) ) { |
| 472 |
$sButtonAnimation = $this->aSettings['buttons_animation']; |
| 473 |
} else { |
| 474 |
$sButtonAnimation = 'default'; |
| 475 |
} |
| 476 |
|
| 477 |
|
| 478 |
if ( isset( $this->aSettings['attention_animation'] ) && in_array( $this->aSettings['attention_animation'], $this->aAttentionAnimationSettings ) ) { |
| 479 |
$sAttentionAnimation = $this->aSettings['attention_animation']; |
| 480 |
} else { |
| 481 |
$sAttentionAnimation = 'default'; |
| 482 |
} |
| 483 |
|
| 484 |
// Label hovering |
| 485 |
|
| 486 |
if ( $this->aSettings['buttons_label_show_on_hover'] == 'default' ) { |
| 487 |
$labelStyle = 'buttonizer_label_default'; |
| 488 |
} else { |
| 489 |
|
| 490 |
if ( $this->aSettings['buttons_label_show_on_hover'] == 'showOnHover' ) { |
| 491 |
$labelStyle = 'buttonizer_label_hover'; |
| 492 |
} else { |
| 493 |
|
| 494 |
if ( $this->aSettings['buttons_label_show_on_hover'] == 'showOnHoverDesktop' ) { |
| 495 |
|
| 496 |
if ( $this->bIsMobile == false ) { |
| 497 |
$labelStyle = 'buttonizer_label_hover'; |
| 498 |
} else { |
| 499 |
$labelStyle = 'buttonizer_label_default'; |
| 500 |
} |
| 501 |
|
| 502 |
} else { |
| 503 |
if ( $this->aSettings['buttons_label_show_on_hover'] == 'showOnHoverMobile' ) { |
| 504 |
|
| 505 |
if ( $this->bIsMobile == true ) { |
| 506 |
$labelStyle = 'buttonizer_label_hover'; |
| 507 |
} else { |
| 508 |
$labelStyle = 'buttonizer_label_default'; |
| 509 |
} |
| 510 |
|
| 511 |
} |
| 512 |
} |
| 513 |
|
| 514 |
} |
| 515 |
|
| 516 |
} |
| 517 |
|
| 518 |
list( $sShadowColorRed, $sShadowColorGreen, $sShadowColorBlue ) = sscanf( $this->aSettings['button_unpushed'], "#%02x%02x%02x" ); |
| 519 |
$iconSize = ( isset( $this->aSettings['icon_size'] ) ? $this->aSettings['icon_size'] : 56 ); |
| 520 |
echo ' |
| 521 |
<style> |
| 522 |
.buttonizer-button a:hover, |
| 523 |
.buttonizer-button a:focus{ background:' . $this->aSettings['button_pushed'] . '; } |
| 524 |
.buttonizer-button a { background:' . $this->aSettings['button_unpushed'] . '; } |
| 525 |
.buttonizer-button a i { color: ' . $this->aSettings['icon_color'] . '; } |
| 526 |
|
| 527 |
.buttonizer-button a.buttonizer_head, .buttonizer-button a.buttonizer_head i { |
| 528 |
height: ' . $iconSize . 'px !important; |
| 529 |
width: ' . $iconSize . 'px !important; |
| 530 |
line-height: ' . $iconSize . 'px !important; |
| 531 |
} |
| 532 |
|
| 533 |
.buttonizer-button a.buttonizer_head, .buttonizer-button a.buttonizer_head { |
| 534 |
margin-left: -' . ($iconSize - 56) / 2 . 'px; |
| 535 |
margin-top: -' . ($iconSize - 56) / 2 . 'px; |
| 536 |
} |
| 537 |
|
| 538 |
.buttonizer-button a.buttonizer_head, .buttonizer-button a.is_extra { |
| 539 |
margin-top: -' . ($iconSize - 56) . 'px; |
| 540 |
} |
| 541 |
.buttonizer-button a.buttonizer_head .text{ |
| 542 |
right: ' . ($iconSize + 20) . 'px !important; |
| 543 |
top: ' . $iconSize / 3 . 'px !important; |
| 544 |
} |
| 545 |
|
| 546 |
|
| 547 |
.buttonizer-button[label-style="mirrored"] a.is_extra.share { |
| 548 |
margin-top: -' . ($iconSize - 56) / 2 . 'px; |
| 549 |
margin-left: ' . ($iconSize - 56) . 'px; |
| 550 |
} |
| 551 |
|
| 552 |
.buttonizer-button[label-style="default"] a.is_extra.share { |
| 553 |
margin-top: -' . ($iconSize - 56) / 2 . 'px; |
| 554 |
margin-left: -' . ($iconSize - 56) . 'px !important; |
| 555 |
} |
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
' . $this->sButtonCss . ' |
| 560 |
</style> |
| 561 |
<div class="buttonizer-button ' . (( $showOnScroll > 0 || $showAfterTimeout > 0 ? 'hide' : '' )) . ' ' . $labelStyle . '" |
| 562 |
button-animation="' . $sButtonAnimation . '" |
| 563 |
attention-animation="' . $sAttentionAnimation . '" |
| 564 |
|
| 565 |
|
| 566 |
label-style="' . (( isset( $this->aSettings['buttons_label_placing'] ) ? $this->aSettings['buttons_label_placing'] : 'default' )) . '" |
| 567 |
|
| 568 |
|
| 569 |
style="' . $this->buttonPositioning() . '" |
| 570 |
id="buttonizer-button"><div class="buttonizer_inner" id="buttonizer-sys">' . $output . '</div></div>' ; |
| 571 |
echo ' |
| 572 |
<script defer type="text/javascript" src="' . plugins_url( '/js/buttonizer.js?v=' . md5( BUTTONIZER_VERSION ), BUTTONIZER_PLUGIN_DIR ) . '"></script> |
| 573 |
<script type="text/javascript"> |
| 574 |
document.addEventListener(\'DOMContentLoaded\', function(){ |
| 575 |
buttonizer.init({ |
| 576 |
scrollBarTop: ' . $showOnScroll . ', |
| 577 |
showAfter: ' . $showAfterTimeout . ', |
| 578 |
' . (( ButtonizerLicense()->is__premium_only() ? 'exitIntent: ' . $this->enableExitIntent() . ',' : '' )) . ' |
| 579 |
' . (( ButtonizerLicense()->is__premium_only() ? 'exitIntentText: "' . $this->enableExitIntentText() . '",' : '' )) . ' |
| 580 |
}); |
| 581 |
}); |
| 582 |
</script>' ; |
| 583 |
} |
| 584 |
|
| 585 |
} |