Call Now Button - Version 1.1.10

Version Description

  • Introduced geo targeting (Premium PRO)
  • New PRO feature: Reveal at scroll height (Premium PRO)
  • Small fixes/improvements
Download this release

Release Info

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

Code changes from version 1.1.9 to 1.1.10

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.9
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.9');
30
  define('CNB_NAME', 'Call Now Button');
31
  define('CNB_BASENAME', plugin_basename(__FILE__));
32
  define('CNB_BASEFOLDER', plugin_basename(dirname(__FILE__)));
@@ -36,6 +36,7 @@ define('CNB_SUPPORT', CNB_WEBSITE . 'support/');
36
  define('CNB_APP', 'https://app.callnowbutton.com/');
37
  define('CNB_SLUG', sanitize_title(CNB_NAME));
38
 
 
39
  register_deactivation_hook( __FILE__, array('cnb\admin\deactivation\Deactivation', 'onDeactivation') );
40
 
41
  require_once dirname( __FILE__ ) . '/src/call-now-button.php';
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.10
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.10');
30
  define('CNB_NAME', 'Call Now Button');
31
  define('CNB_BASENAME', plugin_basename(__FILE__));
32
  define('CNB_BASEFOLDER', plugin_basename(dirname(__FILE__)));
36
  define('CNB_APP', 'https://app.callnowbutton.com/');
37
  define('CNB_SLUG', sanitize_title(CNB_NAME));
38
 
39
+ register_activation_hook(__FILE__, array('cnb\admin\deactivation\Activation', 'onActivation'));
40
  register_deactivation_hook( __FILE__, array('cnb\admin\deactivation\Deactivation', 'onDeactivation') );
41
 
42
  require_once dirname( __FILE__ ) . '/src/call-now-button.php';
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.9
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -111,6 +111,11 @@ Yes, you can upgrade to Premium to enable tons of extra features. Checkout [call
111
 
112
 
113
  == Changelog ==
 
 
 
 
 
114
  = 1.1.9 =
115
  * Introduced exit surveys
116
  * Error & usage reporting setting (off by default)
5
  Requires at least: 3.9
6
  Requires PHP: 5.4
7
  Tested up to: 6.0
8
+ Stable tag: 1.1.10
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.10 =
115
+ * Introduced geo targeting (Premium PRO)
116
+ * New PRO feature: Reveal at scroll height (Premium PRO)
117
+ * Small fixes/improvements
118
+
119
  = 1.1.9 =
120
  * Introduced exit surveys
121
  * Error & usage reporting setting (off by default)
resources/js/call-now-button.js CHANGED
@@ -501,8 +501,8 @@ function cnb_setup_pricing() {
501
  // Fix the elements
502
  result['eur_per_month'] = parseFloat(result['eur_per_month']).toFixed(2)
503
  result['usd_per_month'] = parseFloat(result['usd_per_month']).toFixed(2)
504
- result['eur_discount'] = parseFloat(result['eur_discount']).toFixed(1)
505
- result['usd_discount'] = parseFloat(result['usd_discount']).toFixed(1)
506
 
507
  jQuery('.eur-per-month').text(result['eur_per_month'])
508
  jQuery('.usd-per-month').text(result['usd_per_month'])
501
  // Fix the elements
502
  result['eur_per_month'] = parseFloat(result['eur_per_month']).toFixed(2)
503
  result['usd_per_month'] = parseFloat(result['usd_per_month']).toFixed(2)
504
+ result['eur_discount'] = Math.ceil(parseFloat(result['eur_discount']))
505
+ result['usd_discount'] = Math.ceil(parseFloat(result['usd_discount']))
506
 
507
  jQuery('.eur-per-month').text(result['eur_per_month'])
508
  jQuery('.usd-per-month').text(result['usd_per_month'])
resources/js/condition-edit.js CHANGED
@@ -10,7 +10,7 @@ function cnb_show_condition_placeholder_action() {
10
  } else if(optionSelected === 'REGEX') {
11
  placeholderText = '/(index|about)(\?id=[0-9]+)?$'
12
  } else if(optionSelected === 'COUNTRY_CODE') {
13
- placeholderText = 'NL'
14
  }
15
  jQuery('#cnb_condition_match_value').attr('placeholder', placeholderText)
16
  }
@@ -100,8 +100,8 @@ function cnb_delete_condition() {
100
  const remaining_items = jQuery('table.cnb_list_conditions #the-list tr').length
101
  if (!remaining_items) {
102
  // Add row
103
- jQuery('table.cnb_list_conditions #the-list').html('<tr class="no-items"><td class="colspanchange" colspan="5"<p class="cnb_paragraph">You have no page visibility rules set up. This means that your button will show on all pages.</p>' +
104
- '<p class="cnb_paragraph">Click the <code>Add page rule</code> button above to limit the appearance. You can freely mix and match rules to meet your requirements.</p></td></tr>')
105
  }
106
  })
107
  })
10
  } else if(optionSelected === 'REGEX') {
11
  placeholderText = '/(index|about)(\?id=[0-9]+)?$'
12
  } else if(optionSelected === 'COUNTRY_CODE') {
13
+ placeholderText = '2 letter country code (e.g. NL)'
14
  }
15
  jQuery('#cnb_condition_match_value').attr('placeholder', placeholderText)
16
  }
100
  const remaining_items = jQuery('table.cnb_list_conditions #the-list tr').length
101
  if (!remaining_items) {
102
  // Add row
103
+ jQuery('table.cnb_list_conditions #the-list').html('<tr class="no-items"><td class="colspanchange" colspan="5"<p class="cnb_paragraph">You have no display rules set up. This means that your button will show on all pages.</p>' +
104
+ '<p class="cnb_paragraph">Click the <code>Add display rule</code> button above to limit the appearance. You can freely mix and match rules to meet your requirements.</p></td></tr>')
105
  }
