PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / 3.3.3
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar v3.3.3
3.3.3 3.3.2 3.3.1 3.3.0 3.2.14 3.2.13 3.2.12 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 trunk 0.2.5.5 0.2.5.6 0.2.5.7 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 All 158 releases
← All changes | includes/Extensions/ReviewX/ReviewX.php +289 -0 0.2.5.6 → 3.3.3 View file →
@@ -1,0 +1,289 @@
1 +<?php
2 +/**
3 + * ReviewX Extension
4 + *
5 + * @package NotificationX\Extensions
6 + */
7 +
8 +namespace NotificationX\Extensions\ReviewX;
9 +
10 +use NotificationX\Core\Rules;
11 +use NotificationX\GetInstance;
12 +use NotificationX\Extensions\Extension;
13 +use NotificationX\Extensions\WooCommerce\Woo;
14 +use NotificationX\Extensions\WooCommerce\WooReviews;
15 +use NotificationX\NotificationX;
16 +use NotificationX\Types\Conversions;
17 +use NotificationX\Types\CustomNotification;
18 +use NotificationX\Types\DownloadStats;
19 +
20 +/**
21 + * ReviewX Extension Class
22 + */
23 +class ReviewX extends WooReviews {
24 + protected static $instance = null;
25 +
26 + public $priority = 15;
27 + public $id = 'reviewx';
28 + public $img = NOTIFICATIONX_ADMIN_URL . 'images/extensions/sources/reviewx.png';
29 + public $doc_link = 'https://notificationx.com/docs/reviewx-notification-alerts/';
30 + public $types = 'reviews';
31 + public $module = 'modules_reviewx';
32 + public $module_priority = 4;
33 + // public $class = '\ReviewX';
34 + public $function = 'rvx_wpdrill_init';
35 + public $default_theme = 'reviewx_total-rated';
36 + public $exclude_custom_themes = true;
37 +
38 + /**
39 + * Get the instance of called class.
40 + *
41 + * @return ReviewX
42 + */
43 + public static function get_instance($args = null){
44 + if ( is_null( static::$instance ) || ! static::$instance instanceof self ) {
45 + $class = __CLASS__;
46 + if(strpos($class, "NotificationX\\") === 0){
47 + $pro_class = str_replace("NotificationX\\", "NotificationXPro\\", $class);
48 + if(class_exists($pro_class)){
49 + $class = $pro_class;
50 + }
51 + }
52 +
53 + if(!empty($args)){
54 + static::$instance = new $class($args);
55 + }
56 + else{
57 + static::$instance = new $class;
58 + }
59 + }
60 + return static::$instance;
61 + }
62 +
63 + /**
64 + * Initially Invoked when initialized.
65 + */
66 + public function __construct(){
67 + parent::__construct();
68 + }
69 +
70 + public function init_extension()
71 + {
72 + $this->title = __('ReviewX', 'notificationx');
73 + $this->module_title = __('ReviewX', 'notificationx');
74 + $this->themes = [
75 + 'total-rated' => [
76 + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/wporg/total-rated.png',
77 + 'image_shape' => 'square',
78 + 'template' => [
79 + 'first_param' => 'tag_rated',
80 + 'custom_first_param' => __('Someone', 'notificationx'),
81 + 'second_param' => __('people rated', 'notificationx'),
82 + 'third_param' => 'tag_product_title',
83 + 'fourth_param' => 'tag_rating',
84 + 'custom_fourth_param' => __('Some time ago', 'notificationx'),
85 + ]
86 + ],
87 + 'reviewed' => [
88 + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/wporg/reviewed.png',
89 + 'image_shape' => 'circle',
90 + 'template' => [
91 + 'first_param' => 'tag_username',
92 + 'custom_first_param' => __('Someone', 'notificationx'),
93 + 'second_param' => __('just reviewed', 'notificationx'),
94 + 'third_param' => 'tag_product_title',
95 + 'fourth_param' => 'tag_rating',
96 + 'custom_fourth_param' => __('Some time ago', 'notificationx'),
97 + ]
98 + ],
99 + 'review_saying' => [
100 + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/wporg/saying-review.png',
101 + 'image_shape' => 'circle',
102 + 'template' => [
103 + 'first_param' => 'tag_username',
104 + 'custom_first_param' => __('Someone', 'notificationx'),
105 + 'second_param' => __('saying', 'notificationx'),
106 + 'third_param' => 'tag_title',
107 + 'custom_third_param' => __('Excellent', 'notificationx'),
108 + 'review_fourth_param' => __('about', 'notificationx'),
109 + 'fifth_param' => 'tag_product_title',
110 + 'sixth_param' => 'tag_custom',
111 + 'custom_sixth_param' => __('Try it now', 'notificationx'),
112 + ]
113 + ],
114 + 'review-comment' => [
115 + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/wporg/review-with-comment.jpg',
116 + 'image_shape' => 'rounded',
117 + 'template' => [
118 + 'first_param' => 'tag_username',
119 + 'custom_first_param' => __('Someone', 'notificationx'),
120 + 'second_param' => __('just reviewed', 'notificationx'),
121 + 'third_param' => 'tag_plugin_review',
122 + 'fourth_param' => 'tag_rating',
123 + 'custom_fourth_param' => __('Some time ago', 'notificationx'),
124 + ]
125 + ],
126 + 'review-comment-2' => [
127 + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/wporg/review-with-comment-2.jpg',
128 + 'template' => [
129 + 'first_param' => 'tag_username',
130 + 'custom_first_param' => __('Someone', 'notificationx'),
131 + 'second_param' => __('just reviewed', 'notificationx'),
132 + 'third_param' => 'tag_plugin_review',
133 + 'fourth_param' => 'tag_rating',
134 + 'custom_fourth_param' => __('Some time ago', 'notificationx'),
135 + ]
136 + ],
137 + 'review-comment-3' => [
138 + 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/wporg/review-with-comment-3.jpg',
139 + 'image_shape' => 'circle',
140 + 'template' => [
141 + 'first_param' => 'tag_username',
142 + 'custom_first_param' => __('Someone', 'notificationx'),
143 + 'second_param' => __('just reviewed', 'notificationx'),
144 + 'third_param' => 'tag_plugin_review',
145 + 'fourth_param' => 'tag_time',
146 + 'custom_fourth_param' => __('Some time ago', 'notificationx'),
147 + ]
148 + ],
149 + ];
150 + $this->templates = [
151 + 'reviewx_template_new' => [
152 + 'first_param' => [
153 + 'tag_username' => __('Username', 'notificationx'),
154 + 'tag_rated' => __('Rated', 'notificationx'),
155 + ],
156 + 'third_param' => [
157 + 'tag_product_title' => __('Product Title', 'notificationx'),
158 + 'tag_plugin_review' => __('Review', 'notificationx'),
159 + 'tag_anonymous_title' => __('Anonymous Title', 'notificationx'),
160 + ],
161 + 'fourth_param' => [
162 + 'tag_rating' => __('Rating', 'notificationx'),
163 + 'tag_time' => __('Definite Time', 'notificationx'),
164 + ],
165 + '_themes' => [
166 + 'reviewx_total-rated',
167 + 'reviewx_reviewed',
168 + 'reviewx_review-comment',
169 + 'reviewx_review-comment-2',
170 + 'reviewx_review-comment-3',
171 + ],
172 + ],
173 + 'reviewx_saying_template_new' => [
174 + 'first_param' => [
175 + 'tag_username' => __('Username', 'notificationx'),
176 + ],
177 + 'third_param' => [
178 + 'tag_title' => __('Review Title', 'notificationx'),
179 + 'tag_anonymous_title' => __('Anonymous Title', 'notificationx'),
180 + ],
181 + 'fifth_param' => [
182 + 'tag_plugin_name' => __('Plugin Name', 'notificationx'),
183 + ],
184 + 'sixth_param' => [
185 + // @todo maybe add some predefined texts.
186 + ],
187 + '_themes' => [
188 + 'reviewx_review_saying',
189 + ],
190 + ],
191 + ];
192 + }
193 + /**
194 + * This functions is hooked
195 + *
196 + * @return void
197 + */
198 + public function admin_actions() {
199 + parent::admin_actions();
200 + if(NotificationX::get_instance()->is_pro()){
201 + add_filter("nx_can_entry_{$this->id}", array(Conversions::get_instance(), 'nx_can_entry'), 10, 3);
202 + }
203 + }
204 +
205 + public function source_error_message($messages) {
206 + if (!$this->class_exists()) {
207 + $url = admin_url('plugin-install.php?s=ReviewX&tab=search&type=term');
208 + $messages[$this->id] = [
209 + 'message' => sprintf( '%s <a href="%s" target="_blank">%s</a> %s.',
210 + __( 'You have to install', 'notificationx' ),
211 + $url,
212 + __( 'ReviewX', 'notificationx' ),
213 + __( 'plugin.', 'notificationx' )
214 + ),
215 + 'html' => true,
216 + 'type' => 'error',
217 + 'rules' => Rules::is('source', $this->id),
218 + ];
219 + }
220 + return $messages;
221 + }
222 +
223 + /**
224 + * This function is responsible for making ready the comments data!
225 + *
226 + * @param int|WP_Comment $comment
227 + * @return void
228 + */
229 + public function add($comment) {
230 + $comment_data = [];
231 + if (!$comment instanceof \WP_Comment) {
232 + $comment_id = intval($comment);
233 + $comment = get_comment($comment_id, 'OBJECT');
234 + }
235 + if ($comment->comment_type !== 'review') {
236 + return;
237 + }
238 +
239 + $comment_data['id'] = $comment->comment_ID;
240 + $comment_data['product_id'] = $comment->comment_post_ID;
241 + $comment_data['content'] = $comment->comment_content;
242 + $comment_data['link'] = get_comment_link($comment->comment_ID);
243 + $comment_data['post_title'] = get_the_title($comment->comment_post_ID);
244 + $comment_data['post_link'] = get_permalink($comment->comment_post_ID);
245 + $comment_data['timestamp'] = get_gmt_from_date($comment->comment_date);
246 + $comment_data['rating'] = get_comment_meta($comment->comment_ID, 'rating', true);
247 + $comment_data['title'] = get_comment_meta($comment->comment_ID, 'reviewx_title', true);
248 +
249 + $comment_data['ip'] = $comment->comment_author_IP;
250 +
251 + if ($comment->user_id) {
252 + $comment_data['user_id'] = $comment->user_id;
253 + $user = get_userdata($comment->user_id);
254 + $comment_data['first_name'] = $user->first_name;
255 + $comment_data['last_name'] = $user->last_name;
256 + $comment_data['username'] = $user->display_name;
257 + $comment_data['name'] = $user->first_name . ' ' . mb_substr($user->last_name, 0, 1);
258 + $trimed = trim($comment_data['name']);
259 + if (empty($trimed)) {
260 + $comment_data['name'] = $user->user_nicename;
261 + }
262 + } else {
263 + $commenter_name = get_comment_author($comment->comment_ID);
264 + $comment_data['username'] = $commenter_name;
265 + $commenter_name = explode(' ', $commenter_name);
266 + if (isset($commenter_name[0])) {
267 + $comment_data['first_name'] = $commenter_name[0];
268 + }
269 + $commenter_count = count($commenter_name);
270 + if (isset($commenter_name[$commenter_count - 1])) {
271 + $comment_data['last_name'] = $commenter_name[$commenter_count - 1];
272 + }
273 + }
274 + $comment_data['email'] = get_comment_author_email($comment->comment_ID);
275 + return $comment_data;
276 + }
277 +
278 + public function doc(){
279 + /* translators: %1$s: WooCommerce link URL, %2$s: ReviewX link URL, %3$s: documentation link URL, %4$s: boost WooCommerce Sales link URL */
280 + return sprintf(__('<p>Make sure that you have <a target="_blank" href="%1$s">WooCommerce</a> & <a target="_blank" href="%2$s">ReviewX</a> installed & activated to use this campaign. For further assistance, check out our step by step <a target="_blank" href="%3$s">documentation</a>.</p>
281 + <p><strong>Recommended Blog:</strong></p>
282 + <p>🚀 How to <a target="_blank" href="%4$s">boost WooCommerce Sales</a> Using NotificationX</p>', 'notificationx'),
283 + 'https://wordpress.org/plugins/woocommerce/',
284 + 'https://wordpress.org/plugins/reviewx/',
285 + 'https://notificationx.com/docs/reviewx-notification-alerts',
286 + 'https://wpdeveloper.com/ecommerce-sales-social-proof/'
287 + );
288 + }
289 +}