Passed
Push — master ( 4321c5...7f1e4d )
by Paul
07:58 queued 04:14
created
plugin/Controllers/SettingsController.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -14,17 +14,17 @@  discard block
 block discarded – undo
14 14
      * @return array
15 15
      * @callback register_setting
16 16
      */
17
-    public function callbackRegisterSettings($input)
17
+    public function callbackRegisterSettings( $input )
18 18
     {
19
-        $settings = Arr::consolidateArray($input);
20
-        if (1 === count($settings) && array_key_exists('settings', $settings)) {
21
-            $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input);
22
-            $options = $this->sanitizeGeneral($input, $options);
23
-            $options = $this->sanitizeSubmissions($input, $options);
24
-            $options = $this->sanitizeTranslations($input, $options);
25
-            $options = apply_filters('site-reviews/settings/callback', $options, $settings);
26
-            if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') {
27
-                glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews'));
19
+        $settings = Arr::consolidateArray( $input );
20
+        if( 1 === count( $settings ) && array_key_exists( 'settings', $settings ) ) {
21
+            $options = array_replace_recursive( glsr( OptionManager::class )->all(), $input );
22
+            $options = $this->sanitizeGeneral( $input, $options );
23
+            $options = $this->sanitizeSubmissions( $input, $options );
24
+            $options = $this->sanitizeTranslations( $input, $options );
25
+            $options = apply_filters( 'site-reviews/settings/callback', $options, $settings );
26
+            if( filter_input( INPUT_POST, 'option_page' ) == Application::ID.'-settings' ) {
27
+                glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) );
28 28
             }
29 29
             return $options;
30 30
         }
@@ -37,63 +37,63 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function registerSettings()
39 39
     {
40
-        register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [
40
+        register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [
41 41
             'sanitize_callback' => [$this, 'callbackRegisterSettings'],
42
-        ]);
42
+        ] );
43 43
     }
44 44
 
45 45
     /**
46 46
      * @return array
47 47
      */
