Version Description
= * Added notice bar for live buttons without a phone number entered
Download this release
Release Info
Developer | jasperroel |
Plugin | Call Now Button |
Version | 0.4.7 |
Comparing to | |
See all releases |
Code changes from version 0.4.6 to 0.4.7
- call-now-button.php +3 -3
- readme.txt +12 -9
- src/admin/api/CnbAdminCloud.php +15 -6
- src/admin/api/CnbAppRemote.php +1 -1
- src/admin/apikey-overview.php +6 -1
- src/admin/button-overview.php +1 -1
- src/admin/partials/admin-footer.php +24 -20
- src/admin/partials/admin-functions.php +2 -8
- src/admin/partials/admin-header.php +8 -17
- src/admin/settings.php +2 -2
- src/utils/notices.php +65 -24
- src/utils/utils.php +8 -1
call-now-button.php
CHANGED
@@ -3,9 +3,9 @@
|
|
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.
|
7 |
Author: Jerry Rietveld
|
8 |
-
Author URI:
|
9 |
GitHub Plugin URI: https://github.com/callnowbutton/wp-plugin
|
10 |
License: GPL2
|
11 |
*/
|
@@ -26,7 +26,7 @@ License: GPL2
|
|
26 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
27 |
*/
|
28 |
|
29 |
-
define('CNB_VERSION', '0.4.
|
30 |
define('CNB_NAME', 'Call Now Button');
|
31 |
define('CNB_BASENAME', plugin_basename(__FILE__));
|
32 |
define('CNB_BASEFOLDER', plugin_basename(dirname(__FILE__)));
|
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.7
|
7 |
Author: Jerry Rietveld
|
8 |
+
Author URI: https://www.callnowbutton.com
|
9 |
GitHub Plugin URI: https://github.com/callnowbutton/wp-plugin
|
10 |
License: GPL2
|
11 |
*/
|
26 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
27 |
*/
|
28 |
|
29 |
+
define('CNB_VERSION', '0.4.7');
|
30 |
define('CNB_NAME', 'Call Now Button');
|
31 |
define('CNB_BASENAME', plugin_basename(__FILE__));
|
32 |
define('CNB_BASEFOLDER', plugin_basename(dirname(__FILE__)));
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: call button, click to call, convert, call now button, contact button
|
|
5 |
Requires at least: 3.9
|
6 |
Requires PHP: 5.4
|
7 |
Tested up to: 5.8
|
8 |
-
Stable tag: 0.4.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -15,21 +15,21 @@ A very simple yet very effective and flexible plugin that adds a Call Now Button
|
|
15 |
|
16 |
###What does the plugin do?
|
17 |
|
18 |
-
This plugin places a Call Now Button (click-to-call button) to the bottom of the screen which is **only visible for your mobile visitors**. Because your mobile visitors already have a phone in their hands this plugin will allow them to call you with one simple touch of the button.
|
19 |
-
No more navigating to the contact page and no more complicated copy/pasting or memorizing the phone number!
|
20 |
|
21 |
###Could not be easier!
|
22 |
The settings are very easy: enable and enter your phone number. That's it!
|
23 |
|
24 |
If you want to add some text to your button, that's possible. Entering text is fully optional - leaving it empty will show a nice circular phone button to your visitors (take a look at the screenshots).
|
25 |
|
26 |
-
###Need more control?
|
27 |
Under the **Presentation tab** you can change the color of the button, move it to a different location on the screen and limit the pages on which the button should be visible.
|
28 |
|
29 |
Under the **Settings menu** you'll find a bunch of features that allow you to enable click tracking in Google Analytics, fire a conversion tag so a call is registered as a conversion in Google Ads, adjust the size of the button or move the button further backwards in case you want something else to sit on top of it (e.g. your privacy notice).
|
30 |
|
31 |
### For mobile optimized (responsive) themes
|
32 |
-
The button is super light and fully build in CSS. The **only requirement is that your website's theme is responsive**, meaning it adapts to the size of the screen.
|
33 |
|
34 |
|
35 |
== Installation ==
|
@@ -76,7 +76,7 @@ You have a caching plugin active on your website and you are looking at a cached
|
|
76 |
|
77 |
= I only see the button on some pages of my website
|
78 |
|
79 |
-
You have a caching plugin active on your website and the cached pages are showing an older version of your website. Delete/empty the cache and reload the pages.
|
80 |
|
81 |
Another option could be that you have set the Call Now Button to only appear on specific pages. Go into the Call Now Button settings, open the Presentation tab and check that the field next to Limit appearance is empty.
|
82 |
|
@@ -110,6 +110,9 @@ This is coming before the end of this year. We're currently looking for testers
|
|
110 |
|
111 |
|
112 |
== Changelog ==
|
|
|
|
|
|
|
113 |
= 0.4.6 =
|
114 |
* Fixed an upgrade regression (caused by the previous bugfix) which forced the position to become a boolean in certain scenarios
|
115 |
|
@@ -150,7 +153,7 @@ This is coming before the end of this year. We're currently looking for testers
|
|
150 |
* Added feature to change the z-index of the button with a slider
|
151 |
|
152 |
= 0.3.3 =
|
153 |
-
* Check for active caching plugin
|
154 |
* Added links from plugins page to settings page
|
155 |
|
156 |
= 0.3.2 =
|
@@ -177,7 +180,7 @@ This is coming before the end of this year. We're currently looking for testers
|
|
177 |
* Added middle button position
|
178 |
* Added admin notices for clarity
|
179 |
* Added link to Google Analytics integration manual
|
180 |
-
* More contact links to support and feature requests
|
181 |
* Some small design tweaks to admin screen
|
182 |
|
183 |
= 0.1.3 =
|
@@ -190,7 +193,7 @@ This is coming before the end of this year. We're currently looking for testers
|
|
190 |
* Small debug fixes
|
191 |
|
192 |
= 0.1.1 =
|
193 |
-
* JavaScript fix (needed for Advanced Settings)
|
194 |
|
195 |
= 0.1.0 =
|
196 |
* Change the color of the button
|
5 |
Requires at least: 3.9
|
6 |
Requires PHP: 5.4
|
7 |
Tested up to: 5.8
|
8 |
+
Stable tag: 0.4.7
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
15 |
|
16 |
###What does the plugin do?
|
17 |
|
18 |
+
This plugin places a Call Now Button (click-to-call button) to the bottom of the screen which is **only visible for your mobile visitors**. Because your mobile visitors already have a phone in their hands this plugin will allow them to call you with one simple touch of the button.
|
19 |
+
No more navigating to the contact page and no more complicated copy/pasting or memorizing the phone number!
|
20 |
|
21 |
###Could not be easier!
|
22 |
The settings are very easy: enable and enter your phone number. That's it!
|
23 |
|
24 |
If you want to add some text to your button, that's possible. Entering text is fully optional - leaving it empty will show a nice circular phone button to your visitors (take a look at the screenshots).
|
25 |
|
26 |
+
###Need more control?
|
27 |
Under the **Presentation tab** you can change the color of the button, move it to a different location on the screen and limit the pages on which the button should be visible.
|
28 |
|
29 |
Under the **Settings menu** you'll find a bunch of features that allow you to enable click tracking in Google Analytics, fire a conversion tag so a call is registered as a conversion in Google Ads, adjust the size of the button or move the button further backwards in case you want something else to sit on top of it (e.g. your privacy notice).
|
30 |
|
31 |
### For mobile optimized (responsive) themes
|
32 |
+
The button is super light and fully build in CSS. The **only requirement is that your website's theme is responsive**, meaning it adapts to the size of the screen.
|
33 |
|
34 |
|
35 |
== Installation ==
|
76 |
|
77 |
= I only see the button on some pages of my website
|
78 |
|
79 |
+
You have a caching plugin active on your website and the cached pages are showing an older version of your website. Delete/empty the cache and reload the pages.
|
80 |
|
81 |
Another option could be that you have set the Call Now Button to only appear on specific pages. Go into the Call Now Button settings, open the Presentation tab and check that the field next to Limit appearance is empty.
|
82 |
|
110 |
|
111 |
|
112 |
== Changelog ==
|
113 |
+
= 0.4.7 =
|
114 |
+
* Added notice bar for live buttons without a phone number entered
|
115 |
+
|
116 |
= 0.4.6 =
|
117 |
* Fixed an upgrade regression (caused by the previous bugfix) which forced the position to become a boolean in certain scenarios
|
118 |
|
153 |
* Added feature to change the z-index of the button with a slider
|
154 |
|
155 |
= 0.3.3 =
|
156 |
+
* Check for active caching plugin
|
157 |
* Added links from plugins page to settings page
|
158 |
|
159 |
= 0.3.2 =
|
180 |
* Added middle button position
|
181 |
* Added admin notices for clarity
|
182 |
* Added link to Google Analytics integration manual
|
183 |
+
* More contact links to support and feature requests
|
184 |
* Some small design tweaks to admin screen
|
185 |
|
186 |
= 0.1.3 =
|
193 |
* Small debug fixes
|
194 |
|
195 |
= 0.1.1 =
|
196 |
+
* JavaScript fix (needed for Advanced Settings)
|
197 |
|
198 |
= 0.1.0 =
|
199 |
* Change the color of the button
|
src/admin/api/CnbAdminCloud.php
CHANGED
@@ -340,6 +340,18 @@ class CnbAdminCloud {
|
|
340 |
* @return string HTML code with additional information (Content has been escaped already)
|
341 |
*/
|
342 |
public static function cnb_admin_get_error_message_details( $result ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
343 |
$additional_details = '';
|
344 |
// Get detail message if possible
|
345 |
$details = $result->get_error_data( $result->get_error_code() );
|
@@ -347,17 +359,14 @@ class CnbAdminCloud {
|
|
347 |
$details_obj = json_decode( $details );
|
348 |
if ( json_last_error() == JSON_ERROR_NONE ) {
|
349 |
if ( $details_obj->message ) {
|
350 |
-
$additional_details
|
351 |
}
|
352 |
} else {
|
353 |
-
$additional_details
|
354 |
}
|
355 |
}
|
356 |
|
357 |
-
|
358 |
-
return '<p>Code: <code>' . esc_html( $result->get_error_code() ) . '.</code></p>' . $additional_details;
|
359 |
-
}
|
360 |
-
return '<p>Code: <code>' . esc_html( $result->get_error_code() ) . '</code>, message: <code>' . esc_html( $result->get_error_message() ) . '</code></p>' . $additional_details;
|
361 |
|
362 |
}
|
363 |
|
340 |
* @return string HTML code with additional information (Content has been escaped already)
|
341 |
*/
|
342 |
public static function cnb_admin_get_error_message_details( $result ) {
|
343 |
+
if (!($result instanceof WP_Error)) { return ''; }
|
344 |
+
|
345 |
+
$error_codes = $result->get_error_codes();
|
346 |
+
$codes = 'Technical details: <br />';
|
347 |
+
foreach ($error_codes as $error_code) {
|
348 |
+
if ( $result->get_error_message( $error_code ) === '' ) {
|
349 |
+
$codes .= '<p>Error code: <code>' . esc_html( $error_code ) . '.</code></p>';
|
350 |
+
} else {
|
351 |
+
$codes .= '<p>Error code: <code>' . esc_html( $error_code ) . '</code>, message: <code>' . esc_html( $result->get_error_message( $error_code ) ) . '</code></p>';
|
352 |
+
}
|
353 |
+
}
|
354 |
+
|
355 |
$additional_details = '';
|
356 |
// Get detail message if possible
|
357 |
$details = $result->get_error_data( $result->get_error_code() );
|
359 |
$details_obj = json_decode( $details );
|
360 |
if ( json_last_error() == JSON_ERROR_NONE ) {
|
361 |
if ( $details_obj->message ) {
|
362 |
+
$additional_details .= '<p>Additional details: <strong>' . esc_html( $details_obj->message ) . '</strong></p>';
|
363 |
}
|
364 |
} else {
|
365 |
+
$additional_details .= '<p>Additional details: <strong>' . esc_html( $details ) . '</strong></p>';
|
366 |
}
|
367 |
}
|
368 |
|
369 |
+
return '<p>' . $codes . $additional_details . '</p>';
|
|
|
|
|
|
|
370 |
|
371 |
}
|
372 |
|
src/admin/api/CnbAppRemote.php
CHANGED
@@ -118,7 +118,7 @@ class CnbAppRemote {
|
|
118 |
|
119 |
public static function cnb_remote_handle_response( $response ) {
|
120 |
if ( $response instanceof WP_Error ) {
|
121 |
-
$error = new WP_Error( 'CNB_UNKNOWN_REMOTE_ERROR' );
|
122 |
$error->merge_from( $response );
|
123 |
|
124 |
return $error;
|
118 |
|
119 |
public static function cnb_remote_handle_response( $response ) {
|
120 |
if ( $response instanceof WP_Error ) {
|
121 |
+
$error = new WP_Error( 'CNB_UNKNOWN_REMOTE_ERROR', 'There was an issue communicating with the CallNowButton API. Please see the detailed error message from the response below.' );
|
122 |
$error->merge_from( $response );
|
123 |
|
124 |
return $error;
|
src/admin/apikey-overview.php
CHANGED
@@ -107,6 +107,7 @@ class Cnb_Apikey_List_Table extends WP_List_Table {
|
|
107 |
'name' => __('Name'),
|
108 |
'created' => __('Created'),
|
109 |
'lastUsed' => __('Last used'),
|
|
|
110 |
);
|
111 |
}
|
112 |
|
@@ -115,6 +116,7 @@ class Cnb_Apikey_List_Table extends WP_List_Table {
|
|
115 |
'name' => array('name', false),
|
116 |
'created' => array('created', false),
|
117 |
'lastUsed' => array('lastUsed', false),
|
|
|
118 |
);
|
119 |
}
|
120 |
|
@@ -181,9 +183,11 @@ class Cnb_Apikey_List_Table extends WP_List_Table {
|
|
181 |
case 'id':
|
182 |
return '<code>' . esc_html($item[ $column_name ]) . '</code>';
|
183 |
case 'name':
|
|
|
184 |
case 'created':
|
185 |
case 'lastUsed':
|
186 |
-
|
|
|
187 |
default:
|
188 |
return '<em>Unknown column ' .esc_html($column_name) . '</em>';
|
189 |
}
|
@@ -203,6 +207,7 @@ class Cnb_Apikey_List_Table extends WP_List_Table {
|
|
203 |
'name' => $apikey->name,
|
204 |
'created' => $apikey->created,
|
205 |
'lastUsed' => $apikey->lastUsed,
|
|
|
206 |
);
|
207 |
}
|
208 |
return $data;
|
107 |
'name' => __('Name'),
|
108 |
'created' => __('Created'),
|
109 |
'lastUsed' => __('Last used'),
|
110 |
+
'updateTime' => __('Last updated'),
|
111 |
);
|
112 |
}
|
113 |
|
116 |
'name' => array('name', false),
|
117 |
'created' => array('created', false),
|
118 |
'lastUsed' => array('lastUsed', false),
|
119 |
+
'updateTime' => array('updateTime', false),
|
120 |
);
|
121 |
}
|
122 |
|
183 |
case 'id':
|
184 |
return '<code>' . esc_html($item[ $column_name ]) . '</code>';
|
185 |
case 'name':
|
186 |
+
return esc_html($item[ $column_name ]);
|
187 |
case 'created':
|
188 |
case 'lastUsed':
|
189 |
+
case 'updateTime':
|
190 |
+
return esc_html(cnb_timestamp_to_string($item[ $column_name ]));
|
191 |
default:
|
192 |
return '<em>Unknown column ' .esc_html($column_name) . '</em>';
|
193 |
}
|
207 |
'name' => $apikey->name,
|
208 |
'created' => $apikey->created,
|
209 |
'lastUsed' => $apikey->lastUsed,
|
210 |
+
'updateTime' => $apikey->updateTime,
|
211 |
);
|
212 |
}
|
213 |
return $data;
|
src/admin/button-overview.php
CHANGED
@@ -469,7 +469,7 @@ function cnb_admin_page_overview_render_list() {
|
|
469 |
|
470 |
// Check if we should warn about inactive buttons
|
471 |
$views = $wp_list_table->get_views();
|
472 |
-
$active_views = $views['active'];
|
473 |
if (false !== strpos($active_views, '(0)')) {
|
474 |
echo '<div class="notice-warning notice"><p><strong>You have no active buttons.</strong> Create or enable one (or more) buttons to use the Call Now Button.</p></div>';
|
475 |
}
|
469 |
|
470 |
// Check if we should warn about inactive buttons
|
471 |
$views = $wp_list_table->get_views();
|
472 |
+
$active_views = isset($views['active']) ? $views['active'] : '';
|
473 |
if (false !== strpos($active_views, '(0)')) {
|
474 |
echo '<div class="notice-warning notice"><p><strong>You have no active buttons.</strong> Create or enable one (or more) buttons to use the Call Now Button.</p></div>';
|
475 |
}
|
src/admin/partials/admin-footer.php
CHANGED
@@ -20,29 +20,33 @@ function cnb_admin_footer() {
|
|
20 |
<strong><a href="https://www.paypal.com/paypalme/jgrietveld/" target="_blank" title="Thanks or your support">Donate</a></strong>
|
21 |
</p>
|
22 |
<?php
|
23 |
-
global $
|
24 |
if (isset($cnb_options['footer_show_traces']) && $cnb_options['footer_show_traces'] == 1 &&
|
25 |
-
isset($cnb_options['advanced_view']) && $cnb_options['advanced_view'] == 1
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
44 |
|
45 |
-
|
|
|
46 |
}
|
47 |
?>
|
48 |
</div>
|
20 |
<strong><a href="https://www.paypal.com/paypalme/jgrietveld/" target="_blank" title="Thanks or your support">Donate</a></strong>
|
21 |
</p>
|
22 |
<?php
|
23 |
+
global $cnb_options;
|
24 |
if (isset($cnb_options['footer_show_traces']) && $cnb_options['footer_show_traces'] == 1 &&
|
25 |
+
isset($cnb_options['advanced_view']) && $cnb_options['advanced_view'] == 1) {
|
26 |
+
$cnb_remoted_traces = RemoteTracer::getInstance();
|
27 |
+
if ( $cnb_remoted_traces ) {
|
28 |
+
echo '<p>';
|
29 |
+
$traces = $cnb_remoted_traces->getTraces();
|
30 |
+
echo '<strong>' . count( $traces ) . '</strong> remote calls executed';
|
31 |
+
$totaltime = 0.0;
|
32 |
+
foreach ( $traces as $trace ) {
|
33 |
+
$totaltime += (float) $trace->getTime();
|
34 |
+
}
|
35 |
+
echo ' in <strong>' . $totaltime . '</strong>sec:<br />';
|
36 |
|
37 |
+
echo '<ul>';
|
38 |
+
foreach ( $traces as $trace ) {
|
39 |
+
echo '<li>';
|
40 |
+
echo '<code>' . $trace->getEndpoint() . '</code> in <strong>' . $trace->getTime() . '</strong>sec';
|
41 |
+
if ( $trace->isCacheHit() ) {
|
42 |
+
echo ' (from cache)';
|
43 |
+
}
|
44 |
+
echo '.</li>';
|
45 |
+
}
|
46 |
+
echo '</ul>';
|
47 |
|
48 |
+
echo '</p>';
|
49 |
+
}
|
50 |
}
|
51 |
?>
|
52 |
</div>
|
src/admin/partials/admin-functions.php
CHANGED
@@ -10,13 +10,7 @@ function cnb_is_active_tab($tab_name) {
|
|
10 |
|
11 |
function cnb_get_changelog() {
|
12 |
return array(
|
13 |
-
'0.4.
|
14 |
-
'0.4.5' => array(
|
15 |
-
'Fixed an upgrade regression which forced the position to be FULL in certain scenarios',
|
16 |
-
'Removed HTML element that could overlay the label for certain buttons'
|
17 |
-
),
|
18 |
-
'0.4.4' => 'Small UI improvements',
|
19 |
-
'0.4.3' => 'Critical fix',
|
20 |
'0.4.2' => 'Button styling adjustments, security improvements',
|
21 |
'0.4.0' => array(
|
22 |
'Text bubbles for standard buttons',
|
@@ -102,4 +96,4 @@ function cnb_create_days_of_week_array($original) {
|
|
102 |
$day_of_week;
|
103 |
}
|
104 |
return $result;
|
105 |
-
}
|
10 |
|
11 |
function cnb_get_changelog() {
|
12 |
return array(
|
13 |
+
'0.4.7' => 'Small UI improvements',
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
'0.4.2' => 'Button styling adjustments, security improvements',
|
15 |
'0.4.0' => array(
|
16 |
'Text bubbles for standard buttons',
|
96 |
$day_of_week;
|
97 |
}
|
98 |
return $result;
|
99 |
+
}
|
src/admin/partials/admin-header.php
CHANGED
@@ -1,21 +1,8 @@
|
|
1 |
<?php
|
|
|
2 |
|
3 |
function cnb_admin_header_get_cloud_error($error) {
|
4 |
-
|
5 |
-
$redirect_link =
|
6 |
-
add_query_arg(
|
7 |
-
array(
|
8 |
-
'page' => 'call-now-button-settings',
|
9 |
-
),
|
10 |
-
$url );
|
11 |
-
$redirect_url = esc_url( $redirect_link );
|
12 |
-
$errorNotice = '<div class="notice notice-error">
|
13 |
-
<h2 class="title">API Key invalid</h2>
|
14 |
-
<p>You have enabled Cloud Hosting, but you need a valid API key from CallNowButtom</p>
|
15 |
-
<p>Go to <a href="'.$redirect_url.'">Settings</a> for instructions.</p>';
|
16 |
-
$errorNotice .= CnbAdminCloud::cnb_admin_get_error_message_details( $error );
|
17 |
-
$errorNotice .= '</div>';
|
18 |
-
return $errorNotice;
|
19 |
}
|
20 |
|
21 |
function cnb_admin_header( $cnb_options, $cnb_settings, $cnb_cloud_notifications = array(), $cnb_changelog = array() ) {
|
@@ -28,14 +15,18 @@ function cnb_admin_header( $cnb_options, $cnb_settings, $cnb_cloud_notifications
|
|
28 |
|
29 |
// Display notification that the button is active or inactive
|
30 |
if ( $cnb_options['active'] != 1 ) {
|
31 |
-
echo
|
|
|
|
|
|
|
|
|
32 |
}
|
33 |
|
34 |
// Display notification that there's a caching plugin active
|
35 |
if ( isset( $_GET['settings-updated'] ) ) {
|
36 |
$cnb_caching_check = cnb_check_for_caching();
|
37 |
if ( $cnb_caching_check[0] == true ) {
|
38 |
-
echo
|
39 |
}
|
40 |
}
|
41 |
|
1 |
<?php
|
2 |
+
require_once dirname( __FILE__ ) . '/../../utils/notices.php';
|
3 |
|
4 |
function cnb_admin_header_get_cloud_error($error) {
|
5 |
+
return cnb_api_key_invalid_notice($error);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
}
|
7 |
|
8 |
function cnb_admin_header( $cnb_options, $cnb_settings, $cnb_cloud_notifications = array(), $cnb_changelog = array() ) {
|
15 |
|
16 |
// Display notification that the button is active or inactive
|
17 |
if ( $cnb_options['active'] != 1 ) {
|
18 |
+
echo cnb_button_disabled_notice();
|
19 |
+
}
|
20 |
+
|
21 |
+
if ( $cnb_options['active'] == 1 && $cnb_options['status'] == 'enabled' && empty($cnb_options['number'])) {
|
22 |
+
echo cnb_button_classic_enabled_but_no_number_notice();
|
23 |
}
|
24 |
|
25 |
// Display notification that there's a caching plugin active
|
26 |
if ( isset( $_GET['settings-updated'] ) ) {
|
27 |
$cnb_caching_check = cnb_check_for_caching();
|
28 |
if ( $cnb_caching_check[0] == true ) {
|
29 |
+
echo cnb_caching_plugin_warning_notice($cnb_caching_check[1]);
|
30 |
}
|
31 |
}
|
32 |
|
src/admin/settings.php
CHANGED
@@ -232,7 +232,7 @@ function cnb_admin_settings_page() {
|
|
232 |
<th colspan="2"></th>
|
233 |
</tr>
|
234 |
<tr>
|
235 |
-
<th scope="row">
|
236 |
<td>
|
237 |
<div class="cnb-radio-item">
|
238 |
<input type="radio" name="cnb[status]" id="cnb_status_disabled" value="disabled" <?php checked('disabled', $cnb_options['status']); ?> />
|
@@ -380,7 +380,7 @@ function cnb_admin_settings_page() {
|
|
380 |
</tr>
|
381 |
<tr>
|
382 |
<th scope="row">Account ID</th>
|
383 |
-
<td><?php esc_html_e($cnb_user->id) ?></td>
|
384 |
</tr>
|
385 |
<?php } ?>
|
386 |
</table>
|
232 |
<th colspan="2"></th>
|
233 |
</tr>
|
234 |
<tr>
|
235 |
+
<th scope="row">Button status:</th>
|
236 |
<td>
|
237 |
<div class="cnb-radio-item">
|
238 |
<input type="radio" name="cnb[status]" id="cnb_status_disabled" value="disabled" <?php checked('disabled', $cnb_options['status']); ?> />
|
380 |
</tr>
|
381 |
<tr>
|
382 |
<th scope="row">Account ID</th>
|
383 |
+
<td><code><?php esc_html_e($cnb_user->id) ?></code></td>
|
384 |
</tr>
|
385 |
<?php } ?>
|
386 |
</table>
|
src/utils/notices.php
CHANGED
@@ -27,15 +27,9 @@ function cnb_settings_get_account_missing_notice($user) {
|
|
27 |
<input type="submit" class="button-primary" value="' . __('Save API key') . '"/>
|
28 |
</td>
|
29 |
</table>
|
30 |
-
</form>
|
31 |
-
|
32 |
-
|
33 |
-
Error code: <code>'. esc_html($user->get_error_code()) . '.</code>';
|
34 |
-
|
35 |
-
if ($user->get_error_message() != '') {
|
36 |
-
$notice .= 'Message: <code>'. esc_html($user->get_error_message()) .'</code>';
|
37 |
-
}
|
38 |
-
$notice .= '</p></div>';
|
39 |
return $notice;
|
40 |
}
|
41 |
|
@@ -51,14 +45,9 @@ function cnb_settings_get_domain_missing_notice($domain) {
|
|
51 |
<input type="hidden" name="_wpnonce" value="' . wp_create_nonce('cnb_create_cloud_domain') .'" />
|
52 |
<input type="submit" value="Create domain" class="button button-secondary" />
|
53 |
</form>
|
54 |
-
</p>
|
55 |
-
|
56 |
-
|
57 |
-
Error code: <code>' . esc_html($domain->get_error_code()) . '</code>';
|
58 |
-
if ($domain->get_error_message() != '') {
|
59 |
-
$notice .= 'Message: <code>' . esc_html($domain->get_error_message()) . '</code>';
|
60 |
-
}
|
61 |
-
$notice .= '</p></div>';
|
62 |
return $notice;
|
63 |
}
|
64 |
|
@@ -83,12 +72,64 @@ function cnb_settings_get_buttons_missing_notice($error) {
|
|
83 |
$notice = '<div class="notice notice-warning">
|
84 |
<h2 class="title">Could not retrieve Buttons</h2>
|
85 |
<p>Something unexpected went wrong retrieving the Buttons for this API key</p>';
|
86 |
-
$notice .=
|
87 |
-
|
88 |
-
Error code: <code>' . esc_html($error->get_error_code()) . '</code>';
|
89 |
-
if ($error->get_error_message() != '') {
|
90 |
-
$notice .= 'Message: <code>' . esc_html($error->get_error_message()) . '</code>';
|
91 |
-
}
|
92 |
-
$notice .= '</p></div>';
|
93 |
return $notice;
|
94 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
<input type="submit" class="button-primary" value="' . __('Save API key') . '"/>
|
28 |
</td>
|
29 |
</table>
|
30 |
+
</form>';
|
31 |
+
$notice .= CnbAdminCloud::cnb_admin_get_error_message_details($user);
|
32 |
+
$notice .= '</div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
return $notice;
|
34 |
}
|
35 |
|
45 |
<input type="hidden" name="_wpnonce" value="' . wp_create_nonce('cnb_create_cloud_domain') .'" />
|
46 |
<input type="submit" value="Create domain" class="button button-secondary" />
|
47 |
</form>
|
48 |
+
</p>';
|
49 |
+
$notice .= CnbAdminCloud::cnb_admin_get_error_message_details( $domain );
|
50 |
+
$notice .= '</div>';
|
|
|
|
|
|
|
|
|
|
|
51 |
return $notice;
|
52 |
}
|
53 |
|
72 |
$notice = '<div class="notice notice-warning">
|
73 |
<h2 class="title">Could not retrieve Buttons</h2>
|
74 |
<p>Something unexpected went wrong retrieving the Buttons for this API key</p>';
|
75 |
+
$notice .= CnbAdminCloud::cnb_admin_get_error_message_details( $error );
|
76 |
+
$notice .= '</div>';
|
|
|
|
|
|
|
|
|
|
|
77 |
return $notice;
|
78 |
}
|
79 |
+
|
80 |
+
function cnb_api_key_invalid_notice($error) {
|
81 |
+
$url = admin_url('admin.php');
|
82 |
+
$redirect_link =
|
83 |
+
add_query_arg(
|
84 |
+
array(
|
85 |
+
'page' => 'call-now-button-settings',
|
86 |
+
),
|
87 |
+
$url );
|
88 |
+
$redirect_url = esc_url( $redirect_link );
|
89 |
+
|
90 |
+
$errorNotice = '<div class="notice notice-error">
|
91 |
+
<h2 class="title">API Key invalid</h2>
|
92 |
+
<p>You have enabled Cloud Hosting, but you need a valid API key from CallNowButtom</p>
|
93 |
+
<p>Go to <a href="'.$redirect_url.'">Settings</a> for instructions.</p>';
|
94 |
+
$errorNotice .= CnbAdminCloud::cnb_admin_get_error_message_details( $error );
|
95 |
+
$errorNotice .= '</div>';
|
96 |
+
return $errorNotice;
|
97 |
+
|
98 |
+
}
|
99 |
+
|
100 |
+
function cnb_button_disabled_notice() {
|
101 |
+
$url = admin_url('admin.php');
|
102 |
+
$redirect_link =
|
103 |
+
add_query_arg(
|
104 |
+
array(
|
105 |
+
'page' => 'call-now-button-settings',
|
106 |
+
),
|
107 |
+
$url );
|
108 |
+
$redirect_url = esc_url( $redirect_link );
|
109 |
+
|
110 |
+
return '<div class="notice-error notice">
|
111 |
+
<p>The Call Now Button is currently <b>disabled</b>.
|
112 |
+
Change the <i>Button status</i> under <a href="'.$redirect_url.'">Settings</a> to enable.</p></div>';
|
113 |
+
}
|
114 |
+
|
115 |
+
function cnb_button_classic_enabled_but_no_number_notice() {
|
116 |
+
$url = admin_url('admin.php');
|
117 |
+
$redirect_link =
|
118 |
+
add_query_arg(
|
119 |
+
array(
|
120 |
+
'page' => 'call-now-button-settings',
|
121 |
+
),
|
122 |
+
$url );
|
123 |
+
$redirect_url = esc_url( $redirect_link );
|
124 |
+
|
125 |
+
return '<div class="notice-warning notice">
|
126 |
+
<p>The Call Now Button is currently <strong>active without a phone number</strong>.
|
127 |
+
Change the <i>Button status</i> under <a href="'.$redirect_url.'">Settings</a> to disable or enter a phone number.</p></div>';
|
128 |
+
}
|
129 |
+
|
130 |
+
function cnb_caching_plugin_warning_notice($caching_plugin_name) {
|
131 |
+
return '<div class="notice-error notice">
|
132 |
+
<p><span class="dashicons dashicons-warning"></span>
|
133 |
+
Your website is using a <strong><i>Caching Plugin</i></strong> (' . $caching_plugin_name . ').
|
134 |
+
If you\'re not seeing your button or your changes, make sure you empty your cache first.</p></div>';
|
135 |
+
}
|
src/utils/utils.php
CHANGED
@@ -92,7 +92,7 @@ function cnb_update_options() {
|
|
92 |
? $cnb_options['frontpage'] == 1 ? 1 : 0
|
93 |
: $cnb_defaults['frontpage'];
|
94 |
$cnb_options['conversions'] = isset($cnb_options['conversions'])
|
95 |
-
? $cnb_options['conversions'] == 1 ?
|
96 |
: $cnb_defaults['conversions'];
|
97 |
$cnb_options['zoom'] = isset($cnb_options['zoom']) ? $cnb_options['zoom'] : $cnb_defaults['zoom'];
|
98 |
$cnb_options['z-index'] = isset($cnb_options['z-index']) ? $cnb_options['z-index'] : $cnb_defaults['z-index'];
|
@@ -369,3 +369,10 @@ function cnb_array_column($array, $column_key, $index_key = null) {
|
|
369 |
return array_column($array_arr, $column_key, $index_key);
|
370 |
}
|
371 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
? $cnb_options['frontpage'] == 1 ? 1 : 0
|
93 |
: $cnb_defaults['frontpage'];
|
94 |
$cnb_options['conversions'] = isset($cnb_options['conversions'])
|
95 |
+
? ($cnb_options['conversions'] == 1 || $cnb_options['conversions'] == 2) ? (int) $cnb_options['conversions'] : 0
|
96 |
: $cnb_defaults['conversions'];
|
97 |
$cnb_options['zoom'] = isset($cnb_options['zoom']) ? $cnb_options['zoom'] : $cnb_defaults['zoom'];
|
98 |
$cnb_options['z-index'] = isset($cnb_options['z-index']) ? $cnb_options['z-index'] : $cnb_defaults['z-index'];
|
369 |
return array_column($array_arr, $column_key, $index_key);
|
370 |
}
|
371 |
}
|
372 |
+
|
373 |
+
function cnb_timestamp_to_string($timestamp){
|
374 |
+
if ( $timestamp instanceof stdClass ) {
|
375 |
+
return date("r", $timestamp->seconds);
|
376 |
+
}
|
377 |
+
return $timestamp;
|
378 |
+
}
|