106
  })
107
  })
resources/js/deactivation.js CHANGED
@@ -22,6 +22,7 @@ function cnb_add_deactivation_popup_tally() {
22
  },
23
  hiddenFields: {
24
  wordPressUrl: window.location.href,
 
25
  },
26
  onClose: () => window.location = event.target.href,
27
  onSubmit: () => {
22
  },
23
  hiddenFields: {
24
  wordPressUrl: window.location.href,
25
+ activationTime: cnb_plugin_data.activation_time,
26
  },
27
  onClose: () => window.location = event.target.href,
28
  onSubmit: () => {
resources/js/legacy-edit.js CHANGED
@@ -1,23 +1,34 @@
1
  function cnb_setup_legacy() {
2
  // Option to Hide Icon is only visible when the full width button is selected
3
- const radioValue = jQuery("input[name='cnb[appearance]']:checked").val();
4
- const textValue = jQuery("input[name='cnb[text]']").val();
 
5
  if(radioValue !== 'full' && radioValue !== 'tfull') {
6
- jQuery('#hideIconTR').hide();
7
  } else if(textValue.length < 1) {
8
- jQuery('#hideIconTR').hide();
9
  }
 
10
  jQuery('input[name="cnb[appearance]"]').on("change",function(){
11
- const radioValue = jQuery("input[name='cnb[appearance]']:checked").val();
12
- const textValue = jQuery("input[name='cnb[text]']").val();
13
  if(radioValue !== 'full' && radioValue !== 'tfull') {
14
- jQuery('#hideIconTR').hide();
15
  } else if(textValue.length > 0 ) {
16
- jQuery('#hideIconTR').show();
17
  }
18
- });
 
 
 
 
 
 
 
 
19
  }
20
 
21
  jQuery( function() {
22
- cnb_setup_legacy();
23
- })
 
1
  function cnb_setup_legacy() {
2
  // Option to Hide Icon is only visible when the full width button is selected
3
+ const radioValue = jQuery("input[name='cnb[appearance]']:checked").val()
4
+ const textValue = jQuery("input[name='cnb[text]']").val()
5
+
6
  if(radioValue !== 'full' && radioValue !== 'tfull') {
7
+ jQuery('#hideIconTR').hide()
8
  } else if(textValue.length < 1) {
9
+ jQuery('#hideIconTR').hide()
10
  }
11
+
12
  jQuery('input[name="cnb[appearance]"]').on("change",function(){
13
+ const radioValue = jQuery("input[name='cnb[appearance]']:checked").val()
14
+ const textValue = jQuery("input[name='cnb[text]']").val()
15
  if(radioValue !== 'full' && radioValue !== 'tfull') {
16
+ jQuery('#hideIconTR').hide()
17
  } else if(textValue.length > 0 ) {
18
+ jQuery('#hideIconTR').show()
19
  }
20
+ })
21
+ }
22
+
23
+ function cnb_setup_banner() {
24
+ jQuery('.welcome-banner-content').slideUp()
25
+ jQuery('#welcome-banner-notice').on("click",function() {
26
+ jQuery('#welcome-banner-notice').remove()
27
+ jQuery('.welcome-banner-content').slideToggle()
28
+ })
29
  }
30
 
31
  jQuery( function() {
32
+ cnb_setup_legacy()
33
+ cnb_setup_banner()
34
+ })
resources/style/call-now-button.css CHANGED
@@ -961,6 +961,16 @@ Enforce mobile viewport for previews via overwrites:
961
  /*
962
  Welcome banner styling
963
  */
 
 
 
 
 
 
 
 
 
 
964
  .welcome-banner {
965
  position: relative;
966
  overflow: auto;
@@ -971,6 +981,8 @@ Welcome banner styling
971
  background: #fff;
972
  font-size: 13px;
973
  line-height: 1.7;
 
 
974
  }
975
  .welcome-banner h2 {
976
  margin: 0;
@@ -1044,16 +1056,7 @@ Welcome banner styling
1044
  }
1045
 
1046
  }
1047
- @media screen and (min-width:783px) {
1048
- .welcome-banner .screen-reader-text {
1049
- width: 55px;
1050
- height: 14px;
1051
- right: 26px;
1052
- top: 11px;
1053
- clip-path: none;
1054
- clip: unset;
1055
- }
1056
- }
1057
 
1058
  a.cnb-nav-tab {
1059
  float: left;
@@ -1212,3 +1215,14 @@ td.draggable svg {
1212
  .ui-sortable-placeholder td:first-of-type{
1213
  display: none;
1214
  }
 
 
 
 
 
 
 
 
 
 
 
961
  /*
962
  Welcome banner styling
963
  */
964
+ .cnb-expand-link {
965
+ text-decoration: underline;
966
+ }
967
+ #welcome-banner-notice {
968
+ margin-top: -13px;
969
+ margin-left: 10px;
970
+ margin-bottom: 0;
971
+ color:#3c434a;
972
+ cursor: pointer;
973
+ }
974
  .welcome-banner {
975
  position: relative;
976
  overflow: auto;
981
  background: #fff;
982
  font-size: 13px;
983
  line-height: 1.7;
984
+ border-left-width: 4px;
985
+ border-left-color: #B12371;
986
  }
987
  .welcome-banner h2 {
988
  margin: 0;
1056
  }
1057
 
1058
  }
1059
+
 
 
 
 
 
 
 
 
 
1060
 
