Call Now Button - Version 0.4.2

Version Description

= * Button styling adjustments * Security improvements (input sanitisation, output escaping)

Download this release

Release Info

Developer jgrietveld
Plugin Icon 128x128 Call Now Button
Version 0.4.2
Comparing to
See all releases

Code changes from version 0.4.1 to 0.4.2

Files changed (3) hide show
  1. call-now-button.css +13 -0
  2. call-now-button.php +69 -38
  3. readme.txt +5 -1
call-now-button.css CHANGED
@@ -79,4 +79,17 @@ input[type='range'] {
79
  }
80
  .nounderscore {
81
  text-decoration: none;
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  }
79
  }
80
  .nounderscore {
81
  text-decoration: none;
82
+ }
83
+
84
+ a#cnb_donate {
85
+ display: inline-block;
86
+ padding: 5px 10px;
87
+ text-decoration: none;
88
+ background: #ffc439;
89
+ border-radius: 15px;
90
+ color: #000;
91
+ font-weight: bold;
92
+ border-style: outset none;
93
+ border-color: #ffdc8a;
94
+ border-width: 1px;
95
  }
call-now-button.php CHANGED
@@ -3,13 +3,13 @@
3
  Plugin Name: Call Now Button
4
  Plugin URI: https://callnowbutton.com
5
  Description: Mobile visitors will see a <strong>Call Now Button</strong> on your website. Easy to use but flexible to meet more demanding requirements. Change placement and color, hide on specific pages, track how many people click them or conversions of your Google Ads campaigns. It's all optional but possible.
6
- Version: 0.4.1
7
  Author: Jerry Rietveld
8
- Author URI: http://www.jgrietveld.com
9
  License: GPL2
10
  */
11
 
12
- /* Copyright 2013-2017 Jerry Rietveld (email : jerry@jgrietveld.com)
13
 
14
  This program is free software; you can redistribute it and/or modify
15
  it under the terms of the GNU General Public License, version 2, as
@@ -26,7 +26,7 @@ License: GPL2
26
  */
27
  ?>
28
  <?php
29
- define('CNB_VERSION','0.4.1');
30
  define('CNB_BASENAME', plugin_basename( __FILE__ ) );
31
  define('CNB_BASEFOLDER', plugin_basename( dirname( __FILE__ ) ) );
32
  define('CNB_FILENAME', str_replace( CNB_BASEFOLDER.'/', '', CNB_BASENAME ) );
@@ -38,6 +38,7 @@ add_action('admin_init', 'cnb_options_init');
38
  $cnb_changelog =
