PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.8
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.8
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 3.10.4 All 148 releases
visualizer / vendor / codeinwp / themeisle-sdk / src / Modules / Review.php

Review.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.4.8, at vendor/codeinwp/themeisle-sdk/src/Modules/Review.php

118 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The Review model class for ThemeIsle SDK
4 *
5 * @package ThemeIsleSDK
6 * @subpackage Modules
7 * @copyright Copyright (c) 2017, Marius Cristea
8 * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9 * @since 1.0.0
10 */
11
12 namespace ThemeisleSDK\Modules;
13
14 use ThemeisleSDK\Common\Abstract_Module;
15 use ThemeisleSDK\Product;
16
17 // Exit if accessed directly.
18 if ( ! defined( 'ABSPATH' ) ) {
19 exit;
20 }
21
22 /**
23 * Review module for ThemeIsle SDK.
24 */
25 class Review extends Abstract_Module {
26
27 /**
28 * Check if we should load module for this.
29 *
30 * @param Product $product Product to check.
31 *
32 * @return bool Should load ?
33 */
34 public function can_load( $product ) {
35 if ( $this->is_from_partner( $product ) ) {
36 return false;
37 }
38 if ( ! $product->is_wordpress_available() ) {
39 return false;
40 }
41
42 return apply_filters( $product->get_slug() . '_sdk_should_review', true );
43 }
44
45
46 /**
47 * Add notification to queue.
48 *
49 * @param array $all_notifications Previous notification.
50 *
51 * @return array All notifications.
52 */
53 public function add_notification( $all_notifications ) {
54
55 $developers = [
56 'Bogdan',
57 'Marius',
58 'Hardeep',
59 'Rodica',
60 'Stefan',
61 'Uriahs',
62 'Madalin',
63 'Cristi',
64 'Silviu',
65 'Andrei',
66 ];
67
68 $link = 'https://wordpress.org/support/' . $this->product->get_type() . '/' . $this->product->get_slug() . '/reviews/#wporg-footer';
69
70 $message = apply_filters( $this->product->get_key() . '_feedback_review_message', '<p>Hey, it\'s great to see you have <b>{product}</b> active for a few days now. How is everything going? If you can spare a few moments to rate it on WordPress.org it would help us a lot (and boost my motivation). Cheers! <br/> <br/>~ {developer}, developer of {product}</p>' );
71
72 $button_submit = apply_filters( $this->product->get_key() . '_feedback_review_button_do', 'Ok, I will gladly help.' );
73 $button_cancel = apply_filters( $this->product->get_key() . '_feedback_review_button_cancel', 'No, thanks.' );
74 $message = str_replace(
75 [ '{product}', '{developer}' ],
76 [
77 $this->product->get_friendly_name(),
78 $developers[ strlen( get_site_url() ) % 10 ],
79 ],
80 $message
81 );
82
83 $all_notifications[] = [
84 'id' => $this->product->get_key() . '_review_flag',
85 'message' => $message,
86 'ctas' => [
87 'confirm' => [
88 'link' => $link,
89 'text' => $button_submit,
90 ],
91 'cancel' => [
92 'link' => '#',
93 'text' => $button_cancel,
94 ],
95 ],
96 ];
97
98 return $all_notifications;
99 }
100
101
102 /**
103 * Load module logic.
104 *
105 * @param Product $product Product to load.
106 *
107 * @return Review Module instance.
108 */
109 public function load( $product ) {
110
111 $this->product = $product;
112
113 add_filter( 'themeisle_sdk_registered_notifications', [ $this, 'add_notification' ] );
114
115 return $this;
116 }
117 }
118