← All changes
|
vendor/codeinwp/themeisle-sdk/src/Common/Abstract_module.php
+61
-7
4.2.5
→
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', |
| @@ -39,13 +40,23 @@ | ||
| 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', |
| 42 | 43 | 'wpcf7-redirect' => 'wpcf7-redirect/wpcf7-redirect.php', |
| 44 | + 'anti-spam' => 'anti-spam/anti-spam.php', | |
| 43 | 45 | 'wp-full-stripe-free' => 'wp-full-stripe-free/wp-full-stripe.php', |
| 44 | 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', | |
| 45 | 49 | ]; |
| 46 | 50 | |
| 47 | 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 | + /** | |
| 48 | 59 | * Product which use the module. |
| 49 | 60 | * |
| 50 | 61 | * @var Product $product Product object. |
| 51 | 62 | */ |
| @@ -139,9 +150,10 @@ | ||
| 139 | 150 | array( |
| 140 | 151 | 'slug' => $slug, |
| 141 | 152 | 'fields' => array( |
| 142 | 153 | 'downloaded' => false, |
| 143 | - 'rating' => false, | |
| 154 | + 'rating' => true, | |
| 155 | + 'ratings' => true, | |
| 144 | 156 | 'description' => false, |
| 145 | 157 | 'short_description' => true, |
| 146 | 158 | 'donate_link' => false, |
| 147 | 159 | 'tags' => false, |
| @@ -171,13 +183,11 @@ | ||
| 171 | 183 | * |
| 172 | 184 | * @return bool |
| 173 | 185 | */ |
| 174 | 186 | public function is_plugin_installed( $plugin ) { |
| 175 | - if ( ! isset( $this->plugin_paths[ $plugin ] ) ) { | |
| 176 | - return false; | |
| 177 | - } | |
| 187 | + $plugin_file = $this->resolve_plugin_main_file( $plugin ); | |
| 178 | 188 | |
| 179 | - if ( file_exists( WP_CONTENT_DIR . '/plugins/' . $this->plugin_paths[ $plugin ] ) ) { | |
| 189 | + if ( file_exists( WP_CONTENT_DIR . '/plugins/' . $plugin_file ) ) { | |
| 180 | 190 | return true; |
| 181 | 191 | } |
| 182 | 192 | |
| 183 | 193 | return false; |
| @@ -191,9 +201,9 @@ | ||
| 191 | 201 | * @return string |
| 192 | 202 | */ |
| 193 | 203 | public function get_plugin_activation_link( $slug ) { |
| 194 | 204 | $reference_key = $slug === 'otter-blocks' ? 'reference_key' : 'optimole_reference_key'; |
| 195 | - $plugin = isset( $this->plugin_paths[ $slug ] ) ? $this->plugin_paths[ $slug ] : $slug . '/' . $slug . '.php'; | |
| 205 | + $plugin = $this->resolve_plugin_main_file( $slug ); | |
| 196 | 206 | |
| 197 | 207 | return add_query_arg( |
| 198 | 208 | array( |
| 199 | 209 | 'plugin_status' => 'all', |
| @@ -216,11 +226,55 @@ | ||
| 216 | 226 | */ |
| 217 | 227 | public function is_plugin_active( $plugin ) { |
| 218 | 228 | include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 219 | 229 | |
| 220 | - $plugin = isset( $this->plugin_paths[ $plugin ] ) ? $this->plugin_paths[ $plugin ] : $plugin . '/' . $plugin . '.php'; | |
| 230 | + $plugin = $this->resolve_plugin_main_file( $plugin ); | |
| 221 | 231 | |
| 222 | 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 ]; | |
| 223 | 277 | } |
| 224 | 278 | |
| 225 | 279 | /** |
| 226 | 280 | * Get the current date. |