39
  array(
40
  array(
 
41
  '4.0' => 'Text bubbles for standard buttons, set the icon color, Google Ads conversion tracking, tabbed admin interface, 6 additional button locations, small button design changes, added support articles for (nearly) all settings, control visibility on front page, plus a bunch of smaller fixes. Enjoy!',
42
  '3.6' => 'Small validation fixes and zoom now controls icon size in full width buttons.',
43
  '3.5' => 'Small JS fix',
@@ -147,7 +148,17 @@ function cnb_admin_settings_page() {
147
 
148
 
149
  if( isset( $_GET[ 'tab' ] ) ) {
150
- $active_tab = $_GET[ 'tab' ];
 
 
 
 
 
 
 
 
 
 
151
  } else {
152
  $active_tab = "basic_options";
153
  } // end if
@@ -383,7 +394,7 @@ if( isset( $_GET[ 'tab' ] ) ) {
383
  </div>
384
 
385
  <div class="donate cnb-center">
386
- <a href="https://www.paypal.com/paypalme/jgrietveld"><img src="https://callnowbutton.com/wp-content/uploads/2020/10/btn_donateCC_LG.gif"></a>
387
  </div><!--.donate-->
388
  </div>
389
      </div>
@@ -421,15 +432,15 @@ if(get_option('cnb') && !is_admin()) {
421
  } else {
422
 
423
  // NEW BUTTON DESIGN
424
- $cnb_button_shape = "width:65px; height:65px; border-radius:50%; box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);transform: scale(" . $cnb_options['zoom'] . ");";
425
  $cnb_button_positions = array(
426
- 'middle' => 'bottom:15px; left:50%; margin-left:-33px;',
427
  'left' => 'bottom:15px; left:20px;',
428
  'right' => 'bottom:15px; right:20px;',
429
- 'mleft' => 'top:50%; margin-top:-33px; left:20px;',
430
- 'mright' => 'top:50%; margin-top:-33px; right:20px;',
431
  'tleft' => 'top:15px; left:20px;',
432
- 'tmiddle' => 'top:15px; left:50%; margin-left:-33px;',
433
  'tright' => 'top:15px; right:20px;',
434
  );
435
 
@@ -455,20 +466,27 @@ if(get_option('cnb') && !is_admin()) {
455
  $circularButtonTextCSS = "#callnowbutton span{display: none;";
456
  } elseif($cnb_has_text && !$cnb_is_full_width){
457
  $circularButtonTextCSS = "#callnowbutton span{
 
 
 
 
458
  display: block;
459
  width: auto;
460
- background: rgba(243, 243, 243, 0.96);
461
- border-top:1px solid rgba(243, 243, 243, 1);
462
- position: absolute;"
463
- .$cnb_label_side.": 74px;
464
- border-radius: 5px;
465
- padding: 2px 15px;
466
- font-size: 15px;
467
- color: #505050;
468
- top: 20px;
469
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
 
470
  word-break: keep-all;
471
- line-height: 1;
 
 
472
  }";
473
  } elseif(!$cnb_is_full_width) {
474
  $circularButtonTextCSS = "#callnowbutton span{display:none;}";
@@ -476,19 +494,18 @@ if(get_option('cnb') && !is_admin()) {
476
  $circularButtonTextCSS = "";
477
  }
478
 
479
- $cnb_button_css = $cnb_button_css ."<style>";
480
  $cnb_button_css .= "#callnowbutton {display:none;} @media screen and (max-width:650px){#callnowbutton {display:block; position:fixed; text-decoration:none; z-index:".zindex($cnb_options['z-index']).";";
481
  $cnb_button_css .= $cnb_button_appearance;
482
  if($cnb_is_full_width) {
483
  $cnb_button_css .= "background:".$cnb_options['color'].";display: flex; justify-content: center; align-items: center;text-shadow: 0 1px 0px rgba(0, 0, 0, 0.18);";
484
  } else {
485
- $cnb_button_css .= "background:url(data:image/svg+xml;base64,".svg(changeColor($cnb_options['color'], 'darker'),$cnb_options['iconcolor'] ).") center/45px 45px no-repeat ".$cnb_options['color'].";";
486
  }
487
  $cnb_button_css .= "}" . $ButtonExtra . "}" . $circularButtonTextCSS;
488
- $cnb_button_css .= "</style>\n";
489
 
490
  }
491
- echo $cnb_button_css;
492
  }
493
  add_action('wp_head', 'cnb_head');
494
 
@@ -526,38 +543,52 @@ if(get_option('cnb') && !is_admin()) {
526
  $cnb_conversion_code = "";
527
  }
528
 
529
- $cnb_onclick_events = $cnb_click_tracking || $cnb_conversion_tracking ? 'onclick="' . $cnb_tracking_code . $cnb_conversion_code . '"' : "";
530
 
 
531
  if(!$cnb_has_text && !$cnb_is_full_width) {
532
- $cnb_button_text = '<span>Call Now Button</span>';
 
533
  } elseif(!$cnb_has_text && $cnb_is_full_width) {
534
- $cnb_button_text = '<img alt="Call Now Button" src="data:image/svg+xml;base64,'.svg(changeColor($cnb_options['color'], 'darker'),$cnb_options['iconcolor']).'" width="40">';
 
535
  } elseif($cnb_hide_icon && $cnb_is_full_width) {
536
- $cnb_button_text = '<span style="color:'.$cnb_options['iconcolor'].'">'. $cnb_options['text'] . '</span>';
537
  } elseif($cnb_is_full_width) {
538
- $cnb_button_text = '<img alt="Call Now Button" src="data:image/svg+xml;base64,'.svg(changeColor($cnb_options['color'], 'darker'),$cnb_options['iconcolor']).'" width="40"><span style="color:'.$cnb_options['iconcolor'].'">'. $cnb_options['text'] . '</span>';
539
- } else {
540
- $cnb_button_text = '<span>'.str_replace(" ", "&nbsp;", $cnb_options['text']).'</span>';
541
  }
542
 
543
- $cnb_call_link = '<a href="tel:'.$cnb_options['number'].'" id="callnowbutton" '.$cnb_onclick_events.'>'.$cnb_button_text.'</a>';
 
 
 
 
 
 
 
 
 
 
 
544
 
545
  if(is_front_page()) {
546
  if(!$cnb_hide_frontpage) {
547
- echo $cnb_call_link;
548
  }
549
  } elseif($cnb_show_limited) {
550
  if($cnb_show_included) {
551
  if(is_single($cnb_show_ids) || is_page($cnb_show_ids)) {
552
- echo $cnb_call_link;
553
  }
554
  } else {
555
  if(!is_single($cnb_show_ids) && !is_page($cnb_show_ids)) {
556
- echo $cnb_call_link;
557
  }
558
  }
559
  } else {
560
- echo $cnb_call_link;
561
  }
562
  }
563
  add_action('wp_footer', 'cnb_footer');
3
  Plugin Name: Call Now Button
4
  Plugin URI: https://callnowbutton.com
5
  Description: Mobile visitors will see a <strong>Call Now Button</strong> on your website. Easy to use but flexible to meet more demanding requirements. Change placement and color, hide on specific pages, track how many people click them or conversions of your Google Ads campaigns. It's all optional but possible.
6
+ Version: 0.4.2
7
  Author: Jerry Rietveld
8
+ Author URI: http://www.callnowbutton.com
9
  License: GPL2
10
  */
11
 
12
+ /* Copyright 2013-2021 Jerry Rietveld (email : jerry@callnowbutton.com)
13
 
14
  This program is free software; you can redistribute it and/or modify
15
  it under the terms of the GNU General Public License, version 2, as
26
  */
27
  ?>
28
  <?php
29
+ define('CNB_VERSION','0.4.2');
30
  define('CNB_BASENAME', plugin_basename( __FILE__ ) );
31
  define('CNB_BASEFOLDER', plugin_basename( dirname( __FILE__ ) ) );
32
  define('CNB_FILENAME', str_replace( CNB_BASEFOLDER.'/', '', CNB_BASENAME ) );
38
  $cnb_changelog =
39
  array(
40
  array(
41
+ '4.2' => 'Button styling adjustments, security improvements',
42
  '4.0' => 'Text bubbles for standard buttons, set the icon color, Google Ads conversion tracking, tabbed admin interface, 6 additional button locations, small button design changes, added support articles for (nearly) all settings, control visibility on front page, plus a bunch of smaller fixes. Enjoy!',
43
  '3.6' => 'Small validation fixes and zoom now controls icon size in full width buttons.',
44
  '3.5' => 'Small JS fix',
148
 
149
 
150
  if( isset( $_GET[ 'tab' ] ) ) {
151
+ $cnb_admin_tabs = array (
152
+ "basic_options",
153
+ "extra_options",
154
+ "advanced_options"
155
+ );
156
+ $get_tab = sanitize_key($_GET[ 'tab' ]);
157
+ if(in_array($get_tab, $cnb_admin_tabs)) {
158
+ $active_tab = $get_tab;
159
+ } else {
160
+ $active_tab = "basic_options";
161
+ }
162
  } else {
163
  $active_tab = "basic_options";
164
  } // end if
394
  </div>
395
 
396
  <div class="donate cnb-center">
397
+ <a id="cnb_donate" title="Thank you!!" href="https://www.paypal.com/paypalme/jgrietveld">Donate</a>
398
  </div><!--.donate-->
399
  </div>
400
      </div>
432
  } else {
433
 
434
  // NEW BUTTON DESIGN
435
+ $cnb_button_shape = "width:55px; height:55px; border-radius:50%; box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);transform: scale(" . $cnb_options['zoom'] . ");";
436
  $cnb_button_positions = array(
437
+ 'middle' => 'bottom:15px; left:50%; margin-left:-28px;',
438
  'left' => 'bottom:15px; left:20px;',
439
  'right' => 'bottom:15px; right:20px;',
440
+ 'mleft' => 'top:50%; margin-top:-28px; left:20px;',
441
+ 'mright' => 'top:50%; margin-top:-28px; right:20px;',
442
  'tleft' => 'top:15px; left:20px;',
443
+ 'tmiddle' => 'top:15px; left:50%; margin-left:-28px;',
444
  'tright' => 'top:15px; right:20px;',
445
  );
446
 
466
  $circularButtonTextCSS = "#callnowbutton span{display: none;";
467
  } elseif($cnb_has_text && !$cnb_is_full_width){
468
  $circularButtonTextCSS = "#callnowbutton span{
469
+ -moz-osx-font-smoothing: grayscale;
470
+ -webkit-user-select: none;
471
+ -ms-user-select: none;
472
+ user-select: none;
473
  display: block;
474
  width: auto;
475
+ background-color: rgba(70,70,70,.9);
476
+ position: absolute;
477
+ ".$cnb_label_side.": 68px;
478
+ border-radius: 2px;
479
+ font-family: Helvetica,Arial,sans-serif;
480
+ padding: 6px 8px;
481
+ font-size: 13px;
482
+ font-weight:700;
483
+ color: #ececec;
484
+ top: 15px;
485
+ box-shadow: 0 1px 2px rgba(0,0,0,.15);
486
  word-break: keep-all;
487
+ line-height: 1em;
488
+ text-overflow: ellipsis;
489
+ vertical-align: middle;
490
  }";
491
  } elseif(!$cnb_is_full_width) {
492
  $circularButtonTextCSS = "#callnowbutton span{display:none;}";
494
  $circularButtonTextCSS = "";
495
  }
496
 
 
497
  $cnb_button_css .= "#callnowbutton {display:none;} @media screen and (max-width:650px){#callnowbutton {display:block; position:fixed; text-decoration:none; z-index:".zindex($cnb_options['z-index']).";";
498
  $cnb_button_css .= $cnb_button_appearance;
499
  if($cnb_is_full_width) {
500
  $cnb_button_css .= "background:".$cnb_options['color'].";display: flex; justify-content: center; align-items: center;text-shadow: 0 1px 0px rgba(0, 0, 0, 0.18);";
501
  } else {
502
+ $cnb_button_css .= "background:url(data:image/svg+xml;base64,".svg(changeColor($cnb_options['color'], 'darker'),$cnb_options['iconcolor'] ).") center/35px 35px no-repeat ".$cnb_options['color'].";";
503
  }
504
  $cnb_button_css .= "}" . $ButtonExtra . "}" . $circularButtonTextCSS;
505
+
506
 
507
  }
508
+ echo "<style>" . esc_html($cnb_button_css) . "</style>\n";
509
  }
