PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / trunk
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites vtrunk
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
← All changes | admin/notice-upgrade.php +155 -160 2.6.1trunk View file →
@@ -1,138 +1,51 @@
1 1 <?php
2 2 // Exit if accessed directly.
3 3 defined( 'ABSPATH' ) || exit;
4 4
5 +class Blockspare_Upgrade_Notice extends Blockspare_Setup {
5 6
6 -// Exit if accessed directly.
7 -defined('ABSPATH') || exit;
8 -
9 -class Blockspare_Notice
10 -{
11 - public $name;
12 - public $type;
13 - public $dismiss_url;
14 - public $temporary_dismiss_url;
15 - public $pricing_url;
16 - public $current_user_id;
17 -
18 7 /**
19 - * The constructor.
20 - *
21 - * @param string $name Notice Name.
22 - * @param string $type Notice type.
23 - * @param string $dismiss_url Notice permanent dismiss URL.
24 - * @param string $temporary_dismiss_url Notice temporary dismiss URL.
25 - *
26 - * @since 1.4.7
27 - *
8 + * Constructor.
28 9 */
29 - public function __construct($name, $type, $dismiss_url, $temporary_dismiss_url)
30 - {
31 - $this->name = $name;
32 - $this->type = $type;
33 - $this->dismiss_url = $dismiss_url;
34 - $this->temporary_dismiss_url = $temporary_dismiss_url;
35 - $this->pricing_url = 'https://www.blockspare.com/pricing/';
36 - $this->current_user_id = get_current_user_id();
37 -
38 - // Notice markup.
39 - add_action('admin_notices', array($this, 'notice'));
40 -
41 - $this->dismiss_notice();
42 - $this->dismiss_notice_temporary();
43 - }
44 -
45 - public function notice()
46 - {
47 - if (!$this->is_dismiss_notice()) {
48 - $this->notice_markup();
49 - }
50 - }
51 -
52 - private function is_dismiss_notice()
53 - {
54 - return apply_filters('blockspare_' . $this->name . '_notice_dismiss', true);
55 - }
56 -
57 - public function notice_markup()
58 - {
59 - echo '';
60 - }
61 -
62 - /**
63 - * Hide a notice if the GET variable is set.
64 - */
65 - public function dismiss_notice()
66 - {
67 - if (isset($_GET['blockspare_notice_dismiss']) && isset($_GET['_blockspare_upgrade_notice_dismiss_nonce'])) { // WPCS: input var ok.
68 - if (!wp_verify_nonce(wp_unslash($_GET['_blockspare_upgrade_notice_dismiss_nonce']), 'blockspare_upgrade_notice_dismiss_nonce')) { // phpcs:ignore WordPress.VIP.ValidatedSanitizedInput.InputNotSanitized
69 - wp_die(__('Action failed. Please refresh the page and retry.', 'blockspare')); // WPCS: xss ok.
70 - }
71 -
72 - if (!current_user_can('publish_posts')) {
73 - wp_die(__('Cheatin&#8217; huh?', 'blockspare')); // WPCS: xss ok.
74 - }
75 -
76 - $dismiss_notice = sanitize_text_field(wp_unslash($_GET['blockspare_notice_dismiss']));
77 -
78 - // Hide.
79 - if ($dismiss_notice === $_GET['blockspare_notice_dismiss']) {
80 - add_user_meta(get_current_user_id(), 'blockspare_' . $dismiss_notice . '_notice_dismiss', 'yes', true);
81 - }
82 - }
83 - }
84 -
85 - public function dismiss_notice_temporary()
86 - {
87 - if (isset($_GET['blockspare_notice_dismiss_temporary']) && isset($_GET['_blockspare_upgrade_notice_dismiss_temporary_nonce'])) { // WPCS: input var ok.
88 - if (!wp_verify_nonce(wp_unslash($_GET['_blockspare_upgrade_notice_dismiss_temporary_nonce']), 'blockspare_upgrade_notice_dismiss_temporary_nonce')) { // phpcs:ignore WordPress.VIP.ValidatedSanitizedInput.InputNotSanitized
89 - wp_die(__('Action failed. Please refresh the page and retry.', 'blockspare')); // WPCS: xss ok.
90 - }
91 -
92 - if (!current_user_can('publish_posts')) {
93 - wp_die(__('Cheatin&#8217; huh?', 'blockspare')); // WPCS: xss ok.
94 - }
95 -
96 - $dismiss_notice = sanitize_text_field(wp_unslash($_GET['blockspare_notice_dismiss_temporary']));
97 -
98 - // Hide.
99 - if ($dismiss_notice === $_GET['blockspare_notice_dismiss_temporary']) {
100 - add_user_meta(get_current_user_id(), 'blockspare_' . $dismiss_notice . '_notice_dismiss_temporary', 'yes', true);
101 - }
102 - }
103 - }
104 -}
105 -
106 -
107 -class Blockspare_Upgrade_Notice extends Blockspare_Notice {
108 -
109 10 public function __construct() {
110 - if ( ! current_user_can( 'publish_posts' ) ) {
111 - return;
112 - }
113 11
12 + // FIX: Replaced 'blockspare_notice_dismiss' with 'blockspare_setup_notice_dismiss' to match parent architecture
114 13 $dismiss_url = wp_nonce_url(
115 - add_query_arg( 'blockspare_notice_dismiss', 'upgrade', admin_url() ),
14 + add_query_arg(
15 + 'blockspare_setup_notice_dismiss',
16 + 'upgrade',
17 + admin_url()
18 + ),
116 19 'blockspare_upgrade_notice_dismiss_nonce',
117 20 '_blockspare_upgrade_notice_dismiss_nonce'
118 21 );
119 22
120 23 $temporary_dismiss_url = wp_nonce_url(
121 - add_query_arg( 'blockspare_notice_dismiss_temporary', 'upgrade', admin_url() ),
24 + add_query_arg(
25 + 'blockspare_setup_notice_dismiss_temporary',
26 + 'upgrade',
27 + admin_url()
28 + ),
122 29 'blockspare_upgrade_notice_dismiss_temporary_nonce',
123 30 '_blockspare_upgrade_notice_dismiss_temporary_nonce'
124 31 );
125 32
126 - parent::__construct( 'upgrade', 'info', $dismiss_url, $temporary_dismiss_url );
33 + parent::__construct(
34 + 'upgrade',
35 + 'info',
36 + $dismiss_url,
37 + $temporary_dismiss_url
38 + );
127 39
128 40 $this->set_notice_time();
129 -
130 41 $this->set_temporary_dismiss_notice_time();
131 -
132 42 $this->set_dismiss_notice();
133 43 }
134 44
45 + /**
46 + * Set initial notice time.
47 + */
135 48 private function set_notice_time() {
136 49 if ( ! get_option( 'blockspare_upgrade_notice_start_time' ) ) {
137 50 update_option( 'blockspare_upgrade_notice_start_time', time() );
138 51 }
@@ -137,27 +50,38 @@
137 50 update_option( 'blockspare_upgrade_notice_start_time', time() );
138 51 }
139 52 }
140 53
54 + /**
55 + * Set temporary dismiss time.
56 + */
141 57 private function set_temporary_dismiss_notice_time() {
142 - if ( isset( $_GET['blockspare_notice_dismiss_temporary'] ) && 'upgrade' === $_GET['blockspare_notice_dismiss_temporary'] ) {
143 - update_user_meta( $this->current_user_id, 'blockspare_upgrade_notice_dismiss_temporary_start_time', time() );
58 + // FIX: Aligned parameter string check with parent class
59 + if (
60 + isset( $_GET['blockspare_setup_notice_dismiss_temporary'] ) &&
61 + 'upgrade' === $_GET['blockspare_setup_notice_dismiss_temporary']
62 + ) {
63 + update_user_meta(
64 + $this->current_user_id,
65 + 'blockspare_upgrade_notice_dismiss_temporary_start_time',
66 + time()
67 + );
144 68 }
145 69 }
146 70
71 + /**
72 + * Set dismiss conditions.
73 + */
147 74 public function set_dismiss_notice() {
75 + $user_id = get_current_user_id();
148 76
149 - /**
150 - * Do not show notice if:
151 - *
152 - * 1. It has not been 5 days since the plugin is activated.
153 - * 2. If the user has ignored the message partially for 2 days.
154 - * 3. Dismiss always if clicked on 'Dismiss' button.
155 - */
156 - if ( get_option( 'blockspare_upgrade_notice_start_time' ) > strtotime( '-2 days' )
157 - || get_user_meta( get_current_user_id(), 'blockspare_upgrade_notice_dismiss', true )
158 - || get_user_meta( get_current_user_id(), 'blockspare_upgrade_notice_dismiss_temporary_start_time', true ) > strtotime( '-2 days' )
159 - ) {
77 + $is_permanently_dismissed = ( 'yes' === get_user_meta( $user_id, 'blockspare_upgrade_notice_dismiss', true ) );
78 +
79 + $temporary_dismiss_time = (int) get_user_meta( $user_id, 'blockspare_upgrade_notice_dismiss_temporary_start_time', true );
80 + $is_temporarily_dismissed = ( $temporary_dismiss_time > strtotime( '-2 days' ) );
81 +
82 + // FIX: Evaluates user meta correctly without loops or instant expiration loops
83 + if ( $is_permanently_dismissed || $is_temporarily_dismissed ) {
160 84 add_filter( 'blockspare_upgrade_notice_dismiss', '__return_true' );
161 85 } else {
162 86 add_filter( 'blockspare_upgrade_notice_dismiss', '__return_false' );
163 87 }
@@ -162,56 +86,127 @@
162 86 add_filter( 'blockspare_upgrade_notice_dismiss', '__return_false' );
163 87 }
164 88 }
165 89
90 + /**
91 + * Notice markup.
92 + */
166 93 public function notice_markup() {
167 94 ?>
168 - <div class="notice notice-success blockspare-notice" >
169 - <a class="blockspare-notice-dismiss notice-dismiss" href="<?php echo esc_url( $this->dismiss_url ); ?>"></a>
170 - <span class="blockspare-icon-display"></span>
171 -
172 - <?php
173 - $current_user = wp_get_current_user();
95 + <div class="notice notice-info blockspare-notice-upgrade" style="padding:24px; position:relative; border-left:4px solid #2271b1; background:#fff;">
174 96
175 - printf(
176 - /* Translators: %1$s current user display name., %2$s this plugin name., %3$s discount coupon code., %4$s discount percentage. */
177 - esc_html__(
178 - '%1$s %7$s We would appreciate it if you can %4$sgive us a 5 star rating on WordPress.org%5$s! By spreading the love, we will continue to create thrilling new features for free in the future! %6$sYou may always upgrade to %3$s to gain access to premium templates, sections and blocks. Enjoy! %8$s',
179 - 'blockspare'
180 - ),
181 - '<h2>Hello ' . esc_html( $current_user->display_name ) . ', you are awesome for using Blockspare!</h2>',
182 - '<p class="notice-text"><strong>Blockspare</strong>',
183 - '<strong><a target="_blank" href="https://www.blockspare.com/pricing/">Blockspare Pro</a></strong>',
184 - '<strong><a href="https://wordpress.org/support/plugin/blockspare/reviews/?filter=5#new-post" target="_blank">',
185 - '</a></strong>',
186 - '<br>',
187 - '<p>',
188 - '</p>',
189 - );
190 - ?>
191 - </p>
97 + <div style="display:flex; justify-content:space-between; gap:28px; align-items:flex-start; flex-wrap:wrap;">
192 98
193 - <div class="links">
194 - <a href="https://wordpress.org/support/plugin/blockspare/reviews/?filter=5#new-post" class="button button-primary" target="_blank">
195 - <span><?php esc_html_e( 'Sure thing', 'blockspare' ); ?></span>
196 - </a>
99 + <div style="flex:1; min-width:300px;">
197 100
198 - <a href="<?php echo esc_url( $this->pricing_url ); ?>" class="button button-secondary" target="_blank">
199 - <span><?php esc_html_e( 'Upgrade', 'blockspare' ); ?></span>
200 - </a>
101 + <div style="display:inline-block; background:#e8f2ff; color:#2271b1; padding:4px 10px; border-radius:30px; font-size:12px; font-weight:600; margin-bottom:14px;">
102 + <?php esc_html_e( 'Upgrade Available', 'blockspare' ); ?>
103 + </div>
201 104
202 - <a href="<?php echo esc_url( $this->temporary_dismiss_url ); ?>" class="button button-secondary plain">
105 + <h2 style="margin:0 0 12px; font-size:24px; line-height:1.4; font-weight:700;">
106 + <?php esc_html_e( 'Unlock More Power with Blockspare Pro', 'blockspare' ); ?>
107 + </h2>
203 108
204 - <span><?php esc_html_e( 'Maybe later', 'blockspare' ); ?></span>
205 - </a>
109 + <p style="margin:0 0 16px; font-size:14px; color:#555; max-width:920px; line-height:1.8;">
110 + <?php esc_html_e( 'Get access to premium templates, advanced post layouts, extra design blocks, and more control over how your content looks. Blockspare Pro helps you build faster and create richer pages with less effort.', 'blockspare' ); ?>
111 + </p>
206 112
207 - <a href="https://afthemes.com/supports/" class="button button-secondary plain" target="_blank">
113 + <div style="display:flex; flex-wrap:wrap; gap:8px; margin-bottom:18px;">
208 114
209 - <span><?php esc_html_e( 'Need help?', 'blockspare' ); ?></span>
210 - </a>
115 + <span style="background:#f6f7f7; padding:7px 12px; border-radius:5px; font-size:12px;">
116 + <?php esc_html_e( 'Premium Templates', 'blockspare' ); ?>
117 + </span>
118 +
119 + <span style="background:#f6f7f7; padding:7px 12px; border-radius:5px; font-size:12px;">
120 + <?php esc_html_e( 'Advanced Post Layouts', 'blockspare' ); ?>
121 + </span>
122 +
123 + <span style="background:#f6f7f7; padding:7px 12px; border-radius:5px; font-size:12px;">
124 + <?php esc_html_e( 'More Blocks & Sections', 'blockspare' ); ?>
125 + </span>
126 +
127 + <span style="background:#f6f7f7; padding:7px 12px; border-radius:5px; font-size:12px;">
128 + <?php esc_html_e( 'Extra Design Controls', 'blockspare' ); ?>
129 + </span>
130 +
131 + <span style="background:#f6f7f7; padding:7px 12px; border-radius:5px; font-size:12px;">
132 + <?php esc_html_e( 'Faster Website Building', 'blockspare' ); ?>
133 + </span>
134 +
135 + </div>
136 +
137 + <div style="display:flex; flex-wrap:wrap; gap:10px; align-items:center;">
138 +
139 + <a
140 + class="button button-primary"
141 + href="<?php echo esc_url( $this->pricing_url ); ?>"
142 + target="_blank"
143 + rel="noopener noreferrer"
144 + >
145 + <?php esc_html_e( 'Upgrade to Pro', 'blockspare' ); ?>
146 + </a>
147 +
148 + <a
149 + class="button"
150 + href="<?php echo esc_url( 'https://www.blockspare.com/' ); ?>"
151 + target="_blank"
152 + rel="noopener noreferrer"
153 + >
154 + <?php esc_html_e( 'View Features', 'blockspare' ); ?>
155 + </a>
156 +
157 + <a
158 + class="button button-secondary plain"
159 + href="<?php echo esc_url( $this->temporary_dismiss_url ); ?>"
160 + >
161 + <?php esc_html_e( 'Maybe later', 'blockspare' ); ?>
162 + </a>
163 +
164 + <a
165 + class="button button-secondary plain"
166 + href="<?php echo esc_url( 'https://afthemes.com/supports/' ); ?>"
167 + target="_blank"
168 + rel="noopener noreferrer"
169 + >
170 + <?php esc_html_e( 'Need help?', 'blockspare' ); ?>
171 + </a>
172 +
173 + </div>
174 +
175 + </div>
176 +
177 + <div style="width:240px; background:#f8fbff; border:1px solid #dcdcde; border-radius:12px; padding:18px;">
178 +
179 + <div style="font-size:13px; font-weight:600; color:#2271b1; margin-bottom:12px;">
180 + <?php esc_html_e( 'Why upgrade?', 'blockspare' ); ?>
181 + </div>
182 +
183 + <ul style="margin:0; padding-left:18px; color:#555; line-height:1.8; font-size:13px;">
184 + <li><?php esc_html_e( 'Access premium layouts and demos', 'blockspare' ); ?></li>
185 + <li><?php esc_html_e( 'Create richer post displays', 'blockspare' ); ?></li>
186 + <li><?php esc_html_e( 'Get more design flexibility', 'blockspare' ); ?></li>
187 + <li><?php esc_html_e( 'Build pages faster with less effort', 'blockspare' ); ?></li>
188 + </ul>
189 +
190 + </div>
191 +
211 192 </div>
212 - </div> <!-- /blockspare-notice -->
193 +
194 + <a class="blockspare-notice-dismiss notice-dismiss" href="<?php echo esc_url( $this->dismiss_url ); ?>"></a>
195 + </div>
213 196 <?php
214 197 }
215 198 }
216 199
217 -new Blockspare_Upgrade_Notice();
200 +/**
201 + * Initialize notice.
202 + */
203 +function blockspare_upgrade_notice_init() {
204 +
205 + if ( ! is_admin() ) {
206 + return;
207 + }
208 +
209 + new Blockspare_Upgrade_Notice();
210 +}
211 +
212 +add_action( 'admin_init', 'blockspare_upgrade_notice_init' );