Call Now Button - Version 1.1.12

Version Description

  • Small hotfix
Download this release

Release Info

Developer jasperroel
Plugin Icon 128x128 Call Now Button
Version 1.1.12
Comparing to
See all releases

Code changes from version 1.1.11 to 1.1.12

call-now-button.php CHANGED
@@ -3,7 +3,7 @@
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: 1.1.11
7
  Author: Jerry Rietveld
8
  Author URI: https://www.callnowbutton.com
9
  GitHub Plugin URI: https://github.com/callnowbutton/wp-plugin
@@ -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', '1.1.11');
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: 1.1.12
7
  Author: Jerry Rietveld
8
  Author URI: https://www.callnowbutton.com
9
  GitHub Plugin URI: https://github.com/callnowbutton/wp-plugin
26
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
  */
28
 
29
+ define('CNB_VERSION', '1.1.12');
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: 6.0
8
- Stable tag: 1.1.11
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -111,6 +111,9 @@ Yes, you can upgrade to Premium to enable tons of extra features. Checkout [call
111
 
112
 
113
  == Changelog ==
 
 
 
114
  = 1.1.11 =
115
  * Welcome page for new installations
116
  * UI improvements
5
  Requires at least: 3.9
6
  Requires PHP: 5.4
7
  Tested up to: 6.0
8
+ Stable tag: 1.1.12
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
111
 
112
 
113
  == Changelog ==
114
+ = 1.1.12 =
115
+ * Small hotfix
116
+
117
  = 1.1.11 =
118
  * Welcome page for new installations
119
  * UI improvements
resources/js/dismiss.js CHANGED
@@ -6,9 +6,16 @@ function cnb_dismissables_listener() {
6
  jQuery( '.notice-call-now-button').on( 'click', '.notice-dismiss',
7
  function() {
8
  const $notice = jQuery(this).parent('.is-dismissible');
9
- const dismiss_url = $notice.attr('data-dismiss-url');
10
- if ( dismiss_url ) {
11
- jQuery.get( dismiss_url );
 
 
 
 
 
 
 
12
  }
13
  });
14
  }
6
  jQuery( '.notice-call-now-button').on( 'click', '.notice-dismiss',
7
  function() {
8
  const $notice = jQuery(this).parent('.is-dismissible');
9
+ const dismiss_option = $notice.attr('data-dismiss-option');
10
+ const nonce = $notice.attr('data-dismiss-nonce');
11
+ if ( dismiss_option ) {
12
+ const data = {
13
+ 'action': 'cnb_hide_notice',
14
+ '_wpnonce': nonce,
15
+ 'dismiss_option': dismiss_option
16
+ };
17
+
18
+ jQuery.post(ajaxurl, data)
19
  }
20
  });
21
  }
src/CallNowButton.php CHANGED
@@ -27,6 +27,7 @@ use cnb\admin\profile\CnbProfileController;
27
  use cnb\admin\profile\CnbProfileRouter;
28
  use cnb\admin\settings\CnbSettingsController;
29
  use cnb\admin\settings\CnbSettingsRouter;
 
30
  use cnb\utils\Cnb_Sentry;
31
  use cnb\utils\CnbUtils;
32
 
