PluginProbe
Elementor Website Builder – more than just a page builder / 3.19.2
Elementor Website Builder – more than just a page builder v3.19.2
4.3.0-beta3 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 All 452 releases
← All changes | modules/apps/admin-apps-page.php +54 -44 4.2.23.19.2 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
@@ -10,21 +6,15 @@
10 6 }
11 7
12 8 class Admin_Apps_Page {
13 9
14 - const APPS_URL = 'https://assets.elementor.com/apps/v1/apps.json';
15 -
16 - private static ?Wordpress_Adapter $wordpress_adapter = null;
17 -
18 - private static ?Plugin_Status_Adapter $plugin_status_adapter = null;
19 -
20 10 public static function render() {
21 11 ?>
22 12 <div class="wrap e-a-apps">
23 13
24 14 <div class="e-a-page-title">
25 - <h2><?php echo esc_html__( 'Popular Add-ons, New Possibilities.', 'elementor' ); ?></h2>
26 - <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>
15 + <h2><?php echo esc_html__( 'Popular Apps, New Possibilities.', 'elementor' ); ?></h2>
16 + <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 17 <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 18 </p>
29 19 </div>
30 20
@@ -31,9 +21,9 @@
31 21 <div class="e-a-list">
32 22 <?php self::render_plugins_list(); ?>
33 23 </div>
34 24 <div class="e-a-page-footer">
35 - <p>*<?php echo esc_html__( 'Please note that certain tools and services on this page are developed by third-party companies and are not part of Elementor\'s suite of products or support. Before using them, we recommend independently evaluating them. Additionally, when clicking on their action buttons, you may be redirected to an external website.', 'elementor' ); ?></p>
25 + <p><?php echo esc_html__( 'Please note that certain services on this page are developed by third-party companies. When you click on the their action button, you may be redirected to an external website.', 'elementor' ); ?></p>
36 26 </div>
37 27 </div>
38 28 <?php
39 29 }
@@ -45,17 +35,9 @@
45 35 self::render_plugin_item( $plugin );
46 36 }
47 37 }
48 38
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 -
39 + private static function get_plugins() : array {
58 40 $apps = static::get_remote_apps();
59 41
60 42 return static::filter_apps( $apps );
61 43 }
@@ -60,15 +42,21 @@
60 42 return static::filter_apps( $apps );
61 43 }
62 44
63 45 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 - ] );
46 + $apps = wp_remote_get( 'https://assets.elementor.com/apps/v1/apps.json' );
69 47
70 - return $editor_assets_api->get_assets_data();
48 + if ( is_wp_error( $apps ) ) {
49 + return [];
50 + }
51 +
52 + $apps = json_decode( wp_remote_retrieve_body( $apps ), true );
53 +
54 + if ( empty( $apps['apps'] ) || ! is_array( $apps['apps'] ) ) {
55 + return [];
56 + }
57 +
58 + return $apps['apps'];
71 59 }
72 60
73 61 private static function filter_apps( $apps ) {
74 62 $filtered_apps = [];
@@ -96,26 +84,28 @@
96 84 return isset( $app['type'] ) && 'wporg' === $app['type'];
97 85 }
98 86
99 87 private static function filter_wporg_app( $app ) {
100 - if ( self::$wordpress_adapter->is_plugin_active( $app['file_path'] ) ) {
88 + if ( static::is_plugin_activated( $app['file_path'] ) ) {
101 89 return null;
102 90 }
103 91
104 - if ( self::$plugin_status_adapter->is_plugin_installed( $app['file_path'] ) ) {
92 + if ( static::is_plugin_installed( $app['file_path'] ) ) {
105 93 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'] );
94 + $app['action_label'] = 'Activate';
95 + $app['action_url'] = static::get_activate_plugin_url( $app['file_path'] );
108 96 } else {
109 - $app['action_label'] = esc_html__( 'Cannot Activate', 'elementor' );
97 + $app['action_label'] = 'Cannot Activate';
110 98 $app['action_url'] = '#';
111 99 }
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 100 } else {
116 - $app['action_label'] = esc_html__( 'Cannot Install', 'elementor' );
117 - $app['action_url'] = '#';
101 + if ( current_user_can( 'install_plugins' ) ) {
102 + $app['action_label'] = 'Install';
103 + $app['action_url'] = static::get_install_plugin_url( $app['file_path'] );
104 + } else {
105 + $app['action_label'] = 'Cannot Install';
106 + $app['action_url'] = '#';
107 + }
118 108 }
119 109
120 110 return $app;
121 111 }
@@ -124,21 +114,21 @@
124 114 return isset( $app['type'] ) && 'ecom' === $app['type'];
125 115 }
126 116
127 117 private static function filter_ecom_app( $app ) {
128 - if ( self::$wordpress_adapter->is_plugin_active( $app['file_path'] ) ) {
118 + if ( static::is_plugin_activated( $app['file_path'] ) ) {
129 119 return null;
130 120 }
131 121
132 - if ( ! self::$plugin_status_adapter->is_plugin_installed( $app['file_path'] ) ) {
122 + if ( ! static::is_plugin_installed( $app['file_path'] ) ) {
133 123 return $app;
134 124 }
135 125
136 126 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'] );
127 + $app['action_label'] = 'Activate';
128 + $app['action_url'] = static::get_activate_plugin_url( $app['file_path'] );
139 129 } else {
140 - $app['action_label'] = esc_html__( 'Cannot Activate', 'elementor' );
130 + $app['action_label'] = 'Cannot Activate';
141 131 $app['action_url'] = '#';
142 132 }
143 133
144 134 $app['target'] = '_self';
@@ -153,11 +143,31 @@
153 143 private static function is_elementor_pro_installed() {
154 144 return defined( 'ELEMENTOR_PRO_VERSION' );
155 145 }
156 146
147 + private static function is_plugin_installed( $file_path ) {
148 + $installed_plugins = get_plugins();
149 +
150 + return isset( $installed_plugins[ $file_path ] );
151 + }
152 +
153 + private static function is_plugin_activated( $file_path ) {
154 + return is_plugin_active( $file_path );
155 + }
156 +
157 + private static function get_activate_plugin_url( $file_path ) {
158 + 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 );
159 + }
160 +
161 + private static function get_install_plugin_url( $file_path ) {
162 + $slug = dirname( $file_path );
163 +
164 + return wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $slug ), 'install-plugin_' . $slug );
165 + }
166 +
157 167 private static function render_plugin_item( $plugin ) {
158 168 ?>
159 - <div class="e-a-item"<?php echo ! empty( $plugin['file_path'] ) ? ' data-plugin="' . esc_attr( $plugin['file_path'] ) . '"' : ''; ?>>
169 + <div class="e-a-item">
160 170 <div class="e-a-heading">
161 171 <img class="e-a-img" src="<?php echo esc_url( $plugin['image'] ); ?>" alt="<?php echo esc_attr( $plugin['name'] ); ?>">
162 172 <?php if ( ! empty( $plugin['badge'] ) ) : ?>
163 173 <span class="e-a-badge"><?php echo esc_html( $plugin['badge'] ); ?></span>