PluginProbe ʕ •ᴥ•ʔ
The Post Grid – Shortcode, Gutenberg Blocks and Elementor Addon for Post Grid / 7.8.8
The Post Grid – Shortcode, Gutenberg Blocks and Elementor Addon for Post Grid v7.8.8
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 / Notice / BlackFriday.php
the-post-grid / app / Controllers / Admin / Notice Last commit date
BlackFriday.php 8 months ago EidSpecial.php 8 months ago LoadResourceType.php 8 months ago Review.php 8 months ago SummerSale.php 8 months ago
BlackFriday.php
103 lines
1 <?php
2 /**
3 * Notice Controller class.
4 *
5 * @package RT_TPG
6 */
7
8 namespace RT\ThePostGrid\Controllers\Admin\Notice;
9
10 // Do not allow directly accessing this file.
11 use RT\ThePostGrid\Helpers\Fns;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit( 'This script cannot be accessed directly.' );
15 }
16
17 /**
18 * Notice Controller class.
19 */
20 class BlackFriday {
21
22 /**
23 * Black friday notice.
24 *
25 * @return void
26 */
27 public function __construct() {
28 if ( ! Fns::is_black_friday_active() ) {
29 return;
30 }
31 add_action( 'admin_notices', [ __CLASS__, 'render_notice' ], 1 );
32 add_action( 'admin_footer', [ __CLASS__, 'admin_footer_scripts' ] );
33 add_action( 'wp_ajax_rttpg_dismiss_black_friday_notice', [ __CLASS__, 'dismiss_black_friday_notice' ] );
34 }
35
36 /**
37 * Black friday notice.
38 *
39 * @return void
40 */
41 public static function render_notice() {
42 $plugin_name = 'The Post Grid';
43 $download_link = 'https://www.radiustheme.com/downloads/the-post-grid-pro-for-wordpress/';
44 ?>
45 <div class="notice notice-info is-dismissible tpg-black-friday-notice" data-rttpg-dismissable="rttpg_dismiss_bf_notice" \
46 style="padding: 0!important;"
47 >
48 <a href="<?php echo esc_url( $download_link ) ?>" style="display: block" target="_blank">
49 <img alt="<?php echo esc_attr( $plugin_name ); ?>"
50 style="width: 100%;display: block;min-height: 30px;object-fit: cover"
51 src="<?php echo esc_url( rtTPG()->get_assets_uri( 'images/offer/black-friday.webp' ) ); ?>"/>
52 </a>
53 </div>
54 <?php
55 }
56
57 public static function admin_footer_scripts() {
58 ?>
59 <script>
60 document.addEventListener('DOMContentLoaded', function () {
61 setTimeout(function () {
62 const dismissButtons = document.querySelectorAll('div[data-rttpg-dismissable] .notice-dismiss, div[data-rttpg-dismissable] .button-dismiss');
63
64 dismissButtons.forEach(function (button) {
65 button.addEventListener('click', function (e) {
66 e.preventDefault();
67
68 // Send AJAX request using fetch()
69 fetch(ajaxurl, {
70 method: 'POST',
71 headers: {
72 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
73 },
74 body: new URLSearchParams({
75 'action': 'rttpg_dismiss_black_friday_notice',
76 'nonce': <?php echo wp_json_encode( wp_create_nonce( 'rttpg-dismissible-notice' ) ); ?>
77 }),
78 });
79
80 // Remove the closest notice element
81 const notice = e.target.closest('.is-dismissible');
82 if (notice) {
83 notice.remove();
84 }
85 });
86 });
87 }, 1000);
88 });
89 </script>
90 <?php
91 }
92
93 public static function dismiss_black_friday_notice() {
94 if ( ! current_user_can( 'manage_options' ) ) {
95 wp_send_json_success( new \WP_Error( 'rttpg_block_user_permission', __( 'User permission error', 'the-post-grid' ) ) );
96 }
97 check_ajax_referer( 'rttpg-dismissible-notice', 'nonce' );
98 $currentYear = date( 'Y' );
99 update_option( 'rttpg_dismiss_bf_notice_' . $currentYear, '1' );
100 wp_die();
101 }
102
103 }