PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / trunk
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization vtrunk
4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 2.5.5 2.5.6 2.5.7 3.0.0 3.0.1 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.11.0 3.11.1 3.11.2 3.11.3 3.12.0 All 135 releases
← All changes | vendor/codeinwp/themeisle-sdk/src/Common/Abstract_module.php +74 -8 3.11.2 → trunk View file →
@@ -32,8 +32,9 @@
32 32 'otter-blocks' => 'otter-blocks/otter-blocks.php',
33 33 'optimole-wp' => 'optimole-wp/optimole-wp.php',
34 34 'tweet-old-post' => 'tweet-old-post/tweet-old-post.php',
35 35 'feedzy-rss-feeds' => 'feedzy-rss-feeds/feedzy-rss-feed.php',
36 + 'insert-php' => 'insert-php/insert_php.php',
36 37 'woocommerce-product-addon' => 'woocommerce-product-addon/woocommerce-product-addon.php',
37 38 'visualizer' => 'visualizer/index.php',
38 39 'wp-landing-kit' => 'wp-landing-kit/wp-landing-kit.php',
39 40 'multiple-pages-generator-by-porthas' => 'multiple-pages-generator-by-porthas/porthas-multi-pages-generator.php',
@@ -38,11 +39,24 @@
38 39 'wp-landing-kit' => 'wp-landing-kit/wp-landing-kit.php',
39 40 'multiple-pages-generator-by-porthas' => 'multiple-pages-generator-by-porthas/porthas-multi-pages-generator.php',
40 41 'sparks-for-woocommerce' => 'sparks-for-woocommerce/sparks-for-woocommerce.php',
41 42 'templates-patterns-collection' => 'templates-patterns-collection/templates-patterns-collection.php',
43 + 'wpcf7-redirect' => 'wpcf7-redirect/wpcf7-redirect.php',
44 + 'anti-spam' => 'anti-spam/anti-spam.php',
45 + 'wp-full-stripe-free' => 'wp-full-stripe-free/wp-full-stripe.php',
46 + 'learning-management-system' => 'learning-management-system/lms.php',
47 + 'wp-cloudflare-page-cache' => 'wp-cloudflare-page-cache/wp-cloudflare-super-page-cache.php',
48 + 'easy-mcp-ai' => 'easy-mcp-ai/easy-mcp-ai.php',
42 49 ];
43 50
44 51 /**
52 + * Runtime-resolved plugin paths.
53 + *
54 + * @var string[] $resolved_plugin_paths Plugin main file path by slug.
55 + */
56 + private $resolved_plugin_paths = [];
57 +
58 + /**
45 59 * Product which use the module.
46 60 *
47 61 * @var Product $product Product object.
48 62 */
@@ -110,9 +124,9 @@
110 124 * $themeisle_sdk_max_path can point to the theme when the theme version is higher.
111 125 * hence we also need to check that the path does not point to the theme else this will break the URL.
112 126 * References: https://github.com/Codeinwp/neve-pro-addon/issues/2403
113 127 */
114 - if ( $this->product->is_plugin() && false === strpos( $themeisle_sdk_max_path, get_template_directory() ) ) {
128 + if ( ( $this->product->is_plugin() || $this->product->is_theme() ) && false === strpos( $themeisle_sdk_max_path, get_template_directory() ) ) {
115 129 return plugins_url( '/', $themeisle_sdk_max_path . '/themeisle-sdk/' );
116 130 };
117 131
118 132 return get_template_directory_uri() . '/vendor/codeinwp/themeisle-sdk/';
@@ -136,9 +150,10 @@
136 150 array(
137 151 'slug' => $slug,
138 152 'fields' => array(
139 153 'downloaded' => false,
140 - 'rating' => false,
154 + 'rating' => true,
155 + 'ratings' => true,
141 156 'description' => false,
142 157 'short_description' => true,
143 158 'donate_link' => false,
144 159 'tags' => false,
@@ -168,13 +183,11 @@
168 183 *
169 184 * @return bool
170 185 */
171 186 public function is_plugin_installed( $plugin ) {
172 - if ( ! isset( $this->plugin_paths[ $plugin ] ) ) {
173 - return false;
174 - }
187 + $plugin_file = $this->resolve_plugin_main_file( $plugin );
175 188
176 - if ( file_exists( WP_CONTENT_DIR . '/plugins/' . $this->plugin_paths[ $plugin ] ) ) {
189 + if ( file_exists( WP_CONTENT_DIR . '/plugins/' . $plugin_file ) ) {
177 190 return true;
178 191 }
179 192
180 193 return false;
@@ -188,9 +201,9 @@
188 201 * @return string
189 202 */
190 203 public function get_plugin_activation_link( $slug ) {
191 204 $reference_key = $slug === 'otter-blocks' ? 'reference_key' : 'optimole_reference_key';
192 - $plugin = isset( $this->plugin_paths[ $slug ] ) ? $this->plugin_paths[ $slug ] : $slug . '/' . $slug . '.php';
205 + $plugin = $this->resolve_plugin_main_file( $slug );
193 206
194 207 return add_query_arg(
195 208 array(
196 209 'plugin_status' => 'all',
@@ -213,9 +226,62 @@
213 226 */
214 227 public function is_plugin_active( $plugin ) {
215 228 include_once ABSPATH . 'wp-admin/includes/plugin.php';
216 229
217 - $plugin = isset( $this->plugin_paths[ $plugin ] ) ? $this->plugin_paths[ $plugin ] : $plugin . '/' . $plugin . '.php';
230 + $plugin = $this->resolve_plugin_main_file( $plugin );
218 231
219 232 return is_plugin_active( $plugin );
233 + }
234 +
235 + /**
236 + * Resolve a plugin's main file path by slug.
237 + *
238 + * @param string $slug Plugin slug.
239 + *
240 + * @return string
241 + */
242 + private function resolve_plugin_main_file( $slug ) {
243 + if ( isset( $this->resolved_plugin_paths[ $slug ] ) ) {
244 + return $this->resolved_plugin_paths[ $slug ];
245 + }
246 +
247 + if ( isset( $this->plugin_paths[ $slug ] ) ) {
248 + $this->resolved_plugin_paths[ $slug ] = $this->plugin_paths[ $slug ];
249 + return $this->resolved_plugin_paths[ $slug ];
250 + }
251 +
252 + $default_plugin_file = $slug . '/' . $slug . '.php';
253 +
254 + if ( file_exists( WP_CONTENT_DIR . '/plugins/' . $default_plugin_file ) ) {
255 + $this->resolved_plugin_paths[ $slug ] = $default_plugin_file;
256 + return $this->resolved_plugin_paths[ $slug ];
257 + }
258 +
259 + include_once ABSPATH . 'wp-admin/includes/plugin.php';
260 +
261 + if ( function_exists( 'get_plugins' ) ) {
262 + $plugins = get_plugins( '/' . $slug );
263 +
264 + if ( ! empty( $plugins ) ) {
265 + $plugin_files = array_keys( $plugins );
266 + $plugin_file = $slug . '/' . reset( $plugin_files );
267 +
268 + $this->resolved_plugin_paths[ $slug ] = $plugin_file;
269 +
270 + return $this->resolved_plugin_paths[ $slug ];
271 + }
272 + }
273 +
274 + $this->resolved_plugin_paths[ $slug ] = $default_plugin_file;
275 +
276 + return $this->resolved_plugin_paths[ $slug ];
277 + }
278 +
279 + /**
280 + * Get the current date.
281 + *
282 + * @return \DateTime The date time.
283 + */
284 + public function get_current_date() {
285 + return apply_filters( 'themeisle_sdk_current_date', new \DateTime( 'now' ) );
220 286 }
221 287 }