Passed
Push — master ( af979f...1dfed5 )
by Paul
08:16 queued 04:12
created
plugin/Modules/Html/ReviewsHtml.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public $reviews;
30 30
 
31
-    public function __construct(array $renderedReviews, $maxPageCount, array $args)
31
+    public function __construct( array $renderedReviews, $maxPageCount, array $args )
32 32
     {
33 33
         $this->args = $args;
34 34
         $this->max_num_pages = $maxPageCount;
35 35
         $this->reviews = $renderedReviews;
36 36
         $this->pagination = $this->buildPagination();
37
-        parent::__construct($renderedReviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
37
+        parent::__construct( $renderedReviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS );
38 38
     }
39 39
 
40 40
     /**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function __toString()
44 44
     {
45
-        return glsr(Template::class)->build('templates/reviews', [
45
+        return glsr( Template::class )->build( 'templates/reviews', [
46 46
             'args' => $this->args,
47 47
             'context' => [
48 48
                 'assigned_to' => $this->args['assigned_to'],
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
                 'pagination' => $this->getPagination(),
53 53
                 'reviews' => $this->getReviews(),
54 54
             ],
55
-        ]);
55
+        ] );
56 56
     }
57 57
 
58 58
     /**
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      */
61 61
     public function getPagination()
62 62
     {
63
-        return wp_validate_boolean($this->args['pagination'])
63
+        return wp_validate_boolean( $this->args['pagination'] )
64 64
             ? $this->pagination
65 65
             : '';
66 66
     }
@@ -72,26 +72,26 @@  discard block
 block discarded – undo
72 72
     {
73 73
         $html = empty($this->reviews)
74 74
             ? $this->getReviewsFallback()
75
-            : implode(PHP_EOL, $this->reviews);
75
+            : implode( PHP_EOL, $this->reviews );
76 76
         $wrapper = '<div class="glsr-reviews">%s</div>';
77
-        $wrapper = apply_filters('site-reviews/reviews/reviews-wrapper', $wrapper);
78
-        return sprintf($wrapper, $html);
77
+        $wrapper = apply_filters( 'site-reviews/reviews/reviews-wrapper', $wrapper );
78
+        return sprintf( $wrapper, $html );
79 79
     }
80 80
 
81 81
     /**
82 82
      * @param mixed $key
83 83
      * @return mixed
84 84
      */
85
-    public function offsetGet($key)
85
+    public function offsetGet( $key )
86 86
     {
87
-        if ('navigation' == $key) {
87
+        if( 'navigation' == $key ) {
88 88
             glsr()->deprecated[] = 'The $reviewsHtml->navigation property has been been deprecated. Please use the $reviewsHtml->pagination property instead.';
89 89
             return $this->pagination;
90 90
         }
91
-        if (array_key_exists($key, $this->reviews)) {
91
+        if( array_key_exists( $key, $this->reviews ) ) {
92 92
             return $this->reviews[$key];
93 93
         }
94
-        return property_exists($this, $key)
94
+        return property_exists( $this, $key )
95 95
             ? $this->$key
96 96
             : null;
97 97
     }
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
      */
102 102
     protected function buildPagination()
103 103
     {
104
-        $html = glsr(Partial::class)->build('pagination', [
105
-            'baseUrl' => Arr::get($this->args, 'pagedUrl'),
106
-            'current' => Arr::get($this->args, 'paged'),
104
+        $html = glsr( Partial::class )->build( 'pagination', [
105
+            'baseUrl' => Arr::get( $this->args, 'pagedUrl' ),
106
+            'current' => Arr::get( $this->args, 'paged' ),
107 107
             'total' => $this->max_num_pages,
108
-        ]);
109
-        $html.= sprintf('<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json']);
108
+        ] );
109
+        $html .= sprintf( '<glsr-pagination hidden data-atts=\'%s\'></glsr-pagination>', $this->args['json'] );
110 110
         $wrapper = '<div class="glsr-pagination">%s</div>';
111
-        $wrapper = apply_filters('site-reviews/reviews/pagination-wrapper', $wrapper);
112
-        return sprintf($wrapper, $html);
111
+        $wrapper = apply_filters( 'site-reviews/reviews/pagination-wrapper', $wrapper );
112
+        return sprintf( $wrapper, $html );
113 113
     }
114 114
 
115 115
     /**
@@ -120,12 +120,12 @@  discard block
 block discarded – undo
120 120
         $defaults = [
121 121
             'glsr-default',
122 122
         ];
123
-        if ('ajax' == $this->args['pagination']) {
123
+        if( 'ajax' == $this->args['pagination'] ) {
124 124
             $defaults[] = 'glsr-ajax-pagination';
125 125
         }
126
-        $classes = explode(' ', $this->args['class']);
127
-        $classes = array_unique(array_merge($defaults, array_filter($classes)));
128
-        return implode(' ', $classes);
126
+        $classes = explode( ' ', $this->args['class'] );
127
+        $classes = array_unique( array_merge( $defaults, array_filter( $classes ) ) );
128
+        return implode( ' ', $classes );
129 129
     }
130 130
 
131 131
     /**
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
      */
134 134
     protected function getReviewsFallback()
135 135
     {
136
-        if (empty($this->args['fallback']) && glsr(OptionManager::class)->getBool('settings.reviews.fallback')) {
137
-            $this->args['fallback'] = __('There are no reviews yet. Be the first one to write one.', 'site-reviews');
136
+        if( empty($this->args['fallback']) && glsr( OptionManager::class )->getBool( 'settings.reviews.fallback' ) ) {
137
+            $this->args['fallback'] = __( 'There are no reviews yet. Be the first one to write one.', 'site-reviews' );
138 138
         }
139 139
         $fallback = '<p class="glsr-no-margins">'.$this->args['fallback'].'</p>';
140
-        return apply_filters('site-reviews/reviews/fallback', $fallback, $this->args);
140
+        return apply_filters( 'site-reviews/reviews/fallback', $fallback, $this->args );
141 141
     }
142 142
 }
Please login to merge, or discard this patch.
plugin/Contracts/PartialContract.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,5 +7,5 @@
 block discarded – undo
7 7
     /**
8 8
      * @return string
9 9
      */
10
-    public function build(array $args = []);
10
+    public function build( array $args = [] );
11 11
 }
Please login to merge, or discard this patch.
uninstall.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-defined('WP_UNINSTALL_PLUGIN') || die;
3
+defined( 'WP_UNINSTALL_PLUGIN' ) || die;
4 4
 
5 5
 $file = __DIR__.'/site-reviews.php';
6 6
 require_once $file;
7 7
 
8
-if (!(new GL_Plugin_Check_v4($file))->isValid()) {
8
+if( !(new GL_Plugin_Check_v4( $file ))->isValid() ) {
9 9
     return;
10 10
 }
11
-delete_option(GeminiLabs\SiteReviews\Database\OptionManager::databaseKey(3));
12
-delete_option(GeminiLabs\SiteReviews\Database\OptionManager::databaseKey(4));
13
-delete_option('_glsr_rebusify');
14
-delete_option('widget_'.glsr()->id.'_site-reviews');
15
-delete_option('widget_'.glsr()->id.'_site-reviews-form');
16
-delete_option('widget_'.glsr()->id.'_site-reviews-summary');
17
-delete_transient(glsr()->id.'_cloudflare_ips');
18
-delete_transient(glsr()->id.'_remote_post_test');
19
-wp_cache_delete(glsr()->id);
11
+delete_option( GeminiLabs\SiteReviews\Database\OptionManager::databaseKey( 3 ) );
12
+delete_option( GeminiLabs\SiteReviews\Database\OptionManager::databaseKey( 4 ) );
13
+delete_option( '_glsr_rebusify' );
14
+delete_option( 'widget_'.glsr()->id.'_site-reviews' );
15
+delete_option( 'widget_'.glsr()->id.'_site-reviews-form' );
16
+delete_option( 'widget_'.glsr()->id.'_site-reviews-summary' );
17
+delete_transient( glsr()->id.'_cloudflare_ips' );
18
+delete_transient( glsr()->id.'_remote_post_test' );
19
+wp_cache_delete( glsr()->id );
20 20
 
21 21
 global $wpdb;
22 22
 
23
-$wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key = '_glsr_notices'");
23
+$wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = '_glsr_notices'" );
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/StarRating.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -14,21 +14,21 @@  discard block
 block discarded – undo
14 14
     /**
15 15
      * @return string
16 16
      */
17
-    public function build(array $args = [])
17
+    public function build( array $args = [] )
18 18
     {
19
-        $this->setProperties($args);
20
-        $fullStars = intval(floor($this->rating));
21
-        $halfStars = intval(ceil($this->rating - $fullStars));
22
-        $emptyStars = max(0, glsr()->constant('MAX_RATING', Rating::class) - $fullStars - $halfStars);
23
-        return glsr(Template::class)->build('templates/rating/stars', [
19
+        $this->setProperties( $args );
20
+        $fullStars = intval( floor( $this->rating ) );
21
+        $halfStars = intval( ceil( $this->rating - $fullStars ) );
22
+        $emptyStars = max( 0, glsr()->constant( 'MAX_RATING', Rating::class ) - $fullStars - $halfStars );
23
+        return glsr( Template::class )->build( 'templates/rating/stars', [
24 24
             'context' => [
25
-                'empty_stars' => $this->getTemplate('empty-star', $emptyStars),
26
-                'full_stars' => $this->getTemplate('full-star', $fullStars),
27
-                'half_stars' => $this->getTemplate('half-star', $halfStars),
25
+                'empty_stars' => $this->getTemplate( 'empty-star', $emptyStars ),
26
+                'full_stars' => $this->getTemplate( 'full-star', $fullStars ),
27
+                'half_stars' => $this->getTemplate( 'half-star', $halfStars ),
28 28
                 'prefix' => $this->prefix,
29
-                'title' => sprintf(__('%s rating', 'site-reviews'), number_format_i18n($this->rating, 1)),
29
+                'title' => sprintf( __( '%s rating', 'site-reviews' ), number_format_i18n( $this->rating, 1 ) ),
30 30
             ],
31
-        ]);
31
+        ] );
32 32
     }
33 33
 
34 34
     /**
@@ -36,26 +36,26 @@  discard block
 block discarded – undo
36 36
      * @param int $timesRepeated
37 37
      * @return string
38 38
      */
39
-    protected function getTemplate($templateName, $timesRepeated)
39
+    protected function getTemplate( $templateName, $timesRepeated )
40 40
     {
41
-        $template = glsr(Template::class)->build('templates/rating/'.$templateName, [
41
+        $template = glsr( Template::class )->build( 'templates/rating/'.$templateName, [
42 42
             'context' => [
43 43
                 'prefix' => $this->prefix,
44 44
             ],
45
-        ]);
46
-        return str_repeat($template, $timesRepeated);
45
+        ] );
46
+        return str_repeat( $template, $timesRepeated );
47 47
     }
48 48
 
49 49
     /**
50 50
      * @return array
51 51
      */
52
-    protected function setProperties(array $args)
52
+    protected function setProperties( array $args )
53 53
     {
54
-        $args = wp_parse_args($args, [
54
+        $args = wp_parse_args( $args, [
55 55
             'prefix' => glsr()->isAdmin() ? '' : 'glsr-',
56 56
             'rating' => 0,
57
-        ]);
57
+        ] );
58 58
         $this->prefix = $args['prefix'];
59
-        $this->rating = (float) str_replace(',', '.', $args['rating']);
59
+        $this->rating = (float)str_replace( ',', '.', $args['rating'] );
60 60
     }
61 61
 }
Please login to merge, or discard this patch.
plugin/Application.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
     public function __construct()
32 32
     {
33 33
         static::$instance = $this;
34
-        $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php');
35
-        $plugin = get_file_data($this->file, [
34
+        $this->file = realpath( trailingslashit( dirname( __DIR__ ) ).static::ID.'.php' );
35
+        $plugin = get_file_data( $this->file, [
36 36
             'languages' => 'Domain Path',
37 37
             'name' => 'Plugin Name',
38 38
             'version' => 'Version',
39
-        ], 'plugin');
40
-        array_walk($plugin, function ($value, $key) {
39
+        ], 'plugin' );
40
+        array_walk( $plugin, function( $value, $key ) {
41 41
             $this->$key = $value;
42 42
         });
43 43
     }
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function activate()
49 49
     {
50
-        $this->make(DefaultsManager::class)->set();
50
+        $this->make( DefaultsManager::class )->set();
51 51
         $this->scheduleCronJob();
52 52
         $this->upgrade();
53 53
     }
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
      * @param string $view
57 57
      * @return string
58 58
      */
59
-    public function build($view, array $data = [])
59
+    public function build( $view, array $data = [] )
60 60
     {
61 61
         ob_start();
62
-        $this->render($view, $data);
62
+        $this->render( $view, $data );
63 63
         return ob_get_clean();
64 64
     }
65 65
 
@@ -69,34 +69,34 @@  discard block
 block discarded – undo
69 69
     public function catchFatalError()
70 70
     {
71 71
         $error = error_get_last();
72
-        if (E_ERROR !== $error['type'] || !Str::contains($error['message'], $this->path())) {
72
+        if( E_ERROR !== $error['type'] || !Str::contains( $error['message'], $this->path() ) ) {
73 73
             return;
74 74
         }
75
-        glsr_log()->error($error['message']);
75
+        glsr_log()->error( $error['message'] );
76 76
     }
77 77
 
78 78
     /**
79 79
      * @param string $name
80 80
      * @return array
81 81
      */
82
-    public function config($name)
82
+    public function config( $name )
83 83
     {
84
-        $configFile = $this->path('config/'.$name.'.php');
85
-        $config = file_exists($configFile)
84
+        $configFile = $this->path( 'config/'.$name.'.php' );
85
+        $config = file_exists( $configFile )
86 86
             ? include $configFile
87 87
             : [];
88
-        return apply_filters('site-reviews/config/'.$name, $config);
88
+        return apply_filters( 'site-reviews/config/'.$name, $config );
89 89
     }
90 90
 
91 91
     /**
92 92
      * @param string $property
93 93
      * @return string
94 94
      */
95
-    public function constant($property, $className = 'static')
95
+    public function constant( $property, $className = 'static' )
96 96
     {
97 97
         $constant = $className.'::'.$property;
98
-        return defined($constant)
99
-            ? apply_filters('site-reviews/const/'.$property, constant($constant))
98
+        return defined( $constant )
99
+            ? apply_filters( 'site-reviews/const/'.$property, constant( $constant ) )
100 100
             : '';
101 101
     }
102 102
 
@@ -112,17 +112,17 @@  discard block
 block discarded – undo
112 112
      * @param string $view
113 113
      * @return void|string
114 114
      */
115
-    public function file($view)
115
+    public function file( $view )
116 116
     {
117
-        $view.= '.php';
117
+        $view .= '.php';
118 118
         $filePaths = [];
119
-        if (Str::startsWith('templates/', $view)) {
120
-            $filePaths[] = $this->themePath(Str::removePrefix('templates/', $view));
119
+        if( Str::startsWith( 'templates/', $view ) ) {
120
+            $filePaths[] = $this->themePath( Str::removePrefix( 'templates/', $view ) );
121 121
         }
122
-        $filePaths[] = $this->path($view);
123
-        $filePaths[] = $this->path('views/'.$view);
124
-        foreach ($filePaths as $file) {
125
-            if (!file_exists($file)) {
122
+        $filePaths[] = $this->path( $view );
123
+        $filePaths[] = $this->path( 'views/'.$view );
124
+        foreach( $filePaths as $file ) {
125
+            if( !file_exists( $file ) ) {
126 126
                 continue;
127 127
             }
128 128
             return $file;
@@ -134,33 +134,33 @@  discard block
 block discarded – undo
134 134
      */
135 135
     public function getDefaults()
136 136
     {
137
-        if (empty($this->defaults)) {
138
-            $this->defaults = $this->make(DefaultsManager::class)->get();
137
+        if( empty($this->defaults) ) {
138
+            $this->defaults = $this->make( DefaultsManager::class )->get();
139 139
             $this->upgrade();
140 140
         }
141
-        return apply_filters('site-reviews/get/defaults', $this->defaults);
141
+        return apply_filters( 'site-reviews/get/defaults', $this->defaults );
142 142
     }
143 143
 
144 144
     /**
145 145
      * @return string
146 146
      */
147
-    public function getPermission($page = '')
147
+    public function getPermission( $page = '' )
148 148
     {
149 149
         $permissions = [
150 150
             'addons' => 'install_plugins',
151 151
             'settings' => 'manage_options',
152 152
             // 'welcome' => 'activate_plugins',
153 153
         ];
154
-        return Arr::get($permissions, $page, $this->constant('CAPABILITY'));
154
+        return Arr::get( $permissions, $page, $this->constant( 'CAPABILITY' ) );
155 155
     }
156 156
 
157 157
     /**
158 158
      * @return bool
159 159
      */
160
-    public function hasPermission($page = '')
160
+    public function hasPermission( $page = '' )
161 161
     {
162 162
         $isAdmin = $this->isAdmin();
163
-        return !$isAdmin || ($isAdmin && current_user_can($this->getPermission($page)));
163
+        return !$isAdmin || ($isAdmin && current_user_can( $this->getPermission( $page ) ));
164 164
     }
165 165
 
166 166
     /**
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
      */
169 169
     public function init()
170 170
     {
171
-        $this->make(Actions::class)->run();
172
-        $this->make(Filters::class)->run();
171
+        $this->make( Actions::class )->run();
172
+        $this->make( Filters::class )->run();
173 173
     }
174 174
 
175 175
     /**
@@ -184,31 +184,31 @@  discard block
 block discarded – undo
184 184
      * @param string $file
185 185
      * @return string
186 186
      */
187
-    public function path($file = '', $realpath = true)
187
+    public function path( $file = '', $realpath = true )
188 188
     {
189
-        $path = plugin_dir_path($this->file);
190
-        if (!$realpath) {
191
-            $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file));
189
+        $path = plugin_dir_path( $this->file );
190
+        if( !$realpath ) {
191
+            $path = trailingslashit( WP_PLUGIN_DIR ).basename( dirname( $this->file ) );
192 192
         }
193
-        $path = trailingslashit($path).ltrim(trim($file), '/');
194
-        return apply_filters('site-reviews/path', $path, $file);
193
+        $path = trailingslashit( $path ).ltrim( trim( $file ), '/' );
194
+        return apply_filters( 'site-reviews/path', $path, $file );
195 195
     }
196 196
 
197 197
     /**
198 198
      * @param object $addon
199 199
      * @return void
200 200
      */
201
-    public function register($addon)
201
+    public function register( $addon )
202 202
     {
203 203
         try {
204
-            $reflection = new \ReflectionClass($addon);
205
-            if ($id = $reflection->getConstant('ID')) {
204
+            $reflection = new \ReflectionClass( $addon );
205
+            if( $id = $reflection->getConstant( 'ID' ) ) {
206 206
                 $this->addons[] = $id;
207
-                $this->bind($id, $addon);
207
+                $this->bind( $id, $addon );
208 208
                 $addon->init();
209 209
             }
210
-        } catch(\ReflectionException $e) {
211
-            glsr_log()->error('Attempted to register an invalid addon.');
210
+        } catch( \ReflectionException $e ) {
211
+            glsr_log()->error( 'Attempted to register an invalid addon.' );
212 212
         }
213 213
     }
214 214
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
      */
218 218
     public function registerAddons()
219 219
     {
220
-        do_action('site-reviews/addon/register', $this);
220
+        do_action( 'site-reviews/addon/register', $this );
221 221
     }
222 222
 
223 223
     /**
@@ -225,8 +225,8 @@  discard block
 block discarded – undo
225 225
      */
226 226
     public function registerLanguages()
227 227
     {
228
-        load_plugin_textdomain(static::ID, false,
229
-            trailingslashit(plugin_basename($this->path()).'/'.$this->languages)
228
+        load_plugin_textdomain( static::ID, false,
229
+            trailingslashit( plugin_basename( $this->path() ).'/'.$this->languages )
230 230
         );
231 231
     }
232 232
 
@@ -235,26 +235,26 @@  discard block
 block discarded – undo
235 235
      */
236 236
     public function registerReviewTypes()
237 237
     {
238
-        $types = apply_filters('site-reviews/addon/types', []);
239
-        $this->reviewTypes = wp_parse_args($types, [
240
-            'local' => __('Local', 'site-reviews'),
241
-        ]);
238
+        $types = apply_filters( 'site-reviews/addon/types', [] );
239
+        $this->reviewTypes = wp_parse_args( $types, [
240
+            'local' => __( 'Local', 'site-reviews' ),
241
+        ] );
242 242
     }
243 243
 
244 244
     /**
245 245
      * @param string $view
246 246
      * @return void
247 247
      */
248
-    public function render($view, array $data = [])
248
+    public function render( $view, array $data = [] )
249 249
     {
250
-        $view = apply_filters('site-reviews/render/view', $view, $data);
251
-        $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data);
252
-        if (!file_exists($file)) {
253
-            glsr_log()->error('File not found: '.$file);
250
+        $view = apply_filters( 'site-reviews/render/view', $view, $data );
251
+        $file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data );
252
+        if( !file_exists( $file ) ) {
253
+            glsr_log()->error( 'File not found: '.$file );
254 254
             return;
255 255
         }
256
-        $data = apply_filters('site-reviews/views/data', $data, $view);
257
-        extract($data);
256
+        $data = apply_filters( 'site-reviews/views/data', $data, $view );
257
+        extract( $data );
258 258
         include $file;
259 259
     }
260 260
 
@@ -263,19 +263,19 @@  discard block
 block discarded – undo
263 263
      */
264 264
     public function scheduleCronJob()
265 265
     {
266
-        if (wp_next_scheduled(static::CRON_EVENT)) {
266
+        if( wp_next_scheduled( static::CRON_EVENT ) ) {
267 267
             return;
268 268
         }
269
-        wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT);
269
+        wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT );
270 270
     }
271 271
 
272 272
     /**
273 273
      * @param string $file
274 274
      * @return string
275 275
      */
276
-    public function themePath($file = '')
276
+    public function themePath( $file = '' )
277 277
     {
278
-        return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/');
278
+        return get_stylesheet_directory().'/'.static::ID.'/'.ltrim( trim( $file ), '/' );
279 279
     }
280 280
 
281 281
     /**
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
      */
284 284
     public function unscheduleCronJob()
285 285
     {
286
-        wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT);
286
+        wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT );
287 287
     }
288 288
 
289 289
     /**
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
      */
292 292
     public function upgrade()
293 293
     {
294
-        $this->make(Upgrader::class)->run();
294
+        $this->make( Upgrader::class )->run();
295 295
     }
296 296
 
297 297
     /**
@@ -299,10 +299,10 @@  discard block
 block discarded – undo
299 299
      * @return void
300 300
      * @action upgrader_process_complete
301 301
      */
302
-    public function upgraded($upgrader, array $data)
302
+    public function upgraded( $upgrader, array $data )
303 303
     {
304
-        if (array_key_exists('plugins', $data)
305
-            && in_array(plugin_basename($this->file), $data['plugins'])
304
+        if( array_key_exists( 'plugins', $data )
305
+            && in_array( plugin_basename( $this->file ), $data['plugins'] )
306 306
             && 'update' === $data['action']
307 307
             && 'plugin' === $data['type']
308 308
         ) {
@@ -314,29 +314,29 @@  discard block
 block discarded – undo
314 314
      * @param string $path
315 315
      * @return string
316 316
      */
317
-    public function url($path = '')
317
+    public function url( $path = '' )
318 318
     {
319
-        $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/'));
320
-        return apply_filters('site-reviews/url', $url, $path);
319
+        $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) );
320
+        return apply_filters( 'site-reviews/url', $url, $path );
321 321
     }
322 322
 
323 323
     /**
324 324
      * @param string $versionLevel
325 325
      * @return string
326 326
      */
327
-    public function version($versionLevel = '')
327
+    public function version( $versionLevel = '' )
328 328
     {
329 329
         $pattern = '/^v?(\d{1,5})(\.\d++)?(\.\d++)?(.+)?$/i';
330
-        preg_match($pattern, $this->version, $matches);
331
-        switch ($versionLevel) {
330
+        preg_match( $pattern, $this->version, $matches );
331
+        switch( $versionLevel ) {
332 332
             case 'major':
333
-                $version = Arr::get($matches, 1);
333
+                $version = Arr::get( $matches, 1 );
334 334
                 break;
335 335
             case 'minor':
336
-                $version = Arr::get($matches, 1).Arr::get($matches, 2);
336
+                $version = Arr::get( $matches, 1 ).Arr::get( $matches, 2 );
337 337
                 break;
338 338
             case 'patch':
339
-                $version = Arr::get($matches, 1).Arr::get($matches, 2).Arr::get($matches, 3);
339
+                $version = Arr::get( $matches, 1 ).Arr::get( $matches, 2 ).Arr::get( $matches, 3 );
340 340
                 break;
341 341
         }
342 342
         return empty($version)
Please login to merge, or discard this patch.
helpers.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-defined('WPINC') || die;
3
+defined( 'WPINC' ) || die;
4 4
 
5 5
 /*
6 6
  * Alternate method of using the functions without having to use `function_exists()`
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @param mixed ...
9 9
  * @return mixed
10 10
  */
11
-add_filter('plugins_loaded', function () {
11
+add_filter( 'plugins_loaded', function() {
12 12
     $hooks = array(
13 13
         'glsr_calculate_ratings' => 1,
14 14
         'glsr_create_review' => 2,
@@ -21,23 +21,23 @@  discard block
 block discarded – undo
21 21
         'glsr_log' => 3,
22 22
         'glsr_star_rating' => 2,
23 23
     );
24
-    foreach ($hooks as $function => $acceptedArgs) {
25
-        add_filter($function, function () use ($function) {
24
+    foreach( $hooks as $function => $acceptedArgs ) {
25
+        add_filter( $function, function() use ($function) {
26 26
             $args = func_get_args();
27
-            array_shift($args); // remove the fallback value
28
-            return call_user_func_array($function, $args);
29
-        }, 10, $acceptedArgs);
27
+            array_shift( $args ); // remove the fallback value
28
+            return call_user_func_array( $function, $args );
29
+        }, 10, $acceptedArgs );
30 30
     }
31 31
 });
32 32
 
33 33
 /**
34 34
  * @return mixed
35 35
  */
36
-function glsr($alias = null)
36
+function glsr( $alias = null )
37 37
 {
38 38
     $app = \GeminiLabs\SiteReviews\Application::load();
39
-    return !is_null($alias)
40
-        ? $app->make($alias)
39
+    return !is_null( $alias )
40
+        ? $app->make( $alias )
41 41
         : $app;
42 42
 }
43 43
 
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
  * @param $column string
47 47
  * @return array
48 48
  */
49
-function glsr_array_column(array $array, $column)
49
+function glsr_array_column( array $array, $column )
50 50
 {
51 51
     $result = array();
52
-    foreach ($array as $subarray) {
53
-        $subarray = (array) $subarray;
54
-        if (!isset($subarray[$column])) {
52
+    foreach( $array as $subarray ) {
53
+        $subarray = (array)$subarray;
54
+        if( !isset($subarray[$column]) ) {
55 55
             continue;
56 56
         }
57 57
         $result[] = $subarray[$column];
@@ -64,19 +64,19 @@  discard block
 block discarded – undo
64 64
  */
65 65
 function glsr_calculate_ratings()
66 66
 {
67
-    glsr('Controllers\AdminController')->routerCountReviews(false);
68
-    glsr_log()->notice(__('Recalculated rating counts.', 'site-reviews'));
67
+    glsr( 'Controllers\AdminController' )->routerCountReviews( false );
68
+    glsr_log()->notice( __( 'Recalculated rating counts.', 'site-reviews' ) );
69 69
 }
70 70
 
71 71
 /**
72 72
  * @return \GeminiLabs\SiteReviews\Review|false
73 73
  */
74
-function glsr_create_review($reviewValues = array())
74
+function glsr_create_review( $reviewValues = array() )
75 75
 {
76 76
     $review = new \GeminiLabs\SiteReviews\Commands\CreateReview(
77
-        \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($reviewValues)
77
+        \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray( $reviewValues )
78 78
     );
79
-    return glsr('Database\ReviewManager')->create($review);
79
+    return glsr( 'Database\ReviewManager' )->create( $review );
80 80
 }
81 81
 
82 82
 /**
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
  */
85 85
 function glsr_current_screen()
86 86
 {
87
-    if (function_exists('get_current_screen')) {
87
+    if( function_exists( 'get_current_screen' ) ) {
88 88
         $screen = get_current_screen();
89 89
     }
90 90
     return empty($screen)
91
-        ? (object) array_fill_keys(['base', 'id', 'post_type'], null)
91
+        ? (object)array_fill_keys( ['base', 'id', 'post_type'], null )
92 92
         : $screen;
93 93
 }
94 94
 
@@ -96,15 +96,15 @@  discard block
 block discarded – undo
96 96
  * @param mixed ...$vars
97 97
  * @return void
98 98
  */
99
-function glsr_debug(...$vars)
99
+function glsr_debug( ...$vars )
100 100
 {
101
-    if (1 == count($vars)) {
102
-        $value = htmlspecialchars(print_r($vars[0], true), ENT_QUOTES, 'UTF-8');
103
-        printf('<div class="glsr-debug"><pre>%s</pre></div>', $value);
101
+    if( 1 == count( $vars ) ) {
102
+        $value = htmlspecialchars( print_r( $vars[0], true ), ENT_QUOTES, 'UTF-8' );
103
+        printf( '<div class="glsr-debug"><pre>%s</pre></div>', $value );
104 104
     } else {
105 105
         echo '<div class="glsr-debug-group">';
106
-        foreach ($vars as $var) {
107
-            glsr_debug($var);
106
+        foreach( $vars as $var ) {
107
+            glsr_debug( $var );
108 108
         }
109 109
         echo '</div>';
110 110
     }
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
  * @param mixed $fallback
117 117
  * @return mixed
118 118
  */
119
-function glsr_get($array, $path = '', $fallback = '')
119
+function glsr_get( $array, $path = '', $fallback = '' )
120 120
 {
121
-    return \GeminiLabs\SiteReviews\Helpers\Arr::get($array, $path, $fallback);
121
+    return \GeminiLabs\SiteReviews\Helpers\Arr::get( $array, $path, $fallback );
122 122
 }
123 123
 
124 124
 /**
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
  * @param string $cast
128 128
  * @return string|array
129 129
  */
130
-function glsr_get_option($path = '', $fallback = '', $cast = '')
130
+function glsr_get_option( $path = '', $fallback = '', $cast = '' )
131 131
 {
132
-    return is_string($path)
133
-        ? glsr('Database\OptionManager')->get(\GeminiLabs\SiteReviews\Helpers\Str::prefix('settings.', $path), $fallback, $cast)
132
+    return is_string( $path )
133
+        ? glsr( 'Database\OptionManager' )->get( \GeminiLabs\SiteReviews\Helpers\Str::prefix( 'settings.', $path ), $fallback, $cast )
134 134
         : $fallback;
135 135
 }
136 136
 
@@ -139,30 +139,30 @@  discard block
 block discarded – undo
139 139
  */
140 140
 function glsr_get_options()
141 141
 {
142
-    return glsr('Database\OptionManager')->get('settings');
142
+    return glsr( 'Database\OptionManager' )->get( 'settings' );
143 143
 }
144 144
 
145 145
 /**
146 146
  * @param \WP_Post|int $post
147 147
  * @return \GeminiLabs\SiteReviews\Review
148 148
  */
149
-function glsr_get_review($post)
149
+function glsr_get_review( $post )
150 150
 {
151
-    if (is_numeric($post)) {
152
-        $post = get_post($post);
151
+    if( is_numeric( $post ) ) {
152
+        $post = get_post( $post );
153 153
     }
154
-    if (!($post instanceof WP_Post)) {
155
-        $post = new WP_Post((object) []);
154
+    if( !($post instanceof WP_Post) ) {
155
+        $post = new WP_Post( (object)[] );
156 156
     }
157
-    return glsr('Database\ReviewManager')->single($post);
157
+    return glsr( 'Database\ReviewManager' )->single( $post );
158 158
 }
159 159
 
160 160
 /**
161 161
  * @return array
162 162
  */
163
-function glsr_get_reviews($args = array())
163
+function glsr_get_reviews( $args = array() )
164 164
 {
165
-    return glsr('Database\ReviewManager')->get(\GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($args));
165
+    return glsr( 'Database\ReviewManager' )->get( \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray( $args ) );
166 166
 }
167 167
 
168 168
 /**
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 function glsr_log()
172 172
 {
173 173
     $args = func_get_args();
174
-    $console = glsr('Modules\Console');
175
-    if ($value = \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '0')) {
176
-        return $console->debug($value, \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '1', []));
174
+    $console = glsr( 'Modules\Console' );
175
+    if( $value = \GeminiLabs\SiteReviews\Helpers\Arr::get( $args, '0' ) ) {
176
+        return $console->debug( $value, \GeminiLabs\SiteReviews\Helpers\Arr::get( $args, '1', [] ) );
177 177
     }
178 178
     return $console;
179 179
 }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 /**
182 182
  * @return string
183 183
  */
184
-function glsr_star_rating($rating)
184
+function glsr_star_rating( $rating )
185 185
 {
186
-    return glsr('Modules\Html\Partial')->build('star-rating', ['rating' => $rating]);
186
+    return glsr( 'Modules\Html\Partial' )->build( 'star-rating', ['rating' => $rating] );
187 187
 }
Please login to merge, or discard this patch.
activate.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-defined('WPINC') || die;
3
+defined( 'WPINC' ) || die;
4 4
 
5 5
 /**
6 6
  * Check for minimum system requirments on plugin activation.
@@ -24,17 +24,17 @@  discard block
 block discarded – undo
24 24
     /**
25 25
      * @param string $file
26 26
      */
27
-    public function __construct($file)
27
+    public function __construct( $file )
28 28
     {
29
-        $this->file = realpath($file);
30
-        $versionRequirements = get_file_data($this->file, [
29
+        $this->file = realpath( $file );
30
+        $versionRequirements = get_file_data( $this->file, [
31 31
             'php' => 'Requires PHP',
32 32
             'wordpress' => 'Requires at least',
33
-        ]);
34
-        $this->versions = wp_parse_args(array_filter($versionRequirements), [
33
+        ] );
34
+        $this->versions = wp_parse_args( array_filter( $versionRequirements ), [
35 35
             'php' => static::MIN_PHP_VERSION,
36 36
             'wordpress' => static::MIN_WORDPRESS_VERSION,
37
-        ]);
37
+        ] );
38 38
     }
39 39
 
40 40
     /**
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function canProceed()
44 44
     {
45
-        if ($this->isValid()) {
45
+        if( $this->isValid() ) {
46 46
             return true;
47 47
         }
48
-        add_action('activated_plugin', [$this, 'deactivate']);
49
-        add_action('admin_notices', [$this, 'deactivate']);
48
+        add_action( 'activated_plugin', [$this, 'deactivate'] );
49
+        add_action( 'admin_notices', [$this, 'deactivate'] );
50 50
         return false;
51 51
     }
52 52
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      */
56 56
     public function isPhpValid()
57 57
     {
58
-        return !version_compare(PHP_VERSION, $this->versions['php'], '<');
58
+        return !version_compare( PHP_VERSION, $this->versions['php'], '<' );
59 59
     }
60 60
 
61 61
     /**
@@ -72,25 +72,25 @@  discard block
 block discarded – undo
72 72
     public function isWpValid()
73 73
     {
74 74
         global $wp_version;
75
-        return !version_compare($wp_version, $this->versions['wordpress'], '<');
75
+        return !version_compare( $wp_version, $this->versions['wordpress'], '<' );
76 76
     }
77 77
 
78 78
     /**
79 79
      * @param string $plugin
80 80
      * @return void
81 81
      */
82
-    public function deactivate($plugin)
82
+    public function deactivate( $plugin )
83 83
     {
84
-        if ($this->isValid()) {
84
+        if( $this->isValid() ) {
85 85
             return;
86 86
         }
87
-        $pluginSlug = plugin_basename($this->file);
88
-        if ($plugin == $pluginSlug) {
87
+        $pluginSlug = plugin_basename( $this->file );
88
+        if( $plugin == $pluginSlug ) {
89 89
             $this->redirect(); //exit
90 90
         }
91
-        $pluginData = get_file_data($this->file, ['name' => 'Plugin Name'], 'plugin');
92
-        deactivate_plugins($pluginSlug);
93
-        $this->printNotice($pluginData['name']);
91
+        $pluginData = get_file_data( $this->file, ['name' => 'Plugin Name'], 'plugin' );
92
+        deactivate_plugins( $pluginSlug );
93
+        $this->printNotice( $pluginData['name'] );
94 94
     }
95 95
 
96 96
     /**
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
     protected function getMessages()
100 100
     {
101 101
         return [
102
-            'notice' => __('The %s plugin was deactivated.', 'site-reviews'),
103
-            'php_version' => __('PHP version', 'site-reviews'),
104
-            'rollback' => __('You can use the %s plugin to restore %s to the previous version.', 'site-reviews'),
105
-            'update_php' => __('Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'site-reviews'),
106
-            'update_wp' => __('Update WordPress', 'site-reviews'),
107
-            'wp_version' => __('WordPress version', 'site-reviews'),
108
-            'wrong_version' => __('This plugin requires %s or greater in order to work properly.', 'site-reviews'),
102
+            'notice' => __( 'The %s plugin was deactivated.', 'site-reviews' ),
103
+            'php_version' => __( 'PHP version', 'site-reviews' ),
104
+            'rollback' => __( 'You can use the %s plugin to restore %s to the previous version.', 'site-reviews' ),
105
+            'update_php' => __( 'Please contact your hosting provider or server administrator to upgrade the version of PHP on your server (your server is running PHP version %s), or try to find an alternative plugin.', 'site-reviews' ),
106
+            'update_wp' => __( 'Update WordPress', 'site-reviews' ),
107
+            'wp_version' => __( 'WordPress version', 'site-reviews' ),
108
+            'wrong_version' => __( 'This plugin requires %s or greater in order to work properly.', 'site-reviews' ),
109 109
         ];
110 110
     }
111 111
 
@@ -113,22 +113,22 @@  discard block
 block discarded – undo
113 113
      * @param string $pluginName
114 114
      * @return void
115 115
      */
116
-    protected function printNotice($pluginName)
116
+    protected function printNotice( $pluginName )
117 117
     {
118 118
         $noticeTemplate = '<div id="message" class="notice notice-error error is-dismissible"><p><strong>%s</strong></p><p>%s</p><p>%s</p></div>';
119 119
         $messages = $this->getMessages();
120
-        $rollbackMessage = sprintf('<strong>'.$messages['rollback'].'</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/">WP Rollback</a>', $pluginName);
121
-        if (!$this->isPhpValid()) {
122
-            printf($noticeTemplate,
123
-                sprintf($messages['notice'], $pluginName),
124
-                sprintf($messages['wrong_version'], $messages['php_version'].' '.$this->versions['php']),
125
-                sprintf($messages['update_php'], PHP_VERSION).'</p><p>'.$rollbackMessage
120
+        $rollbackMessage = sprintf( '<strong>'.$messages['rollback'].'</strong>', '<a href="https://wordpress.org/plugins/wp-rollback/">WP Rollback</a>', $pluginName );
121
+        if( !$this->isPhpValid() ) {
122
+            printf( $noticeTemplate,
123
+                sprintf( $messages['notice'], $pluginName ),
124
+                sprintf( $messages['wrong_version'], $messages['php_version'].' '.$this->versions['php'] ),
125
+                sprintf( $messages['update_php'], PHP_VERSION ).'</p><p>'.$rollbackMessage
126 126
             );
127
-        } elseif (!$this->isWpValid()) {
128
-            printf($noticeTemplate,
129
-                sprintf($messages['notice'], $pluginName),
130
-                sprintf($messages['wrong_version'], $messages['wp_version'].' '.$this->versions['wordpress']),
131
-                $rollbackMessage.'</p><p>'.sprintf('<a href="%s">%s</a>', admin_url('update-core.php'), $messages['update_wp'])
127
+        } elseif( !$this->isWpValid() ) {
128
+            printf( $noticeTemplate,
129
+                sprintf( $messages['notice'], $pluginName ),
130
+                sprintf( $messages['wrong_version'], $messages['wp_version'].' '.$this->versions['wordpress'] ),
131
+                $rollbackMessage.'</p><p>'.sprintf( '<a href="%s">%s</a>', admin_url( 'update-core.php' ), $messages['update_wp'] )
132 132
             );
133 133
         }
134 134
     }
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
      */
139 139
     protected function redirect()
140 140
     {
141
-        wp_safe_redirect(self_admin_url(sprintf('plugins.php?plugin_status=%s&paged=%s&s=%s',
142
-            filter_input(INPUT_GET, 'plugin_status'),
143
-            filter_input(INPUT_GET, 'paged'),
144
-            filter_input(INPUT_GET, 's')
145
-        )));
141
+        wp_safe_redirect( self_admin_url( sprintf( 'plugins.php?plugin_status=%s&paged=%s&s=%s',
142
+            filter_input( INPUT_GET, 'plugin_status' ),
143
+            filter_input( INPUT_GET, 'paged' ),
144
+            filter_input( INPUT_GET, 's' )
145
+        ) ) );
146 146
         exit;
147 147
     }
148 148
 }
Please login to merge, or discard this patch.
plugin/Controllers/NoticeController.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
     public function __construct()
19 19
     {
20 20
         $this->dismissValuesMap = [
21
-            'rebusify' => glsr()->version('major'),
22
-            'welcome' => glsr()->version('minor'),
21
+            'rebusify' => glsr()->version( 'major' ),
22
+            'welcome' => glsr()->version( 'minor' ),
23 23
         ];
24 24
     }
25 25
 
@@ -30,18 +30,18 @@  discard block
 block discarded – undo
30 30
     public function filterAdminNotices()
31 31
     {
32 32
         $screen = glsr_current_screen();
33
-        $this->renderWelcomeNotice($screen->post_type);
34
-        $this->renderRebusifyNotice($screen->post_type);
35
-        $this->renderAddonsNotice($screen->id);
33
+        $this->renderWelcomeNotice( $screen->post_type );
34
+        $this->renderRebusifyNotice( $screen->post_type );
35
+        $this->renderAddonsNotice( $screen->id );
36 36
     }
37 37
 
38 38
     /**
39 39
      * @return void
40 40
      */
41
-    public function routerDismissNotice(array $request)
41
+    public function routerDismissNotice( array $request )
42 42
     {
43
-        if ($key = Arr::get($request, 'notice')) {
44
-            $this->dismissNotice($key);
43
+        if( $key = Arr::get( $request, 'notice' ) ) {
44
+            $this->dismissNotice( $key );
45 45
         }
46 46
     }
47 47
 
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
      * @param string $key
50 50
      * @return void
51 51
      */
52
-    protected function dismissNotice($key)
52
+    protected function dismissNotice( $key )
53 53
     {
54
-        $this->setUserMeta($key, $this->getVersionFor($key));
54
+        $this->setUserMeta( $key, $this->getVersionFor( $key ) );
55 55
     }
56 56
 
57 57
     /**
@@ -59,29 +59,29 @@  discard block
 block discarded – undo
59 59
      * @param mixed $fallback
60 60
      * @return mixed
61 61
      */
62
-    protected function getUserMeta($key, $fallback)
62
+    protected function getUserMeta( $key, $fallback )
63 63
     {
64
-        $meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true);
65
-        return Arr::get($meta, $key, $fallback);
64
+        $meta = get_user_meta( get_current_user_id(), static::USER_META_KEY, true );
65
+        return Arr::get( $meta, $key, $fallback );
66 66
     }
67 67
 
68 68
     /**
69 69
      * @param string $noticeKey
70 70
      * @return string
71 71
      */
72
-    protected function getVersionFor($noticeKey)
72
+    protected function getVersionFor( $noticeKey )
73 73
     {
74
-        return Arr::get($this->dismissValuesMap, $noticeKey, glsr()->version('major'));
74
+        return Arr::get( $this->dismissValuesMap, $noticeKey, glsr()->version( 'major' ) );
75 75
     }
76 76
 
77 77
     /**
78 78
      * @param string $screenId
79 79
      * @return void
80 80
      */
81
-    protected function renderAddonsNotice($screenId)
81
+    protected function renderAddonsNotice( $screenId )
82 82
     {
83
-        if (Application::POST_TYPE.'_page_addons' == $screenId) {
84
-            glsr()->render('partials/notices/addons');
83
+        if( Application::POST_TYPE.'_page_addons' == $screenId ) {
84
+            glsr()->render( 'partials/notices/addons' );
85 85
         }
86 86
     }
87 87
 
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
      * @param string $screenPostType
90 90
      * @return void
91 91
      */
92
-    protected function renderRebusifyNotice($screenPostType)
92
+    protected function renderRebusifyNotice( $screenPostType )
93 93
     {
94
-        if (Application::POST_TYPE == $screenPostType
95
-            && version_compare($this->getVersionFor('rebusify'), $this->getUserMeta('rebusify', 0), '>')
96
-            && !glsr(OptionManager::class)->getBool('settings.general.rebusify')) {
97
-            glsr()->render('partials/notices/rebusify');
94
+        if( Application::POST_TYPE == $screenPostType
95
+            && version_compare( $this->getVersionFor( 'rebusify' ), $this->getUserMeta( 'rebusify', 0 ), '>' )
96
+            && !glsr( OptionManager::class )->getBool( 'settings.general.rebusify' ) ) {
97
+            glsr()->render( 'partials/notices/rebusify' );
98 98
         }
99 99
     }
100 100
 
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
      * @param string $screenPostType
103 103
      * @return void
104 104
      */
105
-    protected function renderWelcomeNotice($screenPostType)
105
+    protected function renderWelcomeNotice( $screenPostType )
106 106
     {
107
-        if (Application::POST_TYPE == $screenPostType
108
-            && version_compare($this->getVersionFor('welcome'), $this->getUserMeta('welcome', 0), '>')) {
109
-            $welcomeText = '0.0.0' == glsr(OptionManager::class)->get('version_upgraded_from')
110
-                ? __('Thanks for installing Site Reviews %s, we hope you love it!', 'site-reviews')
111
-                : __('Thanks for updating to Site Reviews %s, we hope you love the changes!', 'site-reviews');
112
-            glsr()->render('partials/notices/welcome', [
113
-                'text' => sprintf($welcomeText, glsr()->version),
114
-            ]);
107
+        if( Application::POST_TYPE == $screenPostType
108
+            && version_compare( $this->getVersionFor( 'welcome' ), $this->getUserMeta( 'welcome', 0 ), '>' ) ) {
109
+            $welcomeText = '0.0.0' == glsr( OptionManager::class )->get( 'version_upgraded_from' )
110
+                ? __( 'Thanks for installing Site Reviews %s, we hope you love it!', 'site-reviews' )
111
+                : __( 'Thanks for updating to Site Reviews %s, we hope you love the changes!', 'site-reviews' );
112
+            glsr()->render( 'partials/notices/welcome', [
113
+                'text' => sprintf( $welcomeText, glsr()->version ),
114
+            ] );
115 115
         }
116 116
     }
117 117
 
@@ -120,12 +120,12 @@  discard block
 block discarded – undo
120 120
      * @param mixed $fallback
121 121
      * @return mixed
122 122
      */
123
-    protected function setUserMeta($key, $value)
123
+    protected function setUserMeta( $key, $value )
124 124
     {
125 125
         $userId = get_current_user_id();
126
-        $meta = (array) get_user_meta($userId, static::USER_META_KEY, true);
127
-        $meta = array_filter(wp_parse_args($meta, []));
126
+        $meta = (array)get_user_meta( $userId, static::USER_META_KEY, true );
127
+        $meta = array_filter( wp_parse_args( $meta, [] ) );
128 128
         $meta[$key] = $value;
129
-        update_user_meta($userId, static::USER_META_KEY, $meta);
129
+        update_user_meta( $userId, static::USER_META_KEY, $meta );
130 130
     }
131 131
 }
Please login to merge, or discard this patch.
plugin/Shortcodes/Shortcode.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -32,15 +32,15 @@  discard block
 block discarded – undo
32 32
      * @param string $type
33 33
      * @return string
34 34
      */
35
-    public function build($atts, array $args = [], $type = 'shortcode')
35
+    public function build( $atts, array $args = [], $type = 'shortcode' )
36 36
     {
37
-        $args = $this->normalizeArgs($args, $type);
38
-        $atts = $this->normalizeAtts($atts, $type);
39
-        $partial = glsr(Partial::class)->build($this->partialName, $atts);
37
+        $args = $this->normalizeArgs( $args, $type );
38
+        $atts = $this->normalizeAtts( $atts, $type );
39
+        $partial = glsr( Partial::class )->build( $this->partialName, $atts );
40 40
         $title = !empty($atts['title'])
41 41
             ? $args['before_title'].$atts['title'].$args['after_title']
42 42
             : '';
43
-        $debug = sprintf('<glsr-%1$s hidden data-atts=\'%2$s\'></glsr-%1$s>', $type, $atts['json']);
43
+        $debug = sprintf( '<glsr-%1$s hidden data-atts=\'%2$s\'></glsr-%1$s>', $type, $atts['json'] );
44 44
         return $args['before_widget'].$title.$partial.$debug.$args['after_widget'];
45 45
     }
46 46
 
@@ -48,17 +48,17 @@  discard block
 block discarded – undo
48 48
      * @param string|array $atts
49 49
      * @return string
50 50
      */
51
-    public function buildShortcode($atts = [])
51
+    public function buildShortcode( $atts = [] )
52 52
     {
53
-        return $this->build($atts);
53
+        return $this->build( $atts );
54 54
     }
55 55
 
56 56
     /**
57 57
      * @return array
58 58
      */
59
-    public function getDefaults($atts)
59
+    public function getDefaults( $atts )
60 60
     {
61
-        return glsr($this->getShortcodeDefaultsClassName())->restrict(wp_parse_args($atts));
61
+        return glsr( $this->getShortcodeDefaultsClassName() )->restrict( wp_parse_args( $atts ) );
62 62
     }
63 63
 
64 64
     /**
@@ -67,15 +67,15 @@  discard block
 block discarded – undo
67 67
     public function getHideOptions()
68 68
     {
69 69
         $options = $this->hideOptions();
70
-        return apply_filters('site-reviews/shortcode/hide-options', $options, $this->shortcodeName);
70
+        return apply_filters( 'site-reviews/shortcode/hide-options', $options, $this->shortcodeName );
71 71
     }
72 72
 
73 73
     /**
74 74
      * @return string
75 75
      */
76
-    public function getShortcodeClassName($replace = '', $search = 'Shortcode')
76
+    public function getShortcodeClassName( $replace = '', $search = 'Shortcode' )
77 77
     {
78
-        return str_replace($search, $replace, (new ReflectionClass($this))->getShortName());
78
+        return str_replace( $search, $replace, (new ReflectionClass( $this ))->getShortName() );
79 79
     }
80 80
 
81 81
     /**
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     public function getShortcodeDefaultsClassName()
85 85
     {
86 86
         return Helper::buildClassName(
87
-            $this->getShortcodeClassName('Defaults'),
87
+            $this->getShortcodeClassName( 'Defaults' ),
88 88
             'Defaults'
89 89
         );
90 90
     }
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function getShortcodeName()
96 96
     {
97
-        return Str::snakeCase($this->getShortcodeClassName());
97
+        return Str::snakeCase( $this->getShortcodeClassName() );
98 98
     }
99 99
 
100 100
     /**
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function getShortcodePartialName()
104 104
     {
105
-        return Str::dashCase($this->getShortcodeClassName());
105
+        return Str::dashCase( $this->getShortcodeClassName() );
106 106
     }
107 107
 
108 108
     /**
@@ -110,15 +110,15 @@  discard block
 block discarded – undo
110 110
      * @param string $type
111 111
      * @return array
112 112
      */
113
-    public function normalizeArgs($args, $type = 'shortcode')
113
+    public function normalizeArgs( $args, $type = 'shortcode' )
114 114
     {
115
-        $args = wp_parse_args($args, [
115
+        $args = wp_parse_args( $args, [
116 116
             'before_widget' => '<div class="glsr-'.$type.' '.$type.'-'.$this->partialName.'">',
117 117
             'after_widget' => '</div>',
118 118
             'before_title' => '<h3 class="glsr-'.$type.'-title">',
119 119
             'after_title' => '</h3>',
120
-        ]);
121
-        return apply_filters('site-reviews/shortcode/args', $args, $type, $this->partialName);
120
+        ] );
121
+        return apply_filters( 'site-reviews/shortcode/args', $args, $type, $this->partialName );
122 122
     }
123 123
 
124 124
     /**
@@ -126,16 +126,16 @@  discard block
 block discarded – undo
126 126
      * @param string $type
127 127
      * @return array
128 128
      */
129
-    public function normalizeAtts($atts, $type = 'shortcode')
129
+    public function normalizeAtts( $atts, $type = 'shortcode' )
130 130
     {
131
-        $atts = apply_filters('site-reviews/shortcode/atts', $atts, $type, $this->partialName);
132
-        $atts = $this->getDefaults($atts);
133
-        array_walk($atts, function (&$value, $key) {
134
-            $methodName = Helper::buildMethodName($key, 'normalize');
135
-            if (!method_exists($this, $methodName)) {
131
+        $atts = apply_filters( 'site-reviews/shortcode/atts', $atts, $type, $this->partialName );
132
+        $atts = $this->getDefaults( $atts );
133
+        array_walk( $atts, function( &$value, $key ) {
134
+            $methodName = Helper::buildMethodName( $key, 'normalize' );
135
+            if( !method_exists( $this, $methodName ) ) {
136 136
                 return;
137 137
             }
138
-            $value = $this->$methodName($value);
138
+            $value = $this->$methodName( $value );
139 139
         });
140 140
         return $atts;
141 141
     }
@@ -149,12 +149,12 @@  discard block
 block discarded – undo
149 149
      * @param string $postId
150 150
      * @return int|string
151 151
      */
152
-    protected function normalizeAssignedTo($postId)
152
+    protected function normalizeAssignedTo( $postId )
153 153
     {
154
-        if ('parent_id' == $postId) {
155
-            $postId = intval(wp_get_post_parent_id(intval(get_the_ID())));
156
-        } elseif ('post_id' == $postId) {
157
-            $postId = intval(get_the_ID());
154
+        if( 'parent_id' == $postId ) {
155
+            $postId = intval( wp_get_post_parent_id( intval( get_the_ID() ) ) );
156
+        } elseif( 'post_id' == $postId ) {
157
+            $postId = intval( get_the_ID() );
158 158
         }
159 159
         return $postId;
160 160
     }
@@ -163,23 +163,23 @@  discard block
 block discarded – undo
163 163
      * @param string $postId
164 164
      * @return int|string
165 165
      */
166
-    protected function normalizeAssignTo($postId)
166
+    protected function normalizeAssignTo( $postId )
167 167
     {
168
-        return $this->normalizeAssignedTo($postId);
168
+        return $this->normalizeAssignedTo( $postId );
169 169
     }
170 170
 
171 171
     /**
172 172
      * @param string|array $hide
173 173
      * @return array
174 174
      */
175
-    protected function normalizeHide($hide)
175
+    protected function normalizeHide( $hide )
176 176
     {
177
-        if (is_string($hide)) {
178
-            $hide = explode(',', $hide);
177
+        if( is_string( $hide ) ) {
178
+            $hide = explode( ',', $hide );
179 179
         }
180
-        $hideKeys = array_keys($this->getHideOptions());
181
-        return array_filter(array_map('trim', $hide), function ($value) use ($hideKeys) {
182
-            return in_array($value, $hideKeys);
180
+        $hideKeys = array_keys( $this->getHideOptions() );
181
+        return array_filter( array_map( 'trim', $hide ), function( $value ) use ($hideKeys) {
182
+            return in_array( $value, $hideKeys );
183 183
         });
184 184
     }
185 185
 
@@ -187,51 +187,51 @@  discard block
 block discarded – undo
187 187
      * @param string $id
188 188
      * @return string
189 189
      */
190
-    protected function normalizeId($id)
190
+    protected function normalizeId( $id )
191 191
     {
192
-        return sanitize_title($id);
192
+        return sanitize_title( $id );
193 193
     }
194 194
 
195 195
     /**
196 196
      * @param string $labels
197 197
      * @return array
198 198
      */
199
-    protected function normalizeLabels($labels)
199
+    protected function normalizeLabels( $labels )
200 200
     {
201 201
         $defaults = [
202
-            __('Excellent', 'site-reviews'),
203
-            __('Very good', 'site-reviews'),
204
-            __('Average', 'site-reviews'),
205
-            __('Poor', 'site-reviews'),
206
-            __('Terrible', 'site-reviews'),
202
+            __( 'Excellent', 'site-reviews' ),
203
+            __( 'Very good', 'site-reviews' ),
204
+            __( 'Average', 'site-reviews' ),
205
+            __( 'Poor', 'site-reviews' ),
206
+            __( 'Terrible', 'site-reviews' ),
207 207
         ];
208
-        $maxRating = (int) glsr()->constant('MAX_RATING', Rating::class);
209
-        $defaults = array_pad(array_slice($defaults, 0, $maxRating), $maxRating, '');
210
-        $labels = array_map('trim', explode(',', $labels));
211
-        foreach ($defaults as $i => $label) {
212
-            if (empty($labels[$i])) {
208
+        $maxRating = (int)glsr()->constant( 'MAX_RATING', Rating::class );
209
+        $defaults = array_pad( array_slice( $defaults, 0, $maxRating ), $maxRating, '' );
210
+        $labels = array_map( 'trim', explode( ',', $labels ) );
211
+        foreach( $defaults as $i => $label ) {
212
+            if( empty($labels[$i]) ) {
213 213
                 continue;
214 214
             }
215 215
             $defaults[$i] = $labels[$i];
216 216
         }
217
-        return array_combine(range($maxRating, 1), $defaults);
217
+        return array_combine( range( $maxRating, 1 ), $defaults );
218 218
     }
219 219
 
220 220
     /**
221 221
      * @param string $schema
222 222
      * @return bool
223 223
      */
224
-    protected function normalizeSchema($schema)
224
+    protected function normalizeSchema( $schema )
225 225
     {
226
-        return wp_validate_boolean($schema);
226
+        return wp_validate_boolean( $schema );
227 227
     }
228 228
 
229 229
     /**
230 230
      * @param string $text
231 231
      * @return string
232 232
      */
233
-    protected function normalizeText($text)
233
+    protected function normalizeText( $text )
234 234
     {
235
-        return trim($text);
235
+        return trim( $text );
236 236
     }
237 237
 }
Please login to merge, or discard this patch.