@@ -15,18 +15,18 @@ |
||
15 | 15 | */ |
16 | 16 | class WordPressPostsEditorEdit extends RouteMatchSpecification |
17 | 17 | { |
18 | - /** |
|
19 | - * returns true if current request matches specification |
|
20 | - * |
|
21 | - * @return boolean |
|
22 | - * @since 4.9.71.p |
|
23 | - */ |
|
24 | - public function isMatchingRoute() |
|
25 | - { |
|
26 | - global $pagenow; |
|
27 | - return $pagenow |
|
28 | - && $pagenow === 'post.php' |
|
29 | - && $this->request->getRequestParam('post_type', 'post') === 'post' |
|
30 | - && $this->request->getRequestParam('action') === 'edit'; |
|
31 | - } |
|
18 | + /** |
|
19 | + * returns true if current request matches specification |
|
20 | + * |
|
21 | + * @return boolean |
|
22 | + * @since 4.9.71.p |
|
23 | + */ |
|
24 | + public function isMatchingRoute() |
|
25 | + { |
|
26 | + global $pagenow; |
|
27 | + return $pagenow |
|
28 | + && $pagenow === 'post.php' |
|
29 | + && $this->request->getRequestParam('post_type', 'post') === 'post' |
|
30 | + && $this->request->getRequestParam('action') === 'edit'; |
|
31 | + } |
|
32 | 32 | } |
@@ -18,21 +18,21 @@ |
||
18 | 18 | */ |
19 | 19 | class WordPressPageEditor extends MatchAnyRouteSpecification |
20 | 20 | { |
21 | - /** |
|
22 | - * WordPressPostsEditor constructor. |
|
23 | - * |
|
24 | - * @param WordPressPageEditorEdit $edit_page_route_match |
|
25 | - * @param WordPressPageEditorAddNew $create_page_route_match |
|
26 | - * @param RequestInterface $request |
|
27 | - */ |
|
28 | - public function __construct( |
|
29 | - WordPressPageEditorEdit $edit_page_route_match, |
|
30 | - WordPressPageEditorAddNew $create_page_route_match, |
|
31 | - RequestInterface $request |
|
32 | - ) { |
|
33 | - parent::__construct( |
|
34 | - array($edit_page_route_match, $create_page_route_match), |
|
35 | - $request |
|
36 | - ); |
|
37 | - } |
|
21 | + /** |
|
22 | + * WordPressPostsEditor constructor. |
|
23 | + * |
|
24 | + * @param WordPressPageEditorEdit $edit_page_route_match |
|
25 | + * @param WordPressPageEditorAddNew $create_page_route_match |
|
26 | + * @param RequestInterface $request |
|
27 | + */ |
|
28 | + public function __construct( |
|
29 | + WordPressPageEditorEdit $edit_page_route_match, |
|
30 | + WordPressPageEditorAddNew $create_page_route_match, |
|
31 | + RequestInterface $request |
|
32 | + ) { |
|
33 | + parent::__construct( |
|
34 | + array($edit_page_route_match, $create_page_route_match), |
|
35 | + $request |
|
36 | + ); |
|
37 | + } |
|
38 | 38 | } |
@@ -23,17 +23,17 @@ |
||
23 | 23 | */ |
24 | 24 | abstract class RouteMatchSpecification implements RouteMatchSpecificationInterface |
25 | 25 | { |
26 | - /** |
|
27 | - * @var RequestInterface $request |
|
28 | - */ |
|
29 | - protected $request; |
|
26 | + /** |
|
27 | + * @var RequestInterface $request |
|
28 | + */ |
|
29 | + protected $request; |
|
30 | 30 | |
31 | - /** |
|
32 | - * RouteMatch constructor. |
|
33 | - * @param RequestInterface $request |
|
34 | - */ |
|
35 | - public function __construct(RequestInterface $request) |
|
36 | - { |
|
37 | - $this->request = $request; |
|
38 | - } |
|
31 | + /** |
|
32 | + * RouteMatch constructor. |
|
33 | + * @param RequestInterface $request |
|
34 | + */ |
|
35 | + public function __construct(RequestInterface $request) |
|
36 | + { |
|
37 | + $this->request = $request; |
|
38 | + } |
|
39 | 39 | } |
@@ -14,21 +14,21 @@ |
||
14 | 14 | */ |
15 | 15 | class EspressoBlockRenderer extends RouteMatchSpecification |
16 | 16 | { |
17 | - /** |
|
18 | - * returns true if current request matches specification |
|
19 | - * |
|
20 | - * @since 4.9.71.p |
|
21 | - * @return boolean |
|
22 | - */ |
|
23 | - public function isMatchingRoute() |
|
24 | - { |
|
25 | - return strpos( |
|
26 | - $this->request->requestUri(), |
|
27 | - 'wp-json/wp/v2/block-renderer/eventespresso' |
|
28 | - ) !== false |
|
29 | - || strpos( |
|
30 | - $this->request->requestUri(), |
|
31 | - 'wp-json/gutenberg/v2/block-renderer/eventespresso' |
|
32 | - ) !== false; |
|
33 | - } |
|
17 | + /** |
|
18 | + * returns true if current request matches specification |
|
19 | + * |
|
20 | + * @since 4.9.71.p |
|
21 | + * @return boolean |
|
22 | + */ |
|
23 | + public function isMatchingRoute() |
|
24 | + { |
|
25 | + return strpos( |
|
26 | + $this->request->requestUri(), |
|
27 | + 'wp-json/wp/v2/block-renderer/eventespresso' |
|
28 | + ) !== false |
|
29 | + || strpos( |
|
30 | + $this->request->requestUri(), |
|
31 | + 'wp-json/gutenberg/v2/block-renderer/eventespresso' |
|
32 | + ) !== false; |
|
33 | + } |
|
34 | 34 | } |
@@ -13,19 +13,19 @@ |
||
13 | 13 | */ |
14 | 14 | class MatchAnyRouteSpecification extends MultiRouteSpecification |
15 | 15 | { |
16 | - /** |
|
17 | - * returns true if current request matches specification |
|
18 | - * |
|
19 | - * @since 4.9.71.p |
|
20 | - * @return boolean |
|
21 | - */ |
|
22 | - public function isMatchingRoute() |
|
23 | - { |
|
24 | - foreach ($this->specifications as $specification) { |
|
25 | - if ($specification->isMatchingRoute()) { |
|
26 | - return true; |
|
27 | - } |
|
28 | - } |
|
29 | - return false; |
|
30 | - } |
|
16 | + /** |
|
17 | + * returns true if current request matches specification |
|
18 | + * |
|
19 | + * @since 4.9.71.p |
|
20 | + * @return boolean |
|
21 | + */ |
|
22 | + public function isMatchingRoute() |
|
23 | + { |
|
24 | + foreach ($this->specifications as $specification) { |
|
25 | + if ($specification->isMatchingRoute()) { |
|
26 | + return true; |
|
27 | + } |
|
28 | + } |
|
29 | + return false; |
|
30 | + } |
|
31 | 31 | } |
@@ -15,55 +15,55 @@ |
||
15 | 15 | */ |
16 | 16 | class BlockCollection extends Collection |
17 | 17 | { |
18 | - /** |
|
19 | - * Collection constructor |
|
20 | - * |
|
21 | - * @throws InvalidInterfaceException |
|
22 | - */ |
|
23 | - public function __construct() |
|
24 | - { |
|
25 | - parent::__construct('EventEspresso\core\domain\entities\editor\BlockInterface'); |
|
26 | - } |
|
18 | + /** |
|
19 | + * Collection constructor |
|
20 | + * |
|
21 | + * @throws InvalidInterfaceException |
|
22 | + */ |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + parent::__construct('EventEspresso\core\domain\entities\editor\BlockInterface'); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * unRegisterBlock |
|
31 | - * finds block in the Collection based on the identifier that was set using addObject() |
|
32 | - * and calls unRegisterBlock() on it. Returns block if successful and false if block was not found. |
|
33 | - * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
|
34 | - * |
|
35 | - * @param mixed $identifier |
|
36 | - * @return boolean |
|
37 | - */ |
|
38 | - public function unRegisterBlock($identifier) |
|
39 | - { |
|
40 | - $this->rewind(); |
|
41 | - while ($this->valid()) { |
|
42 | - if ($identifier === $this->getInfo()) { |
|
43 | - $object = $this->current(); |
|
44 | - $this->rewind(); |
|
45 | - return $object->unRegisterBlock(); |
|
46 | - } |
|
47 | - $this->next(); |
|
48 | - } |
|
49 | - return false; |
|
50 | - } |
|
29 | + /** |
|
30 | + * unRegisterBlock |
|
31 | + * finds block in the Collection based on the identifier that was set using addObject() |
|
32 | + * and calls unRegisterBlock() on it. Returns block if successful and false if block was not found. |
|
33 | + * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
|
34 | + * |
|
35 | + * @param mixed $identifier |
|
36 | + * @return boolean |
|
37 | + */ |
|
38 | + public function unRegisterBlock($identifier) |
|
39 | + { |
|
40 | + $this->rewind(); |
|
41 | + while ($this->valid()) { |
|
42 | + if ($identifier === $this->getInfo()) { |
|
43 | + $object = $this->current(); |
|
44 | + $this->rewind(); |
|
45 | + return $object->unRegisterBlock(); |
|
46 | + } |
|
47 | + $this->next(); |
|
48 | + } |
|
49 | + return false; |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * unRegisterAllBlocks |
|
55 | - * calls unRegisterBlock() on all blocks in Collection. |
|
56 | - * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
|
57 | - * |
|
58 | - * @return void |
|
59 | - */ |
|
60 | - public function unRegisterAllBlocks() |
|
61 | - { |
|
62 | - $this->rewind(); |
|
63 | - while ($this->valid()) { |
|
64 | - $this->current()->unRegisterBlock(); |
|
65 | - $this->next(); |
|
66 | - } |
|
67 | - $this->rewind(); |
|
68 | - } |
|
53 | + /** |
|
54 | + * unRegisterAllBlocks |
|
55 | + * calls unRegisterBlock() on all blocks in Collection. |
|
56 | + * PLZ NOTE: the pointer is reset to the beginning of the collection afterwards |
|
57 | + * |
|
58 | + * @return void |
|
59 | + */ |
|
60 | + public function unRegisterAllBlocks() |
|
61 | + { |
|
62 | + $this->rewind(); |
|
63 | + while ($this->valid()) { |
|
64 | + $this->current()->unRegisterBlock(); |
|
65 | + $this->next(); |
|
66 | + } |
|
67 | + $this->rewind(); |
|
68 | + } |
|
69 | 69 | } |
@@ -21,70 +21,70 @@ |
||
21 | 21 | */ |
22 | 22 | interface BlockInterface |
23 | 23 | { |
24 | - const NAME_SPACE = 'eventespresso'; |
|
25 | - |
|
26 | - /** |
|
27 | - * Perform any early setup required by the block |
|
28 | - * including setting the block type and supported post types |
|
29 | - * |
|
30 | - * @return void |
|
31 | - */ |
|
32 | - public function initialize(); |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - public function blockType(); |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * AssetRegister that this editor block uses for asset registration |
|
43 | - * |
|
44 | - * @return BlockAssetManagerInterface |
|
45 | - */ |
|
46 | - public function assetManager(); |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * Registers the Editor Block with WP core; |
|
51 | - * Returns the registered block type on success, or false on failure. |
|
52 | - * |
|
53 | - * @return WP_Block_Type|false |
|
54 | - */ |
|
55 | - public function registerBlock(); |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * Un-registers the Editor Block with WP core; |
|
60 | - * Returns the registered block type on success, or false on failure. |
|
61 | - * |
|
62 | - * @return WP_Block_Type|false |
|
63 | - */ |
|
64 | - public function unRegisterBlock(); |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * returns an array of fully qualified class names |
|
69 | - * for RouteMatchSpecificationInterface objects |
|
70 | - * that specify routes that the block should be loaded for. |
|
71 | - * |
|
72 | - * @return array |
|
73 | - */ |
|
74 | - public function supportedRoutes(); |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * @return array |
|
79 | - */ |
|
80 | - public function getEditorContainer(); |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * returns the rendered HTML for the block |
|
85 | - * |
|
86 | - * @param array $attributes |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - public function renderBlock(array $attributes = array()); |
|
24 | + const NAME_SPACE = 'eventespresso'; |
|
25 | + |
|
26 | + /** |
|
27 | + * Perform any early setup required by the block |
|
28 | + * including setting the block type and supported post types |
|
29 | + * |
|
30 | + * @return void |
|
31 | + */ |
|
32 | + public function initialize(); |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + public function blockType(); |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * AssetRegister that this editor block uses for asset registration |
|
43 | + * |
|
44 | + * @return BlockAssetManagerInterface |
|
45 | + */ |
|
46 | + public function assetManager(); |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * Registers the Editor Block with WP core; |
|
51 | + * Returns the registered block type on success, or false on failure. |
|
52 | + * |
|
53 | + * @return WP_Block_Type|false |
|
54 | + */ |
|
55 | + public function registerBlock(); |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * Un-registers the Editor Block with WP core; |
|
60 | + * Returns the registered block type on success, or false on failure. |
|
61 | + * |
|
62 | + * @return WP_Block_Type|false |
|
63 | + */ |
|
64 | + public function unRegisterBlock(); |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * returns an array of fully qualified class names |
|
69 | + * for RouteMatchSpecificationInterface objects |
|
70 | + * that specify routes that the block should be loaded for. |
|
71 | + * |
|
72 | + * @return array |
|
73 | + */ |
|
74 | + public function supportedRoutes(); |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * @return array |
|
79 | + */ |
|
80 | + public function getEditorContainer(); |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * returns the rendered HTML for the block |
|
85 | + * |
|
86 | + * @param array $attributes |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + public function renderBlock(array $attributes = array()); |
|
90 | 90 | } |
@@ -13,14 +13,14 @@ |
||
13 | 13 | */ |
14 | 14 | interface ContextInterface |
15 | 15 | { |
16 | - /** |
|
17 | - * @return string |
|
18 | - */ |
|
19 | - public function slug(); |
|
16 | + /** |
|
17 | + * @return string |
|
18 | + */ |
|
19 | + public function slug(); |
|
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * @return string |
|
24 | - */ |
|
25 | - public function description(); |
|
22 | + /** |
|
23 | + * @return string |
|
24 | + */ |
|
25 | + public function description(); |
|
26 | 26 | } |
@@ -13,62 +13,62 @@ |
||
13 | 13 | */ |
14 | 14 | class Context implements ContextInterface |
15 | 15 | { |
16 | - /** |
|
17 | - * @var string $slug |
|
18 | - */ |
|
19 | - private $slug; |
|
16 | + /** |
|
17 | + * @var string $slug |
|
18 | + */ |
|
19 | + private $slug; |
|
20 | 20 | |
21 | - /** |
|
22 | - * @var string $description |
|
23 | - */ |
|
24 | - private $description; |
|
21 | + /** |
|
22 | + * @var string $description |
|
23 | + */ |
|
24 | + private $description; |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * Context constructor. |
|
29 | - * |
|
30 | - * @param string $slug |
|
31 | - * @param string $description |
|
32 | - */ |
|
33 | - public function __construct($slug, $description) |
|
34 | - { |
|
35 | - $this->setSlug($slug); |
|
36 | - $this->setDescription($description); |
|
37 | - } |
|
27 | + /** |
|
28 | + * Context constructor. |
|
29 | + * |
|
30 | + * @param string $slug |
|
31 | + * @param string $description |
|
32 | + */ |
|
33 | + public function __construct($slug, $description) |
|
34 | + { |
|
35 | + $this->setSlug($slug); |
|
36 | + $this->setDescription($description); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function slug() |
|
44 | - { |
|
45 | - return $this->slug; |
|
46 | - } |
|
40 | + /** |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function slug() |
|
44 | + { |
|
45 | + return $this->slug; |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * @param string $slug |
|
51 | - */ |
|
52 | - private function setSlug($slug) |
|
53 | - { |
|
54 | - $this->slug = sanitize_key($slug); |
|
55 | - } |
|
49 | + /** |
|
50 | + * @param string $slug |
|
51 | + */ |
|
52 | + private function setSlug($slug) |
|
53 | + { |
|
54 | + $this->slug = sanitize_key($slug); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * @return string |
|
60 | - */ |
|
61 | - public function description() |
|
62 | - { |
|
63 | - return $this->description; |
|
64 | - } |
|
58 | + /** |
|
59 | + * @return string |
|
60 | + */ |
|
61 | + public function description() |
|
62 | + { |
|
63 | + return $this->description; |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * @param string $description |
|
69 | - */ |
|
70 | - private function setDescription($description) |
|
71 | - { |
|
72 | - $this->description = sanitize_text_field($description); |
|
73 | - } |
|
67 | + /** |
|
68 | + * @param string $description |
|
69 | + */ |
|
70 | + private function setDescription($description) |
|
71 | + { |
|
72 | + $this->description = sanitize_text_field($description); |
|
73 | + } |
|
74 | 74 | } |