PluginProbe
Elementor Website Builder – more than just a page builder / 4.2.0
Elementor Website Builder – more than just a page builder v4.2.0
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
elementor / modules / apps / admin-apps-page.php

admin-apps-page.php in Elementor Website Builder – more than just a page builder 4.2.0, at modules/apps/admin-apps-page.php

185 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Modules\Apps;
3
4 use Elementor\Core\Isolation\Wordpress_Adapter;
5 use Elementor\Core\Isolation\Plugin_Status_Adapter;
6 use Elementor\Includes\EditorAssetsAPI;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 class Admin_Apps_Page {
13
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 public static function render() {
21 ?>
22 <div class="wrap e-a-apps">
23
24 <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>
27 <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 </p>
29 </div>
30
31 <div class="e-a-list">
32 <?php self::render_plugins_list(); ?>
33 </div>
34 <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>
36 </div>
37 </div>
38 <?php
39 }
40
41 private static function render_plugins_list() {
42 $plugins = self::get_plugins();
43
44 foreach ( $plugins as $plugin ) {
45 self::render_plugin_item( $plugin );
46 }
47 }
48
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
58 $apps = static::get_remote_apps();
59
60 return static::filter_apps( $apps );
61 }
62
63 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 ] );
69
70 return $editor_assets_api->get_assets_data();
71 }
72
73 private static function filter_apps( $apps ) {
74 $filtered_apps = [];
75
76 foreach ( $apps as $app ) {
77 if ( static::is_wporg_app( $app ) ) {
78 $app = static::filter_wporg_app( $app );
79 }
80
81 if ( static::is_ecom_app( $app ) ) {
82 $app = static::filter_ecom_app( $app );
83 }
84
85 if ( empty( $app ) ) {
86 continue;
87 }
88
89 $filtered_apps[] = $app;
90 }
91
92 return $filtered_apps;
93 }
94
95 private static function is_wporg_app( $app ) {
96 return isset( $app['type'] ) && 'wporg' === $app['type'];
97 }
98
99 private static function filter_wporg_app( $app ) {
100 if ( self::$wordpress_adapter->is_plugin_active( $app['file_path'] ) ) {
101 return null;
102 }
103
104 if ( self::$plugin_status_adapter->is_plugin_installed( $app['file_path'] ) ) {
105 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'] );
108 } else {
109 $app['action_label'] = esc_html__( 'Cannot Activate', 'elementor' );
110 $app['action_url'] = '#';
111 }
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 } else {
116 $app['action_label'] = esc_html__( 'Cannot Install', 'elementor' );
117 $app['action_url'] = '#';
118 }
119
120 return $app;
121 }
122
123 private static function is_ecom_app( $app ) {
124 return isset( $app['type'] ) && 'ecom' === $app['type'];
125 }
126
127 private static function filter_ecom_app( $app ) {
128 if ( self::$wordpress_adapter->is_plugin_active( $app['file_path'] ) ) {
129 return null;
130 }
131
132 if ( ! self::$plugin_status_adapter->is_plugin_installed( $app['file_path'] ) ) {
133 return $app;
134 }
135
136 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'] );
139 } else {
140 $app['action_label'] = esc_html__( 'Cannot Activate', 'elementor' );
141 $app['action_url'] = '#';
142 }
143
144 $app['target'] = '_self';
145
146 return $app;
147 }
148
149 private static function get_images_url() {
150 return ELEMENTOR_URL . 'modules/apps/images/';
151 }
152
153 private static function is_elementor_pro_installed() {
154 return defined( 'ELEMENTOR_PRO_VERSION' );
155 }
156
157 private static function render_plugin_item( $plugin ) {
158 ?>
159 <div class="e-a-item"<?php echo ! empty( $plugin['file_path'] ) ? ' data-plugin="' . esc_attr( $plugin['file_path'] ) . '"' : ''; ?>>
160 <div class="e-a-heading">
161 <img class="e-a-img" src="<?php echo esc_url( $plugin['image'] ); ?>" alt="<?php echo esc_attr( $plugin['name'] ); ?>">
162 <?php if ( ! empty( $plugin['badge'] ) ) : ?>
163 <span class="e-a-badge"><?php echo esc_html( $plugin['badge'] ); ?></span>
164 <?php endif; ?>
165 </div>
166 <h3 class="e-a-title"><?php echo esc_html( $plugin['name'] ); ?></h3>
167 <p class="e-a-author"><?php esc_html_e( 'By', 'elementor' ); ?> <a href="<?php echo esc_url( $plugin['author_url'] ); ?>" target="_blank"><?php echo esc_html( $plugin['author'] ); ?></a></p>
168 <div class="e-a-desc">
169 <p><?php echo esc_html( $plugin['description'] ); ?></p>
170 <?php if ( ! empty( $plugin['offering'] ) ) : ?>
171 <p class="e-a-offering"><?php echo esc_html( $plugin['offering'] ); ?></p>
172 <?php endif; ?>
173 </div>
174
175 <p class="e-a-actions">
176 <?php if ( ! empty( $plugin['learn_more_url'] ) ) : ?>
177 <a class="e-a-learn-more" href="<?php echo esc_url( $plugin['learn_more_url'] ); ?>" target="_blank"><?php echo esc_html__( 'Learn More', 'elementor' ); ?></a>
178 <?php endif; ?>
179 <a href="<?php echo esc_url( $plugin['action_url'] ); ?>" class="e-btn e-accent" target="<?php echo isset( $plugin['target'] ) ? esc_attr( $plugin['target'] ) : '_blank'; ?>"><?php echo esc_html( $plugin['action_label'] ); ?></a>
180 </p>
181 </div>
182 <?php
183 }
184 }
185