Passed
Push — master ( ae1954...aab291 )
by Paul
08:17 queued 04:15
created
plugin/Widgets/Widget.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -12,48 +12,48 @@
 block discarded – undo
12 12
      */
13 13
     protected $widgetArgs;
14 14
 
15
-    public function __construct($idBase, $name, $values)
15
+    public function __construct( $idBase, $name, $values )
16 16
     {
17 17
         $controlOptions = $widgetOptions = [];
18
-        if (isset($values['class'])) {
18
+        if( isset($values['class']) ) {
19 19
             $widgetOptions['classname'] = $values['class'];
20 20
         }
21
-        if (isset($values['description'])) {
21
+        if( isset($values['description']) ) {
22 22
             $widgetOptions['description'] = $values['description'];
23 23
         }
24
-        if (isset($values['width'])) {
24
+        if( isset($values['width']) ) {
25 25
             $controlOptions['width'] = $values['width'];
26 26
         }
27
-        parent::__construct($idBase, $name, $widgetOptions, $controlOptions);
27
+        parent::__construct( $idBase, $name, $widgetOptions, $controlOptions );
28 28
     }
29 29
 
30 30
     /**
31 31
      * @param string $tag
32 32
      * @return void
33 33
      */
34
-    protected function renderField($tag, array $args = [])
34
+    protected function renderField( $tag, array $args = [] )
35 35
     {
36
-        $args = $this->normalizeFieldAttributes($tag, $args);
37
-        $field = glsr(Builder::class)->$tag($args['name'], $args);
38
-        echo glsr(Builder::class)->div($field, [
36
+        $args = $this->normalizeFieldAttributes( $tag, $args );
37
+        $field = glsr( Builder::class )->$tag( $args['name'], $args );
38
+        echo glsr( Builder::class )->div( $field, [
39 39
             'class' => 'glsr-field',
40
-        ]);
40
+        ] );
41 41
     }
42 42
 
43 43
     /**
44 44
      * @param string $tag
45 45
      * @return array
46 46
      */
47
-    protected function normalizeFieldAttributes($tag, array $args)
47
+    protected function normalizeFieldAttributes( $tag, array $args )
48 48
     {
49
-        if (empty($args['value'])) {
49
+        if( empty($args['value']) ) {
50 50
             $args['value'] = $this->widgetArgs[$args['name']];
51 51
         }
52
-        if (empty($this->widgetArgs['options']) && in_array($tag, ['checkbox', 'radio'])) {
53
-            $args['checked'] = in_array($args['value'], (array) $this->widgetArgs[$args['name']]);
52
+        if( empty($this->widgetArgs['options']) && in_array( $tag, ['checkbox', 'radio'] ) ) {
53
+            $args['checked'] = in_array( $args['value'], (array)$this->widgetArgs[$args['name']] );
54 54
         }
55
-        $args['id'] = $this->get_field_id($args['name']);
56
-        $args['name'] = $this->get_field_name($args['name']);
55
+        $args['id'] = $this->get_field_id( $args['name'] );
56
+        $args['name'] = $this->get_field_name( $args['name'] );
57 57
         $args['is_widget'] = true;
58 58
         return $args;
59 59
     }
Please login to merge, or discard this patch.
plugin/Modules/Html/ReviewHtml.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
      */
18 18
     public $values;
19 19
 
20
-    public function __construct(Review $review, array $values = [])
20
+    public function __construct( Review $review, array $values = [] )
21 21
     {
22 22
         $this->review = $review;
23 23
         $this->values = $values;
24
-        parent::__construct($values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
24
+        parent::__construct( $values, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS );
25 25
     }
26 26
 
27 27
     /**
@@ -29,25 +29,25 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public function __toString()
31 31
     {
32
-        if (empty($this->values)) {
32
+        if( empty($this->values) ) {
33 33
             return;
34 34
         }
35
-        return glsr(Template::class)->build('templates/review', [
35
+        return glsr( Template::class )->build( 'templates/review', [
36 36
             'context' => $this->values,
37 37
             'review' => $this->review,
38
-        ]);
38
+        ] );
39 39
     }
40 40
 
41 41
     /**
42 42
      * @param mixed $key
43 43
      * @return mixed
44 44
      */
45
-    public function offsetGet($key)
45
+    public function offsetGet( $key )
46 46
     {
47
-        if (property_exists($this, $key)) {
47
+        if( property_exists( $this, $key ) ) {
48 48
             return $this->$key;
49 49
         }
50
-        return array_key_exists($key, $this->values)
50
+        return array_key_exists( $key, $this->values )
51 51
             ? $this->values[$key]
52 52
             : null;
53 53
     }
Please login to merge, or discard this patch.
plugin/Modules/Html/ReviewsHtml.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
      */
28 28
     public $reviews;
29 29
 
30
-    public function __construct(array $reviews, $maxPageCount, array $args)
30
+    public function __construct( array $reviews, $maxPageCount, array $args )
31 31
     {
32 32
         $this->args = $args;
33 33
         $this->max_num_pages = $maxPageCount;
34 34
         $this->reviews = $reviews;
35 35
         $this->pagination = $this->buildPagination();
36
-        parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
36
+        parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS );
37 37
     }
38 38
 
39 39
     /**
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function __toString()
43 43
     {
44
-        return glsr(Template::class)->build('templates/reviews', [
44
+        return glsr( Template::class )->build( 'templates/reviews', [
45 45
             'args' => $this->args,
46 46
             'context' => [
47 47
                 'assigned_to' => $this->args['assigned_to'],
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
                 'pagination' => $this->getPagination(),
52 52
                 'reviews' => $this->getReviews(),
53 53
             ],
54
-        ]);
54
+        ] );
55 55
     }
56 56
 
57 57
     /**
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function getPagination()
61 61
     {
62
-        return wp_validate_boolean($this->args['pagination'])
62
+        return wp_validate_boolean( $this->args['pagination'] )
63 63
             ? $this->pagination
64 64
             : '';
65 65
     }
@@ -71,26 +71,26 @@  discard block
 block discarded – undo
71 71
     {
72 72
         $html = empty($this->reviews)
73 73
             ? $this->getReviewsFallback()
74
-            : implode(PHP_EOL, $this->reviews);
74
+            : implode( PHP_EOL, $this->reviews );
75 75
         $wrapper = '<div class="glsr-reviews">%s</div>';
76
-        $wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper);
77
-        return sprintf($wrapper, $html);
76
+        $wrapper = apply_filters( 'site-reviews/reviews/reviews-wrapper', $wrapper );
77
+        return sprintf( $wrapper, $html );
78 78
     }
79 79
 
80 80
     /**
81 81
      * @param mixed $key
82 82
      * @return mixed
83 83
      */
84
-    public function offsetGet($key)
84
+    public function offsetGet( $key )
85 85
     {
86
-        if ('navigation' == $key) {
86
+        if( 'navigation' == $key ) {
87 87
             glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.';
88 88
             return $this->pagination;
89 89
         }
90
-        if (property_exists($this, $key)) {
90
+        if( property_exists( $this, $key ) ) {
91 91
             return $this->$key;
92 92
         }
93
-        return array_key_exists($key, $this->reviews)
93
+        return array_key_exists( $key, $this->reviews )
94 94
             ? $this->reviews[$key]
95 95
             : null;
96 96
     }
@@ -100,15 +100,15 @@  discard block
 block discarded – undo
100 100
      */
101 101
     protected function buildPagination()
102 102
     {
103
-        $html = glsr(Partial::class)->build('pagination', [
104
-            'baseUrl' => glsr_get($this->args, 'pagedUrl'),
105
-            'current' => glsr_get($this->args, 'paged'),
103
+        $html = glsr( Partial::class )->build( 'pagination', [
104
+            'baseUrl' => glsr_get( $this->args, 'pagedUrl' ),
105
+            'current' => glsr_get( $this->args, 'paged' ),
106 106
             'total' => $this->max_num_pages,
107
-        ]);
108
-        $html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']);
107
+        ] );
108
+        $html .= sprintf( '<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json'] );
109 109
         $wrapper = '<div class="glsr-pagination">%s</div>';
110
-        $wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper);
111
-        return sprintf($wrapper, $html);
110
+        $wrapper = apply_filters( 'site-reviews/reviews/pagination-wrapper', $wrapper );
111
+        return sprintf( $wrapper, $html );
112 112
     }
113 113
 
114 114
     /**
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
         $defaults = [
120 120
             'glsr-default',
121 121
         ];
122
-        if ('ajax' == $this->args['pagination']) {
122
+        if( 'ajax' == $this->args['pagination'] ) {
123 123
             $defaults[] = 'glsr-ajax-pagination';
124 124
         }
125
-        $classes = explode(' ', $this->args['class']);
126
-        $classes = array_unique(array_merge($defaults, array_filter($classes)));
127
-        return implode(' ', $classes);
125
+        $classes = explode( ' ', $this->args['class'] );
126
+        $classes = array_unique( array_merge( $defaults, array_filter( $classes ) ) );
127
+        return implode( ' ', $classes );
128 128
     }
129 129
 
130 130
     /**
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
      */
133 133
     protected function getReviewsFallback()
134 134
     {
135
-        if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) {
136
-            $this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews');
135
+        if( empty($this->args['fallback']) && glsr( OptionManager::class )->getBool( 'settings.reviews.fallback' ) ) {
136
+            $this->args['fallback'] = __( 'There are no reviews yet. Be the first one to write one.', 'site-reviews' );
137 137
         }
138 138
         $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>';
139
-        return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args);
139
+        return apply_filters( 'site-reviews/reviews/fallback', $fallback, $this->args );
140 140
     }
141 141
 }
Please login to merge, or discard this patch.
plugin/Modules/System.php 1 patch
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -39,17 +39,17 @@  discard block
 block discarded – undo
39 39
             'setting' => 'Plugin Settings',
40 40
             'reviews' => 'Review Counts',
41 41
         ];
42
-        $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
43
-            $methodName = glsr(Helper::class)->buildMethodName('get-'.$key.'-details');
44
-            if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
42
+        $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use ($details) {
43
+            $methodName = glsr( Helper::class )->buildMethodName( 'get-'.$key.'-details' );
44
+            if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) {
45 45
                 return $carry.$this->implode(
46
-                    strtoupper($details[$key]),
47
-                    apply_filters('site-reviews/system/'.$key, $systemDetails)
46
+                    strtoupper( $details[$key] ),
47
+                    apply_filters( 'site-reviews/system/'.$key, $systemDetails )
48 48
                 );
49 49
             }
50 50
             return $carry;
51 51
         });
52
-        return trim($systemInfo);
52
+        return trim( $systemInfo );
53 53
     }