510
  add_action('wp_head', 'cnb_head');
511
 
543
  $cnb_conversion_code = "";
544
  }
545
 
546
+ $cnb_onclick_events = $cnb_click_tracking || $cnb_conversion_tracking ? $cnb_tracking_code . $cnb_conversion_code : "";
547
 
548
+ $cnb_button_text = str_replace(" ", "&nbsp;", $cnb_options['text']);
549
  if(!$cnb_has_text && !$cnb_is_full_width) {
550
+ $cnb_button_text = 'Call Now Button';
551
+ $cnb_button_content = 10; // text only
552
  } elseif(!$cnb_has_text && $cnb_is_full_width) {
553
+ $cnb_button_text = '';
554
+ $cnb_button_content = 20; // image only
555
  } elseif($cnb_hide_icon && $cnb_is_full_width) {
556
+ $cnb_button_content = 11; // text only with flexible color
557
  } elseif($cnb_is_full_width) {
558
+ $cnb_button_content = 31; // text and image both flexible colors
559
+ } else {
560
+ $cnb_button_content = 10; // text only
561
  }
562
 
563
+ function cnb_button_output($number, $onclick, $text, $content, $color, $icon) {
564
+ if($content == 10){
565
+ return '<a href="tel:'.esc_attr($number).'" id="callnowbutton" onclick="'.$onclick.'""><span>'.esc_html($text).'</span></a>';
566
+ } elseif($content == 11) {
567
+ return '<a href="tel:'.esc_attr($number).'" id="callnowbutton" onclick="'.$onclick.'""><span style="color:'.$icon.'">'.esc_html($text).'</span></a>';
568
+ } elseif($content == 20) {
569
+ return '<a href="tel:'.esc_attr($number).'" id="callnowbutton" onclick="'.$onclick.'""><img alt="Call Now Button" src="data:image/svg+xml;base64,'.svg(changeColor($color, 'darker'), $icon).'" width="40"></a>';
570
+ } elseif($content == 31) {
571
+ return '<a href="tel:'.esc_attr($number).'" id="callnowbutton" onclick="'.$onclick.'""><img alt="Call Now Button" src="data:image/svg+xml;base64,'.svg(changeColor($color, 'darker'), $icon).'" width="40"><span style="color:'.$icon.'">'.esc_html($text).'</span></a>';
572
+ }
573
+
574
+ }
575
 
