PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.10
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.10
4.0.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 All 149 releases
← All changes | vendor/codeinwp/themeisle-sdk/src/Common/Abstract_module.php +160 -3 3.1.33.11.10 View file →
@@ -23,8 +23,28 @@
23 23 * @package ThemeisleSDK\Common
24 24 */
25 25 abstract class Abstract_Module {
26 26 /**
27 + * Plugin paths.
28 + *
29 + * @var string[] $plugin_paths Plugin paths.
30 + */
31 + private $plugin_paths = [
32 + 'otter-blocks' => 'otter-blocks/otter-blocks.php',
33 + 'optimole-wp' => 'optimole-wp/optimole-wp.php',
34 + 'tweet-old-post' => 'tweet-old-post/tweet-old-post.php',
35 + 'feedzy-rss-feeds' => 'feedzy-rss-feeds/feedzy-rss-feed.php',
36 + 'woocommerce-product-addon' => 'woocommerce-product-addon/woocommerce-product-addon.php',
37 + 'visualizer' => 'visualizer/index.php',
38 + 'wp-landing-kit' => 'wp-landing-kit/wp-landing-kit.php',
39 + 'multiple-pages-generator-by-porthas' => 'multiple-pages-generator-by-porthas/porthas-multi-pages-generator.php',
40 + 'sparks-for-woocommerce' => 'sparks-for-woocommerce/sparks-for-woocommerce.php',
41 + 'templates-patterns-collection' => 'templates-patterns-collection/templates-patterns-collection.php',
42 + 'wpcf7-redirect' => 'wpcf7-redirect/wpcf7-redirect.php',
43 + 'wp-full-stripe-free' => 'wp-full-stripe-free/wp-full-stripe.php',
44 + ];
45 +
46 + /**
27 47 * Product which use the module.
28 48 *
29 49 * @var Product $product Product object.
30 50 */
@@ -36,9 +56,9 @@
36 56 * @param Product $product Product data.
37 57 *
38 58 * @return bool Should load module?
39 59 */
40 - public abstract function can_load( $product );
60 + abstract public function can_load( $product );
41 61
42 62 /**
43 63 * Bootstrap the module.
44 64 *
@@ -43,9 +63,9 @@
43 63 * Bootstrap the module.
44 64 *
45 65 * @param Product $product Product object.
46 66 */
47 - public abstract function load( $product );
67 + abstract public function load( $product );
48 68
49 69 /**
50 70 * Check if the product is from partner.
51 71 *
@@ -53,9 +73,8 @@
53 73 *
54 74 * @return bool Is product from partner.
55 75 */
56 76 public function is_from_partner( $product ) {
57 -
58 77 foreach ( Module_Factory::$domains as $partner_domain ) {
59 78 if ( strpos( $product->get_store_url(), $partner_domain ) !== false ) {
60 79 return true;
61 80 }
@@ -61,6 +80,144 @@
61 80 }
62 81 }
63 82
64 83 return array_key_exists( $product->get_slug(), Module_Factory::$slugs );
84 + }
85 +
86 + /**
87 + * Wrapper for wp_remote_get on VIP environments.
88 + *
89 + * @param string $url Url to check.
90 + * @param array $args Option params.
91 + *
92 + * @return array|\WP_Error
93 + */
94 + public function safe_get( $url, $args = array() ) {
95 + return function_exists( 'vip_safe_wp_remote_get' )
96 + ? vip_safe_wp_remote_get( $url )
97 + : wp_remote_get( //phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get, Already used.
98 + $url,
99 + $args
100 + );
101 + }
102 +
103 + /**
104 + * Get the SDK base url.
105 + *
106 + * @return string
107 + */
108 + public function get_sdk_uri() {
109 + global $themeisle_sdk_max_path;
110 +
111 + /**
112 + * $themeisle_sdk_max_path can point to the theme when the theme version is higher.
113 + * hence we also need to check that the path does not point to the theme else this will break the URL.
114 + * References: https://github.com/Codeinwp/neve-pro-addon/issues/2403
115 + */
116 + if ( ( $this->product->is_plugin() || $this->product->is_theme() ) && false === strpos( $themeisle_sdk_max_path, get_template_directory() ) ) {
117 + return plugins_url( '/', $themeisle_sdk_max_path . '/themeisle-sdk/' );
118 + };
119 +
120 + return get_template_directory_uri() . '/vendor/codeinwp/themeisle-sdk/';
121 + }
122 +
123 + /**
124 + * Call plugin api
125 + *
126 + * @param string $slug plugin slug.
127 + *
128 + * @return array|mixed|object
129 + */
130 + public function call_plugin_api( $slug ) {
131 + include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
132 +
133 + $call_api = get_transient( 'ti_plugin_info_' . $slug );
134 +
135 + if ( false === $call_api ) {
136 + $call_api = plugins_api(
137 + 'plugin_information',
138 + array(
139 + 'slug' => $slug,
140 + 'fields' => array(
141 + 'downloaded' => false,
142 + 'rating' => false,
143 + 'description' => false,
144 + 'short_description' => true,
145 + 'donate_link' => false,
146 + 'tags' => false,
147 + 'sections' => true,
148 + 'homepage' => true,
149 + 'added' => false,
150 + 'last_updated' => false,
151 + 'compatibility' => false,
152 + 'tested' => false,
153 + 'requires' => false,
154 + 'downloadlink' => false,
155 + 'icons' => true,
156 + 'banners' => true,
157 + ),
158 + )
159 + );
160 + set_transient( 'ti_plugin_info_' . $slug, $call_api, 30 * MINUTE_IN_SECONDS );
161 + }
162 +
163 + return $call_api;
164 + }
165 +
166 + /**
167 + * Get the plugin status.
168 + *
169 + * @param string $plugin Plugin slug.
170 + *
171 + * @return bool
172 + */
173 + public function is_plugin_installed( $plugin ) {
174 + if ( ! isset( $this->plugin_paths[ $plugin ] ) ) {
175 + return false;
176 + }
177 +
178 + if ( file_exists( WP_CONTENT_DIR . '/plugins/' . $this->plugin_paths[ $plugin ] ) ) {
179 + return true;
180 + }
181 +
182 + return false;
183 + }
184 +
185 + /**
186 + * Get plugin activation link.
187 + *
188 + * @param string $slug The plugin slug.
189 + *
190 + * @return string
191 + */
192 + public function get_plugin_activation_link( $slug ) {
193 + $reference_key = $slug === 'otter-blocks' ? 'reference_key' : 'optimole_reference_key';
194 + $plugin = isset( $this->plugin_paths[ $slug ] ) ? $this->plugin_paths[ $slug ] : $slug . '/' . $slug . '.php';
195 +
196 + return add_query_arg(
197 + array(
198 + 'plugin_status' => 'all',
199 + 'paged' => '1',
200 + 'action' => 'activate',
201 + $reference_key => $this->product->get_key(),
202 + 'plugin' => rawurlencode( $plugin ),
203 + '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $plugin ),
204 + ),
205 + admin_url( 'plugins.php' )
206 + );
207 + }
208 +
209 + /**
210 + * Checks if a plugin is active.
211 + *
212 + * @param string $plugin plugin slug.
213 + *
214 + * @return bool
215 + */
216 + public function is_plugin_active( $plugin ) {
217 + include_once ABSPATH . 'wp-admin/includes/plugin.php';
218 +
219 + $plugin = isset( $this->plugin_paths[ $plugin ] ) ? $this->plugin_paths[ $plugin ] : $plugin . '/' . $plugin . '.php';
220 +
221 + return is_plugin_active( $plugin );
65 222 }
66 223 }