48
-    protected function sanitizeGeneral(array $input, array $options)
48
+    protected function sanitizeGeneral( array $input, array $options )
49 49
     {
50 50
         $key = 'settings.general';
51
-        $inputForm = Arr::get($input, $key);
52
-        if (!$this->hasMultilingualIntegration(Arr::get($inputForm, 'multilingual'))) {
53
-            $options = Arr::set($options, $key.'.multilingual', '');
51
+        $inputForm = Arr::get( $input, $key );
52
+        if( !$this->hasMultilingualIntegration( Arr::get( $inputForm, 'multilingual' ) ) ) {
53
+            $options = Arr::set( $options, $key.'.multilingual', '' );
54 54
         }
55
-        if ('' == trim(Arr::get($inputForm, 'notification_message'))) {
56
-            $defaultValue = Arr::get(glsr()->defaults, $key.'.notification_message');
57
-            $options = Arr::set($options, $key.'.notification_message', $defaultValue);
55
+        if( '' == trim( Arr::get( $inputForm, 'notification_message' ) ) ) {
56
+            $defaultValue = Arr::get( glsr()->defaults, $key.'.notification_message' );
57
+            $options = Arr::set( $options, $key.'.notification_message', $defaultValue );
58 58
         }
59
-        $defaultValue = Arr::get($inputForm, 'notifications', []);
60
-        $options = Arr::set($options, $key.'.notifications', $defaultValue);
59
+        $defaultValue = Arr::get( $inputForm, 'notifications', [] );
60
+        $options = Arr::set( $options, $key.'.notifications', $defaultValue );
61 61
         return $options;
62 62
     }
63 63
 
64 64
     /**
65 65
      * @return array
66 66
      */
67
-    protected function sanitizeSubmissions(array $input, array $options)
67
+    protected function sanitizeSubmissions( array $input, array $options )
68 68
     {
69 69
         $key = 'settings.submissions';
70
-        $inputForm = Arr::get($input, $key);
70
+        $inputForm = Arr::get( $input, $key );
71 71
         $defaultValue = isset($inputForm['required'])
72 72
             ? $inputForm['required']
73 73
             : [];
74
-        $options = Arr::set($options, $key.'.required', $defaultValue);
74
+        $options = Arr::set( $options, $key.'.required', $defaultValue );
75 75
         return $options;
76 76
     }
77 77
 
78 78
     /**
79 79
      * @return array
80 80
      */
81
-    protected function sanitizeTranslations(array $input, array $options)
81
+    protected function sanitizeTranslations( array $input, array $options )
82 82
     {
83 83
         $key = 'settings.strings';
84
-        $inputForm = Arr::consolidateArray(Arr::get($input, $key));
85
-        if (!empty($inputForm)) {
86
-            $options = Arr::set($options, $key, array_values(array_filter($inputForm)));
84
+        $inputForm = Arr::consolidateArray( Arr::get( $input, $key ) );
85
+        if( !empty($inputForm) ) {
86
+            $options = Arr::set( $options, $key, array_values( array_filter( $inputForm ) ) );
87 87
             $allowedTags = [
88 88
                 'a' => ['class' => [], 'href' => [], 'target' => []],
89 89
                 'span' => ['class' => []],
90 90
             ];
91
-            array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) {
92
-                if (isset($string['s2'])) {
93
-                    $string['s2'] = wp_kses($string['s2'], $allowedTags);
91
+            array_walk( $options['settings']['strings'], function( &$string ) use ($allowedTags) {
92
+                if( isset($string['s2']) ) {
93
+                    $string['s2'] = wp_kses( $string['s2'], $allowedTags );
94 94
                 }
95
-                if (isset($string['p2'])) {
96
-                    $string['p2'] = wp_kses($string['p2'], $allowedTags);
95
+                if( isset($string['p2']) ) {
96
+                    $string['p2'] = wp_kses( $string['p2'], $allowedTags );
97 97
                 }
98 98
             });
99 99
         }
@@ -103,24 +103,24 @@  discard block
 block discarded – undo
103 103
     /**
104 104
      * @return bool
105 105
      */
106
-    protected function hasMultilingualIntegration($integration)
106
+    protected function hasMultilingualIntegration( $integration )
107 107
     {
108
-        if (!in_array($integration, ['polylang', 'wpml'])) {
108
+        if( !in_array( $integration, ['polylang', 'wpml'] ) ) {
109 109
             return false;
110 110
         }
111
-        $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst($integration);
112
-        if (!glsr($integrationClass)->isActive()) {
113
-            glsr(Notice::class)->addError(sprintf(
114
-                __('Please install/activate the %s plugin to enable integration.', 'site-reviews'),
115
-                constant($integrationClass.'::PLUGIN_NAME')
116
-            ));
111
+        $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst( $integration );
112
+        if( !glsr( $integrationClass )->isActive() ) {
113
+            glsr( Notice::class )->addError( sprintf(
114
+                __( 'Please install/activate the %s plugin to enable integration.', 'site-reviews' ),
115
+                constant( $integrationClass.'::PLUGIN_NAME' )
116
+            ) );
117 117
             return false;
118
-        } elseif (!glsr($integrationClass)->isSupported()) {
119
-            glsr(Notice::class)->addError(sprintf(
120
-                __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'),
121
-                constant($integrationClass.'::PLUGIN_NAME'),
122
-                constant($integrationClass.'::SUPPORTED_VERSION')
123
-            ));
118
+        } elseif( !glsr( $integrationClass )->isSupported() ) {
119
+            glsr( Notice::class )->addError( sprintf(
120
+                __( 'Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews' ),
121
+                constant( $integrationClass.'::PLUGIN_NAME' ),
122
+                constant( $integrationClass.'::SUPPORTED_VERSION' )
123
+            ) );
124 124
             return false;
125 125
         }
126 126
         return true;
Please login to merge, or discard this patch.
views/partials/editor/review.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <div id="titlediv">
4
-    <input type="text" id="title" value="<?= $post->post_title ? esc_attr($post->post_title) : sprintf('(%s)', __('no title', 'site-reviews')); ?>" readonly>
4
+    <input type="text" id="title" value="<?= $post->post_title ? esc_attr( $post->post_title ) : sprintf( '(%s)', __( 'no title', 'site-reviews' ) ); ?>" readonly>
5 5
 </div>
6 6
 
7 7
 <div id="contentdiv" class="wp-editor-container">
8
-    <textarea readonly><?= esc_attr($post->post_content); ?></textarea>
8
+    <textarea readonly><?= esc_attr( $post->post_content ); ?></textarea>
9 9
 </div>
10 10
 
11
-<?php if (empty($response)) {
11
+<?php if( empty($response) ) {
12 12
     return;
13 13
 } ?>
14 14
 
15 15
 <div class="postbox glsr-response-postbox">
16 16
     <button type="button" class="handlediv" aria-expanded="true">
17
-        <span class="screen-reader-text"><?= __('Toggle panel: Public Response', 'site-reviews'); ?></span>
17
+        <span class="screen-reader-text"><?= __( 'Toggle panel: Public Response', 'site-reviews' ); ?></span>
18 18
         <span class="toggle-indicator" aria-hidden="true"></span>
19 19
     </button>
20 20
     <h2 class="hndle">
21
-        <span><?= __('Public Response', 'site-reviews'); ?></span>
21
+        <span><?= __( 'Public Response', 'site-reviews' ); ?></span>
22 22
     </h2>
23 23
     <div class="inside">
24
-        <?= wpautop(esc_attr($response)); ?>
24
+        <?= wpautop( esc_attr( $response ) ); ?>
25 25
     </div>
26 26
 </div>
Please login to merge, or discard this patch.
views/pages/tools/console.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <textarea id="log-file" class="large-text code glsr-code glsr-code-large" rows="20" readonly>{{ console }}</textarea>
4 4
 <form method="post" class="glsr-float-left">
5 5
     <input type="hidden" name="{{ id }}[_action]" value="download-console">
6
-    <?php wp_nonce_field('download-console'); ?>
7
-    <?php submit_button(__('Download Console', 'site-reviews'), 'primary', '', false); ?>
6
+    <?php wp_nonce_field( 'download-console' ); ?>
7
+    <?php submit_button( __( 'Download Console', 'site-reviews' ), 'primary', '', false ); ?>
8 8
 </form>
9 9
 <form method="post" class="glsr-float-left">
10 10
     <input type="hidden" name="{{ id }}[_action]" value="fetch-console">
11
-    <?php wp_nonce_field('fetch-console'); ?>
11
+    <?php wp_nonce_field( 'fetch-console' ); ?>
12 12
     <button type="submit" class="glsr-button button" id="fetch-console">
13
-        <span data-loading="<?= __('Reloading...', 'site-reviews'); ?>"><?= __('Reload', 'site-reviews'); ?></span>
13
+        <span data-loading="<?= __( 'Reloading...', 'site-reviews' ); ?>"><?= __( 'Reload', 'site-reviews' ); ?></span>
14 14
     </button>
15 15
 </form>
16 16
 <form method="post">
17 17
     <input type="hidden" name="{{ id }}[_action]" value="clear-console">
18
-    <?php wp_nonce_field('clear-console'); ?>
18
+    <?php wp_nonce_field( 'clear-console' ); ?>
19 19
     <button type="submit" class="glsr-button button" id="clear-console">
20
-        <span data-loading="<?= __('Clearing...', 'site-reviews'); ?>"><?= __('Clear', 'site-reviews'); ?></span>
20
+        <span data-loading="<?= __( 'Clearing...', 'site-reviews' ); ?>"><?= __( 'Clear', 'site-reviews' ); ?></span>
21 21
     </button>
22 22
 </form>
Please login to merge, or discard this patch.
plugin/Handlers/EnqueueAdminAssets.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
     /**
19 19
      * @return void
20 20
      */
21
-    public function handle(Command $command)
21
+    public function handle( Command $command )
22 22
     {
23
-        $this->generatePointers($command->pointers);
23
+        $this->generatePointers( $command->pointers );
24 24
         $this->enqueueAssets();
25 25
         $this->localizeAssets();
26 26
     }
@@ -30,25 +30,25 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public function enqueueAssets()
32 32
     {
33
-        if (!$this->isCurrentScreen()) {
33
+        if( !$this->isCurrentScreen() ) {
34 34
             return;
35 35
         }
36 36
         wp_enqueue_style(
37 37
             Application::ID,
38
-            glsr()->url('assets/styles/'.Application::ID.'-admin.css'),
38
+            glsr()->url( 'assets/styles/'.Application::ID.'-admin.css' ),
39 39
             [],
40 40
             glsr()->version
41 41
         );
42 42
         wp_enqueue_script(
43 43
             Application::ID,
44
-            glsr()->url('assets/scripts/'.Application::ID.'-admin.js'),
44
+            glsr()->url( 'assets/scripts/'.Application::ID.'-admin.js' ),
45 45
             $this->getDependencies(),
46 46
             glsr()->version,
47 47
             true
48 48
         );
49
-        if (!empty($this->pointers)) {
50
-            wp_enqueue_style('wp-pointer');
51
-            wp_enqueue_script('wp-pointer');
49
+        if( !empty($this->pointers) ) {
50
+            wp_enqueue_style( 'wp-pointer' );
51
+            wp_enqueue_script( 'wp-pointer' );
52 52
         }
53 53
     }
54 54
 
@@ -60,33 +60,33 @@  discard block
 block discarded – undo
60 60
         $variables = [
61 61
             'action' => Application::PREFIX.'action',
62 62
             'addons' => [],
63
-            'ajaxurl' => admin_url('admin-ajax.php'),
63
+            'ajaxurl' => admin_url( 'admin-ajax.php' ),
64 64
             'hideoptions' => [
65
-                'site_reviews' => glsr(SiteReviewsShortcode::class)->getHideOptions(),
66
-                'site_reviews_form' => glsr(SiteReviewsFormShortcode::class)->getHideOptions(),
67
-                'site_reviews_summary' => glsr(SiteReviewsSummaryShortcode::class)->getHideOptions(),
65
+                'site_reviews' => glsr( SiteReviewsShortcode::class )->getHideOptions(),
66
+                'site_reviews_form' => glsr( SiteReviewsFormShortcode::class )->getHideOptions(),
67
+                'site_reviews_summary' => glsr( SiteReviewsSummaryShortcode::class )->getHideOptions(),
68 68
             ],
69 69
             'nameprefix' => Application::ID,
70 70
             'nonce' => [
71
-                'change-status' => wp_create_nonce('change-status'),
72
-                'clear-console' => wp_create_nonce('clear-console'),
73
-                'count-reviews' => wp_create_nonce('count-reviews'),
74
-                'fetch-console' => wp_create_nonce('fetch-console'),
75
-                'mce-shortcode' => wp_create_nonce('mce-shortcode'),
76
-                'sync-reviews' => wp_create_nonce('sync-reviews'),
77
-                'toggle-pinned' => wp_create_nonce('toggle-pinned'),
71
+                'change-status' => wp_create_nonce( 'change-status' ),
72
+                'clear-console' => wp_create_nonce( 'clear-console' ),
73
+                'count-reviews' => wp_create_nonce( 'count-reviews' ),
74
+                'fetch-console' => wp_create_nonce( 'fetch-console' ),
75
+                'mce-shortcode' => wp_create_nonce( 'mce-shortcode' ),
76
+                'sync-reviews' => wp_create_nonce( 'sync-reviews' ),
77
+                'toggle-pinned' => wp_create_nonce( 'toggle-pinned' ),
78 78
             ],
79 79
             'pointers' => $this->pointers,
80 80
             'shortcodes' => [],
81 81
             'tinymce' => [
82
-                'glsr_shortcode' => glsr()->url('assets/scripts/mce-plugin.js'),
82
+                'glsr_shortcode' => glsr()->url( 'assets/scripts/mce-plugin.js' ),
83 83
             ],
84 84
         ];
85
-        if (user_can_richedit()) {
85
+        if( user_can_richedit() ) {
86 86
             $variables['shortcodes'] = $this->localizeShortcodes();
87 87
         }
88
-        $variables = apply_filters('site-reviews/enqueue/admin/localize', $variables);
89
-        wp_localize_script(Application::ID, 'GLSR', $variables);
88
+        $variables = apply_filters( 'site-reviews/enqueue/admin/localize', $variables );
89
+        wp_localize_script( Application::ID, 'GLSR', $variables );
90 90
     }
91 91
 
92 92
     /**
@@ -94,17 +94,17 @@  discard block
 block discarded – undo
94 94
      */
95 95
     protected function getDependencies()
96 96
     {
97
-        $dependencies = apply_filters('site-reviews/enqueue/admin/dependencies', []);
98
-        $dependencies = array_merge($dependencies, [
97
+        $dependencies = apply_filters( 'site-reviews/enqueue/admin/dependencies', [] );
98
+        $dependencies = array_merge( $dependencies, [
99 99
             'jquery', 'jquery-ui-sortable', 'underscore', 'wp-util',
100
-        ]);
100
+        ] );
101 101
         return $dependencies;
102 102
     }
103 103
 
104 104
     /**
105 105
      * @return array
106 106
      */
107
-    protected function generatePointer(array $pointer)
107
+    protected function generatePointer( array $pointer )
108 108
     {
109 109
         return [
110 110
             'id' => $pointer['id'],
@@ -120,19 +120,19 @@  discard block
 block discarded – undo
120 120
     /**
121 121
      * @return void
122 122
      */
123
-    protected function generatePointers(array $pointers)
123
+    protected function generatePointers( array $pointers )
124 124
     {
125
-        $dismissedPointers = get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true);
126
-        $dismissedPointers = explode(',', (string) $dismissedPointers);
125
+        $dismissedPointers = get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true );
126
+        $dismissedPointers = explode( ',', (string)$dismissedPointers );
127 127
         $generatedPointers = [];
128
-        foreach ($pointers as $pointer) {
129
-            if ($pointer['screen'] != glsr_current_screen()->id) {
128
+        foreach( $pointers as $pointer ) {
129
+            if( $pointer['screen'] != glsr_current_screen()->id ) {
130 130
                 continue;
131 131
             }
132
-            if (in_array($pointer['id'], $dismissedPointers)) {
132
+            if( in_array( $pointer['id'], $dismissedPointers ) ) {
133 133
                 continue;
134 134
             }
135
-            $generatedPointers[] = $this->generatePointer($pointer);
135
+            $generatedPointers[] = $this->generatePointer( $pointer );
136 136
         }
137 137
         $this->pointers = $generatedPointers;
138 138
     }
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
     protected function localizeShortcodes()
157 157
     {
158 158
         $variables = [];
159
-        foreach (glsr()->mceShortcodes as $tag => $args) {
160
-            if (empty($args['required'])) {
159
+        foreach( glsr()->mceShortcodes as $tag => $args ) {
160
+            if( empty($args['required']) ) {
161 161
                 continue;
162 162
             }
163 163
             $variables[$tag] = $args['required'];
Please login to merge, or discard this patch.
plugin/Controllers/AjaxController.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
     /**
18 18
      * @return void
19 19
      */
20
-    public function routerChangeStatus(array $request)
20
+    public function routerChangeStatus( array $request )
21 21
     {
22
-        wp_send_json_success($this->execute(new ChangeStatus($request)));
22
+        wp_send_json_success( $this->execute( new ChangeStatus( $request ) ) );
23 23
     }
24 24
 
25 25
     /**
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
      */
28 28
     public function routerClearConsole()
29 29
     {
30
-        glsr(AdminController::class)->routerClearConsole();
31
-        wp_send_json_success([
32
-            'console' => glsr(Console::class)->get(),
33
-            'notices' => glsr(Notice::class)->get(),
34
-        ]);
30
+        glsr( AdminController::class )->routerClearConsole();
31
+        wp_send_json_success( [
32
+            'console' => glsr( Console::class )->get(),
33
+            'notices' => glsr( Notice::class )->get(),
34
+        ] );
35 35
     }
36 36
 
37 37
     /**
@@ -39,32 +39,32 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function routerCountReviews()
41 41
     {
42
-        glsr(AdminController::class)->routerCountReviews();
43
-        wp_send_json_success([
44
-            'notices' => glsr(Notice::class)->get(),
45
-        ]);
42
+        glsr( AdminController::class )->routerCountReviews();
43
+        wp_send_json_success( [
44
+            'notices' => glsr( Notice::class )->get(),
45
+        ] );
46 46
     }
47 47
 
48 48
     /**
49 49
      * @return void
50 50
      */
51
-    public function routerDismissNotice(array $request)
51
+    public function routerDismissNotice( array $request )
52 52
     {
53
-        glsr(NoticeController::class)->routerDismissNotice($request);
53
+        glsr( NoticeController::class )->routerDismissNotice( $request );
54 54
         wp_send_json_success();
55 55
     }
56 56
 
57 57
     /**
58 58
      * @return void
59 59
      */
60
-    public function routerMceShortcode(array $request)
60
+    public function routerMceShortcode( array $request )
61 61
     {
62 62
         $shortcode = $request['shortcode'];
63 63
         $response = false;
64
-        if (array_key_exists($shortcode, glsr()->mceShortcodes)) {
64
+        if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) {
65 65
             $data = glsr()->mceShortcodes[$shortcode];
66
-            if (!empty($data['errors'])) {
67
-                $data['btn_okay'] = [esc_html__('Okay', 'site-reviews')];
66
+            if( !empty($data['errors']) ) {
67
+                $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )];
68 68
             }
69 69
             $response = [
70 70
                 'body' => $data['fields'],
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
                 'title' => $data['title'],
75 75
             ];
76 76
         }
77
-        wp_send_json_success($response);
77
+        wp_send_json_success( $response );
78 78
     }
79 79
 
80 80
     /**
@@ -82,101 +82,101 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function routerFetchConsole()
84 84
     {
85
-        glsr(AdminController::class)->routerFetchConsole();
86
-        wp_send_json_success([
87
-            'console' => glsr(Console::class)->get(),
88
-            'notices' => glsr(Notice::class)->get(),
89
-        ]);
85
+        glsr( AdminController::class )->routerFetchConsole();
86
+        wp_send_json_success( [
87
+            'console' => glsr( Console::class )->get(),
88
+            'notices' => glsr( Notice::class )->get(),
89
+        ] );
90 90
     }
91 91
 
92 92
     /**
93 93
      * @return void
94 94
      */
95
-    public function routerSearchPosts(array $request)
95
+    public function routerSearchPosts( array $request )
96 96
     {
97
-        $results = glsr(Database::class)->searchPosts($request['search']);
98
-        wp_send_json_success([
99
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
97
+        $results = glsr( Database::class )->searchPosts( $request['search'] );
98
+        wp_send_json_success( [
99
+            'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>',
100 100
             'items' => $results,
101
-        ]);
101
+        ] );
102 102
     }
103 103
 
104 104
     /**
105 105
      * @return void
106 106
      */
107
-    public function routerSearchTranslations(array $request)
107
+    public function routerSearchTranslations( array $request )
108 108
     {
109
-        if (empty($request['exclude'])) {
109
+        if( empty($request['exclude']) ) {
110 110
             $request['exclude'] = [];
111 111
         }
112
-        $results = glsr(Translation::class)
113
-            ->search($request['search'])
112
+        $results = glsr( Translation::class )
113
+            ->search( $request['search'] )
114 114
             ->exclude()
115
-            ->exclude($request['exclude'])
115
+            ->exclude( $request['exclude'] )
116 116
             ->renderResults();
117
-        wp_send_json_success([
118
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
117
+        wp_send_json_success( [
118
+            'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>',
119 119
             'items' => $results,
120
-        ]);
120
+        ] );
121 121
     }
122 122
 
123 123
     /**
124 124
      * @return void
125 125
      */
126
-    public function routerSubmitReview(array $request)
126
+    public function routerSubmitReview( array $request )
127 127
     {
128
-        $command = glsr(PublicController::class)->routerSubmitReview($request);
129
-        $redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true)));
130
-        $redirect = apply_filters('site-reviews/review/redirect', $redirect, $command);
128
+        $command = glsr( PublicController::class )->routerSubmitReview( $request );
129
+        $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ) ) );
130
+        $redirect = apply_filters( 'site-reviews/review/redirect', $redirect, $command );
131 131
         $data = [
132
-            'errors' => glsr()->sessionGet($command->form_id.'errors', false),
133
-            'message' => glsr()->sessionGet($command->form_id.'message', ''),
134
-            'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false),
132
+            'errors' => glsr()->sessionGet( $command->form_id.'errors', false ),
133
+            'message' => glsr()->sessionGet( $command->form_id.'message', '' ),
134
+            'recaptcha' => glsr()->sessionGet( $command->form_id.'recaptcha', false ),
135 135
             'redirect' => $redirect,
136 136
         ];
137
-        if (false === $data['errors']) {
137
+        if( false === $data['errors'] ) {
138 138
             glsr()->sessionClear();
139
-            wp_send_json_success($data);
139
+            wp_send_json_success( $data );
140 140
         }
141
-        wp_send_json_error($data);
141
+        wp_send_json_error( $data );
142 142
     }
143 143
 
144 144
     /**
145 145
      * @return void
146 146
      */
147
-    public function routerFetchPagedReviews(array $request)
147
+    public function routerFetchPagedReviews( array $request )
148 148
     {
149
-        $homePath = untrailingslashit(parse_url(home_url(), PHP_URL_PATH));
150
-        $urlPath = untrailingslashit(parse_url(Arr::get($request, 'url'), PHP_URL_PATH));
149
+        $homePath = untrailingslashit( parse_url( home_url(), PHP_URL_PATH ) );
150
+        $urlPath = untrailingslashit( parse_url( Arr::get( $request, 'url' ), PHP_URL_PATH ) );
151 151
         $urlQuery = [];
152
-        parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery);
152
+        parse_str( parse_url( Arr::get( $request, 'url' ), PHP_URL_QUERY ), $urlQuery );
153 153
         $pagedUrl = $homePath === $urlPath
154 154
             ? home_url()
155
-            : home_url($urlPath);
155
+            : home_url( $urlPath );
156 156
         $args = [
157
-            'paged' => (int) Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1),
158
-            'pagedUrl' => trailingslashit($pagedUrl),
157
+            'paged' => (int)Arr::get( $urlQuery, glsr()->constant( 'PAGED_QUERY_VAR' ), 1 ),
158
+            'pagedUrl' => trailingslashit( $pagedUrl ),
159 159
             'pagination' => 'ajax',
160 160
             'schema' => false,
161 161
         ];
162
-        $atts = (array) json_decode(Arr::get($request, 'atts'));
163
-        $atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts);
164
-        $html = glsr(SiteReviewsPartial::class)->build(wp_parse_args($args, $atts));
165
-        return wp_send_json_success([
162
+        $atts = (array)json_decode( Arr::get( $request, 'atts' ) );
163
+        $atts = glsr( SiteReviewsShortcode::class )->normalizeAtts( $atts );
164
+        $html = glsr( SiteReviewsPartial::class )->build( wp_parse_args( $args, $atts ) );
165
+        return wp_send_json_success( [
166 166
             'pagination' => $html->getPagination(),
167 167
             'reviews' => $html->getReviews(),
168
-        ]);
168
+        ] );
169 169
     }
170 170
 
171 171
     /**
172 172
      * @return void
173 173
      */
174
-    public function routerTogglePinned(array $request)
174
+    public function routerTogglePinned( array $request )
175 175
     {
176
-        $isPinned = $this->execute(new TogglePinned($request));
177
-        wp_send_json_success([
178
-            'notices' => glsr(Notice::class)->get(),
176
+        $isPinned = $this->execute( new TogglePinned( $request ) );
177
+        wp_send_json_success( [
178
+            'notices' => glsr( Notice::class )->get(),
179 179
             'pinned' => $isPinned,
180
-        ]);
180
+        ] );
181 181
     }
182 182
 }
Please login to merge, or discard this patch.
plugin/Modules/Rating.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
      * @param int $roundBy
46 46
      * @return float
47 47
      */
48
-    public function getAverage(array $ratingCounts, $roundBy = 1)
48
+    public function getAverage( array $ratingCounts, $roundBy = 1 )
49 49
     {
50
-        $average = array_sum($ratingCounts);
51
-        if ($average > 0) {
52
-            $average = $this->getTotalSum($ratingCounts) / $average;
50
+        $average = array_sum( $ratingCounts );
51
+        if( $average > 0 ) {
52
+            $average = $this->getTotalSum( $ratingCounts ) / $average;
53 53
         }
54
-        $roundedAverage = round($average, intval($roundBy));
55
-        return floatval(apply_filters('site-reviews/rating/average', $roundedAverage, $ratingCounts, $average));
54
+        $roundedAverage = round( $average, intval( $roundBy ) );
55
+        return floatval( apply_filters( 'site-reviews/rating/average', $roundedAverage, $ratingCounts, $average ) );
56 56
     }
57 57
 
58 58
     /**
@@ -65,50 +65,50 @@  discard block
 block discarded – undo
65 65
      * @param int $confidencePercentage
66 66
      * @return int|float
67 67
      */
68
-    public function getLowerBound(array $upDownCounts = [0, 0], $confidencePercentage = 95)
68
+    public function getLowerBound( array $upDownCounts = [0, 0], $confidencePercentage = 95 )
69 69
     {
70
-        $numRatings = array_sum($upDownCounts);
71
-        if ($numRatings < 1) {
70
+        $numRatings = array_sum( $upDownCounts );
71
+        if( $numRatings < 1 ) {
72 72
             return 0;
73 73
         }
74 74
         $z = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage];
75 75
         $phat = 1 * $upDownCounts[1] / $numRatings;
76
-        return ($phat + $z * $z / (2 * $numRatings) - $z * sqrt(($phat * (1 - $phat) + $z * $z / (4 * $numRatings)) / $numRatings)) / (1 + $z * $z / $numRatings);
76
+        return ($phat + $z * $z / (2 * $numRatings) - $z * sqrt( ($phat * (1 - $phat) + $z * $z / (4 * $numRatings)) / $numRatings )) / (1 + $z * $z / $numRatings);
77 77
     }
78 78
 
79 79
     /**
80 80
      * @return int|float
81 81
      */
82
-    public function getOverallPercentage(array $ratingCounts)
82
+    public function getOverallPercentage( array $ratingCounts )
83 83
     {
84
-        return round($this->getAverage($ratingCounts) * 100 / glsr()->constant('MAX_RATING', __CLASS__), 2);
84
+        return round( $this->getAverage( $ratingCounts ) * 100 / glsr()->constant( 'MAX_RATING', __CLASS__ ), 2 );
85 85
     }
86 86
 
87 87
     /**
88 88
      * @return array
89 89
      */
90
-    public function getPercentages(array $ratingCounts)
90
+    public function getPercentages( array $ratingCounts )
91 91
     {
92
-        $total = array_sum($ratingCounts);
93
-        foreach ($ratingCounts as $index => $count) {
94
-            if (empty($count)) {
92
+        $total = array_sum( $ratingCounts );
93
+        foreach( $ratingCounts as $index => $count ) {
94
+            if( empty($count) ) {
95 95
                 continue;
96 96
             }
97 97
             $ratingCounts[$index] = $count / $total * 100;
98 98
         }
99
-        return $this->getRoundedPercentages($ratingCounts);
99
+        return $this->getRoundedPercentages( $ratingCounts );
100 100
     }
101 101
 
102 102
     /**
103 103
      * @return float
104 104
      */
105
-    public function getRanking(array $ratingCounts)
105
+    public function getRanking( array $ratingCounts )
106 106
     {
107
-        return floatval(apply_filters('site-reviews/rating/ranking',
108
-            $this->getRankingUsingImdb($ratingCounts),
107
+        return floatval( apply_filters( 'site-reviews/rating/ranking',
108
+            $this->getRankingUsingImdb( $ratingCounts ),
109 109
             $ratingCounts,
110 110
             $this
111
-        ));
111
+        ) );
112 112
     }
113 113
 
114 114
     /**
@@ -121,15 +121,15 @@  discard block
 block discarded – undo
121 121
      * @param int $confidencePercentage
122 122
      * @return int|float
123 123
      */
124
-    public function getRankingUsingImdb(array $ratingCounts, $confidencePercentage = 70)
124
+    public function getRankingUsingImdb( array $ratingCounts, $confidencePercentage = 70 )
125 125
     {
126
-        $avgRating = $this->getAverage($ratingCounts);
126
+        $avgRating = $this->getAverage( $ratingCounts );
127 127
         // Represents a prior (your prior opinion without data) for the average star rating. A higher prior also means a higher margin for error.
128 128
         // This could also be the average score of all items instead of a fixed value.
129
-        $bayesMean = ($confidencePercentage / 100) * glsr()->constant('MAX_RATING', __CLASS__); // prior, 70% = 3.5
129
+        $bayesMean = ($confidencePercentage / 100) * glsr()->constant( 'MAX_RATING', __CLASS__ ); // prior, 70% = 3.5
130 130
         // Represents the number of ratings expected to begin observing a pattern that would put confidence in the prior.
131 131
         $bayesMinimal = 10; // confidence
132
-        $numOfReviews = array_sum($ratingCounts);
132
+        $numOfReviews = array_sum( $ratingCounts );
133 133
         return $avgRating > 0
134 134
             ? (($bayesMinimal * $bayesMean) + ($avgRating * $numOfReviews)) / ($bayesMinimal + $numOfReviews)
135 135
             : 0;
@@ -145,48 +145,48 @@  discard block
 block discarded – undo
145 145
      * @param int $confidencePercentage
146 146
      * @return float
147 147
      */
148
-    public function getRankingUsingZScores(array $ratingCounts, $confidencePercentage = 90)
148
+    public function getRankingUsingZScores( array $ratingCounts, $confidencePercentage = 90 )
149 149
     {
150
-        $ratingCountsSum = array_sum($ratingCounts) + glsr()->constant('MAX_RATING', __CLASS__);
151
-        $weight = $this->getWeight($ratingCounts, $ratingCountsSum);
152
-        $weightPow2 = $this->getWeight($ratingCounts, $ratingCountsSum, true);
150
+        $ratingCountsSum = array_sum( $ratingCounts ) + glsr()->constant( 'MAX_RATING', __CLASS__ );
151
+        $weight = $this->getWeight( $ratingCounts, $ratingCountsSum );
152
+        $weightPow2 = $this->getWeight( $ratingCounts, $ratingCountsSum, true );
153 153
         $zScore = static::CONFIDENCE_LEVEL_Z_SCORES[$confidencePercentage];
154
-        return $weight - $zScore * sqrt(($weightPow2 - pow($weight, 2)) / ($ratingCountsSum + 1));
154
+        return $weight - $zScore * sqrt( ($weightPow2 - pow( $weight, 2 )) / ($ratingCountsSum + 1) );
155 155
     }
156 156
 
157 157
     /**
158 158
      * @param int $target
159 159
      * @return array
160 160
      */
161
-    protected function getRoundedPercentages(array $percentages, $totalPercent = 100)
161
+    protected function getRoundedPercentages( array $percentages, $totalPercent = 100 )
162 162
     {
163
-        array_walk($percentages, function (&$percent, $index) {
163
+        array_walk( $percentages, function( &$percent, $index ) {
164 164
             $percent = [
165 165
                 'index' => $index,
166
-                'percent' => floor($percent),
167
-                'remainder' => fmod($percent, 1),
166
+                'percent' => floor( $percent ),
167
+                'remainder' => fmod( $percent, 1 ),
168 168
             ];
169 169
         });
170
-        $indexes = glsr_array_column($percentages, 'index');
171
-        $remainders = glsr_array_column($percentages, 'remainder');
172
-        array_multisort($remainders, SORT_DESC, SORT_STRING, $indexes, SORT_DESC, $percentages);
170
+        $indexes = glsr_array_column( $percentages, 'index' );
171
+        $remainders = glsr_array_column( $percentages, 'remainder' );
172
+        array_multisort( $remainders, SORT_DESC, SORT_STRING, $indexes, SORT_DESC, $percentages );
173 173
         $i = 0;
174
-        if (array_sum(glsr_array_column($percentages, 'percent')) > 0) {
175
-            while (array_sum(glsr_array_column($percentages, 'percent')) < $totalPercent) {
174
+        if( array_sum( glsr_array_column( $percentages, 'percent' ) ) > 0 ) {
175
+            while( array_sum( glsr_array_column( $percentages, 'percent' ) ) < $totalPercent ) {
176 176
                 ++$percentages[$i]['percent'];
177 177
                 ++$i;
178 178
             }
179 179
         }
180
-        array_multisort($indexes, SORT_DESC, $percentages);
181
-        return array_combine($indexes, glsr_array_column($percentages, 'percent'));
180
+        array_multisort( $indexes, SORT_DESC, $percentages );
181
+        return array_combine( $indexes, glsr_array_column( $percentages, 'percent' ) );
182 182
     }
183 183
 
184 184
     /**
185 185
      * @return int
186 186
      */
187
-    protected function getTotalSum(array $ratingCounts)
187
+    protected function getTotalSum( array $ratingCounts )
188 188
     {
189
-        return array_reduce(array_keys($ratingCounts), function ($carry, $index) use ($ratingCounts) {
189
+        return array_reduce( array_keys( $ratingCounts ), function( $carry, $index ) use ($ratingCounts) {
190 190
             return $carry + ($index * $ratingCounts[$index]);
191 191
         });
192 192
     }
@@ -196,12 +196,12 @@  discard block
 block discarded – undo
196 196
      * @param bool $powerOf2
197 197
      * @return float
198 198
      */
199
-    protected function getWeight(array $ratingCounts, $ratingCountsSum, $powerOf2 = false)
199
+    protected function getWeight( array $ratingCounts, $ratingCountsSum, $powerOf2 = false )
200 200
     {
201
-        return array_reduce(array_keys($ratingCounts),
202
-            function ($count, $rating) use ($ratingCounts, $ratingCountsSum, $powerOf2) {
201
+        return array_reduce( array_keys( $ratingCounts ),
202
+            function( $count, $rating ) use ($ratingCounts, $ratingCountsSum, $powerOf2) {
203 203
                 $ratingLevel = $powerOf2
204
-                    ? pow($rating, 2)
204
+                    ? pow( $rating, 2 )
205 205
                     : $rating;
206 206
                 return $count + ($ratingLevel * ($ratingCounts[$rating] + 1)) / $ratingCountsSum;
207 207
             }
Please login to merge, or discard this patch.
plugin/Modules/Html/Builder.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -61,18 +61,18 @@  discard block
 block discarded – undo
61 61
      * @param array $args
62 62
      * @return string|void
63 63
      */
64
-    public function __call($method, $args)
64
+    public function __call( $method, $args )
65 65
     {
66 66
         $instance = new static();
67
-        $instance->setTagFromMethod($method);
68
-        call_user_func_array([$instance, 'normalize'], $args += ['', '']);
69
-        $tags = array_merge(static::TAGS_FORM, static::TAGS_SINGLE, static::TAGS_STRUCTURE, static::TAGS_TEXT);
70
-        do_action_ref_array('site-reviews/builder', [$instance]);
71
-        $generatedTag = in_array($instance->tag, $tags)
67
+        $instance->setTagFromMethod( $method );
68
+        call_user_func_array( [$instance, 'normalize'], $args += ['', ''] );
69
+        $tags = array_merge( static::TAGS_FORM, static::TAGS_SINGLE, static::TAGS_STRUCTURE, static::TAGS_TEXT );
70
+        do_action_ref_array( 'site-reviews/builder', [$instance] );
71
+        $generatedTag = in_array( $instance->tag, $tags )
72 72
             ? $instance->buildTag()
73 73
             : $instance->buildCustomField();
74
-        $generatedTag = apply_filters('site-reviews/builder/result', $generatedTag, $instance);
75
-        if (!$this->render) {
74
+        $generatedTag = apply_filters( 'site-reviews/builder/result', $generatedTag, $instance );
75
+        if( !$this->render ) {
76 76
             return $generatedTag;
77 77
         }
78 78
         echo $generatedTag;
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
      * @param mixed $value
84 84
      * @return void
85 85
      */
86
-    public function __set($property, $value)
86
+    public function __set( $property, $value )
87 87
     {
88 88
         $properties = [
89 89
             'args' => 'is_array',
90 90
             'render' => 'is_bool',
91 91
             'tag' => 'is_string',
92 92
         ];
93
-        if (!isset($properties[$property])
94
-            || empty(array_filter([$value], $properties[$property]))
93
+        if( !isset($properties[$property])
94
+            || empty(array_filter( [$value], $properties[$property] ))
95 95
         ) {
96 96
             return;
97 97
         }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function getClosingTag()
105 105
     {
106
-        if (empty($this->tag)) {
106
+        if( empty($this->tag) ) {
107 107
             return;
108 108
         }
109 109
         return '</'.$this->tag.'>';
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
      */
115 115
     public function getOpeningTag()
116 116
     {
117
-        if (empty($this->tag)) {
117
+        if( empty($this->tag) ) {
118 118
             return;
119 119
         }
120
-        $attributes = glsr(Attributes::class)->{$this->tag}($this->args)->toString();
121
-        return '<'.trim($this->tag.' '.$attributes).'>';
120
+        $attributes = glsr( Attributes::class )->{$this->tag}($this->args)->toString();
121
+        return '<'.trim( $this->tag.' '.$attributes ).'>';
122 122
     }
123 123
 
124 124
     /**
@@ -126,19 +126,19 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function getTag()
128 128
     {
129
-        if (in_array($this->tag, static::TAGS_SINGLE)) {
129
+        if( in_array( $this->tag, static::TAGS_SINGLE ) ) {
130 130
             return $this->getOpeningTag();
131 131
         }
132
-        if (!in_array($this->tag, static::TAGS_FORM)) {
132
+        if( !in_array( $this->tag, static::TAGS_FORM ) ) {
133 133
             return $this->buildDefaultTag();
134 134
         }
135
-        return call_user_func([$this, 'buildForm'.ucfirst($this->tag)]).$this->buildFieldDescription();
135
+        return call_user_func( [$this, 'buildForm'.ucfirst( $this->tag )] ).$this->buildFieldDescription();
136 136
     }
137 137
 
138 138
     /**
139 139
      * @return string
140 140
      */
141
-    public function raw(array $field)
141
+    public function raw( array $field )
142 142
     {
143 143
         unset($field['label']);
144 144
         return $this->{$field['type']}($field);
@@ -150,18 +150,18 @@  discard block
 block discarded – undo
150 150
     protected function buildCustomField()
151 151
     {
152 152
         $className = $this->getCustomFieldClassName();
153
-        if (class_exists($className)) {
154
-            return (new $className($this))->build();
153
+        if( class_exists( $className ) ) {
154
+            return (new $className( $this ))->build();
155 155
         }
156
-        glsr_log()->error('Field missing: '.$className);
156
+        glsr_log()->error( 'Field missing: '.$className );
157 157
     }
158 158
 
159 159
     /**
160 160
      * @return string|void
161 161
      */
162
-    protected function buildDefaultTag($text = '')
162
+    protected function buildDefaultTag( $text = '' )
163 163
     {
164
-        if (empty($text)) {
164
+        if( empty($text) ) {
165 165
             $text = $this->args['text'];
166 166
         }
167 167
         return $this->getOpeningTag().$text.$this->getClosingTag();
@@ -172,13 +172,13 @@  discard block
 block discarded – undo
172 172
      */
173 173
     protected function buildFieldDescription()
174 174
     {
175
-        if (empty($this->args['description'])) {
175
+        if( empty($this->args['description']) ) {
176 176
             return;
177 177
         }
178
-        if ($this->args['is_widget']) {
179
-            return $this->small($this->args['description']);
178
+        if( $this->args['is_widget'] ) {
179
+            return $this->small( $this->args['description'] );
180 180
         }
181
-        return $this->p($this->args['description'], ['class' => 'description']);
181
+        return $this->p( $this->args['description'], ['class' => 'description'] );
182 182
     }
183 183
 
184 184
     /**
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
      */
187 187
     protected function buildFormInput()
188 188
     {
189
-        if (!in_array($this->args['type'], ['checkbox', 'radio'])) {
190
-            if (isset($this->args['multiple'])) {
191
-                $this->args['name'].= '[]';
189
+        if( !in_array( $this->args['type'], ['checkbox', 'radio'] ) ) {
190
+            if( isset($this->args['multiple']) ) {
191
+                $this->args['name'] .= '[]';
192 192
             }
193 193
             return $this->buildFormLabel().$this->getOpeningTag();
194 194
         }
@@ -202,19 +202,19 @@  discard block
 block discarded – undo
202 202
      */
203 203
     protected function buildFormInputChoice()
204 204
     {
205
-        if (!empty($this->args['text'])) {
205
+        if( !empty($this->args['text']) ) {
206 206
             $this->args['label'] = $this->args['text'];
207 207
         }
208
-        if (!$this->args['is_public']) {
209
-            return $this->buildFormLabel([
208
+        if( !$this->args['is_public'] ) {
209
+            return $this->buildFormLabel( [
210 210
                 'class' => 'glsr-'.$this->args['type'].'-label',
211 211
                 'text' => $this->getOpeningTag().' '.$this->args['label'].'<span></span>',
212
-            ]);
212
+            ] );
213 213
         }
214
-        return $this->getOpeningTag().$this->buildFormLabel([
214
+        return $this->getOpeningTag().$this->buildFormLabel( [
215 215
             'class' => 'glsr-'.$this->args['type'].'-label',
216 216
             'text' => $this->args['label'].'<span></span>',
217
-        ]);
217
+        ] );
218 218
     }
219 219
 
220 220
     /**
@@ -222,39 +222,39 @@  discard block
 block discarded – undo
222 222
      */
223 223
     protected function buildFormInputMultiChoice()
224 224
     {
225
-        if ('checkbox' == $this->args['type']) {
226
-            $this->args['name'].= '[]';
225
+        if( 'checkbox' == $this->args['type'] ) {
226
+            $this->args['name'] .= '[]';
227 227
         }
228 228
         $index = 0;
229
-        $options = array_reduce(array_keys($this->args['options']), function ($carry, $key) use (&$index) {
230
-            return $carry.$this->li($this->{$this->args['type']}([
231
-                'checked' => in_array($key, (array) $this->args['value']),
229
+        $options = array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) use (&$index) {
230
+            return $carry.$this->li( $this->{$this->args['type']}([
231
+                'checked' => in_array( $key, (array)$this->args['value'] ),
232 232
                 'id' => $this->args['id'].'-'.$index++,
233 233
                 'name' => $this->args['name'],
234 234
                 'text' => $this->args['options'][$key],
235 235
                 'value' => $key,
236
-            ]));
236
+            ]) );
237 237
         });
238
-        return $this->ul($options, [
238
+        return $this->ul( $options, [
239 239
             'class' => $this->args['class'],
240 240
             'id' => $this->args['id'],
241
-        ]);
241
+        ] );
242 242
     }
243 243
 
244 244
     /**
245 245
      * @return void|string
246 246
      */
247
-    protected function buildFormLabel(array $customArgs = [])
247
+    protected function buildFormLabel( array $customArgs = [] )
248 248
     {
249
-        if (empty($this->args['label']) || 'hidden' == $this->args['type']) {
249
+        if( empty($this->args['label']) || 'hidden' == $this->args['type'] ) {
250 250
             return;
251 251
         }
252
-        return $this->label(wp_parse_args($customArgs, [
252
+        return $this->label( wp_parse_args( $customArgs, [
253 253
             'for' => $this->args['id'],
254 254
             'is_public' => $this->args['is_public'],
255 255
             'text' => $this->args['label'],
256 256
             'type' => $this->args['type'],
257
-        ]));
257
+        ] ) );
258 258
     }
259 259
 
260 260
     /**
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
      */
263 263
     protected function buildFormSelect()
264 264
     {
265
-        return $this->buildFormLabel().$this->buildDefaultTag($this->buildFormSelectOptions());
265
+        return $this->buildFormLabel().$this->buildDefaultTag( $this->buildFormSelectOptions() );
266 266
     }
267 267
 
268 268
     /**
@@ -270,12 +270,12 @@  discard block
 block discarded – undo
270 270
      */
271 271
     protected function buildFormSelectOptions()
272 272
     {
273
-        return array_reduce(array_keys($this->args['options']), function ($carry, $key) {
274
-            return $carry.$this->option([
275
-                'selected' => $this->args['value'] === (string) $key,
273
+        return array_reduce( array_keys( $this->args['options'] ), function( $carry, $key ) {
274
+            return $carry.$this->option( [
275
+                'selected' => $this->args['value'] === (string)$key,
276 276
                 'text' => $this->args['options'][$key],
277 277
                 'value' => $key,
278
-            ]);
278
+            ] );
279 279
         });
280 280
     }
281 281
 
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
      */
285 285
     protected function buildFormTextarea()
286 286
     {
287
-        return $this->buildFormLabel().$this->buildDefaultTag($this->args['value']);
287
+        return $this->buildFormLabel().$this->buildDefaultTag( $this->args['value'] );
288 288
     }
289 289
 
290 290
     /**
@@ -301,8 +301,8 @@  discard block
 block discarded – undo
301 301
      */
302 302
     protected function getCustomFieldClassName()
303 303
     {
304
-        $classname = Helper::buildClassName($this->tag, __NAMESPACE__.'\Fields');
305
-        return apply_filters('site-reviews/builder/field/'.$this->tag, $classname);
304
+        $classname = Helper::buildClassName( $this->tag, __NAMESPACE__.'\Fields' );
305
+        return apply_filters( 'site-reviews/builder/field/'.$this->tag, $classname );
306 306
     }
307 307
 
308 308
     /**
@@ -311,27 +311,27 @@  discard block
 block discarded – undo
311 311
     protected function mergeArgsWithRequiredDefaults()
312 312
     {
313 313
         $className = $this->getCustomFieldClassName();
314
-        if (class_exists($className)) {
315
-            $this->args = $className::merge($this->args);
314
+        if( class_exists( $className ) ) {
315
+            $this->args = $className::merge( $this->args );
316 316
         }
317
-        $this->args = glsr(BuilderDefaults::class)->merge($this->args);
317
+        $this->args = glsr( BuilderDefaults::class )->merge( $this->args );
318 318
     }
319 319
 
320 320
     /**
321 321
      * @param string|array ...$params
322 322
      * @return void
323 323
      */
324
-    protected function normalize(...$params)
324
+    protected function normalize( ...$params )
325 325
     {
326
-        if (is_string($params[0]) || is_numeric($params[0])) {
327
-            $this->setNameOrTextAttributeForTag($params[0]);
326
+        if( is_string( $params[0] ) || is_numeric( $params[0] ) ) {
327
+            $this->setNameOrTextAttributeForTag( $params[0] );
328 328
         }
329
-        if (is_array($params[0])) {
329
+        if( is_array( $params[0] ) ) {
330 330
             $this->args += $params[0];
331
-        } elseif (is_array($params[1])) {
331
+        } elseif( is_array( $params[1] ) ) {
332 332
             $this->args += $params[1];
333 333
         }
334
-        if (!isset($this->args['is_public'])) {
334
+        if( !isset($this->args['is_public']) ) {
335 335
             $this->args['is_public'] = false;
336 336
         }
337 337
     }
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
      * @param string $value
341 341
      * @return void
342 342
      */
343
-    protected function setNameOrTextAttributeForTag($value)
343
+    protected function setNameOrTextAttributeForTag( $value )
344 344
     {
345
-        $attribute = in_array($this->tag, static::TAGS_FORM)
345
+        $attribute = in_array( $this->tag, static::TAGS_FORM )
346 346
             ? 'name'
347 347
             : 'text';
348 348
         $this->args[$attribute] = $value;
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
      * @param string $method
353 353
      * @return void
354 354
      */
355
-    protected function setTagFromMethod($method)
355
+    protected function setTagFromMethod( $method )
356 356
     {
357
-        $this->tag = strtolower($method);
358
-        if (in_array($this->tag, static::INPUT_TYPES)) {
357
+        $this->tag = strtolower( $method );
358
+        if( in_array( $this->tag, static::INPUT_TYPES ) ) {
359 359
             $this->args['type'] = $this->tag;
360 360
             $this->tag = 'input';
361 361
         }
Please login to merge, or discard this patch.
plugin/Database/SqlQueries.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -22,17 +22,17 @@  discard block
 block discarded – undo
22 22
      * @param string $metaReviewId
23 23
      * @return int
24 24
      */
25
-    public function getPostIdFromReviewId($metaReviewId)
25
+    public function getPostIdFromReviewId( $metaReviewId )
26 26
     {
27
-        $postId = $this->db->get_var("
27
+        $postId = $this->db->get_var( "
28 28
             SELECT p.ID
29 29
             FROM {$this->db->posts} AS p
30 30
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
31 31
             WHERE p.post_type = '{$this->postType}'
32 32
             AND m.meta_key = '_review_id'
33 33
             AND m.meta_value = '{$metaReviewId}'
34
-        ");
35
-        return intval($postId);
34
+        " );
35
+        return intval( $postId );
36 36
     }
37 37
 
38 38
     /**
@@ -40,23 +40,23 @@  discard block
 block discarded – undo
40 40
      * @param int $limit
41 41
      * @return array
42 42
      */
43
-    public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500)
43
+    public function getReviewCounts( array $args, $lastPostId = 0, $limit = 500 )
44 44
     {
45
-        return (array) $this->db->get_results("
45
+        return (array)$this->db->get_results( "
46 46
             SELECT DISTINCT p.ID, m1.meta_value AS rating, m2.meta_value AS type
47 47
             FROM {$this->db->posts} AS p
48 48
             INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
49 49
             INNER JOIN {$this->db->postmeta} AS m2 ON p.ID = m2.post_id
50
-            {$this->getInnerJoinForCounts($args)}
50
+            {$this->getInnerJoinForCounts( $args )}
51 51
             WHERE p.ID > {$lastPostId}
52 52
             AND p.post_status = 'publish'
53 53
             AND p.post_type = '{$this->postType}'
54 54
             AND m1.meta_key = '_rating'
55 55
             AND m2.meta_key = '_review_type'
56
-            {$this->getAndForCounts($args)}
56
+            {$this->getAndForCounts( $args )}
57 57
             ORDER By p.ID ASC
58 58
             LIMIT {$limit}
59
-        ");
59
+        " );
60 60
     }
61 61
 
62 62
     /**
@@ -64,17 +64,17 @@  discard block
 block discarded – undo
64 64
      * @param string $metaKey
65 65
      * @return array
66 66
      */
67
-    public function getReviewCountsFor($metaKey)
67
+    public function getReviewCountsFor( $metaKey )
68 68
     {
69
-        $metaKey = Str::prefix('_', $metaKey);
70
-        return (array) $this->db->get_results("
69
+        $metaKey = Str::prefix( '_', $metaKey );
70
+        return (array)$this->db->get_results( "
71 71
             SELECT DISTINCT m.meta_value AS name, COUNT(*) num_posts
72 72
             FROM {$this->db->posts} AS p
73 73
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
74 74
             WHERE p.post_type = '{$this->postType}'
75 75
             AND m.meta_key = '{$metaKey}'
76 76
             GROUP BY name
77
-        ");
77
+        " );
78 78
     }
79 79
 
80 80
     /**
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
      * @param string $reviewType
83 83
      * @return array
84 84
      */
85
-    public function getReviewIdsByType($reviewType)
85
+    public function getReviewIdsByType( $reviewType )
86 86
     {
87
-        $results = $this->db->get_col("
87
+        $results = $this->db->get_col( "
88 88
             SELECT DISTINCT m1.meta_value AS review_id
89 89
             FROM {$this->db->posts} AS p
90 90
             INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
             AND m1.meta_key = '_review_id'
94 94
             AND m2.meta_key = '_review_type'
95 95
             AND m2.meta_value = '{$reviewType}'
96
-        ");
97
-        return array_keys(array_flip($results));
96
+        " );
97
+        return array_keys( array_flip( $results ) );
98 98
     }
99 99
 
100 100
     /**
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
      * @param int $limit
103 103
      * @return array
104 104
      */
105
-    public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100)
105
+    public function getReviewRatingsFromIds( array $postIds, $greaterThanId = 0, $limit = 100 )
106 106
     {
107
-        sort($postIds);
108
-        $postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit);
109
-        $postIds = implode(',', $postIds);
110
-        return (array) $this->db->get_results("
107
+        sort( $postIds );
108
+        $postIds = array_slice( $postIds, intval( array_search( $greaterThanId, $postIds ) ), $limit );
109
+        $postIds = implode( ',', $postIds );
110
+        return (array)$this->db->get_results( "
111 111
             SELECT p.ID, m.meta_value AS rating
112 112
             FROM {$this->db->posts} AS p
113 113
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
             GROUP BY p.ID
120 120
             ORDER By p.ID ASC
121 121
             LIMIT {$limit}
122
-        ");
122
+        " );
123 123
     }
124 124
 
125 125
     /**
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
      * @param string $status
128 128
      * @return array
129 129
      */
130
-    public function getReviewsMeta($key, $status = 'publish')
130
+    public function getReviewsMeta( $key, $status = 'publish' )
131 131
     {
132 132
         $postStatusQuery = 'all' != $status && !empty($status)
133 133
             ? "AND p.post_status = '{$status}'"
134 134
             : '';
135
-        $key = Str::prefix('_', $key);
136
-        $values = $this->db->get_col("
135
+        $key = Str::prefix( '_', $key );
136
+        $values = $this->db->get_col( "
137 137
             SELECT DISTINCT m.meta_value
138 138
             FROM {$this->db->postmeta} m
139 139
             LEFT JOIN {$this->db->posts} p ON p.ID = m.post_id
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
             $postStatusQuery
144 144
             GROUP BY p.ID -- remove duplicate meta_value entries
145 145
             ORDER BY m.meta_id ASC -- sort by oldest meta_value
146
-        ");
147
-        sort($values);
146
+        " );
147
+        sort( $values );
148 148
         return $values;
149 149
     }
150 150
 
@@ -152,34 +152,34 @@  discard block
 block discarded – undo
152 152
      * @param string $and
153 153
      * @return string
154 154
      */
155
-    protected function getAndForCounts(array $args, $and = '')
155
+    protected function getAndForCounts( array $args, $and = '' )
156 156
     {
157
-        $postIds = implode(',', array_filter(Arr::get($args, 'post_ids', [])));
158
-        $termIds = implode(',', array_filter(Arr::get($args, 'term_ids', [])));
159
-        if (!empty($args['type'])) {
160
-            $and.= "AND m2.meta_value = '{$args['type']}' ";
157
+        $postIds = implode( ',', array_filter( Arr::get( $args, 'post_ids', [] ) ) );
158
+        $termIds = implode( ',', array_filter( Arr::get( $args, 'term_ids', [] ) ) );
159
+        if( !empty($args['type']) ) {
160
+            $and .= "AND m2.meta_value = '{$args['type']}' ";
161 161
         }
162
-        if ($postIds) {
163
-            $and.= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
162
+        if( $postIds ) {
163
+            $and .= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
164 164
         }
165
-        if ($termIds) {
166
-            $and.= "AND tr.term_taxonomy_id IN ({$termIds}) ";
165
+        if( $termIds ) {
166
+            $and .= "AND tr.term_taxonomy_id IN ({$termIds}) ";
167 167
         }
168
-        return apply_filters('site-reviews/query/and-for-counts', $and);
168
+        return apply_filters( 'site-reviews/query/and-for-counts', $and );
169 169
     }
170 170
 
171 171
     /**
172 172
      * @param string $innerJoin
173 173
      * @return string
174 174
      */
175
-    protected function getInnerJoinForCounts(array $args, $innerJoin = '')
175
+    protected function getInnerJoinForCounts( array $args, $innerJoin = '' )
176 176
     {
177
-        if (!empty(Arr::get($args, 'post_ids'))) {
178
-            $innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
177
+        if( !empty(Arr::get( $args, 'post_ids' )) ) {
178
+            $innerJoin .= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
179 179
         }
180
-        if (!empty(Arr::get($args, 'term_ids'))) {
181
-            $innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
180
+        if( !empty(Arr::get( $args, 'term_ids' )) ) {
181
+            $innerJoin .= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
182 182
         }
183
-        return apply_filters('site-reviews/query/inner-join-for-counts', $innerJoin);
183
+        return apply_filters( 'site-reviews/query/inner-join-for-counts', $innerJoin );
184 184
     }
185 185
 }
Please login to merge, or discard this patch.
plugin/Controllers/ListTableController.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -20,15 +20,15 @@  discard block
 block discarded – undo
20 20
      */
21 21
     public function approve()
22 22
     {
23
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
23
+        if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) {
24 24
             return;
25 25
         }
26
-        check_admin_referer('approve-review_'.($postId = $this->getPostId()));
27
-        wp_update_post([
26
+        check_admin_referer( 'approve-review_'.($postId = $this->getPostId()) );
27
+        wp_update_post( [
28 28
             'ID' => $postId,
29 29
             'post_status' => 'publish',
30
-        ]);
31
-        wp_safe_redirect(wp_get_referer());
30
+        ] );
31
+        wp_safe_redirect( wp_get_referer() );
32 32
         exit;
33 33
     }
34 34
 
@@ -37,20 +37,20 @@  discard block
 block discarded – undo
37 37
      * @return array
38 38
      * @filter manage_.Application::POST_TYPE._posts_columns
39 39
      */
40
-    public function filterColumnsForPostType($columns)
40
+    public function filterColumnsForPostType( $columns )
41 41
     {
42
-        $columns = Arr::consolidateArray($columns);
42
+        $columns = Arr::consolidateArray( $columns );
43 43
         $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
44
-        foreach ($postTypeColumns as $key => &$value) {
45
-            if (!array_key_exists($key, $columns) || !empty($value)) {
44
+        foreach( $postTypeColumns as $key => &$value ) {
45
+            if( !array_key_exists( $key, $columns ) || !empty($value) ) {
46 46
                 continue;
47 47
             }
48 48
             $value = $columns[$key];
49 49
         }
50
-        if (count(glsr(Database::class)->getReviewsMeta('review_type')) < 2) {
50
+        if( count( glsr( Database::class )->getReviewsMeta( 'review_type' ) ) < 2 ) {
51 51
             unset($postTypeColumns['review_type']);
52 52
         }
53
-        return array_filter($postTypeColumns, 'strlen');
53
+        return array_filter( $postTypeColumns, 'strlen' );
54 54
     }
55 55
 
56 56
     /**
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
      * @return string
60 60
      * @filter post_date_column_status
61 61
      */
62
-    public function filterDateColumnStatus($status, $post)
62
+    public function filterDateColumnStatus( $status, $post )
63 63
     {
64
-        if (Application::POST_TYPE == Arr::get($post, 'post_type')) {
65
-            $status = __('Submitted', 'site-reviews');
64
+        if( Application::POST_TYPE == Arr::get( $post, 'post_type' ) ) {
65
+            $status = __( 'Submitted', 'site-reviews' );
66 66
         }
67 67
         return $status;
68 68
     }
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
      * @return array
74 74
      * @filter default_hidden_columns
75 75
      */
76
-    public function filterDefaultHiddenColumns($hidden, $screen)
76
+    public function filterDefaultHiddenColumns( $hidden, $screen )
77 77
     {
78
-        if (Arr::get($screen, 'id') == 'edit-'.Application::POST_TYPE) {
79
-            $hidden = Arr::consolidateArray($hidden);
80
-            $hidden = array_unique(array_merge($hidden, [
78
+        if( Arr::get( $screen, 'id' ) == 'edit-'.Application::POST_TYPE ) {
79
+            $hidden = Arr::consolidateArray( $hidden );
80
+            $hidden = array_unique( array_merge( $hidden, [
81 81
                 'email', 'ip_address', 'response', 'reviewer',
82
-            ]));
82
+            ] ) );
83 83
         }
84 84
         return $hidden;
85 85
     }
@@ -90,28 +90,28 @@  discard block
 block discarded – undo
90 90
      * @return array
91 91
      * @filter post_row_actions
92 92
      */
93
-    public function filterRowActions($actions, $post)
93
+    public function filterRowActions( $actions, $post )
94 94
     {
95
-        if (Application::POST_TYPE != Arr::get($post, 'post_type') || 'trash' == $post->post_status) {
95
+        if( Application::POST_TYPE != Arr::get( $post, 'post_type' ) || 'trash' == $post->post_status ) {
96 96
             return $actions;
97 97
         }
98 98
         unset($actions['inline hide-if-no-js']); //Remove Quick-edit
99 99
         $rowActions = [
100
-            'approve' => esc_attr__('Approve', 'site-reviews'),
101
-            'unapprove' => esc_attr__('Unapprove', 'site-reviews'),
100
+            'approve' => esc_attr__( 'Approve', 'site-reviews' ),
101
+            'unapprove' => esc_attr__( 'Unapprove', 'site-reviews' ),
102 102
         ];
103 103
         $newActions = [];
104
-        foreach ($rowActions as $key => $text) {
105
-            $newActions[$key] = glsr(Builder::class)->a($text, [
106
-                'aria-label' => sprintf(esc_attr_x('%s this review', 'Approve the review', 'site-reviews'), $text),
104
+        foreach( $rowActions as $key => $text ) {
105
+            $newActions[$key] = glsr( Builder::class )->a( $text, [
106
+                'aria-label' => sprintf( esc_attr_x( '%s this review', 'Approve the review', 'site-reviews' ), $text ),
107 107
                 'class' => 'glsr-change-status',
108 108
                 'href' => wp_nonce_url(
109
-                    admin_url('post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID),
109
+                    admin_url( 'post.php?post='.$post->ID.'&action='.$key.'&plugin='.Application::ID ),
110 110
                     $key.'-review_'.$post->ID
111 111
                 ),
112
-            ]);
112
+            ] );
113 113
         }
114
-        return $newActions + Arr::consolidateArray($actions);
114
+        return $newActions + Arr::consolidateArray( $actions );
115 115
     }
116 116
 
117 117
     /**
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
      * @return array
120 120
      * @filter manage_edit-.Application::POST_TYPE._sortable_columns
121 121
      */
122
-    public function filterSortableColumns($columns)
122
+    public function filterSortableColumns( $columns )
123 123
     {
124
-        $columns = Arr::consolidateArray($columns);
124
+        $columns = Arr::consolidateArray( $columns );
125 125
         $postTypeColumns = glsr()->postTypeColumns[Application::POST_TYPE];
126 126
         unset($postTypeColumns['cb']);
127
-        foreach ($postTypeColumns as $key => $value) {
128
-            if (Str::startsWith('taxonomy', $key)) {
127
+        foreach( $postTypeColumns as $key => $value ) {
128
+            if( Str::startsWith( 'taxonomy', $key ) ) {
129 129
                 continue;
130 130
             }
131 131
             $columns[$key] = $key;
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
      * @return void
140 140
      * @action bulk_edit_custom_box
141 141
      */
142
-    public function renderBulkEditFields($columnName, $postType)
142
+    public function renderBulkEditFields( $columnName, $postType )
143 143
     {
144
-        if ('assigned_to' == $columnName && Application::POST_TYPE == $postType) {
145
-            glsr()->render('partials/editor/bulk-edit-assigned-to');
144
+        if( 'assigned_to' == $columnName && Application::POST_TYPE == $postType ) {
145
+            glsr()->render( 'partials/editor/bulk-edit-assigned-to' );
146 146
         }
147 147
     }
148 148
 
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
      * @return void
152 152
      * @action restrict_manage_posts
153 153
      */
154
-    public function renderColumnFilters($postType)
154
+    public function renderColumnFilters( $postType )
155 155
     {
156
-        glsr(Columns::class)->renderFilters($postType);
156
+        glsr( Columns::class )->renderFilters( $postType );
157 157
     }
158 158
 
159 159
     /**
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
      * @return void
163 163
      * @action manage_posts_custom_column
164 164
      */
165
-    public function renderColumnValues($column, $postId)
165
+    public function renderColumnValues( $column, $postId )
166 166
     {
167
-        glsr(Columns::class)->renderValues($column, $postId);
167
+        glsr( Columns::class )->renderValues( $column, $postId );
168 168
     }
169 169
 
170 170
     /**
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
      * @return void
173 173
      * @action save_post_.Application::POST_TYPE
174 174
      */
175
-    public function saveBulkEditFields($postId)
175
+    public function saveBulkEditFields( $postId )
176 176
     {
177
-        if (!current_user_can('edit_posts')) {
177
+        if( !current_user_can( 'edit_posts' ) ) {
178 178
             return;
179 179
         }
180
-        $assignedTo = filter_input(INPUT_GET, 'assigned_to');
181
-        if ($assignedTo && get_post($assignedTo)) {
182
-            glsr(Database::class)->update($postId, 'assigned_to', $assignedTo);
180
+        $assignedTo = filter_input( INPUT_GET, 'assigned_to' );
181
+        if( $assignedTo && get_post( $assignedTo ) ) {
182
+            glsr( Database::class )->update( $postId, 'assigned_to', $assignedTo );
183 183
         }
184 184
     }
185 185
 
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
      * @return void
188 188
      * @action pre_get_posts
189 189
      */
190
-    public function setQueryForColumn(WP_Query $query)
190
+    public function setQueryForColumn( WP_Query $query )
191 191
     {
192
-        if (!$this->hasPermission($query)) {
192
+        if( !$this->hasPermission( $query ) ) {
193 193
             return;
194 194
         }
195
-        $this->setMetaQuery($query, [
195
+        $this->setMetaQuery( $query, [
196 196
             'rating', 'review_type',
197
-        ]);
198
-        $this->setOrderby($query);
197
+        ] );
198
+        $this->setOrderby( $query );
199 199
     }
200 200
 
201 201
     /**
@@ -204,15 +204,15 @@  discard block
 block discarded – undo
204 204
      */
205 205
     public function unapprove()
206 206
     {
207
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
207
+        if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) {
208 208
             return;
209 209
         }
210
-        check_admin_referer('unapprove-review_'.($postId = $this->getPostId()));
211
-        wp_update_post([
210
+        check_admin_referer( 'unapprove-review_'.($postId = $this->getPostId()) );
211
+        wp_update_post( [
212 212
             'ID' => $postId,
213 213
             'post_status' => 'pending',
214
-        ]);
215
-        wp_safe_redirect(wp_get_referer());
214
+        ] );
215
+        wp_safe_redirect( wp_get_referer() );
216 216
         exit;
217 217
     }
218 218
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
      * @param string $domain
222 222
      * @return bool
223 223
      */
224
-    protected function canModifyTranslation($domain = 'default')
224
+    protected function canModifyTranslation( $domain = 'default' )
225 225
     {
226 226
         $screen = glsr_current_screen();
227 227
         return 'default' == $domain
@@ -232,48 +232,48 @@  discard block
 block discarded – undo
232 232
     /**
233 233
      * @return bool
234 234
      */
235
-    protected function hasPermission(WP_Query $query)
235
+    protected function hasPermission( WP_Query $query )
236 236
     {
237 237
         global $pagenow;
238 238
         return is_admin()
239 239
             && $query->is_main_query()
240
-            && Application::POST_TYPE == $query->get('post_type')
240
+            && Application::POST_TYPE == $query->get( 'post_type' )
241 241
             && 'edit.php' == $pagenow;
242 242
     }
243 243
 
244 244
     /**
245 245
      * @return void
246 246
      */
247
-    protected function setMetaQuery(WP_Query $query, array $metaKeys)
247
+    protected function setMetaQuery( WP_Query $query, array $metaKeys )
248 248
     {
249
-        foreach ($metaKeys as $key) {
250
-            $value = (string) filter_input(INPUT_GET, $key);
251
-            if ('' === $value) {
249
+        foreach( $metaKeys as $key ) {
250
+            $value = (string)filter_input( INPUT_GET, $key );
251
+            if( '' === $value ) {
252 252
                 continue;
253 253
             }
254
-            $metaQuery = (array) $query->get('meta_query');
254
+            $metaQuery = (array)$query->get( 'meta_query' );
255 255
             $metaQuery[] = [
256
-                'key' => Str::prefix('_', $key, '_'),
256
+                'key' => Str::prefix( '_', $key, '_' ),
257 257
                 'value' => $value,
258 258
             ];
259
-            $query->set('meta_query', array_filter($metaQuery));
259
+            $query->set( 'meta_query', array_filter( $metaQuery ) );
260 260
         }
261 261
     }
262 262
 
263 263
     /**
264 264
      * @return void
265 265
      */
266
-    protected function setOrderby(WP_Query $query)
266
+    protected function setOrderby( WP_Query $query )
267 267
     {
268
-        $orderby = $query->get('orderby');
268
+        $orderby = $query->get( 'orderby' );
269 269
         $columns = glsr()->postTypeColumns[Application::POST_TYPE];
270 270
         unset($columns['cb'], $columns['title'], $columns['date']);
271
-        if (in_array($orderby, array_keys($columns))) {
272
-            if ('reviewer' == $orderby) {
271
+        if( in_array( $orderby, array_keys( $columns ) ) ) {
272
+            if( 'reviewer' == $orderby ) {
273 273
                 $orderby = 'author';
274 274
             }
275
-            $query->set('meta_key', Str::prefix('_', $orderby, '_'));
276
-            $query->set('orderby', 'meta_value');
275
+            $query->set( 'meta_key', Str::prefix( '_', $orderby, '_' ) );
276
+            $query->set( 'orderby', 'meta_value' );
277 277
         }
278 278
     }
279 279
 }
Please login to merge, or discard this patch.