| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | namespace Elementor\Modules\Apps; |
| 3 | 3 | |
| 4 | 4 | use Elementor\Core\Isolation\Wordpress_Adapter; |
| 5 | 5 | use Elementor\Core\Isolation\Plugin_Status_Adapter; |
| 6 | -use Elementor\Includes\EditorAssetsAPI; | |
| 6 | +use Elementor\Plugin; | |
| 7 | 7 | |
| 8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | 9 | exit; // Exit if accessed directly. |
| 10 | 10 | } |
| @@ -46,9 +46,13 @@ | ||
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | private static function get_plugins(): array { |
| 50 | - if ( ! self::$wordpress_adapter ) { | |
| 50 | + $container = Plugin::$instance->elementor_container(); | |
| 51 | + | |
| 52 | + if ( $container->has( Wordpress_Adapter::class ) ) { | |
| 53 | + self::$wordpress_adapter = $container->get( Wordpress_Adapter::class ); | |
| 54 | + } else if ( ! self::$wordpress_adapter ) { | |
| 51 | 55 | self::$wordpress_adapter = new Wordpress_Adapter(); |
| 52 | 56 | } |
| 53 | 57 | |
| 54 | 58 | if ( ! self::$plugin_status_adapter ) { |
| @@ -60,15 +64,21 @@ | ||
| 60 | 64 | return static::filter_apps( $apps ); |
| 61 | 65 | } |
| 62 | 66 | |
| 63 | 67 | private static function get_remote_apps() { |
| 64 | - $editor_assets_api = new EditorAssetsAPI( [ | |
| 65 | - EditorAssetsAPI::ASSETS_DATA_URL => static::APPS_URL, | |
| 66 | - EditorAssetsAPI::ASSETS_DATA_TRANSIENT_KEY => '_elementor_apps_data', | |
| 67 | - EditorAssetsAPI::ASSETS_DATA_KEY => 'apps', | |
| 68 | - ] ); | |
| 68 | + $apps = wp_remote_get( static::APPS_URL ); | |
| 69 | 69 | |
| 70 | - return $editor_assets_api->get_assets_data(); | |
| 70 | + if ( is_wp_error( $apps ) ) { | |
| 71 | + return []; | |
| 72 | + } | |
| 73 | + | |
| 74 | + $apps = json_decode( wp_remote_retrieve_body( $apps ), true ); | |
| 75 | + | |
| 76 | + if ( empty( $apps['apps'] ) || ! is_array( $apps['apps'] ) ) { | |
| 77 | + return []; | |
| 78 | + } | |
| 79 | + | |
| 80 | + return $apps['apps']; | |
| 71 | 81 | } |
| 72 | 82 | |
| 73 | 83 | private static function filter_apps( $apps ) { |
| 74 | 84 | $filtered_apps = []; |