@@ -25,122 +25,122 @@ |
||
25 | 25 | */ |
26 | 26 | class RouteMatchSpecificationManager |
27 | 27 | { |
28 | - /** |
|
29 | - * @var CollectionInterface[]|RouteMatchSpecificationInterface[] $specifications |
|
30 | - */ |
|
31 | - private $specifications; |
|
28 | + /** |
|
29 | + * @var CollectionInterface[]|RouteMatchSpecificationInterface[] $specifications |
|
30 | + */ |
|
31 | + private $specifications; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @var RouteMatchSpecificationFactory $specifications_factory |
|
35 | - */ |
|
36 | - private $specifications_factory; |
|
33 | + /** |
|
34 | + * @var RouteMatchSpecificationFactory $specifications_factory |
|
35 | + */ |
|
36 | + private $specifications_factory; |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * RouteMatchSpecificationManager constructor. |
|
41 | - * |
|
42 | - * @param RouteMatchSpecificationCollection $specifications |
|
43 | - * @param RouteMatchSpecificationFactory $specifications_factory |
|
44 | - */ |
|
45 | - public function __construct( |
|
46 | - RouteMatchSpecificationCollection $specifications, |
|
47 | - RouteMatchSpecificationFactory $specifications_factory |
|
48 | - ) { |
|
49 | - $this->specifications = $specifications; |
|
50 | - $this->specifications_factory = $specifications_factory; |
|
51 | - add_action('AHEE__EE_System__loadRouteMatchSpecifications', array($this, 'initialize')); |
|
52 | - } |
|
39 | + /** |
|
40 | + * RouteMatchSpecificationManager constructor. |
|
41 | + * |
|
42 | + * @param RouteMatchSpecificationCollection $specifications |
|
43 | + * @param RouteMatchSpecificationFactory $specifications_factory |
|
44 | + */ |
|
45 | + public function __construct( |
|
46 | + RouteMatchSpecificationCollection $specifications, |
|
47 | + RouteMatchSpecificationFactory $specifications_factory |
|
48 | + ) { |
|
49 | + $this->specifications = $specifications; |
|
50 | + $this->specifications_factory = $specifications_factory; |
|
51 | + add_action('AHEE__EE_System__loadRouteMatchSpecifications', array($this, 'initialize')); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Perform any early setup required for block editors to functions |
|
57 | - * |
|
58 | - * @return void |
|
59 | - * @throws CollectionLoaderException |
|
60 | - * @throws CollectionDetailsException |
|
61 | - */ |
|
62 | - public function initialize() |
|
63 | - { |
|
64 | - $this->populateSpecificationCollection(); |
|
65 | - } |
|
55 | + /** |
|
56 | + * Perform any early setup required for block editors to functions |
|
57 | + * |
|
58 | + * @return void |
|
59 | + * @throws CollectionLoaderException |
|
60 | + * @throws CollectionDetailsException |
|
61 | + */ |
|
62 | + public function initialize() |
|
63 | + { |
|
64 | + $this->populateSpecificationCollection(); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * @return CollectionInterface|RouteMatchSpecificationInterface[] |
|
70 | - * @throws CollectionLoaderException |
|
71 | - * @throws CollectionDetailsException |
|
72 | - * @since 4.9.71.p |
|
73 | - */ |
|
74 | - private function populateSpecificationCollection() |
|
75 | - { |
|
76 | - $loader = new CollectionLoader( |
|
77 | - new CollectionDetails( |
|
78 | - // collection name |
|
79 | - RouteMatchSpecificationCollection::COLLECTION_NAME, |
|
80 | - // collection interface |
|
81 | - 'EventEspresso\core\domain\entities\route_match\RouteMatchSpecificationInterface', |
|
82 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
83 | - apply_filters( |
|
84 | - 'FHEE__EventEspresso_core_services_route_match_RouteMatchSpecificationManager__populateSpecificationCollection__collection_FQCNs', |
|
85 | - array( |
|
86 | - 'EventEspresso\core\domain\entities\route_match\specifications\admin', |
|
87 | - 'EventEspresso\core\domain\entities\route_match\specifications\frontend', |
|
88 | - ) |
|
89 | - ), |
|
90 | - // filepaths to classes to add |
|
91 | - array(), |
|
92 | - // file mask to use if parsing folder for files to add |
|
93 | - '', |
|
94 | - // what to use as identifier for collection entities |
|
95 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
96 | - CollectionDetails::ID_CLASS_NAME |
|
97 | - ), |
|
98 | - $this->specifications, |
|
99 | - null, |
|
100 | - $this->specifications_factory |
|
101 | - ); |
|
102 | - return $loader->getCollection(); |
|
103 | - } |
|
68 | + /** |
|
69 | + * @return CollectionInterface|RouteMatchSpecificationInterface[] |
|
70 | + * @throws CollectionLoaderException |
|
71 | + * @throws CollectionDetailsException |
|
72 | + * @since 4.9.71.p |
|
73 | + */ |
|
74 | + private function populateSpecificationCollection() |
|
75 | + { |
|
76 | + $loader = new CollectionLoader( |
|
77 | + new CollectionDetails( |
|
78 | + // collection name |
|
79 | + RouteMatchSpecificationCollection::COLLECTION_NAME, |
|
80 | + // collection interface |
|
81 | + 'EventEspresso\core\domain\entities\route_match\RouteMatchSpecificationInterface', |
|
82 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
83 | + apply_filters( |
|
84 | + 'FHEE__EventEspresso_core_services_route_match_RouteMatchSpecificationManager__populateSpecificationCollection__collection_FQCNs', |
|
85 | + array( |
|
86 | + 'EventEspresso\core\domain\entities\route_match\specifications\admin', |
|
87 | + 'EventEspresso\core\domain\entities\route_match\specifications\frontend', |
|
88 | + ) |
|
89 | + ), |
|
90 | + // filepaths to classes to add |
|
91 | + array(), |
|
92 | + // file mask to use if parsing folder for files to add |
|
93 | + '', |
|
94 | + // what to use as identifier for collection entities |
|
95 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
96 | + CollectionDetails::ID_CLASS_NAME |
|
97 | + ), |
|
98 | + $this->specifications, |
|
99 | + null, |
|
100 | + $this->specifications_factory |
|
101 | + ); |
|
102 | + return $loader->getCollection(); |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * Given the FQCN for a RouteMatchSpecification, will return true if the current request matches |
|
108 | - * |
|
109 | - * @param string $routeMatchSpecificationFqcn fully qualified class name |
|
110 | - * @return bool |
|
111 | - * @throws InvalidClassException |
|
112 | - * @since 4.9.71.p |
|
113 | - */ |
|
114 | - public function routeMatchesCurrentRequest($routeMatchSpecificationFqcn) |
|
115 | - { |
|
116 | - /** @var RouteMatchSpecificationInterface $specification */ |
|
117 | - $specification = $this->specifications->get($routeMatchSpecificationFqcn); |
|
118 | - if (! $specification instanceof $routeMatchSpecificationFqcn) { |
|
119 | - throw new InvalidClassException($routeMatchSpecificationFqcn); |
|
120 | - } |
|
121 | - return $specification->isMatchingRoute(); |
|
122 | - } |
|
106 | + /** |
|
107 | + * Given the FQCN for a RouteMatchSpecification, will return true if the current request matches |
|
108 | + * |
|
109 | + * @param string $routeMatchSpecificationFqcn fully qualified class name |
|
110 | + * @return bool |
|
111 | + * @throws InvalidClassException |
|
112 | + * @since 4.9.71.p |
|
113 | + */ |
|
114 | + public function routeMatchesCurrentRequest($routeMatchSpecificationFqcn) |
|
115 | + { |
|
116 | + /** @var RouteMatchSpecificationInterface $specification */ |
|
117 | + $specification = $this->specifications->get($routeMatchSpecificationFqcn); |
|
118 | + if (! $specification instanceof $routeMatchSpecificationFqcn) { |
|
119 | + throw new InvalidClassException($routeMatchSpecificationFqcn); |
|
120 | + } |
|
121 | + return $specification->isMatchingRoute(); |
|
122 | + } |
|
123 | 123 | |
124 | 124 | |
125 | - /** |
|
126 | - * Handy method for development that returns |
|
127 | - * a list of existing RouteMatchSpecification classes |
|
128 | - * matching the current request that can be used to identify it. |
|
129 | - * If no matches are returned (or nothing acceptable) |
|
130 | - * then create a new one that better matches your requirements. |
|
131 | - * |
|
132 | - * @return array |
|
133 | - * @since 4.9.71.p |
|
134 | - */ |
|
135 | - public function findRouteMatchSpecificationsMatchingCurrentRequest() |
|
136 | - { |
|
137 | - $matches = array(); |
|
138 | - foreach ($this->specifications as $specification) { |
|
139 | - /** @var RouteMatchSpecificationInterface $specification */ |
|
140 | - if ($specification->isMatchingRoute()) { |
|
141 | - $matches[] = get_class($specification); |
|
142 | - } |
|
143 | - } |
|
144 | - return $matches; |
|
145 | - } |
|
125 | + /** |
|
126 | + * Handy method for development that returns |
|
127 | + * a list of existing RouteMatchSpecification classes |
|
128 | + * matching the current request that can be used to identify it. |
|
129 | + * If no matches are returned (or nothing acceptable) |
|
130 | + * then create a new one that better matches your requirements. |
|
131 | + * |
|
132 | + * @return array |
|
133 | + * @since 4.9.71.p |
|
134 | + */ |
|
135 | + public function findRouteMatchSpecificationsMatchingCurrentRequest() |
|
136 | + { |
|
137 | + $matches = array(); |
|
138 | + foreach ($this->specifications as $specification) { |
|
139 | + /** @var RouteMatchSpecificationInterface $specification */ |
|
140 | + if ($specification->isMatchingRoute()) { |
|
141 | + $matches[] = get_class($specification); |
|
142 | + } |
|
143 | + } |
|
144 | + return $matches; |
|
145 | + } |
|
146 | 146 | } |
@@ -24,46 +24,46 @@ |
||
24 | 24 | class RouteMatchSpecificationFactory extends FactoryWithDependencyResolver |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * RouteMatchSpecificationFactory constructor |
|
29 | - * |
|
30 | - * @param RouteMatchSpecificationDependencyResolver $dependency_resolver |
|
31 | - * @param LoaderInterface $loader |
|
32 | - */ |
|
33 | - public function __construct(RouteMatchSpecificationDependencyResolver $dependency_resolver, LoaderInterface $loader) |
|
34 | - { |
|
35 | - parent::__construct($dependency_resolver, $loader); |
|
36 | - } |
|
27 | + /** |
|
28 | + * RouteMatchSpecificationFactory constructor |
|
29 | + * |
|
30 | + * @param RouteMatchSpecificationDependencyResolver $dependency_resolver |
|
31 | + * @param LoaderInterface $loader |
|
32 | + */ |
|
33 | + public function __construct(RouteMatchSpecificationDependencyResolver $dependency_resolver, LoaderInterface $loader) |
|
34 | + { |
|
35 | + parent::__construct($dependency_resolver, $loader); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param $fqcn |
|
40 | - * @return RouteMatchSpecification |
|
41 | - * @throws InvalidDataTypeException |
|
42 | - * @throws ReflectionException |
|
43 | - * @since 4.9.71.p |
|
44 | - */ |
|
45 | - public function createNewRouteMatchSpecification($fqcn) |
|
46 | - { |
|
47 | - $this->dependencyResolver()->resolveDependenciesForClass($fqcn); |
|
48 | - return $this->loader()->getShared($fqcn); |
|
49 | - } |
|
38 | + /** |
|
39 | + * @param $fqcn |
|
40 | + * @return RouteMatchSpecification |
|
41 | + * @throws InvalidDataTypeException |
|
42 | + * @throws ReflectionException |
|
43 | + * @since 4.9.71.p |
|
44 | + */ |
|
45 | + public function createNewRouteMatchSpecification($fqcn) |
|
46 | + { |
|
47 | + $this->dependencyResolver()->resolveDependenciesForClass($fqcn); |
|
48 | + return $this->loader()->getShared($fqcn); |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * @param $fqcn |
|
54 | - * @return RouteMatchSpecification |
|
55 | - * @throws InvalidArgumentException |
|
56 | - * @throws InvalidDataTypeException |
|
57 | - * @throws InvalidInterfaceException |
|
58 | - * @throws ReflectionException |
|
59 | - * @since 4.9.71.p |
|
60 | - */ |
|
61 | - public static function create($fqcn) |
|
62 | - { |
|
63 | - /** @var RouteMatchSpecificationFactory $specification_factory */ |
|
64 | - $specification_factory = LoaderFactory::getLoader()->getShared( |
|
65 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' |
|
66 | - ); |
|
67 | - return $specification_factory->createNewRouteMatchSpecification($fqcn); |
|
68 | - } |
|
52 | + /** |
|
53 | + * @param $fqcn |
|
54 | + * @return RouteMatchSpecification |
|
55 | + * @throws InvalidArgumentException |
|
56 | + * @throws InvalidDataTypeException |
|
57 | + * @throws InvalidInterfaceException |
|
58 | + * @throws ReflectionException |
|
59 | + * @since 4.9.71.p |
|
60 | + */ |
|
61 | + public static function create($fqcn) |
|
62 | + { |
|
63 | + /** @var RouteMatchSpecificationFactory $specification_factory */ |
|
64 | + $specification_factory = LoaderFactory::getLoader()->getShared( |
|
65 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' |
|
66 | + ); |
|
67 | + return $specification_factory->createNewRouteMatchSpecification($fqcn); |
|
68 | + } |
|
69 | 69 | } |
@@ -22,20 +22,20 @@ |
||
22 | 22 | class RouteMatchSpecificationDependencyResolver extends DependencyResolver |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * Used to configure and/or setup any aliases or namespace roots required by the DependencyResolver |
|
27 | - * |
|
28 | - * @since 4.9.71.p |
|
29 | - * @throws InvalidAliasException |
|
30 | - */ |
|
31 | - public function initialize() |
|
32 | - { |
|
33 | - $this->addAlias( |
|
34 | - new ClassAlias( |
|
35 | - 'EventEspresso\core\services\request\RequestInterface', |
|
36 | - 'EventEspresso\core\services\request\Request' |
|
37 | - ) |
|
38 | - ); |
|
39 | - $this->addNamespaceRoot('EventEspresso\core\domain\entities\route_match\specifications'); |
|
40 | - } |
|
25 | + /** |
|
26 | + * Used to configure and/or setup any aliases or namespace roots required by the DependencyResolver |
|
27 | + * |
|
28 | + * @since 4.9.71.p |
|
29 | + * @throws InvalidAliasException |
|
30 | + */ |
|
31 | + public function initialize() |
|
32 | + { |
|
33 | + $this->addAlias( |
|
34 | + new ClassAlias( |
|
35 | + 'EventEspresso\core\services\request\RequestInterface', |
|
36 | + 'EventEspresso\core\services\request\Request' |
|
37 | + ) |
|
38 | + ); |
|
39 | + $this->addNamespaceRoot('EventEspresso\core\domain\entities\route_match\specifications'); |
|
40 | + } |
|
41 | 41 | } |
@@ -23,155 +23,155 @@ |
||
23 | 23 | abstract class DependencyResolver implements DependencyResolverInterface |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * @var Mirror $mirror |
|
28 | - */ |
|
29 | - private $mirror; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var ClassInterfaceCache $class_cache |
|
33 | - */ |
|
34 | - private $class_cache; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var EE_Dependency_Map $dependency_map |
|
38 | - */ |
|
39 | - private $dependency_map; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var ClassAlias[] $aliases |
|
43 | - */ |
|
44 | - protected $aliases = array(); |
|
45 | - |
|
46 | - /** |
|
47 | - * @var array $namespace_roots |
|
48 | - */ |
|
49 | - protected $namespace_roots = array(); |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * RouteMatchSpecificationDependencyResolver constructor. |
|
54 | - * |
|
55 | - * @param Mirror $mirror |
|
56 | - * @param ClassInterfaceCache $class_cache |
|
57 | - * @param EE_Dependency_Map $dependency_map |
|
58 | - */ |
|
59 | - public function __construct( |
|
60 | - Mirror $mirror, |
|
61 | - ClassInterfaceCache $class_cache, |
|
62 | - EE_Dependency_Map $dependency_map |
|
63 | - ) { |
|
64 | - $this->mirror = $mirror; |
|
65 | - $this->class_cache = $class_cache; |
|
66 | - $this->dependency_map = $dependency_map; |
|
67 | - $this->initialize(); |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * @return Mirror |
|
72 | - */ |
|
73 | - public function mirror() |
|
74 | - { |
|
75 | - return $this->mirror; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @return ClassInterfaceCache |
|
80 | - */ |
|
81 | - public function classCache() |
|
82 | - { |
|
83 | - return $this->class_cache; |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * @return EE_Dependency_Map |
|
88 | - */ |
|
89 | - public function dependencyMap() |
|
90 | - { |
|
91 | - return $this->dependency_map; |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * @param ClassAlias $alias |
|
96 | - * @throws InvalidAliasException |
|
97 | - */ |
|
98 | - public function addAlias(ClassAlias $alias) |
|
99 | - { |
|
100 | - $this->aliases[ $alias->alias() ] = $alias; |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * @param string $param_fqcn Fully Qualified Class Name for dependency parameter |
|
105 | - * @return string |
|
106 | - */ |
|
107 | - public function resolveAlias($param_fqcn) |
|
108 | - { |
|
109 | - return isset($this->aliases[ $param_fqcn ]) |
|
110 | - ? $this->aliases[ $param_fqcn ]->fqcn() |
|
111 | - : $this->classCache()->getFqnForAlias($param_fqcn); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Primarily used to indicate the namespace root for composite objects |
|
116 | - * so that dependencies requiring the same DependencyResolver can be acquired |
|
117 | - * for example: |
|
118 | - * Vendor\path\to\class\A, Vendor\path\to\class\B, and Vendor\path\to\class\C |
|
119 | - * may all implement Vendor\path\to\Interface, |
|
120 | - * but Vendor\path\to\class\C could be a composite object |
|
121 | - * that requires Vendor\path\to\class\A and Vendor\path\to\class\B, |
|
122 | - * and needs both of those dependencies resolved, which would therefore require |
|
123 | - * the use of the same DependencyResolver. |
|
124 | - * |
|
125 | - * By specifying a namespace root of "Vendor\path\to\", |
|
126 | - * then all classes that are descendants of that namespace |
|
127 | - * will use DependencyResolver to acquire the classes they need |
|
128 | - * |
|
129 | - * @param string $namespace_root Partial namespace used for detecting other classes |
|
130 | - * that should employ this same DependencyResolver |
|
131 | - */ |
|
132 | - public function addNamespaceRoot($namespace_root) |
|
133 | - { |
|
134 | - $this->namespace_roots[] = $namespace_root; |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * Returns true if the parameter FQCN belongs to one of |
|
139 | - * the namespaces that utilizes this DependencyResolver |
|
140 | - * |
|
141 | - * @param string $param_fqcn Fully Qualified Class Name for dependency parameter |
|
142 | - * @return boolean |
|
143 | - * @since 4.9.71.p |
|
144 | - */ |
|
145 | - public function dependencyRecursionExists($param_fqcn) |
|
146 | - { |
|
147 | - foreach ($this->namespace_roots as $namespace_root) { |
|
148 | - if (strpos($param_fqcn, $namespace_root) !== false) { |
|
149 | - return true; |
|
150 | - } |
|
151 | - } |
|
152 | - return false; |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * @param string $fqcn Fully Qualified Class Name |
|
158 | - * @throws InvalidDataTypeException |
|
159 | - * @throws ReflectionException |
|
160 | - * @since 4.9.71.p |
|
161 | - */ |
|
162 | - public function resolveDependenciesForClass($fqcn) |
|
163 | - { |
|
164 | - $dependencies = array(); |
|
165 | - $params = $this->mirror()->getParameters($fqcn); |
|
166 | - foreach ($params as $index => $param) { |
|
167 | - // is this a dependency for a specific class ? |
|
168 | - $param_class = $this->mirror()->getParameterClassName($param, $fqcn, $index); |
|
169 | - if ($this->dependencyRecursionExists($param_class)) { |
|
170 | - $this->resolveDependenciesForClass($param_class); |
|
171 | - } |
|
172 | - $param_class = $this->resolveAlias($param_class); |
|
173 | - $dependencies[ $param_class ] = EE_Dependency_Map::load_from_cache; |
|
174 | - } |
|
175 | - $this->dependencyMap()->registerDependencies($fqcn, $dependencies); |
|
176 | - } |
|
26 | + /** |
|
27 | + * @var Mirror $mirror |
|
28 | + */ |
|
29 | + private $mirror; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var ClassInterfaceCache $class_cache |
|
33 | + */ |
|
34 | + private $class_cache; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var EE_Dependency_Map $dependency_map |
|
38 | + */ |
|
39 | + private $dependency_map; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var ClassAlias[] $aliases |
|
43 | + */ |
|
44 | + protected $aliases = array(); |
|
45 | + |
|
46 | + /** |
|
47 | + * @var array $namespace_roots |
|
48 | + */ |
|
49 | + protected $namespace_roots = array(); |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * RouteMatchSpecificationDependencyResolver constructor. |
|
54 | + * |
|
55 | + * @param Mirror $mirror |
|
56 | + * @param ClassInterfaceCache $class_cache |
|
57 | + * @param EE_Dependency_Map $dependency_map |
|
58 | + */ |
|
59 | + public function __construct( |
|
60 | + Mirror $mirror, |
|
61 | + ClassInterfaceCache $class_cache, |
|
62 | + EE_Dependency_Map $dependency_map |
|
63 | + ) { |
|
64 | + $this->mirror = $mirror; |
|
65 | + $this->class_cache = $class_cache; |
|
66 | + $this->dependency_map = $dependency_map; |
|
67 | + $this->initialize(); |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * @return Mirror |
|
72 | + */ |
|
73 | + public function mirror() |
|
74 | + { |
|
75 | + return $this->mirror; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @return ClassInterfaceCache |
|
80 | + */ |
|
81 | + public function classCache() |
|
82 | + { |
|
83 | + return $this->class_cache; |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * @return EE_Dependency_Map |
|
88 | + */ |
|
89 | + public function dependencyMap() |
|
90 | + { |
|
91 | + return $this->dependency_map; |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * @param ClassAlias $alias |
|
96 | + * @throws InvalidAliasException |
|
97 | + */ |
|
98 | + public function addAlias(ClassAlias $alias) |
|
99 | + { |
|
100 | + $this->aliases[ $alias->alias() ] = $alias; |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * @param string $param_fqcn Fully Qualified Class Name for dependency parameter |
|
105 | + * @return string |
|
106 | + */ |
|
107 | + public function resolveAlias($param_fqcn) |
|
108 | + { |
|
109 | + return isset($this->aliases[ $param_fqcn ]) |
|
110 | + ? $this->aliases[ $param_fqcn ]->fqcn() |
|
111 | + : $this->classCache()->getFqnForAlias($param_fqcn); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Primarily used to indicate the namespace root for composite objects |
|
116 | + * so that dependencies requiring the same DependencyResolver can be acquired |
|
117 | + * for example: |
|
118 | + * Vendor\path\to\class\A, Vendor\path\to\class\B, and Vendor\path\to\class\C |
|
119 | + * may all implement Vendor\path\to\Interface, |
|
120 | + * but Vendor\path\to\class\C could be a composite object |
|
121 | + * that requires Vendor\path\to\class\A and Vendor\path\to\class\B, |
|
122 | + * and needs both of those dependencies resolved, which would therefore require |
|
123 | + * the use of the same DependencyResolver. |
|
124 | + * |
|
125 | + * By specifying a namespace root of "Vendor\path\to\", |
|
126 | + * then all classes that are descendants of that namespace |
|
127 | + * will use DependencyResolver to acquire the classes they need |
|
128 | + * |
|
129 | + * @param string $namespace_root Partial namespace used for detecting other classes |
|
130 | + * that should employ this same DependencyResolver |
|
131 | + */ |
|
132 | + public function addNamespaceRoot($namespace_root) |
|
133 | + { |
|
134 | + $this->namespace_roots[] = $namespace_root; |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * Returns true if the parameter FQCN belongs to one of |
|
139 | + * the namespaces that utilizes this DependencyResolver |
|
140 | + * |
|
141 | + * @param string $param_fqcn Fully Qualified Class Name for dependency parameter |
|
142 | + * @return boolean |
|
143 | + * @since 4.9.71.p |
|
144 | + */ |
|
145 | + public function dependencyRecursionExists($param_fqcn) |
|
146 | + { |
|
147 | + foreach ($this->namespace_roots as $namespace_root) { |
|
148 | + if (strpos($param_fqcn, $namespace_root) !== false) { |
|
149 | + return true; |
|
150 | + } |
|
151 | + } |
|
152 | + return false; |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * @param string $fqcn Fully Qualified Class Name |
|
158 | + * @throws InvalidDataTypeException |
|
159 | + * @throws ReflectionException |
|
160 | + * @since 4.9.71.p |
|
161 | + */ |
|
162 | + public function resolveDependenciesForClass($fqcn) |
|
163 | + { |
|
164 | + $dependencies = array(); |
|
165 | + $params = $this->mirror()->getParameters($fqcn); |
|
166 | + foreach ($params as $index => $param) { |
|
167 | + // is this a dependency for a specific class ? |
|
168 | + $param_class = $this->mirror()->getParameterClassName($param, $fqcn, $index); |
|
169 | + if ($this->dependencyRecursionExists($param_class)) { |
|
170 | + $this->resolveDependenciesForClass($param_class); |
|
171 | + } |
|
172 | + $param_class = $this->resolveAlias($param_class); |
|
173 | + $dependencies[ $param_class ] = EE_Dependency_Map::load_from_cache; |
|
174 | + } |
|
175 | + $this->dependencyMap()->registerDependencies($fqcn, $dependencies); |
|
176 | + } |
|
177 | 177 | } |
@@ -15,16 +15,16 @@ |
||
15 | 15 | */ |
16 | 16 | interface DependencyResolverInterface |
17 | 17 | { |
18 | - /** |
|
19 | - * Used to configure and/or setup any aliases or recursions required by the DependencyResolver |
|
20 | - * |
|
21 | - * @since 4.9.71.p |
|
22 | - */ |
|
23 | - public function initialize(); |
|
18 | + /** |
|
19 | + * Used to configure and/or setup any aliases or recursions required by the DependencyResolver |
|
20 | + * |
|
21 | + * @since 4.9.71.p |
|
22 | + */ |
|
23 | + public function initialize(); |
|
24 | 24 | |
25 | - /** |
|
26 | - * @param string $fqcn Fully Qualified Class Name |
|
27 | - * @since 4.9.71.p |
|
28 | - */ |
|
29 | - public function resolveDependenciesForClass($fqcn); |
|
25 | + /** |
|
26 | + * @param string $fqcn Fully Qualified Class Name |
|
27 | + * @since 4.9.71.p |
|
28 | + */ |
|
29 | + public function resolveDependenciesForClass($fqcn); |
|
30 | 30 | } |
@@ -31,543 +31,543 @@ |
||
31 | 31 | class CoreAssetManager extends AssetManager |
32 | 32 | { |
33 | 33 | |
34 | - // WordPress core / Third party JS asset handles |
|
35 | - const JS_HANDLE_JQUERY = 'jquery'; |
|
34 | + // WordPress core / Third party JS asset handles |
|
35 | + const JS_HANDLE_JQUERY = 'jquery'; |
|
36 | 36 | |
37 | - const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
37 | + const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
38 | 38 | |
39 | - const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
39 | + const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
40 | 40 | |
41 | - const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
41 | + const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
42 | 42 | |
43 | - const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
43 | + const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @since 4.9.71.p |
|
47 | - */ |
|
48 | - const JS_HANDLE_REACT = 'react'; |
|
45 | + /** |
|
46 | + * @since 4.9.71.p |
|
47 | + */ |
|
48 | + const JS_HANDLE_REACT = 'react'; |
|
49 | 49 | |
50 | - /** |
|
51 | - * @since 4.9.71.p |
|
52 | - */ |
|
53 | - const JS_HANDLE_REACT_DOM = 'react-dom'; |
|
50 | + /** |
|
51 | + * @since 4.9.71.p |
|
52 | + */ |
|
53 | + const JS_HANDLE_REACT_DOM = 'react-dom'; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @since 4.9.71.p |
|
57 | - */ |
|
58 | - const JS_HANDLE_LODASH = 'lodash'; |
|
55 | + /** |
|
56 | + * @since 4.9.71.p |
|
57 | + */ |
|
58 | + const JS_HANDLE_LODASH = 'lodash'; |
|
59 | 59 | |
60 | - // EE JS assets handles |
|
61 | - const JS_HANDLE_MANIFEST = 'ee-manifest'; |
|
60 | + // EE JS assets handles |
|
61 | + const JS_HANDLE_MANIFEST = 'ee-manifest'; |
|
62 | 62 | |
63 | - const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
63 | + const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
64 | 64 | |
65 | - const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
65 | + const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
66 | 66 | |
67 | - const JS_HANDLE_DATA_STORES = 'eventespresso-data-stores'; |
|
67 | + const JS_HANDLE_DATA_STORES = 'eventespresso-data-stores'; |
|
68 | 68 | |
69 | - const JS_HANDLE_HELPERS = 'eventespresso-helpers'; |
|
69 | + const JS_HANDLE_HELPERS = 'eventespresso-helpers'; |
|
70 | 70 | |
71 | - const JS_HANDLE_MODEL = 'eventespresso-model'; |
|
71 | + const JS_HANDLE_MODEL = 'eventespresso-model'; |
|
72 | 72 | |
73 | - const JS_HANDLE_VALUE_OBJECTS = 'eventespresso-value-objects'; |
|
73 | + const JS_HANDLE_VALUE_OBJECTS = 'eventespresso-value-objects'; |
|
74 | 74 | |
75 | - const JS_HANDLE_HOCS = 'eventespresso-hocs'; |
|
75 | + const JS_HANDLE_HOCS = 'eventespresso-hocs'; |
|
76 | 76 | |
77 | - const JS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
78 | - |
|
79 | - const JS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs'; |
|
77 | + const JS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
78 | + |
|
79 | + const JS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs'; |
|
80 | 80 | |
81 | - const JS_HANDLE_VALIDATORS = 'eventespresso-validators'; |
|
81 | + const JS_HANDLE_VALIDATORS = 'eventespresso-validators'; |
|
82 | 82 | |
83 | - const JS_HANDLE_CORE = 'espresso_core'; |
|
83 | + const JS_HANDLE_CORE = 'espresso_core'; |
|
84 | 84 | |
85 | - const JS_HANDLE_I18N = 'eei18n'; |
|
86 | - |
|
87 | - const JS_HANDLE_ACCOUNTING = 'ee-accounting'; |
|
88 | - |
|
89 | - const JS_HANDLE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
90 | - |
|
91 | - // EE CSS assets handles |
|
92 | - const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
93 | - |
|
94 | - const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
95 | - |
|
96 | - const CSS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
97 | - |
|
98 | - /** |
|
99 | - * @var EE_Currency_Config $currency_config |
|
100 | - */ |
|
101 | - protected $currency_config; |
|
102 | - |
|
103 | - /** |
|
104 | - * @var EE_Template_Config $template_config |
|
105 | - */ |
|
106 | - protected $template_config; |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * CoreAssetRegister constructor. |
|
111 | - * |
|
112 | - * @param AssetCollection $assets |
|
113 | - * @param EE_Currency_Config $currency_config |
|
114 | - * @param EE_Template_Config $template_config |
|
115 | - * @param DomainInterface $domain |
|
116 | - * @param Registry $registry |
|
117 | - */ |
|
118 | - public function __construct( |
|
119 | - AssetCollection $assets, |
|
120 | - EE_Currency_Config $currency_config, |
|
121 | - EE_Template_Config $template_config, |
|
122 | - DomainInterface $domain, |
|
123 | - Registry $registry |
|
124 | - ) { |
|
125 | - $this->currency_config = $currency_config; |
|
126 | - $this->template_config = $template_config; |
|
127 | - parent::__construct($domain, $assets, $registry); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * @since 4.9.62.p |
|
133 | - * @throws DomainException |
|
134 | - * @throws DuplicateCollectionIdentifierException |
|
135 | - * @throws InvalidArgumentException |
|
136 | - * @throws InvalidDataTypeException |
|
137 | - * @throws InvalidEntityException |
|
138 | - * @throws InvalidInterfaceException |
|
139 | - */ |
|
140 | - public function addAssets() |
|
141 | - { |
|
142 | - $this->addJavascriptFiles(); |
|
143 | - $this->addStylesheetFiles(); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * @since 4.9.62.p |
|
149 | - * @throws DomainException |
|
150 | - * @throws DuplicateCollectionIdentifierException |
|
151 | - * @throws InvalidArgumentException |
|
152 | - * @throws InvalidDataTypeException |
|
153 | - * @throws InvalidEntityException |
|
154 | - * @throws InvalidInterfaceException |
|
155 | - */ |
|
156 | - public function addJavascriptFiles() |
|
157 | - { |
|
158 | - $this->loadCoreJs(); |
|
159 | - $this->loadJqueryValidate(); |
|
160 | - $this->loadAccountingJs(); |
|
161 | - add_action( |
|
162 | - 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
163 | - array($this, 'loadQtipJs') |
|
164 | - ); |
|
165 | - $this->registerAdminAssets(); |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * @since 4.9.62.p |
|
171 | - * @throws DuplicateCollectionIdentifierException |
|
172 | - * @throws InvalidDataTypeException |
|
173 | - * @throws InvalidEntityException |
|
174 | - */ |
|
175 | - public function addStylesheetFiles() |
|
176 | - { |
|
177 | - $this->loadCoreCss(); |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * core default javascript |
|
183 | - * |
|
184 | - * @since 4.9.62.p |
|
185 | - * @throws DomainException |
|
186 | - * @throws DuplicateCollectionIdentifierException |
|
187 | - * @throws InvalidArgumentException |
|
188 | - * @throws InvalidDataTypeException |
|
189 | - * @throws InvalidEntityException |
|
190 | - * @throws InvalidInterfaceException |
|
191 | - */ |
|
192 | - private function loadCoreJs() |
|
193 | - { |
|
194 | - // conditionally load third-party libraries that WP core MIGHT have. |
|
195 | - $this->registerWpAssets(); |
|
196 | - |
|
197 | - $this->addJavascript( |
|
198 | - CoreAssetManager::JS_HANDLE_MANIFEST, |
|
199 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
200 | - ); |
|
201 | - |
|
202 | - $this->addJavascript( |
|
203 | - CoreAssetManager::JS_HANDLE_JS_CORE, |
|
204 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
205 | - array(CoreAssetManager::JS_HANDLE_MANIFEST) |
|
206 | - ) |
|
207 | - ->setHasInlineData(); |
|
208 | - |
|
209 | - $this->addJavascript( |
|
210 | - CoreAssetManager::JS_HANDLE_VENDOR, |
|
211 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'), |
|
212 | - array( |
|
213 | - CoreAssetManager::JS_HANDLE_JS_CORE, |
|
214 | - CoreAssetManager::JS_HANDLE_REACT, |
|
215 | - CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
216 | - CoreAssetManager::JS_HANDLE_LODASH, |
|
217 | - ) |
|
218 | - ); |
|
219 | - |
|
220 | - $this->addJavascript( |
|
221 | - CoreAssetManager::JS_HANDLE_VALIDATORS, |
|
222 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'validators') |
|
223 | - )->setRequiresTranslation(); |
|
224 | - |
|
225 | - $this->addJavascript( |
|
226 | - CoreAssetManager::JS_HANDLE_HELPERS, |
|
227 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'), |
|
228 | - array( |
|
229 | - CoreAssetManager::JS_HANDLE_VALIDATORS |
|
230 | - ) |
|
231 | - )->setRequiresTranslation(); |
|
232 | - |
|
233 | - $this->addJavascript( |
|
234 | - CoreAssetManager::JS_HANDLE_MODEL, |
|
235 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'model'), |
|
236 | - array( |
|
237 | - CoreAssetManager::JS_HANDLE_HELPERS |
|
238 | - ) |
|
239 | - )->setRequiresTranslation(); |
|
240 | - |
|
241 | - $this->addJavascript( |
|
242 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
243 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'), |
|
244 | - array( |
|
245 | - CoreAssetManager::JS_HANDLE_MODEL |
|
246 | - ) |
|
247 | - )->setRequiresTranslation(); |
|
248 | - |
|
249 | - $this->addJavascript( |
|
250 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
251 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'), |
|
252 | - array( |
|
253 | - CoreAssetManager::JS_HANDLE_VENDOR, |
|
254 | - 'wp-data', |
|
255 | - 'wp-api-fetch', |
|
256 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS |
|
257 | - ) |
|
258 | - ) |
|
259 | - ->setRequiresTranslation(); |
|
260 | - |
|
261 | - $this->addJavascript( |
|
262 | - CoreAssetManager::JS_HANDLE_HOCS, |
|
263 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'hocs'), |
|
264 | - array( |
|
265 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
266 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
267 | - 'wp-components', |
|
268 | - ) |
|
269 | - )->setRequiresTranslation(); |
|
270 | - |
|
271 | - $this->addJavascript( |
|
272 | - CoreAssetManager::JS_HANDLE_COMPONENTS, |
|
273 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'), |
|
274 | - array( |
|
275 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
276 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
277 | - 'wp-components', |
|
278 | - ) |
|
279 | - ) |
|
280 | - ->setRequiresTranslation(); |
|
281 | - |
|
282 | - $this->addJavascript( |
|
283 | - CoreAssetManager::JS_HANDLE_EDITOR_HOCS, |
|
284 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'editor-hocs'), |
|
285 | - array( |
|
286 | - CoreAssetManager::JS_HANDLE_COMPONENTS |
|
287 | - ) |
|
288 | - )->setRequiresTranslation(); |
|
289 | - |
|
290 | - $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
291 | - $this->registry->addData( |
|
292 | - 'paths', |
|
293 | - array( |
|
294 | - 'rest_route' => rest_url('ee/v4.8.36/'), |
|
295 | - 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
296 | - 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(), |
|
297 | - 'site_url' => site_url('/'), |
|
298 | - 'admin_url' => admin_url('/'), |
|
299 | - ) |
|
300 | - ); |
|
301 | - /** site formatting values **/ |
|
302 | - $this->registry->addData( |
|
303 | - 'site_formats', |
|
304 | - array( |
|
305 | - 'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats() |
|
306 | - ) |
|
307 | - ); |
|
308 | - /** currency data **/ |
|
309 | - $this->registry->addData( |
|
310 | - 'currency_config', |
|
311 | - $this->getCurrencySettings() |
|
312 | - ); |
|
313 | - /** site timezone */ |
|
314 | - $this->registry->addData( |
|
315 | - 'default_timezone', |
|
316 | - array( |
|
317 | - 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
318 | - 'string' => get_option('timezone_string'), |
|
319 | - 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
320 | - ) |
|
321 | - ); |
|
322 | - /** site locale (user locale if user logged in) */ |
|
323 | - $this->registry->addData( |
|
324 | - 'locale', |
|
325 | - array( |
|
326 | - 'user' => get_user_locale(), |
|
327 | - 'site' => get_locale() |
|
328 | - ) |
|
329 | - ); |
|
330 | - |
|
331 | - $this->addJavascript( |
|
332 | - CoreAssetManager::JS_HANDLE_CORE, |
|
333 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
334 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
335 | - ) |
|
336 | - ->setInlineDataCallback( |
|
337 | - function () { |
|
338 | - wp_localize_script( |
|
339 | - CoreAssetManager::JS_HANDLE_CORE, |
|
340 | - CoreAssetManager::JS_HANDLE_I18N, |
|
341 | - EE_Registry::$i18n_js_strings |
|
342 | - ); |
|
343 | - } |
|
344 | - ); |
|
345 | - } |
|
346 | - |
|
347 | - |
|
348 | - /** |
|
349 | - * Registers vendor files that are bundled with a later version WP but might not be for the current version of |
|
350 | - * WordPress in the running environment. |
|
351 | - * |
|
352 | - * @throws DuplicateCollectionIdentifierException |
|
353 | - * @throws InvalidDataTypeException |
|
354 | - * @throws InvalidEntityException |
|
355 | - * @throws DomainException |
|
356 | - * @since 4.9.71.p |
|
357 | - */ |
|
358 | - private function registerWpAssets() |
|
359 | - { |
|
360 | - global $wp_version; |
|
361 | - if (version_compare($wp_version, '5.0.beta', '>=')) { |
|
362 | - return; |
|
363 | - } |
|
364 | - $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT) |
|
365 | - ->setVersion('16.6.0'); |
|
366 | - $this->addVendorJavascript( |
|
367 | - CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
368 | - array(CoreAssetManager::JS_HANDLE_REACT) |
|
369 | - )->setVersion('16.6.0'); |
|
370 | - $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH) |
|
371 | - ->setInlineDataCallback( |
|
372 | - function() { |
|
373 | - wp_add_inline_script( |
|
374 | - CoreAssetManager::JS_HANDLE_LODASH, |
|
375 | - 'window.lodash = _.noConflict();' |
|
376 | - ); |
|
377 | - } |
|
378 | - ) |
|
379 | - ->setVersion('4.17.11'); |
|
380 | - } |
|
381 | - |
|
382 | - |
|
383 | - /** |
|
384 | - * Returns configuration data for the accounting-js library. |
|
385 | - * @since 4.9.71.p |
|
386 | - * @return array |
|
387 | - */ |
|
388 | - private function getAccountingSettings() { |
|
389 | - return array( |
|
390 | - 'currency' => array( |
|
391 | - 'symbol' => $this->currency_config->sign, |
|
392 | - 'format' => array( |
|
393 | - 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
394 | - 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
395 | - 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
396 | - ), |
|
397 | - 'decimal' => $this->currency_config->dec_mrk, |
|
398 | - 'thousand' => $this->currency_config->thsnds, |
|
399 | - 'precision' => $this->currency_config->dec_plc, |
|
400 | - ), |
|
401 | - 'number' => array( |
|
402 | - 'precision' => $this->currency_config->dec_plc, |
|
403 | - 'thousand' => $this->currency_config->thsnds, |
|
404 | - 'decimal' => $this->currency_config->dec_mrk, |
|
405 | - ), |
|
406 | - ); |
|
407 | - } |
|
408 | - |
|
409 | - |
|
410 | - /** |
|
411 | - * Returns configuration data for the js Currency VO. |
|
412 | - * @since 4.9.71.p |
|
413 | - * @return array |
|
414 | - */ |
|
415 | - private function getCurrencySettings() |
|
416 | - { |
|
417 | - return array( |
|
418 | - 'code' => $this->currency_config->code, |
|
419 | - 'singularLabel' => $this->currency_config->name, |
|
420 | - 'pluralLabel' => $this->currency_config->plural, |
|
421 | - 'sign' => $this->currency_config->sign, |
|
422 | - 'signB4' => $this->currency_config->sign_b4, |
|
423 | - 'decimalPlaces' => $this->currency_config->dec_plc, |
|
424 | - 'decimalMark' => $this->currency_config->dec_mrk, |
|
425 | - 'thousandsSeparator' => $this->currency_config->thsnds, |
|
426 | - ); |
|
427 | - } |
|
428 | - |
|
429 | - |
|
430 | - /** |
|
431 | - * @since 4.9.62.p |
|
432 | - * @throws DuplicateCollectionIdentifierException |
|
433 | - * @throws InvalidDataTypeException |
|
434 | - * @throws InvalidEntityException |
|
435 | - */ |
|
436 | - private function loadCoreCss() |
|
437 | - { |
|
438 | - if ($this->template_config->enable_default_style && ! is_admin()) { |
|
439 | - $this->addStylesheet( |
|
440 | - CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
441 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
442 | - ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
443 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
444 | - array('dashicons') |
|
445 | - ); |
|
446 | - //Load custom style sheet if available |
|
447 | - if ($this->template_config->custom_style_sheet !== null) { |
|
448 | - $this->addStylesheet( |
|
449 | - CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
450 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
451 | - array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
|
452 | - ); |
|
453 | - } |
|
454 | - } |
|
455 | - $this->addStylesheet( |
|
456 | - CoreAssetManager::CSS_HANDLE_COMPONENTS, |
|
457 | - $this->registry->getCssUrl( |
|
458 | - $this->domain->assetNamespace(), |
|
459 | - 'components' |
|
460 | - ) |
|
461 | - ); |
|
462 | - } |
|
463 | - |
|
464 | - |
|
465 | - /** |
|
466 | - * jQuery Validate for form validation |
|
467 | - * |
|
468 | - * @since 4.9.62.p |
|
469 | - * @throws DomainException |
|
470 | - * @throws DuplicateCollectionIdentifierException |
|
471 | - * @throws InvalidDataTypeException |
|
472 | - * @throws InvalidEntityException |
|
473 | - */ |
|
474 | - private function loadJqueryValidate() |
|
475 | - { |
|
476 | - $this->addJavascript( |
|
477 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
478 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
479 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
480 | - ) |
|
481 | - ->setVersion('1.15.0'); |
|
482 | - |
|
483 | - $this->addJavascript( |
|
484 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
485 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
486 | - array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
487 | - ) |
|
488 | - ->setVersion('1.15.0'); |
|
489 | - } |
|
490 | - |
|
491 | - |
|
492 | - /** |
|
493 | - * accounting.js for performing client-side calculations |
|
494 | - * |
|
495 | - * @since 4.9.62.p |
|
496 | - * @throws DomainException |
|
497 | - * @throws DuplicateCollectionIdentifierException |
|
498 | - * @throws InvalidDataTypeException |
|
499 | - * @throws InvalidEntityException |
|
500 | - */ |
|
501 | - private function loadAccountingJs() |
|
502 | - { |
|
503 | - //accounting.js library |
|
504 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
505 | - $this->addJavascript( |
|
506 | - CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
507 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
508 | - array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
509 | - ) |
|
510 | - ->setVersion('0.3.2'); |
|
511 | - |
|
512 | - $this->addJavascript( |
|
513 | - CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
514 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
515 | - array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
516 | - ) |
|
517 | - ->setInlineDataCallback( |
|
518 | - function () { |
|
519 | - wp_localize_script( |
|
520 | - CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
521 | - 'EE_ACCOUNTING_CFG', |
|
522 | - $this->getAccountingSettings() |
|
523 | - ); |
|
524 | - } |
|
525 | - ) |
|
526 | - ->setVersion(); |
|
527 | - } |
|
528 | - |
|
529 | - |
|
530 | - /** |
|
531 | - * registers assets for cleaning your ears |
|
532 | - * |
|
533 | - * @param JavascriptAsset $script |
|
534 | - */ |
|
535 | - public function loadQtipJs(JavascriptAsset $script) |
|
536 | - { |
|
537 | - // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
538 | - // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
539 | - if ( |
|
540 | - $script->handle() === CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE |
|
541 | - && apply_filters('FHEE_load_qtip', false) |
|
542 | - ) { |
|
543 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
544 | - } |
|
545 | - } |
|
546 | - |
|
547 | - |
|
548 | - /** |
|
549 | - * assets that are used in the WordPress admin |
|
550 | - * |
|
551 | - * @since 4.9.62.p |
|
552 | - * @throws DuplicateCollectionIdentifierException |
|
553 | - * @throws InvalidDataTypeException |
|
554 | - * @throws InvalidEntityException |
|
555 | - */ |
|
556 | - private function registerAdminAssets() |
|
557 | - { |
|
558 | - $this->addJavascript( |
|
559 | - CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
560 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
561 | - array( |
|
562 | - CoreAssetManager::JS_HANDLE_JQUERY, |
|
563 | - CoreAssetManager::JS_HANDLE_VENDOR, |
|
564 | - ) |
|
565 | - ) |
|
566 | - ->setRequiresTranslation(); |
|
567 | - |
|
568 | - $this->addStylesheet( |
|
569 | - CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
570 | - $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
571 | - ); |
|
572 | - } |
|
85 | + const JS_HANDLE_I18N = 'eei18n'; |
|
86 | + |
|
87 | + const JS_HANDLE_ACCOUNTING = 'ee-accounting'; |
|
88 | + |
|
89 | + const JS_HANDLE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
90 | + |
|
91 | + // EE CSS assets handles |
|
92 | + const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
93 | + |
|
94 | + const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
95 | + |
|
96 | + const CSS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
97 | + |
|
98 | + /** |
|
99 | + * @var EE_Currency_Config $currency_config |
|
100 | + */ |
|
101 | + protected $currency_config; |
|
102 | + |
|
103 | + /** |
|
104 | + * @var EE_Template_Config $template_config |
|
105 | + */ |
|
106 | + protected $template_config; |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * CoreAssetRegister constructor. |
|
111 | + * |
|
112 | + * @param AssetCollection $assets |
|
113 | + * @param EE_Currency_Config $currency_config |
|
114 | + * @param EE_Template_Config $template_config |
|
115 | + * @param DomainInterface $domain |
|
116 | + * @param Registry $registry |
|
117 | + */ |
|
118 | + public function __construct( |
|
119 | + AssetCollection $assets, |
|
120 | + EE_Currency_Config $currency_config, |
|
121 | + EE_Template_Config $template_config, |
|
122 | + DomainInterface $domain, |
|
123 | + Registry $registry |
|
124 | + ) { |
|
125 | + $this->currency_config = $currency_config; |
|
126 | + $this->template_config = $template_config; |
|
127 | + parent::__construct($domain, $assets, $registry); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * @since 4.9.62.p |
|
133 | + * @throws DomainException |
|
134 | + * @throws DuplicateCollectionIdentifierException |
|
135 | + * @throws InvalidArgumentException |
|
136 | + * @throws InvalidDataTypeException |
|
137 | + * @throws InvalidEntityException |
|
138 | + * @throws InvalidInterfaceException |
|
139 | + */ |
|
140 | + public function addAssets() |
|
141 | + { |
|
142 | + $this->addJavascriptFiles(); |
|
143 | + $this->addStylesheetFiles(); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * @since 4.9.62.p |
|
149 | + * @throws DomainException |
|
150 | + * @throws DuplicateCollectionIdentifierException |
|
151 | + * @throws InvalidArgumentException |
|
152 | + * @throws InvalidDataTypeException |
|
153 | + * @throws InvalidEntityException |
|
154 | + * @throws InvalidInterfaceException |
|
155 | + */ |
|
156 | + public function addJavascriptFiles() |
|
157 | + { |
|
158 | + $this->loadCoreJs(); |
|
159 | + $this->loadJqueryValidate(); |
|
160 | + $this->loadAccountingJs(); |
|
161 | + add_action( |
|
162 | + 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
163 | + array($this, 'loadQtipJs') |
|
164 | + ); |
|
165 | + $this->registerAdminAssets(); |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * @since 4.9.62.p |
|
171 | + * @throws DuplicateCollectionIdentifierException |
|
172 | + * @throws InvalidDataTypeException |
|
173 | + * @throws InvalidEntityException |
|
174 | + */ |
|
175 | + public function addStylesheetFiles() |
|
176 | + { |
|
177 | + $this->loadCoreCss(); |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * core default javascript |
|
183 | + * |
|
184 | + * @since 4.9.62.p |
|
185 | + * @throws DomainException |
|
186 | + * @throws DuplicateCollectionIdentifierException |
|
187 | + * @throws InvalidArgumentException |
|
188 | + * @throws InvalidDataTypeException |
|
189 | + * @throws InvalidEntityException |
|
190 | + * @throws InvalidInterfaceException |
|
191 | + */ |
|
192 | + private function loadCoreJs() |
|
193 | + { |
|
194 | + // conditionally load third-party libraries that WP core MIGHT have. |
|
195 | + $this->registerWpAssets(); |
|
196 | + |
|
197 | + $this->addJavascript( |
|
198 | + CoreAssetManager::JS_HANDLE_MANIFEST, |
|
199 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
200 | + ); |
|
201 | + |
|
202 | + $this->addJavascript( |
|
203 | + CoreAssetManager::JS_HANDLE_JS_CORE, |
|
204 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
205 | + array(CoreAssetManager::JS_HANDLE_MANIFEST) |
|
206 | + ) |
|
207 | + ->setHasInlineData(); |
|
208 | + |
|
209 | + $this->addJavascript( |
|
210 | + CoreAssetManager::JS_HANDLE_VENDOR, |
|
211 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'), |
|
212 | + array( |
|
213 | + CoreAssetManager::JS_HANDLE_JS_CORE, |
|
214 | + CoreAssetManager::JS_HANDLE_REACT, |
|
215 | + CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
216 | + CoreAssetManager::JS_HANDLE_LODASH, |
|
217 | + ) |
|
218 | + ); |
|
219 | + |
|
220 | + $this->addJavascript( |
|
221 | + CoreAssetManager::JS_HANDLE_VALIDATORS, |
|
222 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'validators') |
|
223 | + )->setRequiresTranslation(); |
|
224 | + |
|
225 | + $this->addJavascript( |
|
226 | + CoreAssetManager::JS_HANDLE_HELPERS, |
|
227 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'), |
|
228 | + array( |
|
229 | + CoreAssetManager::JS_HANDLE_VALIDATORS |
|
230 | + ) |
|
231 | + )->setRequiresTranslation(); |
|
232 | + |
|
233 | + $this->addJavascript( |
|
234 | + CoreAssetManager::JS_HANDLE_MODEL, |
|
235 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'model'), |
|
236 | + array( |
|
237 | + CoreAssetManager::JS_HANDLE_HELPERS |
|
238 | + ) |
|
239 | + )->setRequiresTranslation(); |
|
240 | + |
|
241 | + $this->addJavascript( |
|
242 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
243 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'), |
|
244 | + array( |
|
245 | + CoreAssetManager::JS_HANDLE_MODEL |
|
246 | + ) |
|
247 | + )->setRequiresTranslation(); |
|
248 | + |
|
249 | + $this->addJavascript( |
|
250 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
251 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'), |
|
252 | + array( |
|
253 | + CoreAssetManager::JS_HANDLE_VENDOR, |
|
254 | + 'wp-data', |
|
255 | + 'wp-api-fetch', |
|
256 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS |
|
257 | + ) |
|
258 | + ) |
|
259 | + ->setRequiresTranslation(); |
|
260 | + |
|
261 | + $this->addJavascript( |
|
262 | + CoreAssetManager::JS_HANDLE_HOCS, |
|
263 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'hocs'), |
|
264 | + array( |
|
265 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
266 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
267 | + 'wp-components', |
|
268 | + ) |
|
269 | + )->setRequiresTranslation(); |
|
270 | + |
|
271 | + $this->addJavascript( |
|
272 | + CoreAssetManager::JS_HANDLE_COMPONENTS, |
|
273 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'), |
|
274 | + array( |
|
275 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
276 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
277 | + 'wp-components', |
|
278 | + ) |
|
279 | + ) |
|
280 | + ->setRequiresTranslation(); |
|
281 | + |
|
282 | + $this->addJavascript( |
|
283 | + CoreAssetManager::JS_HANDLE_EDITOR_HOCS, |
|
284 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'editor-hocs'), |
|
285 | + array( |
|
286 | + CoreAssetManager::JS_HANDLE_COMPONENTS |
|
287 | + ) |
|
288 | + )->setRequiresTranslation(); |
|
289 | + |
|
290 | + $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
291 | + $this->registry->addData( |
|
292 | + 'paths', |
|
293 | + array( |
|
294 | + 'rest_route' => rest_url('ee/v4.8.36/'), |
|
295 | + 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
296 | + 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(), |
|
297 | + 'site_url' => site_url('/'), |
|
298 | + 'admin_url' => admin_url('/'), |
|
299 | + ) |
|
300 | + ); |
|
301 | + /** site formatting values **/ |
|
302 | + $this->registry->addData( |
|
303 | + 'site_formats', |
|
304 | + array( |
|
305 | + 'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats() |
|
306 | + ) |
|
307 | + ); |
|
308 | + /** currency data **/ |
|
309 | + $this->registry->addData( |
|
310 | + 'currency_config', |
|
311 | + $this->getCurrencySettings() |
|
312 | + ); |
|
313 | + /** site timezone */ |
|
314 | + $this->registry->addData( |
|
315 | + 'default_timezone', |
|
316 | + array( |
|
317 | + 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
318 | + 'string' => get_option('timezone_string'), |
|
319 | + 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
320 | + ) |
|
321 | + ); |
|
322 | + /** site locale (user locale if user logged in) */ |
|
323 | + $this->registry->addData( |
|
324 | + 'locale', |
|
325 | + array( |
|
326 | + 'user' => get_user_locale(), |
|
327 | + 'site' => get_locale() |
|
328 | + ) |
|
329 | + ); |
|
330 | + |
|
331 | + $this->addJavascript( |
|
332 | + CoreAssetManager::JS_HANDLE_CORE, |
|
333 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
334 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
335 | + ) |
|
336 | + ->setInlineDataCallback( |
|
337 | + function () { |
|
338 | + wp_localize_script( |
|
339 | + CoreAssetManager::JS_HANDLE_CORE, |
|
340 | + CoreAssetManager::JS_HANDLE_I18N, |
|
341 | + EE_Registry::$i18n_js_strings |
|
342 | + ); |
|
343 | + } |
|
344 | + ); |
|
345 | + } |
|
346 | + |
|
347 | + |
|
348 | + /** |
|
349 | + * Registers vendor files that are bundled with a later version WP but might not be for the current version of |
|
350 | + * WordPress in the running environment. |
|
351 | + * |
|
352 | + * @throws DuplicateCollectionIdentifierException |
|
353 | + * @throws InvalidDataTypeException |
|
354 | + * @throws InvalidEntityException |
|
355 | + * @throws DomainException |
|
356 | + * @since 4.9.71.p |
|
357 | + */ |
|
358 | + private function registerWpAssets() |
|
359 | + { |
|
360 | + global $wp_version; |
|
361 | + if (version_compare($wp_version, '5.0.beta', '>=')) { |
|
362 | + return; |
|
363 | + } |
|
364 | + $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT) |
|
365 | + ->setVersion('16.6.0'); |
|
366 | + $this->addVendorJavascript( |
|
367 | + CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
368 | + array(CoreAssetManager::JS_HANDLE_REACT) |
|
369 | + )->setVersion('16.6.0'); |
|
370 | + $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH) |
|
371 | + ->setInlineDataCallback( |
|
372 | + function() { |
|
373 | + wp_add_inline_script( |
|
374 | + CoreAssetManager::JS_HANDLE_LODASH, |
|
375 | + 'window.lodash = _.noConflict();' |
|
376 | + ); |
|
377 | + } |
|
378 | + ) |
|
379 | + ->setVersion('4.17.11'); |
|
380 | + } |
|
381 | + |
|
382 | + |
|
383 | + /** |
|
384 | + * Returns configuration data for the accounting-js library. |
|
385 | + * @since 4.9.71.p |
|
386 | + * @return array |
|
387 | + */ |
|
388 | + private function getAccountingSettings() { |
|
389 | + return array( |
|
390 | + 'currency' => array( |
|
391 | + 'symbol' => $this->currency_config->sign, |
|
392 | + 'format' => array( |
|
393 | + 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
394 | + 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
395 | + 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
396 | + ), |
|
397 | + 'decimal' => $this->currency_config->dec_mrk, |
|
398 | + 'thousand' => $this->currency_config->thsnds, |
|
399 | + 'precision' => $this->currency_config->dec_plc, |
|
400 | + ), |
|
401 | + 'number' => array( |
|
402 | + 'precision' => $this->currency_config->dec_plc, |
|
403 | + 'thousand' => $this->currency_config->thsnds, |
|
404 | + 'decimal' => $this->currency_config->dec_mrk, |
|
405 | + ), |
|
406 | + ); |
|
407 | + } |
|
408 | + |
|
409 | + |
|
410 | + /** |
|
411 | + * Returns configuration data for the js Currency VO. |
|
412 | + * @since 4.9.71.p |
|
413 | + * @return array |
|
414 | + */ |
|
415 | + private function getCurrencySettings() |
|
416 | + { |
|
417 | + return array( |
|
418 | + 'code' => $this->currency_config->code, |
|
419 | + 'singularLabel' => $this->currency_config->name, |
|
420 | + 'pluralLabel' => $this->currency_config->plural, |
|
421 | + 'sign' => $this->currency_config->sign, |
|
422 | + 'signB4' => $this->currency_config->sign_b4, |
|
423 | + 'decimalPlaces' => $this->currency_config->dec_plc, |
|
424 | + 'decimalMark' => $this->currency_config->dec_mrk, |
|
425 | + 'thousandsSeparator' => $this->currency_config->thsnds, |
|
426 | + ); |
|
427 | + } |
|
428 | + |
|
429 | + |
|
430 | + /** |
|
431 | + * @since 4.9.62.p |
|
432 | + * @throws DuplicateCollectionIdentifierException |
|
433 | + * @throws InvalidDataTypeException |
|
434 | + * @throws InvalidEntityException |
|
435 | + */ |
|
436 | + private function loadCoreCss() |
|
437 | + { |
|
438 | + if ($this->template_config->enable_default_style && ! is_admin()) { |
|
439 | + $this->addStylesheet( |
|
440 | + CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
441 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
442 | + ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
443 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
444 | + array('dashicons') |
|
445 | + ); |
|
446 | + //Load custom style sheet if available |
|
447 | + if ($this->template_config->custom_style_sheet !== null) { |
|
448 | + $this->addStylesheet( |
|
449 | + CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
450 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
451 | + array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
|
452 | + ); |
|
453 | + } |
|
454 | + } |
|
455 | + $this->addStylesheet( |
|
456 | + CoreAssetManager::CSS_HANDLE_COMPONENTS, |
|
457 | + $this->registry->getCssUrl( |
|
458 | + $this->domain->assetNamespace(), |
|
459 | + 'components' |
|
460 | + ) |
|
461 | + ); |
|
462 | + } |
|
463 | + |
|
464 | + |
|
465 | + /** |
|
466 | + * jQuery Validate for form validation |
|
467 | + * |
|
468 | + * @since 4.9.62.p |
|
469 | + * @throws DomainException |
|
470 | + * @throws DuplicateCollectionIdentifierException |
|
471 | + * @throws InvalidDataTypeException |
|
472 | + * @throws InvalidEntityException |
|
473 | + */ |
|
474 | + private function loadJqueryValidate() |
|
475 | + { |
|
476 | + $this->addJavascript( |
|
477 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
478 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
479 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
480 | + ) |
|
481 | + ->setVersion('1.15.0'); |
|
482 | + |
|
483 | + $this->addJavascript( |
|
484 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
485 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
486 | + array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
487 | + ) |
|
488 | + ->setVersion('1.15.0'); |
|
489 | + } |
|
490 | + |
|
491 | + |
|
492 | + /** |
|
493 | + * accounting.js for performing client-side calculations |
|
494 | + * |
|
495 | + * @since 4.9.62.p |
|
496 | + * @throws DomainException |
|
497 | + * @throws DuplicateCollectionIdentifierException |
|
498 | + * @throws InvalidDataTypeException |
|
499 | + * @throws InvalidEntityException |
|
500 | + */ |
|
501 | + private function loadAccountingJs() |
|
502 | + { |
|
503 | + //accounting.js library |
|
504 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
505 | + $this->addJavascript( |
|
506 | + CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
507 | + EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
508 | + array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
509 | + ) |
|
510 | + ->setVersion('0.3.2'); |
|
511 | + |
|
512 | + $this->addJavascript( |
|
513 | + CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
514 | + EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
515 | + array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
516 | + ) |
|
517 | + ->setInlineDataCallback( |
|
518 | + function () { |
|
519 | + wp_localize_script( |
|
520 | + CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
521 | + 'EE_ACCOUNTING_CFG', |
|
522 | + $this->getAccountingSettings() |
|
523 | + ); |
|
524 | + } |
|
525 | + ) |
|
526 | + ->setVersion(); |
|
527 | + } |
|
528 | + |
|
529 | + |
|
530 | + /** |
|
531 | + * registers assets for cleaning your ears |
|
532 | + * |
|
533 | + * @param JavascriptAsset $script |
|
534 | + */ |
|
535 | + public function loadQtipJs(JavascriptAsset $script) |
|
536 | + { |
|
537 | + // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
538 | + // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
539 | + if ( |
|
540 | + $script->handle() === CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE |
|
541 | + && apply_filters('FHEE_load_qtip', false) |
|
542 | + ) { |
|
543 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
544 | + } |
|
545 | + } |
|
546 | + |
|
547 | + |
|
548 | + /** |
|
549 | + * assets that are used in the WordPress admin |
|
550 | + * |
|
551 | + * @since 4.9.62.p |
|
552 | + * @throws DuplicateCollectionIdentifierException |
|
553 | + * @throws InvalidDataTypeException |
|
554 | + * @throws InvalidEntityException |
|
555 | + */ |
|
556 | + private function registerAdminAssets() |
|
557 | + { |
|
558 | + $this->addJavascript( |
|
559 | + CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
560 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
561 | + array( |
|
562 | + CoreAssetManager::JS_HANDLE_JQUERY, |
|
563 | + CoreAssetManager::JS_HANDLE_VENDOR, |
|
564 | + ) |
|
565 | + ) |
|
566 | + ->setRequiresTranslation(); |
|
567 | + |
|
568 | + $this->addStylesheet( |
|
569 | + CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
570 | + $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
571 | + ); |
|
572 | + } |
|
573 | 573 | } |
@@ -18,61 +18,61 @@ |
||
18 | 18 | */ |
19 | 19 | class RestIncomingQueryParamContext |
20 | 20 | { |
21 | - /** |
|
22 | - * @var EEM_Base |
|
23 | - */ |
|
24 | - private $model; |
|
25 | - /** |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - private $requested_version; |
|
29 | - /** |
|
30 | - * @var boolean |
|
31 | - */ |
|
32 | - private $writing; |
|
21 | + /** |
|
22 | + * @var EEM_Base |
|
23 | + */ |
|
24 | + private $model; |
|
25 | + /** |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + private $requested_version; |
|
29 | + /** |
|
30 | + * @var boolean |
|
31 | + */ |
|
32 | + private $writing; |
|
33 | 33 | |
34 | - /** |
|
35 | - * RestIncomingQueryParamContext constructor. |
|
36 | - * @param EEM_Base $model |
|
37 | - * @param string $requested_version |
|
38 | - * @param boolean $writing |
|
39 | - */ |
|
40 | - public function __construct(EEM_Base $model, $requested_version, $writing) |
|
41 | - { |
|
42 | - $this->model = $model; |
|
43 | - $this->requested_version = (string) $requested_version; |
|
44 | - $this->writing = filter_var($writing, FILTER_VALIDATE_BOOLEAN); |
|
45 | - } |
|
34 | + /** |
|
35 | + * RestIncomingQueryParamContext constructor. |
|
36 | + * @param EEM_Base $model |
|
37 | + * @param string $requested_version |
|
38 | + * @param boolean $writing |
|
39 | + */ |
|
40 | + public function __construct(EEM_Base $model, $requested_version, $writing) |
|
41 | + { |
|
42 | + $this->model = $model; |
|
43 | + $this->requested_version = (string) $requested_version; |
|
44 | + $this->writing = filter_var($writing, FILTER_VALIDATE_BOOLEAN); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Gets the model currently being requested, eg class EEM_Event |
|
49 | - * @since 4.9.72.p |
|
50 | - * @return EEM_Base |
|
51 | - */ |
|
52 | - public function getModel() |
|
53 | - { |
|
54 | - return $this->model; |
|
55 | - } |
|
47 | + /** |
|
48 | + * Gets the model currently being requested, eg class EEM_Event |
|
49 | + * @since 4.9.72.p |
|
50 | + * @return EEM_Base |
|
51 | + */ |
|
52 | + public function getModel() |
|
53 | + { |
|
54 | + return $this->model; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Gets the version being requested, eg 4.8.36 |
|
59 | - * @since 4.9.72.p |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function getRequestedVersion() |
|
63 | - { |
|
64 | - return $this->requested_version; |
|
65 | - } |
|
57 | + /** |
|
58 | + * Gets the version being requested, eg 4.8.36 |
|
59 | + * @since 4.9.72.p |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function getRequestedVersion() |
|
63 | + { |
|
64 | + return $this->requested_version; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Gets if the current request is for a writing request or just simple read |
|
69 | - * @since 4.9.72.p |
|
70 | - * @return bool |
|
71 | - */ |
|
72 | - public function isWriting() |
|
73 | - { |
|
74 | - return $this->writing; |
|
75 | - } |
|
67 | + /** |
|
68 | + * Gets if the current request is for a writing request or just simple read |
|
69 | + * @since 4.9.72.p |
|
70 | + * @return bool |
|
71 | + */ |
|
72 | + public function isWriting() |
|
73 | + { |
|
74 | + return $this->writing; |
|
75 | + } |
|
76 | 76 | } |
77 | 77 | // End of file RestIncomingQueryParamContext.php |
78 | 78 | // Location: EventEspresso\core\libraries\rest_api/RestIncomingQueryParamContext.php |
@@ -8,7 +8,7 @@ |
||
8 | 8 | /** |
9 | 9 | * Function was added in WordPress 4.4.0 |
10 | 10 | * |
11 | - * @param null $post |
|
11 | + * @param integer $post |
|
12 | 12 | * @param array $query_args |
13 | 13 | * @param string $preview_link |
14 | 14 | * @return mixed |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * Note: this file should only be required right before calling the function the shim is for. This is to ensure that |
5 | 5 | * it does not override any existing definition of the function in WP. |
6 | 6 | */ |
7 | -if (! function_exists('get_preview_post_link')) { |
|
7 | +if ( ! function_exists('get_preview_post_link')) { |
|
8 | 8 | /** |
9 | 9 | * Function was added in WordPress 4.4.0 |
10 | 10 | * |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | function get_preview_post_link($post = null, $query_args = array(), $preview_link = '') |
17 | 17 | { |
18 | 18 | $post = get_post($post); |
19 | - if (! $post) { |
|
19 | + if ( ! $post) { |
|
20 | 20 | return ''; |
21 | 21 | } |
22 | 22 | |
23 | 23 | $post_type_object = get_post_type_object($post->post_type); |
24 | 24 | if (is_post_type_viewable($post_type_object)) { |
25 | - if (! $preview_link) { |
|
25 | + if ( ! $preview_link) { |
|
26 | 26 | $preview_link = set_url_scheme(get_permalink($post)); |
27 | 27 | } |
28 | 28 | |
@@ -42,12 +42,12 @@ discard block |
||
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | -if (! function_exists('is_post_type_viewable')) { |
|
45 | +if ( ! function_exists('is_post_type_viewable')) { |
|
46 | 46 | function is_post_type_viewable($post_type) |
47 | 47 | { |
48 | 48 | if (is_scalar($post_type)) { |
49 | 49 | $post_type = get_post_type_object($post_type); |
50 | - if (! $post_type) { |
|
50 | + if ( ! $post_type) { |
|
51 | 51 | return false; |
52 | 52 | } |
53 | 53 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | -if (! function_exists('wp_scripts_get_suffix')) { |
|
59 | +if ( ! function_exists('wp_scripts_get_suffix')) { |
|
60 | 60 | /** |
61 | 61 | * Returns the suffix that can be used for the scripts. |
62 | 62 | * |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | static $suffixes; |
74 | 74 | |
75 | 75 | if ($suffixes === null) { |
76 | - include(ABSPATH . WPINC . '/version.php'); // include an unmodified $wp_version |
|
76 | + include(ABSPATH.WPINC.'/version.php'); // include an unmodified $wp_version |
|
77 | 77 | |
78 | 78 | $develop_src = false !== strpos($wp_version, '-src'); |
79 | 79 | |
80 | - if (! defined('SCRIPT_DEBUG')) { |
|
80 | + if ( ! defined('SCRIPT_DEBUG')) { |
|
81 | 81 | define('SCRIPT_DEBUG', $develop_src); |
82 | 82 | } |
83 | 83 | $suffix = SCRIPT_DEBUG ? '' : '.min'; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | -if (! function_exists('get_user_locale')) { |
|
97 | +if ( ! function_exists('get_user_locale')) { |
|
98 | 98 | /** |
99 | 99 | * Shim for get_user_locale that was added in WP 4.7.0 |
100 | 100 | * |
@@ -5,105 +5,105 @@ |
||
5 | 5 | * it does not override any existing definition of the function in WP. |
6 | 6 | */ |
7 | 7 | if (! function_exists('get_preview_post_link')) { |
8 | - /** |
|
9 | - * Function was added in WordPress 4.4.0 |
|
10 | - * |
|
11 | - * @param null $post |
|
12 | - * @param array $query_args |
|
13 | - * @param string $preview_link |
|
14 | - * @return mixed |
|
15 | - */ |
|
16 | - function get_preview_post_link($post = null, $query_args = array(), $preview_link = '') |
|
17 | - { |
|
18 | - $post = get_post($post); |
|
19 | - if (! $post) { |
|
20 | - return ''; |
|
21 | - } |
|
8 | + /** |
|
9 | + * Function was added in WordPress 4.4.0 |
|
10 | + * |
|
11 | + * @param null $post |
|
12 | + * @param array $query_args |
|
13 | + * @param string $preview_link |
|
14 | + * @return mixed |
|
15 | + */ |
|
16 | + function get_preview_post_link($post = null, $query_args = array(), $preview_link = '') |
|
17 | + { |
|
18 | + $post = get_post($post); |
|
19 | + if (! $post) { |
|
20 | + return ''; |
|
21 | + } |
|
22 | 22 | |
23 | - $post_type_object = get_post_type_object($post->post_type); |
|
24 | - if (is_post_type_viewable($post_type_object)) { |
|
25 | - if (! $preview_link) { |
|
26 | - $preview_link = set_url_scheme(get_permalink($post)); |
|
27 | - } |
|
23 | + $post_type_object = get_post_type_object($post->post_type); |
|
24 | + if (is_post_type_viewable($post_type_object)) { |
|
25 | + if (! $preview_link) { |
|
26 | + $preview_link = set_url_scheme(get_permalink($post)); |
|
27 | + } |
|
28 | 28 | |
29 | - $query_args['preview'] = 'true'; |
|
30 | - $preview_link = add_query_arg($query_args, $preview_link); |
|
31 | - } |
|
29 | + $query_args['preview'] = 'true'; |
|
30 | + $preview_link = add_query_arg($query_args, $preview_link); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Filters the URL used for a post preview. |
|
35 | - * |
|
36 | - * @since 2.0.5 |
|
37 | - * @since 4.0.0 Added the `$post` parameter. |
|
38 | - * @param string $preview_link URL used for the post preview. |
|
39 | - * @param WP_Post $post Post object. |
|
40 | - */ |
|
41 | - return apply_filters('preview_post_link', $preview_link, $post); |
|
42 | - } |
|
33 | + /** |
|
34 | + * Filters the URL used for a post preview. |
|
35 | + * |
|
36 | + * @since 2.0.5 |
|
37 | + * @since 4.0.0 Added the `$post` parameter. |
|
38 | + * @param string $preview_link URL used for the post preview. |
|
39 | + * @param WP_Post $post Post object. |
|
40 | + */ |
|
41 | + return apply_filters('preview_post_link', $preview_link, $post); |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | if (! function_exists('is_post_type_viewable')) { |
46 | - function is_post_type_viewable($post_type) |
|
47 | - { |
|
48 | - if (is_scalar($post_type)) { |
|
49 | - $post_type = get_post_type_object($post_type); |
|
50 | - if (! $post_type) { |
|
51 | - return false; |
|
52 | - } |
|
53 | - } |
|
46 | + function is_post_type_viewable($post_type) |
|
47 | + { |
|
48 | + if (is_scalar($post_type)) { |
|
49 | + $post_type = get_post_type_object($post_type); |
|
50 | + if (! $post_type) { |
|
51 | + return false; |
|
52 | + } |
|
53 | + } |
|
54 | 54 | |
55 | - return $post_type->publicly_queryable || ($post_type->_builtin && $post_type->public); |
|
56 | - } |
|
55 | + return $post_type->publicly_queryable || ($post_type->_builtin && $post_type->public); |
|
56 | + } |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | if (! function_exists('wp_scripts_get_suffix')) { |
60 | - /** |
|
61 | - * Returns the suffix that can be used for the scripts. |
|
62 | - * |
|
63 | - * There are two suffix types, the normal one and the dev suffix. |
|
64 | - * |
|
65 | - * @since 5.0.0 |
|
66 | - * |
|
67 | - * @param string $type The type of suffix to retrieve. |
|
68 | - * @return string The script suffix. |
|
69 | - */ |
|
70 | - function wp_scripts_get_suffix($type = '') |
|
71 | - { |
|
72 | - global $wp_version; |
|
73 | - static $suffixes; |
|
60 | + /** |
|
61 | + * Returns the suffix that can be used for the scripts. |
|
62 | + * |
|
63 | + * There are two suffix types, the normal one and the dev suffix. |
|
64 | + * |
|
65 | + * @since 5.0.0 |
|
66 | + * |
|
67 | + * @param string $type The type of suffix to retrieve. |
|
68 | + * @return string The script suffix. |
|
69 | + */ |
|
70 | + function wp_scripts_get_suffix($type = '') |
|
71 | + { |
|
72 | + global $wp_version; |
|
73 | + static $suffixes; |
|
74 | 74 | |
75 | - if ($suffixes === null) { |
|
76 | - include(ABSPATH . WPINC . '/version.php'); // include an unmodified $wp_version |
|
75 | + if ($suffixes === null) { |
|
76 | + include(ABSPATH . WPINC . '/version.php'); // include an unmodified $wp_version |
|
77 | 77 | |
78 | - $develop_src = false !== strpos($wp_version, '-src'); |
|
78 | + $develop_src = false !== strpos($wp_version, '-src'); |
|
79 | 79 | |
80 | - if (! defined('SCRIPT_DEBUG')) { |
|
81 | - define('SCRIPT_DEBUG', $develop_src); |
|
82 | - } |
|
83 | - $suffix = SCRIPT_DEBUG ? '' : '.min'; |
|
84 | - $dev_suffix = $develop_src ? '' : '.min'; |
|
80 | + if (! defined('SCRIPT_DEBUG')) { |
|
81 | + define('SCRIPT_DEBUG', $develop_src); |
|
82 | + } |
|
83 | + $suffix = SCRIPT_DEBUG ? '' : '.min'; |
|
84 | + $dev_suffix = $develop_src ? '' : '.min'; |
|
85 | 85 | |
86 | - $suffixes = array('suffix' => $suffix, 'dev_suffix' => $dev_suffix); |
|
87 | - } |
|
86 | + $suffixes = array('suffix' => $suffix, 'dev_suffix' => $dev_suffix); |
|
87 | + } |
|
88 | 88 | |
89 | - if ($type === 'dev') { |
|
90 | - return $suffixes['dev_suffix']; |
|
91 | - } |
|
89 | + if ($type === 'dev') { |
|
90 | + return $suffixes['dev_suffix']; |
|
91 | + } |
|
92 | 92 | |
93 | - return $suffixes['suffix']; |
|
94 | - } |
|
93 | + return $suffixes['suffix']; |
|
94 | + } |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | if (! function_exists('get_user_locale')) { |
98 | - /** |
|
99 | - * Shim for get_user_locale that was added in WP 4.7.0 |
|
100 | - * |
|
101 | - * @param int $user_id |
|
102 | - * @return string |
|
103 | - * @since 4.9.73.p |
|
104 | - */ |
|
105 | - function get_user_locale($user_id = 0) |
|
106 | - { |
|
107 | - return get_locale(); |
|
108 | - } |
|
98 | + /** |
|
99 | + * Shim for get_user_locale that was added in WP 4.7.0 |
|
100 | + * |
|
101 | + * @param int $user_id |
|
102 | + * @return string |
|
103 | + * @since 4.9.73.p |
|
104 | + */ |
|
105 | + function get_user_locale($user_id = 0) |
|
106 | + { |
|
107 | + return get_locale(); |
|
108 | + } |
|
109 | 109 | } |
110 | 110 | \ No newline at end of file |
@@ -38,103 +38,103 @@ |
||
38 | 38 | * @since 4.0 |
39 | 39 | */ |
40 | 40 | if (function_exists('espresso_version')) { |
41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | - /** |
|
43 | - * espresso_duplicate_plugin_error |
|
44 | - * displays if more than one version of EE is activated at the same time |
|
45 | - */ |
|
46 | - function espresso_duplicate_plugin_error() |
|
47 | - { |
|
48 | - ?> |
|
41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
42 | + /** |
|
43 | + * espresso_duplicate_plugin_error |
|
44 | + * displays if more than one version of EE is activated at the same time |
|
45 | + */ |
|
46 | + function espresso_duplicate_plugin_error() |
|
47 | + { |
|
48 | + ?> |
|
49 | 49 | <div class="error"> |
50 | 50 | <p> |
51 | 51 | <?php |
52 | - echo esc_html__( |
|
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
52 | + echo esc_html__( |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
61 | - } |
|
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | + } |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.4.0'); |
|
65 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | - /** |
|
98 | - * espresso_version |
|
99 | - * Returns the plugin version |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function espresso_version() |
|
104 | - { |
|
105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.74.rc.001'); |
|
106 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
97 | + /** |
|
98 | + * espresso_version |
|
99 | + * Returns the plugin version |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function espresso_version() |
|
104 | + { |
|
105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.74.rc.001'); |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * espresso_plugin_activation |
|
110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | - */ |
|
112 | - function espresso_plugin_activation() |
|
113 | - { |
|
114 | - update_option('ee_espresso_activation', true); |
|
115 | - } |
|
108 | + /** |
|
109 | + * espresso_plugin_activation |
|
110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
111 | + */ |
|
112 | + function espresso_plugin_activation() |
|
113 | + { |
|
114 | + update_option('ee_espresso_activation', true); |
|
115 | + } |
|
116 | 116 | |
117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
118 | 118 | |
119 | - require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | - bootstrap_espresso(); |
|
121 | - } |
|
119 | + require_once __DIR__ . '/core/bootstrap_espresso.php'; |
|
120 | + bootstrap_espresso(); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | if (! function_exists('espresso_deactivate_plugin')) { |
124 | - /** |
|
125 | - * deactivate_plugin |
|
126 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | - * |
|
128 | - * @access public |
|
129 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | - * @return void |
|
131 | - */ |
|
132 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | - { |
|
134 | - if (! function_exists('deactivate_plugins')) { |
|
135 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | - } |
|
137 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | - deactivate_plugins($plugin_basename); |
|
139 | - } |
|
124 | + /** |
|
125 | + * deactivate_plugin |
|
126 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
127 | + * |
|
128 | + * @access public |
|
129 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
130 | + * @return void |
|
131 | + */ |
|
132 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
133 | + { |
|
134 | + if (! function_exists('deactivate_plugins')) { |
|
135 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
136 | + } |
|
137 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
138 | + deactivate_plugins($plugin_basename); |
|
139 | + } |
|
140 | 140 | } |