PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.4.9
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.4.9
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 +64 -86 3.7.53.4.9 View file →
@@ -6,9 +6,8 @@
6 6 use Templately\Utils\Helper;
7 7 use Templately\Utils\Database;
8 8 use Templately\Utils\Installer;
9 9 use WP_REST_Request;
10 -use Templately\Utils\Caching;
11 10
12 11 use function current_user_can;
13 12
14 13
@@ -14,9 +13,8 @@
14 13
15 14 class Dependencies extends API {
16 15
17 16 private $endpoint = 'dependencies';
18 -
19 17 public $query = 'dependencies{ id, name, icon, plugin_file, plugin_original_slug, is_pro, link }';
20 18
21 19 public function __construct() {
22 20 parent::__construct();
@@ -27,21 +25,13 @@
27 25 }
28 26
29 27 public function permission_check( WP_REST_Request $request ) {
30 28 $this->request = $request;
29 + // $_route = $request->get_route();
31 30
32 - // Installing reaches beyond template content, so it does not ride the
33 - // `delete_posts` base gate the read routes are happy with. Installer::install()
34 - // checks `install_plugins` / `activate_plugins` per plugin as well; this is the
35 - // front gate, so the route cannot be probed at all without the capability.
36 - if ( $request->get_route() === '/templately/v1/dependencies/install' && ! Helper::current_user_can( 'install_plugins' ) ) {
37 - return $this->error(
38 - 'invalid_permission',
39 - __( 'Sorry, you do not have permission to install a plugin.', 'templately' ),
40 - 'dependencies/install',
41 - rest_authorization_required_code()
42 - );
43 - }
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 + // }
44 34
45 35 return true;
46 36 }
47 37
@@ -244,84 +234,76 @@
244 234 }
245 235 }
246 236 }
247 237
248 - if ( $this->should_offer_caching() ) {
249 - $caching = Caching::dependency_entry();
250 - Caching::mark_offered();
238 + // Category-based plugins
239 + $included_categories = array(
240 + 'blog-magazine',
241 + 'construction',
242 + 'ecommerce',
243 + 'education',
244 + 'entertainment',
245 + 'fashion-lifestyle',
246 + 'features-services',
247 + 'food-restaurant',
248 + 'marketing',
249 + 'miscellaneous',
250 + 'multipurpose',
251 + 'nft-cryptocurrency',
252 + 'non-profit',
253 + 'technology',
254 + 'travel',
255 + );
251 256
252 - $new_dependency_list[] = $caching;
253 - $new_required_plugins[] = $caching;
254 - } else {
255 - // Category-based plugins
256 - $included_categories = array(
257 - 'blog-magazine',
258 - 'construction',
259 - 'ecommerce',
260 - 'education',
261 - 'entertainment',
262 - 'fashion-lifestyle',
263 - 'features-services',
264 - 'food-restaurant',
265 - 'marketing',
266 - 'miscellaneous',
267 - 'multipurpose',
268 - 'nft-cryptocurrency',
269 - 'non-profit',
270 - 'technology',
271 - 'travel',
272 - );
273 -
274 - $is_any_category_included = false;
275 - if ( ! empty( $categories ) && is_array( $categories ) ) {
276 - foreach ( $categories as $category ) {
277 - if ( isset( $category['slug'] ) && in_array( $category['slug'], $included_categories, true ) ) {
278 - $is_any_category_included = true;
279 - break;
280 - }
257 + $is_any_category_included = false;
258 + if ( ! empty( $categories ) && is_array( $categories ) ) {
259 + foreach ( $categories as $category ) {
260 + if ( isset( $category['slug'] ) && in_array( $category['slug'], $included_categories, true ) ) {
261 + $is_any_category_included = true;
262 + break;
281 263 }
282 264 }
265 + }
283 266
284 - if ( $is_any_category_included ) {
285 - $nx_plugin = $this->find_plugin_by_name( $all_plugins, 'notificationx/notificationx' );
286 - $notificationx = array(
287 - 'name' => 'NotificationX',
288 - 'icon' => 'https://ps.w.org/notificationx/assets/icon-256x256.gif?rev=2783824',
289 - 'plugin_file' => 'notificationx/notificationx.php',
290 - 'plugin_original_slug' => 'notificationx',
291 - 'is_pro' => false,
292 - 'installed' => $nx_plugin ? ( $nx_plugin['status'] === 'active' ) : false,
293 - 'link' => 'https://wordpress.org/plugins/notificationx/',
294 - );
295 - $new_dependency_list[] = $notificationx;
296 - $new_required_plugins[] = $notificationx;
297 - }
267 + if ( $is_any_category_included ) {
268 + $nx_plugin = $this->find_plugin_by_name( $all_plugins, 'notificationx/notificationx' );
269 + $notificationx = array(
270 + 'name' => 'NotificationX',
271 + 'icon' => 'https://ps.w.org/notificationx/assets/icon-256x256.gif?rev=2783824',
272 + 'plugin_file' => 'notificationx/notificationx.php',
273 + 'plugin_original_slug' => 'notificationx',
274 + 'is_pro' => false,
275 + 'installed' => $nx_plugin ? ( $nx_plugin['status'] === 'active' ) : false,
276 + 'link' => 'https://wordpress.org/plugins/notificationx/',
277 + );
278 + $new_dependency_list[] = $notificationx;
279 + $new_required_plugins[] = $notificationx;
280 + }
298 281
299 - // EmbedPress for blog-magazine category
300 - $ep_is_any_category_included = false;
301 - if ( ! empty( $categories ) && is_array( $categories ) ) {
302 - foreach ( $categories as $category ) {
303 - if ( isset( $category['slug'] ) && $category['slug'] === 'blog-magazine' ) {
304 - $ep_is_any_category_included = true;
305 - break;
306 - }
282 + // EmbedPress for blog-magazine category
283 + $ep_is_any_category_included = false;
284 + if ( ! empty( $categories ) && is_array( $categories ) ) {
285 + foreach ( $categories as $category ) {
286 + if ( isset( $category['slug'] ) && $category['slug'] === 'blog-magazine' ) {
287 + $ep_is_any_category_included = true;
288 + break;
307 289 }
308 290 }
291 + }
309 292
310 - if ( $ep_is_any_category_included ) {
311 - $ep_plugin = $this->find_plugin_by_name( $all_plugins, 'embedpress/embedpress' );
312 - $embed_press = array(
313 - 'name' => 'EmbedPress',
314 - 'icon' => 'https://ps.w.org/embedpress/assets/icon-256x256.gif?rev=2783824',
315 - 'plugin_file' => 'embedpress/embedpress.php',
316 - 'plugin_original_slug' => 'embedpress',
317 - 'is_pro' => false,
318 - 'installed' => $ep_plugin ? ( $ep_plugin['status'] === 'active' ) : false,
319 - 'link' => 'https://wordpress.org/plugins/embedpress/',
320 - );
321 - $new_dependency_list[] = $embed_press;
322 - $new_required_plugins[] = $embed_press;
323 - }
293 + if ( $ep_is_any_category_included ) {
294 + $ep_plugin = $this->find_plugin_by_name( $all_plugins, 'embedpress/embedpress' );
295 + $embed_press = array(
296 + 'name' => 'EmbedPress',
297 + 'icon' => 'https://ps.w.org/embedpress/assets/icon-256x256.gif?rev=2783824',
298 + 'plugin_file' => 'embedpress/embedpress.php',
299 + 'plugin_original_slug' => 'embedpress',
300 + 'is_pro' => false,
301 + 'installed' => $ep_plugin ? ( $ep_plugin['status'] === 'active' ) : false,
302 + 'link' => 'https://wordpress.org/plugins/embedpress/',
303 + );
304 + $new_dependency_list[] = $embed_press;
305 + $new_required_plugins[] = $embed_press;
324 306 }
325 307
326 308 return new \WP_REST_Response( array(
327 309 'dependencyList' => $new_dependency_list,
@@ -326,12 +308,8 @@
326 308 return new \WP_REST_Response( array(
327 309 'dependencyList' => $new_dependency_list,
328 310 'requiredPlugins' => $new_required_plugins
329 311 ) );
330 - }
331 -
332 - protected function should_offer_caching(): bool {
333 - return Caching::should_offer();
334 312 }
335 313
336 314 /**
337 315 * Helper method to find a plugin by its name/slug