@@ -6,32 +6,32 @@ |
||
6 | 6 | |
7 | 7 | class PostTypeDefaults extends Defaults |
8 | 8 | { |
9 | - /** |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - protected function defaults() |
|
13 | - { |
|
14 | - return [ |
|
15 | - 'columns' => [ |
|
16 | - 'title' => __('Title', 'site-reviews'), |
|
17 | - 'date' => __('Date', 'site-reviews'), |
|
18 | - ], |
|
19 | - 'has_archive' => false, |
|
20 | - 'hierarchical' => false, |
|
21 | - 'labels' => [], |
|
22 | - 'menu_icon' => null, |
|
23 | - 'menu_name' => '', |
|
24 | - 'menu_position' => 25, |
|
25 | - 'plural' => '', //Required |
|
26 | - 'post_type' => '', //Required |
|
27 | - 'public' => false, |
|
28 | - 'query_var' => true, |
|
29 | - 'rewrite' => ['with_front' => false], |
|
30 | - 'show_in_menu' => true, |
|
31 | - 'show_ui' => true, |
|
32 | - 'single' => '', //Required |
|
33 | - 'supports' => ['title', 'editor'], |
|
34 | - 'taxonomies' => [], |
|
35 | - ]; |
|
36 | - } |
|
9 | + /** |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + protected function defaults() |
|
13 | + { |
|
14 | + return [ |
|
15 | + 'columns' => [ |
|
16 | + 'title' => __('Title', 'site-reviews'), |
|
17 | + 'date' => __('Date', 'site-reviews'), |
|
18 | + ], |
|
19 | + 'has_archive' => false, |
|
20 | + 'hierarchical' => false, |
|
21 | + 'labels' => [], |
|
22 | + 'menu_icon' => null, |
|
23 | + 'menu_name' => '', |
|
24 | + 'menu_position' => 25, |
|
25 | + 'plural' => '', //Required |
|
26 | + 'post_type' => '', //Required |
|
27 | + 'public' => false, |
|
28 | + 'query_var' => true, |
|
29 | + 'rewrite' => ['with_front' => false], |
|
30 | + 'show_in_menu' => true, |
|
31 | + 'show_ui' => true, |
|
32 | + 'single' => '', //Required |
|
33 | + 'supports' => ['title', 'editor'], |
|
34 | + 'taxonomies' => [], |
|
35 | + ]; |
|
36 | + } |
|
37 | 37 | } |
@@ -13,8 +13,8 @@ |
||
13 | 13 | { |
14 | 14 | return [ |
15 | 15 | 'columns' => [ |
16 | - 'title' => __('Title', 'site-reviews'), |
|
17 | - 'date' => __('Date', 'site-reviews'), |
|
16 | + 'title' => __( 'Title', 'site-reviews' ), |
|
17 | + 'date' => __( 'Date', 'site-reviews' ), |
|
18 | 18 | ], |
19 | 19 | 'has_archive' => false, |
20 | 20 | 'hierarchical' => false, |
@@ -11,27 +11,27 @@ |
||
11 | 11 | |
12 | 12 | class RestCategoryController extends RestController |
13 | 13 | { |
14 | - public function __construct() |
|
15 | - { |
|
16 | - $this->meta = new WP_REST_Term_Meta_Fields(Application::TAXONOMY); |
|
17 | - $this->namespace = Application::ID.'/v1'; |
|
18 | - $this->rest_base = 'categories'; |
|
19 | - $this->taxonomy = Application::TAXONOMY; |
|
20 | - } |
|
14 | + public function __construct() |
|
15 | + { |
|
16 | + $this->meta = new WP_REST_Term_Meta_Fields(Application::TAXONOMY); |
|
17 | + $this->namespace = Application::ID.'/v1'; |
|
18 | + $this->rest_base = 'categories'; |
|
19 | + $this->taxonomy = Application::TAXONOMY; |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * @return void |
|
24 | - */ |
|
25 | - public function register_routes() |
|
26 | - { |
|
27 | - register_rest_route($this->namespace, '/'.$this->rest_base, [ |
|
28 | - [ |
|
29 | - 'args' => $this->get_collection_params(), |
|
30 | - 'callback' => [$this, 'get_items'], |
|
31 | - 'methods' => Server::READABLE, |
|
32 | - 'permission_callback' => [$this, 'get_items_permissions_check'], |
|
33 | - ], |
|
34 | - 'schema' => [$this, 'get_public_item_schema'], |
|
35 | - ]); |
|
36 | - } |
|
22 | + /** |
|
23 | + * @return void |
|
24 | + */ |
|
25 | + public function register_routes() |
|
26 | + { |
|
27 | + register_rest_route($this->namespace, '/'.$this->rest_base, [ |
|
28 | + [ |
|
29 | + 'args' => $this->get_collection_params(), |
|
30 | + 'callback' => [$this, 'get_items'], |
|
31 | + 'methods' => Server::READABLE, |
|
32 | + 'permission_callback' => [$this, 'get_items_permissions_check'], |
|
33 | + ], |
|
34 | + 'schema' => [$this, 'get_public_item_schema'], |
|
35 | + ]); |
|
36 | + } |
|
37 | 37 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | { |
14 | 14 | public function __construct() |
15 | 15 | { |
16 | - $this->meta = new WP_REST_Term_Meta_Fields(Application::TAXONOMY); |
|
16 | + $this->meta = new WP_REST_Term_Meta_Fields( Application::TAXONOMY ); |
|
17 | 17 | $this->namespace = Application::ID.'/v1'; |
18 | 18 | $this->rest_base = 'categories'; |
19 | 19 | $this->taxonomy = Application::TAXONOMY; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function register_routes() |
26 | 26 | { |
27 | - register_rest_route($this->namespace, '/'.$this->rest_base, [ |
|
27 | + register_rest_route( $this->namespace, '/'.$this->rest_base, [ |
|
28 | 28 | [ |
29 | 29 | 'args' => $this->get_collection_params(), |
30 | 30 | 'callback' => [$this, 'get_items'], |
@@ -32,6 +32,6 @@ discard block |
||
32 | 32 | 'permission_callback' => [$this, 'get_items_permissions_check'], |
33 | 33 | ], |
34 | 34 | 'schema' => [$this, 'get_public_item_schema'], |
35 | - ]); |
|
35 | + ] ); |
|
36 | 36 | } |
37 | 37 | } |
@@ -13,93 +13,93 @@ |
||
13 | 13 | |
14 | 14 | class PublicController extends Controller |
15 | 15 | { |
16 | - /** |
|
17 | - * @return void |
|
18 | - * @action wp_enqueue_scripts |
|
19 | - */ |
|
20 | - public function enqueueAssets() |
|
21 | - { |
|
22 | - (new EnqueuePublicAssets())->handle(); |
|
23 | - } |
|
16 | + /** |
|
17 | + * @return void |
|
18 | + * @action wp_enqueue_scripts |
|
19 | + */ |
|
20 | + public function enqueueAssets() |
|
21 | + { |
|
22 | + (new EnqueuePublicAssets())->handle(); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * @param string $tag |
|
27 | - * @param string $handle |
|
28 | - * @return string |
|
29 | - * @filter script_loader_tag |
|
30 | - */ |
|
31 | - public function filterEnqueuedScripts($tag, $handle) |
|
32 | - { |
|
33 | - $scripts = [Application::ID.'/google-recaptcha']; |
|
34 | - if (in_array($handle, apply_filters('site-reviews/async-scripts', $scripts))) { |
|
35 | - $tag = str_replace(' src=', ' async src=', $tag); |
|
36 | - } |
|
37 | - if (in_array($handle, apply_filters('site-reviews/defer-scripts', $scripts))) { |
|
38 | - $tag = str_replace(' src=', ' defer src=', $tag); |
|
39 | - } |
|
40 | - return $tag; |
|
41 | - } |
|
25 | + /** |
|
26 | + * @param string $tag |
|
27 | + * @param string $handle |
|
28 | + * @return string |
|
29 | + * @filter script_loader_tag |
|
30 | + */ |
|
31 | + public function filterEnqueuedScripts($tag, $handle) |
|
32 | + { |
|
33 | + $scripts = [Application::ID.'/google-recaptcha']; |
|
34 | + if (in_array($handle, apply_filters('site-reviews/async-scripts', $scripts))) { |
|
35 | + $tag = str_replace(' src=', ' async src=', $tag); |
|
36 | + } |
|
37 | + if (in_array($handle, apply_filters('site-reviews/defer-scripts', $scripts))) { |
|
38 | + $tag = str_replace(' src=', ' defer src=', $tag); |
|
39 | + } |
|
40 | + return $tag; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return array |
|
45 | - * @filter site-reviews/config/forms/submission-form |
|
46 | - */ |
|
47 | - public function filterFieldOrder(array $config) |
|
48 | - { |
|
49 | - $order = (array) apply_filters('site-reviews/submission-form/order', array_keys($config)); |
|
50 | - return array_intersect_key(array_merge(array_flip($order), $config), $config); |
|
51 | - } |
|
43 | + /** |
|
44 | + * @return array |
|
45 | + * @filter site-reviews/config/forms/submission-form |
|
46 | + */ |
|
47 | + public function filterFieldOrder(array $config) |
|
48 | + { |
|
49 | + $order = (array) apply_filters('site-reviews/submission-form/order', array_keys($config)); |
|
50 | + return array_intersect_key(array_merge(array_flip($order), $config), $config); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @param array $vars |
|
55 | - * @return array |
|
56 | - * @filter query_vars |
|
57 | - */ |
|
58 | - public function filterQueryVars($vars) |
|
59 | - { |
|
60 | - $vars = glsr(Helper::class)->consolidateArray($vars); |
|
61 | - $vars[] = glsr()->constant('PAGED_QUERY_VAR'); |
|
62 | - return $vars; |
|
63 | - } |
|
53 | + /** |
|
54 | + * @param array $vars |
|
55 | + * @return array |
|
56 | + * @filter query_vars |
|
57 | + */ |
|
58 | + public function filterQueryVars($vars) |
|
59 | + { |
|
60 | + $vars = glsr(Helper::class)->consolidateArray($vars); |
|
61 | + $vars[] = glsr()->constant('PAGED_QUERY_VAR'); |
|
62 | + return $vars; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @param string $view |
|
67 | - * @return string |
|
68 | - * @filter site-reviews/render/view |
|
69 | - */ |
|
70 | - public function filterRenderView($view) |
|
71 | - { |
|
72 | - return glsr(Style::class)->filterView($view); |
|
73 | - } |
|
65 | + /** |
|
66 | + * @param string $view |
|
67 | + * @return string |
|
68 | + * @filter site-reviews/render/view |
|
69 | + */ |
|
70 | + public function filterRenderView($view) |
|
71 | + { |
|
72 | + return glsr(Style::class)->filterView($view); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @return void |
|
77 | - * @action site-reviews/builder |
|
78 | - */ |
|
79 | - public function modifyBuilder(Builder $instance) |
|
80 | - { |
|
81 | - call_user_func_array([glsr(Style::class), 'modifyField'], [$instance]); |
|
82 | - } |
|
75 | + /** |
|
76 | + * @return void |
|
77 | + * @action site-reviews/builder |
|
78 | + */ |
|
79 | + public function modifyBuilder(Builder $instance) |
|
80 | + { |
|
81 | + call_user_func_array([glsr(Style::class), 'modifyField'], [$instance]); |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @return void |
|
86 | - * @action wp_footer |
|
87 | - */ |
|
88 | - public function renderSchema() |
|
89 | - { |
|
90 | - glsr(Schema::class)->render(); |
|
91 | - } |
|
84 | + /** |
|
85 | + * @return void |
|
86 | + * @action wp_footer |
|
87 | + */ |
|
88 | + public function renderSchema() |
|
89 | + { |
|
90 | + glsr(Schema::class)->render(); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * @return CreateReview |
|
95 | - */ |
|
96 | - public function routerSubmitReview(array $request) |
|
97 | - { |
|
98 | - $validated = glsr(ValidateReview::class)->validate($request); |
|
99 | - $command = new CreateReview($validated->request); |
|
100 | - if (empty($validated->error) && !$validated->recaptchaIsUnset) { |
|
101 | - $this->execute($command); |
|
102 | - } |
|
103 | - return $command; |
|
104 | - } |
|
93 | + /** |
|
94 | + * @return CreateReview |
|
95 | + */ |
|
96 | + public function routerSubmitReview(array $request) |
|
97 | + { |
|
98 | + $validated = glsr(ValidateReview::class)->validate($request); |
|
99 | + $command = new CreateReview($validated->request); |
|
100 | + if (empty($validated->error) && !$validated->recaptchaIsUnset) { |
|
101 | + $this->execute($command); |
|
102 | + } |
|
103 | + return $command; |
|
104 | + } |
|
105 | 105 | } |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | * @return string |
29 | 29 | * @filter script_loader_tag |
30 | 30 | */ |
31 | - public function filterEnqueuedScripts($tag, $handle) |
|
31 | + public function filterEnqueuedScripts( $tag, $handle ) |
|
32 | 32 | { |
33 | 33 | $scripts = [Application::ID.'/google-recaptcha']; |
34 | - if (in_array($handle, apply_filters('site-reviews/async-scripts', $scripts))) { |
|
35 | - $tag = str_replace(' src=', ' async src=', $tag); |
|
34 | + if( in_array( $handle, apply_filters( 'site-reviews/async-scripts', $scripts ) ) ) { |
|
35 | + $tag = str_replace( ' src=', ' async src=', $tag ); |
|
36 | 36 | } |
37 | - if (in_array($handle, apply_filters('site-reviews/defer-scripts', $scripts))) { |
|
38 | - $tag = str_replace(' src=', ' defer src=', $tag); |
|
37 | + if( in_array( $handle, apply_filters( 'site-reviews/defer-scripts', $scripts ) ) ) { |
|
38 | + $tag = str_replace( ' src=', ' defer src=', $tag ); |
|
39 | 39 | } |
40 | 40 | return $tag; |
41 | 41 | } |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | * @return array |
45 | 45 | * @filter site-reviews/config/forms/submission-form |
46 | 46 | */ |
47 | - public function filterFieldOrder(array $config) |
|
47 | + public function filterFieldOrder( array $config ) |
|
48 | 48 | { |
49 | - $order = (array) apply_filters('site-reviews/submission-form/order', array_keys($config)); |
|
50 | - return array_intersect_key(array_merge(array_flip($order), $config), $config); |
|
49 | + $order = (array)apply_filters( 'site-reviews/submission-form/order', array_keys( $config ) ); |
|
50 | + return array_intersect_key( array_merge( array_flip( $order ), $config ), $config ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | * @return array |
56 | 56 | * @filter query_vars |
57 | 57 | */ |
58 | - public function filterQueryVars($vars) |
|
58 | + public function filterQueryVars( $vars ) |
|
59 | 59 | { |
60 | - $vars = glsr(Helper::class)->consolidateArray($vars); |
|
61 | - $vars[] = glsr()->constant('PAGED_QUERY_VAR'); |
|
60 | + $vars = glsr( Helper::class )->consolidateArray( $vars ); |
|
61 | + $vars[] = glsr()->constant( 'PAGED_QUERY_VAR' ); |
|
62 | 62 | return $vars; |
63 | 63 | } |
64 | 64 | |
@@ -67,18 +67,18 @@ discard block |
||
67 | 67 | * @return string |
68 | 68 | * @filter site-reviews/render/view |
69 | 69 | */ |
70 | - public function filterRenderView($view) |
|
70 | + public function filterRenderView( $view ) |
|
71 | 71 | { |
72 | - return glsr(Style::class)->filterView($view); |
|
72 | + return glsr( Style::class )->filterView( $view ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
76 | 76 | * @return void |
77 | 77 | * @action site-reviews/builder |
78 | 78 | */ |
79 | - public function modifyBuilder(Builder $instance) |
|
79 | + public function modifyBuilder( Builder $instance ) |
|
80 | 80 | { |
81 | - call_user_func_array([glsr(Style::class), 'modifyField'], [$instance]); |
|
81 | + call_user_func_array( [glsr( Style::class ), 'modifyField'], [$instance] ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -87,18 +87,18 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function renderSchema() |
89 | 89 | { |
90 | - glsr(Schema::class)->render(); |
|
90 | + glsr( Schema::class )->render(); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | 94 | * @return CreateReview |
95 | 95 | */ |
96 | - public function routerSubmitReview(array $request) |
|
96 | + public function routerSubmitReview( array $request ) |
|
97 | 97 | { |
98 | - $validated = glsr(ValidateReview::class)->validate($request); |
|
99 | - $command = new CreateReview($validated->request); |
|
100 | - if (empty($validated->error) && !$validated->recaptchaIsUnset) { |
|
101 | - $this->execute($command); |
|
98 | + $validated = glsr( ValidateReview::class )->validate( $request ); |
|
99 | + $command = new CreateReview( $validated->request ); |
|
100 | + if( empty($validated->error) && !$validated->recaptchaIsUnset ) { |
|
101 | + $this->execute( $command ); |
|
102 | 102 | } |
103 | 103 | return $command; |
104 | 104 | } |
@@ -10,55 +10,55 @@ |
||
10 | 10 | |
11 | 11 | abstract class Controller |
12 | 12 | { |
13 | - /** |
|
14 | - * @return void |
|
15 | - */ |
|
16 | - public function download($filename, $content) |
|
17 | - { |
|
18 | - if (!current_user_can(glsr()->constant('CAPABILITY'))) { |
|
19 | - return; |
|
20 | - } |
|
21 | - nocache_headers(); |
|
22 | - header('Content-Type: text/plain'); |
|
23 | - header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
24 | - echo html_entity_decode($content); |
|
25 | - exit; |
|
26 | - } |
|
13 | + /** |
|
14 | + * @return void |
|
15 | + */ |
|
16 | + public function download($filename, $content) |
|
17 | + { |
|
18 | + if (!current_user_can(glsr()->constant('CAPABILITY'))) { |
|
19 | + return; |
|
20 | + } |
|
21 | + nocache_headers(); |
|
22 | + header('Content-Type: text/plain'); |
|
23 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
24 | + echo html_entity_decode($content); |
|
25 | + exit; |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * @param object $command |
|
30 | - * @return mixed |
|
31 | - * @throws InvalidArgumentException |
|
32 | - */ |
|
33 | - public function execute($command) |
|
34 | - { |
|
35 | - $handlerClass = str_replace('Commands', 'Handlers', get_class($command)); |
|
36 | - if (!class_exists($handlerClass)) { |
|
37 | - throw new InvalidArgumentException('Handler '.$handlerClass.' not found.'); |
|
38 | - } |
|
39 | - try { |
|
40 | - return glsr($handlerClass)->handle($command); |
|
41 | - } catch (Exception $e) { |
|
42 | - status_header(400); |
|
43 | - glsr(Notice::class)->addError(new WP_Error('site_reviews_error', $e->getMessage())); |
|
44 | - glsr_log()->error($e->getMessage()); |
|
45 | - } |
|
46 | - } |
|
28 | + /** |
|
29 | + * @param object $command |
|
30 | + * @return mixed |
|
31 | + * @throws InvalidArgumentException |
|
32 | + */ |
|
33 | + public function execute($command) |
|
34 | + { |
|
35 | + $handlerClass = str_replace('Commands', 'Handlers', get_class($command)); |
|
36 | + if (!class_exists($handlerClass)) { |
|
37 | + throw new InvalidArgumentException('Handler '.$handlerClass.' not found.'); |
|
38 | + } |
|
39 | + try { |
|
40 | + return glsr($handlerClass)->handle($command); |
|
41 | + } catch (Exception $e) { |
|
42 | + status_header(400); |
|
43 | + glsr(Notice::class)->addError(new WP_Error('site_reviews_error', $e->getMessage())); |
|
44 | + glsr_log()->error($e->getMessage()); |
|
45 | + } |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return int |
|
50 | - */ |
|
51 | - protected function getPostId() |
|
52 | - { |
|
53 | - return intval(filter_input(INPUT_GET, 'post')); |
|
54 | - } |
|
48 | + /** |
|
49 | + * @return int |
|
50 | + */ |
|
51 | + protected function getPostId() |
|
52 | + { |
|
53 | + return intval(filter_input(INPUT_GET, 'post')); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param int $postId |
|
58 | - * @return bool |
|
59 | - */ |
|
60 | - protected function isReviewPostId($postId) |
|
61 | - { |
|
62 | - return Application::POST_TYPE == get_post_field('post_type', $postId); |
|
63 | - } |
|
56 | + /** |
|
57 | + * @param int $postId |
|
58 | + * @return bool |
|
59 | + */ |
|
60 | + protected function isReviewPostId($postId) |
|
61 | + { |
|
62 | + return Application::POST_TYPE == get_post_field('post_type', $postId); |
|
63 | + } |
|
64 | 64 | } |
@@ -13,15 +13,15 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * @return void |
15 | 15 | */ |
16 | - public function download($filename, $content) |
|
16 | + public function download( $filename, $content ) |
|
17 | 17 | { |
18 | - if (!current_user_can(glsr()->constant('CAPABILITY'))) { |
|
18 | + if( !current_user_can( glsr()->constant( 'CAPABILITY' ) ) ) { |
|
19 | 19 | return; |
20 | 20 | } |
21 | 21 | nocache_headers(); |
22 | - header('Content-Type: text/plain'); |
|
23 | - header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
24 | - echo html_entity_decode($content); |
|
22 | + header( 'Content-Type: text/plain' ); |
|
23 | + header( 'Content-Disposition: attachment; filename="'.$filename.'"' ); |
|
24 | + echo html_entity_decode( $content ); |
|
25 | 25 | exit; |
26 | 26 | } |
27 | 27 | |
@@ -30,18 +30,18 @@ discard block |
||
30 | 30 | * @return mixed |
31 | 31 | * @throws InvalidArgumentException |
32 | 32 | */ |
33 | - public function execute($command) |
|
33 | + public function execute( $command ) |
|
34 | 34 | { |
35 | - $handlerClass = str_replace('Commands', 'Handlers', get_class($command)); |
|
36 | - if (!class_exists($handlerClass)) { |
|
37 | - throw new InvalidArgumentException('Handler '.$handlerClass.' not found.'); |
|
35 | + $handlerClass = str_replace( 'Commands', 'Handlers', get_class( $command ) ); |
|
36 | + if( !class_exists( $handlerClass ) ) { |
|
37 | + throw new InvalidArgumentException( 'Handler '.$handlerClass.' not found.' ); |
|
38 | 38 | } |
39 | 39 | try { |
40 | - return glsr($handlerClass)->handle($command); |
|
41 | - } catch (Exception $e) { |
|
42 | - status_header(400); |
|
43 | - glsr(Notice::class)->addError(new WP_Error('site_reviews_error', $e->getMessage())); |
|
44 | - glsr_log()->error($e->getMessage()); |
|
40 | + return glsr( $handlerClass )->handle( $command ); |
|
41 | + } catch( Exception $e ) { |
|
42 | + status_header( 400 ); |
|
43 | + glsr( Notice::class )->addError( new WP_Error( 'site_reviews_error', $e->getMessage() ) ); |
|
44 | + glsr_log()->error( $e->getMessage() ); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
@@ -50,15 +50,15 @@ discard block |
||
50 | 50 | */ |
51 | 51 | protected function getPostId() |
52 | 52 | { |
53 | - return intval(filter_input(INPUT_GET, 'post')); |
|
53 | + return intval( filter_input( INPUT_GET, 'post' ) ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * @param int $postId |
58 | 58 | * @return bool |
59 | 59 | */ |
60 | - protected function isReviewPostId($postId) |
|
60 | + protected function isReviewPostId( $postId ) |
|
61 | 61 | { |
62 | - return Application::POST_TYPE == get_post_field('post_type', $postId); |
|
62 | + return Application::POST_TYPE == get_post_field( 'post_type', $postId ); |
|
63 | 63 | } |
64 | 64 | } |
@@ -38,7 +38,8 @@ |
||
38 | 38 | } |
39 | 39 | try { |
40 | 40 | return glsr($handlerClass)->handle($command); |
41 | - } catch (Exception $e) { |
|
41 | + } |
|
42 | + catch (Exception $e) { |
|
42 | 43 | status_header(400); |
43 | 44 | glsr(Notice::class)->addError(new WP_Error('site_reviews_error', $e->getMessage())); |
44 | 45 | glsr_log()->error($e->getMessage()); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | { |
15 | 15 | public function __construct() |
16 | 16 | { |
17 | - $this->meta = new WP_REST_Post_Meta_Fields(Application::POST_TYPE); |
|
17 | + $this->meta = new WP_REST_Post_Meta_Fields( Application::POST_TYPE ); |
|
18 | 18 | $this->namespace = Application::ID.'/v1'; |
19 | 19 | $this->post_type = Application::POST_TYPE; |
20 | 20 | $this->rest_base = 'reviews'; |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | // ['callback' => [$this, 'createReview'], 'methods' => Server::CREATABLE], |
30 | 30 | // ['callback' => [$this, 'getReviews'], 'methods' => Server::READABLE], |
31 | 31 | // ]); |
32 | - register_rest_route($this->namespace, '/types', [ |
|
32 | + register_rest_route( $this->namespace, '/types', [ |
|
33 | 33 | ['callback' => [$this, 'getReviewTypes'], 'methods' => Server::READABLE], |
34 | - ]); |
|
34 | + ] ); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | public function createReview() |
41 | 41 | { |
42 | 42 | $response = []; |
43 | - return rest_ensure_response($response); |
|
43 | + return rest_ensure_response( $response ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | public function getReviews() |
50 | 50 | { |
51 | 51 | $response = []; |
52 | - return rest_ensure_response($response); |
|
52 | + return rest_ensure_response( $response ); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | public function getReviewTypes() |
59 | 59 | { |
60 | 60 | $response = []; |
61 | - foreach (glsr()->reviewTypes as $slug => $name) { |
|
61 | + foreach( glsr()->reviewTypes as $slug => $name ) { |
|
62 | 62 | $response[] = [ |
63 | 63 | 'name' => $name, |
64 | 64 | 'slug' => $slug, |
65 | 65 | ]; |
66 | 66 | } |
67 | - return rest_ensure_response($response); |
|
67 | + return rest_ensure_response( $response ); |
|
68 | 68 | } |
69 | 69 | } |
@@ -12,58 +12,58 @@ |
||
12 | 12 | |
13 | 13 | class RestReviewController extends RestController |
14 | 14 | { |
15 | - public function __construct() |
|
16 | - { |
|
17 | - $this->meta = new WP_REST_Post_Meta_Fields(Application::POST_TYPE); |
|
18 | - $this->namespace = Application::ID.'/v1'; |
|
19 | - $this->post_type = Application::POST_TYPE; |
|
20 | - $this->rest_base = 'reviews'; |
|
21 | - } |
|
15 | + public function __construct() |
|
16 | + { |
|
17 | + $this->meta = new WP_REST_Post_Meta_Fields(Application::POST_TYPE); |
|
18 | + $this->namespace = Application::ID.'/v1'; |
|
19 | + $this->post_type = Application::POST_TYPE; |
|
20 | + $this->rest_base = 'reviews'; |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public function register_routes() |
|
27 | - { |
|
28 | - // register_rest_route($this->namespace, '/'.$this->rest_base, [ |
|
29 | - // ['callback' => [$this, 'createReview'], 'methods' => Server::CREATABLE], |
|
30 | - // ['callback' => [$this, 'getReviews'], 'methods' => Server::READABLE], |
|
31 | - // ]); |
|
32 | - register_rest_route($this->namespace, '/types', [ |
|
33 | - ['callback' => [$this, 'getReviewTypes'], 'methods' => Server::READABLE], |
|
34 | - ]); |
|
35 | - } |
|
23 | + /** |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public function register_routes() |
|
27 | + { |
|
28 | + // register_rest_route($this->namespace, '/'.$this->rest_base, [ |
|
29 | + // ['callback' => [$this, 'createReview'], 'methods' => Server::CREATABLE], |
|
30 | + // ['callback' => [$this, 'getReviews'], 'methods' => Server::READABLE], |
|
31 | + // ]); |
|
32 | + register_rest_route($this->namespace, '/types', [ |
|
33 | + ['callback' => [$this, 'getReviewTypes'], 'methods' => Server::READABLE], |
|
34 | + ]); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * @return WP_Error|Response|mixed |
|
39 | - */ |
|
40 | - public function createReview() |
|
41 | - { |
|
42 | - $response = []; |
|
43 | - return rest_ensure_response($response); |
|
44 | - } |
|
37 | + /** |
|
38 | + * @return WP_Error|Response|mixed |
|
39 | + */ |
|
40 | + public function createReview() |
|
41 | + { |
|
42 | + $response = []; |
|
43 | + return rest_ensure_response($response); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @return WP_Error|Response|mixed |
|
48 | - */ |
|
49 | - public function getReviews() |
|
50 | - { |
|
51 | - $response = []; |
|
52 | - return rest_ensure_response($response); |
|
53 | - } |
|
46 | + /** |
|
47 | + * @return WP_Error|Response|mixed |
|
48 | + */ |
|
49 | + public function getReviews() |
|
50 | + { |
|
51 | + $response = []; |
|
52 | + return rest_ensure_response($response); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @return WP_Error|Response|mixed |
|
57 | - */ |
|
58 | - public function getReviewTypes() |
|
59 | - { |
|
60 | - $response = []; |
|
61 | - foreach (glsr()->reviewTypes as $slug => $name) { |
|
62 | - $response[] = [ |
|
63 | - 'name' => $name, |
|
64 | - 'slug' => $slug, |
|
65 | - ]; |
|
66 | - } |
|
67 | - return rest_ensure_response($response); |
|
68 | - } |
|
55 | + /** |
|
56 | + * @return WP_Error|Response|mixed |
|
57 | + */ |
|
58 | + public function getReviewTypes() |
|
59 | + { |
|
60 | + $response = []; |
|
61 | + foreach (glsr()->reviewTypes as $slug => $name) { |
|
62 | + $response[] = [ |
|
63 | + 'name' => $name, |
|
64 | + 'slug' => $slug, |
|
65 | + ]; |
|
66 | + } |
|
67 | + return rest_ensure_response($response); |
|
68 | + } |
|
69 | 69 | } |
@@ -7,97 +7,97 @@ |
||
7 | 7 | |
8 | 8 | class TaxonomyController |
9 | 9 | { |
10 | - /** |
|
11 | - * @return void |
|
12 | - * @action Application::TAXONOMY._add_form_fields |
|
13 | - * @action Application::TAXONOMY._edit_form |
|
14 | - */ |
|
15 | - public function disableParents() |
|
16 | - { |
|
17 | - global $wp_taxonomies; |
|
18 | - $wp_taxonomies[Application::TAXONOMY]->hierarchical = false; |
|
19 | - } |
|
10 | + /** |
|
11 | + * @return void |
|
12 | + * @action Application::TAXONOMY._add_form_fields |
|
13 | + * @action Application::TAXONOMY._edit_form |
|
14 | + */ |
|
15 | + public function disableParents() |
|
16 | + { |
|
17 | + global $wp_taxonomies; |
|
18 | + $wp_taxonomies[Application::TAXONOMY]->hierarchical = false; |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * @return void |
|
23 | - * @action Application::TAXONOMY._term_edit_form_top |
|
24 | - * @action Application::TAXONOMY._term_new_form_tag |
|
25 | - */ |
|
26 | - public function enableParents() |
|
27 | - { |
|
28 | - global $wp_taxonomies; |
|
29 | - $wp_taxonomies[Application::TAXONOMY]->hierarchical = true; |
|
30 | - } |
|
21 | + /** |
|
22 | + * @return void |
|
23 | + * @action Application::TAXONOMY._term_edit_form_top |
|
24 | + * @action Application::TAXONOMY._term_new_form_tag |
|
25 | + */ |
|
26 | + public function enableParents() |
|
27 | + { |
|
28 | + global $wp_taxonomies; |
|
29 | + $wp_taxonomies[Application::TAXONOMY]->hierarchical = true; |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * @return void |
|
34 | - * @action restrict_manage_posts |
|
35 | - */ |
|
36 | - public function renderTaxonomyFilter() |
|
37 | - { |
|
38 | - if (!is_object_in_taxonomy(glsr_current_screen()->post_type, Application::TAXONOMY)) { |
|
39 | - return; |
|
40 | - } |
|
41 | - echo glsr(Builder::class)->label(__('Filter by category', 'site-reviews'), [ |
|
42 | - 'class' => 'screen-reader-text', |
|
43 | - 'for' => Application::TAXONOMY, |
|
44 | - ]); |
|
45 | - wp_dropdown_categories([ |
|
46 | - 'depth' => 3, |
|
47 | - 'hide_empty' => true, |
|
48 | - 'hide_if_empty' => true, |
|
49 | - 'hierarchical' => true, |
|
50 | - 'name' => Application::TAXONOMY, |
|
51 | - 'orderby' => 'name', |
|
52 | - 'selected' => $this->getSelected(), |
|
53 | - 'show_count' => false, |
|
54 | - 'show_option_all' => $this->getShowOptionAll(), |
|
55 | - 'taxonomy' => Application::TAXONOMY, |
|
56 | - 'value_field' => 'slug', |
|
57 | - ]); |
|
58 | - } |
|
32 | + /** |
|
33 | + * @return void |
|
34 | + * @action restrict_manage_posts |
|
35 | + */ |
|
36 | + public function renderTaxonomyFilter() |
|
37 | + { |
|
38 | + if (!is_object_in_taxonomy(glsr_current_screen()->post_type, Application::TAXONOMY)) { |
|
39 | + return; |
|
40 | + } |
|
41 | + echo glsr(Builder::class)->label(__('Filter by category', 'site-reviews'), [ |
|
42 | + 'class' => 'screen-reader-text', |
|
43 | + 'for' => Application::TAXONOMY, |
|
44 | + ]); |
|
45 | + wp_dropdown_categories([ |
|
46 | + 'depth' => 3, |
|
47 | + 'hide_empty' => true, |
|
48 | + 'hide_if_empty' => true, |
|
49 | + 'hierarchical' => true, |
|
50 | + 'name' => Application::TAXONOMY, |
|
51 | + 'orderby' => 'name', |
|
52 | + 'selected' => $this->getSelected(), |
|
53 | + 'show_count' => false, |
|
54 | + 'show_option_all' => $this->getShowOptionAll(), |
|
55 | + 'taxonomy' => Application::TAXONOMY, |
|
56 | + 'value_field' => 'slug', |
|
57 | + ]); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @param int $postId |
|
62 | - * @param array $terms |
|
63 | - * @param array $newTTIds |
|
64 | - * @param string $taxonomy |
|
65 | - * @param bool $append |
|
66 | - * @param array $oldTTIds |
|
67 | - * @return void |
|
68 | - * @action set_object_terms |
|
69 | - */ |
|
70 | - public function restrictTermSelection($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds) |
|
71 | - { |
|
72 | - if (Application::TAXONOMY != $taxonomy || count($newTTIds) <= 1) { |
|
73 | - return; |
|
74 | - } |
|
75 | - $diff = array_diff($newTTIds, $oldTTIds); |
|
76 | - if (empty($newTerm = array_shift($diff))) { |
|
77 | - $newTerm = array_shift($newTTIds); |
|
78 | - } |
|
79 | - if ($newTerm) { |
|
80 | - wp_set_object_terms($postId, intval($newTerm), $taxonomy); |
|
81 | - } |
|
82 | - } |
|
60 | + /** |
|
61 | + * @param int $postId |
|
62 | + * @param array $terms |
|
63 | + * @param array $newTTIds |
|
64 | + * @param string $taxonomy |
|
65 | + * @param bool $append |
|
66 | + * @param array $oldTTIds |
|
67 | + * @return void |
|
68 | + * @action set_object_terms |
|
69 | + */ |
|
70 | + public function restrictTermSelection($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds) |
|
71 | + { |
|
72 | + if (Application::TAXONOMY != $taxonomy || count($newTTIds) <= 1) { |
|
73 | + return; |
|
74 | + } |
|
75 | + $diff = array_diff($newTTIds, $oldTTIds); |
|
76 | + if (empty($newTerm = array_shift($diff))) { |
|
77 | + $newTerm = array_shift($newTTIds); |
|
78 | + } |
|
79 | + if ($newTerm) { |
|
80 | + wp_set_object_terms($postId, intval($newTerm), $taxonomy); |
|
81 | + } |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @return string |
|
86 | - */ |
|
87 | - protected function getSelected() |
|
88 | - { |
|
89 | - global $wp_query; |
|
90 | - return glsr_get($wp_query->query, Application::TAXONOMY); |
|
91 | - } |
|
84 | + /** |
|
85 | + * @return string |
|
86 | + */ |
|
87 | + protected function getSelected() |
|
88 | + { |
|
89 | + global $wp_query; |
|
90 | + return glsr_get($wp_query->query, Application::TAXONOMY); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * @return string |
|
95 | - */ |
|
96 | - protected function getShowOptionAll() |
|
97 | - { |
|
98 | - $taxonomy = get_taxonomy(Application::TAXONOMY); |
|
99 | - return $taxonomy |
|
100 | - ? ucfirst(strtolower($taxonomy->labels->all_items)) |
|
101 | - : ''; |
|
102 | - } |
|
93 | + /** |
|
94 | + * @return string |
|
95 | + */ |
|
96 | + protected function getShowOptionAll() |
|
97 | + { |
|
98 | + $taxonomy = get_taxonomy(Application::TAXONOMY); |
|
99 | + return $taxonomy |
|
100 | + ? ucfirst(strtolower($taxonomy->labels->all_items)) |
|
101 | + : ''; |
|
102 | + } |
|
103 | 103 | } |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function renderTaxonomyFilter() |
37 | 37 | { |
38 | - if (!is_object_in_taxonomy(glsr_current_screen()->post_type, Application::TAXONOMY)) { |
|
38 | + if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY ) ) { |
|
39 | 39 | return; |
40 | 40 | } |
41 | - echo glsr(Builder::class)->label(__('Filter by category', 'site-reviews'), [ |
|
41 | + echo glsr( Builder::class )->label( __( 'Filter by category', 'site-reviews' ), [ |
|
42 | 42 | 'class' => 'screen-reader-text', |
43 | 43 | 'for' => Application::TAXONOMY, |
44 | - ]); |
|
45 | - wp_dropdown_categories([ |
|
44 | + ] ); |
|
45 | + wp_dropdown_categories( [ |
|
46 | 46 | 'depth' => 3, |
47 | 47 | 'hide_empty' => true, |
48 | 48 | 'hide_if_empty' => true, |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'show_option_all' => $this->getShowOptionAll(), |
55 | 55 | 'taxonomy' => Application::TAXONOMY, |
56 | 56 | 'value_field' => 'slug', |
57 | - ]); |
|
57 | + ] ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -67,17 +67,17 @@ discard block |
||
67 | 67 | * @return void |
68 | 68 | * @action set_object_terms |
69 | 69 | */ |
70 | - public function restrictTermSelection($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds) |
|
70 | + public function restrictTermSelection( $postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds ) |
|
71 | 71 | { |
72 | - if (Application::TAXONOMY != $taxonomy || count($newTTIds) <= 1) { |
|
72 | + if( Application::TAXONOMY != $taxonomy || count( $newTTIds ) <= 1 ) { |
|
73 | 73 | return; |
74 | 74 | } |
75 | - $diff = array_diff($newTTIds, $oldTTIds); |
|
76 | - if (empty($newTerm = array_shift($diff))) { |
|
77 | - $newTerm = array_shift($newTTIds); |
|
75 | + $diff = array_diff( $newTTIds, $oldTTIds ); |
|
76 | + if( empty($newTerm = array_shift( $diff )) ) { |
|
77 | + $newTerm = array_shift( $newTTIds ); |
|
78 | 78 | } |
79 | - if ($newTerm) { |
|
80 | - wp_set_object_terms($postId, intval($newTerm), $taxonomy); |
|
79 | + if( $newTerm ) { |
|
80 | + wp_set_object_terms( $postId, intval( $newTerm ), $taxonomy ); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | protected function getSelected() |
88 | 88 | { |
89 | 89 | global $wp_query; |
90 | - return glsr_get($wp_query->query, Application::TAXONOMY); |
|
90 | + return glsr_get( $wp_query->query, Application::TAXONOMY ); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | */ |
96 | 96 | protected function getShowOptionAll() |
97 | 97 | { |
98 | - $taxonomy = get_taxonomy(Application::TAXONOMY); |
|
98 | + $taxonomy = get_taxonomy( Application::TAXONOMY ); |
|
99 | 99 | return $taxonomy |
100 | - ? ucfirst(strtolower($taxonomy->labels->all_items)) |
|
100 | + ? ucfirst( strtolower( $taxonomy->labels->all_items ) ) |
|
101 | 101 | : ''; |
102 | 102 | } |
103 | 103 | } |
@@ -7,85 +7,85 @@ |
||
7 | 7 | |
8 | 8 | class BlocksController extends Controller |
9 | 9 | { |
10 | - /** |
|
11 | - * @param array $categories |
|
12 | - * @return array |
|
13 | - * @filter block_categories |
|
14 | - */ |
|
15 | - public function filterBlockCategories($categories) |
|
16 | - { |
|
17 | - $categories = glsr(Helper::class)->consolidateArray($categories); |
|
18 | - $categories[] = [ |
|
19 | - 'icon' => null, |
|
20 | - 'slug' => Application::ID, |
|
21 | - 'title' => glsr()->name, |
|
22 | - ]; |
|
23 | - return $categories; |
|
24 | - } |
|
10 | + /** |
|
11 | + * @param array $categories |
|
12 | + * @return array |
|
13 | + * @filter block_categories |
|
14 | + */ |
|
15 | + public function filterBlockCategories($categories) |
|
16 | + { |
|
17 | + $categories = glsr(Helper::class)->consolidateArray($categories); |
|
18 | + $categories[] = [ |
|
19 | + 'icon' => null, |
|
20 | + 'slug' => Application::ID, |
|
21 | + 'title' => glsr()->name, |
|
22 | + ]; |
|
23 | + return $categories; |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * @param array $editors |
|
28 | - * @param string $postType |
|
29 | - * @return array |
|
30 | - * @filter classic_editor_enabled_editors_for_post_type |
|
31 | - * @plugin classic-editor/classic-editor.php |
|
32 | - */ |
|
33 | - public function filterEnabledEditors($editors, $postType) |
|
34 | - { |
|
35 | - return Application::POST_TYPE == $postType |
|
36 | - ? ['block_editor' => false, 'classic_editor' => false] |
|
37 | - : $editors; |
|
38 | - } |
|
26 | + /** |
|
27 | + * @param array $editors |
|
28 | + * @param string $postType |
|
29 | + * @return array |
|
30 | + * @filter classic_editor_enabled_editors_for_post_type |
|
31 | + * @plugin classic-editor/classic-editor.php |
|
32 | + */ |
|
33 | + public function filterEnabledEditors($editors, $postType) |
|
34 | + { |
|
35 | + return Application::POST_TYPE == $postType |
|
36 | + ? ['block_editor' => false, 'classic_editor' => false] |
|
37 | + : $editors; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @param bool $bool |
|
42 | - * @param string $postType |
|
43 | - * @return bool |
|
44 | - * @filter use_block_editor_for_post_type |
|
45 | - */ |
|
46 | - public function filterUseBlockEditor($bool, $postType) |
|
47 | - { |
|
48 | - return Application::POST_TYPE == $postType |
|
49 | - ? false |
|
50 | - : $bool; |
|
51 | - } |
|
40 | + /** |
|
41 | + * @param bool $bool |
|
42 | + * @param string $postType |
|
43 | + * @return bool |
|
44 | + * @filter use_block_editor_for_post_type |
|
45 | + */ |
|
46 | + public function filterUseBlockEditor($bool, $postType) |
|
47 | + { |
|
48 | + return Application::POST_TYPE == $postType |
|
49 | + ? false |
|
50 | + : $bool; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return void |
|
55 | - */ |
|
56 | - public function registerAssets() |
|
57 | - { |
|
58 | - wp_register_style( |
|
59 | - Application::ID.'/blocks', |
|
60 | - glsr()->url('assets/styles/'.Application::ID.'-blocks.css'), |
|
61 | - ['wp-edit-blocks'], |
|
62 | - glsr()->version |
|
63 | - ); |
|
64 | - wp_register_script( |
|
65 | - Application::ID.'/blocks', |
|
66 | - glsr()->url('assets/scripts/'.Application::ID.'-blocks.js'), |
|
67 | - ['wp-api-fetch', 'wp-blocks', 'wp-i18n', 'wp-editor', 'wp-element', Application::ID], |
|
68 | - glsr()->version |
|
69 | - ); |
|
70 | - } |
|
53 | + /** |
|
54 | + * @return void |
|
55 | + */ |
|
56 | + public function registerAssets() |
|
57 | + { |
|
58 | + wp_register_style( |
|
59 | + Application::ID.'/blocks', |
|
60 | + glsr()->url('assets/styles/'.Application::ID.'-blocks.css'), |
|
61 | + ['wp-edit-blocks'], |
|
62 | + glsr()->version |
|
63 | + ); |
|
64 | + wp_register_script( |
|
65 | + Application::ID.'/blocks', |
|
66 | + glsr()->url('assets/scripts/'.Application::ID.'-blocks.js'), |
|
67 | + ['wp-api-fetch', 'wp-blocks', 'wp-i18n', 'wp-editor', 'wp-element', Application::ID], |
|
68 | + glsr()->version |
|
69 | + ); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @return void |
|
74 | - * @action init |
|
75 | - */ |
|
76 | - public function registerBlocks() |
|
77 | - { |
|
78 | - $blocks = [ |
|
79 | - 'form', 'reviews', 'summary', |
|
80 | - ]; |
|
81 | - foreach ($blocks as $block) { |
|
82 | - $id = str_replace('_reviews', '', Application::ID.'_'.$block); |
|
83 | - $blockClass = glsr(Helper::class)->buildClassName($id.'-block', 'Blocks'); |
|
84 | - if (!class_exists($blockClass)) { |
|
85 | - glsr_log()->error(sprintf('Class missing (%s)', $blockClass)); |
|
86 | - continue; |
|
87 | - } |
|
88 | - glsr($blockClass)->register($block); |
|
89 | - } |
|
90 | - } |
|
72 | + /** |
|
73 | + * @return void |
|
74 | + * @action init |
|
75 | + */ |
|
76 | + public function registerBlocks() |
|
77 | + { |
|
78 | + $blocks = [ |
|
79 | + 'form', 'reviews', 'summary', |
|
80 | + ]; |
|
81 | + foreach ($blocks as $block) { |
|
82 | + $id = str_replace('_reviews', '', Application::ID.'_'.$block); |
|
83 | + $blockClass = glsr(Helper::class)->buildClassName($id.'-block', 'Blocks'); |
|
84 | + if (!class_exists($blockClass)) { |
|
85 | + glsr_log()->error(sprintf('Class missing (%s)', $blockClass)); |
|
86 | + continue; |
|
87 | + } |
|
88 | + glsr($blockClass)->register($block); |
|
89 | + } |
|
90 | + } |
|
91 | 91 | } |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | * @return array |
13 | 13 | * @filter block_categories |
14 | 14 | */ |
15 | - public function filterBlockCategories($categories) |
|
15 | + public function filterBlockCategories( $categories ) |
|
16 | 16 | { |
17 | - $categories = glsr(Helper::class)->consolidateArray($categories); |
|
17 | + $categories = glsr( Helper::class )->consolidateArray( $categories ); |
|
18 | 18 | $categories[] = [ |
19 | 19 | 'icon' => null, |
20 | 20 | 'slug' => Application::ID, |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @filter classic_editor_enabled_editors_for_post_type |
31 | 31 | * @plugin classic-editor/classic-editor.php |
32 | 32 | */ |
33 | - public function filterEnabledEditors($editors, $postType) |
|
33 | + public function filterEnabledEditors( $editors, $postType ) |
|
34 | 34 | { |
35 | 35 | return Application::POST_TYPE == $postType |
36 | 36 | ? ['block_editor' => false, 'classic_editor' => false] |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return bool |
44 | 44 | * @filter use_block_editor_for_post_type |
45 | 45 | */ |
46 | - public function filterUseBlockEditor($bool, $postType) |
|
46 | + public function filterUseBlockEditor( $bool, $postType ) |
|
47 | 47 | { |
48 | 48 | return Application::POST_TYPE == $postType |
49 | 49 | ? false |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | { |
58 | 58 | wp_register_style( |
59 | 59 | Application::ID.'/blocks', |
60 | - glsr()->url('assets/styles/'.Application::ID.'-blocks.css'), |
|
60 | + glsr()->url( 'assets/styles/'.Application::ID.'-blocks.css' ), |
|
61 | 61 | ['wp-edit-blocks'], |
62 | 62 | glsr()->version |
63 | 63 | ); |
64 | 64 | wp_register_script( |
65 | 65 | Application::ID.'/blocks', |
66 | - glsr()->url('assets/scripts/'.Application::ID.'-blocks.js'), |
|
66 | + glsr()->url( 'assets/scripts/'.Application::ID.'-blocks.js' ), |
|
67 | 67 | ['wp-api-fetch', 'wp-blocks', 'wp-i18n', 'wp-editor', 'wp-element', Application::ID], |
68 | 68 | glsr()->version |
69 | 69 | ); |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | $blocks = [ |
79 | 79 | 'form', 'reviews', 'summary', |
80 | 80 | ]; |
81 | - foreach ($blocks as $block) { |
|
82 | - $id = str_replace('_reviews', '', Application::ID.'_'.$block); |
|
83 | - $blockClass = glsr(Helper::class)->buildClassName($id.'-block', 'Blocks'); |
|
84 | - if (!class_exists($blockClass)) { |
|
85 | - glsr_log()->error(sprintf('Class missing (%s)', $blockClass)); |
|
81 | + foreach( $blocks as $block ) { |
|
82 | + $id = str_replace( '_reviews', '', Application::ID.'_'.$block ); |
|
83 | + $blockClass = glsr( Helper::class )->buildClassName( $id.'-block', 'Blocks' ); |
|
84 | + if( !class_exists( $blockClass ) ) { |
|
85 | + glsr_log()->error( sprintf( 'Class missing (%s)', $blockClass ) ); |
|
86 | 86 | continue; |
87 | 87 | } |
88 | - glsr($blockClass)->register($block); |
|
88 | + glsr( $blockClass )->register( $block ); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | } |
@@ -4,14 +4,14 @@ |
||
4 | 4 | |
5 | 5 | class TogglePinned |
6 | 6 | { |
7 | - public $id; |
|
8 | - public $pinned; |
|
7 | + public $id; |
|
8 | + public $pinned; |
|
9 | 9 | |
10 | - public function __construct($input) |
|
11 | - { |
|
12 | - $this->id = $input['id']; |
|
13 | - $this->pinned = isset($input['pinned']) |
|
14 | - ? wp_validate_boolean($input['pinned']) |
|
15 | - : null; |
|
16 | - } |
|
10 | + public function __construct($input) |
|
11 | + { |
|
12 | + $this->id = $input['id']; |
|
13 | + $this->pinned = isset($input['pinned']) |
|
14 | + ? wp_validate_boolean($input['pinned']) |
|
15 | + : null; |
|
16 | + } |
|
17 | 17 | } |
@@ -7,11 +7,11 @@ |
||
7 | 7 | public $id; |
8 | 8 | public $pinned; |
9 | 9 | |
10 | - public function __construct($input) |
|
10 | + public function __construct( $input ) |
|
11 | 11 | { |
12 | 12 | $this->id = $input['id']; |
13 | 13 | $this->pinned = isset($input['pinned']) |
14 | - ? wp_validate_boolean($input['pinned']) |
|
14 | + ? wp_validate_boolean( $input['pinned'] ) |
|
15 | 15 | : null; |
16 | 16 | } |
17 | 17 | } |
@@ -4,10 +4,10 @@ |
||
4 | 4 | |
5 | 5 | class RegisterWidgets |
6 | 6 | { |
7 | - public $widgets; |
|
7 | + public $widgets; |
|
8 | 8 | |
9 | - public function __construct($input) |
|
10 | - { |
|
11 | - $this->widgets = $input; |
|
12 | - } |
|
9 | + public function __construct($input) |
|
10 | + { |
|
11 | + $this->widgets = $input; |
|
12 | + } |
|
13 | 13 | } |
@@ -6,7 +6,7 @@ |
||
6 | 6 | { |
7 | 7 | public $widgets; |
8 | 8 | |
9 | - public function __construct($input) |
|
9 | + public function __construct( $input ) |
|
10 | 10 | { |
11 | 11 | $this->widgets = $input; |
12 | 12 | } |