54 54
 
55 55
     /**
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
     public function getActivePluginDetails()
59 59
     {
60 60
         $plugins = get_plugins();
61
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
62
-        $inactive = array_diff_key($plugins, array_flip($activePlugins));
63
-        return $this->normalizePluginList(array_diff_key($plugins, $inactive));
61
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
62
+        $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) );
63
+        return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
64 64
     }
65 65
 
66 66
     /**
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function getAddonDetails()
70 70
     {
71
-        $details = apply_filters('site-reviews/addon/system-info', []);
72
-        ksort($details);
71
+        $details = apply_filters( 'site-reviews/addon/system-info', [] );
72
+        ksort( $details );
73 73
         return $details;
74 74
     }
75 75
 
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
     public function getBrowserDetails()
80 80
     {
81 81
         $browser = new Browser();
82
-        $name = esc_attr($browser->getName());
83
-        $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
84
-        $version = esc_attr($browser->getVersion());
82
+        $name = esc_attr( $browser->getName() );
83
+        $userAgent = esc_attr( $browser->getUserAgent()->getUserAgentString() );
84
+        $version = esc_attr( $browser->getVersion() );
85 85
         return [
86
-            'Browser Name' => sprintf('%s %s', $name, $version),
86
+            'Browser Name' => sprintf( '%s %s', $name, $version ),
87 87
             'Browser UA' => $userAgent,
88 88
         ];
89 89
     }
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function getInactivePluginDetails()
95 95
     {
96
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
97
-        $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
96
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
97
+        $inactivePlugins = $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) );
98 98
         $multisitePlugins = $this->getMultisitePluginDetails();
99 99
         return empty($multisitePlugins)
100 100
             ? $inactivePlugins
101
-            : array_diff($inactivePlugins, $multisitePlugins);
101
+            : array_diff( $inactivePlugins, $multisitePlugins );
102 102
     }
103 103
 
104 104
     /**
@@ -106,10 +106,10 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public function getMuPluginDetails()
108 108
     {
109
-        if (empty($plugins = get_mu_plugins())) {
109
+        if( empty($plugins = get_mu_plugins()) ) {
110 110
             return [];
111 111
         }
112
-        return $this->normalizePluginList($plugins);
112
+        return $this->normalizePluginList( $plugins );
113 113
     }
114 114
 
115 115
     /**
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
      */
118 118
     public function getMultisitePluginDetails()
119 119
     {
120
-        $activePlugins = (array) get_site_option('active_sitewide_plugins', []);
121
-        if (!is_multisite() || empty($activePlugins)) {
120
+        $activePlugins = (array)get_site_option( 'active_sitewide_plugins', [] );
121
+        if( !is_multisite() || empty($activePlugins) ) {
122 122
             return [];
123 123
         }
124
-        return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
124
+        return $this->normalizePluginList( array_intersect_key( get_plugins(), $activePlugins ) );
125 125
     }
126 126
 
127 127
     /**
@@ -129,31 +129,31 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function getPhpDetails()
131 131
     {
132
-        $displayErrors = ini_get('display_errors')
133
-            ? 'On ('.ini_get('display_errors').')'
132
+        $displayErrors = ini_get( 'display_errors' )
133
+            ? 'On ('.ini_get( 'display_errors' ).')'
134 134
             : 'N/A';
135
-        $intlSupport = extension_loaded('intl')
136
-            ? phpversion('intl')
135
+        $intlSupport = extension_loaded( 'intl' )
136
+            ? phpversion( 'intl' )
137 137
             : 'false';
138 138
         return [
139
-            'cURL' => var_export(function_exists('curl_init'), true),
140
-            'Default Charset' => ini_get('default_charset'),
139
+            'cURL' => var_export( function_exists( 'curl_init' ), true ),
140
+            'Default Charset' => ini_get( 'default_charset' ),
141 141
             'Display Errors' => $displayErrors,
142
-            'fsockopen' => var_export(function_exists('fsockopen'), true),
142
+            'fsockopen' => var_export( function_exists( 'fsockopen' ), true ),
143 143
             'Intl' => $intlSupport,
144
-            'IPv6' => var_export(defined('AF_INET6'), true),
145
-            'Max Execution Time' => ini_get('max_execution_time'),
146
-            'Max Input Nesting Level' => ini_get('max_input_nesting_level'),
147
-            'Max Input Vars' => ini_get('max_input_vars'),
148
-            'Memory Limit' => ini_get('memory_limit'),
149
-            'Post Max Size' => ini_get('post_max_size'),
150
-            'Sendmail Path' => ini_get('sendmail_path'),
151
-            'Session Cookie Path' => esc_html(ini_get('session.cookie_path')),
152
-            'Session Name' => esc_html(ini_get('session.name')),
153
-            'Session Save Path' => esc_html(ini_get('session.save_path')),
154
-            'Session Use Cookies' => var_export(wp_validate_boolean(ini_get('session.use_cookies')), true),
155
-            'Session Use Only Cookies' => var_export(wp_validate_boolean(ini_get('session.use_only_cookies')), true),
156
-            'Upload Max Filesize' => ini_get('upload_max_filesize'),
144
+            'IPv6' => var_export( defined( 'AF_INET6' ), true ),
145
+            'Max Execution Time' => ini_get( 'max_execution_time' ),
146
+            'Max Input Nesting Level' => ini_get( 'max_input_nesting_level' ),
147
+            'Max Input Vars' => ini_get( 'max_input_vars' ),
148
+            'Memory Limit' => ini_get( 'memory_limit' ),
149
+            'Post Max Size' => ini_get( 'post_max_size' ),
150
+            'Sendmail Path' => ini_get( 'sendmail_path' ),
151
+            'Session Cookie Path' => esc_html( ini_get( 'session.cookie_path' ) ),
152
+            'Session Name' => esc_html( ini_get( 'session.name' ) ),
153
+            'Session Save Path' => esc_html( ini_get( 'session.save_path' ) ),
154
+            'Session Use Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_cookies' ) ), true ),
155
+            'Session Use Only Cookies' => var_export( wp_validate_boolean( ini_get( 'session.use_only_cookies' ) ), true ),
156
+            'Upload Max Filesize' => ini_get( 'upload_max_filesize' ),
157 157
         ];
158 158
     }
159 159
 
@@ -162,19 +162,19 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function getReviewsDetails()
164 164
     {
165
-        $counts = glsr(CountsManager::class)->getCounts();
166
-        $counts = glsr(Helper::class)->flattenArray($counts);
167
-        array_walk($counts, function (&$ratings) use ($counts) {
168
-            if (!is_array($ratings)) {
165
+        $counts = glsr( CountsManager::class )->getCounts();
166
+        $counts = glsr( Helper::class )->flattenArray( $counts );
167
+        array_walk( $counts, function( &$ratings ) use ($counts) {
168
+            if( !is_array( $ratings ) ) {
169 169
                 glsr_log()
170
-                    ->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
171
-                    ->debug($ratings)
172
-                    ->debug($counts);
170
+                    ->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' )
171
+                    ->debug( $ratings )
172
+                    ->debug( $counts );
173 173
                 return;
174 174
             }
175
-            $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
175
+            $ratings = array_sum( $ratings ).' ('.implode( ', ', $ratings ).')';
176 176
         });
177
-        ksort($counts);
177
+        ksort( $counts );
178 178
         return $counts;
179 179
     }
180 180
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
             'Host Name' => $this->getHostName(),
189 189
             'MySQL Version' => $wpdb->db_version(),
190 190
             'PHP Version' => PHP_VERSION,
191
-            'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
191
+            'Server Software' => filter_input( INPUT_SERVER, 'SERVER_SOFTWARE' ),
192 192
         ];
193 193
     }
194 194
 
@@ -197,17 +197,17 @@  discard block
 block discarded – undo
197 197
      */
198 198
     public function getSettingDetails()
199 199
     {
200
-        $helper = glsr(Helper::class);
201
-        $settings = glsr(OptionManager::class)->get('settings', []);
202
-        $settings = $helper->flattenArray($settings, true);
203
-        $settings = $this->purgeSensitiveData($settings);
204
-        ksort($settings);
200
+        $helper = glsr( Helper::class );
201
+        $settings = glsr( OptionManager::class )->get( 'settings', [] );
202
+        $settings = $helper->flattenArray( $settings, true );
203
+        $settings = $this->purgeSensitiveData( $settings );
204
+        ksort( $settings );
205 205
         $details = [];
206
-        foreach ($settings as $key => $value) {
207
-            if ($helper->startsWith('strings', $key) && $helper->endsWith('id', $key)) {
206
+        foreach( $settings as $key => $value ) {
207
+            if( $helper->startsWith( 'strings', $key ) && $helper->endsWith( 'id', $key ) ) {
208 208
                 continue;
209 209
             }
210
-            $value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
210
+            $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' );
211 211
             $details[$key] = $value;
212 212
         }
213 213
         return $details;
@@ -219,11 +219,11 @@  discard block
 block discarded – undo
219 219
     public function getPluginDetails()
220 220
     {
221 221
         return [
222
-            'Console level' => glsr(Console::class)->humanLevel(),
223
-            'Console size' => glsr(Console::class)->humanSize('0'),
224
-            'Last Rating Count' => date_i18n('Y-m-d H:i', glsr(OptionManager::class)->get('last_review_count')),
222
+            'Console level' => glsr( Console::class )->humanLevel(),
223
+            'Console size' => glsr( Console::class )->humanSize( '0' ),
224
+            'Last Rating Count' => date_i18n( 'Y-m-d H:i', glsr( OptionManager::class )->get( 'last_review_count' ) ),
225 225
             'Version (current)' => glsr()->version,
226
-            'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
226
+            'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ),
227 227
         ];
228 228
     }
229 229
 
@@ -235,23 +235,23 @@  discard block
 block discarded – undo
235 235
         global $wpdb;
236 236
         $theme = wp_get_theme();
237 237
         return [
238
-            'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
239
-            'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
238
+            'Active Theme' => sprintf( '%s v%s', (string)$theme->Name, (string)$theme->Version ),
239
+            'Email Domain' => substr( strrchr( glsr( OptionManager::class )->getWP( 'admin_email' ), '@' ), 1 ),
240 240
             'Home URL' => home_url(),
241 241
             'Language' => get_locale(),
242 242
             'Memory Limit' => WP_MEMORY_LIMIT,
243
-            'Multisite' => var_export(is_multisite(), true),
244
-            'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
245
-            'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
246
-            'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
247
-            'Post Stati' => implode(', ', get_post_stati()),
248
-            'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
249
-            'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
243
+            'Multisite' => var_export( is_multisite(), true ),
244
+            'Page For Posts ID' => glsr( OptionManager::class )->getWP( 'page_for_posts' ),
245
+            'Page On Front ID' => glsr( OptionManager::class )->getWP( 'page_on_front' ),
246
+            'Permalink Structure' => glsr( OptionManager::class )->getWP( 'permalink_structure', 'default' ),
247
+            'Post Stati' => implode( ', ', get_post_stati() ),
248
+            'Remote Post' => glsr( Cache::class )->getRemotePostTest(),
249
+            'Show On Front' => glsr( OptionManager::class )->getWP( 'show_on_front' ),
250 250
             'Site URL' => site_url(),
251
-            'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', ini_get('date.timezone').' (PHP)'),
252
-            'Version' => get_bloginfo('version'),
253
-            'WP Debug' => var_export(defined('WP_DEBUG'), true),
254
-            'WP Max Upload Size' => size_format(wp_max_upload_size()),
251
+            'Timezone' => glsr( OptionManager::class )->getWP( 'timezone_string', ini_get( 'date.timezone' ).' (PHP)' ),
252
+            'Version' => get_bloginfo( 'version' ),
253
+            'WP Debug' => var_export( defined( 'WP_DEBUG' ), true ),
254
+            'WP Max Upload Size' => size_format( wp_max_upload_size() ),
255 255
             'WP Memory Limit' => WP_MEMORY_LIMIT,
256 256
         ];
257 257
     }
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
             'secureserver.net' => 'GoDaddy',
282 282
             'WPE_APIKEY' => 'WP Engine',
283 283
         ];
284
-        foreach ($checks as $key => $value) {
285
-            if (!$this->isWebhostCheckValid($key)) {
284
+        foreach( $checks as $key => $value ) {
285
+            if( !$this->isWebhostCheckValid( $key ) ) {
286 286
                 continue;
287 287
             }
288 288
             return $value;
289 289
         }
290
-        return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
290
+        return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) );
291 291
     }
