PluginProbe ʕ •ᴥ•ʔ
Essential Addons for Elementor – Popular Elementor Templates & Widgets / 6.6.9
Essential Addons for Elementor – Popular Elementor Templates & Widgets v6.6.9
6.6.9 6.6.8 6.6.7 6.6.6 6.6.5 6.6.4 6.6.3 5.7.3 5.7.4 5.8.0 5.8.1 5.8.10 5.8.11 5.8.12 5.8.13 5.8.14 5.8.15 5.8.16 5.8.18 5.8.2 5.8.3 5.8.4 5.8.5 5.8.6 5.8.7 5.8.8 5.8.9 5.9.0 5.9.1 5.9.10 5.9.11 5.9.12 5.9.13 5.9.14 5.9.15 5.9.16 5.9.17 5.9.18 5.9.19 5.9.2 5.9.20 5.9.21 5.9.22 5.9.23 5.9.24 5.9.25 5.9.26 5.9.27 5.9.3 5.9.4 5.9.5 5.9.6 5.9.7 5.9.8 5.9.9 6.0.0 6.0.1 6.0.10 6.0.11 6.0.12 6.0.13 6.0.14 6.0.15 6.0.2 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 6.0.8 6.0.9 6.1.0 6.1.1 6.1.10 6.1.11 trunk 6.1.12 1.0.0 6.1.13 1.0.1 6.1.14 1.1.0 6.1.15 2.0 6.1.17 2.1 6.1.18 2.10.0 6.1.19 2.10.1 6.1.2 2.10.2 6.1.20 2.10.3 6.1.3 2.10.4 6.1.4 2.10.5 6.1.5 2.2.0 6.1.6 2.2.1 6.1.7 2.2.2 6.1.8 2.2.3 6.1.9 2.2.4 6.2.0 2.2.5 6.2.1 2.3.0 6.2.2 2.3.1 6.2.3 2.4.0 6.2.4 2.4.1 6.3.0 2.4.2 6.3.1 2.4.3 6.3.2 2.5.0 6.3.3 2.6.0 6.4.0 2.7.0 6.5.0 2.7.1 6.5.1 2.7.10 6.5.10 2.7.11 6.5.11 2.7.2 6.5.12 2.7.3 6.5.13 2.7.4 6.5.2 2.7.5 6.5.3 2.7.6 6.5.4 2.7.7 6.5.5 2.7.8 6.5.6 2.7.9 6.5.7 2.8.0 6.5.8 2.8.1 6.5.9 2.8.2 6.6.0 2.8.3 6.6.1 2.8.4 6.6.2 2.8.5 2.8.6 2.8.7 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.4.1 3.1.5 3.2.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.5.0 3.5.1 3.5.2 3.6.0 3.6.1 3.6.2 3.7.0 3.7.1 3.7.2 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.8 4.3.9 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.9.0 4.9.1 4.9.2 4.9.3 4.9.4 4.9.5 4.9.6 4.9.7 5.0.0 5.0.1 5.0.10 5.0.11 5.0.12 5.0.13 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.0.9 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.2.0 5.2.1 5.2.2 5.2.3 5.2.4 5.3.0 5.3.1 5.3.2 5.4.6 5.5.5 5.6.5 5.7.2
essential-addons-for-elementor-lite / includes / Classes / WPDeveloper_Plugin_Installer.php
essential-addons-for-elementor-lite / includes / Classes Last commit date
AllTraits.php 1 year ago Asset_Builder.php 9 months ago Bootstrap.php 2 weeks ago Compatibility_Support.php 2 months ago Elements_Manager.php 7 months ago Helper.php 1 month ago Migration.php 5 months ago Plugin_Usage_Tracker.php 5 months ago WPDeveloper_Core_Installer.php 5 months ago WPDeveloper_Notice.php 2 months ago WPDeveloper_Plugin_Installer.php 5 months ago WPDeveloper_Setup_Wizard.php 2 months ago index.php 3 years ago
WPDeveloper_Plugin_Installer.php
245 lines
1 <?php
2 namespace Essential_Addons_Elementor\Classes;
3
4 if (!defined('ABSPATH')) {
5 exit;
6 } // Exit if accessed directly.
7
8 use \WP_Error;
9
10 class WPDeveloper_Plugin_Installer
11 {
12 public function __construct() {
13 add_action( 'wp_ajax_wpdeveloper_auto_active_even_not_installed', [ $this, 'ajax_auto_active_even_not_installed' ] );
14 add_action( 'wp_ajax_wpdeveloper_install_plugin', [ $this, 'ajax_install_plugin' ] );
15 add_action( 'wp_ajax_wpdeveloper_upgrade_plugin', [ $this, 'ajax_upgrade_plugin' ] );
16 add_action( 'wp_ajax_wpdeveloper_activate_plugin', [ $this, 'ajax_activate_plugin' ] );
17 add_action( 'wp_ajax_wpdeveloper_deactivate_plugin', [ $this, 'ajax_deactivate_plugin' ] );
18 }
19
20 /**
21 * get_local_plugin_data
22 *
23 * @param mixed $basename
24 * @return array|false
25 */
26 public function get_local_plugin_data($basename = '')
27 {
28 if (empty($basename)) {
29 return false;
30 }
31
32 if (!function_exists('get_plugins')) {
33 include_once ABSPATH . 'wp-admin/includes/plugin.php';
34 }
35
36 $plugins = get_plugins();
37
38 if (!isset($plugins[$basename])) {
39 return false;
40 }
41
42 return $plugins[$basename];
43 }
44
45 /**
46 * get_remote_plugin_data
47 *
48 * @param mixed $slug
49 * @return mixed array|WP_Error
50 */
51 public function get_remote_plugin_data($slug = '')
52 {
53 if (empty($slug)) {
54 return new WP_Error('empty_arg', __('Argument should not be empty.', 'essential-addons-for-elementor-lite'));
55 }
56
57 $response = wp_remote_post(
58 'http://api.wordpress.org/plugins/info/1.0/',
59 [
60 'body' => [
61 'action' => 'plugin_information',
62 'request' => serialize((object) [
63 'slug' => $slug,
64 'fields' => [
65 'version' => false,
66 ],
67 ]),
68 ],
69 ]
70 );
71
72 if (is_wp_error($response)) {
73 return $response;
74 }
75
76 return unserialize(wp_remote_retrieve_body($response));
77 }
78
79 /**
80 * install_plugin
81 *
82 * @param mixed $slug
83 * @param bool $active
84 * @return mixed bool|WP_Error
85 */
86 public function install_plugin($slug = '', $active = true)
87 {
88 if (empty($slug)) {
89 return new WP_Error('empty_arg', __('Argument should not be empty.', 'essential-addons-for-elementor-lite'));
90 }
91
92 include_once ABSPATH . 'wp-admin/includes/file.php';
93 include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
94 include_once ABSPATH . 'wp-admin/includes/class-automatic-upgrader-skin.php';
95
96 $plugin_data = $this->get_remote_plugin_data($slug);
97
98 if (is_wp_error($plugin_data)) {
99 return $plugin_data;
100 }
101
102 $upgrader = new \Plugin_Upgrader(new \Automatic_Upgrader_Skin());
103
104 // install plugin
105 $install = $upgrader->install($plugin_data->download_link);
106
107 if (is_wp_error($install)) {
108 return $install;
109 }
110
111 // activate plugin
112 if ($install === true && $active) {
113 $active = activate_plugin($upgrader->plugin_info(), '', false, true);
114
115 if (is_wp_error($active)) {
116 return $active;
117 }
118
119 return $active === null;
120 }
121
122 return $install;
123 }
124
125 /**
126 * upgrade_plugin
127 *
128 * @param mixed $basename
129 * @return mixed bool|WP_Error
130 */
131 public function upgrade_plugin($basename = '')
132 {
133 if (empty($slug)) {
134 return new WP_Error('empty_arg', __('Argument should not be empty.', 'essential-addons-for-elementor-lite'));
135 }
136
137 include_once ABSPATH . 'wp-admin/includes/file.php';
138 include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
139 include_once ABSPATH . 'wp-admin/includes/class-automatic-upgrader-skin.php';
140
141 $upgrader = new \Plugin_Upgrader(new \Automatic_Upgrader_Skin());
142
143 // upgrade plugin
144 return $upgrader->upgrade($basename);
145 }
146
147 public function ajax_install_plugin()
148 {
149 check_ajax_referer('essential-addons-elementor', 'security');
150
151 if(!current_user_can( 'install_plugins' )) {
152 wp_send_json_error(__('you are not allowed to do this action', 'essential-addons-for-elementor-lite'));
153 }
154
155 $slug = isset( $_POST['slug'] ) ? sanitize_text_field( wp_unslash( $_POST['slug'] ) ) : '';
156 $result = $this->install_plugin( $slug );
157
158 if ( isset( $_POST['promotype'], $_POST['slug'] ) ) {
159 $promotype = sanitize_text_field( wp_unslash( $_POST['promotype'] ) );
160 $slug = sanitize_text_field( wp_unslash( $_POST['slug'] ) );
161
162 $remote_urls = [
163 'quick-setup' => [
164 'essential-blocks' => 'https://essential-addons.com/essential-blocks-install-quick-setup',
165 'templately' => 'https://essential-addons.com/templately-install-quick-setup',
166 ]
167 ];
168
169 if ( isset( $remote_urls[ $promotype ][ $slug ] ) ) {
170 wp_remote_get( $remote_urls[ $promotype ][ $slug ] );
171 }
172 }
173
174 if ( is_wp_error( $result ) ) {
175 wp_send_json_error( $result->get_error_message() );
176 }
177
178 wp_send_json_success(__('Plugin is installed successfully!', 'essential-addons-for-elementor-lite'));
179 }
180
181 public function ajax_upgrade_plugin()
182 {
183 check_ajax_referer('essential-addons-elementor', 'security');
184 //check user capabilities
185 if(!current_user_can( 'update_plugins' )) {
186 wp_send_json_error(__('you are not allowed to do this action', 'essential-addons-for-elementor-lite'));
187 }
188
189 $basename = isset( $_POST['basename'] ) ? sanitize_text_field( wp_unslash( $_POST['basename'] ) ) : '';
190 $result = $this->upgrade_plugin( $basename );
191
192 if (is_wp_error($result)) {
193 wp_send_json_error($result->get_error_message());
194 }
195
196 wp_send_json_success(__('Plugin is updated successfully!', 'essential-addons-for-elementor-lite'));
197 }
198
199 public function ajax_activate_plugin()
200 {
201 check_ajax_referer('essential-addons-elementor', 'security');
202
203 //check user capabilities
204 if(!current_user_can( 'activate_plugins' )) {
205 wp_send_json_error(__('you are not allowed to do this action', 'essential-addons-for-elementor-lite'));
206 }
207
208 $basename = isset( $_POST['basename'] ) ? sanitize_text_field( wp_unslash( $_POST['basename'] ) ) : '';
209 $result = activate_plugin( $basename, '', false, true );
210
211 if ( is_wp_error( $result ) ) {
212 wp_send_json_error( $result->get_error_message() );
213 }
214
215 if ($result === false) {
216 wp_send_json_error(__('Plugin couldn\'t be activated.', 'essential-addons-for-elementor-lite'));
217 }
218 wp_send_json_success(__('Plugin is activated successfully!', 'essential-addons-for-elementor-lite'));
219 }
220
221 public function ajax_deactivate_plugin() {
222 check_ajax_referer( 'essential-addons-elementor', 'security' );
223
224 //check user capabilities
225 if ( ! current_user_can( 'activate_plugins' ) ) {
226 wp_send_json_error( __( 'you are not allowed to do this action', 'essential-addons-for-elementor-lite' ) );
227 }
228
229 $basename = isset( $_POST['basename'] ) ? sanitize_text_field( wp_unslash( $_POST['basename'] ) ) : '';
230 deactivate_plugins( $basename, true );
231
232 wp_send_json_success( __( 'Plugin is deactivated successfully!', 'essential-addons-for-elementor-lite' ) );
233 }
234
235 public function ajax_auto_active_even_not_installed() {
236 check_ajax_referer( 'essential-addons-elementor', 'security' );
237
238 if ( !empty( $_POST['basename'] ) && $this->get_local_plugin_data( sanitize_text_field( wp_unslash( $_POST['basename'] ) ) ) === false ) {
239 $this->ajax_install_plugin();
240 } else {
241 $this->ajax_activate_plugin();
242 }
243 }
244 }
245