1061
  a.cnb-nav-tab {
1062
  float: left;
1215
  .ui-sortable-placeholder td:first-of-type{
1216
  display: none;
1217
  }
1218
+ span.cnb-pro-badge {
1219
+ display: inline-block;
1220
+ padding: 2px 4px;
1221
+ border-radius: 4px;
1222
+ font-size: 11px;
1223
+ font-weight: bold;
1224
+ line-height: 1.15;
1225
+ text-transform: uppercase;
1226
+ color: rgb(0 153 0);
1227
+ background: rgba(0, 153, 0, 0.125);
1228
+ }
src/CallNowButton.php CHANGED
@@ -227,6 +227,7 @@ class CallNowButton {
227
  }
228
 
229
  public function register_styles_and_scripts() {
 
230
  wp_register_style(
231
  CNB_SLUG . '-styling',
232
  plugins_url( '../resources/style/call-now-button.css', __FILE__ ),
@@ -382,6 +383,14 @@ class CallNowButton {
382
  null,
383
  '17.0.12',
384
  true );
 
 
 
 
 
 
 
 
385
  }
386
 
387
  public function register_global_actions() {
227
  }
228
 
229
  public function register_styles_and_scripts() {
230
+ $options = get_option('cnb');
231
  wp_register_style(
232
  CNB_SLUG . '-styling',
233
  plugins_url( '../resources/style/call-now-button.css', __FILE__ ),
383
  null,
384
  '17.0.12',
385
  true );
386
+
387
+ $activation_time = array_key_exists('activation_time', $options) ? $options['activation_time'] : 0;
388
+ wp_localize_script( CNB_SLUG . '-deactivation', 'cnb_plugin_data',
389
+ array(
390
+ 'activation_time' => $activation_time,
391
+ )
392
+ );
393
+
394
  }
395
 
396
  public function register_global_actions() {
src/admin/button/CnbButtonView.php CHANGED
@@ -143,9 +143,10 @@ class CnbButtonView {
143
  echo '<!-- Sidebar messages -->';
144
  ( new CnbAdminFunctions() )->cnb_promobox(
145
  'purple',
146
- '<span class="usd-discount"></span>% off with the annual plan!',
147
  '<p>Remove the <em>powered by</em> branding from your buttons!</p>
148
- <p>Enjoy unlimited access to all features and publish your buttons without branding.</p>',
 
149
  'flag',
150
  '<strong>&euro;<span class="eur-per-month"></span>/$<span class="usd-per-month"></span> per month</strong>',
151
  'Upgrade',
143
  echo '<!-- Sidebar messages -->';
144
  ( new CnbAdminFunctions() )->cnb_promobox(
145
  'purple',
146
+ 'Remove "Powered by"',
147
  '<p>Remove the <em>powered by</em> branding from your buttons!</p>
148
+ <p>Enjoy unlimited access to all features and publish your buttons without branding.</p>
149
+ <p>Get <strong><span class="usd-discount"></span>% off</strong> with the annual plan!</p>',
150
  'flag',
151
  '<strong>&euro;<span class="eur-per-month"></span>/$<span class="usd-per-month"></span> per month</strong>',
152
  'Upgrade',
src/admin/button/CnbButtonViewEdit.php CHANGED
@@ -581,40 +581,13 @@ class CnbButtonViewEdit {
581
  </select>
582
  </td>
583
  </tr>
584
- <tr class="cnb_hide_on_modal cnb_advanced_view">
585
- <?php $reveal_at_height = $button->options->scroll ? $button->options->scroll->revealAtHeight : 0 ?>
586
- <th><label for="cnb-button-options-scroll-revealatheight">Reveal after scrolling</label></th>
587
- <td>
588
- <input name="button[options][scroll][revealAtHeight]" id="cnb-button-options-scroll-revealatheight" type="number" min="0" style="width: 80px" value="<?php echo esc_attr($reveal_at_height) ?>"> pixels from the top
589
- </td>
590
- </tr>
591
- <tr class="cnb_hide_on_modal cnb_advanced_view">
592
- <?php $hide_at_height = $button->options->scroll ? $button->options->scroll->hideAtHeight : 0 ?>
593
- <th><label for="cnb-button-options-scroll-hideAtHeight">Hide after scrolling</label></th>
594
- <td>
595
- <input name="button[options][scroll][hideAtHeight]" id="cnb-button-options-scroll-hideAtHeight" type="number" min="0" style="width: 80px" value="<?php echo esc_attr($hide_at_height) ?>"> pixels from the top
596
- <p class="description">hideAtHeight</p>
597
- </td>
598
- </tr>
599
- <tr class="cnb_hide_on_modal cnb_advanced_view">
600
- <?php $never_hide = $button->options->scroll ? $button->options->scroll->neverHide : false ?>
601
- <th><label for="cnb-button-options-scroll-neverhide">Never hide</label></th>
602
- <td>
603
- <input type="hidden" name="button[options][scroll][neverHide]" value="0"/>
604
- <input id="cnb-button-options-scroll-neverhide" class="cnb_toggle_checkbox" type="checkbox" name="button[options][scroll][neverHide]"
605
- value="1" <?php checked( true, $never_hide ); ?> />
606
- <label for="cnb-button-options-scroll-neverhide" class="cnb_toggle_label">Toggle</label>
607
- <span data-cnb_toggle_state_label="cnb-button-options-scroll-neverhide" class="cnb_toggle_state cnb_toggle_false">(Inactive)</span>
608
- <span data-cnb_toggle_state_label="cnb-button-options-scroll-neverhide" class="cnb_toggle_state cnb_toggle_true">Active</span>
609
- <p class="description">Once this Button is revealed, it will not be hidden again.</p>
610
- </td>
611
- </tr>
612
  <tr class="cnb_hide_on_modal">
613
  <th class="cnb_padding_0">
614
- <h2>Page rules</h2>
615
  </th>
616
  <td>
617
- <?php echo '<a href="' . esc_url( $new_condition_link ) . '" class="button">Add page rule</a>'; ?>
618
  </td>
619
  </tr>
620
  </tbody>
@@ -766,4 +739,64 @@ class CnbButtonViewEdit {
766
  <?php
767
  do_action( 'cnb_footer' );
768
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
769
  }
581
  </select>
582
  </td>
583
  </tr>
584
+ <?php $this->render_scroll_options($button); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
585
  <tr class="cnb_hide_on_modal">
586
  <th class="cnb_padding_0">
587
+ <h2>Display rules</h2>
588
  </th>
589
  <td>
590
+ <?php echo '<a href="' . esc_url( $new_condition_link ) . '" class="button">Add display rule</a>'; ?>
591
  </td>
592
  </tr>
593
  </tbody>
739
  <?php
740
  do_action( 'cnb_footer' );
741
  }
742
+
743
+ /**
744
+ * @param $button CnbButton
745
+ *
746
+ * @return void
747
+ */
748
+ private function render_scroll_options($button) {
749
+ global $cnb_domain;
750
+ $isPro = $cnb_domain != null && !is_wp_error($cnb_domain) && $cnb_domain->type === 'PRO';
751
+ ?>
752
+ <tr class="cnb_hide_on_modal">
753
+ <?php $reveal_at_height = $button->options->scroll ? $button->options->scroll->revealAtHeight : 0 ?>
754
+ <th><label for="cnb-button-options-scroll-revealatheight">Reveal after scrolling</label></th>
755
+ <td>
756
+ <input
757
+ name="button[options][scroll][revealAtHeight]"
758
+ id="cnb-button-options-scroll-revealatheight"
759
+ type="number"
760
+ min="0"
761
+ <?php if (!$isPro) { ?>disabled="disabled"<?php } ?>
762
+ style="width: 80px"
763
+ value="<?php echo esc_attr($reveal_at_height) ?>"> pixels from the top
764
+ <?php if (!$isPro) {
765
+ $upgrade_link =
766
+ add_query_arg( array(
767
+ 'page' => 'call-now-button-domains',
768
+ 'action' => 'upgrade',
769
+ 'id' => $cnb_domain->id
770
+ ),
771
+ admin_url( 'admin.php' ) );
772
+ ?>
773
+ <p class="description">
774
+ <a href="<?php echo esc_url( $upgrade_link ) ?>">Upgrade</a> to unlock this <span class="cnb-pro-badge">Pro</span> feature.
775
+ </p>
776
+ <?php } ?>
777
+ </td>
778
+ </tr>
779
+ <tr class="cnb_hide_on_modal cnb_advanced_view">
780
+ <?php $hide_at_height = $button->options->scroll ? $button->options->scroll->hideAtHeight : 0 ?>
781
+ <th><label for="cnb-button-options-scroll-hideAtHeight">Hide after scrolling</label></th>
782
+ <td>
783
+ <input name="button[options][scroll][hideAtHeight]" id="cnb-button-options-scroll-hideAtHeight" type="number" min="0" style="width: 80px" value="<?php echo esc_attr($hide_at_height) ?>"> pixels from the top
784
+ <p class="description">hideAtHeight</p>
785
+ </td>
786
+ </tr>
787
+ <tr class="cnb_hide_on_modal cnb_advanced_view">
788
+ <?php $never_hide = $button->options->scroll ? $button->options->scroll->neverHide : false ?>
789
+ <th><label for="cnb-button-options-scroll-neverhide">Never hide</label></th>
790
+ <td>
791
+ <input type="hidden" name="button[options][scroll][neverHide]" value="0"/>
792
+ <input id="cnb-button-options-scroll-neverhide" class="cnb_toggle_checkbox" type="checkbox" name="button[options][scroll][neverHide]"
793
+ value="1" <?php checked( true, $never_hide ); ?> />
794
+ <label for="cnb-button-options-scroll-neverhide" class="cnb_toggle_label">Toggle</label>
795
+ <span data-cnb_toggle_state_label="cnb-button-options-scroll-neverhide" class="cnb_toggle_state cnb_toggle_false">(Inactive)</span>
796
+ <span data-cnb_toggle_state_label="cnb-button-options-scroll-neverhide" class="cnb_toggle_state cnb_toggle_true">Active</span>
797
+ <p class="description">Once this Button is revealed, it will not be hidden again.</p>
798
+ </td>
799
+ </tr>
800
+ <?php
801
+ }
802
  }
src/admin/condition/CnbConditionViewEdit.php CHANGED
@@ -23,9 +23,9 @@ class CnbConditionViewEdit {
23
  if ( $condition->matchValue ) {
24
  $name = $condition->matchValue;
25
  }
26
- echo esc_html__( 'Editing condition' ) . ' <span class="cnb_button_name">' . esc_html( $name ) . '</span>';
27
  } else {
28
- echo esc_html__( 'Add condition' );
29
  }
30
  }
31
 
@@ -35,6 +35,8 @@ class CnbConditionViewEdit {
35
  * @param CnbCondition $condition
36
  */
37
  function render_table( $condition ) {
 
 
38
  ?>
39
  <table class="form-table nav-tab-active">
40
  <tbody>
@@ -49,7 +51,7 @@ class CnbConditionViewEdit {
49
  </th>
50
  </tr>
51
  <tr>
52
- <th scope="row"><label for="cnb_condition_filter_type">Filter type</label></th>
53
  <td>
54
  <select id="cnb_condition_filter_type"
55
  name="conditions[<?php echo esc_attr( $condition->id ) ?>][filterType]">
@@ -61,21 +63,38 @@ class CnbConditionViewEdit {
61
  </select>
62
  </td>
63
  </tr>
64
- <tr class="cnb_advanced_view">
65
- <th scope="row"><label for="cnb_condition_condition_type">Condition type</label></th>
66
  <td>
67
  <select id="cnb_condition_condition_type"
68
  name="conditions[<?php echo esc_attr( $condition->id ) ?>][conditionType]">
69
  <?php foreach ( ( new CnbAdminFunctions() )->cnb_get_condition_types() as $type_key => $type_key_value ) { ?>
70
- <option value="<?php echo esc_attr( $type_key ) ?>"<?php selected( $type_key, $condition->conditionType ) ?>>
71
- <?php echo esc_html( $type_key_value ) ?>
 
 
 
 
72
  </option>
73
  <?php } ?>
74
  </select>
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  </td>
76
  </tr>
77
  <tr>
78
- <th scope="row"><label for="cnb_condition_match_type">Match type</label></th>
79
  <td>
80
  <select id="cnb_condition_match_type"
81
  name="conditions[<?php echo esc_attr( $condition->id ) ?>][matchType]">
@@ -89,7 +108,7 @@ class CnbConditionViewEdit {
89
  <?php
90
  foreach ( ( new CnbAdminFunctions() )->cnb_get_condition_match_types_geo() as $condition_match_type_key => $condition_match_type_value ) { ?>
91
  <option class="conditionType conditionType_GEO" value="<?php echo esc_attr( $condition_match_type_key ) ?>"<?php selected( $condition_match_type_key, $condition->matchType ) ?>>
92
- <?php echo esc_html( $condition_match_type_value ) ?> (Geofencing only)
93
  </option>
94
  <?php } ?>
95
 
@@ -140,8 +159,8 @@ class CnbConditionViewEdit {
140
  $url ) );
141
 
142
  $action_verb = $condition->id === 'new' ? 'adding' : 'editing';
143
- $message = '<p><strong>You are ' . $action_verb . ' a Condition</strong>.
144
- Click <a href="' . $redirect_link . '">here</a> to go back to continue configuring the Button.</p>';
145
  CnbAdminNotices::get_instance()->renderInfo( $message );
146
  }
147
 
23
  if ( $condition->matchValue ) {
24
  $name = $condition->matchValue;
25
  }
26
+ echo esc_html__( 'Editing display rule' ) . ' <span class="cnb_button_name">' . esc_html( $name ) . '</span>';
27
  } else {
28
+ echo esc_html__( 'Add display rule' );
29
  }
30
  }
31
 
35
  * @param CnbCondition $condition
36
  */
37
  function render_table( $condition ) {
38
+ global $cnb_domain;
39
+ $isPro = $cnb_domain != null && !is_wp_error($cnb_domain) && $cnb_domain->type === 'PRO';
40
  ?>
41
  <table class="form-table nav-tab-active">
42
  <tbody>
51
  </th>
52
  </tr>
53
  <tr>
54
+ <th scope="row"><label for="cnb_condition_filter_type">I want to</label></th>
55
  <td>
56
  <select id="cnb_condition_filter_type"
57
  name="conditions[<?php echo esc_attr( $condition->id ) ?>][filterType]">
63
  </select>
64
  </td>
65
  </tr>
66
+ <tr>
67
+ <th scope="row"><label for="cnb_condition_condition_type">Based on</label></th>
68
  <td>
69
  <select id="cnb_condition_condition_type"
70
  name="conditions[<?php echo esc_attr( $condition->id ) ?>][conditionType]">
71
  <?php foreach ( ( new CnbAdminFunctions() )->cnb_get_condition_types() as $type_key => $type_key_value ) { ?>
72
+ <option
73
+ value="<?php echo esc_attr( $type_key ) ?>"
74
+ <?php selected( $type_key, $condition->conditionType ) ?>
75
+ <?php if ($type_key_value['proOnly'] && !$isPro) { ?>disabled="disabled" <?php } ?>
76
+ >
77
+ <?php echo esc_html( $type_key_value['name'] ) ?>
78
  </option>
79
  <?php } ?>
80
  </select>
81
+ <?php if (!$isPro) {
82
+ $upgrade_link =
83
+ add_query_arg( array(
84
+ 'page' => 'call-now-button-domains',
85
+ 'action' => 'upgrade',
86
+ 'id' => $cnb_domain->id
87
+ ),
88
+ admin_url( 'admin.php' ) );
89
+ ?>
90
+ <p class="description">
91
+ <a href="<?php echo esc_url( $upgrade_link ) ?>">Upgrade</a> to <span class="cnb-pro-badge">Pro</span> to unlock visitor country rules.
92
+ </p>
93
+ <?php } ?>
94
  </td>
95
  </tr>
96
  <tr>
97
+ <th scope="row"><label for="cnb_condition_match_type">Where</label></th>
98
  <td>
99
  <select id="cnb_condition_match_type"
100
  name="conditions[<?php echo esc_attr( $condition->id ) ?>][matchType]">
108
  <?php
109
  foreach ( ( new CnbAdminFunctions() )->cnb_get_condition_match_types_geo() as $condition_match_type_key => $condition_match_type_value ) { ?>
110
  <option class="conditionType conditionType_GEO" value="<?php echo esc_attr( $condition_match_type_key ) ?>"<?php selected( $condition_match_type_key, $condition->matchType ) ?>>
111
+ <?php echo esc_html( $condition_match_type_value ) ?>
112
  </option>
113
  <?php } ?>
114
 
159
  $url ) );
160
 
161
  $action_verb = $condition->id === 'new' ? 'adding' : 'editing';
162
+ $message = '<p><strong>You are ' . $action_verb . ' a display rule</strong>.
163
+ Click <a href="' . $redirect_link . '">here</a> to go back.</p>';
164
  CnbAdminNotices::get_instance()->renderInfo( $message );
165
  }
166
 
src/admin/condition/Cnb_Condition_List_Table.php CHANGED
@@ -354,12 +354,12 @@ class Cnb_Condition_List_Table extends WP_List_Table {
354
 
355
  function no_items() {
356
  if ( $this->button ) {
357
- echo '<p class="cnb_paragraph">You have no page visibility rules set up. This means that your button will show on all pages.</p>';
358
- echo '<p class="cnb_paragraph">Click the <code>Add page rule</code> button above to limit the appearance. You can freely mix and match rules to meet your requirements.</p>';
359
 
360
  return;
361
  }
362
- esc_html_e( 'No conditions found.' );
363
 
364
  }
365
  }
354
 
355
  function no_items() {
356
  if ( $this->button ) {
357
+ echo '<p class="cnb_paragraph">You have no display rules set up. This means that your button will show on all pages.</p>';
358
+ echo '<p class="cnb_paragraph">Click the <code>Add display rule</code> button above to limit the appearance. You can freely mix and match rules to meet your requirements.</p>';
359
 
360
  return;
361
  }
362
+ esc_html_e( 'No display rules found.' );
363
 
364
  }
365
  }
src/admin/deactivation/Activation.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace cnb\admin\deactivation;
4
+
5
+ use cnb\CallNowButton;
6
+
7
+ /**
8
+ * On Activation of our plugin.
9
+ */
10
+ class Activation {
11
+
12
+ /**
13
+ * This is called /during/ the activation process.
14
+ *
15
+ * It is only used to register when it was last activated,
16
+ * which is used in feedback forms.
17
+ *
18
+ * @return void
19
+ */
20
+ public static function onActivation() {
21
+ // This has to called manually, since Activation is before the `admin_init` stage!
22
+ $cnb = new CallNowButton();
23
+ $cnb->options_init();
24
+
25
+ $options = get_option('cnb');
26
+ $options['activation_time'] = time();
27
+ update_option( 'cnb', $options );
28
+ }
29
+ }
src/admin/domain/CnbDomainController.php CHANGED
@@ -319,12 +319,14 @@ class CnbDomainController {
319
  }
320
 
321
  /**
 
 
322
  * @param $plan_year CnbPlan
323
  * @param $plan_month CnbPlan
324
  *
325
- * @return float rounded to ".x", so either "12", or "12.3"
326
  */
327
  function get_discount_percentage($plan_year, $plan_month) {
328
- return round(100 - ($plan_year->price/(12*$plan_month->price)*100), 1);
329
  }
330
  }
319
  }
