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