PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 2.4.1
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v2.4.1
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 2.4.1, at admin/views/notices/review.php

147 lines 4.3 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 /**
14 * The admin review notice.
15 */
16 class SPS_Review {
17
18 /**
19 * Initialize the class and set its properties.
20 */
21 public function __construct() {
22 add_action( 'admin_notices', array( $this, 'display_admin_notice' ) );
23 add_action( 'wp_ajax_smart-post-show-never-show-review-notice', array( $this, 'dismiss_review_notice' ) );
24 }
25
26 /**
27 * Display admin notice.
28 *
29 * @return void
30 */
31 public function display_admin_notice() {
32
33 // Show only to Admins.
34 if ( ! current_user_can( 'manage_options' ) ) {
35 return;
36 }
37
38 // Variable default value.
39 $review = get_option( 'smart_post_show_review_notice_dismiss' );
40 $time = time();
41 $load = false;
42
43 if ( ! $review ) {
44 $review = array(
45 'time' => $time,
46 'dismissed' => false,
47 );
48 add_option( 'smart_post_show_review_notice_dismiss', $review );
49 } else {
50 // Check if it has been dismissed or not.
51 if ( ( isset( $review['dismissed'] ) && ! $review['dismissed'] ) && ( isset( $review['time'] ) && ( ( $review['time'] + ( DAY_IN_SECONDS * 3 ) ) <= $time ) ) ) {
52 $load = true;
53 }
54 }
55
56 // If we cannot load, return early.
57 if ( ! $load ) {
58 return;
59 }
60 ?>
61 <div id="smart-post-show-review-notice" class="smart-post-show-review-notice">
62 <div class="sp-sps-plugin-icon">
63 <img src="<?php echo esc_url( SP_PC_URL . 'admin/assets/img/images/sps-icon.svg' ); ?>" alt="Smart Post Show">
64 </div>
65 <div class="sp-sps-notice-text">
66 <h3>Enjoying <strong>Smart Post Show</strong>?</h3>
67 <p>Hope that you had a good experience with the <strong>Smart Post Show</strong>. Would you please show us a little love by rating us in the <a href="https://wordpress.org/support/plugin/post-carousel/reviews/?filter=5#new-post" target="_blank"><strong>WordPress.org</strong></a>?
68 Just a minute to rate it. Thank you!</p>
69
70 <p class="sp-sps-review-actions">
71 <a href="https://wordpress.org/support/plugin/post-carousel/reviews/?filter=5#new-post" target="_blank" class="button button-primary notice-dismissed rate-testimonial">Rate Smart Post Show</a>
72 <a href="#" class="notice-dismissed remind-me-later"><span class="dashicons dashicons-clock"></span>Nope, maybe later
73 </a>
74 <a href="#" class="notice-dismissed never-show-again"><span class="dashicons dashicons-dismiss"></span>Never show again</a>
75 </p>
76 </div>
77 </div>
78
79 <script type='text/javascript'>
80
81 jQuery(document).ready( function($) {
82 $(document).on('click', '#smart-post-show-review-notice.smart-post-show-review-notice .notice-dismissed', function( event ) {
83 if ( $(this).hasClass('rate-testimonial') ) {
84 var notice_dismissed_value = "1";
85 }
86 if ( $(this).hasClass('remind-me-later') ) {
87 var notice_dismissed_value = "2";
88 event.preventDefault();
89 }
90 if ( $(this).hasClass('never-show-again') ) {
91 var notice_dismissed_value = "3";
92 event.preventDefault();
93 }
94
95 $.post( ajaxurl, {
96 action: 'smart-post-show-never-show-review-notice',
97 notice_dismissed_data : notice_dismissed_value,
98 nonce: '<?php echo esc_attr( wp_create_nonce( 'sps_review_notice' ) ); ?>'
99 });
100
101 $('#smart-post-show-review-notice.smart-post-show-review-notice').hide();
102 });
103 });
104
105 </script>
106 <?php
107 }
108
109 /**
110 * Dismiss review notice
111 *
112 * @since 2.2.3
113 *
114 * @return void
115 **/
116 public function dismiss_review_notice() {
117 $post_data = wp_unslash( $_POST );
118
119 if ( ! isset( $post_data['nonce'] ) || ! wp_verify_nonce( sanitize_key( $post_data['nonce'] ), 'sps_review_notice' ) ) {
120 return;
121 }
122
123 $review = get_option( 'smart_post_show_review_notice_dismiss' );
124 if ( ! $review ) {
125 $review = array();
126 }
127 switch ( isset( $post_data['notice_dismissed_data'] ) ? $post_data['notice_dismissed_data'] : '' ) {
128 case '1':
129 $review['time'] = time();
130 $review['dismissed'] = false;
131 break;
132 case '2':
133 $review['time'] = time();
134 $review['dismissed'] = false;
135 break;
136 case '3':
137 $review['time'] = time();
138 $review['dismissed'] = true;
139 break;
140 }
141 update_option( 'smart_post_show_review_notice_dismiss', $review );
142 die;
143 }
144 }
145
146 new SPS_Review();
147