PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / 3.2.14
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar v3.2.14
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 1.2.0 1.2.1 All 156 releases
notificationx / includes / Types / Traits / Reviews.php

Reviews.php in NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar 3.2.14, at includes/Types/Traits/Reviews.php

103 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Reviews Types
4 *
5 * @package NotificationX\Types
6 */
7
8 namespace NotificationX\Types\Traits;
9 use NotificationX\Core\Rules;
10 use NotificationX\Extensions\GlobalFields;
11
12 trait Reviews {
13
14 /**
15 * Adds option to Link Type field in Content tab.
16 *
17 * @param array $options
18 * @return array
19 */
20 public function link_types($options) {
21 $_options = GlobalFields::get_instance()->normalize_fields([
22 'review_page' => __('Product Page', 'notificationx'),
23 ], 'type', $this->id);
24
25 return array_merge($options, $_options);
26 }
27
28 /**
29 * This method is an implementable method for All Extension coming forward.
30 *
31 * @param array $args Settings arguments.
32 * @return mixed
33 */
34 public function review_templates($template) {
35 $template["review_fourth_param"] = [
36 // 'label' => __("Review Fourth Parameter", 'notificationx'),
37 'name' => "review_fourth_param", // changed name from "conversion_size"
38 'type' => "text",
39 'priority' => 27,
40 'default' => __('About', 'notificationx'),
41 'rules' => Rules::includes('themes', 'reviews_review_saying'),
42 ];
43 return $template;
44 }
45
46
47 /**
48 * This method is an implementable method for All Extension coming forward.
49 *
50 * @param array $args Settings arguments.
51 * @return mixed
52 */
53 public function content_trim_length_dependency($dependency) {
54 $dependency[] = 'reviews_review-comment';
55 $dependency[] = 'reviews_review-comment-2';
56 $dependency[] = 'reviews_review-comment-3';
57 $dependency[] = 'woo_reviews_review-comment';
58 $dependency[] = 'woo_reviews_review-comment-2';
59 $dependency[] = 'woo_reviews_review-comment-3';
60 $dependency[] = 'woocommerce_sales_reviews_review-comment';
61 $dependency[] = 'woocommerce_sales_reviews_review-comment-2';
62 $dependency[] = 'woocommerce_sales_reviews_review-comment-3';
63 $dependency[] = 'reviewx_review-comment';
64 $dependency[] = 'reviewx_review-comment-2';
65 $dependency[] = 'reviewx_review-comment-3';
66 return $dependency;
67 }
68
69 // @todo frontend
70 public function conversion_data($saved_data, $settings) {
71 if(empty($saved_data['content']) && !empty($saved_data['plugin_review'])){
72 $saved_data['content'] = $saved_data['plugin_review'];
73 }
74 if (!empty($saved_data['content'])) {
75 $trim_length = 100;
76 if ($settings['themes'] == 'reviews_review-comment-3' || $settings['themes'] == 'reviews_review-comment-3') {
77 $trim_length = 80;
78 }
79 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Reviewed for the NotificationX codebase: acceptable in this context.
80 $nx_trimmed_length = apply_filters('nx_text_trim_length', $trim_length, $settings);
81 $review_content = $saved_data['content'];
82 if (strlen($review_content) > $nx_trimmed_length) {
83 $review_content = substr($review_content, 0, $nx_trimmed_length) . '...';
84 }
85 if ($settings['themes'] == 'reviews_review-comment-2') { // || $settings['theme'] == 'comments_theme-six-free'
86 $review_content = '" ' . $review_content . ' "';
87 }
88 $saved_data['plugin_review'] = $review_content;
89 }
90 if(empty($saved_data['title']))
91 $saved_data['title'] = isset($saved_data['post_title']) ? $saved_data['post_title'] : '';
92
93 return $saved_data;
94 }
95
96 public function preview_entry($entry, $settings){
97 $entry = array_merge($entry, [
98 "title" => _x("NotificationX", 'nx_preview', 'notificationx'),
99 ]);
100 return $entry;
101 }
102
103 }