@@ -8,85 +8,85 @@ |
||
8 | 8 | |
9 | 9 | class BlocksController extends Controller |
10 | 10 | { |
11 | - /** |
|
12 | - * @param array $categories |
|
13 | - * @return array |
|
14 | - * @filter block_categories |
|
15 | - */ |
|
16 | - public function filterBlockCategories($categories) |
|
17 | - { |
|
18 | - $categories = Arr::consolidateArray($categories); |
|
19 | - $categories[] = [ |
|
20 | - 'icon' => null, |
|
21 | - 'slug' => Application::ID, |
|
22 | - 'title' => glsr()->name, |
|
23 | - ]; |
|
24 | - return $categories; |
|
25 | - } |
|
11 | + /** |
|
12 | + * @param array $categories |
|
13 | + * @return array |
|
14 | + * @filter block_categories |
|
15 | + */ |
|
16 | + public function filterBlockCategories($categories) |
|
17 | + { |
|
18 | + $categories = Arr::consolidateArray($categories); |
|
19 | + $categories[] = [ |
|
20 | + 'icon' => null, |
|
21 | + 'slug' => Application::ID, |
|
22 | + 'title' => glsr()->name, |
|
23 | + ]; |
|
24 | + return $categories; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * @param array $editors |
|
29 | - * @param string $postType |
|
30 | - * @return array |
|
31 | - * @filter classic_editor_enabled_editors_for_post_type |
|
32 | - * @plugin classic-editor/classic-editor.php |
|
33 | - */ |
|
34 | - public function filterEnabledEditors($editors, $postType) |
|
35 | - { |
|
36 | - return Application::POST_TYPE == $postType |
|
37 | - ? ['block_editor' => false, 'classic_editor' => false] |
|
38 | - : $editors; |
|
39 | - } |
|
27 | + /** |
|
28 | + * @param array $editors |
|
29 | + * @param string $postType |
|
30 | + * @return array |
|
31 | + * @filter classic_editor_enabled_editors_for_post_type |
|
32 | + * @plugin classic-editor/classic-editor.php |
|
33 | + */ |
|
34 | + public function filterEnabledEditors($editors, $postType) |
|
35 | + { |
|
36 | + return Application::POST_TYPE == $postType |
|
37 | + ? ['block_editor' => false, 'classic_editor' => false] |
|
38 | + : $editors; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param bool $bool |
|
43 | - * @param string $postType |
|
44 | - * @return bool |
|
45 | - * @filter use_block_editor_for_post_type |
|
46 | - */ |
|
47 | - public function filterUseBlockEditor($bool, $postType) |
|
48 | - { |
|
49 | - return Application::POST_TYPE == $postType |
|
50 | - ? false |
|
51 | - : $bool; |
|
52 | - } |
|
41 | + /** |
|
42 | + * @param bool $bool |
|
43 | + * @param string $postType |
|
44 | + * @return bool |
|
45 | + * @filter use_block_editor_for_post_type |
|
46 | + */ |
|
47 | + public function filterUseBlockEditor($bool, $postType) |
|
48 | + { |
|
49 | + return Application::POST_TYPE == $postType |
|
50 | + ? false |
|
51 | + : $bool; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return void |
|
56 | - */ |
|
57 | - public function registerAssets() |
|
58 | - { |
|
59 | - wp_register_style( |
|
60 | - Application::ID.'/blocks', |
|
61 | - glsr()->url('assets/styles/'.Application::ID.'-blocks.css'), |
|
62 | - ['wp-edit-blocks'], |
|
63 | - glsr()->version |
|
64 | - ); |
|
65 | - wp_register_script( |
|
66 | - Application::ID.'/blocks', |
|
67 | - glsr()->url('assets/scripts/'.Application::ID.'-blocks.js'), |
|
68 | - ['wp-api-fetch', 'wp-blocks', 'wp-i18n', 'wp-editor', 'wp-element', Application::ID], |
|
69 | - glsr()->version |
|
70 | - ); |
|
71 | - } |
|
54 | + /** |
|
55 | + * @return void |
|
56 | + */ |
|
57 | + public function registerAssets() |
|
58 | + { |
|
59 | + wp_register_style( |
|
60 | + Application::ID.'/blocks', |
|
61 | + glsr()->url('assets/styles/'.Application::ID.'-blocks.css'), |
|
62 | + ['wp-edit-blocks'], |
|
63 | + glsr()->version |
|
64 | + ); |
|
65 | + wp_register_script( |
|
66 | + Application::ID.'/blocks', |
|
67 | + glsr()->url('assets/scripts/'.Application::ID.'-blocks.js'), |
|
68 | + ['wp-api-fetch', 'wp-blocks', 'wp-i18n', 'wp-editor', 'wp-element', Application::ID], |
|
69 | + glsr()->version |
|
70 | + ); |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @return void |
|
75 | - * @action init |
|
76 | - */ |
|
77 | - public function registerBlocks() |
|
78 | - { |
|
79 | - $blocks = [ |
|
80 | - 'form', 'reviews', 'summary', |
|
81 | - ]; |
|
82 | - foreach ($blocks as $block) { |
|
83 | - $id = str_replace('_reviews', '', Application::ID.'_'.$block); |
|
84 | - $blockClass = Helper::buildClassName($id.'-block', 'Blocks'); |
|
85 | - if (!class_exists($blockClass)) { |
|
86 | - glsr_log()->error(sprintf('Class missing (%s)', $blockClass)); |
|
87 | - continue; |
|
88 | - } |
|
89 | - glsr($blockClass)->register($block); |
|
90 | - } |
|
91 | - } |
|
73 | + /** |
|
74 | + * @return void |
|
75 | + * @action init |
|
76 | + */ |
|
77 | + public function registerBlocks() |
|
78 | + { |
|
79 | + $blocks = [ |
|
80 | + 'form', 'reviews', 'summary', |
|
81 | + ]; |
|
82 | + foreach ($blocks as $block) { |
|
83 | + $id = str_replace('_reviews', '', Application::ID.'_'.$block); |
|
84 | + $blockClass = Helper::buildClassName($id.'-block', 'Blocks'); |
|
85 | + if (!class_exists($blockClass)) { |
|
86 | + glsr_log()->error(sprintf('Class missing (%s)', $blockClass)); |
|
87 | + continue; |
|
88 | + } |
|
89 | + glsr($blockClass)->register($block); |
|
90 | + } |
|
91 | + } |
|
92 | 92 | } |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | * @return array |
14 | 14 | * @filter block_categories |
15 | 15 | */ |
16 | - public function filterBlockCategories($categories) |
|
16 | + public function filterBlockCategories( $categories ) |
|
17 | 17 | { |
18 | - $categories = Arr::consolidateArray($categories); |
|
18 | + $categories = Arr::consolidateArray( $categories ); |
|
19 | 19 | $categories[] = [ |
20 | 20 | 'icon' => null, |
21 | 21 | 'slug' => Application::ID, |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @filter classic_editor_enabled_editors_for_post_type |
32 | 32 | * @plugin classic-editor/classic-editor.php |
33 | 33 | */ |
34 | - public function filterEnabledEditors($editors, $postType) |
|
34 | + public function filterEnabledEditors( $editors, $postType ) |
|
35 | 35 | { |
36 | 36 | return Application::POST_TYPE == $postType |
37 | 37 | ? ['block_editor' => false, 'classic_editor' => false] |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @return bool |
45 | 45 | * @filter use_block_editor_for_post_type |
46 | 46 | */ |
47 | - public function filterUseBlockEditor($bool, $postType) |
|
47 | + public function filterUseBlockEditor( $bool, $postType ) |
|
48 | 48 | { |
49 | 49 | return Application::POST_TYPE == $postType |
50 | 50 | ? false |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | { |
59 | 59 | wp_register_style( |
60 | 60 | Application::ID.'/blocks', |
61 | - glsr()->url('assets/styles/'.Application::ID.'-blocks.css'), |
|
61 | + glsr()->url( 'assets/styles/'.Application::ID.'-blocks.css' ), |
|
62 | 62 | ['wp-edit-blocks'], |
63 | 63 | glsr()->version |
64 | 64 | ); |
65 | 65 | wp_register_script( |
66 | 66 | Application::ID.'/blocks', |
67 | - glsr()->url('assets/scripts/'.Application::ID.'-blocks.js'), |
|
67 | + glsr()->url( 'assets/scripts/'.Application::ID.'-blocks.js' ), |
|
68 | 68 | ['wp-api-fetch', 'wp-blocks', 'wp-i18n', 'wp-editor', 'wp-element', Application::ID], |
69 | 69 | glsr()->version |
70 | 70 | ); |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | $blocks = [ |
80 | 80 | 'form', 'reviews', 'summary', |
81 | 81 | ]; |
82 | - foreach ($blocks as $block) { |
|
83 | - $id = str_replace('_reviews', '', Application::ID.'_'.$block); |
|
84 | - $blockClass = Helper::buildClassName($id.'-block', 'Blocks'); |
|
85 | - if (!class_exists($blockClass)) { |
|
86 | - glsr_log()->error(sprintf('Class missing (%s)', $blockClass)); |
|
82 | + foreach( $blocks as $block ) { |
|
83 | + $id = str_replace( '_reviews', '', Application::ID.'_'.$block ); |
|
84 | + $blockClass = Helper::buildClassName( $id.'-block', 'Blocks' ); |
|
85 | + if( !class_exists( $blockClass ) ) { |
|
86 | + glsr_log()->error( sprintf( 'Class missing (%s)', $blockClass ) ); |
|
87 | 87 | continue; |
88 | 88 | } |
89 | - glsr($blockClass)->register($block); |
|
89 | + glsr( $blockClass )->register( $block ); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | } |
@@ -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 | } |
@@ -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,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' => '', |
@@ -6,60 +6,60 @@ |
||
6 | 6 | |
7 | 7 | class DefaultsManager |
8 | 8 | { |
9 | - /** |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - public function defaults() |
|
13 | - { |
|
14 | - $settings = $this->settings(); |
|
15 | - $defaults = (array) array_combine(array_keys($settings), glsr_array_column($settings, 'default')); |
|
16 | - return wp_parse_args($defaults, [ |
|
17 | - 'version' => '', |
|
18 | - 'version_upgraded_from' => '', |
|
19 | - ]); |
|
20 | - } |
|
9 | + /** |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + public function defaults() |
|
13 | + { |
|
14 | + $settings = $this->settings(); |
|
15 | + $defaults = (array) array_combine(array_keys($settings), glsr_array_column($settings, 'default')); |
|
16 | + return wp_parse_args($defaults, [ |
|
17 | + 'version' => '', |
|
18 | + 'version_upgraded_from' => '', |
|
19 | + ]); |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * @return array |
|
24 | - */ |
|
25 | - public function get() |
|
26 | - { |
|
27 | - return Arr::convertDotNotationArray($this->defaults()); |
|
28 | - } |
|
22 | + /** |
|
23 | + * @return array |
|
24 | + */ |
|
25 | + public function get() |
|
26 | + { |
|
27 | + return Arr::convertDotNotationArray($this->defaults()); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - public function set() |
|
34 | - { |
|
35 | - $settings = glsr(OptionManager::class)->all(); |
|
36 | - $currentSettings = Arr::removeEmptyArrayValues($settings); |
|
37 | - $defaultSettings = array_replace_recursive($this->get(), $currentSettings); |
|
38 | - $updatedSettings = array_replace_recursive($settings, $defaultSettings); |
|
39 | - update_option(OptionManager::databaseKey(), $updatedSettings); |
|
40 | - return $defaultSettings; |
|
41 | - } |
|
30 | + /** |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + public function set() |
|
34 | + { |
|
35 | + $settings = glsr(OptionManager::class)->all(); |
|
36 | + $currentSettings = Arr::removeEmptyArrayValues($settings); |
|
37 | + $defaultSettings = array_replace_recursive($this->get(), $currentSettings); |
|
38 | + $updatedSettings = array_replace_recursive($settings, $defaultSettings); |
|
39 | + update_option(OptionManager::databaseKey(), $updatedSettings); |
|
40 | + return $defaultSettings; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return array |
|
45 | - */ |
|
46 | - public function settings() |
|
47 | - { |
|
48 | - $settings = apply_filters('site-reviews/addon/settings', glsr()->config('settings')); |
|
49 | - return $this->normalize($settings); |
|
50 | - } |
|
43 | + /** |
|
44 | + * @return array |
|
45 | + */ |
|
46 | + public function settings() |
|
47 | + { |
|
48 | + $settings = apply_filters('site-reviews/addon/settings', glsr()->config('settings')); |
|
49 | + return $this->normalize($settings); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @return array |
|
54 | - */ |
|
55 | - protected function normalize(array $settings) |
|
56 | - { |
|
57 | - array_walk($settings, function (&$setting) { |
|
58 | - if (isset($setting['default'])) { |
|
59 | - return; |
|
60 | - } |
|
61 | - $setting['default'] = ''; |
|
62 | - }); |
|
63 | - return $settings; |
|
64 | - } |
|
52 | + /** |
|
53 | + * @return array |
|
54 | + */ |
|
55 | + protected function normalize(array $settings) |
|
56 | + { |
|
57 | + array_walk($settings, function (&$setting) { |
|
58 | + if (isset($setting['default'])) { |
|
59 | + return; |
|
60 | + } |
|
61 | + $setting['default'] = ''; |
|
62 | + }); |
|
63 | + return $settings; |
|
64 | + } |
|
65 | 65 | } |
@@ -12,11 +12,11 @@ discard block |
||
12 | 12 | public function defaults() |
13 | 13 | { |
14 | 14 | $settings = $this->settings(); |
15 | - $defaults = (array) array_combine(array_keys($settings), glsr_array_column($settings, 'default')); |
|
16 | - return wp_parse_args($defaults, [ |
|
15 | + $defaults = (array)array_combine( array_keys( $settings ), glsr_array_column( $settings, 'default' ) ); |
|
16 | + return wp_parse_args( $defaults, [ |
|
17 | 17 | 'version' => '', |
18 | 18 | 'version_upgraded_from' => '', |
19 | - ]); |
|
19 | + ] ); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function get() |
26 | 26 | { |
27 | - return Arr::convertDotNotationArray($this->defaults()); |
|
27 | + return Arr::convertDotNotationArray( $this->defaults() ); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function set() |
34 | 34 | { |
35 | - $settings = glsr(OptionManager::class)->all(); |
|
36 | - $currentSettings = Arr::removeEmptyArrayValues($settings); |
|
37 | - $defaultSettings = array_replace_recursive($this->get(), $currentSettings); |
|
38 | - $updatedSettings = array_replace_recursive($settings, $defaultSettings); |
|
39 | - update_option(OptionManager::databaseKey(), $updatedSettings); |
|
35 | + $settings = glsr( OptionManager::class )->all(); |
|
36 | + $currentSettings = Arr::removeEmptyArrayValues( $settings ); |
|
37 | + $defaultSettings = array_replace_recursive( $this->get(), $currentSettings ); |
|
38 | + $updatedSettings = array_replace_recursive( $settings, $defaultSettings ); |
|
39 | + update_option( OptionManager::databaseKey(), $updatedSettings ); |
|
40 | 40 | return $defaultSettings; |
41 | 41 | } |
42 | 42 | |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function settings() |
47 | 47 | { |
48 | - $settings = apply_filters('site-reviews/addon/settings', glsr()->config('settings')); |
|
49 | - return $this->normalize($settings); |
|
48 | + $settings = apply_filters( 'site-reviews/addon/settings', glsr()->config( 'settings' ) ); |
|
49 | + return $this->normalize( $settings ); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @return array |
54 | 54 | */ |
55 | - protected function normalize(array $settings) |
|
55 | + protected function normalize( array $settings ) |
|
56 | 56 | { |
57 | - array_walk($settings, function (&$setting) { |
|
58 | - if (isset($setting['default'])) { |
|
57 | + array_walk( $settings, function( &$setting ) { |
|
58 | + if( isset($setting['default']) ) { |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | $setting['default'] = ''; |