PluginProbe ʕ •ᴥ•ʔ
Strong Testimonials / 3.3.2
Strong Testimonials v3.3.2
3.3.2 3.3.1 trunk 1.0.1 2.30.9 2.31.10 2.32 2.32.1 2.32.2 2.32.3 2.32.4 2.33 2.34 2.35 2.36 2.37 2.38 2.38.1 2.39 2.39.1 2.39.2 2.39.3 2.40.0 2.40.1 2.40.2 2.40.3 2.40.4 2.40.5 2.40.6 2.40.7 2.41.0 2.41.1 2.50.0 2.50.1 2.50.2 2.50.3 2.50.4 2.51.0 2.51.1 2.51.2 2.51.3 2.51.4 2.51.5 2.51.6 2.51.7 2.51.8 2.51.9 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.17 3.2.18 3.2.19 3.2.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0
strong-testimonials / admin / class-strong-testimonials-review.php
strong-testimonials / admin Last commit date
challenge 1 year ago css 1 week ago img 1 year ago js 1 month ago menu 1 month ago partials 2 weeks ago rest-api 1 week ago scss 1 year ago settings 1 week ago uninstall 1 year ago wpchill 1 month ago admin-notices.php 6 months ago admin.php 1 month ago class-strong-testimonials-addons.php 1 month ago class-strong-testimonials-admin-category-list.php 1 year ago class-strong-testimonials-admin-list.php 1 year ago class-strong-testimonials-admin-scripts.php 1 month ago class-strong-testimonials-admin.php 1 month ago class-strong-testimonials-debug.php 6 months ago class-strong-testimonials-exporter.php 1 year ago class-strong-testimonials-help.php 1 year ago class-strong-testimonials-helper.php 1 month ago class-strong-testimonials-list-table.php 1 year ago class-strong-testimonials-lite-vs-pro-page.php 1 month ago class-strong-testimonials-post-editor.php 7 months ago class-strong-testimonials-review.php 1 year ago class-strong-testimonials-updater.php 1 month ago class-strong-testimonials-upsell.php 1 week ago class-strong-views-list-table.php 1 month ago class-walker-strong-category-checklist.php 1 year ago class-walker-strong-form-category-checklist.php 1 year ago class-wpmtst-onboarding.php 1 year ago compat.php 1 year ago custom-fields-ajax.php 1 year ago custom-fields.php 1 week ago form-preview.php 1 year ago view-list-order.php 1 year ago views-ajax.php 1 month ago views-validate.php 1 year ago views.php 1 month ago
class-strong-testimonials-review.php
171 lines
1 <?php
2
3 class Strong_Testimonials_Review {
4
5 private $value;
6 private $messages;
7 private $link = 'https://wordpress.org/support/plugin/%s/reviews/#new-post';
8 private $slug = 'strong-testimonials';
9
10 public function __construct() {
11 add_action( 'init', array( $this, 'init' ) );
12 }
13
14 public function init() {
15 if ( ! is_admin() ) {
16 return;
17 }
18
19 $this->messages = array(
20 'notice' => esc_html__( "Hi there! Stoked to see you're using Strong Testimonials for a few days now - hope you like it! And if you do, please consider rating it. It would mean the world to us. Keep on rocking!", 'strong-testimonials' ),
21 'rate' => esc_html__( 'Rate the plugin', 'strong-testimonials' ),
22 'rated' => esc_html__( 'Remind me later', 'strong-testimonials' ),
23 'no_rate' => __( 'Don\'t show again', 'strong-testimonials' ),
24 );
25
26 if ( isset( $args['messages'] ) ) {
27 $this->messages = wp_parse_args( $args['messages'], $this->messages );
28 }
29
30 $this->value = $this->value();
31
32 if ( $this->check() ) {
33 add_action( 'admin_notices', array( $this, 'five_star_wp_rate_notice' ) );
34 add_action( 'wp_ajax_strong-testimonials_review', array( $this, 'ajax' ) );
35 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
36 add_action( 'admin_print_footer_scripts', array( $this, 'ajax_script' ) );
37 }
38
39 add_filter( 'st_uninstall_db_options', array( $this, 'uninstall_options' ) );
40 }
41
42 private function check() {
43
44 if ( ! current_user_can( 'manage_options' ) ) {
45 return false;
46 }
47
48 return( time() > $this->value );
49 }
50
51 private function value() {
52
53 $value = get_option( 'strong-testimonials-rate-time', false );
54 if ( $value ) {
55 return $value;
56 }
57
58 $value = time() + DAY_IN_SECONDS;
59 update_option( 'strong-testimonials-rate-time', $value );
60
61 return $value;
62 }
63
64 public function five_star_wp_rate_notice() {
65
66 $url = sprintf( $this->link, $this->slug );
67 $url = apply_filters( 'wpmtst_review_link', $url );
68 $this->messages = apply_filters( 'wpmtst_review_messages', $this->messages );
69
70 $notice = array(
71 'title' => 'Rate Us',
72 'message' => sprintf( esc_html( $this->messages['notice'] ), esc_html( $this->value ) ),
73 'status' => 'success',
74 'dismissible' => false,
75 'timestamp' => false,
76 'actions' => array(
77 array(
78 'label' => esc_html( $this->messages['rated'] ),
79 'id' => 'strong-testimonials-later',
80 'class' => 'strong-testimonials-review-button',
81 'dismiss' => true,
82 'callback' => 'handleStButtonClick',
83 ),
84 array(
85 'label' => esc_html( $this->messages['no_rate'] ),
86 'id' => 'strong-testimonials-no-rate',
87 'class' => 'strong-testimonials-review-button',
88 'dismiss' => true,
89 'callback' => 'handleStButtonClick',
90 ),
91 array(
92 'label' => esc_html( $this->messages['rate'] ),
93 'id' => 'strong-testimonials-rate',
94 'url' => esc_url( $url ),
95 'class' => 'strong-testimonials-review-button',
96 'variant' => 'primary',
97 'target' => '_BLANK',
98 'dismiss' => true,
99 'callback' => 'handleStButtonClick',
100 ),
101 ),
102 'source' => array(
103 'slug' => 'strong-testimonials',
104 'name' => 'Strong Testimonials',
105 ),
106 );
107
108 WPChill_Notifications::add_notification( 'wpmtst-five-star-rate', $notice );
109 }
110
111 public function ajax() {
112
113 check_ajax_referer( 'strong-testimonials-review', 'security' );
114
115 if ( ! isset( $_POST['check'] ) ) {
116 wp_die( 'ok' );
117 }
118
119 $time = get_option( 'strong-testimonials-rate-time' );
120
121 if ( 'strong-testimonials-rate' === $_POST['check'] || 'strong-testimonials-no-rate' === $_POST['check'] ) {
122 $time = time() + YEAR_IN_SECONDS * 5;
123 } else {
124 $time = time() + WEEK_IN_SECONDS;
125 }
126
127 update_option( 'strong-testimonials-rate-time', $time );
128 wp_die( 'ok' );
129 }
130
131 public function enqueue() {
132 wp_enqueue_script( 'jquery' );
133 }
134
135 public function ajax_script() {
136
137 $ajax_nonce = wp_create_nonce( 'strong-testimonials-review' );
138
139 ?>
140 <script type="text/javascript">
141
142 function handleStButtonClick( element ) {
143 console.error('clicky');
144 var data = {
145 action: 'strong-testimonials_review',
146 security: '<?php echo esc_js( $ajax_nonce ); ?>',
147 check: element.url ? 'strong-testimonials-rate' : element.id
148 };
149
150 jQuery.post('<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>', data );
151 }
152 </script>
153 <?php
154 }
155
156 /**
157 * @param $options
158 *
159 * @return mixed
160 *
161 * @since 2.51.6
162 */
163 public function uninstall_options( $options ) {
164
165 $options[] = 'strong-testimonials-rate-time';
166
167 return $options;
168 }
169 }
170
171 new Strong_Testimonials_Review();