320
 
321
  /**
322
+ * Get the discount percentage (difference for a year between the 2 Plans).
323
+ *
324
  * @param $plan_year CnbPlan
325
  * @param $plan_month CnbPlan
326
  *
327
+ * @return float integer rounded up to "12", "16", etc.
328
  */
329
  function get_discount_percentage($plan_year, $plan_month) {
330
+ return ceil(100 - ($plan_year->price/(12*$plan_month->price)*100));
331
  }
332
  }
src/admin/domain/partials/CnbDomainViewUpgradeOverview.php CHANGED
@@ -147,13 +147,16 @@ class CnbDomainViewUpgradeOverview {
147
  ?>
148
  <div class="pricebox">
149
  <h3 class="yearly"><span class="cnb-premium-label">PRO </span>Yearly <span class="cnb-green">Save <?php echo esc_html( $annual_discount ); ?>%!</span></h3>
150
- <div class="benefit">All button branding removed</div>
 
 
 
151
  <div class="plan-amount"><span class="currency">€</span><span
152
  class="euros"><?php echo esc_html( $plan_x ) ?></span><span
153
  class="cents">.<?php echo esc_html( $plan_y ) ?></span><span class="timeframe">/month</span>
154
  </div>
155
  <div class="billingprice">
156
- Billed at €<?php echo esc_html( number_format($plan->price, 2) ) ?> annually
157
  </div>
158
  <?php $this->get_profile_edit_modal_link(
159
  'button button-primary',
@@ -171,7 +174,10 @@ class CnbDomainViewUpgradeOverview {
171
  ?>
172
  <div class="pricebox">
173
  <h3 class="monthly"><span class="cnb-premium-label">PRO </span>Monthly</h3>
174
- <div class="benefit">All button branding removed</div>
 
 
 
175
  <div class="plan-amount"><span class="currency">€</span><span
176
  class="euros"><?php echo esc_html( $plan_x ) ?></span><span
177
  class="cents">.<?php echo esc_html( $plan_y ) ?></span><span class="timeframe">/month</span>
@@ -202,13 +208,16 @@ class CnbDomainViewUpgradeOverview {
202
  ?>
203
  <div class="pricebox">
204
  <h3 class="yearly"><span class="cnb-premium-label">PRO </span>Yearly <span class="cnb-green">Save <?php echo esc_html( $annual_discount ); ?>%!</span></h3>
205
- <div class="benefit">All button branding removed</div>
 
 
 
206
  <div class="plan-amount"><span class="currency">$</span><span
207
  class="euros"><?php echo esc_html( $plan_x ) ?></span><span
208
  class="cents">.<?php echo esc_html( $plan_y ) ?></span><span class="timeframe">/month</span>
209
  </div>
210
  <div class="billingprice">
211
- Billed at $<?php echo esc_html( number_format($plan->price, 2) ) ?> annually
212
  </div>
213
  <?php $this->get_profile_edit_modal_link(
214
  'button button-primary',
@@ -225,7 +234,10 @@ class CnbDomainViewUpgradeOverview {
225
  ?>
226
  <div class="pricebox">
227
  <h3 class="monthly"><span class="cnb-premium-label">PRO </span>Monthly</h3>
228
- <div class="benefit">All button branding removed</div>
 
 
 
229
  <div class="plan-amount"><span class="currency">$</span><span
230
  class="euros"><?php echo esc_html( $plan_x ) ?></span><span
231
  class="cents">.<?php echo esc_html( $plan_y ) ?></span><span class="timeframe">/month</span>
@@ -325,7 +337,7 @@ class CnbDomainViewUpgradeOverview {
325
  array(
326
  'TB_inline' => 'true',
327
  'inlineId' => 'cnb_admin_page_domain_upgrade_profile',
328
- 'height' => '525'
329
  ),
330
  $url );
331
  printf(
147
  ?>
148
  <div class="pricebox">
149
  <h3 class="yearly"><span class="cnb-premium-label">PRO </span>Yearly <span class="cnb-green">Save <?php echo esc_html( $annual_discount ); ?>%!</span></h3>
150
+ <div class="benefit">🧰 All features from Premium</div>
151
+ <div class="benefit">✨ "Powered by" notice removed</div>
152
+ <div class="benefit">🌍 Include and exclude countries</div>
153
+ <div class="benefit">↕️ Set scroll height for buttons to appear</div>
154
  <div class="plan-amount"><span class="currency">€</span><span
155
  class="euros"><?php echo esc_html( $plan_x ) ?></span><span
156
  class="cents">.<?php echo esc_html( $plan_y ) ?></span><span class="timeframe">/month</span>
157
  </div>
158
  <div class="billingprice">
159
+ Billed annually
160
  </div>
161
  <?php $this->get_profile_edit_modal_link(
162
  'button button-primary',
174
  ?>
175
  <div class="pricebox">
176
  <h3 class="monthly"><span class="cnb-premium-label">PRO </span>Monthly</h3>
177
+ <div class="benefit">🧰 All features from Premium</div>
178
+ <div class="benefit">✨ "Powered by" notice removed</div>
179
+ <div class="benefit">🌍 Include and exclude countries</div>
180
+ <div class="benefit">↕️ Set scroll height for buttons to appear</div>
181
  <div class="plan-amount"><span class="currency">€</span><span
182
  class="euros"><?php echo esc_html( $plan_x ) ?></span><span
183
  class="cents">.<?php echo esc_html( $plan_y ) ?></span><span class="timeframe">/month</span>
208
  ?>
209
  <div class="pricebox">
210
  <h3 class="yearly"><span class="cnb-premium-label">PRO </span>Yearly <span class="cnb-green">Save <?php echo esc_html( $annual_discount ); ?>%!</span></h3>
211
+ <div class="benefit">🧰 All features from Premium</div>
212
+ <div class="benefit">✨ "Powered by" notice removed</div>
213
+ <div class="benefit">🌍 Include and exclude countries</div>
214
+ <div class="benefit">↕️ Set scroll height for buttons to appear</div>
215
  <div class="plan-amount"><span class="currency">$</span><span
216
  class="euros"><?php echo esc_html( $plan_x ) ?></span><span
217
  class="cents">.<?php echo esc_html( $plan_y ) ?></span><span class="timeframe">/month</span>
218
  </div>
219
  <div class="billingprice">
220
+ Billed annually
221
  </div>
222
  <?php $this->get_profile_edit_modal_link(
223
  'button button-primary',
234
  ?>
235
  <div class="pricebox">
236
  <h3 class="monthly"><span class="cnb-premium-label">PRO </span>Monthly</h3>
237
+ <div class="benefit">🧰 All features from Premium</div>
238
+ <div class="benefit">✨ "Powered by" notice removed</div>
239
+ <div class="benefit">🌍 Include and exclude countries</div>
240
+ <div class="benefit">↕️ Set scroll height for buttons to appear</div>
241
  <div class="plan-amount"><span class="currency">$</span><span
242
  class="euros"><?php echo esc_html( $plan_x ) ?></span><span
243
  class="cents">.<?php echo esc_html( $plan_y ) ?></span><span class="timeframe">/month</span>
337
  array(
338
  'TB_inline' => 'true',
339
  'inlineId' => 'cnb_admin_page_domain_upgrade_profile',
340
+ 'height' => '725'
341
  ),
342
  $url );
343
  printf(
src/admin/legacy/CnbLegacyEdit.php CHANGED
@@ -177,6 +177,7 @@ class CnbLegacyEdit {
177
  <div id="welcome-banner"
178
  class="welcome-banner is-dismissible notice-call-now-button"
179
  data-dismiss-url="<?php echo esc_url( $dismiss_url ) ?>">
 
180
  <div class="welcome-banner-content">
181
  <h2>Welcome to Call&nbsp;Now&nbsp;Button!</h2>
182
  <div class="welcome-banner-column-container">
177
  <div id="welcome-banner"
178
  class="welcome-banner is-dismissible notice-call-now-button"
179
  data-dismiss-url="<?php echo esc_url( $dismiss_url ) ?>">
180
+ <p id="welcome-banner-notice">🎉 Welcome to <b>Call Now Button</b>! <a class="cnb-expand-link">Click to expand...</a></p>
181
  <div class="welcome-banner-content">
182
  <h2>Welcome to Call&nbsp;Now&nbsp;Button!</h2>
183
  <div class="welcome-banner-column-container">
src/admin/settings/CnbApiKeyActivatedView.php CHANGED
@@ -110,7 +110,7 @@ class CnbApiKeyActivatedView {
110
  $timezoneSelect = ( new CnbDomainViewEdit() )->getTimezoneSelect( $domain );
111
  echo sprintf( '
112
  <div class="cnb-get-started cnb-plan-features cnb-center top-50">
113
- <h1 class="cnb-center">Let\'s get started</h1>
114
  <div class="cnb-flexbox">
115
  <div class="box">
116
  <h2>Is this your time zone?</h2>
@@ -156,7 +156,8 @@ class CnbApiKeyActivatedView {
156
  return;
157
  }
158
  echo '<div class="cnb-plan-features cnb-center top-50">';
159
- echo '<h1>Upgrade to PRO to remove the branding</h1>';
 
160
  ( new CnbDomainViewUpgradeOverview() )->renderUpgradeForm( $domain );
161
  echo '</div>';
162
  }
110
  $timezoneSelect = ( new CnbDomainViewEdit() )->getTimezoneSelect( $domain );
111
  echo sprintf( '
112
  <div class="cnb-get-started cnb-plan-features cnb-center top-50">
113
+ <h1 class="cnb-center"><strong>Let\'s get started</strong></h1><hr>
114
  <div class="cnb-flexbox">
115
  <div class="box">
116
  <h2>Is this your time zone?</h2>
156
  return;
157
  }
158
  echo '<div class="cnb-plan-features cnb-center top-50">';
159
+ echo '<h1><strong>Upgrade to PRO!</strong></h1>';
160
+ echo '<h3>🤩 All features from Premium plus more! 🤩</h3>';
161
  ( new CnbDomainViewUpgradeOverview() )->renderUpgradeForm( $domain );
162
  echo '</div>';
163
  }
src/autoload.php CHANGED
@@ -44,6 +44,7 @@ spl_autoload_register(
44
  'cnb\\admin\\condition\\cnbconditionrouter' => '/admin/condition/CnbConditionRouter.php',
45
  'cnb\\admin\\condition\\cnbconditionview' => '/admin/condition/CnbConditionView.php',
46
  'cnb\\admin\\condition\\cnbconditionviewedit' => '/admin/condition/CnbConditionViewEdit.php',
 
47
  'cnb\\admin\\deactivation\\deactivation' => '/admin/deactivation/Deactivation.php',
48
  'cnb\\admin\\domain\\cnb_domain_list_table' => '/admin/domain/Cnb_Domain_List_Table.php',
49
  'cnb\\admin\\domain\\cnbdomain' => '/admin/domain/CnbDomain.php',
44
  'cnb\\admin\\condition\\cnbconditionrouter' => '/admin/condition/CnbConditionRouter.php',
45
  'cnb\\admin\\condition\\cnbconditionview' => '/admin/condition/CnbConditionView.php',
46
  'cnb\\admin\\condition\\cnbconditionviewedit' => '/admin/condition/CnbConditionViewEdit.php',
47
+ 'cnb\\admin\\deactivation\\activation' => '/admin/deactivation/Activation.php',
48
  'cnb\\admin\\deactivation\\deactivation' => '/admin/deactivation/Deactivation.php',
49
  'cnb\\admin\\domain\\cnb_domain_list_table' => '/admin/domain/Cnb_Domain_List_Table.php',
50
  'cnb\\admin\\domain\\cnbdomain' => '/admin/domain/CnbDomain.php',
src/utils/CnbAdminFunctions.php CHANGED
@@ -70,15 +70,21 @@ class CnbAdminFunctions {
70
 
71
  function cnb_get_condition_filter_types() {
72
  return array(
73
- 'INCLUDE' => 'Include',
74
- 'EXCLUDE' => 'Exclude',
75
  );
76
  }
77
 
78
  function cnb_get_condition_types() {
79
  return array(
80
- 'URL' => 'URL',
81
- 'GEO' => 'Geofencing',
 
 
 
 
 
 
82
  );
83
  }
84
 
@@ -88,10 +94,10 @@ class CnbAdminFunctions {
88
  */
89
  function cnb_get_condition_match_types() {
90
  return array(
91
- 'SIMPLE' => 'Page path is:',
92
- 'EXACT' => 'Page URL is:',
93
- 'SUBSTRING' => 'Page URL contains:',
94
- 'REGEX' => 'Page URL matches RegEx:',
95
  );
96
  }
97
 
@@ -102,7 +108,7 @@ class CnbAdminFunctions {
102
  */
103
  function cnb_get_condition_match_types_geo() {
104
  return array(
105
- 'COUNTRY_CODE' => 'Country code is:',
106
  );
107
  }
108
 
70
 
71
  function cnb_get_condition_filter_types() {
72
  return array(
73
+ 'INCLUDE' => 'Display the button',
74
+ 'EXCLUDE' => 'Hide the button',
75
  );
76
  }
77
 
78
  function cnb_get_condition_types() {
79
  return array(
80
+ 'URL' => [
81
+ 'name' => 'Page URL',
82
+ 'proOnly' => false
83
+ ],
84
+ 'GEO' => [
85
+ 'name' => 'Visitor location',
86
+ 'proOnly' => true
87
+ ]
88
  );
89
  }
90
 
94
  */
95
  function cnb_get_condition_match_types() {
96
  return array(
97
+ 'SIMPLE' => 'Page path is',
98
+ 'EXACT' => 'Page URL is',
99
+ 'SUBSTRING' => 'Page URL contains',
100
+ 'REGEX' => 'Page URL matches RegEx',
101
  );
102
  }
103
 
108
  */
109
  function cnb_get_condition_match_types_geo() {
110
  return array(
111
+ 'COUNTRY_CODE' => 'Country code is',
112
  );
113
  }
114