PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.4
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.4
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / admin / views / notices / review.php

review.php in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.4, at admin/views/notices/review.php

158 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The admin review notice.
4 *
5 * @since 2.2.3
6 * @version 2.2.3
7 *
8 * @package Smart_Post_Show
9 * @subpackage Smart_Post_Show/admin/views/notices
10 * @author ShapedPlugin<support@shapedplugin.com>
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit; // Exit if accessed directly.
15 }
16
17 /**
18 * The admin review notice.
19 */
20 class SPS_Review {
21
22 /**
23 * Initialize the class and set its properties.
24 */
25 public function __construct() {
26 add_action( 'admin_notices', array( $this, 'display_admin_notice' ) );
27 add_action( 'wp_ajax_smart-post-show-never-show-review-notice', array( $this, 'dismiss_review_notice' ) );
28 }
29
30 /**
31 * Display admin notice.
32 *
33 * @return void
34 */
35 public function display_admin_notice() {
36
37 // Show only to Admins.
38 if ( ! current_user_can( 'manage_options' ) ) {
39 return;
40 }
41
42 // Variable default value.
43 $review = get_option( 'smart_post_show_review_notice_dismiss' );
44 $time = time();
45 $load = false;
46
47 if ( ! $review ) {
48 $review = array(
49 'time' => $time,
50 'dismissed' => false,
51 );
52 add_option( 'smart_post_show_review_notice_dismiss', $review );
53 } else {
54 // Check if it has been dismissed or not.
55 if ( ( isset( $review['dismissed'] ) && ! $review['dismissed'] ) && ( isset( $review['time'] ) && ( ( $review['time'] + ( DAY_IN_SECONDS * 3 ) ) <= $time ) ) ) {
56 $load = true;
57 }
58 }
59
60 // If we cannot load, return early.
61 if ( ! $load ) {
62 return;
63 }
64
65 $plugin_logo_image = 'https://ps.w.org/post-carousel/assets/icon-256x256.gif';
66
67 ?>
68 <div id="smart-post-show-review-notice" class="smart-post-show-review-notice">
69 <div class="sp-sps-plugin-icon">
70 <img src="<?php echo esc_url( $plugin_logo_image ); ?>" alt="Smart Post">
71 </div>
72 <div class="sp-sps-notice-text">
73 <h3>Enjoying <strong>Smart Post</strong>?</h3>
74 <p>We hope you had a wonderful experience using <strong>Smart Post</strong>. Please take a moment to leave a review on <a href="https://wordpress.org/support/plugin/post-carousel/reviews/" target="_blank"><strong>WordPress.org</strong></a>?
75 Your positive review will help us improve. Thank you! 😊</p>
76
77 <p class="sp-sps-review-actions">
78 <a href="https://wordpress.org/support/plugin/post-carousel/reviews/" target="_blank" class="button button-primary notice-dismissed rate-testimonial">Ok, you deserve �
79
80
81
82
83 </a>
84 <a href="#" class="notice-dismissed remind-me-later"><span class="dashicons dashicons-clock"></span>Nope, maybe later</a>
85 <a href="#" class="notice-dismissed never-show-again"><span class="dashicons dashicons-dismiss"></span>Never show again</a>
86 </p>
87 </div>
88 </div>
89
90 <script type='text/javascript'>
91
92 jQuery(document).ready( function($) {
93 $(document).on('click', '#smart-post-show-review-notice.smart-post-show-review-notice .notice-dismissed', function( event ) {
94 if ( $(this).hasClass('rate-testimonial') ) {
95 var notice_dismissed_value = "1";
96 }
97 if ( $(this).hasClass('remind-me-later') ) {
98 var notice_dismissed_value = "2";
99 event.preventDefault();
100 }
101 if ( $(this).hasClass('never-show-again') ) {
102 var notice_dismissed_value = "3";
103 event.preventDefault();
104 }
105
106 $.post( ajaxurl, {
107 action: 'smart-post-show-never-show-review-notice',
108 notice_dismissed_data : notice_dismissed_value,
109 nonce: '<?php echo esc_attr( wp_create_nonce( 'sps_review_notice' ) ); ?>'
110 });
111
112 $('#smart-post-show-review-notice.smart-post-show-review-notice').hide();
113 });
114 });
115
116 </script>
117 <?php
118 }
119
120 /**
121 * Dismiss review notice
122 *
123 * @since 2.2.3
124 *
125 * @return void
126 **/
127 public function dismiss_review_notice() {
128
129 if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['nonce'] ) ), 'sps_review_notice' ) ) {
130 return;
131 }
132
133 $review = get_option( 'smart_post_show_review_notice_dismiss' );
134 if ( ! $review ) {
135 $review = array();
136 }
137 $notice_dismissed_data = isset( $_POST['notice_dismissed_data'] ) ? sanitize_key( wp_unslash( $_POST['notice_dismissed_data'] ) ) : '';
138 switch ( $notice_dismissed_data ) {
139 case '1':
140 $review['time'] = time();
141 $review['dismissed'] = true;
142 break;
143 case '2':
144 $review['time'] = time();
145 $review['dismissed'] = false;
146 break;
147 case '3':
148 $review['time'] = time();
149 $review['dismissed'] = true;
150 break;
151 }
152 update_option( 'smart_post_show_review_notice_dismiss', $review );
153 die;
154 }
155 }
156
157 new SPS_Review();
158