PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.0.2
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.0.2
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
← All changes | includes/API/Dependencies.php +7 -124 3.1.103.0.2 View file →
@@ -15,23 +15,15 @@
15 15
16 16 private $endpoint = 'dependencies';
17 17 public $query = 'dependencies{ id, name, icon, plugin_file, plugin_original_slug, is_pro, link }';
18 18
19 - public function __construct() {
20 - parent::__construct();
21 -
22 - if(!empty($_GET['disable_redirect'])) {
23 - add_filter('wp_redirect', '__return_false', 999);
24 - }
25 - }
26 -
27 19 public function permission_check( WP_REST_Request $request ) {
28 20 $this->request = $request;
29 - // $_route = $request->get_route();
21 + $_route = $request->get_route();
30 22
31 - // if( $_route === '/templately/v1/dependencies/install' && ! Helper::current_user_can( 'install_plugins' ) ) {
32 - // return Helper::error('invalid_permission', __( 'Sorry, you do not have permission to install a plugin.', 'templately' ), 'dependencies/install', 403 );
33 - // }
23 + if( $_route === '/templately/v1/dependencies/install' && ! current_user_can( 'install_plugins' ) ) {
24 + return $this->error('invalid_permission', __( 'Sorry, you do not have permission to install a plugin.', 'templately' ), 'dependencies/install', 403 );
25 + }
34 26
35 27 return true;
36 28 }
37 29
@@ -36,10 +28,8 @@
36 28 }
37 29
38 30 public function register_routes() {
39 31 $this->get( $this->endpoint, [ $this, 'get_dependencies' ] );
40 - $this->get( $this->endpoint . '/plugins', [ $this, 'get_plugins' ] );
41 - $this->get( $this->endpoint . '/themes', [ $this, 'get_themes' ] );
42 32 $this->post( $this->endpoint . '/check', [$this, 'check_dependencies'] );
43 33 $this->post( $this->endpoint . '/install', [$this, 'install_dependencies'] );
44 34 }
45 35
@@ -86,15 +76,14 @@
86 76
87 77 $_inactive_plugins = [];
88 78 $_plugins = Helper::get_plugins();
89 79
90 - if( $platform === 'elementor' ) {
80 + if( ! Helper::is_plugin_active( 'elementor/elementor.php' ) && $platform === 'elementor' ) {
91 81 $elementor_plugin = new stdClass();
92 82 $elementor_plugin->name = __( 'Elementor', 'templately' );
93 83 $elementor_plugin->plugin_file = 'elementor/elementor.php';
94 84 $elementor_plugin->slug = 'elementor';
95 85 $elementor_plugin->is_pro = false;
96 - $elementor_plugin->is_active = Helper::is_plugin_active( 'elementor/elementor.php' );
97 86
98 87 $_inactive_plugins[] = $elementor_plugin;
99 88 }
100 89
@@ -104,14 +93,12 @@
104 93 continue;
105 94 }
106 95
107 96 $dependency = ( object ) $dependency;
108 - if ( is_null( $dependency->plugin_file ) ) {
97 + if ( is_null( $dependency->plugin_file ) || Helper::is_plugin_active( $dependency->plugin_file ) ) {
109 98 continue;
110 99 }
111 100
112 - $dependency->is_active = Helper::is_plugin_active( $dependency->plugin_file );
113 -
114 101 if( isset( $dependency->plugin_original_slug ) ) {
115 102 $dependency->slug = $dependency->plugin_original_slug;
116 103 unset( $dependency->plugin_original_slug );
117 104 }
@@ -140,111 +127,7 @@
140 127 '/install',
141 128 400
142 129 );
143 130 }
144 - $installed = Installer::get_instance()->install( $requirements );
145 - if(empty($installed['success'])){
146 - return $this->error($installed['code'], $installed['message'], 'dependencies/install', 403 );
147 - }
148 - return $installed;
131 + return Installer::get_instance()->install( $requirements );
149 132 }
150 -
151 - public function get_plugins() {
152 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
153 -
154 - $plugins = array();
155 -
156 - foreach ( get_plugins() as $file => $data ) {
157 - // if ( is_wp_error( $this->check_read_permission( $file ) ) ) {
158 - // continue;
159 - // }
160 -
161 - $data = array(
162 - 'plugin' => substr( $file, 0, - 4 ),
163 - 'status' => $this->get_plugin_status( $file ),
164 - 'name' => $data['Name'],
165 - 'plugin_uri' => $data['PluginURI'],
166 - 'author' => $data['Author'],
167 - 'author_uri' => $data['AuthorURI'],
168 - 'description' => array(
169 - 'raw' => $data['Description'],
170 - 'rendered' => $data['Description'],
171 - ),
172 - 'version' => $data['Version'],
173 - 'network_only' => $data['Network'],
174 - 'requires_wp' => $data['RequiresWP'],
175 - 'requires_php' => $data['RequiresPHP'],
176 - 'textdomain' => $data['TextDomain'],
177 - );
178 -
179 - $plugins[] = $data;
180 - }
181 -
182 - return new \WP_REST_Response( $plugins );
183 - }
184 -
185 - public function get_themes() {
186 - $themes = array();
187 -
188 - $active_themes = wp_get_themes();
189 - $current_theme = wp_get_theme();
190 -
191 - foreach ( $active_themes as $theme_name => $theme ) {
192 - $data = array(
193 - 'status' => $theme->get_stylesheet() === $current_theme->get_stylesheet() ? 'active' : 'inactive',
194 - 'template' => $theme->get_template(),
195 - 'stylesheet' => $theme->get_stylesheet(),
196 - );
197 -
198 -
199 - $plain_field_mappings = array(
200 - 'requires_php' => 'RequiresPHP',
201 - 'requires_wp' => 'RequiresWP',
202 - 'textdomain' => 'TextDomain',
203 - 'version' => 'Version',
204 - );
205 -
206 - foreach ( $plain_field_mappings as $field => $header ) {
207 - $data[ $field ] = $theme->get( $header );
208 - }
209 -
210 - $rich_field_mappings = array(
211 - 'author' => 'Author',
212 - 'author_uri' => 'AuthorURI',
213 - 'description' => 'Description',
214 - 'name' => 'Name',
215 - 'tags' => 'Tags',
216 - 'theme_uri' => 'ThemeURI',
217 - );
218 -
219 - foreach ( $rich_field_mappings as $field => $header ) {
220 - $data[ $field ]['raw'] = $theme->display( $header, false, true );
221 - $data[ $field ]['rendered'] = $theme->display( $header );
222 - }
223 -
224 - $themes[] = $data;
225 - }
226 -
227 - return new \WP_REST_Response( $themes );
228 - }
229 -
230 - /**
231 - * Get's the activation status for a plugin.
232 - *
233 - * @since 5.5.0
234 - *
235 - * @param string $plugin The plugin file to check.
236 - * @return string Either 'active' or 'inactive'.
237 - */
238 - protected function get_plugin_status( $plugin ) {
239 - if ( is_plugin_active_for_network( $plugin ) ) {
240 - return 'active';
241 - }
242 -
243 - if ( is_plugin_active( $plugin ) ) {
244 - return 'active';
245 - }
246 -
247 - return 'inactive';
248 - }
249 -
250 133 }