@@ -10,17 +10,17 @@ discard block |
||
10 | 10 | * @param string $partialPath |
11 | 11 | * @return string |
12 | 12 | */ |
13 | - public function build($partialPath, array $args = []) |
|
13 | + public function build( $partialPath, array $args = [] ) |
|
14 | 14 | { |
15 | - $className = Helper::buildClassName($partialPath, 'Modules\Html\Partials'); |
|
16 | - if (!class_exists($className)) { |
|
17 | - glsr_log()->error('Partial missing: '.$className); |
|
15 | + $className = Helper::buildClassName( $partialPath, 'Modules\Html\Partials' ); |
|
16 | + if( !class_exists( $className ) ) { |
|
17 | + glsr_log()->error( 'Partial missing: '.$className ); |
|
18 | 18 | return; |
19 | 19 | } |
20 | - $args = apply_filters('site-reviews/partial/args/'.$partialPath, $args); |
|
21 | - $partial = glsr($className)->build($args); |
|
22 | - $partial = apply_filters('site-reviews/rendered/partial', $partial, $partialPath, $args); |
|
23 | - $partial = apply_filters('site-reviews/rendered/partial/'.$partialPath, $partial, $args); |
|
20 | + $args = apply_filters( 'site-reviews/partial/args/'.$partialPath, $args ); |
|
21 | + $partial = glsr( $className )->build( $args ); |
|
22 | + $partial = apply_filters( 'site-reviews/rendered/partial', $partial, $partialPath, $args ); |
|
23 | + $partial = apply_filters( 'site-reviews/rendered/partial/'.$partialPath, $partial, $args ); |
|
24 | 24 | return $partial; |
25 | 25 | } |
26 | 26 | |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | * @param string $partialPath |
29 | 29 | * @return void |
30 | 30 | */ |
31 | - public function render($partialPath, array $args = []) |
|
31 | + public function render( $partialPath, array $args = [] ) |
|
32 | 32 | { |
33 | - echo $this->build($partialPath, $args); |
|
33 | + echo $this->build( $partialPath, $args ); |
|
34 | 34 | } |
35 | 35 | } |
@@ -11,29 +11,29 @@ |
||
11 | 11 | * @param int $postId |
12 | 12 | * @return void |
13 | 13 | */ |
14 | - public function saveAssignedToMetabox($postId) |
|
14 | + public function saveAssignedToMetabox( $postId ) |
|
15 | 15 | { |
16 | - if (!wp_verify_nonce(Helper::filterInput('_nonce-assigned-to'), 'assigned_to')) { |
|
16 | + if( !wp_verify_nonce( Helper::filterInput( '_nonce-assigned-to' ), 'assigned_to' ) ) { |
|
17 | 17 | return; |
18 | 18 | } |
19 | - $assignedTo = strval(Helper::filterInput('assigned_to')); |
|
20 | - glsr(Database::class)->update($postId, 'assigned_to', $assignedTo); |
|
19 | + $assignedTo = strval( Helper::filterInput( 'assigned_to' ) ); |
|
20 | + glsr( Database::class )->update( $postId, 'assigned_to', $assignedTo ); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @param int $postId |
25 | 25 | * @return mixed |
26 | 26 | */ |
27 | - public function saveResponseMetabox($postId) |
|
27 | + public function saveResponseMetabox( $postId ) |
|
28 | 28 | { |
29 | - if (!wp_verify_nonce(Helper::filterInput('_nonce-response'), 'response')) { |
|
29 | + if( !wp_verify_nonce( Helper::filterInput( '_nonce-response' ), 'response' ) ) { |
|
30 | 30 | return; |
31 | 31 | } |
32 | - $response = strval(Helper::filterInput('response')); |
|
33 | - glsr(Database::class)->update($postId, 'response', trim(wp_kses($response, [ |
|
32 | + $response = strval( Helper::filterInput( 'response' ) ); |
|
33 | + glsr( Database::class )->update( $postId, 'response', trim( wp_kses( $response, [ |
|
34 | 34 | 'a' => ['href' => [], 'title' => []], |
35 | 35 | 'em' => [], |
36 | 36 | 'strong' => [], |
37 | - ]))); |
|
37 | + ] ) ) ); |
|
38 | 38 | } |
39 | 39 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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'] = ''; |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | public $postType; |
16 | 16 | public $single; |
17 | 17 | |
18 | - public function __construct($input) |
|
18 | + public function __construct( $input ) |
|
19 | 19 | { |
20 | - $args = glsr(PostTypeDefaults::class)->merge($input); |
|
21 | - $this->normalize($args); |
|
20 | + $args = glsr( PostTypeDefaults::class )->merge( $input ); |
|
21 | + $this->normalize( $args ); |
|
22 | 22 | $this->normalizeColumns(); |
23 | 23 | $this->normalizeLabels(); |
24 | 24 | } |
@@ -26,19 +26,19 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * @return void |
28 | 28 | */ |
29 | - protected function normalize(array $args) |
|
29 | + protected function normalize( array $args ) |
|
30 | 30 | { |
31 | - foreach ($args as $key => $value) { |
|
32 | - $property = Helper::buildPropertyName($key); |
|
33 | - if (!property_exists($this, $property)) { |
|
31 | + foreach( $args as $key => $value ) { |
|
32 | + $property = Helper::buildPropertyName( $key ); |
|
33 | + if( !property_exists( $this, $property ) ) { |
|
34 | 34 | continue; |
35 | 35 | } |
36 | 36 | $this->$property = $value; |
37 | 37 | unset($args[$key]); |
38 | 38 | } |
39 | - $this->args = wp_parse_args($args, [ |
|
39 | + $this->args = wp_parse_args( $args, [ |
|
40 | 40 | 'menu_name' => $this->plural, |
41 | - ]); |
|
41 | + ] ); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -46,22 +46,22 @@ discard block |
||
46 | 46 | */ |
47 | 47 | protected function normalizeLabels() |
48 | 48 | { |
49 | - $this->args['labels'] = wp_parse_args($this->args['labels'], [ |
|
50 | - 'add_new_item' => sprintf(_x('Add New %s', 'Add New Post', 'site-reviews'), $this->plural), |
|
51 | - 'all_items' => sprintf(_x('All %s', 'All Posts', 'site-reviews'), $this->plural), |
|
52 | - 'archives' => sprintf(_x('%s Archives', 'Post Archives', 'site-reviews'), $this->single), |
|
53 | - 'edit_item' => sprintf(_x('Edit %s', 'Edit Post', 'site-reviews'), $this->single), |
|
54 | - 'insert_into_item' => sprintf(_x('Insert into %s', 'Insert into Post', 'site-reviews'), $this->single), |
|
49 | + $this->args['labels'] = wp_parse_args( $this->args['labels'], [ |
|
50 | + 'add_new_item' => sprintf( _x( 'Add New %s', 'Add New Post', 'site-reviews' ), $this->plural ), |
|
51 | + 'all_items' => sprintf( _x( 'All %s', 'All Posts', 'site-reviews' ), $this->plural ), |
|
52 | + 'archives' => sprintf( _x( '%s Archives', 'Post Archives', 'site-reviews' ), $this->single ), |
|
53 | + 'edit_item' => sprintf( _x( 'Edit %s', 'Edit Post', 'site-reviews' ), $this->single ), |
|
54 | + 'insert_into_item' => sprintf( _x( 'Insert into %s', 'Insert into Post', 'site-reviews' ), $this->single ), |
|
55 | 55 | 'menu_name' => $this->args['menu_name'], |
56 | 56 | 'name' => $this->plural, |
57 | - 'new_item' => sprintf(_x('New %s', 'New Post', 'site-reviews'), $this->single), |
|
58 | - 'not_found' => sprintf(_x('No %s found', 'No Posts found', 'site-reviews'), $this->plural), |
|
59 | - 'not_found_in_trash' => sprintf(_x('No %s found in Trash', 'No Posts found in Trash', 'site-reviews'), $this->plural), |
|
60 | - 'search_items' => sprintf(_x('Search %s', 'Search Posts', 'site-reviews'), $this->plural), |
|
57 | + 'new_item' => sprintf( _x( 'New %s', 'New Post', 'site-reviews' ), $this->single ), |
|
58 | + 'not_found' => sprintf( _x( 'No %s found', 'No Posts found', 'site-reviews' ), $this->plural ), |
|
59 | + 'not_found_in_trash' => sprintf( _x( 'No %s found in Trash', 'No Posts found in Trash', 'site-reviews' ), $this->plural ), |
|
60 | + 'search_items' => sprintf( _x( 'Search %s', 'Search Posts', 'site-reviews' ), $this->plural ), |
|
61 | 61 | 'singular_name' => $this->single, |
62 | - 'uploaded_to_this_item' => sprintf(_x('Uploaded to this %s', 'Uploaded to this Post', 'site-reviews'), $this->single), |
|
63 | - 'view_item' => sprintf(_x('View %s', 'View Post', 'site-reviews'), $this->single), |
|
64 | - ]); |
|
62 | + 'uploaded_to_this_item' => sprintf( _x( 'Uploaded to this %s', 'Uploaded to this Post', 'site-reviews' ), $this->single ), |
|
63 | + 'view_item' => sprintf( _x( 'View %s', 'View Post', 'site-reviews' ), $this->single ), |
|
64 | + ] ); |
|
65 | 65 | unset($this->args['menu_name']); |
66 | 66 | } |
67 | 67 | |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | protected function normalizeColumns() |
72 | 72 | { |
73 | 73 | $this->columns = ['cb' => ''] + $this->columns; |
74 | - if (array_key_exists('category', $this->columns)) { |
|
75 | - $keys = array_keys($this->columns); |
|
76 | - $keys[array_search('category', $keys)] = 'taxonomy-'.Application::TAXONOMY; |
|
77 | - $this->columns = array_combine($keys, $this->columns); |
|
74 | + if( array_key_exists( 'category', $this->columns ) ) { |
|
75 | + $keys = array_keys( $this->columns ); |
|
76 | + $keys[array_search( 'category', $keys )] = 'taxonomy-'.Application::TAXONOMY; |
|
77 | + $this->columns = array_combine( $keys, $this->columns ); |
|
78 | 78 | } |
79 | - if (array_key_exists('pinned', $this->columns)) { |
|
80 | - $this->columns['pinned'] = glsr(Builder::class)->span('<span>'.$this->columns['pinned'].'</span>', |
|
79 | + if( array_key_exists( 'pinned', $this->columns ) ) { |
|
80 | + $this->columns['pinned'] = glsr( Builder::class )->span( '<span>'.$this->columns['pinned'].'</span>', |
|
81 | 81 | ['class' => 'pinned-icon'] |
82 | 82 | ); |
83 | 83 | } |
@@ -14,10 +14,10 @@ discard block |
||
14 | 14 | |
15 | 15 | public function __construct() |
16 | 16 | { |
17 | - $this->unguardedActions = apply_filters('site-reviews/router/unguarded-actions', [ |
|
17 | + $this->unguardedActions = apply_filters( 'site-reviews/router/unguarded-actions', [ |
|
18 | 18 | 'dismiss-notice', |
19 | 19 | 'fetch-paged-reviews', |
20 | - ]); |
|
20 | + ] ); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | public function routeAdminPostRequest() |
27 | 27 | { |
28 | 28 | $request = $this->getRequest(); |
29 | - if (!$this->isValidPostRequest($request)) { |
|
29 | + if( !$this->isValidPostRequest( $request ) ) { |
|
30 | 30 | return; |
31 | 31 | } |
32 | - check_admin_referer($request['_action']); |
|
33 | - $this->routeRequest('admin', $request['_action'], $request); |
|
32 | + check_admin_referer( $request['_action'] ); |
|
33 | + $this->routeRequest( 'admin', $request['_action'], $request ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | public function routeAjaxRequest() |
40 | 40 | { |
41 | 41 | $request = $this->getRequest(); |
42 | - $this->checkAjaxRequest($request); |
|
43 | - $this->checkAjaxNonce($request); |
|
44 | - $this->routeRequest('ajax', $request['_action'], $request); |
|
42 | + $this->checkAjaxRequest( $request ); |
|
43 | + $this->checkAjaxNonce( $request ); |
|
44 | + $this->routeRequest( 'ajax', $request['_action'], $request ); |
|
45 | 45 | wp_die(); |
46 | 46 | } |
47 | 47 | |
@@ -50,45 +50,45 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function routePublicPostRequest() |
52 | 52 | { |
53 | - if (is_admin()) { |
|
53 | + if( is_admin() ) { |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | $request = $this->getRequest(); |
57 | - if (!$this->isValidPostRequest($request)) { |
|
57 | + if( !$this->isValidPostRequest( $request ) ) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | - if (!$this->isValidPublicNonce($request)) { |
|
60 | + if( !$this->isValidPublicNonce( $request ) ) { |
|
61 | 61 | return; |
62 | 62 | } |
63 | - $this->routeRequest('public', $request['_action'], $request); |
|
63 | + $this->routeRequest( 'public', $request['_action'], $request ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * @return void |
68 | 68 | */ |
69 | - protected function checkAjaxNonce(array $request) |
|
69 | + protected function checkAjaxNonce( array $request ) |
|
70 | 70 | { |
71 | - if (!is_user_logged_in() || in_array(Arr::get($request, '_action'), $this->unguardedActions)) { |
|
71 | + if( !is_user_logged_in() || in_array( Arr::get( $request, '_action' ), $this->unguardedActions ) ) { |
|
72 | 72 | return; |
73 | 73 | } |
74 | - if (!isset($request['_nonce'])) { |
|
75 | - $this->sendAjaxError('request is missing a nonce', $request); |
|
74 | + if( !isset($request['_nonce']) ) { |
|
75 | + $this->sendAjaxError( 'request is missing a nonce', $request ); |
|
76 | 76 | } |
77 | - if (!wp_verify_nonce($request['_nonce'], $request['_action'])) { |
|
78 | - $this->sendAjaxError('request failed the nonce check', $request, 403); |
|
77 | + if( !wp_verify_nonce( $request['_nonce'], $request['_action'] ) ) { |
|
78 | + $this->sendAjaxError( 'request failed the nonce check', $request, 403 ); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | 83 | * @return void |
84 | 84 | */ |
85 | - protected function checkAjaxRequest(array $request) |
|
85 | + protected function checkAjaxRequest( array $request ) |
|
86 | 86 | { |
87 | - if (!isset($request['_action'])) { |
|
88 | - $this->sendAjaxError('request must include an action', $request); |
|
87 | + if( !isset($request['_action']) ) { |
|
88 | + $this->sendAjaxError( 'request must include an action', $request ); |
|
89 | 89 | } |
90 | - if (empty($request['_ajax_request'])) { |
|
91 | - $this->sendAjaxError('request is invalid', $request); |
|
90 | + if( empty($request['_ajax_request']) ) { |
|
91 | + $this->sendAjaxError( 'request is invalid', $request ); |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | */ |
100 | 100 | protected function getRequest() |
101 | 101 | { |
102 | - $request = Helper::filterInputArray(Application::ID); |
|
103 | - if (Helper::filterInput('action') == Application::PREFIX.'action') { |
|
102 | + $request = Helper::filterInputArray( Application::ID ); |
|
103 | + if( Helper::filterInput( 'action' ) == Application::PREFIX.'action' ) { |
|
104 | 104 | $request['_ajax_request'] = true; |
105 | 105 | } |
106 | - if ('submit-review' == Helper::filterInput('_action', $request)) { |
|
107 | - $request['_recaptcha-token'] = Helper::filterInput('g-recaptcha-response'); |
|
106 | + if( 'submit-review' == Helper::filterInput( '_action', $request ) ) { |
|
107 | + $request['_recaptcha-token'] = Helper::filterInput( 'g-recaptcha-response' ); |
|
108 | 108 | } |
109 | 109 | return $request; |
110 | 110 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | /** |
113 | 113 | * @return bool |
114 | 114 | */ |
115 | - protected function isValidPostRequest(array $request = []) |
|
115 | + protected function isValidPostRequest( array $request = [] ) |
|
116 | 116 | { |
117 | 117 | return !empty($request['_action']) && empty($request['_ajax_request']); |
118 | 118 | } |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | /** |
121 | 121 | * @return bool |
122 | 122 | */ |
123 | - protected function isValidPublicNonce(array $request) |
|
123 | + protected function isValidPublicNonce( array $request ) |
|
124 | 124 | { |
125 | - if (is_user_logged_in() && !wp_verify_nonce($request['_nonce'], $request['_action'])) { |
|
126 | - glsr_log()->error('nonce check failed for public request')->debug($request); |
|
125 | + if( is_user_logged_in() && !wp_verify_nonce( $request['_nonce'], $request['_action'] ) ) { |
|
126 | + glsr_log()->error( 'nonce check failed for public request' )->debug( $request ); |
|
127 | 127 | return false; |
128 | 128 | } |
129 | 129 | return true; |
@@ -134,19 +134,19 @@ discard block |
||
134 | 134 | * @param string $action |
135 | 135 | * @return void |
136 | 136 | */ |
137 | - protected function routeRequest($type, $action, array $request = []) |
|
137 | + protected function routeRequest( $type, $action, array $request = [] ) |
|
138 | 138 | { |
139 | 139 | $actionHook = 'site-reviews/route/'.$type.'/request'; |
140 | - $controller = glsr(Helper::buildClassName($type.'-controller', 'Controllers')); |
|
141 | - $method = Helper::buildMethodName($action, 'router'); |
|
142 | - $request = apply_filters('site-reviews/route/request', $request, $action, $type); |
|
143 | - do_action($actionHook, $action, $request); |
|
144 | - if (is_callable([$controller, $method])) { |
|
145 | - call_user_func([$controller, $method], $request); |
|
140 | + $controller = glsr( Helper::buildClassName( $type.'-controller', 'Controllers' ) ); |
|
141 | + $method = Helper::buildMethodName( $action, 'router' ); |
|
142 | + $request = apply_filters( 'site-reviews/route/request', $request, $action, $type ); |
|
143 | + do_action( $actionHook, $action, $request ); |
|
144 | + if( is_callable( [$controller, $method] ) ) { |
|
145 | + call_user_func( [$controller, $method], $request ); |
|
146 | 146 | return; |
147 | 147 | } |
148 | - if (0 === did_action($actionHook)) { |
|
149 | - glsr_log('Unknown '.$type.' router request: '.$action); |
|
148 | + if( 0 === did_action( $actionHook ) ) { |
|
149 | + glsr_log( 'Unknown '.$type.' router request: '.$action ); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
@@ -155,14 +155,14 @@ discard block |
||
155 | 155 | * @param int $statusCode |
156 | 156 | * @return void |
157 | 157 | */ |
158 | - protected function sendAjaxError($error, array $request, $statusCode = 400) |
|
158 | + protected function sendAjaxError( $error, array $request, $statusCode = 400 ) |
|
159 | 159 | { |
160 | - glsr_log()->error($error)->debug($request); |
|
161 | - glsr(Notice::class)->addError(__('There was an error (try reloading the page).', 'site-reviews').' <code>'.$error.'</code>'); |
|
162 | - wp_send_json_error([ |
|
163 | - 'message' => __('The form could not be submitted. Please notify the site administrator.', 'site-reviews'), |
|
164 | - 'notices' => glsr(Notice::class)->get(), |
|
160 | + glsr_log()->error( $error )->debug( $request ); |
|
161 | + glsr( Notice::class )->addError( __( 'There was an error (try reloading the page).', 'site-reviews' ).' <code>'.$error.'</code>' ); |
|
162 | + wp_send_json_error( [ |
|
163 | + 'message' => __( 'The form could not be submitted. Please notify the site administrator.', 'site-reviews' ), |
|
164 | + 'notices' => glsr( Notice::class )->get(), |
|
165 | 165 | 'error' => $error, |
166 | - ]); |
|
166 | + ] ); |
|
167 | 167 | } |
168 | 168 | } |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function renderTaxonomyFilter() |
38 | 38 | { |
39 | - if (!is_object_in_taxonomy(glsr_current_screen()->post_type, Application::TAXONOMY)) { |
|
39 | + if( !is_object_in_taxonomy( glsr_current_screen()->post_type, Application::TAXONOMY ) ) { |
|
40 | 40 | return; |
41 | 41 | } |
42 | - echo glsr(Builder::class)->label(__('Filter by category', 'site-reviews'), [ |
|
42 | + echo glsr( Builder::class )->label( __( 'Filter by category', 'site-reviews' ), [ |
|
43 | 43 | 'class' => 'screen-reader-text', |
44 | 44 | 'for' => Application::TAXONOMY, |
45 | - ]); |
|
46 | - wp_dropdown_categories([ |
|
45 | + ] ); |
|
46 | + wp_dropdown_categories( [ |
|
47 | 47 | 'depth' => 3, |
48 | 48 | 'hide_empty' => true, |
49 | 49 | 'hide_if_empty' => true, |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | 'show_option_all' => $this->getShowOptionAll(), |
56 | 56 | 'taxonomy' => Application::TAXONOMY, |
57 | 57 | 'value_field' => 'slug', |
58 | - ]); |
|
58 | + ] ); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -68,17 +68,17 @@ discard block |
||
68 | 68 | * @return void |
69 | 69 | * @action set_object_terms |
70 | 70 | */ |
71 | - public function restrictTermSelection($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds) |
|
71 | + public function restrictTermSelection( $postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds ) |
|
72 | 72 | { |
73 | - if (Application::TAXONOMY != $taxonomy || count($newTTIds) <= 1) { |
|
73 | + if( Application::TAXONOMY != $taxonomy || count( $newTTIds ) <= 1 ) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | - $diff = array_diff($newTTIds, $oldTTIds); |
|
77 | - if (empty($newTerm = array_shift($diff))) { |
|
78 | - $newTerm = array_shift($newTTIds); |
|
76 | + $diff = array_diff( $newTTIds, $oldTTIds ); |
|
77 | + if( empty($newTerm = array_shift( $diff )) ) { |
|
78 | + $newTerm = array_shift( $newTTIds ); |
|
79 | 79 | } |
80 | - if ($newTerm) { |
|
81 | - wp_set_object_terms($postId, intval($newTerm), $taxonomy); |
|
80 | + if( $newTerm ) { |
|
81 | + wp_set_object_terms( $postId, intval( $newTerm ), $taxonomy ); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | protected function getSelected() |
89 | 89 | { |
90 | 90 | global $wp_query; |
91 | - return Arr::get($wp_query->query, Application::TAXONOMY); |
|
91 | + return Arr::get( $wp_query->query, Application::TAXONOMY ); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected function getShowOptionAll() |
98 | 98 | { |
99 | - $taxonomy = get_taxonomy(Application::TAXONOMY); |
|
99 | + $taxonomy = get_taxonomy( Application::TAXONOMY ); |
|
100 | 100 | return $taxonomy |
101 | - ? ucfirst(strtolower($taxonomy->labels->all_items)) |
|
101 | + ? ucfirst( strtolower( $taxonomy->labels->all_items ) ) |
|
102 | 102 | : ''; |
103 | 103 | } |
104 | 104 | } |