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 / Common / AbstractModule.php
everest-forms / vendor / themegrill / themegrill-sdk / src / Common Last commit date
AbstractModule.php 6 months ago ModuleFactory.php 1 month ago
AbstractModule.php
221 lines
1 <?php
2 /**
3 * The abstract class for module definition.
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\Common;
13
14 use ThemeGrillSDK\Product;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 /**
21 * Class AbstractModule.
22 *
23 * @package ThemeGrillSDK\Common
24 */
25 abstract class AbstractModule {
26 /**
27 * Plugin paths.
28 *
29 * @var string[] $plugin_paths Plugin paths.
30 */
31 private $plugin_paths = [
32 'learning-management-system' => 'learning-management-system/lms.php',
33 ];
34
35 /**
36 * Product which use the module.
37 *
38 * @var Product $product Product object.
39 */
40 protected $product = null;
41
42 /**
43 * Can load the module for the selected product.
44 *
45 * @param Product $product Product data.
46 *
47 * @return bool Should load module?
48 */
49 abstract public function can_load( $product );
50
51 /**
52 * Bootstrap the module.
53 *
54 * @param Product $product Product object.
55 */
56 abstract public function load( $product );
57
58 /**
59 * Check if the product is from partner.
60 *
61 * @param Product $product Product data.
62 *
63 * @return bool Is product from partner.
64 */
65 public function is_from_partner( $product ) {
66 foreach ( ModuleFactory::$domains as $partner_domain ) {
67 if ( strpos( $product->get_store_url(), $partner_domain ) !== false ) {
68 return true;
69 }
70 }
71
72 return array_key_exists( $product->get_slug(), ModuleFactory::$slugs );
73 }
74
75 /**
76 * Wrapper for wp_remote_get on VIP environments.
77 *
78 * @param string $url Url to check.
79 * @param array $args Option params.
80 *
81 * @return array|\WP_Error
82 */
83 public function safe_get( $url, $args = array() ) {
84 return function_exists( 'vip_safe_wp_remote_get' )
85 ? vip_safe_wp_remote_get( $url )
86 : wp_remote_get( //phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get, Already used.
87 $url,
88 $args
89 );
90 }
91
92 /**
93 * Get the SDK base url.
94 *
95 * @return string
96 */
97 public function get_sdk_uri() {
98 global $themegrill_sdk_max_path;
99
100 /**
101 * $themegrill_sdk_max_path can point to the theme when the theme version is higher.
102 * hence we also need to check that the path does not point to the theme else this will break the URL.
103 * References: https://github.com/Codeinwp/neve-pro-addon/issues/2403
104 */
105 if ( ( $this->product->is_plugin() || $this->product->is_theme() ) && false === strpos( $themegrill_sdk_max_path, get_template_directory() ) ) {
106 return plugins_url( '/', $themegrill_sdk_max_path . '/themegrill-sdk/' );
107 }
108
109 return get_template_directory_uri() . '/vendor/themegrill/themegrill-sdk/';
110 }
111
112 /**
113 * Call plugin api
114 *
115 * @param string $slug plugin slug.
116 *
117 * @return array|mixed|object
118 */
119 public function call_plugin_api( $slug ) {
120 include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
121
122 $call_api = get_transient( 'ti_plugin_info_' . $slug );
123
124 if ( false === $call_api ) {
125 $call_api = plugins_api(
126 'plugin_information',
127 array(
128 'slug' => $slug,
129 'fields' => array(
130 'downloaded' => false,
131 'rating' => false,
132 'description' => false,
133 'short_description' => true,
134 'donate_link' => false,
135 'tags' => false,
136 'sections' => true,
137 'homepage' => true,
138 'added' => false,
139 'last_updated' => false,
140 'compatibility' => false,
141 'tested' => false,
142 'requires' => false,
143 'downloadlink' => false,
144 'icons' => true,
145 'banners' => true,
146 ),
147 )
148 );
149 set_transient( 'ti_plugin_info_' . $slug, $call_api, 30 * MINUTE_IN_SECONDS );
150 }
151
152 return $call_api;
153 }
154
155 /**
156 * Get the plugin status.
157 *
158 * @param string $plugin Plugin slug.
159 *
160 * @return bool
161 */
162 public function is_plugin_installed( $plugin ) {
163 if ( ! isset( $this->plugin_paths[ $plugin ] ) ) {
164 return false;
165 }
166
167 if ( file_exists( WP_CONTENT_DIR . '/plugins/' . $this->plugin_paths[ $plugin ] ) ) {
168 return true;
169 }
170
171 return false;
172 }
173
174 /**
175 * Get plugin activation link.
176 *
177 * @param string $slug The plugin slug.
178 *
179 * @return string
180 */
181 public function get_plugin_activation_link( $slug ) {
182 $plugin = isset( $this->plugin_paths[ $slug ] ) ? $this->plugin_paths[ $slug ] : $slug . '/' . $slug . '.php';
183
184 return add_query_arg(
185 array(
186 'plugin_status' => 'all',
187 'paged' => '1',
188 'action' => 'activate',
189 'reference_key' => $this->product->get_key(),
190 'plugin' => rawurlencode( $plugin ),
191 '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $plugin ),
192 ),
193 admin_url( 'plugins.php' )
194 );
195 }
196
197 /**
198 * Checks if a plugin is active.
199 *
200 * @param string $plugin plugin slug.
201 *
202 * @return bool
203 */
204 public function is_plugin_active( $plugin ) {
205 include_once ABSPATH . 'wp-admin/includes/plugin.php';
206
207 $plugin = isset( $this->plugin_paths[ $plugin ] ) ? $this->plugin_paths[ $plugin ] : $plugin . '/' . $plugin . '.php';
208
209 return is_plugin_active( $plugin );
210 }
211
212 /**
213 * Get the current date.
214 *
215 * @return \DateTime The date time.
216 */
217 public function get_current_date() {
218 return apply_filters( 'themegrill_sdk_current_date', new \DateTime( 'now' ) );
219 }
220 }
221