PluginProbe ʕ •ᴥ•ʔ
The Post Grid – Shortcode, Gutenberg Blocks and Elementor Addon for Post Grid / 5.0.3
The Post Grid – Shortcode, Gutenberg Blocks and Elementor Addon for Post Grid v5.0.3
7.9.3 7.9.2 trunk 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 4.2.0 4.2.1 4.2.2 4.2.3 5.0.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 6.0.0 7.0.0 7.0.1 7.0.2 7.1.0 7.2.0 7.2.1 7.2.10 7.2.11 7.2.2 7.2.3 7.2.4 7.2.5 7.2.6 7.2.7 7.2.8 7.2.9 7.3.0 7.3.1 7.4.0 7.4.1 7.4.2 7.4.3 7.5.0 7.6.0 7.6.1 7.7.0 7.7.1 7.7.10 7.7.11 7.7.12 7.7.13 7.7.14 7.7.15 7.7.16 7.7.17 7.7.18 7.7.19 7.7.2 7.7.20 7.7.21 7.7.22 7.7.3 7.7.4 7.7.5 7.7.6 7.7.7 7.7.8 7.7.9 7.8.0 7.8.1 7.8.2 7.8.3 7.8.4 7.8.5 7.8.6 7.8.7 7.8.8 7.8.9 7.9.0 7.9.1
the-post-grid / app / Controllers / Admin / NoticeController.php
the-post-grid / app / Controllers / Admin Last commit date
AdminAjaxController.php 3 years ago MetaController.php 3 years ago NoticeController.php 3 years ago PostTypeController.php 3 years ago SettingsController.php 3 years ago UpgradeController.php 3 years ago
NoticeController.php
445 lines
1 <?php
2 /**
3 * Notice Controller class.
4 *
5 * @package RT_TPG
6 */
7
8 namespace RT\ThePostGrid\Controllers\Admin;
9
10 // Do not allow directly accessing this file.
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit( 'This script cannot be accessed directly.' );
13 }
14
15 /**
16 * Notice Controller class.
17 */
18 class NoticeController {
19 /**
20 * Class Constructor
21 */
22 public function __construct() {
23 $current = time();
24 $black_friday = mktime( 0, 0, 0, 11, 18, 2022 ) <= $current && $current <= mktime( 0, 0, 0, 1, 6, 2023 );
25
26 if ( $black_friday ) {
27 add_action( 'admin_init', [ $this, 'black_friday_notice' ] );
28 }
29
30 register_activation_hook( RT_THE_POST_GRID_PLUGIN_ACTIVE_FILE_NAME, [ $this, 'rttpg_activation_time' ] );
31 add_action( 'admin_init', [ $this, 'rttpg_check_installation_time' ] );
32 add_action( 'admin_init', [ __CLASS__, 'rttpg_spare_me' ], 5 );
33
34 add_action( 'admin_init', [ __CLASS__, 'rttpg_notice' ] );
35 add_filter( 'post_row_actions', [ $this, 'filter_post_row_actions' ], 11, 2 );
36 add_filter( 'page_row_actions', [ $this, 'filter_post_row_actions' ], 11, 2 );
37
38 }
39
40 public function filter_post_row_actions( $actions, $post ) {
41
42 // return $post->ID;
43 return $actions;
44 }
45
46 /**
47 * Notice
48 *
49 * @return void
50 */
51 public static function rttpg_notice() {
52 add_action(
53 'admin_notices',
54 function () {
55 $settings = get_option( 'rt_the_post_grid_settings' );
56 $screen = get_current_screen();
57
58 if ( isset( $settings['tpg_block_type'] ) ) {
59 if ( in_array( $screen->id, [
60 'edit-rttpg',
61 'rttpg'
62 ], true ) && 'elementor' === $settings['tpg_block_type'] ) { ?>
63 <div class="notice notice-for-warning">
64 <p>
65 <?php
66 echo sprintf(
67 '%1$s<a style="color: #fff;" href="%2$s">%3$s</a>',
68 esc_html__( 'You have selected only Elementor method. To use Shortcode Generator please enable shortcode or default from ', 'the-post-grid' ),
69 esc_url( admin_url( 'edit.php?post_type=rttpg&page=rttpg_settings' ) ),
70 esc_html__( 'Settings => Common Settings => Resource Load Type', 'the-post-grid' )
71 );
72 ?>
73 </p>
74 </div>
75 <?php
76 }
77
78 if ( 'edit-tpg_builder' === $screen->id && 'shortcode' === $settings['tpg_block_type'] ) {
79 ?>
80 <div class="notice notice-for-warning">
81 <p>
82 <?php
83 echo sprintf(
84 '%1$s<a style="color: #fff;" href="%2$s">%3$s</a>',
85 esc_html__( 'You have selected only Shortcode Generator method. To use Elementor please enable Elementor or default from ', 'the-post-grid' ),
86 esc_url( admin_url( 'edit.php?post_type=rttpg&page=rttpg_settings&section=common-settings' ) ),
87 esc_html__( 'Settings => Common Settings => Resource Load Type', 'the-post-grid' )
88 );
89 ?>
90 </p>
91 </div>
92 <?php
93 }
94 }
95 }
96 );
97 }
98
99 /**
100 * Black friday notice.
101 *
102 * @return void
103 */
104 public static function black_friday_notice() {
105 if ( get_option( 'rttpg_bf_2023' ) != '1' ) {
106 self::notice();
107 }
108 }
109
110 /**
111 * Black friday notice.
112 *
113 * @return void
114 */
115 public static function notice() {
116 add_action(
117 'admin_enqueue_scripts',
118 function () {
119 wp_enqueue_script( 'jquery' );
120 }
121 );
122
123 add_action(
124 'admin_notices',
125 function () {
126 $plugin_name = 'The Post Grid';
127 $download_link = 'https://www.radiustheme.com/downloads/the-post-grid-pro-for-wordpress/'; ?>
128 <div class="notice notice-info is-dismissible" data-rttpg-dismissable="rttpg_bf_2022"
129 style="display:grid;grid-template-columns: 100px auto;padding-top: 25px; padding-bottom: 22px;">
130 <img alt="<?php echo esc_attr( $plugin_name ); ?>"
131 src="<?php echo esc_url( rtTPG()->get_assets_uri( 'images/post-grid-gif.gif' ) ); ?>"
132 width="74px" height="74px" style="grid-row: 1 / 4; align-self: center;justify-self: center"/>
133 <h3 style="margin:0;"><?php echo sprintf( '%s Cyber Week Deal!!', esc_html( $plugin_name ) ); ?></h3>
134 <p style="margin:0 0 2px;">Don't miss out on our biggest sale of the year! Get your
135 <b><?php echo esc_html( $plugin_name ); ?> plan</b> with <b>UPTO 50% OFF</b>! Limited time offer!!!</p>
136 <p style="margin:0;">
137 <a class="button button-primary" href="<?php echo esc_url( $download_link ); ?>"
138 target="_blank">Buy Now</a>
139 <a class="button button-dismiss" href="#">Dismiss</a>
140 </p>
141 </div>
142 <?php
143 }
144 );
145
146 add_action(
147 'admin_footer',
148 function () {
149 ?>
150 <script type="text/javascript">
151 (function ($) {
152 $(function () {
153 setTimeout(function () {
154 $('div[data-rttpg-dismissable] .notice-dismiss, div[data-rttpg-dismissable] .button-dismiss')
155 .on('click', function (e) {
156 e.preventDefault();
157 $.post(ajaxurl, {
158 'action': 'rttpg_dismiss_admin_notice',
159 'nonce': <?php echo wp_json_encode( wp_create_nonce( 'rttpg-dismissible-notice' ) ); ?>
160 });
161 $(e.target).closest('.is-dismissible').remove();
162 });
163 }, 1000);
164 });
165 })(jQuery);
166 </script>
167 <?php
168 }
169 );
170
171 add_action(
172 'wp_ajax_rttpg_dismiss_admin_notice',
173 function () {
174 check_ajax_referer( 'rttpg-dismissible-notice', 'nonce' );
175
176 update_option( 'rttpg_bf_2022', '1' );
177 wp_die();
178 }
179 );
180 }
181
182 /**
183 * Plugin activation time
184 *
185 * @return void
186 */
187 public static function rttpg_activation_time() {
188 $get_activation_time = strtotime( "now" );
189 add_option( 'rttpg_plugin_activation_time', $get_activation_time );
190 }
191
192 /**
193 * Check if review notice should be shown or not
194 *
195 * @return void
196 */
197 public static function rttpg_check_installation_time() {
198 // Added Lines Start.
199 $nobug = get_option( 'rttpg_spare_me', '0' );
200
201 if ( $nobug == '1' || $nobug == '3' ) {
202 return;
203 }
204
205 $install_date = get_option( 'rttpg_plugin_activation_time' );
206 $past_date = strtotime( '-10 days' );
207
208 $remind_time = get_option( 'rttpg_remind_me' );
209 $remind_due = strtotime( '+15 days', $remind_time );
210 $now = strtotime( 'now' );
211
212 if ( $now >= $remind_due ) {
213 add_action( 'admin_notices', [ __CLASS__, 'rttpg_display_admin_notice' ] );
214 } else if ( ( $past_date >= $install_date ) && '2' !== $nobug ) {
215 add_action( 'admin_notices', [ __CLASS__, 'rttpg_display_admin_notice' ] );
216 }
217 }
218
219 /**
220 * Display Admin Notice, asking for a review
221 *
222 * @return void
223 */
224 public static function rttpg_display_admin_notice() {
225 global $pagenow;
226
227 $exclude = [
228 'themes.php',
229 'users.php',
230 'tools.php',
231 'options-general.php',
232 'options-writing.php',
233 'options-reading.php',
234 'options-discussion.php',
235 'options-media.php',
236 'options-permalink.php',
237 'options-privacy.php',
238 'edit-comments.php',
239 'upload.php',
240 'media-new.php',
241 'admin.php',
242 'import.php',
243 'export.php',
244 'site-health.php',
245 'export-personal-data.php',
246 'erase-personal-data.php',
247 ];
248
249 if ( ! in_array( $pagenow, $exclude ) ) {
250 $dont_disturb = add_query_arg( 'rttpg_spare_me', '1', self::rttpg_current_admin_url() );
251 $remind_me = add_query_arg( 'rttpg_remind_me', '1', self::rttpg_current_admin_url() );
252 $rated = add_query_arg( 'rttpg_rated', '1', self::rttpg_current_admin_url() );
253 $reviewurl = 'https://wordpress.org/support/plugin/the-post-grid/reviews/?filter=5#new-post';
254
255 printf(
256 '<div class="notice rttpg-review-notice rttpg-review-notice--extended">
257 <div class="rttpg-review-notice_content">
258 <h3>%1$s</h3>
259 <p>%2$s</p>
260 <div class="rttpg-review-notice_actions">
261 <a href="%3$s" class="rttpg-review-button rttpg-review-button--cta" target="_blank"><span>⭐ Yes, You Deserve It!</span></a>
262 <a href="%4$s" class="rttpg-review-button rttpg-review-button--cta rttpg-review-button--outline"><span>😀 Already Rated!</span></a>
263 <a href="%5$s" class="rttpg-review-button rttpg-review-button--cta rttpg-review-button--outline"><span>🔔 Remind Me Later</span></a>
264 <a href="%6$s" class="rttpg-review-button rttpg-review-button--cta rttpg-review-button--error rttpg-review-button--outline"><span>😐 No Thanks</span></a>
265 </div>
266 </div>
267 </div>',
268 esc_html__( 'Enjoying The Post Grid?', 'the-post-grid' ),
269 esc_html__( 'Thank you for choosing The Post Grid. If you have found our plugin useful and makes you smile, please consider giving us a 5-star rating on WordPress.org. It will help us to grow.', 'the-post-grid' ),
270 esc_url( $reviewurl ),
271 esc_url( $rated ),
272 esc_url( $remind_me ),
273 esc_url( $dont_disturb )
274 );
275
276 echo '<style>
277 .rttpg-review-button--cta {
278 --e-button-context-color: #4C6FFF;
279 --e-button-context-color-dark: #4C6FFF;
280 --e-button-context-tint: rgb(75 47 157/4%);
281 --e-focus-color: rgb(75 47 157/40%);
282 }
283 .rttpg-review-notice {
284 position: relative;
285 margin: 5px 20px 5px 2px;
286 border: 1px solid #ccd0d4;
287 background: #fff;
288 box-shadow: 0 1px 4px rgba(0,0,0,0.15);
289 font-family: Roboto, Arial, Helvetica, Verdana, sans-serif;
290 border-inline-start-width: 4px;
291 }
292 .rttpg-review-notice.notice {
293 padding: 0;
294 }
295 .rttpg-review-notice:before {
296 position: absolute;
297 top: -1px;
298 bottom: -1px;
299 left: -4px;
300 display: block;
301 width: 4px;
302 background: -webkit-linear-gradient(bottom, #4C6FFF 0%, #6939c6 100%);
303 background: linear-gradient(0deg, #4C6FFF 0%, #6939c6 100%);
304 content: "";
305 }
306 .rttpg-review-notice_content {
307 padding: 20px;
308 }
309 .rttpg-review-notice_actions > * + * {
310 margin-inline-start: 8px;
311 -webkit-margin-start: 8px;
312 -moz-margin-start: 8px;
313 }
314 .rttpg-review-notice p {
315 margin: 0;
316 padding: 0;
317 line-height: 1.5;
318 }
319 p + .rttpg-review-notice_actions {
320 margin-top: 1rem;
321 }
322 .rttpg-review-notice h3 {
323 margin: 0;
324 font-size: 1.0625rem;
325 line-height: 1.2;
326 }
327 .rttpg-review-notice h3 + p {
328 margin-top: 8px;
329 }
330 .rttpg-review-button {
331 display: inline-block;
332 padding: 0.4375rem 0.75rem;
333 border: 0;
334 border-radius: 3px;;
335 background: var(--e-button-context-color);
336 color: #fff;
337 vertical-align: middle;
338 text-align: center;
339 text-decoration: none;
340 white-space: nowrap;
341 }
342 .rttpg-review-button:active {
343 background: var(--e-button-context-color-dark);
344 color: #fff;
345 text-decoration: none;
346 }
347 .rttpg-review-button:focus {
348 outline: 0;
349 background: var(--e-button-context-color-dark);
350 box-shadow: 0 0 0 2px var(--e-focus-color);
351 color: #fff;
352 text-decoration: none;
353 }
354 .rttpg-review-button:hover {
355 background: var(--e-button-context-color-dark);
356 color: #fff;
357 text-decoration: none;
358 }
359 .rttpg-review-button.focus {
360 outline: 0;
361 box-shadow: 0 0 0 2px var(--e-focus-color);
362 }
363 .rttpg-review-button--error {
364 --e-button-context-color: #d72b3f;
365 --e-button-context-color-dark: #ae2131;
366 --e-button-context-tint: rgba(215,43,63,0.04);
367 --e-focus-color: rgba(215,43,63,0.4);
368 }
369 .rttpg-review-button.rttpg-review-button--outline {
370 border: 1px solid;
371 background: 0 0;
372 color: var(--e-button-context-color);
373 }
374 .rttpg-review-button.rttpg-review-button--outline:focus {
375 background: var(--e-button-context-tint);
376 color: var(--e-button-context-color-dark);
377 }
378 .rttpg-review-button.rttpg-review-button--outline:hover {
379 background: var(--e-button-context-tint);
380 color: var(--e-button-context-color-dark);
381 }
382 </style>';
383 }
384 }
385
386 /**
387 * Current admin URL.
388 *
389 * @return string
390 */
391 protected static function rttpg_current_admin_url() {
392 $uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
393 $uri = preg_replace( '|^.*/wp-admin/|i', '', $uri );
394
395 if ( ! $uri ) {
396 return '';
397 }
398
399 return remove_query_arg(
400 [
401 '_wpnonce',
402 '_wc_notice_nonce',
403 'wc_db_update',
404 'wc_db_update_nonce',
405 'wc-hide-notice'
406 ],
407 admin_url( $uri )
408 );
409 }
410
411 /**
412 * Remove the notice for the user if review already done
413 *
414 * @return void
415 */
416 public static function rttpg_spare_me() {
417 if ( isset( $_GET['rttpg_spare_me'] ) && ! empty( $_GET['rttpg_spare_me'] ) ) {
418 $spare_me = absint( $_GET['rttpg_spare_me'] );
419
420 if ( 1 == $spare_me ) {
421 update_option( 'rttpg_spare_me', '1' );
422 }
423 }
424
425 if ( isset( $_GET['rttpg_remind_me'] ) && ! empty( $_GET['rttpg_remind_me'] ) ) {
426 $remind_me = absint( $_GET['rttpg_remind_me'] );
427
428 if ( 1 == $remind_me ) {
429 $get_activation_time = strtotime( 'now' );
430
431 update_option( 'rttpg_remind_me', $get_activation_time );
432 update_option( 'rttpg_spare_me', '2' );
433 }
434 }
435
436 if ( isset( $_GET['rttpg_rated'] ) && ! empty( $_GET['rttpg_rated'] ) ) {
437 $rttpg_rated = absint( $_GET['rttpg_rated'] );
438
439 if ( 1 == $rttpg_rated ) {
440 update_option( 'rttpg_rated', 'yes' );
441 update_option( 'rttpg_spare_me', '3' );
442 }
443 }
444 }
445 }