@@ -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 = Arr::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 = Arr::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 = Arr::consolidateArray($vars); |
|
61 | - $vars[] = glsr()->constant('PAGED_QUERY_VAR'); |
|
60 | + $vars = Arr::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,141 +10,141 @@ |
||
10 | 10 | |
11 | 11 | class Columns |
12 | 12 | { |
13 | - /** |
|
14 | - * @param int $postId |
|
15 | - * @return string |
|
16 | - */ |
|
17 | - public function buildColumnAssignedTo($postId) |
|
18 | - { |
|
19 | - $assignedPost = glsr(Database::class)->getAssignedToPost($postId); |
|
20 | - $column = '—'; |
|
21 | - if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) { |
|
22 | - $column = glsr(Builder::class)->a(get_the_title($assignedPost->ID), [ |
|
23 | - 'href' => (string) get_the_permalink($assignedPost->ID), |
|
24 | - ]); |
|
25 | - } |
|
26 | - return $column; |
|
27 | - } |
|
13 | + /** |
|
14 | + * @param int $postId |
|
15 | + * @return string |
|
16 | + */ |
|
17 | + public function buildColumnAssignedTo($postId) |
|
18 | + { |
|
19 | + $assignedPost = glsr(Database::class)->getAssignedToPost($postId); |
|
20 | + $column = '—'; |
|
21 | + if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) { |
|
22 | + $column = glsr(Builder::class)->a(get_the_title($assignedPost->ID), [ |
|
23 | + 'href' => (string) get_the_permalink($assignedPost->ID), |
|
24 | + ]); |
|
25 | + } |
|
26 | + return $column; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * @param int $postId |
|
31 | - * @return string |
|
32 | - */ |
|
33 | - public function buildColumnPinned($postId) |
|
34 | - { |
|
35 | - $pinned = glsr(Database::class)->get($postId, 'pinned') |
|
36 | - ? 'pinned ' |
|
37 | - : ''; |
|
38 | - return glsr(Builder::class)->i([ |
|
39 | - 'class' => $pinned.'dashicons dashicons-sticky', |
|
40 | - 'data-id' => $postId, |
|
41 | - ]); |
|
42 | - } |
|
29 | + /** |
|
30 | + * @param int $postId |
|
31 | + * @return string |
|
32 | + */ |
|
33 | + public function buildColumnPinned($postId) |
|
34 | + { |
|
35 | + $pinned = glsr(Database::class)->get($postId, 'pinned') |
|
36 | + ? 'pinned ' |
|
37 | + : ''; |
|
38 | + return glsr(Builder::class)->i([ |
|
39 | + 'class' => $pinned.'dashicons dashicons-sticky', |
|
40 | + 'data-id' => $postId, |
|
41 | + ]); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param int $postId |
|
46 | - * @return string |
|
47 | - */ |
|
48 | - public function buildColumnReviewer($postId) |
|
49 | - { |
|
50 | - return strval(glsr(Database::class)->get($postId, 'author')); |
|
51 | - } |
|
44 | + /** |
|
45 | + * @param int $postId |
|
46 | + * @return string |
|
47 | + */ |
|
48 | + public function buildColumnReviewer($postId) |
|
49 | + { |
|
50 | + return strval(glsr(Database::class)->get($postId, 'author')); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @param int $postId |
|
55 | - * @param int|null $rating |
|
56 | - * @return string |
|
57 | - */ |
|
58 | - public function buildColumnRating($postId) |
|
59 | - { |
|
60 | - return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating'))); |
|
61 | - } |
|
53 | + /** |
|
54 | + * @param int $postId |
|
55 | + * @param int|null $rating |
|
56 | + * @return string |
|
57 | + */ |
|
58 | + public function buildColumnRating($postId) |
|
59 | + { |
|
60 | + return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating'))); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @param int $postId |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function buildColumnReviewType($postId) |
|
68 | - { |
|
69 | - $type = glsr(Database::class)->get($postId, 'review_type'); |
|
70 | - return array_key_exists($type, glsr()->reviewTypes) |
|
71 | - ? glsr()->reviewTypes[$type] |
|
72 | - : __('Unsupported Type', 'site-reviews'); |
|
73 | - } |
|
63 | + /** |
|
64 | + * @param int $postId |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function buildColumnReviewType($postId) |
|
68 | + { |
|
69 | + $type = glsr(Database::class)->get($postId, 'review_type'); |
|
70 | + return array_key_exists($type, glsr()->reviewTypes) |
|
71 | + ? glsr()->reviewTypes[$type] |
|
72 | + : __('Unsupported Type', 'site-reviews'); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @param string $postType |
|
77 | - * @return void |
|
78 | - */ |
|
79 | - public function renderFilters($postType) |
|
80 | - { |
|
81 | - if (Application::POST_TYPE !== $postType) { |
|
82 | - return; |
|
83 | - } |
|
84 | - if (!($status = filter_input(INPUT_GET, 'post_status'))) { |
|
85 | - $status = 'publish'; |
|
86 | - } |
|
87 | - $ratings = glsr(Database::class)->getReviewsMeta('rating', $status); |
|
88 | - $types = glsr(Database::class)->getReviewsMeta('review_type', $status); |
|
89 | - $this->renderFilterRatings($ratings); |
|
90 | - $this->renderFilterTypes($types); |
|
91 | - } |
|
75 | + /** |
|
76 | + * @param string $postType |
|
77 | + * @return void |
|
78 | + */ |
|
79 | + public function renderFilters($postType) |
|
80 | + { |
|
81 | + if (Application::POST_TYPE !== $postType) { |
|
82 | + return; |
|
83 | + } |
|
84 | + if (!($status = filter_input(INPUT_GET, 'post_status'))) { |
|
85 | + $status = 'publish'; |
|
86 | + } |
|
87 | + $ratings = glsr(Database::class)->getReviewsMeta('rating', $status); |
|
88 | + $types = glsr(Database::class)->getReviewsMeta('review_type', $status); |
|
89 | + $this->renderFilterRatings($ratings); |
|
90 | + $this->renderFilterTypes($types); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * @param string $column |
|
95 | - * @param int $postId |
|
96 | - * @return void |
|
97 | - */ |
|
98 | - public function renderValues($column, $postId) |
|
99 | - { |
|
100 | - $method = Helper::buildMethodName($column, 'buildColumn'); |
|
101 | - echo method_exists($this, $method) |
|
102 | - ? call_user_func([$this, $method], $postId) |
|
103 | - : apply_filters('site-reviews/columns/'.$column, '', $postId); |
|
104 | - } |
|
93 | + /** |
|
94 | + * @param string $column |
|
95 | + * @param int $postId |
|
96 | + * @return void |
|
97 | + */ |
|
98 | + public function renderValues($column, $postId) |
|
99 | + { |
|
100 | + $method = Helper::buildMethodName($column, 'buildColumn'); |
|
101 | + echo method_exists($this, $method) |
|
102 | + ? call_user_func([$this, $method], $postId) |
|
103 | + : apply_filters('site-reviews/columns/'.$column, '', $postId); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * @param array $ratings |
|
108 | - * @return void |
|
109 | - */ |
|
110 | - protected function renderFilterRatings($ratings) |
|
111 | - { |
|
112 | - if (empty($ratings)) { |
|
113 | - return; |
|
114 | - } |
|
115 | - $ratings = array_flip(array_reverse($ratings)); |
|
116 | - array_walk($ratings, function (&$value, $key) { |
|
117 | - $label = _n('%s star', '%s stars', $key, 'site-reviews'); |
|
118 | - $value = sprintf($label, $key); |
|
119 | - }); |
|
120 | - echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [ |
|
121 | - 'class' => 'screen-reader-text', |
|
122 | - 'for' => 'rating', |
|
123 | - ]); |
|
124 | - echo glsr(Builder::class)->select([ |
|
125 | - 'name' => 'rating', |
|
126 | - 'options' => ['' => __('All ratings', 'site-reviews')] + $ratings, |
|
127 | - 'value' => filter_input(INPUT_GET, 'rating'), |
|
128 | - ]); |
|
129 | - } |
|
106 | + /** |
|
107 | + * @param array $ratings |
|
108 | + * @return void |
|
109 | + */ |
|
110 | + protected function renderFilterRatings($ratings) |
|
111 | + { |
|
112 | + if (empty($ratings)) { |
|
113 | + return; |
|
114 | + } |
|
115 | + $ratings = array_flip(array_reverse($ratings)); |
|
116 | + array_walk($ratings, function (&$value, $key) { |
|
117 | + $label = _n('%s star', '%s stars', $key, 'site-reviews'); |
|
118 | + $value = sprintf($label, $key); |
|
119 | + }); |
|
120 | + echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [ |
|
121 | + 'class' => 'screen-reader-text', |
|
122 | + 'for' => 'rating', |
|
123 | + ]); |
|
124 | + echo glsr(Builder::class)->select([ |
|
125 | + 'name' => 'rating', |
|
126 | + 'options' => ['' => __('All ratings', 'site-reviews')] + $ratings, |
|
127 | + 'value' => filter_input(INPUT_GET, 'rating'), |
|
128 | + ]); |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * @param array $types |
|
133 | - * @return void |
|
134 | - */ |
|
135 | - protected function renderFilterTypes($types) |
|
136 | - { |
|
137 | - if (count(glsr()->reviewTypes) < 2) { |
|
138 | - return; |
|
139 | - } |
|
140 | - echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [ |
|
141 | - 'class' => 'screen-reader-text', |
|
142 | - 'for' => 'review_type', |
|
143 | - ]); |
|
144 | - echo glsr(Builder::class)->select([ |
|
145 | - 'name' => 'review_type', |
|
146 | - 'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes, |
|
147 | - 'value' => filter_input(INPUT_GET, 'review_type'), |
|
148 | - ]); |
|
149 | - } |
|
131 | + /** |
|
132 | + * @param array $types |
|
133 | + * @return void |
|
134 | + */ |
|
135 | + protected function renderFilterTypes($types) |
|
136 | + { |
|
137 | + if (count(glsr()->reviewTypes) < 2) { |
|
138 | + return; |
|
139 | + } |
|
140 | + echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [ |
|
141 | + 'class' => 'screen-reader-text', |
|
142 | + 'for' => 'review_type', |
|
143 | + ]); |
|
144 | + echo glsr(Builder::class)->select([ |
|
145 | + 'name' => 'review_type', |
|
146 | + 'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes, |
|
147 | + 'value' => filter_input(INPUT_GET, 'review_type'), |
|
148 | + ]); |
|
149 | + } |
|
150 | 150 | } |
@@ -14,14 +14,14 @@ discard block |
||
14 | 14 | * @param int $postId |
15 | 15 | * @return string |
16 | 16 | */ |
17 | - public function buildColumnAssignedTo($postId) |
|
17 | + public function buildColumnAssignedTo( $postId ) |
|
18 | 18 | { |
19 | - $assignedPost = glsr(Database::class)->getAssignedToPost($postId); |
|
19 | + $assignedPost = glsr( Database::class )->getAssignedToPost( $postId ); |
|
20 | 20 | $column = '—'; |
21 | - if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) { |
|
22 | - $column = glsr(Builder::class)->a(get_the_title($assignedPost->ID), [ |
|
23 | - 'href' => (string) get_the_permalink($assignedPost->ID), |
|
24 | - ]); |
|
21 | + if( $assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status ) { |
|
22 | + $column = glsr( Builder::class )->a( get_the_title( $assignedPost->ID ), [ |
|
23 | + 'href' => (string)get_the_permalink( $assignedPost->ID ), |
|
24 | + ] ); |
|
25 | 25 | } |
26 | 26 | return $column; |
27 | 27 | } |
@@ -30,24 +30,24 @@ discard block |
||
30 | 30 | * @param int $postId |
31 | 31 | * @return string |
32 | 32 | */ |
33 | - public function buildColumnPinned($postId) |
|
33 | + public function buildColumnPinned( $postId ) |
|
34 | 34 | { |
35 | - $pinned = glsr(Database::class)->get($postId, 'pinned') |
|
35 | + $pinned = glsr( Database::class )->get( $postId, 'pinned' ) |
|
36 | 36 | ? 'pinned ' |
37 | 37 | : ''; |
38 | - return glsr(Builder::class)->i([ |
|
38 | + return glsr( Builder::class )->i( [ |
|
39 | 39 | 'class' => $pinned.'dashicons dashicons-sticky', |
40 | 40 | 'data-id' => $postId, |
41 | - ]); |
|
41 | + ] ); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @param int $postId |
46 | 46 | * @return string |
47 | 47 | */ |
48 | - public function buildColumnReviewer($postId) |
|
48 | + public function buildColumnReviewer( $postId ) |
|
49 | 49 | { |
50 | - return strval(glsr(Database::class)->get($postId, 'author')); |
|
50 | + return strval( glsr( Database::class )->get( $postId, 'author' ) ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -55,39 +55,39 @@ discard block |
||
55 | 55 | * @param int|null $rating |
56 | 56 | * @return string |
57 | 57 | */ |
58 | - public function buildColumnRating($postId) |
|
58 | + public function buildColumnRating( $postId ) |
|
59 | 59 | { |
60 | - return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating'))); |
|
60 | + return glsr_star_rating( intval( glsr( Database::class )->get( $postId, 'rating' ) ) ); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @param int $postId |
65 | 65 | * @return string |
66 | 66 | */ |
67 | - public function buildColumnReviewType($postId) |
|
67 | + public function buildColumnReviewType( $postId ) |
|
68 | 68 | { |
69 | - $type = glsr(Database::class)->get($postId, 'review_type'); |
|
70 | - return array_key_exists($type, glsr()->reviewTypes) |
|
69 | + $type = glsr( Database::class )->get( $postId, 'review_type' ); |
|
70 | + return array_key_exists( $type, glsr()->reviewTypes ) |
|
71 | 71 | ? glsr()->reviewTypes[$type] |
72 | - : __('Unsupported Type', 'site-reviews'); |
|
72 | + : __( 'Unsupported Type', 'site-reviews' ); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
76 | 76 | * @param string $postType |
77 | 77 | * @return void |
78 | 78 | */ |
79 | - public function renderFilters($postType) |
|
79 | + public function renderFilters( $postType ) |
|
80 | 80 | { |
81 | - if (Application::POST_TYPE !== $postType) { |
|
81 | + if( Application::POST_TYPE !== $postType ) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | - if (!($status = filter_input(INPUT_GET, 'post_status'))) { |
|
84 | + if( !($status = filter_input( INPUT_GET, 'post_status' )) ) { |
|
85 | 85 | $status = 'publish'; |
86 | 86 | } |
87 | - $ratings = glsr(Database::class)->getReviewsMeta('rating', $status); |
|
88 | - $types = glsr(Database::class)->getReviewsMeta('review_type', $status); |
|
89 | - $this->renderFilterRatings($ratings); |
|
90 | - $this->renderFilterTypes($types); |
|
87 | + $ratings = glsr( Database::class )->getReviewsMeta( 'rating', $status ); |
|
88 | + $types = glsr( Database::class )->getReviewsMeta( 'review_type', $status ); |
|
89 | + $this->renderFilterRatings( $ratings ); |
|
90 | + $this->renderFilterTypes( $types ); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -95,56 +95,56 @@ discard block |
||
95 | 95 | * @param int $postId |
96 | 96 | * @return void |
97 | 97 | */ |
98 | - public function renderValues($column, $postId) |
|
98 | + public function renderValues( $column, $postId ) |
|
99 | 99 | { |
100 | - $method = Helper::buildMethodName($column, 'buildColumn'); |
|
101 | - echo method_exists($this, $method) |
|
102 | - ? call_user_func([$this, $method], $postId) |
|
103 | - : apply_filters('site-reviews/columns/'.$column, '', $postId); |
|
100 | + $method = Helper::buildMethodName( $column, 'buildColumn' ); |
|
101 | + echo method_exists( $this, $method ) |
|
102 | + ? call_user_func( [$this, $method], $postId ) |
|
103 | + : apply_filters( 'site-reviews/columns/'.$column, '', $postId ); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @param array $ratings |
108 | 108 | * @return void |
109 | 109 | */ |
110 | - protected function renderFilterRatings($ratings) |
|
110 | + protected function renderFilterRatings( $ratings ) |
|
111 | 111 | { |
112 | - if (empty($ratings)) { |
|
112 | + if( empty($ratings) ) { |
|
113 | 113 | return; |
114 | 114 | } |
115 | - $ratings = array_flip(array_reverse($ratings)); |
|
116 | - array_walk($ratings, function (&$value, $key) { |
|
117 | - $label = _n('%s star', '%s stars', $key, 'site-reviews'); |
|
118 | - $value = sprintf($label, $key); |
|
115 | + $ratings = array_flip( array_reverse( $ratings ) ); |
|
116 | + array_walk( $ratings, function( &$value, $key ) { |
|
117 | + $label = _n( '%s star', '%s stars', $key, 'site-reviews' ); |
|
118 | + $value = sprintf( $label, $key ); |
|
119 | 119 | }); |
120 | - echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [ |
|
120 | + echo glsr( Builder::class )->label( __( 'Filter by rating', 'site-reviews' ), [ |
|
121 | 121 | 'class' => 'screen-reader-text', |
122 | 122 | 'for' => 'rating', |
123 | - ]); |
|
124 | - echo glsr(Builder::class)->select([ |
|
123 | + ] ); |
|
124 | + echo glsr( Builder::class )->select( [ |
|
125 | 125 | 'name' => 'rating', |
126 | - 'options' => ['' => __('All ratings', 'site-reviews')] + $ratings, |
|
127 | - 'value' => filter_input(INPUT_GET, 'rating'), |
|
128 | - ]); |
|
126 | + 'options' => ['' => __( 'All ratings', 'site-reviews' )] + $ratings, |
|
127 | + 'value' => filter_input( INPUT_GET, 'rating' ), |
|
128 | + ] ); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
132 | 132 | * @param array $types |
133 | 133 | * @return void |
134 | 134 | */ |
135 | - protected function renderFilterTypes($types) |
|
135 | + protected function renderFilterTypes( $types ) |
|
136 | 136 | { |
137 | - if (count(glsr()->reviewTypes) < 2) { |
|
137 | + if( count( glsr()->reviewTypes ) < 2 ) { |
|
138 | 138 | return; |
139 | 139 | } |
140 | - echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [ |
|
140 | + echo glsr( Builder::class )->label( __( 'Filter by type', 'site-reviews' ), [ |
|
141 | 141 | 'class' => 'screen-reader-text', |
142 | 142 | 'for' => 'review_type', |
143 | - ]); |
|
144 | - echo glsr(Builder::class)->select([ |
|
143 | + ] ); |
|
144 | + echo glsr( Builder::class )->select( [ |
|
145 | 145 | 'name' => 'review_type', |
146 | - 'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes, |
|
147 | - 'value' => filter_input(INPUT_GET, 'review_type'), |
|
148 | - ]); |
|
146 | + 'options' => ['' => __( 'All types', 'site-reviews' )] + glsr()->reviewTypes, |
|
147 | + 'value' => filter_input( INPUT_GET, 'review_type' ), |
|
148 | + ] ); |
|
149 | 149 | } |
150 | 150 | } |
@@ -7,18 +7,18 @@ |
||
7 | 7 | |
8 | 8 | class RegisterShortcodes |
9 | 9 | { |
10 | - /** |
|
11 | - * @return void |
|
12 | - */ |
|
13 | - public function handle(Command $command) |
|
14 | - { |
|
15 | - foreach ($command->shortcodes as $shortcode) { |
|
16 | - $shortcodeClass = Helper::buildClassName($shortcode.'-shortcode', 'Shortcodes'); |
|
17 | - if (!class_exists($shortcodeClass)) { |
|
18 | - glsr_log()->error(sprintf('Class missing (%s)', $shortcodeClass)); |
|
19 | - continue; |
|
20 | - } |
|
21 | - add_shortcode($shortcode, [glsr($shortcodeClass), 'buildShortcode']); |
|
22 | - } |
|
23 | - } |
|
10 | + /** |
|
11 | + * @return void |
|
12 | + */ |
|
13 | + public function handle(Command $command) |
|
14 | + { |
|
15 | + foreach ($command->shortcodes as $shortcode) { |
|
16 | + $shortcodeClass = Helper::buildClassName($shortcode.'-shortcode', 'Shortcodes'); |
|
17 | + if (!class_exists($shortcodeClass)) { |
|
18 | + glsr_log()->error(sprintf('Class missing (%s)', $shortcodeClass)); |
|
19 | + continue; |
|
20 | + } |
|
21 | + add_shortcode($shortcode, [glsr($shortcodeClass), 'buildShortcode']); |
|
22 | + } |
|
23 | + } |
|
24 | 24 | } |
@@ -10,15 +10,15 @@ |
||
10 | 10 | /** |
11 | 11 | * @return void |
12 | 12 | */ |
13 | - public function handle(Command $command) |
|
13 | + public function handle( Command $command ) |
|
14 | 14 | { |
15 | - foreach ($command->shortcodes as $shortcode) { |
|
16 | - $shortcodeClass = Helper::buildClassName($shortcode.'-shortcode', 'Shortcodes'); |
|
17 | - if (!class_exists($shortcodeClass)) { |
|
18 | - glsr_log()->error(sprintf('Class missing (%s)', $shortcodeClass)); |
|
15 | + foreach( $command->shortcodes as $shortcode ) { |
|
16 | + $shortcodeClass = Helper::buildClassName( $shortcode.'-shortcode', 'Shortcodes' ); |
|
17 | + if( !class_exists( $shortcodeClass ) ) { |
|
18 | + glsr_log()->error( sprintf( 'Class missing (%s)', $shortcodeClass ) ); |
|
19 | 19 | continue; |
20 | 20 | } |
21 | - add_shortcode($shortcode, [glsr($shortcodeClass), 'buildShortcode']); |
|
21 | + add_shortcode( $shortcode, [glsr( $shortcodeClass ), 'buildShortcode'] ); |
|
22 | 22 | } |
23 | 23 | } |
24 | 24 | } |
@@ -7,22 +7,22 @@ |
||
7 | 7 | |
8 | 8 | class RegisterTinymcePopups |
9 | 9 | { |
10 | - /** |
|
11 | - * @return void |
|
12 | - */ |
|
13 | - public function handle(Command $command) |
|
14 | - { |
|
15 | - foreach ($command->popups as $slug => $label) { |
|
16 | - $buttonClass = Helper::buildClassName($slug.'-popup', 'Shortcodes'); |
|
17 | - if (!class_exists($buttonClass)) { |
|
18 | - glsr_log()->error(sprintf('Class missing (%s)', $buttonClass)); |
|
19 | - continue; |
|
20 | - } |
|
21 | - $shortcode = glsr($buttonClass)->register($slug, [ |
|
22 | - 'label' => $label, |
|
23 | - 'title' => $label, |
|
24 | - ]); |
|
25 | - glsr()->mceShortcodes[$slug] = $shortcode->properties; |
|
26 | - } |
|
27 | - } |
|
10 | + /** |
|
11 | + * @return void |
|
12 | + */ |
|
13 | + public function handle(Command $command) |
|
14 | + { |
|
15 | + foreach ($command->popups as $slug => $label) { |
|
16 | + $buttonClass = Helper::buildClassName($slug.'-popup', 'Shortcodes'); |
|
17 | + if (!class_exists($buttonClass)) { |
|
18 | + glsr_log()->error(sprintf('Class missing (%s)', $buttonClass)); |
|
19 | + continue; |
|
20 | + } |
|
21 | + $shortcode = glsr($buttonClass)->register($slug, [ |
|
22 | + 'label' => $label, |
|
23 | + 'title' => $label, |
|
24 | + ]); |
|
25 | + glsr()->mceShortcodes[$slug] = $shortcode->properties; |
|
26 | + } |
|
27 | + } |
|
28 | 28 | } |
@@ -10,18 +10,18 @@ |
||
10 | 10 | /** |
11 | 11 | * @return void |
12 | 12 | */ |
13 | - public function handle(Command $command) |
|
13 | + public function handle( Command $command ) |
|
14 | 14 | { |
15 | - foreach ($command->popups as $slug => $label) { |
|
16 | - $buttonClass = Helper::buildClassName($slug.'-popup', 'Shortcodes'); |
|
17 | - if (!class_exists($buttonClass)) { |
|
18 | - glsr_log()->error(sprintf('Class missing (%s)', $buttonClass)); |
|
15 | + foreach( $command->popups as $slug => $label ) { |
|
16 | + $buttonClass = Helper::buildClassName( $slug.'-popup', 'Shortcodes' ); |
|
17 | + if( !class_exists( $buttonClass ) ) { |
|
18 | + glsr_log()->error( sprintf( 'Class missing (%s)', $buttonClass ) ); |
|
19 | 19 | continue; |
20 | 20 | } |
21 | - $shortcode = glsr($buttonClass)->register($slug, [ |
|
21 | + $shortcode = glsr( $buttonClass )->register( $slug, [ |
|
22 | 22 | 'label' => $label, |
23 | 23 | 'title' => $label, |
24 | - ]); |
|
24 | + ] ); |
|
25 | 25 | glsr()->mceShortcodes[$slug] = $shortcode->properties; |
26 | 26 | } |
27 | 27 | } |
@@ -8,21 +8,21 @@ |
||
8 | 8 | |
9 | 9 | class RegisterWidgets |
10 | 10 | { |
11 | - /** |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function handle(Command $command) |
|
15 | - { |
|
16 | - global $wp_widget_factory; |
|
17 | - foreach ($command->widgets as $key => $values) { |
|
18 | - $widgetClass = Helper::buildClassName($key.'-widget', 'Widgets'); |
|
19 | - if (!class_exists($widgetClass)) { |
|
20 | - glsr_log()->error(sprintf('Class missing (%s)', $widgetClass)); |
|
21 | - continue; |
|
22 | - } |
|
23 | - // Here we bypass register_widget() in order to pass our custom values to the widget |
|
24 | - $widget = new $widgetClass(Application::ID.'_'.$key, $values['title'], $values); |
|
25 | - $wp_widget_factory->widgets[$widgetClass] = $widget; |
|
26 | - } |
|
27 | - } |
|
11 | + /** |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function handle(Command $command) |
|
15 | + { |
|
16 | + global $wp_widget_factory; |
|
17 | + foreach ($command->widgets as $key => $values) { |
|
18 | + $widgetClass = Helper::buildClassName($key.'-widget', 'Widgets'); |
|
19 | + if (!class_exists($widgetClass)) { |
|
20 | + glsr_log()->error(sprintf('Class missing (%s)', $widgetClass)); |
|
21 | + continue; |
|
22 | + } |
|
23 | + // Here we bypass register_widget() in order to pass our custom values to the widget |
|
24 | + $widget = new $widgetClass(Application::ID.'_'.$key, $values['title'], $values); |
|
25 | + $wp_widget_factory->widgets[$widgetClass] = $widget; |
|
26 | + } |
|
27 | + } |
|
28 | 28 | } |
@@ -11,17 +11,17 @@ |
||
11 | 11 | /** |
12 | 12 | * @return void |
13 | 13 | */ |
14 | - public function handle(Command $command) |
|
14 | + public function handle( Command $command ) |
|
15 | 15 | { |
16 | 16 | global $wp_widget_factory; |
17 | - foreach ($command->widgets as $key => $values) { |
|
18 | - $widgetClass = Helper::buildClassName($key.'-widget', 'Widgets'); |
|
19 | - if (!class_exists($widgetClass)) { |
|
20 | - glsr_log()->error(sprintf('Class missing (%s)', $widgetClass)); |
|
17 | + foreach( $command->widgets as $key => $values ) { |
|
18 | + $widgetClass = Helper::buildClassName( $key.'-widget', 'Widgets' ); |
|
19 | + if( !class_exists( $widgetClass ) ) { |
|
20 | + glsr_log()->error( sprintf( 'Class missing (%s)', $widgetClass ) ); |
|
21 | 21 | continue; |
22 | 22 | } |
23 | 23 | // Here we bypass register_widget() in order to pass our custom values to the widget |
24 | - $widget = new $widgetClass(Application::ID.'_'.$key, $values['title'], $values); |
|
24 | + $widget = new $widgetClass( Application::ID.'_'.$key, $values['title'], $values ); |
|
25 | 25 | $wp_widget_factory->widgets[$widgetClass] = $widget; |
26 | 26 | } |
27 | 27 | } |
@@ -8,121 +8,121 @@ |
||
8 | 8 | |
9 | 9 | class Helper |
10 | 10 | { |
11 | - /** |
|
12 | - * @param string $name |
|
13 | - * @param string $path |
|
14 | - * @return string |
|
15 | - */ |
|
16 | - public static function buildClassName($name, $path = '') |
|
17 | - { |
|
18 | - $className = Str::camelCase($name); |
|
19 | - $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\'); |
|
20 | - return !empty($path) |
|
21 | - ? __NAMESPACE__.'\\'.$path.'\\'.$className |
|
22 | - : $className; |
|
23 | - } |
|
11 | + /** |
|
12 | + * @param string $name |
|
13 | + * @param string $path |
|
14 | + * @return string |
|
15 | + */ |
|
16 | + public static function buildClassName($name, $path = '') |
|
17 | + { |
|
18 | + $className = Str::camelCase($name); |
|
19 | + $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\'); |
|
20 | + return !empty($path) |
|
21 | + ? __NAMESPACE__.'\\'.$path.'\\'.$className |
|
22 | + : $className; |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * @param string $name |
|
27 | - * @param string $prefix |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - public static function buildMethodName($name, $prefix = '') |
|
31 | - { |
|
32 | - return lcfirst($prefix.static::buildClassName($name)); |
|
33 | - } |
|
25 | + /** |
|
26 | + * @param string $name |
|
27 | + * @param string $prefix |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + public static function buildMethodName($name, $prefix = '') |
|
31 | + { |
|
32 | + return lcfirst($prefix.static::buildClassName($name)); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param string $name |
|
37 | - * @return string |
|
38 | - */ |
|
39 | - public static function buildPropertyName($name) |
|
40 | - { |
|
41 | - return lcfirst(static::buildClassName($name)); |
|
42 | - } |
|
35 | + /** |
|
36 | + * @param string $name |
|
37 | + * @return string |
|
38 | + */ |
|
39 | + public static function buildPropertyName($name) |
|
40 | + { |
|
41 | + return lcfirst(static::buildClassName($name)); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param string $cast |
|
46 | - * @param mixed $value |
|
47 | - * @return mixed |
|
48 | - */ |
|
49 | - public static function castTo($cast = '', $value) |
|
50 | - { |
|
51 | - switch ($cast) { |
|
52 | - case 'array': |
|
53 | - return (array) $value; |
|
54 | - case 'bool': |
|
55 | - case 'boolean': |
|
56 | - return filter_var($value, FILTER_VALIDATE_BOOLEAN); |
|
57 | - case 'float': |
|
58 | - return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND); |
|
59 | - case 'int': |
|
60 | - case 'integer': |
|
61 | - return (int) filter_var($value, FILTER_VALIDATE_INT); |
|
62 | - case 'object': |
|
63 | - return (object) (array) $value; |
|
64 | - case 'str': |
|
65 | - case 'string': |
|
66 | - if (is_object($value) && in_array('__toString', get_class_methods($value))) { |
|
67 | - return (string) $value->__toString(); |
|
68 | - } |
|
69 | - if (is_array($value) || is_object($value)) { |
|
70 | - return serialize($value); |
|
71 | - } |
|
72 | - return (string) $value; |
|
73 | - default: |
|
74 | - return $value; |
|
75 | - } |
|
76 | - } |
|
44 | + /** |
|
45 | + * @param string $cast |
|
46 | + * @param mixed $value |
|
47 | + * @return mixed |
|
48 | + */ |
|
49 | + public static function castTo($cast = '', $value) |
|
50 | + { |
|
51 | + switch ($cast) { |
|
52 | + case 'array': |
|
53 | + return (array) $value; |
|
54 | + case 'bool': |
|
55 | + case 'boolean': |
|
56 | + return filter_var($value, FILTER_VALIDATE_BOOLEAN); |
|
57 | + case 'float': |
|
58 | + return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND); |
|
59 | + case 'int': |
|
60 | + case 'integer': |
|
61 | + return (int) filter_var($value, FILTER_VALIDATE_INT); |
|
62 | + case 'object': |
|
63 | + return (object) (array) $value; |
|
64 | + case 'str': |
|
65 | + case 'string': |
|
66 | + if (is_object($value) && in_array('__toString', get_class_methods($value))) { |
|
67 | + return (string) $value->__toString(); |
|
68 | + } |
|
69 | + if (is_array($value) || is_object($value)) { |
|
70 | + return serialize($value); |
|
71 | + } |
|
72 | + return (string) $value; |
|
73 | + default: |
|
74 | + return $value; |
|
75 | + } |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param string $key |
|
80 | - * @return mixed |
|
81 | - */ |
|
82 | - public static function filterInput($key, array $request = []) |
|
83 | - { |
|
84 | - if (isset($request[$key])) { |
|
85 | - return $request[$key]; |
|
86 | - } |
|
87 | - $variable = filter_input(INPUT_POST, $key); |
|
88 | - if (is_null($variable) && isset($_POST[$key])) { |
|
89 | - $variable = $_POST[$key]; |
|
90 | - } |
|
91 | - return $variable; |
|
92 | - } |
|
78 | + /** |
|
79 | + * @param string $key |
|
80 | + * @return mixed |
|
81 | + */ |
|
82 | + public static function filterInput($key, array $request = []) |
|
83 | + { |
|
84 | + if (isset($request[$key])) { |
|
85 | + return $request[$key]; |
|
86 | + } |
|
87 | + $variable = filter_input(INPUT_POST, $key); |
|
88 | + if (is_null($variable) && isset($_POST[$key])) { |
|
89 | + $variable = $_POST[$key]; |
|
90 | + } |
|
91 | + return $variable; |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * @param string $key |
|
96 | - * @return array |
|
97 | - */ |
|
98 | - public static function filterInputArray($key) |
|
99 | - { |
|
100 | - $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
101 | - if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) { |
|
102 | - $variable = $_POST[$key]; |
|
103 | - } |
|
104 | - return (array) $variable; |
|
105 | - } |
|
94 | + /** |
|
95 | + * @param string $key |
|
96 | + * @return array |
|
97 | + */ |
|
98 | + public static function filterInputArray($key) |
|
99 | + { |
|
100 | + $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
101 | + if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) { |
|
102 | + $variable = $_POST[$key]; |
|
103 | + } |
|
104 | + return (array) $variable; |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * @return string |
|
109 | - */ |
|
110 | - public static function getIpAddress() |
|
111 | - { |
|
112 | - $cloudflareIps = glsr(Cache::class)->getCloudflareIps(); |
|
113 | - $whitelist = [ |
|
114 | - Whip::CLOUDFLARE_HEADERS => [Whip::IPV4 => $cloudflareIps['v4']], |
|
115 | - // Whip::CUSTOM_HEADERS => [Whip::IPV4 => ['127.0.0.1']], |
|
116 | - ]; |
|
117 | - if (defined('AF_INET6')) { |
|
118 | - $whitelist[Whip::CLOUDFLARE_HEADERS][Whip::IPV6] = $cloudflareIps['v6']; |
|
119 | - // $whitelist[Whip::CUSTOM_HEADERS][Whip::IPV6] = ['::1']; |
|
120 | - } |
|
121 | - $whitelist = apply_filters('site-reviews/whip/whitelist', $whitelist); |
|
122 | - $methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR; |
|
123 | - $methods = apply_filters('site-reviews/whip/methods', $methods); |
|
124 | - $whip = new Whip($methods, $whitelist); |
|
125 | - do_action_ref_array('site-reviews/whip', [$whip]); |
|
126 | - return (string) $whip->getValidIpAddress(); |
|
127 | - } |
|
107 | + /** |
|
108 | + * @return string |
|
109 | + */ |
|
110 | + public static function getIpAddress() |
|
111 | + { |
|
112 | + $cloudflareIps = glsr(Cache::class)->getCloudflareIps(); |
|
113 | + $whitelist = [ |
|
114 | + Whip::CLOUDFLARE_HEADERS => [Whip::IPV4 => $cloudflareIps['v4']], |
|
115 | + // Whip::CUSTOM_HEADERS => [Whip::IPV4 => ['127.0.0.1']], |
|
116 | + ]; |
|
117 | + if (defined('AF_INET6')) { |
|
118 | + $whitelist[Whip::CLOUDFLARE_HEADERS][Whip::IPV6] = $cloudflareIps['v6']; |
|
119 | + // $whitelist[Whip::CUSTOM_HEADERS][Whip::IPV6] = ['::1']; |
|
120 | + } |
|
121 | + $whitelist = apply_filters('site-reviews/whip/whitelist', $whitelist); |
|
122 | + $methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR; |
|
123 | + $methods = apply_filters('site-reviews/whip/methods', $methods); |
|
124 | + $whip = new Whip($methods, $whitelist); |
|
125 | + do_action_ref_array('site-reviews/whip', [$whip]); |
|
126 | + return (string) $whip->getValidIpAddress(); |
|
127 | + } |
|
128 | 128 | } |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | * @param string $path |
14 | 14 | * @return string |
15 | 15 | */ |
16 | - public static function buildClassName($name, $path = '') |
|
16 | + public static function buildClassName( $name, $path = '' ) |
|
17 | 17 | { |
18 | - $className = Str::camelCase($name); |
|
19 | - $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\'); |
|
18 | + $className = Str::camelCase( $name ); |
|
19 | + $path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' ); |
|
20 | 20 | return !empty($path) |
21 | 21 | ? __NAMESPACE__.'\\'.$path.'\\'.$className |
22 | 22 | : $className; |
@@ -27,18 +27,18 @@ discard block |
||
27 | 27 | * @param string $prefix |
28 | 28 | * @return string |
29 | 29 | */ |
30 | - public static function buildMethodName($name, $prefix = '') |
|
30 | + public static function buildMethodName( $name, $prefix = '' ) |
|
31 | 31 | { |
32 | - return lcfirst($prefix.static::buildClassName($name)); |
|
32 | + return lcfirst( $prefix.static::buildClassName( $name ) ); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * @param string $name |
37 | 37 | * @return string |
38 | 38 | */ |
39 | - public static function buildPropertyName($name) |
|
39 | + public static function buildPropertyName( $name ) |
|
40 | 40 | { |
41 | - return lcfirst(static::buildClassName($name)); |
|
41 | + return lcfirst( static::buildClassName( $name ) ); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -46,30 +46,30 @@ discard block |
||
46 | 46 | * @param mixed $value |
47 | 47 | * @return mixed |
48 | 48 | */ |
49 | - public static function castTo($cast = '', $value) |
|
49 | + public static function castTo( $cast = '', $value ) |
|
50 | 50 | { |
51 | - switch ($cast) { |
|
51 | + switch( $cast ) { |
|
52 | 52 | case 'array': |
53 | - return (array) $value; |
|
53 | + return (array)$value; |
|
54 | 54 | case 'bool': |
55 | 55 | case 'boolean': |
56 | - return filter_var($value, FILTER_VALIDATE_BOOLEAN); |
|
56 | + return filter_var( $value, FILTER_VALIDATE_BOOLEAN ); |
|
57 | 57 | case 'float': |
58 | - return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND); |
|
58 | + return (float)filter_var( $value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND ); |
|
59 | 59 | case 'int': |
60 | 60 | case 'integer': |
61 | - return (int) filter_var($value, FILTER_VALIDATE_INT); |
|
61 | + return (int)filter_var( $value, FILTER_VALIDATE_INT ); |
|
62 | 62 | case 'object': |
63 | - return (object) (array) $value; |
|
63 | + return (object)(array)$value; |
|
64 | 64 | case 'str': |
65 | 65 | case 'string': |
66 | - if (is_object($value) && in_array('__toString', get_class_methods($value))) { |
|
67 | - return (string) $value->__toString(); |
|
66 | + if( is_object( $value ) && in_array( '__toString', get_class_methods( $value ) ) ) { |
|
67 | + return (string)$value->__toString(); |
|
68 | 68 | } |
69 | - if (is_array($value) || is_object($value)) { |
|
70 | - return serialize($value); |
|
69 | + if( is_array( $value ) || is_object( $value ) ) { |
|
70 | + return serialize( $value ); |
|
71 | 71 | } |
72 | - return (string) $value; |
|
72 | + return (string)$value; |
|
73 | 73 | default: |
74 | 74 | return $value; |
75 | 75 | } |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | * @param string $key |
80 | 80 | * @return mixed |
81 | 81 | */ |
82 | - public static function filterInput($key, array $request = []) |
|
82 | + public static function filterInput( $key, array $request = [] ) |
|
83 | 83 | { |
84 | - if (isset($request[$key])) { |
|
84 | + if( isset($request[$key]) ) { |
|
85 | 85 | return $request[$key]; |
86 | 86 | } |
87 | - $variable = filter_input(INPUT_POST, $key); |
|
88 | - if (is_null($variable) && isset($_POST[$key])) { |
|
87 | + $variable = filter_input( INPUT_POST, $key ); |
|
88 | + if( is_null( $variable ) && isset($_POST[$key]) ) { |
|
89 | 89 | $variable = $_POST[$key]; |
90 | 90 | } |
91 | 91 | return $variable; |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | * @param string $key |
96 | 96 | * @return array |
97 | 97 | */ |
98 | - public static function filterInputArray($key) |
|
98 | + public static function filterInputArray( $key ) |
|
99 | 99 | { |
100 | - $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); |
|
101 | - if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) { |
|
100 | + $variable = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); |
|
101 | + if( empty($variable) && !empty($_POST[$key]) && is_array( $_POST[$key] ) ) { |
|
102 | 102 | $variable = $_POST[$key]; |
103 | 103 | } |
104 | - return (array) $variable; |
|
104 | + return (array)$variable; |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -109,20 +109,20 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public static function getIpAddress() |
111 | 111 | { |
112 | - $cloudflareIps = glsr(Cache::class)->getCloudflareIps(); |
|
112 | + $cloudflareIps = glsr( Cache::class )->getCloudflareIps(); |
|
113 | 113 | $whitelist = [ |
114 | 114 | Whip::CLOUDFLARE_HEADERS => [Whip::IPV4 => $cloudflareIps['v4']], |
115 | 115 | // Whip::CUSTOM_HEADERS => [Whip::IPV4 => ['127.0.0.1']], |
116 | 116 | ]; |
117 | - if (defined('AF_INET6')) { |
|
117 | + if( defined( 'AF_INET6' ) ) { |
|
118 | 118 | $whitelist[Whip::CLOUDFLARE_HEADERS][Whip::IPV6] = $cloudflareIps['v6']; |
119 | 119 | // $whitelist[Whip::CUSTOM_HEADERS][Whip::IPV6] = ['::1']; |
120 | 120 | } |
121 | - $whitelist = apply_filters('site-reviews/whip/whitelist', $whitelist); |
|
121 | + $whitelist = apply_filters( 'site-reviews/whip/whitelist', $whitelist ); |
|
122 | 122 | $methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR; |
123 | - $methods = apply_filters('site-reviews/whip/methods', $methods); |
|
124 | - $whip = new Whip($methods, $whitelist); |
|
125 | - do_action_ref_array('site-reviews/whip', [$whip]); |
|
126 | - return (string) $whip->getValidIpAddress(); |
|
123 | + $methods = apply_filters( 'site-reviews/whip/methods', $methods ); |
|
124 | + $whip = new Whip( $methods, $whitelist ); |
|
125 | + do_action_ref_array( 'site-reviews/whip', [$whip] ); |
|
126 | + return (string)$whip->getValidIpAddress(); |
|
127 | 127 | } |
128 | 128 | } |
@@ -7,22 +7,22 @@ |
||
7 | 7 | |
8 | 8 | class ValidateReviewDefaults extends Defaults |
9 | 9 | { |
10 | - /** |
|
11 | - * @return array |
|
12 | - */ |
|
13 | - protected function defaults() |
|
14 | - { |
|
15 | - return [ |
|
16 | - 'assign_to' => '', |
|
17 | - 'category' => '', |
|
18 | - 'content' => '', |
|
19 | - 'email' => '', |
|
20 | - 'form_id' => '', |
|
21 | - 'ip_address' => Helper::getIpAddress(), // required for Akismet and Blacklist validation |
|
22 | - 'name' => '', |
|
23 | - 'rating' => '0', |
|
24 | - 'terms' => '', |
|
25 | - 'title' => '', |
|
26 | - ]; |
|
27 | - } |
|
10 | + /** |
|
11 | + * @return array |
|
12 | + */ |
|
13 | + protected function defaults() |
|
14 | + { |
|
15 | + return [ |
|
16 | + 'assign_to' => '', |
|
17 | + 'category' => '', |
|
18 | + 'content' => '', |
|
19 | + 'email' => '', |
|
20 | + 'form_id' => '', |
|
21 | + 'ip_address' => Helper::getIpAddress(), // required for Akismet and Blacklist validation |
|
22 | + 'name' => '', |
|
23 | + 'rating' => '0', |
|
24 | + 'terms' => '', |
|
25 | + 'title' => '', |
|
26 | + ]; |
|
27 | + } |
|
28 | 28 | } |
@@ -7,117 +7,117 @@ |
||
7 | 7 | |
8 | 8 | abstract class DefaultsAbstract |
9 | 9 | { |
10 | - /** |
|
11 | - * @var array |
|
12 | - */ |
|
13 | - protected $callable = [ |
|
14 | - 'defaults', 'filter', 'merge', 'restrict', 'unguarded', |
|
15 | - ]; |
|
10 | + /** |
|
11 | + * @var array |
|
12 | + */ |
|
13 | + protected $callable = [ |
|
14 | + 'defaults', 'filter', 'merge', 'restrict', 'unguarded', |
|
15 | + ]; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @var array |
|
19 | - */ |
|
20 | - protected $guarded = []; |
|
17 | + /** |
|
18 | + * @var array |
|
19 | + */ |
|
20 | + protected $guarded = []; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @param string $name |
|
24 | - * @return void|array |
|
25 | - */ |
|
26 | - public function __call($name, array $args = []) |
|
27 | - { |
|
28 | - if (!method_exists($this, $name) || !in_array($name, $this->callable)) { |
|
29 | - return; |
|
30 | - } |
|
31 | - $defaults = call_user_func_array([$this, $name], $args); |
|
32 | - $hookName = (new ReflectionClass($this))->getShortName(); |
|
33 | - $hookName = str_replace('Defaults', '', $hookName); |
|
34 | - $hookName = Str::dashCase($hookName); |
|
35 | - return apply_filters('site-reviews/defaults/'.$hookName, $defaults, $name); |
|
36 | - } |
|
22 | + /** |
|
23 | + * @param string $name |
|
24 | + * @return void|array |
|
25 | + */ |
|
26 | + public function __call($name, array $args = []) |
|
27 | + { |
|
28 | + if (!method_exists($this, $name) || !in_array($name, $this->callable)) { |
|
29 | + return; |
|
30 | + } |
|
31 | + $defaults = call_user_func_array([$this, $name], $args); |
|
32 | + $hookName = (new ReflectionClass($this))->getShortName(); |
|
33 | + $hookName = str_replace('Defaults', '', $hookName); |
|
34 | + $hookName = Str::dashCase($hookName); |
|
35 | + return apply_filters('site-reviews/defaults/'.$hookName, $defaults, $name); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @return array |
|
40 | - */ |
|
41 | - abstract protected function defaults(); |
|
38 | + /** |
|
39 | + * @return array |
|
40 | + */ |
|
41 | + abstract protected function defaults(); |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return array |
|
45 | - */ |
|
46 | - protected function filter(array $values = []) |
|
47 | - { |
|
48 | - return $this->normalize($this->merge(array_filter($values)), $values); |
|
49 | - } |
|
43 | + /** |
|
44 | + * @return array |
|
45 | + */ |
|
46 | + protected function filter(array $values = []) |
|
47 | + { |
|
48 | + return $this->normalize($this->merge(array_filter($values)), $values); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return string |
|
53 | - */ |
|
54 | - protected function filteredJson(array $values = []) |
|
55 | - { |
|
56 | - $defaults = $this->flattenArray( |
|
57 | - array_diff_key($this->defaults(), array_flip($this->guarded)) |
|
58 | - ); |
|
59 | - $values = $this->flattenArray( |
|
60 | - shortcode_atts($defaults, $values) |
|
61 | - ); |
|
62 | - $filtered = array_filter(array_diff_assoc($values, $defaults), function ($value) { |
|
63 | - return !$this->isEmpty($value); |
|
64 | - }); |
|
65 | - return json_encode($filtered, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
|
66 | - } |
|
51 | + /** |
|
52 | + * @return string |
|
53 | + */ |
|
54 | + protected function filteredJson(array $values = []) |
|
55 | + { |
|
56 | + $defaults = $this->flattenArray( |
|
57 | + array_diff_key($this->defaults(), array_flip($this->guarded)) |
|
58 | + ); |
|
59 | + $values = $this->flattenArray( |
|
60 | + shortcode_atts($defaults, $values) |
|
61 | + ); |
|
62 | + $filtered = array_filter(array_diff_assoc($values, $defaults), function ($value) { |
|
63 | + return !$this->isEmpty($value); |
|
64 | + }); |
|
65 | + return json_encode($filtered, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @return array |
|
70 | - */ |
|
71 | - protected function flattenArray(array $values) |
|
72 | - { |
|
73 | - array_walk($values, function (&$value) { |
|
74 | - if (!is_array($value)) { |
|
75 | - return; |
|
76 | - } |
|
77 | - $value = implode(',', $value); |
|
78 | - }); |
|
79 | - return $values; |
|
80 | - } |
|
68 | + /** |
|
69 | + * @return array |
|
70 | + */ |
|
71 | + protected function flattenArray(array $values) |
|
72 | + { |
|
73 | + array_walk($values, function (&$value) { |
|
74 | + if (!is_array($value)) { |
|
75 | + return; |
|
76 | + } |
|
77 | + $value = implode(',', $value); |
|
78 | + }); |
|
79 | + return $values; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @param mixed $var |
|
84 | - * @return bool |
|
85 | - */ |
|
86 | - protected function isEmpty($var) |
|
87 | - { |
|
88 | - return !is_numeric($var) && !is_bool($var) && empty($var); |
|
89 | - } |
|
82 | + /** |
|
83 | + * @param mixed $var |
|
84 | + * @return bool |
|
85 | + */ |
|
86 | + protected function isEmpty($var) |
|
87 | + { |
|
88 | + return !is_numeric($var) && !is_bool($var) && empty($var); |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * @return array |
|
93 | - */ |
|
94 | - protected function merge(array $values = []) |
|
95 | - { |
|
96 | - return $this->normalize(wp_parse_args($values, $this->defaults()), $values); |
|
97 | - } |
|
91 | + /** |
|
92 | + * @return array |
|
93 | + */ |
|
94 | + protected function merge(array $values = []) |
|
95 | + { |
|
96 | + return $this->normalize(wp_parse_args($values, $this->defaults()), $values); |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * @return array |
|
101 | - */ |
|
102 | - protected function normalize(array $values, array $originalValues) |
|
103 | - { |
|
104 | - $values['json'] = $this->filteredJson($originalValues); |
|
105 | - return $values; |
|
106 | - } |
|
99 | + /** |
|
100 | + * @return array |
|
101 | + */ |
|
102 | + protected function normalize(array $values, array $originalValues) |
|
103 | + { |
|
104 | + $values['json'] = $this->filteredJson($originalValues); |
|
105 | + return $values; |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * @return array |
|
110 | - */ |
|
111 | - protected function restrict(array $values = []) |
|
112 | - { |
|
113 | - return $this->normalize(shortcode_atts($this->defaults(), $values), $values); |
|
114 | - } |
|
108 | + /** |
|
109 | + * @return array |
|
110 | + */ |
|
111 | + protected function restrict(array $values = []) |
|
112 | + { |
|
113 | + return $this->normalize(shortcode_atts($this->defaults(), $values), $values); |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * @return array |
|
118 | - */ |
|
119 | - protected function unguarded() |
|
120 | - { |
|
121 | - return array_diff_key($this->defaults(), array_flip($this->guarded)); |
|
122 | - } |
|
116 | + /** |
|
117 | + * @return array |
|
118 | + */ |
|
119 | + protected function unguarded() |
|
120 | + { |
|
121 | + return array_diff_key($this->defaults(), array_flip($this->guarded)); |
|
122 | + } |
|
123 | 123 | } |
@@ -23,16 +23,16 @@ discard block |
||
23 | 23 | * @param string $name |
24 | 24 | * @return void|array |
25 | 25 | */ |
26 | - public function __call($name, array $args = []) |
|
26 | + public function __call( $name, array $args = [] ) |
|
27 | 27 | { |
28 | - if (!method_exists($this, $name) || !in_array($name, $this->callable)) { |
|
28 | + if( !method_exists( $this, $name ) || !in_array( $name, $this->callable ) ) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | - $defaults = call_user_func_array([$this, $name], $args); |
|
32 | - $hookName = (new ReflectionClass($this))->getShortName(); |
|
33 | - $hookName = str_replace('Defaults', '', $hookName); |
|
34 | - $hookName = Str::dashCase($hookName); |
|
35 | - return apply_filters('site-reviews/defaults/'.$hookName, $defaults, $name); |
|
31 | + $defaults = call_user_func_array( [$this, $name], $args ); |
|
32 | + $hookName = (new ReflectionClass( $this ))->getShortName(); |
|
33 | + $hookName = str_replace( 'Defaults', '', $hookName ); |
|
34 | + $hookName = Str::dashCase( $hookName ); |
|
35 | + return apply_filters( 'site-reviews/defaults/'.$hookName, $defaults, $name ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -43,38 +43,38 @@ discard block |
||
43 | 43 | /** |
44 | 44 | * @return array |
45 | 45 | */ |
46 | - protected function filter(array $values = []) |
|
46 | + protected function filter( array $values = [] ) |
|
47 | 47 | { |
48 | - return $this->normalize($this->merge(array_filter($values)), $values); |
|
48 | + return $this->normalize( $this->merge( array_filter( $values ) ), $values ); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @return string |
53 | 53 | */ |
54 | - protected function filteredJson(array $values = []) |
|
54 | + protected function filteredJson( array $values = [] ) |
|
55 | 55 | { |
56 | 56 | $defaults = $this->flattenArray( |
57 | - array_diff_key($this->defaults(), array_flip($this->guarded)) |
|
57 | + array_diff_key( $this->defaults(), array_flip( $this->guarded ) ) |
|
58 | 58 | ); |
59 | 59 | $values = $this->flattenArray( |
60 | - shortcode_atts($defaults, $values) |
|
60 | + shortcode_atts( $defaults, $values ) |
|
61 | 61 | ); |
62 | - $filtered = array_filter(array_diff_assoc($values, $defaults), function ($value) { |
|
63 | - return !$this->isEmpty($value); |
|
62 | + $filtered = array_filter( array_diff_assoc( $values, $defaults ), function( $value ) { |
|
63 | + return !$this->isEmpty( $value ); |
|
64 | 64 | }); |
65 | - return json_encode($filtered, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); |
|
65 | + return json_encode( $filtered, JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @return array |
70 | 70 | */ |
71 | - protected function flattenArray(array $values) |
|
71 | + protected function flattenArray( array $values ) |
|
72 | 72 | { |
73 | - array_walk($values, function (&$value) { |
|
74 | - if (!is_array($value)) { |
|
73 | + array_walk( $values, function( &$value ) { |
|
74 | + if( !is_array( $value ) ) { |
|
75 | 75 | return; |
76 | 76 | } |
77 | - $value = implode(',', $value); |
|
77 | + $value = implode( ',', $value ); |
|
78 | 78 | }); |
79 | 79 | return $values; |
80 | 80 | } |
@@ -83,34 +83,34 @@ discard block |
||
83 | 83 | * @param mixed $var |
84 | 84 | * @return bool |
85 | 85 | */ |
86 | - protected function isEmpty($var) |
|
86 | + protected function isEmpty( $var ) |
|
87 | 87 | { |
88 | - return !is_numeric($var) && !is_bool($var) && empty($var); |
|
88 | + return !is_numeric( $var ) && !is_bool( $var ) && empty($var); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
92 | 92 | * @return array |
93 | 93 | */ |
94 | - protected function merge(array $values = []) |
|
94 | + protected function merge( array $values = [] ) |
|
95 | 95 | { |
96 | - return $this->normalize(wp_parse_args($values, $this->defaults()), $values); |
|
96 | + return $this->normalize( wp_parse_args( $values, $this->defaults() ), $values ); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
100 | 100 | * @return array |
101 | 101 | */ |
102 | - protected function normalize(array $values, array $originalValues) |
|
102 | + protected function normalize( array $values, array $originalValues ) |
|
103 | 103 | { |
104 | - $values['json'] = $this->filteredJson($originalValues); |
|
104 | + $values['json'] = $this->filteredJson( $originalValues ); |
|
105 | 105 | return $values; |
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
109 | 109 | * @return array |
110 | 110 | */ |
111 | - protected function restrict(array $values = []) |
|
111 | + protected function restrict( array $values = [] ) |
|
112 | 112 | { |
113 | - return $this->normalize(shortcode_atts($this->defaults(), $values), $values); |
|
113 | + return $this->normalize( shortcode_atts( $this->defaults(), $values ), $values ); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -118,6 +118,6 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected function unguarded() |
120 | 120 | { |
121 | - return array_diff_key($this->defaults(), array_flip($this->guarded)); |
|
121 | + return array_diff_key( $this->defaults(), array_flip( $this->guarded ) ); |
|
122 | 122 | } |
123 | 123 | } |
@@ -7,41 +7,41 @@ |
||
7 | 7 | |
8 | 8 | class CreateReviewDefaults extends Defaults |
9 | 9 | { |
10 | - /** |
|
11 | - * @var array |
|
12 | - */ |
|
13 | - protected $guarded = [ |
|
14 | - 'assigned_to', |
|
15 | - 'content', |
|
16 | - 'date', |
|
17 | - 'pinned', |
|
18 | - 'response', |
|
19 | - 'review_id', |
|
20 | - 'review_type', |
|
21 | - 'title', |
|
22 | - ]; |
|
10 | + /** |
|
11 | + * @var array |
|
12 | + */ |
|
13 | + protected $guarded = [ |
|
14 | + 'assigned_to', |
|
15 | + 'content', |
|
16 | + 'date', |
|
17 | + 'pinned', |
|
18 | + 'response', |
|
19 | + 'review_id', |
|
20 | + 'review_type', |
|
21 | + 'title', |
|
22 | + ]; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @return array |
|
26 | - */ |
|
27 | - protected function defaults() |
|
28 | - { |
|
29 | - return [ |
|
30 | - 'assigned_to' => '', |
|
31 | - 'author' => '', |
|
32 | - 'avatar' => '', |
|
33 | - 'content' => '', |
|
34 | - 'custom' => '', |
|
35 | - 'date' => current_time('mysql'), |
|
36 | - 'email' => '', |
|
37 | - 'ip_address' => Helper::getIpAddress(), |
|
38 | - 'pinned' => false, |
|
39 | - 'rating' => '', |
|
40 | - 'response' => '', |
|
41 | - 'review_id' => md5(time().mt_rand()), |
|
42 | - 'review_type' => 'local', |
|
43 | - 'title' => '', |
|
44 | - 'url' => '', |
|
45 | - ]; |
|
46 | - } |
|
24 | + /** |
|
25 | + * @return array |
|
26 | + */ |
|
27 | + protected function defaults() |
|
28 | + { |
|
29 | + return [ |
|
30 | + 'assigned_to' => '', |
|
31 | + 'author' => '', |
|
32 | + 'avatar' => '', |
|
33 | + 'content' => '', |
|
34 | + 'custom' => '', |
|
35 | + 'date' => current_time('mysql'), |
|
36 | + 'email' => '', |
|
37 | + 'ip_address' => Helper::getIpAddress(), |
|
38 | + 'pinned' => false, |
|
39 | + 'rating' => '', |
|
40 | + 'response' => '', |
|
41 | + 'review_id' => md5(time().mt_rand()), |
|
42 | + 'review_type' => 'local', |
|
43 | + 'title' => '', |
|
44 | + 'url' => '', |
|
45 | + ]; |
|
46 | + } |
|
47 | 47 | } |
@@ -32,13 +32,13 @@ |
||
32 | 32 | 'avatar' => '', |
33 | 33 | 'content' => '', |
34 | 34 | 'custom' => '', |
35 | - 'date' => current_time('mysql'), |
|
35 | + 'date' => current_time( 'mysql' ), |
|
36 | 36 | 'email' => '', |
37 | 37 | 'ip_address' => Helper::getIpAddress(), |
38 | 38 | 'pinned' => false, |
39 | 39 | 'rating' => '', |
40 | 40 | 'response' => '', |
41 | - 'review_id' => md5(time().mt_rand()), |
|
41 | + 'review_id' => md5( time().mt_rand() ), |
|
42 | 42 | 'review_type' => 'local', |
43 | 43 | 'title' => '', |
44 | 44 | 'url' => '', |