PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 3.6.0
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v3.6.0
3.6.0 3.5.3 3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.6.1 1.6.7 1.7.0 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.2 1.7.2.1 1.7.2.2 1.7.3 1.7.4 1.7.5 1.7.5.1 1.7.5.2 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.8.0 1.8.0.1 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.0.1 1.9.1 1.9.2 1.9.3 1.9.4 1.9.4.1 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.0.1 2.0.1 2.0.2 2.0.3 2.0.3.1 2.0.4 2.0.4.1 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 3.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.3.1 3.0.4 3.0.4.1 3.0.4.2 3.0.5 3.0.5.1 3.0.5.2 3.0.6 3.0.6.1 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.0.9.1 3.0.9.2 3.0.9.3 3.0.9.4 3.0.9.5 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.2.1 3.4.3 3.4.4 3.4.5 trunk 1.0 1.0.1 1.0.2 1.0.3
everest-forms / vendor / themegrill / themegrill-sdk / src / Loader.php
everest-forms / vendor / themegrill / themegrill-sdk / src Last commit date
Common 1 month ago Modules 1 month ago Loader.php 1 month ago Product.php 1 month ago
Loader.php
245 lines
1 <?php
2 /**
3 * The main loader class for ThemeGrill SDK
4 *
5 * @package ThemeGrillSDK
6 * @subpackage Loader
7 * @copyright Copyright (c) 2025, ThemeGrill
8 * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9 * @since 1.0.0
10 */
11
12 namespace ThemeGrillSDK;
13
14 use ThemeGrillSDK\Common\ModuleFactory;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 /**
21 * Singleton loader for ThemeGrill SDK.
22 */
23 final class Loader {
24 /**
25 * Singleton instance.
26 *
27 * @var Loader instance The singleton instance
28 */
29 private static $instance;
30 /**
31 * Current loader version.
32 *
33 * @var string $version The class version.
34 */
35 private static $version = '1.0.4';
36 /**
37 * Holds registered products.
38 *
39 * @var array<Product> The products which use the SDK.
40 */
41 private static $products = [];
42 /**
43 * Holds available modules to load.
44 *
45 * @var array The modules which SDK will be using.
46 */
47 private static $available_modules = [
48 'script_loader',
49 'rollback',
50 'uninstall_feedback',
51 'logger',
52 'notification',
53 'announcements',
54 'licenser',
55 'updater',
56 ];
57 /**
58 * Holds the labels for the modules.
59 *
60 * @var array The labels for the modules.
61 */
62 public static $labels = [
63 'announcements' => [
64 'notice_link_label' => 'See the Offer',
65 'max_savings' => 'Our biggest sale of the year: <strong>%s OFF everything!</strong> Don\'t miss this limited-time offer.',
66 'black_friday' => 'Black Friday Sale',
67 'time_left' => '%s left',
68 ],
69 'uninstall' => [
70 'heading_plugin' => 'What\'s wrong?',
71 'heading_theme' => 'What does not work for you in {theme}?',
72 'submit' => 'Submit',
73 'cta_info' => 'What info do we collect?',
74 'button_submit' => 'Submit &amp; Deactivate',
75 'button_cancel' => 'Skip &amp; Deactivate',
76 'disclosure' => [
77 'title' => 'Below is a detailed view of all data that ThemeGrill will receive if you fill in this survey. No email address or IP addresses are transmitted after you submit the survey.',
78 'version' => '%s %s version %s %s %s %s',
79 'website' => '%sCurrent website:%s %s %s %s',
80 'usage' => '%sUsage time:%s %s %s%s',
81 'reason' => '%s Uninstall reason %s %s Selected reason from the above survey %s ',
82 ],
83
84 'options' => [
85 'id3' => [
86 'title' => 'I found a better plugin',
87 'placeholder' => 'What\'s the plugin\'s name?',
88 ],
89 'id4' => [
90 'title' => 'I could not get the plugin to work',
91 'placeholder' => 'What problem are you experiencing?',
92 ],
93 'id5' => [
94 'title' => 'I no longer need the plugin',
95 'placeholder' => 'If you could improve one thing about our product, what would it be?',
96 ],
97 'id6' => [
98 'title' => 'It\'s a temporary deactivation. I\'m just debugging an issue.',
99 'placeholder' => 'What problem are you experiencing?',
100 ],
101 'id7' => [
102 'title' => 'I don\'t know how to make it look like demo',
103 ],
104 'id8' => [
105
106 'placeholder' => 'What option is missing?',
107 'title' => 'It lacks options',
108 ],
109 'id9' => [
110 'title' => 'Is not working with a plugin that I need',
111 'placeholder' => 'What is the name of the plugin',
112 ],
113 'id10' => [
114 'title' => 'I want to try a new design, I don\'t like {theme} style',
115 ],
116 'id999' => [
117 'title' => 'Other',
118 'placeholder' => 'What can we do better?',
119 ],
120 ],
121 ],
122 'rollback' => [
123 'cta' => 'Rollback to v%s',
124 ],
125 'logger' => [
126 'notice' => 'Do you enjoy <b>{product}</b>? Become a contributor by opting in to our anonymous data tracking. We guarantee no sensitive data is collected.',
127 'cta_y' => 'Sure, I would love to help.',
128 'cta_n' => 'No, thanks.',
129 ],
130 ];
131
132 /**
133 * Initialize the sdk logic.
134 */
135 public static function init() {
136 /**
137 * This filter can be used to localize the labels inside each product.
138 */
139 self::$labels = apply_filters( 'themegrill_sdk_labels', self::$labels );
140 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Loader ) ) {
141 self::$instance = new Loader();
142 $modules = array_merge( self::$available_modules, apply_filters( 'themegrill_sdk_modules', [] ) );
143 foreach ( $modules as $key => $module ) {
144 if ( ! class_exists( 'ThemeGrillSDK\\Modules\\' . str_replace( ' ', '', ucwords( str_replace( '_', ' ', $module ) ) ) ) ) {
145 unset( $modules[ $key ] );
146 }
147 }
148 self::$available_modules = $modules;
149
150 add_action( 'themegrill_sdk_first_activation', array( __CLASS__, 'activate' ) );
151 }
152 }
153
154 /**
155 * Get cache token used in API requests.
156 *
157 * @return string Cache token.
158 */
159 public static function get_cache_token() {
160 $cache_token = get_transient( 'themegrill_sdk_cache_token' );
161 if ( false === $cache_token ) {
162 $cache_token = wp_generate_password( 6, false );
163 set_transient( 'themegrill_sdk_cache_token', $cache_token, WEEK_IN_SECONDS );
164 }
165
166 return $cache_token;
167 }
168
169 /**
170 * Clear cache token.
171 */
172 public static function clear_cache_token() {
173 delete_transient( 'themegrill_sdk_cache_token' );
174 }
175
176 /**
177 * Register product into SDK.
178 *
179 * @param string $base_file The product base file.
180 *
181 * @return Loader The singleton object.
182 */
183 public static function add_product( $base_file ) {
184 if ( ! is_file( $base_file ) ) {
185 return self::$instance;
186 }
187 $product = new Product( $base_file );
188
189 ModuleFactory::attach( $product, self::get_modules() );
190
191 self::$products[ $product->get_slug() ] = $product;
192
193 return self::$instance;
194 }
195
196 /**
197 * Activate the product routine.
198 *
199 * @param string $file The base file of the product.
200 *
201 * @return void
202 */
203 public static function activate( $file ) {
204
205 $dirname = trailingslashit( dirname( ( $file ) ) );
206 if ( ! file_exists( $dirname . '_reference.php' ) ) {
207 return;
208 }
209 $reference_data = require_once $dirname . '_reference.php';
210 if ( ! is_array( $reference_data ) ||
211 ! isset( $reference_data['key'] ) ||
212 ! isset( $reference_data['value'] ) ||
213 ! preg_match( '/^[a-zA-Z0-9_]+_reference_key$/', $reference_data['key'] ) ) {
214 return;
215 }
216 add_option( $reference_data['key'], sanitize_key( $reference_data['value'] ) );
217 }
218 /**
219 * Get all registered modules by the SDK.
220 *
221 * @return array Modules available.
222 */
223 public static function get_modules() {
224 return self::$available_modules;
225 }
226
227 /**
228 * Get all products using the SDK.
229 *
230 * @return array<Product> Products available.
231 */
232 public static function get_products() {
233 return self::$products;
234 }
235
236 /**
237 * Get the version of the SDK.
238 *
239 * @return string The version.
240 */
241 public static function get_version() {
242 return self::$version;
243 }
244 }
245