Call Now Button - Version 0.3.2

Version Description

= * Option to hide icon in text button * Fix for gtag tracking code * JS fix * Fix for iOS border bug

Download this release

Release Info

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

Code changes from version 0.3.1 to 0.3.2

Files changed (4) hide show
  1. call-now-button.css +2 -1
  2. call-now-button.js +1 -36
  3. call-now-button.php +66 -33
  4. readme.txt +7 -1
call-now-button.css CHANGED
@@ -5,7 +5,8 @@
5
font-weight: 200;
6
}
7
.form-table td p.description,
8
- .inline-helper {
9
font-size: 12px;
10
}
11
.cnb-url a {
5
font-weight: 200;
6
}
7
.form-table td p.description,
8
+ .inline-helper,
9
+ label.small-italic {
10
font-size: 12px;
11
}
12
.cnb-url a {
call-now-button.js CHANGED
@@ -25,39 +25,4 @@ jQuery(document).ready(function($){
25
scrollTop: $("tr.classic").offset().top
26
}, 500);
27
});
28
- });
29
-
30
- const textButtonField = document.querySelector("#buttonTextField");
31
-
32
- textFieldChars();
33
-
34
- textButtonField.addEventListener("keyup", textFieldChars);
35
-
36
- function textFieldChars() {
37
- chars = textButtonField.value.length;
38
- if(chars>0) {
39
- toggleVisibility('.appearance-options', 'none');
40
- toggleVisibility('.classic', 'none');
41
- toggleVisibility('.appearanceDesc', 'block');
42
- toggleVisibility('.notempty', 'block')
43
- } else {
44
- toggleVisibility('.appearance-options', 'block');
45
- toggleVisibility('.classic', 'table-row');
46
- toggleVisibility('.appearanceDesc', 'none');
47
- toggleVisibility('.notempty', 'none')
48
- }
49
- if( chars > 15 ) {
50
- document.querySelector('.lengthwarning').innerHTML = "Your text is " + chars + " characters.";
51
- document.querySelector('.lengthwarning').style.color = '#C00';
52
- } else if(chars > 0) {
53
- document.querySelector('.lengthwarning').innerHTML = "Your text is " + chars + " character(s).";
54
- document.querySelector('.lengthwarning').style.color = '#444';
55
- } else {
56
- document.querySelector('.lengthwarning').innerHTML = "Leave blank to only show the button with icon.";
57
- document.querySelector('.lengthwarning').style.color = '#444';
58
- }
59
- }
60
-
61
- function toggleVisibility(selector, value) {
62
- document.querySelector(selector).style.display = value;
63
- }
25
scrollTop: $("tr.classic").offset().top
26
}, 500);
27
});
28
+ });
call-now-button.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: Call Now Button
4
Plugin URI: http://callnowbutton.com
5
Description: Mobile visitors will see a call now button fixed at the bottom of your site
6
- Version: 0.3.1
7
Author: Jerry Rietveld
8
Author URI: http://www.jgrietveld.com
9
License: GPL2
@@ -26,13 +26,19 @@ License: GPL2
26
*/
27
?>
28
<?php
29
- define('CNB_VERSION','0.3.1');
30
add_action('admin_menu', 'register_cnb_page');
31
add_action('admin_init', 'cnb_options_init');
32
33
- $cnb_changelog = array(
34
- '0.3' => 'You can now add text to your button and it\'s possible to switch between including and excluding specific pages.',
35
- '0.2' => 'The Call Now Button has a fresh new look! If you prefer the old button, you can <span class="cnb-switch-back">switch back</span> in the Advanced Settings. <a href="http://callnowbutton.com/new-button-design/" target="_blank" class="cnb-external"><i>See the difference &raquo;</i></a>'
36
);
37
38
$cnb_settings = cnb_get_options(); // Grabbing the settins and checking for latest version OR creating the options file for first time installations
@@ -42,11 +48,10 @@ $cnb_updated = $cnb_settings['updated'];
42
43
$cnb_options['active'] = isset($cnb_options['active']) ? 1 : 0;
44
$cnb_options['classic'] = isset($cnb_options['classic']) ? 1 : 0;
45
46
$plugin_title = apply_filters( 'cnb_plugin_title', 'Call Now Button');
47
48
-
49
-
50
add_action( 'admin_enqueue_scripts', 'cnb_enqueue_color_picker' ); // add the color picker
51
52
function register_cnb_page() {
@@ -74,6 +79,7 @@ function call_now_settings_page() {
74
75
<div class="wrap">
76
<h1>Call Now Button <span class="version">v<?php echo CNB_VERSION;?></span></h1>
77
<!--## NOTIFICATION BARS ## -->
78
<?php
79
// Display notification that the button is active or inactive
@@ -93,10 +99,9 @@ function call_now_settings_page() {
93
if($cnb_updated[0]) { ?>
94
<div class="notice-warning notice is-dismissible">
95
<?php
96
- foreach ($cnb_changelog as $key => $value) { // Only on first run after update show list of changes since last update
97
- if($cnb_updated[1] == $key) {
98
- break;
99
- } else {
100
echo '<p><span class="dashicons dashicons-yes"></span> ' . $value . '</p>';
101
}
102
}
@@ -104,7 +109,6 @@ function call_now_settings_page() {
104
</div>
105
<?php } ?>
106
107
-
108
<form method="post" action="options.php" class="cnb-container">
109
<?php settings_fields('cnb_options'); ?>
110
<table class="form-table">
@@ -122,8 +126,9 @@ function call_now_settings_page() {
122
<th scope="row">Button text:</th>
123
<td>
124
<input id="buttonTextField" type="text" name="cnb[text]" value="<?php echo $cnb_options['text']; ?>" maxlength="30" />
125
- <p class="description lengthwarning " style="color:#C00"></p>
126
- <p class="description notempty">We recommend that you stay under 15 character and that you always check if the text fits on your button. <span class="whatsThis">(<a href="http://callnowbutton.com/call-now-button-text-buttons/" target="_blank">Learn why...</a>)</span></p>
127
</td>
128
</tr>
129
</table>
@@ -267,13 +272,16 @@ if(get_option('cnb') && !is_admin()) {
267
// NEWEST BUTTON DESIGN
268
$credits = "\n<!-- Call Now Button ".CNB_VERSION." by Jerry Rietveld (callnowbutton.com) -->\n";
269
270
- $ButtonShape = "width:65px; height:65px; border-radius:80px; border-top:1px solid ".changeColor($cnb_options['color'], 'lighter')."; border-bottom: 1px solid ".changeColor($cnb_options['color'], 'darker')."; bottom:15px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);";
271
272
if($cnb_options['appearance'] == 'full' || $showTextButton) {
273
$ButtonAppearance = "width:100%;left:0;bottom:0;height:60px;border-top:1px solid ".changeColor($cnb_options['color'], 'lighter')."; border-bottom:1px solid ".changeColor($cnb_options['color'], 'darker').";";
274
$ButtonExtra = "body {padding-bottom:60px;}";
275
if($showTextButton) {
276
- $ButtonAppearance .= $ButtonAppearance . "text-shadow: 0 1px ".changeColor($cnb_options['color'], 'darker')."; text-align:center;color:#fff; font-weight:600; font-size:120%; padding-right:27px; overflow: hidden;";
277
}
278
}
279
elseif($cnb_options['appearance'] == 'left' ) {
@@ -302,29 +310,35 @@ if(get_option('cnb') && !is_admin()) {
302
add_action('wp_head', 'cnb_head');
303
304
function cnb_footer() {
305
- $alloptions = get_option('cnb');
306
307
- if(isset($alloptions['show']) && $alloptions['show'] != "") {
308
- $show = explode(',', str_replace(' ', '' ,$alloptions['show']));
309
$limited = TRUE;
310
- $include = ($alloptions['limit'] == 'include') ? TRUE : FALSE; // FALSE meanse IDs should be excluded
311
} else {
312
$limited = FALSE;
313
}
314
315
- if($alloptions['tracking'] == '1') { // for ga.js
316
$tracking = "onclick=\"_gaq.push(['_trackEvent', 'Contact', 'Call Now Button', 'Phone']);\"";
317
- } elseif($alloptions['tracking'] == '2') { // for analytics.js
318
$tracking = "onclick=\"ga('send', 'event', 'Contact', 'Call Now Button', 'Phone');\"";
319
- } elseif($alloptions['tracking'] == '3') { // for gtag.js
320
- $tracking = "onclick=\"gtag('event', 'Call Now Button', {'event_category': 'contact', 'event_label': 'phone'});\"";
321
} else {
322
$tracking = "";
323
}
324
325
- $buttonText = ($alloptions['text'] == '') ? '&nbsp;' : '<img src="data:image/svg+xml;base64,'.svg(changeColor($alloptions['color'], 'darker')).'" width="55">'. $alloptions['text'];
326
327
- $callLink = '<a href="tel:'.$alloptions['number'].'" id="callnowbutton" '.$tracking.'>'.$buttonText.'</a>';
328
329
if($limited) {
330
if($include) {
@@ -350,6 +364,7 @@ function cnb_get_options() { // Grabbing existing settings and creating them if
350
'active',
351
'number' => '',
352
'text' => '',
353
'color' => '#009900',
354
'appearance' => 'right',
355
'tracking' => 0,
@@ -365,30 +380,48 @@ function cnb_get_options() { // Grabbing existing settings and creating them if
365
$cnb_options['updated'] = isset($updated) ? $updated : array(false, substr(CNB_VERSION, 0, 3));
366
return $cnb_options;
367
}
368
-
369
function cnb_update_options() {
370
$cnb_options = get_option('cnb');
371
- $version = array_key_exists('version', $cnb_options) ? substr($cnb_options['version'], 0, 3) : 0.1;
372
- if($version != substr(CNB_VERSION, 0, 3)) { // Check current version and if it needs an update
373
$cnb_options['active'] = isset($cnb_options['active']) ? 1 : 0;
374
$default_options = array(
375
'active' => $cnb_options['active'],
376
'number' => $cnb_options['number'],
377
- 'text' => '',
378
'color' => $cnb_options['color'],
379
'appearance' => $cnb_options['appearance'],
380
'tracking' => $cnb_options['tracking'],
381
'show' => $cnb_options['show'],
382
- 'limit' => 'include',
383
'version' => CNB_VERSION
384
);
385
if(array_key_exists('classic', $cnb_options) && $cnb_options['classic'] == 1 ) {
386
$default_options['classic'] = 1;
387
}
388
update_option('cnb',$default_options);
389
- $updated = array(true, $version); // Updated and previous version number
390
} else {
391
- $updated = array(false, $version); // Not updated and current version number
392
}
393
return $updated;
394
}
3
Plugin Name: Call Now Button
4
Plugin URI: http://callnowbutton.com
5
Description: Mobile visitors will see a call now button fixed at the bottom of your site
6
+ Version: 0.3.2
7
Author: Jerry Rietveld
8
Author URI: http://www.jgrietveld.com
9
License: GPL2
26
*/
27
?>
28
<?php
29
+ define('CNB_VERSION','0.3.2');
30
add_action('admin_menu', 'register_cnb_page');
31
add_action('admin_init', 'cnb_options_init');
32
33
+ $cnb_changelog =
34
+ array(
35
+ array(
36
+ '3.2' => 'Option to hide icon in text button, small bug fixes.',
37
+ '3.1' => 'You can now add text to your button and it\'s possible to switch between including and excluding specific pages.',
38
+ '3.0' => 'Option to add text to your button.',
39
+ '2.1' => 'Some small fixes',
40
+ '2.0' => 'The Call Now Button has a fresh new look! If you prefer the old button, you can <span class="cnb-switch-back">switch back</span> in the Advanced Settings. <a href="http://callnowbutton.com/new-button-design/" target="_blank" class="cnb-external"><i>See the difference &raquo;</i></a>'
41
+ )
42
);
43
44
$cnb_settings = cnb_get_options(); // Grabbing the settins and checking for latest version OR creating the options file for first time installations
48
49
$cnb_options['active'] = isset($cnb_options['active']) ? 1 : 0;
50
$cnb_options['classic'] = isset($cnb_options['classic']) ? 1 : 0;
51
+ $cnb_options['hideIcon'] = isset($cnb_options['hideIcon']) ? 1 : 0;
52
53
$plugin_title = apply_filters( 'cnb_plugin_title', 'Call Now Button');
54
55
add_action( 'admin_enqueue_scripts', 'cnb_enqueue_color_picker' ); // add the color picker
56
57
function register_cnb_page() {
79
80
<div class="wrap">
81
<h1>Call Now Button <span class="version">v<?php echo CNB_VERSION;?></span></h1>
82
+
83
<!--## NOTIFICATION BARS ## -->
84
<?php
85
// Display notification that the button is active or inactive
99
if($cnb_updated[0]) { ?>
100
<div class="notice-warning notice is-dismissible">
101
<?php
102
+ $cnb_old_version = substr($cnb_updated[1],2);
103
+ foreach ($cnb_changelog[0] as $key => $value) { // Only on first run after update show list of changes since last update
104
+ if($key > $cnb_old_version) {
105
echo '<p><span class="dashicons dashicons-yes"></span> ' . $value . '</p>';
106
}
107
}
109
</div>
110
<?php } ?>
111
112
<form method="post" action="options.php" class="cnb-container">
113
<?php settings_fields('cnb_options'); ?>
114
<table class="form-table">
126
<th scope="row">Button text:</th>
127
<td>
128
<input id="buttonTextField" type="text" name="cnb[text]" value="<?php echo $cnb_options['text']; ?>" maxlength="30" />
129
+ <input id="hideIcon" name="cnb[hideIcon]" type="checkbox" value="1" <?php checked('1', $cnb_options['hideIcon']); ?> /> <label class="small-italic" title="hide" for="hideIcon">Hide icon</label>
130
+
131
+ <p class="description">Make sure to check on your phone if the text fits your button! <span class="whatsThis">(<a href="http://callnowbutton.com/call-now-button-text-buttons/" target="_blank">Learn why...</a>)</span></p>
132
</td>
133
</tr>
134
</table>
272
// NEWEST BUTTON DESIGN
273
$credits = "\n<!-- Call Now Button ".CNB_VERSION." by Jerry Rietveld (callnowbutton.com) -->\n";
274
275
+ $ButtonShape = "width:65px; height:65px; border-radius:50%; border-top:1px solid ".changeColor($cnb_options['color'], 'lighter')."; bottom:15px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);";
276
277
if($cnb_options['appearance'] == 'full' || $showTextButton) {
278
$ButtonAppearance = "width:100%;left:0;bottom:0;height:60px;border-top:1px solid ".changeColor($cnb_options['color'], 'lighter')."; border-bottom:1px solid ".changeColor($cnb_options['color'], 'darker').";";
279
$ButtonExtra = "body {padding-bottom:60px;}";
280
if($showTextButton) {
281
+ $ButtonAppearance .= "text-shadow: 0 1px ".changeColor($cnb_options['color'], 'darker')."; text-align:center;color:#fff; font-weight:600; font-size:120%; overflow: hidden;";
282
+ if(!isset($cnb_options['hideIcon'])) {
283
+ $ButtonAppearance .= 'padding-right:27px;';
284
+ }
285
}
286
}
287
elseif($cnb_options['appearance'] == 'left' ) {
310
add_action('wp_head', 'cnb_head');
311
312
function cnb_footer() {
313
+ $cnb_options = get_option('cnb');
314
315
+ if(isset($cnb_options['show']) && $cnb_options['show'] != "") {
316
+ $show = explode(',', str_replace(' ', '' ,$cnb_options['show']));
317
$limited = TRUE;
318
+ $include = ($cnb_options['limit'] == 'include') ? TRUE : FALSE; // FALSE meanse IDs should be excluded
319
} else {
320
$limited = FALSE;
321
}
322
323
+ if($cnb_options['tracking'] == '1') { // for ga.js
324
$tracking = "onclick=\"_gaq.push(['_trackEvent', 'Contact', 'Call Now Button', 'Phone']);\"";
325
+ } elseif($cnb_options['tracking'] == '2') { // for analytics.js
326
$tracking = "onclick=\"ga('send', 'event', 'Contact', 'Call Now Button', 'Phone');\"";
327
+ } elseif($cnb_options['tracking'] == '3') { // for gtag.js
328
+ $tracking = "onclick=\"gtag('event', 'Call Now Button', {event_category: 'contact', event_label: 'phone'});\"";
329
} else {
330
$tracking = "";
331
}
332
333
+ if($cnb_options['text'] == '') {
334
+ $buttonText = '';
335
+ } elseif(isset($cnb_options['hideIcon'])) {
336
+ $buttonText = $cnb_options['text'];
337
+ } else {
338
+ $buttonText = '<img src="data:image/svg+xml;base64,'.svg(changeColor($cnb_options['color'], 'darker')).'" width="55">'. $cnb_options['text'];
339
+ }
340
341
+ $callLink = '<a href="tel:'.$cnb_options['number'].'" id="callnowbutton" '.$tracking.'>'.$buttonText.'</a>';
342
343
if($limited) {
344
if($include) {
364
'active',
365
'number' => '',
366
'text' => '',
367
+ 'hideIcon' => 0,
368
'color' => '#009900',
369
'appearance' => 'right',
370
'tracking' => 0,
380
$cnb_options['updated'] = isset($updated) ? $updated : array(false, substr(CNB_VERSION, 0, 3));
381
return $cnb_options;
382
}
383
+ function cnb_update_needed() { //compares version numbers
384
+ $cnb_options = get_option('cnb');
385
+ $pluginVersion = CNB_VERSION;
386
+ $setupVersion = array_key_exists('version', $cnb_options) ? $cnb_options['version'] : 0.1;
387
+ if($pluginVersion == $setupVersion) {
388
+ $output = false;
389
+ } elseif(substr($pluginVersion,0,3) > substr($setupVersion,0,3)) {
390
+ $output = true;
391
+ } elseif(substr($pluginVersion,0,3) == substr($setupVersion,0,3)) {
392
+ $output = (substr($pluginVersion,-1) > substr($setupVersion,-1)) ? true : false;
393
+ } else {
394
+ $output = false;
395
+ }
396
+ return $output;
397
+ }
398
function cnb_update_options() {
399
$cnb_options = get_option('cnb');
400
+ //$version = array_key_exists('version', $cnb_options) ? substr($cnb_options['version'], 0, 3) : 0.1;
401
+ if(cnb_update_needed()) { // Check current version and if it needs an update
402
$cnb_options['active'] = isset($cnb_options['active']) ? 1 : 0;
403
+ $cnb_options['text'] = isset($cnb_options['text']) ? $cnb_options['text'] : "";
404
+ $cnb_options['hideIcon'] = isset($cnb_options['hideIcon']) ? $cnb_options['hideIcon'] : 0;
405
+ $cnb_options['limit'] = isset($cnb_options['limit']) ? $cnb_options['limit'] : 'include';
406
$default_options = array(
407
'active' => $cnb_options['active'],
408
'number' => $cnb_options['number'],
409
+ 'text' => $cnb_options['text'],
410
+ 'hideIcon' => $cnb_options['hideIcon'],
411
'color' => $cnb_options['color'],
412
'appearance' => $cnb_options['appearance'],
413
'tracking' => $cnb_options['tracking'],
414
'show' => $cnb_options['show'],
415
+ 'limit' => $cnb_options['limit'],
416
'version' => CNB_VERSION
417
);
418
if(array_key_exists('classic', $cnb_options) && $cnb_options['classic'] == 1 ) {
419
$default_options['classic'] = 1;
420
}
421
update_option('cnb',$default_options);
422
+ $updated = array(true, $cnb_options['version']); // Updated and previous version number
423
} else {
424
+ $updated = array(false, $cnb_options['version']); // Not updated and current version number
425
}
426
return $updated;
427
}
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://callnowbutton.com/donate/
4
Tags: call, contact, customers, sell, sales, leads, convert, conversions, call now button
5
Requires at least: 2.7
6
Tested up to: 4.9
7
- Stable tag: 0.3.1
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -86,6 +86,12 @@ Yes, this is coming soon. We're currently looking for testers so if you want to
86
87
== Changelog ==
88
89
= 0.3.1 =
90
* Small bug fix
91
4
Tags: call, contact, customers, sell, sales, leads, convert, conversions, call now button
5
Requires at least: 2.7
6
Tested up to: 4.9
7
+ Stable tag: 0.3.2
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
86
87
== Changelog ==
88
89
+ = 0.3.2 =
90
+ * Option to hide icon in text button
91
+ * Fix for gtag tracking code
92
+ * JS fix
93
+ * Fix for iOS border bug
94
+
95
= 0.3.1 =
96
* Small bug fix
97