PluginProbe
Elementor Website Builder – more than just a page builder / 3.20.0-dev3
Elementor Website Builder – more than just a page builder v3.20.0-dev3
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | modules/apps/admin-apps-page.php +52 -40 4.2.0-dev23.20.0-dev3 View file →
@@ -1,11 +1,7 @@
1 1 <?php
2 2 namespace Elementor\Modules\Apps;
3 3
4 -use Elementor\Core\Isolation\Wordpress_Adapter;
5 -use Elementor\Core\Isolation\Plugin_Status_Adapter;
6 -use Elementor\Includes\EditorAssetsAPI;
7 -
8 4 if ( ! defined( 'ABSPATH' ) ) {
9 5 exit; // Exit if accessed directly.
10 6 }
11 7
@@ -12,18 +8,14 @@
12 8 class Admin_Apps_Page {
13 9
14 10 const APPS_URL = 'https://assets.elementor.com/apps/v1/apps.json';
15 11
16 - private static ?Wordpress_Adapter $wordpress_adapter = null;
17 -
18 - private static ?Plugin_Status_Adapter $plugin_status_adapter = null;
19 -
20 12 public static function render() {
21 13 ?>
22 14 <div class="wrap e-a-apps">
23 15
24 16 <div class="e-a-page-title">
25 - <h2><?php echo esc_html__( 'Popular Add-ons, New Possibilities.', 'elementor' ); ?></h2>
17 + <h2><?php echo esc_html__( 'Popular Addons, New Possibilities.', 'elementor' ); ?></h2>
26 18 <p><?php echo esc_html__( 'Boost your web-creation process with add-ons, plugins, and more tools specially selected to unleash your creativity, increase productivity, and enhance your Elementor-powered website.', 'elementor' ); ?>*<br>
27 19 <a href="https://go.elementor.com/wp-dash-apps-about-apps-page/" target="_blank"><?php echo esc_html__( 'Learn more about this page.', 'elementor' ); ?></a>
28 20 </p>
29 21 </div>
@@ -45,17 +37,9 @@
45 37 self::render_plugin_item( $plugin );
46 38 }
47 39 }
48 40
49 - private static function get_plugins(): array {
50 - if ( ! self::$wordpress_adapter ) {
51 - self::$wordpress_adapter = new Wordpress_Adapter();
52 - }
53 -
54 - if ( ! self::$plugin_status_adapter ) {
55 - self::$plugin_status_adapter = new Plugin_Status_Adapter( self::$wordpress_adapter );
56 - }
57 -
41 + private static function get_plugins() : array {
58 42 $apps = static::get_remote_apps();
59 43
60 44 return static::filter_apps( $apps );
61 45 }
@@ -60,15 +44,21 @@
60 44 return static::filter_apps( $apps );
61 45 }
62 46
63 47 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 - ] );
48 + $apps = wp_remote_get( static::APPS_URL );
69 49
70 - return $editor_assets_api->get_assets_data();
50 + if ( is_wp_error( $apps ) ) {
51 + return [];
52 + }
53 +
54 + $apps = json_decode( wp_remote_retrieve_body( $apps ), true );
55 +
56 + if ( empty( $apps['apps'] ) || ! is_array( $apps['apps'] ) ) {
57 + return [];
58 + }
59 +
60 + return $apps['apps'];
71 61 }
72 62
73 63 private static function filter_apps( $apps ) {
74 64 $filtered_apps = [];
@@ -96,26 +86,28 @@
96 86 return isset( $app['type'] ) && 'wporg' === $app['type'];
97 87 }
98 88
99 89 private static function filter_wporg_app( $app ) {
100 - if ( self::$wordpress_adapter->is_plugin_active( $app['file_path'] ) ) {
90 + if ( static::is_plugin_activated( $app['file_path'] ) ) {
101 91 return null;
102 92 }
103 93
104 - if ( self::$plugin_status_adapter->is_plugin_installed( $app['file_path'] ) ) {
94 + if ( static::is_plugin_installed( $app['file_path'] ) ) {
105 95 if ( current_user_can( 'activate_plugins' ) ) {
106 - $app['action_label'] = esc_html__( 'Activate', 'elementor' );
107 - $app['action_url'] = self::$plugin_status_adapter->get_activate_plugin_url( $app['file_path'] );
96 + $app['action_label'] = 'Activate';
97 + $app['action_url'] = static::get_activate_plugin_url( $app['file_path'] );
108 98 } else {
109 - $app['action_label'] = esc_html__( 'Cannot Activate', 'elementor' );
99 + $app['action_label'] = 'Cannot Activate';
110 100 $app['action_url'] = '#';
111 101 }
112 - } elseif ( current_user_can( 'install_plugins' ) ) {
113 - $app['action_label'] = esc_html__( 'Install', 'elementor' );
114 - $app['action_url'] = self::$plugin_status_adapter->get_install_plugin_url( $app['file_path'] );
115 102 } else {
116 - $app['action_label'] = esc_html__( 'Cannot Install', 'elementor' );
117 - $app['action_url'] = '#';
103 + if ( current_user_can( 'install_plugins' ) ) {
104 + $app['action_label'] = 'Install';
105 + $app['action_url'] = static::get_install_plugin_url( $app['file_path'] );
106 + } else {
107 + $app['action_label'] = 'Cannot Install';
108 + $app['action_url'] = '#';
109 + }
118 110 }
119 111
120 112 return $app;
121 113 }
@@ -124,21 +116,21 @@
124 116 return isset( $app['type'] ) && 'ecom' === $app['type'];
125 117 }
126 118
127 119 private static function filter_ecom_app( $app ) {
128 - if ( self::$wordpress_adapter->is_plugin_active( $app['file_path'] ) ) {
120 + if ( static::is_plugin_activated( $app['file_path'] ) ) {
129 121 return null;
130 122 }
131 123
132 - if ( ! self::$plugin_status_adapter->is_plugin_installed( $app['file_path'] ) ) {
124 + if ( ! static::is_plugin_installed( $app['file_path'] ) ) {
133 125 return $app;
134 126 }
135 127
136 128 if ( current_user_can( 'activate_plugins' ) ) {
137 - $app['action_label'] = esc_html__( 'Activate', 'elementor' );
138 - $app['action_url'] = self::$plugin_status_adapter->get_activate_plugin_url( $app['file_path'] );
129 + $app['action_label'] = 'Activate';
130 + $app['action_url'] = static::get_activate_plugin_url( $app['file_path'] );
139 131 } else {
140 - $app['action_label'] = esc_html__( 'Cannot Activate', 'elementor' );
132 + $app['action_label'] = 'Cannot Activate';
141 133 $app['action_url'] = '#';
142 134 }
143 135
144 136 $app['target'] = '_self';
@@ -153,11 +145,31 @@
153 145 private static function is_elementor_pro_installed() {
154 146 return defined( 'ELEMENTOR_PRO_VERSION' );
155 147 }
156 148
149 + private static function is_plugin_installed( $file_path ) {
150 + $installed_plugins = get_plugins();
151 +
152 + return isset( $installed_plugins[ $file_path ] );
153 + }
154 +
155 + private static function is_plugin_activated( $file_path ) {
156 + return is_plugin_active( $file_path );
157 + }
158 +
159 + private static function get_activate_plugin_url( $file_path ) {
160 + return wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $file_path . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $file_path );
161 + }
162 +
163 + private static function get_install_plugin_url( $file_path ) {
164 + $slug = dirname( $file_path );
165 +
166 + return wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $slug ), 'install-plugin_' . $slug );
167 + }
168 +
157 169 private static function render_plugin_item( $plugin ) {
158 170 ?>
159 - <div class="e-a-item"<?php echo ! empty( $plugin['file_path'] ) ? ' data-plugin="' . esc_attr( $plugin['file_path'] ) . '"' : ''; ?>>
171 + <div class="e-a-item">
160 172 <div class="e-a-heading">
161 173 <img class="e-a-img" src="<?php echo esc_url( $plugin['image'] ); ?>" alt="<?php echo esc_attr( $plugin['name'] ); ?>">
162 174 <?php if ( ! empty( $plugin['badge'] ) ) : ?>
163 175 <span class="e-a-badge"><?php echo esc_html( $plugin['badge'] ); ?></span>