@@ -55,7 +56,8 @@ class CallNowButton {
55
 
56
  $header_notices = new CnbHeaderNotices();
57
  $has_changelog = $header_notices->upgrade_notice();
58
- if ($has_changelog) $counter++;
 
59
 
60
  // Detect errors (specific, - Premium enabled, but API key is not present yet)
61
  if ( $cnb_cloud_hosting && ! array_key_exists( 'api_key', $cnb_options ) ) {
@@ -512,5 +514,8 @@ class CallNowButton {
512
 
513
  $domain_controller = new CnbDomainController();
514
  add_action( 'wp_ajax_cnb_domain_timezone_change', array( $domain_controller, 'update_timezone' ) );
 
 
 
515
  }
516
  }
27
  use cnb\admin\profile\CnbProfileRouter;
28
  use cnb\admin\settings\CnbSettingsController;
29
  use cnb\admin\settings\CnbSettingsRouter;
30
+ use cnb\notices\CnbAdminNotices;
31
  use cnb\utils\Cnb_Sentry;
32
  use cnb\utils\CnbUtils;
33
 
56
 
57
  $header_notices = new CnbHeaderNotices();
58
  $has_changelog = $header_notices->upgrade_notice();
59
+ $is_dismissed = CnbAdminNotices::get_instance()->is_dismissed($header_notices->cnb_get_upgrade_notice_dismiss_name());
60
+ if ($has_changelog && !$is_dismissed) $counter++;
61
 
62
  // Detect errors (specific, - Premium enabled, but API key is not present yet)
63
  if ( $cnb_cloud_hosting && ! array_key_exists( 'api_key', $cnb_options ) ) {
514
 
515
  $domain_controller = new CnbDomainController();
516
  add_action( 'wp_ajax_cnb_domain_timezone_change', array( $domain_controller, 'update_timezone' ) );
517
+
518
+ $admin_controller = CnbAdminNotices::get_instance();
519
+ add_action( 'wp_ajax_cnb_hide_notice', array( $admin_controller, 'hide_notice' ) );
520
  }
521
  }