576
  if(is_front_page()) {
577
  if(!$cnb_hide_frontpage) {
578
+ echo cnb_button_output($cnb_options['number'],$cnb_onclick_events,$cnb_button_text,$cnb_button_content,$cnb_options['color'],$cnb_options['iconcolor']);
579
  }
580
  } elseif($cnb_show_limited) {
581
  if($cnb_show_included) {
582
  if(is_single($cnb_show_ids) || is_page($cnb_show_ids)) {
583
+ echo cnb_button_output($cnb_options['number'],$cnb_onclick_events,$cnb_button_text,$cnb_button_content,$cnb_options['color'],$cnb_options['iconcolor']);
584
  }
585
  } else {
586
  if(!is_single($cnb_show_ids) && !is_page($cnb_show_ids)) {
587
+ echo cnb_button_output($cnb_options['number'],$cnb_onclick_events,$cnb_button_text,$cnb_button_content,$cnb_options['color'],$cnb_options['iconcolor']);
588
  }
589
  }
590
  } else {
591
+ echo cnb_button_output($cnb_options['number'],$cnb_onclick_events,$cnb_button_text,$cnb_button_content,$cnb_options['color'],$cnb_options['iconcolor']);
592
  }
593
  }
594
  add_action('wp_footer', 'cnb_footer');
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://callnowbutton.com/donate/
4
  Tags: call button, click to call, convert, call now button, contact button
5
  Requires at least: 2.7
6
  Tested up to: 5.7
7
- Stable tag: 0.4.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -111,6 +111,10 @@ This is coming very soon. We're currently looking for testers so if you want to
111
 
112
  == Changelog ==
113
 
 
 
 
 
114
  = 0.4.0 =
115
  * Tabbed admin interface
116
  * Google Ads conversion tracking
4
  Tags: call button, click to call, convert, call now button, contact button
5
  Requires at least: 2.7
6
  Tested up to: 5.7
7
+ Stable tag: 0.4.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
111
 
112
  == Changelog ==
113
 
114
+ = 0.4.2 =
115
+ * Button styling adjustments
116
+ * Security improvements (input sanitisation, output escaping)
117
+
118
  = 0.4.0 =
119
  * Tabbed admin interface
120
  * Google Ads conversion tracking