292 292
 
293 293
     /**
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
      */
296 296
     protected function getHostName()
297 297
     {
298
-        return sprintf('%s (%s)',
298
+        return sprintf( '%s (%s)',
299 299
             $this->detectWebhostProvider(),
300
-            glsr(Helper::class)->getIpAddress()
300
+            glsr( Helper::class )->getIpAddress()
301 301
         );
302 302
     }
303 303
 
@@ -307,9 +307,9 @@  discard block
 block discarded – undo
307 307
     protected function getWordpressPlugins()
308 308
     {
309 309
         $plugins = get_plugins();
310
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
311
-        $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
312
-        $active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
310
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
311
+        $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) );
312
+        $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
313 313
         return $active + $inactive;
314 314
     }
315 315
 
@@ -317,48 +317,48 @@  discard block
 block discarded – undo
317 317
      * @param string $title
318 318
      * @return string
319 319
      */
320
-    protected function implode($title, array $details)
320
+    protected function implode( $title, array $details )
321 321
     {
322 322
         $strings = ['['.$title.']'];
323
-        $padding = max(array_map('strlen', array_keys($details)));
324
-        $padding = max([$padding, static::PAD]);
325
-        foreach ($details as $key => $value) {
326
-            $strings[] = is_string($key)
327
-                ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
323
+        $padding = max( array_map( 'strlen', array_keys( $details ) ) );
324
+        $padding = max( [$padding, static::PAD] );
325
+        foreach( $details as $key => $value ) {
326
+            $strings[] = is_string( $key )
327
+                ? sprintf( '%s : %s', str_pad( $key, $padding, '.' ), $value )
328 328
                 : ' - '.$value;
329 329
         }
330
-        return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
330
+        return implode( PHP_EOL, $strings ).PHP_EOL.PHP_EOL;
331 331
     }
332 332
 
333 333
     /**
334 334
      * @param string $key
335 335
      * @return bool
336 336
      */
337
-    protected function isWebhostCheckValid($key)
337
+    protected function isWebhostCheckValid( $key )
338 338
     {
339
-        return defined($key)
340
-            || filter_input(INPUT_SERVER, $key)
341
-            || false !== strpos(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
342
-            || false !== strpos(DB_HOST, $key)
343
-            || false !== strpos(php_uname(), $key);
339
+        return defined( $key )
340
+            || filter_input( INPUT_SERVER, $key )
341
+            || false !== strpos( filter_input( INPUT_SERVER, 'SERVER_NAME' ), $key )
342
+            || false !== strpos( DB_HOST, $key )
343
+            || false !== strpos( php_uname(), $key );
344 344
     }
345 345
 
346 346
     /**
347 347
      * @return array
348 348
      */
349
-    protected function normalizePluginList(array $plugins)
349
+    protected function normalizePluginList( array $plugins )
350 350
     {
351
-        $plugins = array_map(function ($plugin) {
352
-            return sprintf('%s v%s', glsr_get($plugin, 'Name'), glsr_get($plugin, 'Version'));
353
-        }, $plugins);
354
-        natcasesort($plugins);
355
-        return array_flip($plugins);
351
+        $plugins = array_map( function( $plugin ) {
352
+            return sprintf( '%s v%s', glsr_get( $plugin, 'Name' ), glsr_get( $plugin, 'Version' ) );
353
+        }, $plugins );
354
+        natcasesort( $plugins );
355
+        return array_flip( $plugins );
356 356
     }
357 357
 
358 358
     /**
359 359
      * @return array
360 360
      */
361
-    protected function purgeSensitiveData(array $settings)
361
+    protected function purgeSensitiveData( array $settings )
362 362
     {
363 363
         $keys = [
364 364
             'general.rebusify_serial',
@@ -366,12 +366,12 @@  discard block
 block discarded – undo
366 366
             'submissions.recaptcha.key',
367 367
             'submissions.recaptcha.secret',
368 368
         ];
369
-        array_walk($settings, function (&$value, $setting) use ($keys) {
370
-            foreach ($keys as $key) {
371
-                if (!glsr(Helper::class)->startsWith($key, $setting) || empty($value)) {
369
+        array_walk( $settings, function( &$value, $setting ) use ($keys) {
370
+            foreach( $keys as $key ) {
371
+                if( !glsr( Helper::class )->startsWith( $key, $setting ) || empty($value) ) {
372 372
                     continue;
373 373
                 }
374
-                $value = str_repeat('•', 13);
374
+                $value = str_repeat( '•', 13 );
375 375
                 return;
376 376
             }
377 377
         });
Please login to merge, or discard this patch.
plugin/Modules/Rebusify.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -19,25 +19,25 @@  discard block
 block discarded – undo
19 19
     /**
20 20
      * @return mixed
21 21
      */
22
-    public function __get($key)
22
+    public function __get( $key )
23 23
     {
24
-        return property_exists($this, $key)
24
+        return property_exists( $this, $key )
25 25
             ? $this->$key
26
-            : glsr_get($this->response, $key, null);
26
+            : glsr_get( $this->response, $key, null );
27 27
     }
28 28
 
29 29
     /**
30 30
      * @return self
31 31
      */
32
-    public function activateKey($apiKey = '', $email = '')
32
+    public function activateKey( $apiKey = '', $email = '' )
33 33
     {
34
-        $this->send('api_key_activation.php', [
34
+        $this->send( 'api_key_activation.php', [
35 35
             'body' => [
36 36
                 'apikey' => $apiKey ?: 0,
37 37
                 'domain' => get_home_url(),
38 38
                 'email' => $email ?: 0,
39 39
             ],
40
-        ]);
40
+        ] );
41 41
         return $this;
42 42
     }
43 43
 
@@ -55,77 +55,77 @@  discard block
 block discarded – undo
55 55
     /**
56 56
      * @return self
57 57
      */
58
-    public function sendReview(Review $review)
58
+    public function sendReview( Review $review )
59 59
     {
60
-        $this->send('index.php', [
61
-            'body' => $this->getBodyForReview($review),
60
+        $this->send( 'index.php', [
61
+            'body' => $this->getBodyForReview( $review ),
62 62
             'timeout' => 120,
63
-        ]);
63
+        ] );
64 64
         return $this;
65 65
     }
66 66
 
67 67
     /**
68 68
      * @return self
69 69
      */
70
-    public function sendReviewResponse(Review $review)
70
+    public function sendReviewResponse( Review $review )
71 71
     {
72
-        $this->send('fetch_customer_reply.php', [
73
-            'body' => $this->getBodyForResponse($review),
74
-        ]);
72
+        $this->send( 'fetch_customer_reply.php', [
73
+            'body' => $this->getBodyForResponse( $review ),
74
+        ] );
75 75
         return $this;
76 76
     }
77 77
 
78 78
     /**
79 79
      * @return array
80 80
      */
81
-    protected function getBodyForResponse(Review $review)
81
+    protected function getBodyForResponse( Review $review )
82 82
     {
83 83
         $rebusifyResponse = [
84
-            'reply' => glsr(Helper::class)->truncate($review->response, 300),
85
-            'review_id' => glsr(Database::class)->get($review->ID, 'rebusify'), // this is the rebusify review ID
84
+            'reply' => glsr( Helper::class )->truncate( $review->response, 300 ),
85
+            'review_id' => glsr( Database::class )->get( $review->ID, 'rebusify' ), // this is the rebusify review ID
86 86
             'review_transaction_id' => $review->review_id,
87 87
             'type' => 'M',
88 88
         ];
89
-        return apply_filters('site-reviews/rebusify/response', $rebusifyResponse, $review);
89
+        return apply_filters( 'site-reviews/rebusify/response', $rebusifyResponse, $review );
90 90
     }
91 91
 
92 92
     /**
93 93
      * @return array
94 94
      */
95
-    protected function getBodyForReview(Review $review)
95
+    protected function getBodyForReview( Review $review )
96 96
     {
97 97
         $rebusifyReview = [
98 98
             'domain' => get_home_url(),
99
-            'firstname' => glsr(Helper::class)->truncate(glsr(Helper::class)->convertName($review->author, 'first'), 25),
99
+            'firstname' => glsr( Helper::class )->truncate( glsr( Helper::class )->convertName( $review->author, 'first' ), 25 ),
100 100
             'rate' => $review->rating,
101 101
             'review_transaction_id' => $review->review_id,
102
-            'reviews' => glsr(Helper::class)->truncate($review->content, 280),
103
-            'title' => glsr(Helper::class)->truncate($review->title, 35),
102
+            'reviews' => glsr( Helper::class )->truncate( $review->content, 280 ),
103
+            'title' => glsr( Helper::class )->truncate( $review->title, 35 ),
104 104
             'transaction' => Application::ID, // woocommerce field, not needed for Site Reviews
105 105
         ];
106
-        return apply_filters('site-reviews/rebusify/review', $rebusifyReview, $review);
106
+        return apply_filters( 'site-reviews/rebusify/review', $rebusifyReview, $review );
107 107
     }
108 108
 
109 109
     /**
110 110
      * @param \WP_Error|array $response
111 111
      * @return void
112 112
      */
113
-    protected function handleResponse($response)
113
+    protected function handleResponse( $response )
114 114
     {
115
-        if (is_wp_error($response)) {
115
+        if( is_wp_error( $response ) ) {
116 116
             $this->message = $response->get_error_message();
117 117
         } else {
118
-            $responseBody = wp_remote_retrieve_body($response);
119
-            $responseCode = wp_remote_retrieve_response_code($response);
120
-            $responseData = (array) json_decode($responseBody, true);
121
-            $this->response = array_shift($responseData);
122
-            $this->message = glsr_get($this->response, 'msg');
123
-            $this->success = 'success' === glsr_get($this->response, 'result') || 'yes' === glsr_get($this->response, 'success'); // @todo remove this ugly hack!
124
-            if (200 !== $responseCode) {
125
-                glsr_log()->error('Bad response code ['.$responseCode.']');
118
+            $responseBody = wp_remote_retrieve_body( $response );
119
+            $responseCode = wp_remote_retrieve_response_code( $response );
120
+            $responseData = (array)json_decode( $responseBody, true );
121
+            $this->response = array_shift( $responseData );
122
+            $this->message = glsr_get( $this->response, 'msg' );
123
+            $this->success = 'success' === glsr_get( $this->response, 'result' ) || 'yes' === glsr_get( $this->response, 'success' ); // @todo remove this ugly hack!
124
+            if( 200 !== $responseCode ) {
125
+                glsr_log()->error( 'Bad response code ['.$responseCode.']' );
126 126
             }
127
-            if (!$this->success) {
128
-                glsr_log()->error($this->message);
127
+            if( !$this->success ) {
128
+                glsr_log()->error( $this->message );
129 129
             }
130 130
         }
131 131
     }
@@ -134,18 +134,18 @@  discard block
 block discarded – undo
134 134
      * @param string $endpoint
135 135
      * @return void
136 136
      */
137
-    protected function send($endpoint, array $args = [])
137
+    protected function send( $endpoint, array $args = [] )
138 138
     {
139
-        $args = wp_parse_args($args, [
139
+        $args = wp_parse_args( $args, [
140 140
             'body' => null,
141 141
             'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
142 142
             'redirection' => 5,
143 143
             'sslverify' => false,
144 144
             'timeout' => 5,
145
-        ]);
145
+        ] );
146 146
         $this->reset();
147 147
         $this->handleResponse(
148
-            wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args)
148
+            wp_remote_post( trailingslashit( static::API_URL ).$endpoint, $args )
149 149
         );
150 150
     }
151 151
 }
Please login to merge, or discard this patch.
plugin/Database/CountsManager.php 1 patch
Spacing   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -20,26 +20,26 @@  discard block
 block discarded – undo
20 20
      * @return array
21 21
      * @todo verify the additional type checks are needed
22 22
      */
23
-    public function buildCounts(array $args = [])
23
+    public function buildCounts( array $args = [] )
24 24
     {
25 25
         $counts = [];
26
-        $query = $this->queryReviews($args);
27
-        while ($query) {
28
-            $types = array_keys(array_flip(glsr_array_column($query->reviews, 'type')));
29
-            $types = array_unique(array_merge(['local'], $types));
30
-            foreach ($types as $type) {
31
-                $type = $this->normalizeType($type);
32
-                if (isset($counts[$type])) {
26
+        $query = $this->queryReviews( $args );
27
+        while( $query ) {
28
+            $types = array_keys( array_flip( glsr_array_column( $query->reviews, 'type' ) ) );
29
+            $types = array_unique( array_merge( ['local'], $types ) );
30
+            foreach( $types as $type ) {
31
+                $type = $this->normalizeType( $type );
32
+                if( isset($counts[$type]) ) {
33 33
                     continue;
34 34
             }
35
-                $counts[$type] = array_fill_keys(range(0, glsr()->constant('MAX_RATING', Rating::class)), 0);
35
+                $counts[$type] = array_fill_keys( range( 0, glsr()->constant( 'MAX_RATING', Rating::class ) ), 0 );
36 36
             }
37
-            foreach ($query->reviews as $review) {
38
-                $type = $this->normalizeType($review->type);
37
+            foreach( $query->reviews as $review ) {
38
+                $type = $this->normalizeType( $review->type );
39 39
                 ++$counts[$type][$review->rating];
40 40
             }
41 41
             $query = $query->has_more
42
-                ? $this->queryReviews($args, end($query->reviews)->ID)
42
+                ? $this->queryReviews( $args, end( $query->reviews )->ID )
43 43
                 : false;
44 44
         }
45 45
         return $counts;
@@ -49,18 +49,18 @@  discard block
 block discarded – undo
49 49
      * @param int $postId
50 50
      * @return array
51 51
      */
52
-    public function buildPostCounts($postId)
52
+    public function buildPostCounts( $postId )
53 53
     {
54
-        return $this->buildCounts(['post_ids' => [$postId]]);
54
+        return $this->buildCounts( ['post_ids' => [$postId]] );
55 55
     }
56 56
 
57 57
     /**
58 58
      * @param int $termTaxonomyId
59 59
      * @return array
60 60
      */
61
-    public function buildTermCounts($termTaxonomyId)
61
+    public function buildTermCounts( $termTaxonomyId )
62 62
     {
63
-        return $this->buildCounts(['term_ids' => [$termTaxonomyId]]);
63
+        return $this->buildCounts( ['term_ids' => [$termTaxonomyId]] );
64 64
     }
65 65
 
66 66
     /**
@@ -68,80 +68,80 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function countAll()
70 70
     {
71
-        $terms = glsr(Database::class)->getTerms(['fields' => 'all']);
72
-        foreach ($terms as $term) {
73
-            $this->setTermCounts($term->term_id, $this->buildTermCounts($term->term_taxonomy_id));
71
+        $terms = glsr( Database::class )->getTerms( ['fields' => 'all'] );
72
+        foreach( $terms as $term ) {
73
+            $this->setTermCounts( $term->term_id, $this->buildTermCounts( $term->term_taxonomy_id ) );
74 74
         }
75
-        $postIds = glsr(SqlQueries::class)->getReviewsMeta('assigned_to');
76
-        foreach ($postIds as $postId) {
77
-            $this->setPostCounts($postId, $this->buildPostCounts($postId));
75
+        $postIds = glsr( SqlQueries::class )->getReviewsMeta( 'assigned_to' );
76
+        foreach( $postIds as $postId ) {
77
+            $this->setPostCounts( $postId, $this->buildPostCounts( $postId ) );
78 78
         }
79
-        $this->setCounts($this->buildCounts());
79
+        $this->setCounts( $this->buildCounts() );
80 80
     }
81 81
 
82 82
     /**
83 83
      * @return void
84 84
      */
85
-    public function decrease(Review $review)
85
+    public function decrease( Review $review )
86 86
     {
87
-        $this->decreaseCounts($review);
88
-        $this->decreasePostCounts($review);
89
-        $this->decreaseTermCounts($review);
87
+        $this->decreaseCounts( $review );
88
+        $this->decreasePostCounts( $review );
89
+        $this->decreaseTermCounts( $review );
90 90
     }
91 91
 
92 92
     /**
93 93
      * @return void
94 94
      */
95
-    public function decreaseCounts(Review $review)
95
+    public function decreaseCounts( Review $review )
96 96
     {
97
-        $this->setCounts($this->decreaseRating(
97
+        $this->setCounts( $this->decreaseRating(
98 98
             $this->getCounts(),
99 99
             $review->review_type,
100 100
             $review->rating
101
-        ));
101
+        ) );
102 102
     }
103 103
 
104 104
     /**
105 105
      * @return void
106 106
      */
107
-    public function decreasePostCounts(Review $review)
107
+    public function decreasePostCounts( Review $review )
108 108
     {
109
-        if (empty($counts = $this->getPostCounts($review->assigned_to))) {
109
+        if( empty($counts = $this->getPostCounts( $review->assigned_to )) ) {
110 110
             return;
111 111
         }
112
-        $counts = $this->decreaseRating($counts, $review->review_type, $review->rating);
113
-        $this->setPostCounts($review->assigned_to, $counts);
112
+        $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
113
+        $this->setPostCounts( $review->assigned_to, $counts );
114 114
     }
115 115
 
116 116
     /**
117 117
      * @return void
118 118
      */
119
-    public function decreaseTermCounts(Review $review)
119
+    public function decreaseTermCounts( Review $review )
120 120
     {
121
-        foreach ($review->term_ids as $termId) {
122
-            if (empty($counts = $this->getTermCounts($termId))) {
121
+        foreach( $review->term_ids as $termId ) {
122
+            if( empty($counts = $this->getTermCounts( $termId )) ) {
123 123
                 continue;
124 124
             }
125
-            $counts = $this->decreaseRating($counts, $review->review_type, $review->rating);
126
-            $this->setTermCounts($termId, $counts);
125
+            $counts = $this->decreaseRating( $counts, $review->review_type, $review->rating );
126
+            $this->setTermCounts( $termId, $counts );
127 127
         }
128 128
     }
129 129
 
130 130
     /**
131 131
      * @return array
132 132
      */
133
-    public function flatten(array $reviewCounts, array $args = [])
133
+    public function flatten( array $reviewCounts, array $args = [] )
134 134
     {
135 135
         $counts = [];
136
-        array_walk_recursive($reviewCounts, function ($num, $index) use (&$counts) {
137
-            $counts[$index] = $num + intval(glsr_get($counts, $index, 0));
136
+        array_walk_recursive( $reviewCounts, function( $num, $index ) use (&$counts) {
137
+            $counts[$index] = $num + intval( glsr_get( $counts, $index, 0 ) );
138 138
         });
139
-        $args = wp_parse_args($args, [
140
-            'max' => glsr()->constant('MAX_RATING', Rating::class),
141
-            'min' => glsr()->constant('MIN_RATING', Rating::class),
142
-        ]);
143
-        foreach ($counts as $index => &$num) {
144
-            if ($index >= intval($args['min']) && $index <= intval($args['max'])) {
139
+        $args = wp_parse_args( $args, [
140
+            'max' => glsr()->constant( 'MAX_RATING', Rating::class ),
141
+            'min' => glsr()->constant( 'MIN_RATING', Rating::class ),
142
+        ] );
143
+        foreach( $counts as $index => &$num ) {
144
+            if( $index >= intval( $args['min'] ) && $index <= intval( $args['max'] ) ) {
145 145
                 continue;
146 146
             }
147 147
             $num = 0;
@@ -152,26 +152,26 @@  discard block
 block discarded – undo
152 152
     /**
153 153
      * @return array
154 154
      */
155
-    public function get(array $args = [])
155
+    public function get( array $args = [] )
156 156
     {
157
-        $args = $this->normalizeArgs($args);
157
+        $args = $this->normalizeArgs( $args );
158 158
         $counts = [];
159
-        if ($this->isMixedCount($args)) {
160
-            $counts = [$this->buildCounts($args)]; // force query the database
159
+        if( $this->isMixedCount( $args ) ) {
160
+            $counts = [$this->buildCounts( $args )]; // force query the database
161 161
         } else {
162
-            foreach ($args['post_ids'] as $postId) {
163
-                $counts[] = $this->getPostCounts($postId);
162
+            foreach( $args['post_ids'] as $postId ) {
163
+                $counts[] = $this->getPostCounts( $postId );
164 164
         }
165
-            foreach ($args['term_ids'] as $termId) {
166
-                $counts[] = $this->getTermCounts($termId);
165
+            foreach( $args['term_ids'] as $termId ) {
166
+                $counts[] = $this->getTermCounts( $termId );
167 167
             }
168
-            if (empty($counts)) {
168
+            if( empty($counts) ) {
169 169
                 $counts[] = $this->getCounts();
170 170
             }
171 171
         }
172
-        return in_array($args['type'], ['', 'all'])
173
-            ? $this->normalize([$this->flatten($counts)])
174
-            : $this->normalize(glsr_array_column($counts, $args['type']));
172
+        return in_array( $args['type'], ['', 'all'] )
173
+            ? $this->normalize( [$this->flatten( $counts )] )
174
+            : $this->normalize( glsr_array_column( $counts, $args['type'] ) );
175 175
     }
176 176
 
177 177
     /**
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
      */
180 180
     public function getCounts()
181 181
     {
182
-        $counts = glsr(OptionManager::class)->get('counts', []);
183
-        if (!is_array($counts)) {
184
-            glsr_log()->error('Review counts is not an array; possibly due to incorrectly imported reviews.')->debug($counts);
182
+        $counts = glsr( OptionManager::class )->get( 'counts', [] );
183
+        if( !is_array( $counts ) ) {
184
+            glsr_log()->error( 'Review counts is not an array; possibly due to incorrectly imported reviews.' )->debug( $counts );
185 185
             return [];
186 186
         }
187 187
         return $counts;
@@ -191,105 +191,105 @@  discard block
 block discarded – undo
191 191
      * @param int $postId
192 192
      * @return array
193 193
      */
194
-    public function getPostCounts($postId)
194
+    public function getPostCounts( $postId )
195 195
     {
196
-        return array_filter((array) get_post_meta($postId, static::META_COUNT, true));
196
+        return array_filter( (array)get_post_meta( $postId, static::META_COUNT, true ) );
197 197
     }
198 198
 
199 199
     /**
200 200
      * @param int $termId
201 201
      * @return array
202 202
      */
203
-    public function getTermCounts($termId)
203
+    public function getTermCounts( $termId )
204 204
     {
205
-        return array_filter((array) get_term_meta($termId, static::META_COUNT, true));
205
+        return array_filter( (array)get_term_meta( $termId, static::META_COUNT, true ) );
206 206
     }
207 207
 
208 208
     /**
209 209
      * @return void
210 210
      */
211
-    public function increase(Review $review)
211
+    public function increase( Review $review )
212 212
     {
213
-        $this->increaseCounts($review);
214
-        $this->increasePostCounts($review);
215
-        $this->increaseTermCounts($review);
213
+        $this->increaseCounts( $review );
214
+        $this->increasePostCounts( $review );
215
+        $this->increaseTermCounts( $review );
216 216
     }
217 217
 
218 218
     /**
219 219
      * @return void
220 220
      */
221
-    public function increaseCounts(Review $review)
221
+    public function increaseCounts( Review $review )
222 222
     {
223
-        if (empty($counts = $this->getCounts())) {
223
+        if( empty($counts = $this->getCounts()) ) {
224 224
             $counts = $this->buildCounts();
225 225
         }
226
-        $this->setCounts($this->increaseRating($counts, $review->review_type, $review->rating));
226
+        $this->setCounts( $this->increaseRating( $counts, $review->review_type, $review->rating ) );
227 227
     }
228 228
 
229 229
     /**
230 230
      * @return void
231 231
      */
232
-    public function increasePostCounts(Review $review)
232
+    public function increasePostCounts( Review $review )
233 233
     {
234
-        if (!(get_post($review->assigned_to) instanceof WP_Post)) {
234
+        if( !(get_post( $review->assigned_to ) instanceof WP_Post) ) {
235 235
             return;
236 236
         }
237
-        $counts = $this->getPostCounts($review->assigned_to);
237
+        $counts = $this->getPostCounts( $review->assigned_to );
238 238
         $counts = empty($counts)
239
-            ? $this->buildPostCounts($review->assigned_to)
240
-            : $this->increaseRating($counts, $review->review_type, $review->rating);
241
-        $this->setPostCounts($review->assigned_to, $counts);
239
+            ? $this->buildPostCounts( $review->assigned_to )
240
+            : $this->increaseRating( $counts, $review->review_type, $review->rating );
241
+        $this->setPostCounts( $review->assigned_to, $counts );
242 242
     }
243 243
 
244 244
     /**
245 245
      * @return void
246 246
      */
247
-    public function increaseTermCounts(Review $review)
247
+    public function increaseTermCounts( Review $review )
248 248
     {
249
-        $terms = glsr(ReviewManager::class)->normalizeTerms(implode(',', $review->term_ids));
250
-        foreach ($terms as $term) {
251
-            $counts = $this->getTermCounts($term['term_id']);
249
+        $terms = glsr( ReviewManager::class )->normalizeTerms( implode( ',', $review->term_ids ) );
250
+        foreach( $terms as $term ) {
251
+            $counts = $this->getTermCounts( $term['term_id'] );
252 252
             $counts = empty($counts)
253
-                ? $this->buildTermCounts($term['term_taxonomy_id'])
254
-                : $this->increaseRating($counts, $review->review_type, $review->rating);
255
-            $this->setTermCounts($term['term_id'], $counts);
253
+                ? $this->buildTermCounts( $term['term_taxonomy_id'] )
254
+                : $this->increaseRating( $counts, $review->review_type, $review->rating );
255
+            $this->setTermCounts( $term['term_id'], $counts );
256 256
         }
257 257
     }
258 258
 
259 259
     /**
260 260
      * @return void
261 261
      */
262
-    public function setCounts(array $reviewCounts)
262
+    public function setCounts( array $reviewCounts )
263 263
     {
264
-        glsr(OptionManager::class)->set('counts', $reviewCounts);
264
+        glsr( OptionManager::class )->set( 'counts', $reviewCounts );
265 265
     }
266 266
 
267 267
     /**
268 268
      * @param int $postId
269 269
      * @return void
270 270
      */
271
-    public function setPostCounts($postId, array $reviewCounts)
271
+    public function setPostCounts( $postId, array $reviewCounts )
272 272
     {
273
-        $ratingCounts = $this->flatten($reviewCounts);
274
-        update_post_meta($postId, static::META_COUNT, $reviewCounts);
275
-        update_post_meta($postId, static::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
276
-        update_post_meta($postId, static::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
273
+        $ratingCounts = $this->flatten( $reviewCounts );
274
+        update_post_meta( $postId, static::META_COUNT, $reviewCounts );
275
+        update_post_meta( $postId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) );
276
+        update_post_meta( $postId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) );
277 277
     }
278 278
 
279 279
     /**
280 280
      * @param int $termId
281 281
      * @return void
282 282
      */
283
-    public function setTermCounts($termId, array $reviewCounts)
283
+    public function setTermCounts( $termId, array $reviewCounts )
284 284
     {
285
-        $term = get_term($termId, Application::TAXONOMY);
286
-        if (!isset($term->term_id)) {
285
+        $term = get_term( $termId, Application::TAXONOMY );
286
+        if( !isset($term->term_id) ) {
287 287
             return;
288 288
         }
289
-        $ratingCounts = $this->flatten($reviewCounts);
290
-        update_term_meta($termId, static::META_COUNT, $reviewCounts);
291
-        update_term_meta($termId, static::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
292
-        update_term_meta($termId, static::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
289
+        $ratingCounts = $this->flatten( $reviewCounts );
290
+        update_term_meta( $termId, static::META_COUNT, $reviewCounts );
291
+        update_term_meta( $termId, static::META_AVERAGE, glsr( Rating::class )->getAverage( $ratingCounts ) );
292
+        update_term_meta( $termId, static::META_RANKING, glsr( Rating::class )->getRanking( $ratingCounts ) );
293 293
     }
294 294
 
295 295
     /**
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
      * @param int $rating
298 298
      * @return array
299 299
      */
300
-    protected function decreaseRating(array $reviewCounts, $type, $rating)
300
+    protected function decreaseRating( array $reviewCounts, $type, $rating )
301 301
     {
302
-        if (isset($reviewCounts[$type][$rating])) {
303
-            $reviewCounts[$type][$rating] = max(0, $reviewCounts[$type][$rating] - 1);
302
+        if( isset($reviewCounts[$type][$rating]) ) {
303
+            $reviewCounts[$type][$rating] = max( 0, $reviewCounts[$type][$rating] - 1 );
304 304
         }
305 305
         return $reviewCounts;
306 306
     }
@@ -310,23 +310,23 @@  discard block
 block discarded – undo
310 310
      * @param int $rating
311 311
      * @return array
312 312
      */
313
-    protected function increaseRating(array $reviewCounts, $type, $rating)
313
+    protected function increaseRating( array $reviewCounts, $type, $rating )
314 314
     {
315
-        if (!array_key_exists($type, glsr()->reviewTypes)) {
315
+        if( !array_key_exists( $type, glsr()->reviewTypes ) ) {
316 316
             return $reviewCounts;
317 317
         }
318
-        if (!array_key_exists($type, $reviewCounts)) {
318
+        if( !array_key_exists( $type, $reviewCounts ) ) {
319 319
             $reviewCounts[$type] = [];
320 320
         }
321
-        $reviewCounts = $this->normalize($reviewCounts);
322
-        $reviewCounts[$type][$rating] = intval($reviewCounts[$type][$rating]) + 1;
321
+        $reviewCounts = $this->normalize( $reviewCounts );
322
+        $reviewCounts[$type][$rating] = intval( $reviewCounts[$type][$rating] ) + 1;
323 323
         return $reviewCounts;
324 324
     }
325 325
 
326 326
     /**
327 327
      * @return bool
328 328
      */
329
-    protected function isMixedCount(array $args)
329
+    protected function isMixedCount( array $args )
330 330
     {
331 331
         return !empty($args['post_ids']) && !empty($args['term_ids']);
332 332
     }
@@ -334,19 +334,19 @@  discard block
 block discarded – undo
334 334
     /**
335 335
      * @return array
336 336
      */
337
-    protected function normalize(array $reviewCounts)
337
+    protected function normalize( array $reviewCounts )
338 338
     {
339
-        if (empty($reviewCounts)) {
339
+        if( empty($reviewCounts) ) {
340 340
             $reviewCounts = [[]];
341 341
         }
342
-        foreach ($reviewCounts as &$counts) {
343
-            foreach (range(0, glsr()->constant('MAX_RATING', Rating::class)) as $index) {
344
-                if (isset($counts[$index])) {
342
+        foreach( $reviewCounts as &$counts ) {
343
+            foreach( range( 0, glsr()->constant( 'MAX_RATING', Rating::class ) ) as $index ) {
344
+                if( isset($counts[$index]) ) {
345 345
                     continue;
346 346
                 }
347 347
                 $counts[$index] = 0;
348 348
             }
349
-            ksort($counts);
349
+            ksort( $counts );
350 350
         }
351 351
         return $reviewCounts;
352 352
     }
@@ -354,15 +354,15 @@  discard block
 block discarded – undo
354 354
     /**
355 355
      * @return array
356 356
      */
357
-    protected function normalizeArgs(array $args)
357
+    protected function normalizeArgs( array $args )
358 358
     {
359
-        $args = wp_parse_args(array_filter($args), [
359
+        $args = wp_parse_args( array_filter( $args ), [
360 360
             'post_ids' => [],
361 361
             'term_ids' => [],
362 362
             'type' => 'local',
363
-        ]);
364
-        $args['post_ids'] = glsr(Polylang::class)->getPostIds($args['post_ids']);
365
-        $args['type'] = $this->normalizeType($args['type']);
363
+        ] );
364
+        $args['post_ids'] = glsr( Polylang::class )->getPostIds( $args['post_ids'] );
365
+        $args['type'] = $this->normalizeType( $args['type'] );
366 366
         return $args;
367 367
     }
368 368
 
@@ -370,9 +370,9 @@  discard block
 block discarded – undo
370 370
      * @param string $type
371 371
      * @return string
372 372
      */
373
-    protected function normalizeType($type)
373
+    protected function normalizeType( $type )
374 374
     {
375
-        return empty($type) || !is_string($type)
375
+        return empty($type) || !is_string( $type )
376 376
             ? 'local'
377 377
             : $type;
378 378
     }
@@ -381,13 +381,13 @@  discard block
 block discarded – undo
381 381
      * @param int $lastPostId
382 382
      * @return object
383 383
      */
384
-    protected function queryReviews(array $args = [], $lastPostId = 0)
384
+    protected function queryReviews( array $args = [], $lastPostId = 0 )
385 385
     {
386
-        $reviews = glsr(SqlQueries::class)->getReviewCounts($args, $lastPostId, static::LIMIT);
387
-        $hasMore = is_array($reviews)
388
-            ? count($reviews) == static::LIMIT
386
+        $reviews = glsr( SqlQueries::class )->getReviewCounts( $args, $lastPostId, static::LIMIT );
387
+        $hasMore = is_array( $reviews )
388
+            ? count( $reviews ) == static::LIMIT
389 389
             : false;
390
-        return (object) [
390
+        return (object)[
391 391
             'has_more' => $hasMore,
392 392
             'reviews' => $reviews,
393 393
         ];
Please login to merge, or discard this patch.
plugin/Review.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -32,27 +32,27 @@  discard block
 block discarded – undo
32 32
     public $url;
33 33
     public $user_id;
34 34
 
35
-    public function __construct(WP_Post $post)
35
+    public function __construct( WP_Post $post )
36 36
     {
37
-        if (Application::POST_TYPE != $post->post_type) {
37
+        if( Application::POST_TYPE != $post->post_type ) {
38 38
             return;
39 39
         }
40 40
         $this->content = $post->post_content;
41 41
         $this->date = $post->post_date;
42
-        $this->ID = intval($post->ID);
42
+        $this->ID = intval( $post->ID );
43 43
         $this->status = $post->post_status;
44 44
         $this->title = $post->post_title;
45
-        $this->user_id = intval($post->post_author);
46
-        $this->setProperties($post);
47
-        $this->setTermIds($post);
45
+        $this->user_id = intval( $post->post_author );
46
+        $this->setProperties( $post );
47
+        $this->setTermIds( $post );
48 48
     }
49 49
 
50 50
     /**
51 51
      * @return mixed
52 52
      */
53
-    public function __get($key)
53
+    public function __get( $key )
54 54
     {
55
-        return $this->offsetGet($key);
55
+        return $this->offsetGet( $key );
56 56
     }
57 57
 
58 58
     /**
@@ -60,41 +60,41 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function __toString()
62 62
     {
63
-        return (string) $this->build();
63
+        return (string)$this->build();
64 64
     }
65 65
 
66 66
     /**
67 67
      * @return ReviewHtml
68 68
      */
69
-    public function build(array $args = [])
69
+    public function build( array $args = [] )
70 70
     {
71
-        if (empty($this->ID)) {
72
-            return new ReviewHtml($this);
71
+        if( empty($this->ID) ) {
72
+            return new ReviewHtml( $this );
73 73
         }
74
-        $partial = glsr(SiteReviewsPartial::class);
75
-        $partial->args = glsr(SiteReviewsDefaults::class)->merge($args);
76
-        $partial->options = glsr(Helper::class)->flattenArray(glsr(OptionManager::class)->all());
77
-        return $partial->buildReview($this);
74
+        $partial = glsr( SiteReviewsPartial::class );
75
+        $partial->args = glsr( SiteReviewsDefaults::class )->merge( $args );
76
+        $partial->options = glsr( Helper::class )->flattenArray( glsr( OptionManager::class )->all() );
77
+        return $partial->buildReview( $this );
78 78
     }
79 79
 
80 80
     /**
81 81
      * @param mixed $key
82 82
      * @return bool
83 83
      */
84
-    public function offsetExists($key)
84
+    public function offsetExists( $key )
85 85
     {
86
-        return property_exists($this, $key) || array_key_exists($key, (array) $this->custom);
86
+        return property_exists( $this, $key ) || array_key_exists( $key, (array)$this->custom );
87 87
     }
88 88
 
89 89
     /**
90 90
      * @param mixed $key
91 91
      * @return mixed
92 92
      */
93
-    public function offsetGet($key)
93
+    public function offsetGet( $key )
94 94
     {
95
-        return property_exists($this, $key)
95
+        return property_exists( $this, $key )
96 96
             ? $this->$key
97
-            : glsr_get($this->custom, $key, null);
97
+            : glsr_get( $this->custom, $key, null );
98 98
     }
99 99
 
100 100
     /**
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
      * @param mixed $value
103 103
      * @return void
104 104
      */
105
-    public function offsetSet($key, $value)
105
+    public function offsetSet( $key, $value )
106 106
     {
107
-        if (property_exists($this, $key)) {
107
+        if( property_exists( $this, $key ) ) {
108 108
             $this->$key = $value;
109 109
             return;
110 110
         }
111
-        if (!is_array($this->custom)) {
112
-            $this->custom = array_filter((array) $this->custom);
111
+        if( !is_array( $this->custom ) ) {
112
+            $this->custom = array_filter( (array)$this->custom );
113 113
         }
114 114
         $this->custom[$key] = $value;
115 115
     }
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
      * @param mixed $key
119 119
      * @return void
120 120
      */
121
-    public function offsetUnset($key)
121
+    public function offsetUnset( $key )
122 122
     {
123
-        $this->offsetSet($key, null);
123
+        $this->offsetSet( $key, null );
124 124
     }
125 125
 
126 126
     /**
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     /**
135 135
      * @return bool
136 136
      */
137
-    protected function isModified(array $properties)
137
+    protected function isModified( array $properties )
138 138
     {
139 139
         return $this->date != $properties['date']
140 140
             || $this->content != $properties['content']
@@ -144,39 +144,39 @@  discard block
 block discarded – undo
144 144
     /**
145 145
      * @return void
146 146
      */
147
-    protected function setProperties(WP_Post $post)
147
+    protected function setProperties( WP_Post $post )
148 148
     {
149 149
         $defaults = [
150
-            'author' => __('Anonymous', 'site-reviews'),
150
+            'author' => __( 'Anonymous', 'site-reviews' ),
151 151
             'date' => '',
152 152
             'review_id' => '',
153 153
             'review_type' => 'local',
154 154
         ];
155 155
         $meta = array_filter(
156
-            array_map('array_shift', array_filter((array) get_post_meta($post->ID))),
156
+            array_map( 'array_shift', array_filter( (array)get_post_meta( $post->ID ) ) ),
157 157
             'strlen'
158 158
         );
159
-        $meta = array_merge($defaults, glsr(Helper::class)->unprefixArrayKeys($meta));
160
-        $properties = glsr(CreateReviewDefaults::class)->restrict(array_merge($defaults, $meta));
161
-        $this->modified = $this->isModified($properties);
162
-        array_walk($properties, function ($value, $key) {
163
-            if (!property_exists($this, $key) || isset($this->$key)) {
159
+        $meta = array_merge( $defaults, glsr( Helper::class )->unprefixArrayKeys( $meta ) );
160
+        $properties = glsr( CreateReviewDefaults::class )->restrict( array_merge( $defaults, $meta ) );
161
+        $this->modified = $this->isModified( $properties );
162
+        array_walk( $properties, function( $value, $key ) {
163
+            if( !property_exists( $this, $key ) || isset($this->$key) ) {
164 164
                 return;
165 165
             }
166
-            $this->$key = maybe_unserialize($value);
166
+            $this->$key = maybe_unserialize( $value );
167 167
         });
168 168
     }
169 169
 
170 170
     /**
171 171
      * @return void
172 172
      */
173
-    protected function setTermIds(WP_Post $post)
173
+    protected function setTermIds( WP_Post $post )
174 174
     {
175 175
         $this->term_ids = [];
176
-        if (!is_array($terms = get_the_terms($post, Application::TAXONOMY))) {
176
+        if( !is_array( $terms = get_the_terms( $post, Application::TAXONOMY ) ) ) {
177 177
             return;
178 178
         }
179
-        foreach ($terms as $term) {
179
+        foreach( $terms as $term ) {
180 180
             $this->term_ids[] = $term->term_id;
181 181
         }
182 182
     }
Please login to merge, or discard this patch.
plugin/Controllers/ReviewController.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -21,22 +21,22 @@  discard block
 block discarded – undo
21 21
      * @return void
22 22
      * @action set_object_terms
23 23
      */
24
-    public function onAfterChangeCategory($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds)
24
+    public function onAfterChangeCategory( $postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds )
25 25
     {
26
-        sort($newTTIds);
27
-        sort($oldTTIds);
28
-        if ($newTTIds === $oldTTIds || !$this->isReviewPostId($postId)) {
26
+        sort( $newTTIds );
27
+        sort( $oldTTIds );
28
+        if( $newTTIds === $oldTTIds || !$this->isReviewPostId( $postId ) ) {
29 29
             return;
30 30
         }
31
-        $review = glsr_get_review($postId);
32
-        $ignoredIds = array_intersect($oldTTIds, $newTTIds);
33
-        $decreasedIds = array_diff($oldTTIds, $ignoredIds);
34
-        $increasedIds = array_diff($newTTIds, $ignoredIds);
35
-        if ($review->term_ids = glsr(Database::class)->getTermIds($decreasedIds, 'term_taxonomy_id')) {
36
-            glsr(CountsManager::class)->decreaseTermCounts($review);
31
+        $review = glsr_get_review( $postId );
32
+        $ignoredIds = array_intersect( $oldTTIds, $newTTIds );
33
+        $decreasedIds = array_diff( $oldTTIds, $ignoredIds );
34
+        $increasedIds = array_diff( $newTTIds, $ignoredIds );
35
+        if( $review->term_ids = glsr( Database::class )->getTermIds( $decreasedIds, 'term_taxonomy_id' ) ) {
36
+            glsr( CountsManager::class )->decreaseTermCounts( $review );
37 37
         }
38
-        if ($review->term_ids = glsr(Database::class)->getTermIds($increasedIds, 'term_taxonomy_id')) {
39
-            glsr(CountsManager::class)->increaseTermCounts($review);
38
+        if( $review->term_ids = glsr( Database::class )->getTermIds( $increasedIds, 'term_taxonomy_id' ) ) {
39
+            glsr( CountsManager::class )->increaseTermCounts( $review );
40 40
         }
41 41
     }
42 42
 
@@ -47,16 +47,16 @@  discard block
 block discarded – undo
47 47
      * @return void
48 48
      * @action transition_post_status
49 49
      */
50
-    public function onAfterChangeStatus($newStatus, $oldStatus, $post)
50
+    public function onAfterChangeStatus( $newStatus, $oldStatus, $post )
51 51
     {
52
-        if (Application::POST_TYPE != glsr_get($post, 'post_type') || in_array($oldStatus, ['new', $newStatus])) {
52
+        if( Application::POST_TYPE != glsr_get( $post, 'post_type' ) || in_array( $oldStatus, ['new', $newStatus] ) ) {
53 53
             return;
54 54
         }
55
-        $review = glsr_get_review($post);
56
-        if ('publish' == $post->post_status) {
57
-            glsr(CountsManager::class)->increase($review);
55
+        $review = glsr_get_review( $post );
56
+        if( 'publish' == $post->post_status ) {
57
+            glsr( CountsManager::class )->increase( $review );
58 58
         } else {
59
-            glsr(CountsManager::class)->decrease($review);
59
+            glsr( CountsManager::class )->decrease( $review );
60 60
         }
61 61
     }
62 62
 
@@ -64,13 +64,13 @@  discard block
 block discarded – undo
64 64
      * @return void
65 65
      * @action site-reviews/review/created
66 66
      */
67
-    public function onAfterCreate(Review $review)
67
+    public function onAfterCreate( Review $review )
68 68
     {
69
-        if ('publish' !== $review->status) {
69
+        if( 'publish' !== $review->status ) {
70 70
             return;
71 71
         }
72
-        glsr(CountsManager::class)->increaseCounts($review);
73
-        glsr(CountsManager::class)->increasePostCounts($review);
72
+        glsr( CountsManager::class )->increaseCounts( $review );
73
+        glsr( CountsManager::class )->increasePostCounts( $review );
74 74
     }
75 75
 
76 76
     /**
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
      * @return void
79 79
      * @action before_delete_post
80 80
      */
81
-    public function onBeforeDelete($postId)
81
+    public function onBeforeDelete( $postId )
82 82
     {
83
-        if (!$this->isReviewPostId($postId)) {
83
+        if( !$this->isReviewPostId( $postId ) ) {
84 84
             return;
85 85
         }
86
-        $review = glsr_get_review($postId);
87
-        if ('trash' !== $review->status) { // do not run for trashed posts
88
-            glsr(CountsManager::class)->decrease($review);
86
+        $review = glsr_get_review( $postId );
87
+        if( 'trash' !== $review->status ) { // do not run for trashed posts
88
+            glsr( CountsManager::class )->decrease( $review );
89 89
         }
90 90
     }
91 91
 
@@ -97,53 +97,53 @@  discard block
 block discarded – undo
97 97
      * @return void
98 98
      * @action update_postmeta
99 99
      */
100
-    public function onBeforeUpdate($metaId, $postId, $metaKey, $metaValue)
100
+    public function onBeforeUpdate( $metaId, $postId, $metaKey, $metaValue )
101 101
     {
102
-        if (!$this->isReviewPostId($postId)) {
102
+        if( !$this->isReviewPostId( $postId ) ) {
103 103
             return;
104 104
         }
105
-        $metaKey = glsr(Helper::class)->removePrefix('_', $metaKey);
106
-        if (!in_array($metaKey, ['assigned_to', 'rating', 'review_type'])) {
105
+        $metaKey = glsr( Helper::class )->removePrefix( '_', $metaKey );
106
+        if( !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) ) {
107 107
             return;
108 108
         }
109
-        $review = glsr_get_review($postId);
110
-        if ($review->$metaKey == $metaValue) {
109
+        $review = glsr_get_review( $postId );
110
+        if( $review->$metaKey == $metaValue ) {
111 111
             return;
112 112
         }
113
-        $method = glsr(Helper::class)->buildMethodName($metaKey, 'onBeforeChange');
114
-        call_user_func([$this, $method], $review, $metaValue);
113
+        $method = glsr( Helper::class )->buildMethodName( $metaKey, 'onBeforeChange' );
114
+        call_user_func( [$this, $method], $review, $metaValue );
115 115
     }
116 116
 
117 117
     /**
118 118
      * @param string|int $assignedTo
119 119
      * @return void
120 120
      */
121
-    public function onBeforeChangeAssignedTo(Review $review, $assignedTo)
121
+    public function onBeforeChangeAssignedTo( Review $review, $assignedTo )
122 122
     {
123
-        glsr(CountsManager::class)->decreasePostCounts($review);
123
+        glsr( CountsManager::class )->decreasePostCounts( $review );
124 124
         $review->assigned_to = $assignedTo;
125
-        glsr(CountsManager::class)->increasePostCounts($review);
125
+        glsr( CountsManager::class )->increasePostCounts( $review );
126 126
     }
127 127
 
128 128
     /**
129 129
      * @param string|int $rating
130 130
      * @return void
131 131
      */
132
-    public function onBeforeChangeRating(Review $review, $rating)
132
+    public function onBeforeChangeRating( Review $review, $rating )
133 133
     {
134
-        glsr(CountsManager::class)->decrease($review);
134
+        glsr( CountsManager::class )->decrease( $review );
135 135
         $review->rating = $rating;
136
-        glsr(CountsManager::class)->increase($review);
136
+        glsr( CountsManager::class )->increase( $review );
137 137
     }
138 138
 
139 139
     /**
140 140
      * @param string $reviewType
141 141
      * @return void
142 142
      */
143
-    public function onBeforeChangeReviewType(Review $review, $reviewType)
143
+    public function onBeforeChangeReviewType( Review $review, $reviewType )
144 144
     {
145
-        glsr(CountsManager::class)->decrease($review);
145
+        glsr( CountsManager::class )->decrease( $review );
146 146
         $review->review_type = $reviewType;
147
-        glsr(CountsManager::class)->increase($review);
147
+        glsr( CountsManager::class )->increase( $review );
148 148
     }
149 149
 }
Please login to merge, or discard this patch.
views/pages/welcome/support.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <p class="about-description">
4
-    Still need help with <?= glsr()->name; ?>? We offer excellent support for you. But don't forget to check our <a href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!shortcodes'); ?>">documentation</a> first.
4
+    Still need help with <?= glsr()->name; ?>? We offer excellent support for you. But don't forget to check our <a href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!shortcodes' ); ?>">documentation</a> first.
5 5
 </p>
6 6
 <div class="is-fullwidth">
7 7
     <div class="glsr-flex-row glsr-has-2-columns">
Please login to merge, or discard this patch.