src/admin/partials/CnbHeader.php CHANGED
@@ -51,7 +51,6 @@ class CnbHeader {
51
 
52
  echo '<div class="wrap call-now-button-plugin">'; // This is closed in CnbFooter::render
53
 
54
- echo '<!--## NOTIFICATION BARS ## -->';
55
  $noticeHandler = new CnbHeaderNotices();
56
 
57
  $noticeHandler->get_cloud_notices();
51
 
52
  echo '<div class="wrap call-now-button-plugin">'; // This is closed in CnbFooter::render
53
 
 
54
  $noticeHandler = new CnbHeaderNotices();
55
 
56
  $noticeHandler->get_cloud_notices();
src/admin/partials/CnbHeaderNotices.php CHANGED
@@ -230,7 +230,7 @@ class CnbHeaderNotices {
230
  function get_generic_changelog_message() {
231
  $cnb_utils = new CnbUtils();
232
  $changelog_link = $cnb_utils->get_website_url( 'wordpress/changelog/', 'update_notice' );
233
- $changelog_message = '<a href="' . esc_url( $changelog_link ) . '">Click here to see what changed</a>';
234
  $message = '<p><span class="dashicons dashicons-yes"></span> ';
235
  $message .= 'The plugin has been updated. ';
236
  $message .= $changelog_message;
230
  function get_generic_changelog_message() {
231
  $cnb_utils = new CnbUtils();
232
  $changelog_link = $cnb_utils->get_website_url( 'wordpress/changelog/', 'update_notice' );
233
+ $changelog_message = '<a href="' . esc_url( $changelog_link ) . '" target="_blank">Click here to see what changed</a>';
234
  $message = '<p><span class="dashicons dashicons-yes"></span> ';
235
  $message .= 'The plugin has been updated. ';
236
  $message .= $changelog_message;
src/notices/CnbAdminNotices.php CHANGED
@@ -22,8 +22,7 @@ class CnbAdminNotices {
22
  private function __construct() {
23
  $this->admin_notices = new CnbNotices();
24
 
25
- add_action( 'admin_init', array( &$this, 'action_admin_init' ) );
26
- add_action( 'cnb_admin_notices', array( &$this, 'action_admin_notices' ) );
27
  }
28
 
29
  public static function get_instance() {
@@ -34,17 +33,38 @@ class CnbAdminNotices {
34
  return self::$_instance;
35
  }
36
 
37
- public function action_admin_init() {
38
- $dismiss_option = filter_input( INPUT_GET, CNB_SLUG . '_dismiss', FILTER_SANITIZE_STRING );
39
- if ( is_string( $dismiss_option ) && ! empty( $dismiss_option ) ) {
40
- update_option( CNB_SLUG . '_dismissed_' . $dismiss_option, true );
41
- do_action( $dismiss_option );
42
- wp_die(
43
- esc_html( 'Dismissed notice: ' . $dismiss_option ), esc_html__( 'Dismissed notice' ),
44
- array(
45
- 'response' => 200,
46
- )
47
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
  }
50
 
@@ -68,13 +88,8 @@ class CnbAdminNotices {
68
  }
69
 
70
  $dismiss_classes = '';
71
- $dismiss_url = null;
72
  if ( $notice->dismiss_option ) {
73
  $notice->dismissable = true;
74
- $url = admin_url( 'admin.php' );
75
- $dismiss_url = add_query_arg( array(
76
- CNB_SLUG . '_dismiss' => $notice->dismiss_option
77
- ), $url );
78
  }
79
 
80
  if ( $notice->dismissable ) {
@@ -88,8 +103,9 @@ class CnbAdminNotices {
88
  esc_attr( $dismiss_classes ) .
89
  '"' .
90
  // phpcs:ignore WordPress.Security
91
- ( $notice->dismissable === true && $dismiss_url
92
- ? ' data-dismiss-url="' . esc_url( $dismiss_url ) . '"'
 
93
  : ''
94
  ) . '>';
95
  // phpcs:ignore WordPress.Security
22
  private function __construct() {
23
  $this->admin_notices = new CnbNotices();
24
 
25
+ add_action( 'cnb_admin_notices', array( $this, 'action_admin_notices' ) );
 
26
  }
27
 
28
  public static function get_instance() {
33
  return self::$_instance;
34
  }
35
 
36
+ /**
37
+ * Ensure a previous notice does not return.
38
+ *
39
+ * Called via admin_ajax
40
+ *
41
+ * @return void
42
+ */
43
+ public function hide_notice() {
44
+ do_action( 'cnb_init', __METHOD__ );
45
+ $nonce = filter_input( INPUT_POST, '_wpnonce', FILTER_SANITIZE_STRING );
46
+ $action = 'cnb_hide_notice';
47
+ $nonce_verified = wp_verify_nonce( $nonce, $action );
48
+ if ( $nonce_verified ) {
49
+ $dismiss_option = filter_input( INPUT_POST, 'dismiss_option', FILTER_SANITIZE_STRING );
50
+ if ( is_string( $dismiss_option ) && ! empty( $dismiss_option ) ) {
51
+ update_option( CNB_SLUG . '_dismissed_' . $dismiss_option, true );
52
+ // For example, do_action(cnb_update_' . CNB_VERSION), which calls the Settings Controller (update_version)
53
+ do_action( $dismiss_option );
54
+ do_action( 'cnb_finish' );
55
+ wp_die(
56
+ esc_html( 'Dismissed notice: ' . $dismiss_option ), esc_html__( 'Dismissed notice' ),
57
+ array(
58
+ 'response' => 200,
59
+ )
60
+ );
61
+ }
62
+ } else {
63
+ do_action( 'cnb_finish' );
64
+ wp_die( esc_html__( 'Invalid nonce specified' ), esc_html__( 'Error' ), array(
65
+ 'response' => 403,
66
+ 'back_link' => true,
67
+ ) );
68
  }
69
  }
70
 
88
  }
89
 
90
  $dismiss_classes = '';
 
91
  if ( $notice->dismiss_option ) {
92
  $notice->dismissable = true;
 
 
 
 
93
  }
94
 
95
  if ( $notice->dismissable ) {
103
  esc_attr( $dismiss_classes ) .
104
  '"' .
105
  // phpcs:ignore WordPress.Security
106
+ ( $notice->dismissable === true && $notice->dismiss_option
107
+ ? ' data-dismiss-option="' . esc_attr( $notice->dismiss_option ) . '"' .
108
+ ' data-dismiss-nonce="' . esc_attr(wp_create_nonce('cnb_hide_notice')) . '"'
109
  : ''
110
  ) . '>';
111
  // phpcs:ignore WordPress.Security