@@ -16,55 +16,55 @@ |
||
16 | 16 | interface DomainInterface extends InterminableInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @return string |
|
21 | - * @throws DomainException |
|
22 | - */ |
|
23 | - public function pluginFile(); |
|
19 | + /** |
|
20 | + * @return string |
|
21 | + * @throws DomainException |
|
22 | + */ |
|
23 | + public function pluginFile(); |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @return string |
|
28 | - * @throws DomainException |
|
29 | - */ |
|
30 | - public function pluginBasename(); |
|
26 | + /** |
|
27 | + * @return string |
|
28 | + * @throws DomainException |
|
29 | + */ |
|
30 | + public function pluginBasename(); |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @return string |
|
35 | - */ |
|
36 | - public function pluginPath(); |
|
33 | + /** |
|
34 | + * @return string |
|
35 | + */ |
|
36 | + public function pluginPath(); |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @return string |
|
41 | - * @throws DomainException |
|
42 | - */ |
|
43 | - public function pluginUrl(); |
|
39 | + /** |
|
40 | + * @return string |
|
41 | + * @throws DomainException |
|
42 | + */ |
|
43 | + public function pluginUrl(); |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * @return string |
|
48 | - * @throws DomainException |
|
49 | - */ |
|
50 | - public function version(); |
|
46 | + /** |
|
47 | + * @return string |
|
48 | + * @throws DomainException |
|
49 | + */ |
|
50 | + public function version(); |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - public function distributionAssetsPath(); |
|
53 | + /** |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + public function distributionAssetsPath(); |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function distributionAssetsUrl(); |
|
59 | + /** |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function distributionAssetsUrl(); |
|
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function assetNamespace(); |
|
65 | + /** |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function assetNamespace(); |
|
69 | 69 | |
70 | 70 | } |
@@ -20,55 +20,55 @@ |
||
20 | 20 | class BlockCollection extends Collection |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Collection constructor |
|
25 | - * |
|
26 | - * @throws InvalidInterfaceException |
|
27 | - */ |
|
28 | - public function __construct() |
|
29 | - { |
|
30 | - parent::__construct('EventEspresso\core\domain\entities\editor\BlockInterface'); |
|
31 | - } |
|
23 | + /** |
|
24 | + * Collection constructor |
|
25 | + * |
|
26 | + * @throws InvalidInterfaceException |
|
27 | + */ |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + parent::__construct('EventEspresso\core\domain\entities\editor\BlockInterface'); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * unRegisterBlock |
|
36 | - * finds block in the Collection based on the identifier that was set using addObject() |
|
37 | - * and calls unRegisterBlock() on it. Returns block if successful and false if block was not found. |
|
38 | - * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
|
39 | - * |
|
40 | - * @param mixed $identifier |
|
41 | - * @return boolean |
|
42 | - */ |
|
43 | - public function unRegisterBlock($identifier) |
|
44 | - { |
|
45 | - $this->rewind(); |
|
46 | - while ($this->valid()) { |
|
47 | - if ($identifier === $this->getInfo()) { |
|
48 | - $object = $this->current(); |
|
49 | - $this->rewind(); |
|
50 | - return $object->unRegisterBlock(); |
|
51 | - } |
|
52 | - $this->next(); |
|
53 | - } |
|
54 | - return false; |
|
55 | - } |
|
34 | + /** |
|
35 | + * unRegisterBlock |
|
36 | + * finds block in the Collection based on the identifier that was set using addObject() |
|
37 | + * and calls unRegisterBlock() on it. Returns block if successful and false if block was not found. |
|
38 | + * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
|
39 | + * |
|
40 | + * @param mixed $identifier |
|
41 | + * @return boolean |
|
42 | + */ |
|
43 | + public function unRegisterBlock($identifier) |
|
44 | + { |
|
45 | + $this->rewind(); |
|
46 | + while ($this->valid()) { |
|
47 | + if ($identifier === $this->getInfo()) { |
|
48 | + $object = $this->current(); |
|
49 | + $this->rewind(); |
|
50 | + return $object->unRegisterBlock(); |
|
51 | + } |
|
52 | + $this->next(); |
|
53 | + } |
|
54 | + return false; |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * unRegisterAllBlocks |
|
60 | - * calls unRegisterBlock() on all blocks in Collection. |
|
61 | - * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
|
62 | - * |
|
63 | - * @return void |
|
64 | - */ |
|
65 | - public function unRegisterAllBlocks() |
|
66 | - { |
|
67 | - $this->rewind(); |
|
68 | - while ($this->valid()) { |
|
69 | - $this->current()->unRegisterBlock(); |
|
70 | - $this->next(); |
|
71 | - } |
|
72 | - $this->rewind(); |
|
73 | - } |
|
58 | + /** |
|
59 | + * unRegisterAllBlocks |
|
60 | + * calls unRegisterBlock() on all blocks in Collection. |
|
61 | + * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
|
62 | + * |
|
63 | + * @return void |
|
64 | + */ |
|
65 | + public function unRegisterAllBlocks() |
|
66 | + { |
|
67 | + $this->rewind(); |
|
68 | + while ($this->valid()) { |
|
69 | + $this->current()->unRegisterBlock(); |
|
70 | + $this->next(); |
|
71 | + } |
|
72 | + $this->rewind(); |
|
73 | + } |
|
74 | 74 | } |
@@ -16,26 +16,26 @@ |
||
16 | 16 | class InvalidCollectionIdentifierException extends OutOfBoundsException |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * InvalidCollectionIdentifierException constructor. |
|
21 | - * |
|
22 | - * @param $identifier |
|
23 | - * @param string $message |
|
24 | - * @param int $code |
|
25 | - * @param Exception|null $previous |
|
26 | - */ |
|
27 | - public function __construct($identifier, $message = '', $code = 0, Exception $previous = null) |
|
28 | - { |
|
29 | - if (empty($message)) { |
|
30 | - $message = sprintf( |
|
31 | - __( |
|
32 | - 'The supplied identifier "%1$s" does not exist within this collection. |
|
19 | + /** |
|
20 | + * InvalidCollectionIdentifierException constructor. |
|
21 | + * |
|
22 | + * @param $identifier |
|
23 | + * @param string $message |
|
24 | + * @param int $code |
|
25 | + * @param Exception|null $previous |
|
26 | + */ |
|
27 | + public function __construct($identifier, $message = '', $code = 0, Exception $previous = null) |
|
28 | + { |
|
29 | + if (empty($message)) { |
|
30 | + $message = sprintf( |
|
31 | + __( |
|
32 | + 'The supplied identifier "%1$s" does not exist within this collection. |
|
33 | 33 | You may need to delay adding this asset until the required dependency has been added.', |
34 | - 'event_espresso' |
|
35 | - ), |
|
36 | - $identifier |
|
37 | - ); |
|
38 | - } |
|
39 | - parent::__construct($message, $code, $previous); |
|
40 | - } |
|
34 | + 'event_espresso' |
|
35 | + ), |
|
36 | + $identifier |
|
37 | + ); |
|
38 | + } |
|
39 | + parent::__construct($message, $code, $previous); |
|
40 | + } |
|
41 | 41 | } |
@@ -16,25 +16,25 @@ |
||
16 | 16 | class DuplicateCollectionIdentifierException extends OutOfRangeException |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * DuplicateCollectionIdentifierException constructor. |
|
21 | - * |
|
22 | - * @param $identifier |
|
23 | - * @param string $message |
|
24 | - * @param int $code |
|
25 | - * @param Exception|null $previous |
|
26 | - */ |
|
27 | - public function __construct($identifier, $message = '', $code = 0, Exception $previous = null) |
|
28 | - { |
|
29 | - if (empty($message)) { |
|
30 | - $message = sprintf( |
|
31 | - __( |
|
32 | - 'The supplied identifier "%1$s" already exists within this collection.', |
|
33 | - 'event_espresso' |
|
34 | - ), |
|
35 | - $identifier |
|
36 | - ); |
|
37 | - } |
|
38 | - parent::__construct($message, $code, $previous); |
|
39 | - } |
|
19 | + /** |
|
20 | + * DuplicateCollectionIdentifierException constructor. |
|
21 | + * |
|
22 | + * @param $identifier |
|
23 | + * @param string $message |
|
24 | + * @param int $code |
|
25 | + * @param Exception|null $previous |
|
26 | + */ |
|
27 | + public function __construct($identifier, $message = '', $code = 0, Exception $previous = null) |
|
28 | + { |
|
29 | + if (empty($message)) { |
|
30 | + $message = sprintf( |
|
31 | + __( |
|
32 | + 'The supplied identifier "%1$s" already exists within this collection.', |
|
33 | + 'event_espresso' |
|
34 | + ), |
|
35 | + $identifier |
|
36 | + ); |
|
37 | + } |
|
38 | + parent::__construct($message, $code, $previous); |
|
39 | + } |
|
40 | 40 | } |
@@ -21,86 +21,86 @@ |
||
21 | 21 | { |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * AssetCollection constructor |
|
26 | - * |
|
27 | - * @throws InvalidInterfaceException |
|
28 | - */ |
|
29 | - public function __construct() |
|
30 | - { |
|
31 | - parent::__construct('EventEspresso\core\domain\values\assets\Asset'); |
|
32 | - } |
|
24 | + /** |
|
25 | + * AssetCollection constructor |
|
26 | + * |
|
27 | + * @throws InvalidInterfaceException |
|
28 | + */ |
|
29 | + public function __construct() |
|
30 | + { |
|
31 | + parent::__construct('EventEspresso\core\domain\values\assets\Asset'); |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * @return StylesheetAsset[] |
|
37 | - * @since $VID:$ |
|
38 | - */ |
|
39 | - public function getStylesheetAssets() |
|
40 | - { |
|
41 | - return $this->getAssetsOfType(Asset::TYPE_CSS); |
|
42 | - } |
|
35 | + /** |
|
36 | + * @return StylesheetAsset[] |
|
37 | + * @since $VID:$ |
|
38 | + */ |
|
39 | + public function getStylesheetAssets() |
|
40 | + { |
|
41 | + return $this->getAssetsOfType(Asset::TYPE_CSS); |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * @return JavascriptAsset[] |
|
47 | - * @since $VID:$ |
|
48 | - */ |
|
49 | - public function getJavascriptAssets() |
|
50 | - { |
|
51 | - return $this->getAssetsOfType(Asset::TYPE_JS); |
|
52 | - } |
|
45 | + /** |
|
46 | + * @return JavascriptAsset[] |
|
47 | + * @since $VID:$ |
|
48 | + */ |
|
49 | + public function getJavascriptAssets() |
|
50 | + { |
|
51 | + return $this->getAssetsOfType(Asset::TYPE_JS); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * @return ManifestFile[] |
|
57 | - * @since $VID:$ |
|
58 | - */ |
|
59 | - public function getManifestFiles() |
|
60 | - { |
|
61 | - return $this->getAssetsOfType(Asset::TYPE_MANIFEST); |
|
62 | - } |
|
55 | + /** |
|
56 | + * @return ManifestFile[] |
|
57 | + * @since $VID:$ |
|
58 | + */ |
|
59 | + public function getManifestFiles() |
|
60 | + { |
|
61 | + return $this->getAssetsOfType(Asset::TYPE_MANIFEST); |
|
62 | + } |
|
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * @param $type |
|
67 | - * @return array |
|
68 | - * @since $VID:$ |
|
69 | - */ |
|
70 | - protected function getAssetsOfType($type) |
|
71 | - { |
|
72 | - $files = array(); |
|
73 | - $this->rewind(); |
|
74 | - while ($this->valid()) { |
|
75 | - /** @var \EventEspresso\core\domain\values\assets\Asset $asset */ |
|
76 | - $asset = $this->current(); |
|
77 | - if ($asset->type() === $type) { |
|
78 | - $files[ $asset->handle() ] = $asset; |
|
79 | - } |
|
80 | - $this->next(); |
|
81 | - } |
|
82 | - $this->rewind(); |
|
83 | - return $files; |
|
84 | - } |
|
65 | + /** |
|
66 | + * @param $type |
|
67 | + * @return array |
|
68 | + * @since $VID:$ |
|
69 | + */ |
|
70 | + protected function getAssetsOfType($type) |
|
71 | + { |
|
72 | + $files = array(); |
|
73 | + $this->rewind(); |
|
74 | + while ($this->valid()) { |
|
75 | + /** @var \EventEspresso\core\domain\values\assets\Asset $asset */ |
|
76 | + $asset = $this->current(); |
|
77 | + if ($asset->type() === $type) { |
|
78 | + $files[ $asset->handle() ] = $asset; |
|
79 | + } |
|
80 | + $this->next(); |
|
81 | + } |
|
82 | + $this->rewind(); |
|
83 | + return $files; |
|
84 | + } |
|
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * @return JavascriptAsset[] |
|
89 | - * @since $VID:$ |
|
90 | - */ |
|
91 | - public function getJavascriptAssetsWithData() |
|
92 | - { |
|
93 | - $files = array(); |
|
94 | - $this->rewind(); |
|
95 | - while ($this->valid()) { |
|
96 | - /** @var \EventEspresso\core\domain\values\assets\JavascriptAsset $asset */ |
|
97 | - $asset = $this->current(); |
|
98 | - if ($asset->type() === Asset::TYPE_JS && $asset->hasLocalizedData()) { |
|
99 | - $files[ $asset->handle() ] = $asset; |
|
100 | - } |
|
101 | - $this->next(); |
|
102 | - } |
|
103 | - $this->rewind(); |
|
104 | - return $files; |
|
105 | - } |
|
87 | + /** |
|
88 | + * @return JavascriptAsset[] |
|
89 | + * @since $VID:$ |
|
90 | + */ |
|
91 | + public function getJavascriptAssetsWithData() |
|
92 | + { |
|
93 | + $files = array(); |
|
94 | + $this->rewind(); |
|
95 | + while ($this->valid()) { |
|
96 | + /** @var \EventEspresso\core\domain\values\assets\JavascriptAsset $asset */ |
|
97 | + $asset = $this->current(); |
|
98 | + if ($asset->type() === Asset::TYPE_JS && $asset->hasLocalizedData()) { |
|
99 | + $files[ $asset->handle() ] = $asset; |
|
100 | + } |
|
101 | + $this->next(); |
|
102 | + } |
|
103 | + $this->rewind(); |
|
104 | + return $files; |
|
105 | + } |
|
106 | 106 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | /** @var \EventEspresso\core\domain\values\assets\Asset $asset */ |
76 | 76 | $asset = $this->current(); |
77 | 77 | if ($asset->type() === $type) { |
78 | - $files[ $asset->handle() ] = $asset; |
|
78 | + $files[$asset->handle()] = $asset; |
|
79 | 79 | } |
80 | 80 | $this->next(); |
81 | 81 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | /** @var \EventEspresso\core\domain\values\assets\JavascriptAsset $asset */ |
97 | 97 | $asset = $this->current(); |
98 | 98 | if ($asset->type() === Asset::TYPE_JS && $asset->hasLocalizedData()) { |
99 | - $files[ $asset->handle() ] = $asset; |
|
99 | + $files[$asset->handle()] = $asset; |
|
100 | 100 | } |
101 | 101 | $this->next(); |
102 | 102 | } |
@@ -20,71 +20,71 @@ |
||
20 | 20 | interface AssetManagerInterface |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @return ManifestFile |
|
25 | - * @throws DuplicateCollectionIdentifierException |
|
26 | - * @throws InvalidDataTypeException |
|
27 | - * @throws InvalidEntityException |
|
28 | - * @since $VID:$ |
|
29 | - */ |
|
30 | - public function addManifestFile(); |
|
23 | + /** |
|
24 | + * @return ManifestFile |
|
25 | + * @throws DuplicateCollectionIdentifierException |
|
26 | + * @throws InvalidDataTypeException |
|
27 | + * @throws InvalidEntityException |
|
28 | + * @since $VID:$ |
|
29 | + */ |
|
30 | + public function addManifestFile(); |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @return ManifestFile[] |
|
35 | - * @since $VID:$ |
|
36 | - */ |
|
37 | - public function getManifestFile(); |
|
33 | + /** |
|
34 | + * @return ManifestFile[] |
|
35 | + * @since $VID:$ |
|
36 | + */ |
|
37 | + public function getManifestFile(); |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @param string $handle |
|
42 | - * @param string $source |
|
43 | - * @param array $dependencies |
|
44 | - * @param bool $load_in_footer |
|
45 | - * @return JavascriptAsset |
|
46 | - * @throws DuplicateCollectionIdentifierException |
|
47 | - * @throws InvalidDataTypeException |
|
48 | - * @throws InvalidEntityException |
|
49 | - * @since $VID:$ |
|
50 | - */ |
|
51 | - public function addJavascript( |
|
52 | - $handle, |
|
53 | - $source, |
|
54 | - array $dependencies = array(), |
|
55 | - $load_in_footer = true |
|
56 | - ); |
|
40 | + /** |
|
41 | + * @param string $handle |
|
42 | + * @param string $source |
|
43 | + * @param array $dependencies |
|
44 | + * @param bool $load_in_footer |
|
45 | + * @return JavascriptAsset |
|
46 | + * @throws DuplicateCollectionIdentifierException |
|
47 | + * @throws InvalidDataTypeException |
|
48 | + * @throws InvalidEntityException |
|
49 | + * @since $VID:$ |
|
50 | + */ |
|
51 | + public function addJavascript( |
|
52 | + $handle, |
|
53 | + $source, |
|
54 | + array $dependencies = array(), |
|
55 | + $load_in_footer = true |
|
56 | + ); |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * @return JavascriptAsset[] |
|
61 | - * @since $VID:$ |
|
62 | - */ |
|
63 | - public function getJavascriptAssets(); |
|
59 | + /** |
|
60 | + * @return JavascriptAsset[] |
|
61 | + * @since $VID:$ |
|
62 | + */ |
|
63 | + public function getJavascriptAssets(); |
|
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * @param string $handle |
|
68 | - * @param string $source |
|
69 | - * @param array $dependencies |
|
70 | - * @param string $media |
|
71 | - * @return StylesheetAsset |
|
72 | - * @throws DuplicateCollectionIdentifierException |
|
73 | - * @throws InvalidDataTypeException |
|
74 | - * @throws InvalidEntityException |
|
75 | - * @since $VID:$ |
|
76 | - */ |
|
77 | - public function addStylesheet( |
|
78 | - $handle, |
|
79 | - $source, |
|
80 | - array $dependencies = array(), |
|
81 | - $media = 'all' |
|
82 | - ); |
|
66 | + /** |
|
67 | + * @param string $handle |
|
68 | + * @param string $source |
|
69 | + * @param array $dependencies |
|
70 | + * @param string $media |
|
71 | + * @return StylesheetAsset |
|
72 | + * @throws DuplicateCollectionIdentifierException |
|
73 | + * @throws InvalidDataTypeException |
|
74 | + * @throws InvalidEntityException |
|
75 | + * @since $VID:$ |
|
76 | + */ |
|
77 | + public function addStylesheet( |
|
78 | + $handle, |
|
79 | + $source, |
|
80 | + array $dependencies = array(), |
|
81 | + $media = 'all' |
|
82 | + ); |
|
83 | 83 | |
84 | 84 | |
85 | - /** |
|
86 | - * @return StylesheetAsset[] |
|
87 | - * @since $VID:$ |
|
88 | - */ |
|
89 | - public function getStylesheetAssets(); |
|
85 | + /** |
|
86 | + * @return StylesheetAsset[] |
|
87 | + * @since $VID:$ |
|
88 | + */ |
|
89 | + public function getStylesheetAssets(); |
|
90 | 90 | } |
@@ -16,28 +16,28 @@ |
||
16 | 16 | class InvalidIdentifierException extends InvalidArgumentException |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * InvalidIdentifierException constructor. |
|
21 | - * |
|
22 | - * @param string $actual the identifier that was supplied |
|
23 | - * @param string $expected example of an acceptable identifier |
|
24 | - * @param string $message |
|
25 | - * @param int $code |
|
26 | - * @param Exception $previous |
|
27 | - */ |
|
28 | - public function __construct($actual, $expected, $message = '', $code = 0, Exception $previous = null) |
|
29 | - { |
|
30 | - if (empty($message)) { |
|
31 | - $message = sprintf( |
|
32 | - __( |
|
33 | - 'The supplied identifier "%1$s" is invalid. A value like "%2$s" was expected.', |
|
34 | - 'event_espresso' |
|
35 | - ), |
|
36 | - $actual, |
|
37 | - $expected |
|
38 | - ); |
|
39 | - } |
|
40 | - parent::__construct($message, $code, $previous); |
|
41 | - } |
|
19 | + /** |
|
20 | + * InvalidIdentifierException constructor. |
|
21 | + * |
|
22 | + * @param string $actual the identifier that was supplied |
|
23 | + * @param string $expected example of an acceptable identifier |
|
24 | + * @param string $message |
|
25 | + * @param int $code |
|
26 | + * @param Exception $previous |
|
27 | + */ |
|
28 | + public function __construct($actual, $expected, $message = '', $code = 0, Exception $previous = null) |
|
29 | + { |
|
30 | + if (empty($message)) { |
|
31 | + $message = sprintf( |
|
32 | + __( |
|
33 | + 'The supplied identifier "%1$s" is invalid. A value like "%2$s" was expected.', |
|
34 | + 'event_espresso' |
|
35 | + ), |
|
36 | + $actual, |
|
37 | + $expected |
|
38 | + ); |
|
39 | + } |
|
40 | + parent::__construct($message, $code, $previous); |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | // Location: core/exceptions/InvalidIdentifierException.php |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | //js.api |
176 | 176 | $this->addJavascript( |
177 | 177 | CoreAssetManager::JS_HANDLE_EE_JS_API, |
178 | - EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
178 | + EE_LIBRARIES_URL.'rest_api/assets/js/eejs-api.min.js', |
|
179 | 179 | array( |
180 | 180 | CoreAssetManager::JS_HANDLE_UNDERSCORE, |
181 | 181 | CoreAssetManager::JS_HANDLE_EE_JS_CORE |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | |
188 | 188 | $this->addJavascript( |
189 | 189 | CoreAssetManager::JS_HANDLE_EE_CORE, |
190 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
190 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', |
|
191 | 191 | array(CoreAssetManager::JS_HANDLE_JQUERY) |
192 | 192 | ) |
193 | 193 | ->setLocalizationCallback( |
194 | - function () { |
|
194 | + function() { |
|
195 | 195 | wp_localize_script( |
196 | 196 | CoreAssetManager::JS_HANDLE_EE_CORE, |
197 | 197 | CoreAssetManager::JS_HANDLE_EE_I18N, |
@@ -213,16 +213,16 @@ discard block |
||
213 | 213 | if ($this->template_config->enable_default_style && ! is_admin()) { |
214 | 214 | $this->addStylesheet( |
215 | 215 | CoreAssetManager::CSS_HANDLE_EE_DEFAULT, |
216 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
216 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css') |
|
217 | 217 | ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
218 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
218 | + : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
219 | 219 | array('dashicons') |
220 | 220 | ); |
221 | 221 | //Load custom style sheet if available |
222 | 222 | if ($this->template_config->custom_style_sheet !== null) { |
223 | 223 | $this->addStylesheet( |
224 | 224 | CoreAssetManager::CSS_HANDLE_EE_CUSTOM, |
225 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
225 | + EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet, |
|
226 | 226 | array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT) |
227 | 227 | ); |
228 | 228 | } |
@@ -242,14 +242,14 @@ discard block |
||
242 | 242 | { |
243 | 243 | $this->addJavascript( |
244 | 244 | CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
245 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
245 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', |
|
246 | 246 | array(CoreAssetManager::JS_HANDLE_JQUERY) |
247 | 247 | ) |
248 | 248 | ->setVersion('1.15.0'); |
249 | 249 | |
250 | 250 | $this->addJavascript( |
251 | 251 | CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
252 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
252 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', |
|
253 | 253 | array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
254 | 254 | ) |
255 | 255 | ->setVersion('1.15.0'); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | // @link http://josscrowcroft.github.io/accounting.js/ |
271 | 271 | $this->addJavascript( |
272 | 272 | CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
273 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
273 | + EE_THIRD_PARTY_URL.'accounting/accounting.js', |
|
274 | 274 | array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
275 | 275 | ) |
276 | 276 | ->setVersion('0.3.2'); |
@@ -278,11 +278,11 @@ discard block |
||
278 | 278 | $currency_config = $this->currency_config; |
279 | 279 | $this->addJavascript( |
280 | 280 | CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
281 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
281 | + EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', |
|
282 | 282 | array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
283 | 283 | ) |
284 | 284 | ->setLocalizationCallback( |
285 | - function () use ($currency_config) { |
|
285 | + function() use ($currency_config) { |
|
286 | 286 | wp_localize_script( |
287 | 287 | CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
288 | 288 | 'EE_ACCOUNTING_CFG', |
@@ -27,330 +27,330 @@ |
||
27 | 27 | class CoreAssetManager extends AssetManager |
28 | 28 | { |
29 | 29 | |
30 | - // WordPress core / Third party JS asset handles |
|
31 | - const JS_HANDLE_JQUERY = 'jquery'; |
|
32 | - |
|
33 | - const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
34 | - |
|
35 | - const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
36 | - |
|
37 | - const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
38 | - |
|
39 | - const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
40 | - |
|
41 | - // EE JS assets handles |
|
42 | - const JS_HANDLE_EE_MANIFEST = 'ee-manifest'; |
|
43 | - |
|
44 | - const JS_HANDLE_EE_JS_CORE = 'eejs-core'; |
|
45 | - |
|
46 | - const JS_HANDLE_EE_VENDOR_REACT = 'ee-vendor-react'; |
|
47 | - |
|
48 | - const JS_HANDLE_EE_JS_API = 'eejs-api'; |
|
49 | - |
|
50 | - const JS_HANDLE_EE_CORE = 'espresso_core'; |
|
51 | - |
|
52 | - const JS_HANDLE_EE_I18N = 'eei18n'; |
|
53 | - |
|
54 | - const JS_HANDLE_EE_ACCOUNTING = 'ee-accounting'; |
|
55 | - |
|
56 | - const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
57 | - |
|
58 | - // EE CSS assets handles |
|
59 | - const CSS_HANDLE_EE_DEFAULT = 'espresso_default'; |
|
60 | - |
|
61 | - const CSS_HANDLE_EE_CUSTOM = 'espresso_custom_css'; |
|
62 | - |
|
63 | - /** |
|
64 | - * @var EE_Currency_Config $currency_config |
|
65 | - */ |
|
66 | - protected $currency_config; |
|
67 | - |
|
68 | - /** |
|
69 | - * @var EE_Template_Config $template_config |
|
70 | - */ |
|
71 | - protected $template_config; |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * CoreAssetRegister constructor. |
|
76 | - * |
|
77 | - * @param AssetCollection $assets |
|
78 | - * @param EE_Currency_Config $currency_config |
|
79 | - * @param EE_Template_Config $template_config |
|
80 | - * @param DomainInterface $domain |
|
81 | - * @param Registry $registry |
|
82 | - */ |
|
83 | - public function __construct( |
|
84 | - AssetCollection $assets, |
|
85 | - EE_Currency_Config $currency_config, |
|
86 | - EE_Template_Config $template_config, |
|
87 | - DomainInterface $domain, |
|
88 | - Registry $registry |
|
89 | - ) { |
|
90 | - $this->currency_config = $currency_config; |
|
91 | - $this->template_config = $template_config; |
|
92 | - parent::__construct($domain, $assets, $registry); |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @since $VID:$ |
|
98 | - * @throws DuplicateCollectionIdentifierException |
|
99 | - * @throws InvalidArgumentException |
|
100 | - * @throws InvalidDataTypeException |
|
101 | - * @throws InvalidEntityException |
|
102 | - */ |
|
103 | - public function addAssets() |
|
104 | - { |
|
105 | - $this->addJavascriptFiles(); |
|
106 | - $this->addStylesheetFiles(); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * @since $VID:$ |
|
112 | - * @throws DuplicateCollectionIdentifierException |
|
113 | - * @throws InvalidArgumentException |
|
114 | - * @throws InvalidDataTypeException |
|
115 | - * @throws InvalidEntityException |
|
116 | - */ |
|
117 | - public function addJavascriptFiles() |
|
118 | - { |
|
119 | - $this->loadCoreJs(); |
|
120 | - $this->loadJqueryValidate(); |
|
121 | - $this->loadAccountingJs(); |
|
122 | - add_action( |
|
123 | - 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
124 | - array($this, 'loadQtipJs') |
|
125 | - ); |
|
126 | - $this->registerAdminAssets(); |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * @since $VID:$ |
|
132 | - * @throws DuplicateCollectionIdentifierException |
|
133 | - * @throws InvalidDataTypeException |
|
134 | - * @throws InvalidEntityException |
|
135 | - */ |
|
136 | - public function addStylesheetFiles() |
|
137 | - { |
|
138 | - $this->loadCoreCss(); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * core default javascript |
|
144 | - * |
|
145 | - * @since $VID:$ |
|
146 | - * @throws DuplicateCollectionIdentifierException |
|
147 | - * @throws InvalidArgumentException |
|
148 | - * @throws InvalidDataTypeException |
|
149 | - * @throws InvalidEntityException |
|
150 | - */ |
|
151 | - private function loadCoreJs() |
|
152 | - { |
|
153 | - $this->addJavascript( |
|
154 | - CoreAssetManager::JS_HANDLE_EE_MANIFEST, |
|
155 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
156 | - ); |
|
157 | - |
|
158 | - $this->addJavascript( |
|
159 | - CoreAssetManager::JS_HANDLE_EE_JS_CORE, |
|
160 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
161 | - array(CoreAssetManager::JS_HANDLE_EE_MANIFEST) |
|
162 | - ) |
|
163 | - ->setRequiresTranslation() |
|
164 | - ->setHasLocalizedData(); |
|
165 | - |
|
166 | - $this->addJavascript( |
|
167 | - CoreAssetManager::JS_HANDLE_EE_VENDOR_REACT, |
|
168 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'reactVendor'), |
|
169 | - array(CoreAssetManager::JS_HANDLE_EE_JS_CORE) |
|
170 | - ); |
|
171 | - |
|
172 | - global $wp_version; |
|
173 | - if (version_compare($wp_version, '4.4.0', '>')) { |
|
174 | - //js.api |
|
175 | - $this->addJavascript( |
|
176 | - CoreAssetManager::JS_HANDLE_EE_JS_API, |
|
177 | - EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
178 | - array( |
|
179 | - CoreAssetManager::JS_HANDLE_UNDERSCORE, |
|
180 | - CoreAssetManager::JS_HANDLE_EE_JS_CORE |
|
181 | - ) |
|
182 | - ); |
|
183 | - $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
184 | - $this->registry->addData('paths', array('rest_route' => rest_url('ee/v4.8.36/'))); |
|
185 | - } |
|
186 | - |
|
187 | - $this->addJavascript( |
|
188 | - CoreAssetManager::JS_HANDLE_EE_CORE, |
|
189 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
190 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
191 | - ) |
|
192 | - ->setLocalizationCallback( |
|
193 | - function () { |
|
194 | - wp_localize_script( |
|
195 | - CoreAssetManager::JS_HANDLE_EE_CORE, |
|
196 | - CoreAssetManager::JS_HANDLE_EE_I18N, |
|
197 | - EE_Registry::$i18n_js_strings |
|
198 | - ); |
|
199 | - } |
|
200 | - ); |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - /** |
|
205 | - * @since $VID:$ |
|
206 | - * @throws DuplicateCollectionIdentifierException |
|
207 | - * @throws InvalidDataTypeException |
|
208 | - * @throws InvalidEntityException |
|
209 | - */ |
|
210 | - private function loadCoreCss() |
|
211 | - { |
|
212 | - if ($this->template_config->enable_default_style && ! is_admin()) { |
|
213 | - $this->addStylesheet( |
|
214 | - CoreAssetManager::CSS_HANDLE_EE_DEFAULT, |
|
215 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
216 | - ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
217 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
218 | - array('dashicons') |
|
219 | - ); |
|
220 | - //Load custom style sheet if available |
|
221 | - if ($this->template_config->custom_style_sheet !== null) { |
|
222 | - $this->addStylesheet( |
|
223 | - CoreAssetManager::CSS_HANDLE_EE_CUSTOM, |
|
224 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
225 | - array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT) |
|
226 | - ); |
|
227 | - } |
|
228 | - } |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - /** |
|
233 | - * jQuery Validate for form validation |
|
234 | - * |
|
235 | - * @since $VID:$ |
|
236 | - * @throws DuplicateCollectionIdentifierException |
|
237 | - * @throws InvalidDataTypeException |
|
238 | - * @throws InvalidEntityException |
|
239 | - */ |
|
240 | - private function loadJqueryValidate() |
|
241 | - { |
|
242 | - $this->addJavascript( |
|
243 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
244 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
245 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
246 | - ) |
|
247 | - ->setVersion('1.15.0'); |
|
248 | - |
|
249 | - $this->addJavascript( |
|
250 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
251 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
252 | - array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
253 | - ) |
|
254 | - ->setVersion('1.15.0'); |
|
255 | - } |
|
256 | - |
|
257 | - |
|
258 | - /** |
|
259 | - * accounting.js for performing client-side calculations |
|
260 | - * |
|
261 | - * @since $VID:$ |
|
262 | - * @throws DuplicateCollectionIdentifierException |
|
263 | - * @throws InvalidDataTypeException |
|
264 | - * @throws InvalidEntityException |
|
265 | - */ |
|
266 | - private function loadAccountingJs() |
|
267 | - { |
|
268 | - //accounting.js library |
|
269 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
270 | - $this->addJavascript( |
|
271 | - CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
272 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
273 | - array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
274 | - ) |
|
275 | - ->setVersion('0.3.2'); |
|
276 | - |
|
277 | - $currency_config = $this->currency_config; |
|
278 | - $this->addJavascript( |
|
279 | - CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
|
280 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
281 | - array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
282 | - ) |
|
283 | - ->setLocalizationCallback( |
|
284 | - function () use ($currency_config) { |
|
285 | - wp_localize_script( |
|
286 | - CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
|
287 | - 'EE_ACCOUNTING_CFG', |
|
288 | - array( |
|
289 | - 'currency' => array( |
|
290 | - 'symbol' => $currency_config->sign, |
|
291 | - 'format' => array( |
|
292 | - 'pos' => $currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
293 | - 'neg' => $currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
294 | - 'zero' => $currency_config->sign_b4 ? '%s--' : '--%s', |
|
295 | - ), |
|
296 | - 'decimal' => $currency_config->dec_mrk, |
|
297 | - 'thousand' => $currency_config->thsnds, |
|
298 | - 'precision' => $currency_config->dec_plc, |
|
299 | - ), |
|
300 | - 'number' => array( |
|
301 | - 'precision' => $currency_config->dec_plc, |
|
302 | - 'thousand' => $currency_config->thsnds, |
|
303 | - 'decimal' => $currency_config->dec_mrk, |
|
304 | - ), |
|
305 | - ) |
|
306 | - ); |
|
307 | - } |
|
308 | - ) |
|
309 | - ->setVersion(); |
|
310 | - } |
|
311 | - |
|
312 | - |
|
313 | - /** |
|
314 | - * registers assets for cleaning your ears |
|
315 | - * |
|
316 | - * @param JavascriptAsset $script |
|
317 | - */ |
|
318 | - public function loadQtipJs(JavascriptAsset $script) |
|
319 | - { |
|
320 | - // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
321 | - // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
322 | - if ( |
|
323 | - $script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE |
|
324 | - && apply_filters('FHEE_load_qtip', false) |
|
325 | - ) { |
|
326 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
327 | - } |
|
328 | - } |
|
329 | - |
|
330 | - |
|
331 | - /** |
|
332 | - * assets that are used in the WordPress admin |
|
333 | - * |
|
334 | - * @since $VID:$ |
|
335 | - * @throws DuplicateCollectionIdentifierException |
|
336 | - * @throws InvalidDataTypeException |
|
337 | - * @throws InvalidEntityException |
|
338 | - */ |
|
339 | - private function registerAdminAssets() |
|
340 | - { |
|
341 | - $this->addJavascript( |
|
342 | - CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE, |
|
343 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
344 | - array( |
|
345 | - CoreAssetManager::JS_HANDLE_JQUERY, |
|
346 | - CoreAssetManager::JS_HANDLE_EE_VENDOR_REACT, |
|
347 | - ) |
|
348 | - ) |
|
349 | - ->setRequiresTranslation(); |
|
350 | - |
|
351 | - $this->addStylesheet( |
|
352 | - CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE, |
|
353 | - $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
354 | - ); |
|
355 | - } |
|
30 | + // WordPress core / Third party JS asset handles |
|
31 | + const JS_HANDLE_JQUERY = 'jquery'; |
|
32 | + |
|
33 | + const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
34 | + |
|
35 | + const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
36 | + |
|
37 | + const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
38 | + |
|
39 | + const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
40 | + |
|
41 | + // EE JS assets handles |
|
42 | + const JS_HANDLE_EE_MANIFEST = 'ee-manifest'; |
|
43 | + |
|
44 | + const JS_HANDLE_EE_JS_CORE = 'eejs-core'; |
|
45 | + |
|
46 | + const JS_HANDLE_EE_VENDOR_REACT = 'ee-vendor-react'; |
|
47 | + |
|
48 | + const JS_HANDLE_EE_JS_API = 'eejs-api'; |
|
49 | + |
|
50 | + const JS_HANDLE_EE_CORE = 'espresso_core'; |
|
51 | + |
|
52 | + const JS_HANDLE_EE_I18N = 'eei18n'; |
|
53 | + |
|
54 | + const JS_HANDLE_EE_ACCOUNTING = 'ee-accounting'; |
|
55 | + |
|
56 | + const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
57 | + |
|
58 | + // EE CSS assets handles |
|
59 | + const CSS_HANDLE_EE_DEFAULT = 'espresso_default'; |
|
60 | + |
|
61 | + const CSS_HANDLE_EE_CUSTOM = 'espresso_custom_css'; |
|
62 | + |
|
63 | + /** |
|
64 | + * @var EE_Currency_Config $currency_config |
|
65 | + */ |
|
66 | + protected $currency_config; |
|
67 | + |
|
68 | + /** |
|
69 | + * @var EE_Template_Config $template_config |
|
70 | + */ |
|
71 | + protected $template_config; |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * CoreAssetRegister constructor. |
|
76 | + * |
|
77 | + * @param AssetCollection $assets |
|
78 | + * @param EE_Currency_Config $currency_config |
|
79 | + * @param EE_Template_Config $template_config |
|
80 | + * @param DomainInterface $domain |
|
81 | + * @param Registry $registry |
|
82 | + */ |
|
83 | + public function __construct( |
|
84 | + AssetCollection $assets, |
|
85 | + EE_Currency_Config $currency_config, |
|
86 | + EE_Template_Config $template_config, |
|
87 | + DomainInterface $domain, |
|
88 | + Registry $registry |
|
89 | + ) { |
|
90 | + $this->currency_config = $currency_config; |
|
91 | + $this->template_config = $template_config; |
|
92 | + parent::__construct($domain, $assets, $registry); |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @since $VID:$ |
|
98 | + * @throws DuplicateCollectionIdentifierException |
|
99 | + * @throws InvalidArgumentException |
|
100 | + * @throws InvalidDataTypeException |
|
101 | + * @throws InvalidEntityException |
|
102 | + */ |
|
103 | + public function addAssets() |
|
104 | + { |
|
105 | + $this->addJavascriptFiles(); |
|
106 | + $this->addStylesheetFiles(); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * @since $VID:$ |
|
112 | + * @throws DuplicateCollectionIdentifierException |
|
113 | + * @throws InvalidArgumentException |
|
114 | + * @throws InvalidDataTypeException |
|
115 | + * @throws InvalidEntityException |
|
116 | + */ |
|
117 | + public function addJavascriptFiles() |
|
118 | + { |
|
119 | + $this->loadCoreJs(); |
|
120 | + $this->loadJqueryValidate(); |
|
121 | + $this->loadAccountingJs(); |
|
122 | + add_action( |
|
123 | + 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
124 | + array($this, 'loadQtipJs') |
|
125 | + ); |
|
126 | + $this->registerAdminAssets(); |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * @since $VID:$ |
|
132 | + * @throws DuplicateCollectionIdentifierException |
|
133 | + * @throws InvalidDataTypeException |
|
134 | + * @throws InvalidEntityException |
|
135 | + */ |
|
136 | + public function addStylesheetFiles() |
|
137 | + { |
|
138 | + $this->loadCoreCss(); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * core default javascript |
|
144 | + * |
|
145 | + * @since $VID:$ |
|
146 | + * @throws DuplicateCollectionIdentifierException |
|
147 | + * @throws InvalidArgumentException |
|
148 | + * @throws InvalidDataTypeException |
|
149 | + * @throws InvalidEntityException |
|
150 | + */ |
|
151 | + private function loadCoreJs() |
|
152 | + { |
|
153 | + $this->addJavascript( |
|
154 | + CoreAssetManager::JS_HANDLE_EE_MANIFEST, |
|
155 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
156 | + ); |
|
157 | + |
|
158 | + $this->addJavascript( |
|
159 | + CoreAssetManager::JS_HANDLE_EE_JS_CORE, |
|
160 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
161 | + array(CoreAssetManager::JS_HANDLE_EE_MANIFEST) |
|
162 | + ) |
|
163 | + ->setRequiresTranslation() |
|
164 | + ->setHasLocalizedData(); |
|
165 | + |
|
166 | + $this->addJavascript( |
|
167 | + CoreAssetManager::JS_HANDLE_EE_VENDOR_REACT, |
|
168 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'reactVendor'), |
|
169 | + array(CoreAssetManager::JS_HANDLE_EE_JS_CORE) |
|
170 | + ); |
|
171 | + |
|
172 | + global $wp_version; |
|
173 | + if (version_compare($wp_version, '4.4.0', '>')) { |
|
174 | + //js.api |
|
175 | + $this->addJavascript( |
|
176 | + CoreAssetManager::JS_HANDLE_EE_JS_API, |
|
177 | + EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js', |
|
178 | + array( |
|
179 | + CoreAssetManager::JS_HANDLE_UNDERSCORE, |
|
180 | + CoreAssetManager::JS_HANDLE_EE_JS_CORE |
|
181 | + ) |
|
182 | + ); |
|
183 | + $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
184 | + $this->registry->addData('paths', array('rest_route' => rest_url('ee/v4.8.36/'))); |
|
185 | + } |
|
186 | + |
|
187 | + $this->addJavascript( |
|
188 | + CoreAssetManager::JS_HANDLE_EE_CORE, |
|
189 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
190 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
191 | + ) |
|
192 | + ->setLocalizationCallback( |
|
193 | + function () { |
|
194 | + wp_localize_script( |
|
195 | + CoreAssetManager::JS_HANDLE_EE_CORE, |
|
196 | + CoreAssetManager::JS_HANDLE_EE_I18N, |
|
197 | + EE_Registry::$i18n_js_strings |
|
198 | + ); |
|
199 | + } |
|
200 | + ); |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + /** |
|
205 | + * @since $VID:$ |
|
206 | + * @throws DuplicateCollectionIdentifierException |
|
207 | + * @throws InvalidDataTypeException |
|
208 | + * @throws InvalidEntityException |
|
209 | + */ |
|
210 | + private function loadCoreCss() |
|
211 | + { |
|
212 | + if ($this->template_config->enable_default_style && ! is_admin()) { |
|
213 | + $this->addStylesheet( |
|
214 | + CoreAssetManager::CSS_HANDLE_EE_DEFAULT, |
|
215 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
216 | + ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
217 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
218 | + array('dashicons') |
|
219 | + ); |
|
220 | + //Load custom style sheet if available |
|
221 | + if ($this->template_config->custom_style_sheet !== null) { |
|
222 | + $this->addStylesheet( |
|
223 | + CoreAssetManager::CSS_HANDLE_EE_CUSTOM, |
|
224 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
225 | + array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT) |
|
226 | + ); |
|
227 | + } |
|
228 | + } |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + /** |
|
233 | + * jQuery Validate for form validation |
|
234 | + * |
|
235 | + * @since $VID:$ |
|
236 | + * @throws DuplicateCollectionIdentifierException |
|
237 | + * @throws InvalidDataTypeException |
|
238 | + * @throws InvalidEntityException |
|
239 | + */ |
|
240 | + private function loadJqueryValidate() |
|
241 | + { |
|
242 | + $this->addJavascript( |
|
243 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
244 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
245 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
246 | + ) |
|
247 | + ->setVersion('1.15.0'); |
|
248 | + |
|
249 | + $this->addJavascript( |
|
250 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
251 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
252 | + array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
253 | + ) |
|
254 | + ->setVersion('1.15.0'); |
|
255 | + } |
|
256 | + |
|
257 | + |
|
258 | + /** |
|
259 | + * accounting.js for performing client-side calculations |
|
260 | + * |
|
261 | + * @since $VID:$ |
|
262 | + * @throws DuplicateCollectionIdentifierException |
|
263 | + * @throws InvalidDataTypeException |
|
264 | + * @throws InvalidEntityException |
|
265 | + */ |
|
266 | + private function loadAccountingJs() |
|
267 | + { |
|
268 | + //accounting.js library |
|
269 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
270 | + $this->addJavascript( |
|
271 | + CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
272 | + EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
273 | + array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
274 | + ) |
|
275 | + ->setVersion('0.3.2'); |
|
276 | + |
|
277 | + $currency_config = $this->currency_config; |
|
278 | + $this->addJavascript( |
|
279 | + CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
|
280 | + EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
281 | + array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
282 | + ) |
|
283 | + ->setLocalizationCallback( |
|
284 | + function () use ($currency_config) { |
|
285 | + wp_localize_script( |
|
286 | + CoreAssetManager::JS_HANDLE_EE_ACCOUNTING, |
|
287 | + 'EE_ACCOUNTING_CFG', |
|
288 | + array( |
|
289 | + 'currency' => array( |
|
290 | + 'symbol' => $currency_config->sign, |
|
291 | + 'format' => array( |
|
292 | + 'pos' => $currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
293 | + 'neg' => $currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
294 | + 'zero' => $currency_config->sign_b4 ? '%s--' : '--%s', |
|
295 | + ), |
|
296 | + 'decimal' => $currency_config->dec_mrk, |
|
297 | + 'thousand' => $currency_config->thsnds, |
|
298 | + 'precision' => $currency_config->dec_plc, |
|
299 | + ), |
|
300 | + 'number' => array( |
|
301 | + 'precision' => $currency_config->dec_plc, |
|
302 | + 'thousand' => $currency_config->thsnds, |
|
303 | + 'decimal' => $currency_config->dec_mrk, |
|
304 | + ), |
|
305 | + ) |
|
306 | + ); |
|
307 | + } |
|
308 | + ) |
|
309 | + ->setVersion(); |
|
310 | + } |
|
311 | + |
|
312 | + |
|
313 | + /** |
|
314 | + * registers assets for cleaning your ears |
|
315 | + * |
|
316 | + * @param JavascriptAsset $script |
|
317 | + */ |
|
318 | + public function loadQtipJs(JavascriptAsset $script) |
|
319 | + { |
|
320 | + // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
321 | + // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
322 | + if ( |
|
323 | + $script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE |
|
324 | + && apply_filters('FHEE_load_qtip', false) |
|
325 | + ) { |
|
326 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
327 | + } |
|
328 | + } |
|
329 | + |
|
330 | + |
|
331 | + /** |
|
332 | + * assets that are used in the WordPress admin |
|
333 | + * |
|
334 | + * @since $VID:$ |
|
335 | + * @throws DuplicateCollectionIdentifierException |
|
336 | + * @throws InvalidDataTypeException |
|
337 | + * @throws InvalidEntityException |
|
338 | + */ |
|
339 | + private function registerAdminAssets() |
|
340 | + { |
|
341 | + $this->addJavascript( |
|
342 | + CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE, |
|
343 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
344 | + array( |
|
345 | + CoreAssetManager::JS_HANDLE_JQUERY, |
|
346 | + CoreAssetManager::JS_HANDLE_EE_VENDOR_REACT, |
|
347 | + ) |
|
348 | + ) |
|
349 | + ->setRequiresTranslation(); |
|
350 | + |
|
351 | + $this->addStylesheet( |
|
352 | + CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE, |
|
353 | + $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
354 | + ); |
|
355 | + } |
|
356 | 356 | } |
@@ -19,150 +19,150 @@ |
||
19 | 19 | abstract class DomainBase implements DomainInterface |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * Equivalent to `__FILE__` for main plugin file. |
|
24 | - * |
|
25 | - * @var FilePath |
|
26 | - */ |
|
27 | - private $plugin_file; |
|
28 | - |
|
29 | - /** |
|
30 | - * String indicating version for plugin |
|
31 | - * |
|
32 | - * @var string |
|
33 | - */ |
|
34 | - private $version; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var string $plugin_basename |
|
38 | - */ |
|
39 | - private $plugin_basename; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var string $plugin_path |
|
43 | - */ |
|
44 | - private $plugin_path; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var string $plugin_url |
|
48 | - */ |
|
49 | - private $plugin_url; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var string $asset_namespace |
|
53 | - */ |
|
54 | - private $asset_namespace; |
|
55 | - |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * Initializes internal properties. |
|
60 | - * |
|
61 | - * @param FilePath $plugin_file |
|
62 | - * @param Version $version |
|
63 | - */ |
|
64 | - public function __construct(FilePath $plugin_file, Version $version) |
|
65 | - { |
|
66 | - $this->plugin_file = $plugin_file; |
|
67 | - $this->version = $version; |
|
68 | - $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
69 | - $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
70 | - $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
71 | - $this->setAssetNamespace(); |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * @return string |
|
77 | - */ |
|
78 | - public function pluginFile() |
|
79 | - { |
|
80 | - return (string) $this->plugin_file; |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * @return string |
|
87 | - */ |
|
88 | - public function pluginBasename() |
|
89 | - { |
|
90 | - return $this->plugin_basename; |
|
91 | - } |
|
92 | - |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * @return string |
|
97 | - */ |
|
98 | - public function pluginPath() |
|
99 | - { |
|
100 | - return $this->plugin_path; |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * @return string |
|
107 | - */ |
|
108 | - public function pluginUrl() |
|
109 | - { |
|
110 | - return $this->plugin_url; |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * @return string |
|
117 | - */ |
|
118 | - public function version() |
|
119 | - { |
|
120 | - return (string) $this->version; |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * @return Version |
|
127 | - */ |
|
128 | - public function versionValueObject() |
|
129 | - { |
|
130 | - return $this->version; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * @return string |
|
136 | - */ |
|
137 | - public function distributionAssetsPath() |
|
138 | - { |
|
139 | - return $this->pluginPath() . 'assets/dist/'; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * @return string |
|
145 | - */ |
|
146 | - public function distributionAssetsUrl() |
|
147 | - { |
|
148 | - return $this->pluginUrl() . 'assets/dist/'; |
|
149 | - } |
|
22 | + /** |
|
23 | + * Equivalent to `__FILE__` for main plugin file. |
|
24 | + * |
|
25 | + * @var FilePath |
|
26 | + */ |
|
27 | + private $plugin_file; |
|
28 | + |
|
29 | + /** |
|
30 | + * String indicating version for plugin |
|
31 | + * |
|
32 | + * @var string |
|
33 | + */ |
|
34 | + private $version; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var string $plugin_basename |
|
38 | + */ |
|
39 | + private $plugin_basename; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var string $plugin_path |
|
43 | + */ |
|
44 | + private $plugin_path; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var string $plugin_url |
|
48 | + */ |
|
49 | + private $plugin_url; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var string $asset_namespace |
|
53 | + */ |
|
54 | + private $asset_namespace; |
|
55 | + |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * Initializes internal properties. |
|
60 | + * |
|
61 | + * @param FilePath $plugin_file |
|
62 | + * @param Version $version |
|
63 | + */ |
|
64 | + public function __construct(FilePath $plugin_file, Version $version) |
|
65 | + { |
|
66 | + $this->plugin_file = $plugin_file; |
|
67 | + $this->version = $version; |
|
68 | + $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
69 | + $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
70 | + $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
71 | + $this->setAssetNamespace(); |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * @return string |
|
77 | + */ |
|
78 | + public function pluginFile() |
|
79 | + { |
|
80 | + return (string) $this->plugin_file; |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * @return string |
|
87 | + */ |
|
88 | + public function pluginBasename() |
|
89 | + { |
|
90 | + return $this->plugin_basename; |
|
91 | + } |
|
92 | + |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * @return string |
|
97 | + */ |
|
98 | + public function pluginPath() |
|
99 | + { |
|
100 | + return $this->plugin_path; |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * @return string |
|
107 | + */ |
|
108 | + public function pluginUrl() |
|
109 | + { |
|
110 | + return $this->plugin_url; |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * @return string |
|
117 | + */ |
|
118 | + public function version() |
|
119 | + { |
|
120 | + return (string) $this->version; |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * @return Version |
|
127 | + */ |
|
128 | + public function versionValueObject() |
|
129 | + { |
|
130 | + return $this->version; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * @return string |
|
136 | + */ |
|
137 | + public function distributionAssetsPath() |
|
138 | + { |
|
139 | + return $this->pluginPath() . 'assets/dist/'; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * @return string |
|
145 | + */ |
|
146 | + public function distributionAssetsUrl() |
|
147 | + { |
|
148 | + return $this->pluginUrl() . 'assets/dist/'; |
|
149 | + } |
|
150 | 150 | |
151 | - |
|
152 | - /** |
|
153 | - * @return string |
|
154 | - */ |
|
155 | - public function assetNamespace() |
|
156 | - { |
|
157 | - return $this->asset_namespace; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @return void |
|
163 | - */ |
|
164 | - private function setAssetNamespace() |
|
165 | - { |
|
166 | - $this->asset_namespace = sanitize_key($this->plugin_basename); |
|
167 | - } |
|
151 | + |
|
152 | + /** |
|
153 | + * @return string |
|
154 | + */ |
|
155 | + public function assetNamespace() |
|
156 | + { |
|
157 | + return $this->asset_namespace; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @return void |
|
163 | + */ |
|
164 | + private function setAssetNamespace() |
|
165 | + { |
|
166 | + $this->asset_namespace = sanitize_key($this->plugin_basename); |
|
167 | + } |
|
168 | 168 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public function distributionAssetsPath() |
138 | 138 | { |
139 | - return $this->pluginPath() . 'assets/dist/'; |
|
139 | + return $this->pluginPath().'assets/dist/'; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function distributionAssetsUrl() |
147 | 147 | { |
148 | - return $this->pluginUrl() . 'assets/dist/'; |
|
148 | + return $this->pluginUrl().'assets/dist/'; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 |
@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use EventEspresso\core\domain\values\FilePath; |
6 | 6 | use EventEspresso\core\domain\values\Version; |
7 | -use EventEspresso\core\services\assets\Registry; |
|
8 | 7 | |
9 | 8 | /** |
10 | 9 | * DomainBase Class |