PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.0-dev2
Elementor Website Builder – more than just a page builder v3.32.0-dev2
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 / core / utils / assets-config-provider.php

assets-config-provider.php in Elementor Website Builder – more than just a page builder 3.32.0-dev2, at core/utils/assets-config-provider.php

80 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Utils;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 class Assets_Config_Provider extends Collection {
9 /**
10 * @var callable|null
11 */
12 private $path_resolver = null;
13
14 /**
15 * @param callable $path_resolver
16 *
17 * @return $this
18 */
19 public function set_path_resolver( callable $path_resolver ) {
20 $this->path_resolver = $path_resolver;
21
22 return $this;
23 }
24
25 /**
26 * Load asset config from a file into the collection.
27 *
28 * @param $key
29 * @param $path
30 *
31 * @return $this
32 */
33 public function load( $key, $path = null ) {
34 if ( ! $path && $this->path_resolver ) {
35 $path_resolver_callback = $this->path_resolver;
36
37 $path = $path_resolver_callback( $key );
38 }
39
40 if ( ! $path || ! file_exists( $path ) ) {
41 return $this;
42 }
43
44 $config = require $path;
45
46 if ( ! $this->is_valid_handle( $config ) ) {
47 return $this;
48 }
49
50 $this->items[ $key ] = [
51 'handle' => $config['handle'],
52 'deps' => $this->is_valid_deps( $config ) ? $config['deps'] : [],
53 ];
54
55 return $this;
56 }
57
58 /**
59 * Check that the handle property in the config is a valid.
60 *
61 * @param $config
62 *
63 * @return bool
64 */
65 private function is_valid_handle( $config ) {
66 return ! empty( $config['handle'] ) && is_string( $config['handle'] );
67 }
68
69 /**
70 * Check that the deps property in the config is a valid.
71 *
72 * @param $config
73 *
74 * @return bool
75 */
76 private function is_valid_deps( $config ) {
77 return isset( $config['deps'] ) && is_array( $config['deps'] );
78 }
79 }
80