Call Now Button - Version 0.1.0

Version Description

  • Change the color of the button
  • Change the appearance of the button
  • Track button clicks via Google Analytics
  • Limit the appearance to specific pages
Download this release

Release Info

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

Version 0.1.0

Files changed (5) hide show
  1. call-now-button.php +179 -0
  2. callbutton01.png +0 -0
  3. readme.txt +81 -0
  4. screenshot-1.png +0 -0
  5. screenshot-2.png +0 -0
call-now-button.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Call Now Button
4
+ Plugin URI: http://callnowbutton.com
5
+ Description: Mobile visitors will see a call now button at the bottom of your site
6
+ Version: 0.1.0
7
+ Author: Jerry G. Rietveld
8
+ Author URI: http://www.jgrietveld.com
9
+ License: GPL2
10
+ */
11
+ ?>
12
+ <?php
13
+ /* Copyright 2013 Jerry G. Rietveld (email : jerry@jgrietveld.com)
14
+
15
+ This program is free software; you can redistribute it and/or modify
16
+ it under the terms of the GNU General Public License, version 2, as
17
+ published by the Free Software Foundation.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
+ */
28
+ ?>
29
+ <?php
30
+ define('CNB_VERSION','0.1.0');
31
+ add_action('admin_menu', 'register_cnb_page');
32
+ add_action('admin_init', 'cnb_options_init');
33
+
34
+ function register_cnb_page() {
35
+ add_submenu_page('options-general.php', 'Call Now Button', 'Call Now Button', 'manage_options', 'call-now-button', 'call_now_settings_page');
36
+ }
37
+
38
+ // add the color picker
39
+ add_action( 'admin_enqueue_scripts', 'cnb_enqueue_color_picker' );
40
+ function cnb_enqueue_color_picker( $hook_suffix ) {
41
+ wp_enqueue_style( 'wp-color-picker' );
42
+ wp_enqueue_script( 'cnb-script-handle', plugins_url('call-now-button.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
43
+ }
44
+
45
+ function cnb_options_init() {
46
+ register_setting('cnb_options','cnb');
47
+ }
48
+ function call_now_settings_page() { ?>
49
+ <div class="wrap"><h2>Call Now Button <span style="font-size:12px; font-variant: small-caps; font-family: Verdana, Geneva, sans-serif;">by <a class="pluginhelp" style=" text-decoration:none;" href="http://www.jgrietveld.com" rel="help">Jerry G. Rietveld</a></span></h2>
50
+
51
+
52
+ <form method="post" action="options.php">
53
+             <?php settings_fields('cnb_options'); ?>
54
+             <?php $options = get_option('cnb'); ?>
55
+ <h4 style="max-width:700px; text-align:right; margin:0;cursor:pointer; color:#21759b" class="cnb_settings"><span class="plus">+</span><span class="minus">-</span> Advanced settings</h4>
56
+ <table class="form-table">
57
+ <tr valign="top"><th scope="row">Call Now Button</th>
58
+ <td><input name="cnb[active]" type="checkbox" value="1" <?php checked('1', $options['active']); ?> /> Enable</td>
59
+ </tr>
60
+                 <tr valign="top"><th scope="row">Phone number</th>
61
+                     <td><input type="text" name="cnb[number]" value="<?php echo $options['number']; ?>" /></td>
62
+                 </tr>
63
+ </table>
64
+ <div id="settings">
65
+ <table class="form-table">
66
+ <tr valign="top"><th scope="row">Button color</th>
67
+ <td><input name="cnb[color]" type="text" value="<?php echo $options['color']; ?>" class="cnb-color-field" data-default-color="#009900" /></td>
68
+ </tr>
69
+ <tr valign="top"><th scope="row">Appearance</th>
70
+ <td>
71
+ <label title="right">
72
+ <input type="radio" name="cnb[appearance]" value="right" <?php checked('right', $options['appearance']); ?>>
73
+ <span>Right corner</span>
74
+ </label><br />
75
+ <label title="left">
76
+ <input type="radio" name="cnb[appearance]" value="left" <?php checked('left', $options['appearance']); ?>>
77
+ <span>Left corner</span>
78
+ </label><br />
79
+ <label title="full">
80
+ <input type="radio" name="cnb[appearance]" value="full" <?php checked('full', $options['appearance']); ?>>
81
+ <span>Full bottom</span>
82
+ </label>
83
+ </td>
84
+ </tr>
85
+                 <tr valign="top"><th scope="row">Click tracking</th>
86
+                     <td><input type="checkbox" name="cnb[tracking]" value="1" <?php checked('1', $options['tracking']); ?> /> Enable
87
+ <p class="description">Only for sites using Google Analytics.</p></td>
88
+                 </tr>
89
+                 <tr valign="top"><th scope="row">Limit appearance</th>
90
+                     <td><input type="text" name="cnb[show]" value="<?php echo $options['show']; ?>" />
91
+ <p class="description">Enter IDs of the posts & pages the Call Now Button should appear on (leave blank for all).</p></td>
92
+                 </tr>
93
+             </table>
94
+ </div><!--#settings-->
95
+             <p class="submit">
96
+             <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
97
+             </p>
98
+         </form>
99
+
100
+ <h2>Feedback, Requests &amp; Appreciation</h2>
101
+ <div class="donate" style="width:160px; float:left; padding:20px; height:70px;">
102
+ <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
103
+ <input type="hidden" name="cmd" value="_s-xclick">
104
+ <input type="hidden" name="hosted_button_id" value="Q82GBVSERC9AW">
105
+ <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
106
+ <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
107
+ </form>
108
+ </div><!--.donate-->
109
+
110
+ <p><strong>Feedback:</strong> I'm very interested in hearing your thoughts about the plugin. Please drop me a line on <a href="http://callnowbutton.com">CallNowButton.com</a></p>
111
+ <p><strong>Coding requests:</strong> If you have any particular modification request you can hire me to tailor the plugin to meet your needs. You can contact me <a href="http://www.jgrietveld.com/contact-me/">here</a>.</p>
112
+ <p><strong>Say thanks:</strong> Developing a plugin takes time and energy. If you like the plugin or use it for clients, consider making a donation. Thanks.</p>
113
+     </div>
114
+ <?php }
115
+ if(get_option('cnb') && !is_admin()) {
116
+
117
+ // Darker color function to calculate borders
118
+ function darkerColor($color) {
119
+ if(!preg_match('/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i', $color, $parts));
120
+ for($i = 1; $i <= 3; $i++) {
121
+ $parts[$i] = hexdec($parts[$i]);
122
+ $parts[$i] = round($parts[$i] * 1.4);
123
+ if($parts[$i] > 255) { $parts[$i] = 255; }
124
+ $parts[$i] = dechex($parts[$i]);
125
+ }
126
+ $output = '#' . str_pad($parts[1],2,"0",STR_PAD_LEFT) . str_pad($parts[2],2,"0",STR_PAD_LEFT) . str_pad($parts[3],2,"0",STR_PAD_LEFT);
127
+ return $output;
128
+ }
129
+
130
+
131
+ $options = get_option('cnb');
132
+ if(isset($options['active'])) $enabled = $options['active']; else $enabled = 0;
133
+ if($enabled == '1') {
134
+ // it's enables so put footer stuff here
135
+ function cnb_head() {
136
+ $options = get_option('cnb');
137
+ $credits = "\n<!-- Call Now Button ".CNB_VERSION." by Jerry Rietveld (callnowbutton.com) -->\n";
138
+ if($options['appearance'] == 'full') {
139
+ $ButtonAppearance = "width:100%;left:0;";
140
+ $ButtonExtra = "body {padding-bottom:60px;}";
141
+ } elseif($options['appearance'] == 'left') {
142
+ $ButtonAppearance = "width:100px;left:0;border-bottom-right-radius:40px; border-top-right-radius:40px;";
143
+ $ButtonExtra = "";
144
+ } else {
145
+ $ButtonAppearance = "width:100px;right:0;border-bottom-left-radius:40px; border-top-left-radius:40px;";
146
+ $ButtonExtra = "";
147
+ }
148
+ echo $credits."<style>#callnowbutton {display:none;} @media screen and (max-width:650px){#callnowbutton {display:block; ".$ButtonAppearance." height:80px; position:fixed; bottom:-20px; border-top:2px solid ".darkerColor($options['color'])."; background:url(" .plugins_url( 'callbutton01.png' , __FILE__ ). ") center 10px no-repeat ".$options['color']."; text-decoration:none; -webkit-box-shadow:0 0 5px #888; z-index:9999;}".$ButtonExtra."}</style>\n";
149
+ }
150
+ add_action('wp_head', 'cnb_head');
151
+
152
+ function cnb_footer() {
153
+ $alloptions = get_option('cnb');
154
+
155
+
156
+ if(isset($alloptions['show']) && $alloptions['show'] != "") {
157
+ $show = explode(',', str_replace(' ', '' ,$alloptions['show']));
158
+ $limited = TRUE;
159
+ } else {
160
+ $limited = FALSE;
161
+ }
162
+
163
+ if($alloptions['tracking'] == '1') {
164
+ $tracking = "onclick=\"_gaq.push(['_trackEvent', 'Contact', 'Call Now Button', 'Phone']);\"";
165
+ } else {
166
+ $tracking = "";
167
+ }
168
+
169
+ if($limited) {
170
+ if(is_single($show) || is_page($show)) {
171
+ echo '<a href="tel:'.$alloptions['number'].'" id="callnowbutton" '.$tracking.'>&nbsp;</a>';
172
+ }
173
+ } else {
174
+ echo '<a href="tel:'.$alloptions['number'].'" id="callnowbutton" '.$tracking.'>&nbsp;</a>';
175
+ }
176
+ }
177
+ add_action('wp_footer', 'cnb_footer');
178
+ }
179
+ } ?>
callbutton01.png ADDED
Binary file
readme.txt ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
2
+ Contributors: jgrietveld
3
+ Donate link: http://callnowbutton.com/donate/
4
+ Tags: call, contact, customers, sell, sales, leads, convert, conversions
5
+ Requires at least: 2.7
6
+ Tested up to: 3.5.2
7
+ Stable tag: 0.1.0
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ A very simple yet very effective plugin that adds a Call Now button to your website for mobile visitors (only for mobile optimized websites).
12
+
13
+ == Description ==
14
+
15
+ ###What does the plugin do?
16
+
17
+ This plugin places a Call Now button to the bottom right corner of the screen which is only visible for your mobile visitors. Because your mobile visitors are already holding their phone it will allow them to call you with one simple touch of the button.
18
+ No more complicated copy-and-pasting or memorizing the phone number!
19
+
20
+ ###Could not be easier!
21
+ The settings are very easy: enable and enter your phone number. That's it!
22
+
23
+ But if you want more control, you can always open up the Advanced Settings and change the default behavior.
24
+
25
+ ###Only for mobile optimized themes
26
+ Usage at this point is only recommended for responsive websites or websites otherwise optimized for display on mobile devices.
27
+
28
+
29
+ == Installation ==
30
+
31
+ 1. From your WordPress Dashboard go to 'Plugins' > 'Add new' and search for 'Call Now Button'.
32
+ 2. Click 'Install Now' under the title of the Call Now Button plugin
33
+ 3. Click activate
34
+ 4. Go to 'Settings' > 'Call Now Button' and check the box to activate the button and enter your phone number.
35
+ 5. Click 'Save' and you're done!
36
+
37
+ Or:
38
+
39
+ 1. Upload `call-now-button`-folder to the `/wp-content/plugins/` directory
40
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
41
+ 3. Go to 'Settings' > 'Call Now Button' and check the box to activate the button and enter your phone number.
42
+ 4. Click 'Save' and you're done!
43
+
44
+
45
+ == Frequently Asked Questions ==
46
+
47
+ = I don't see the button on my website but I'm looking at it with my mobile phone. Why? =
48
+
49
+ The button will only work on websites that use a responsive theme. Responsive means that the website adapts to the size of the screen it's being viewed on. Simply put, if you need to zoom in to be able to read the text of your website on your mobile phone, the plugin will not work.
50
+
51
+ = Do I add a country code to my phone number? =
52
+
53
+ You don't have to but i recommend you do to increase your options internationally.
54
+
55
+ = Do I start the number with + or 00? =
56
+
57
+ Up to you. Your phone will understand both!
58
+
59
+ = Can I change the appearance of the Call Now Button? =
60
+
61
+ Yes! You can easily change the color of the button and make it sit in the left or right corner. Or spread it out over the full bottom of the phone screen.
62
+
63
+
64
+ == Screenshots ==
65
+
66
+ 1. What the Call Now Button will look like
67
+ 2. All the required settings
68
+ 3. Advanced Settings: Set your button's color
69
+ 4. Advanced Settings: More options
70
+
71
+
72
+ == Changelog ==
73
+
74
+ = 0.1.0 =
75
+ * Change the color of the button
76
+ * Change the appearance of the button
77
+ * Track button clicks via Google Analytics
78
+ * Limit the appearance to specific pages
79
+
80
+ = 0.0.1 =
81
+ * First time launch
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file