Passed
Push — master ( 6b35fa...ccb079 )
by Paul
10:24 queued 05:13
created
plugin/Controllers/Controller.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -10,55 +10,55 @@
 block discarded – undo
10 10
 
11 11
 abstract class Controller
12 12
 {
13
-    /**
14
-     * @return void
15
-     */
16
-    public function download($filename, $content)
17
-    {
18
-        if (!glsr()->can('edit_others_posts')) {
19
-            return;
20
-        }
21
-        nocache_headers();
22
-        header('Content-Type: text/plain');
23
-        header('Content-Disposition: attachment; filename="'.$filename.'"');
24
-        echo html_entity_decode($content);
25
-        exit;
26
-    }
13
+	/**
14
+	 * @return void
15
+	 */
16
+	public function download($filename, $content)
17
+	{
18
+		if (!glsr()->can('edit_others_posts')) {
19
+			return;
20
+		}
21
+		nocache_headers();
22
+		header('Content-Type: text/plain');
23
+		header('Content-Disposition: attachment; filename="'.$filename.'"');
24
+		echo html_entity_decode($content);
25
+		exit;
26
+	}
27 27
 
28
-    /**
29
-     * @param object $command
30
-     * @return mixed
31
-     * @throws InvalidArgumentException
32
-     */
33
-    public function execute($command)
34
-    {
35
-        $handlerClass = str_replace('Commands', 'Handlers', get_class($command));
36
-        if (!class_exists($handlerClass)) {
37
-            throw new InvalidArgumentException('Handler '.$handlerClass.' not found.');
38
-        }
39
-        try {
40
-            return glsr($handlerClass)->handle($command);
41
-        } catch (Exception $e) {
42
-            status_header(400);
43
-            glsr(Notice::class)->addError(new WP_Error('site_reviews_error', $e->getMessage()));
44
-            glsr_log()->error($e->getMessage());
45
-        }
46
-    }
28
+	/**
29
+	 * @param object $command
30
+	 * @return mixed
31
+	 * @throws InvalidArgumentException
32
+	 */
33
+	public function execute($command)
34
+	{
35
+		$handlerClass = str_replace('Commands', 'Handlers', get_class($command));
36
+		if (!class_exists($handlerClass)) {
37
+			throw new InvalidArgumentException('Handler '.$handlerClass.' not found.');
38
+		}
39
+		try {
40
+			return glsr($handlerClass)->handle($command);
41
+		} catch (Exception $e) {
42
+			status_header(400);
43
+			glsr(Notice::class)->addError(new WP_Error('site_reviews_error', $e->getMessage()));
44
+			glsr_log()->error($e->getMessage());
45
+		}
46
+	}
47 47
 
48
-    /**
49
-     * @return int
50
-     */
51
-    protected function getPostId()
52
-    {
53
-        return intval(filter_input(INPUT_GET, 'post'));
54
-    }
48
+	/**
49
+	 * @return int
50
+	 */
51
+	protected function getPostId()
52
+	{
53
+		return intval(filter_input(INPUT_GET, 'post'));
54
+	}
55 55
 
56
-    /**
57
-     * @param int $postId
58
-     * @return bool
59
-     */
60
-    protected function isReviewPostId($postId)
61
-    {
62
-        return Application::POST_TYPE == get_post_field('post_type', $postId);
63
-    }
56
+	/**
57
+	 * @param int $postId
58
+	 * @return bool
59
+	 */
60
+	protected function isReviewPostId($postId)
61
+	{
62
+		return Application::POST_TYPE == get_post_field('post_type', $postId);
63
+	}
64 64
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
13 13
     /**
14 14
      * @return void
15 15
      */
16
-    public function download($filename, $content)
16
+    public function download( $filename, $content )
17 17
     {
18
-        if (!glsr()->can('edit_others_posts')) {
18
+        if( !glsr()->can( 'edit_others_posts' ) ) {
19 19
             return;
20 20
         }
21 21
         nocache_headers();
22
-        header('Content-Type: text/plain');
23
-        header('Content-Disposition: attachment; filename="'.$filename.'"');
24
-        echo html_entity_decode($content);
22
+        header( 'Content-Type: text/plain' );
23
+        header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
24
+        echo html_entity_decode( $content );
25 25
         exit;
26 26
     }
27 27
 
@@ -30,18 +30,18 @@  discard block
 block discarded – undo
30 30
      * @return mixed
31 31
      * @throws InvalidArgumentException
32 32
      */
33
-    public function execute($command)
33
+    public function execute( $command )
34 34
     {
35
-        $handlerClass = str_replace('Commands', 'Handlers', get_class($command));
36
-        if (!class_exists($handlerClass)) {
37
-            throw new InvalidArgumentException('Handler '.$handlerClass.' not found.');
35
+        $handlerClass = str_replace( 'Commands', 'Handlers', get_class( $command ) );
36
+        if( !class_exists( $handlerClass ) ) {
37
+            throw new InvalidArgumentException( 'Handler '.$handlerClass.' not found.' );
38 38
         }
39 39
         try {
40
-            return glsr($handlerClass)->handle($command);
41
-        } catch (Exception $e) {
42
-            status_header(400);
43
-            glsr(Notice::class)->addError(new WP_Error('site_reviews_error', $e->getMessage()));
44
-            glsr_log()->error($e->getMessage());
40
+            return glsr( $handlerClass )->handle( $command );
41
+        } catch( Exception $e ) {
42
+            status_header( 400 );
43
+            glsr( Notice::class )->addError( new WP_Error( 'site_reviews_error', $e->getMessage() ) );
44
+            glsr_log()->error( $e->getMessage() );
45 45
         }
46 46
     }
47 47
 
@@ -50,15 +50,15 @@  discard block
 block discarded – undo
50 50
      */
51 51
     protected function getPostId()
52 52
     {
53
-        return intval(filter_input(INPUT_GET, 'post'));
53
+        return intval( filter_input( INPUT_GET, 'post' ) );
54 54
     }
55 55
 
56 56
     /**
57 57
      * @param int $postId
58 58
      * @return bool
59 59
      */
60
-    protected function isReviewPostId($postId)
60
+    protected function isReviewPostId( $postId )
61 61
     {
62
-        return Application::POST_TYPE == get_post_field('post_type', $postId);
62
+        return Application::POST_TYPE == get_post_field( 'post_type', $postId );
63 63
     }
64 64
 }
Please login to merge, or discard this patch.
plugin/Controllers/AdminController.php 2 patches
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -18,248 +18,248 @@
 block discarded – undo
18 18
 
19 19
 class AdminController extends Controller
20 20
 {
21
-    /**
22
-     * @return void
23
-     * @action admin_enqueue_scripts
24
-     */
25
-    public function enqueueAssets()
26
-    {
27
-        $command = new EnqueueAdminAssets([
28
-            'pointers' => [[
29
-                'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'),
30
-                'id' => 'glsr-pointer-pinned',
31
-                'position' => [
32
-                    'edge' => 'right',
33
-                    'align' => 'middle',
34
-                ],
35
-                'screen' => Application::POST_TYPE,
36
-                'target' => '#misc-pub-pinned',
37
-                'title' => __('Pin Your Reviews', 'site-reviews'),
38
-            ]],
39
-        ]);
40
-        $this->execute($command);
41
-    }
21
+	/**
22
+	 * @return void
23
+	 * @action admin_enqueue_scripts
24
+	 */
25
+	public function enqueueAssets()
26
+	{
27
+		$command = new EnqueueAdminAssets([
28
+			'pointers' => [[
29
+				'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'),
30
+				'id' => 'glsr-pointer-pinned',
31
+				'position' => [
32
+					'edge' => 'right',
33
+					'align' => 'middle',
34
+				],
35
+				'screen' => Application::POST_TYPE,
36
+				'target' => '#misc-pub-pinned',
37
+				'title' => __('Pin Your Reviews', 'site-reviews'),
38
+			]],
39
+		]);
40
+		$this->execute($command);
41
+	}
42 42
 
43
-    /**
44
-     * @return array
45
-     * @filter plugin_action_links_site-reviews/site-reviews.php
46
-     */
47
-    public function filterActionLinks(array $links)
48
-    {
49
-        $links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [
50
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'),
51
-        ]);
52
-        $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
53
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'),
54
-        ]);
55
-        return $links;
56
-    }
43
+	/**
44
+	 * @return array
45
+	 * @filter plugin_action_links_site-reviews/site-reviews.php
46
+	 */
47
+	public function filterActionLinks(array $links)
48
+	{
49
+		$links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [
50
+			'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'),
51
+		]);
52
+		$links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
53
+			'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'),
54
+		]);
55
+		return $links;
56
+	}
57 57
 
58
-    /**
59
-     * @param array $capabilities
60
-     * @param string $capability
61
-     * @return array
62
-     * @filter map_meta_cap
63
-     */
64
-    public function filterCreateCapability($capabilities, $capability)
65
-    {
66
-        if ($capability == 'create_'.Application::POST_TYPE) {
67
-            $capabilities[] = 'do_not_allow';
68
-        }
69
-        return $capabilities;
70
-    }
58
+	/**
59
+	 * @param array $capabilities
60
+	 * @param string $capability
61
+	 * @return array
62
+	 * @filter map_meta_cap
63
+	 */
64
+	public function filterCreateCapability($capabilities, $capability)
65
+	{
66
+		if ($capability == 'create_'.Application::POST_TYPE) {
67
+			$capabilities[] = 'do_not_allow';
68
+		}
69
+		return $capabilities;
70
+	}
71 71
 
72
-    /**
73
-     * @param array $items
74
-     * @return array
75
-     * @filter dashboard_glance_items
76
-     */
77
-    public function filterDashboardGlanceItems($items)
78
-    {
79
-        $postCount = wp_count_posts(Application::POST_TYPE);
80
-        if (empty($postCount->publish)) {
81
-            return $items;
82
-        }
83
-        $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews');
84
-        $text = sprintf($text, number_format_i18n($postCount->publish));
85
-        $items = Arr::consolidateArray($items);
86
-        $items[] = glsr()->can('edit_posts')
87
-            ? glsr(Builder::class)->a($text, [
88
-                'class' => 'glsr-review-count',
89
-                'href' => 'edit.php?post_type='.Application::POST_TYPE,
90
-            ])
91
-            : glsr(Builder::class)->span($text, [
92
-                'class' => 'glsr-review-count',
93
-            ]);
94
-        return $items;
95
-    }
72
+	/**
73
+	 * @param array $items
74
+	 * @return array
75
+	 * @filter dashboard_glance_items
76
+	 */
77
+	public function filterDashboardGlanceItems($items)
78
+	{
79
+		$postCount = wp_count_posts(Application::POST_TYPE);
80
+		if (empty($postCount->publish)) {
81
+			return $items;
82
+		}
83
+		$text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews');
84
+		$text = sprintf($text, number_format_i18n($postCount->publish));
85
+		$items = Arr::consolidateArray($items);
86
+		$items[] = glsr()->can('edit_posts')
87
+			? glsr(Builder::class)->a($text, [
88
+				'class' => 'glsr-review-count',
89
+				'href' => 'edit.php?post_type='.Application::POST_TYPE,
90
+			])
91
+			: glsr(Builder::class)->span($text, [
92
+				'class' => 'glsr-review-count',
93
+			]);
94
+		return $items;
95
+	}
96 96
 
97
-    /**
98
-     * @param array $plugins
99
-     * @return array
100
-     * @filter mce_external_plugins
101
-     */
102
-    public function filterTinymcePlugins($plugins)
103
-    {
104
-        if (glsr()->can('edit_posts')) {
105
-            $plugins = Arr::consolidateArray($plugins);
106
-            $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js');
107
-        }
108
-        return $plugins;
109
-    }
97
+	/**
98
+	 * @param array $plugins
99
+	 * @return array
100
+	 * @filter mce_external_plugins
101
+	 */
102
+	public function filterTinymcePlugins($plugins)
103
+	{
104
+		if (glsr()->can('edit_posts')) {
105
+			$plugins = Arr::consolidateArray($plugins);
106
+			$plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js');
107
+		}
108
+		return $plugins;
109
+	}
110 110
 
111
-    /**
112
-     * @return void
113
-     * @action admin_init
114
-     */
115
-    public function registerTinymcePopups()
116
-    {
117
-        $command = new RegisterTinymcePopups([
118
-            'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'),
119
-            'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'),
120
-            'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'),
121
-        ]);
122
-        $this->execute($command);
123
-    }
111
+	/**
112
+	 * @return void
113
+	 * @action admin_init
114
+	 */
115
+	public function registerTinymcePopups()
116
+	{
117
+		$command = new RegisterTinymcePopups([
118
+			'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'),
119
+			'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'),
120
+			'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'),
121
+		]);
122
+		$this->execute($command);
123
+	}
124 124
 
125
-    /**
126
-     * @param string $editorId
127
-     * @return void|null
128
-     * @action media_buttons
129
-     */
130
-    public function renderTinymceButton($editorId)
131
-    {
132
-        $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId);
133
-        if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) {
134
-            return;
135
-        }
136
-        $shortcodes = [];
137
-        foreach (glsr()->mceShortcodes as $shortcode => $values) {
138
-            $shortcodes[$shortcode] = $values;
139
-        }
140
-        if (empty($shortcodes)) {
141
-            return;
142
-        }
143
-        glsr()->render('partials/editor/tinymce', [
144
-            'shortcodes' => $shortcodes,
145
-        ]);
146
-    }
125
+	/**
126
+	 * @param string $editorId
127
+	 * @return void|null
128
+	 * @action media_buttons
129
+	 */
130
+	public function renderTinymceButton($editorId)
131
+	{
132
+		$allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId);
133
+		if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) {
134
+			return;
135
+		}
136
+		$shortcodes = [];
137
+		foreach (glsr()->mceShortcodes as $shortcode => $values) {
138
+			$shortcodes[$shortcode] = $values;
139
+		}
140
+		if (empty($shortcodes)) {
141
+			return;
142
+		}
143
+		glsr()->render('partials/editor/tinymce', [
144
+			'shortcodes' => $shortcodes,
145
+		]);
146
+	}
147 147
 
148
-    /**
149
-     * @return void
150
-     */
151
-    public function routerClearConsole()
152
-    {
153
-        glsr(Console::class)->clear();
154
-        glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews'));
155
-    }
148
+	/**
149
+	 * @return void
150
+	 */
151
+	public function routerClearConsole()
152
+	{
153
+		glsr(Console::class)->clear();
154
+		glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews'));
155
+	}
156 156
 
157
-    /**
158
-     * @return void
159
-     */
160
-    public function routerCountReviews()
161
-    {
162
-        glsr(CountsManager::class)->updateAll();
163
-        glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews'));
164
-    }
157
+	/**
158
+	 * @return void
159
+	 */
160
+	public function routerCountReviews()
161
+	{
162
+		glsr(CountsManager::class)->updateAll();
163
+		glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews'));
164
+	}
165 165
 
166
-    /**
167
-     * @return void
168
-     */
169
-    public function routerDownloadConsole()
170
-    {
171
-        $this->download(Application::ID.'-console.txt', glsr(Console::class)->get());
172
-    }
166
+	/**
167
+	 * @return void
168
+	 */
169
+	public function routerDownloadConsole()
170
+	{
171
+		$this->download(Application::ID.'-console.txt', glsr(Console::class)->get());
172
+	}
173 173
 
174
-    /**
175
-     * @return void
176
-     */
177
-    public function routerDownloadSystemInfo()
178
-    {
179
-        $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get());
180
-    }
174
+	/**
175
+	 * @return void
176
+	 */
177
+	public function routerDownloadSystemInfo()
178
+	{
179
+		$this->download(Application::ID.'-system-info.txt', glsr(System::class)->get());
180
+	}
181 181
 
182
-    /**
183
-     * @return void
184
-     */
185
-    public function routerExportSettings()
186
-    {
187
-        $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json());
188
-    }
182
+	/**
183
+	 * @return void
184
+	 */
185
+	public function routerExportSettings()
186
+	{
187
+		$this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json());
188
+	}
189 189
 
190
-    /**
191
-     * @return void
192
-     */
193
-    public function routerFetchConsole()
194
-    {
195
-        glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews'));
196
-    }
190
+	/**
191
+	 * @return void
192
+	 */
193
+	public function routerFetchConsole()
194
+	{
195
+		glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews'));
196
+	}
197 197
 
198
-    /**
199
-     * @return void
200
-     */
201
-    public function routerImportSettings()
202
-    {
203
-        $file = $_FILES['import-file'];
204
-        if (UPLOAD_ERR_OK !== $file['error']) {
205
-            return glsr(Notice::class)->addError($this->getUploadError($file['error']));
206
-        }
207
-        if ('application/json' !== $file['type'] || !Str::endsWith('.json', $file['name'])) {
208
-            return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews'));
209
-        }
210
-        $settings = json_decode(file_get_contents($file['tmp_name']), true);
211
-        if (empty($settings)) {
212
-            return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews'));
213
-        }
214
-        glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings));
215
-        glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews'));
216
-    }
198
+	/**
199
+	 * @return void
200
+	 */
201
+	public function routerImportSettings()
202
+	{
203
+		$file = $_FILES['import-file'];
204
+		if (UPLOAD_ERR_OK !== $file['error']) {
205
+			return glsr(Notice::class)->addError($this->getUploadError($file['error']));
206
+		}
207
+		if ('application/json' !== $file['type'] || !Str::endsWith('.json', $file['name'])) {
208
+			return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews'));
209
+		}
210
+		$settings = json_decode(file_get_contents($file['tmp_name']), true);
211
+		if (empty($settings)) {
212
+			return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews'));
213
+		}
214
+		glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings));
215
+		glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews'));
216
+	}
217 217
 
218
-    /**
219
-     * @return void
220
-     */
221
-    public function routerMigrateReviews()
222
-    {
223
-        glsr(Migrate::class)->runAll();
224
-        glsr(Notice::class)->clear()->addSuccess(__('The plugin has been migrated to the latest version.', 'site-reviews'));
225
-    }
218
+	/**
219
+	 * @return void
220
+	 */
221
+	public function routerMigrateReviews()
222
+	{
223
+		glsr(Migrate::class)->runAll();
224
+		glsr(Notice::class)->clear()->addSuccess(__('The plugin has been migrated to the latest version.', 'site-reviews'));
225
+	}
226 226
 
227
-    /**
228
-     * @return void
229
-     */
230
-    public function routerResetPermissions()
231
-    {
232
-        glsr(Role::class)->resetAll();
233
-        glsr(Notice::class)->clear()->addSuccess(__('The permissions have been reset.', 'site-reviews'));
234
-    }
227
+	/**
228
+	 * @return void
229
+	 */
230
+	public function routerResetPermissions()
231
+	{
232
+		glsr(Role::class)->resetAll();
233
+		glsr(Notice::class)->clear()->addSuccess(__('The permissions have been reset.', 'site-reviews'));
234
+	}
235 235
 
236
-    /**
237
-     * @return void
238
-     * @action admin_init
239
-     */
240
-    public function runMigrations()
241
-    {
242
-        if (glsr(Migrate::class)->isMigrationNeeded()) {
243
-            glsr(Migrate::class)->run();
244
-            glsr(CountsManager::class)->updateAll();
245
-        }
246
-    }
236
+	/**
237
+	 * @return void
238
+	 * @action admin_init
239
+	 */
240
+	public function runMigrations()
241
+	{
242
+		if (glsr(Migrate::class)->isMigrationNeeded()) {
243
+			glsr(Migrate::class)->run();
244
+			glsr(CountsManager::class)->updateAll();
245
+		}
246
+	}
247 247
 
248
-    /**
249
-     * @param int $errorCode
250
-     * @return string
251
-     */
252
-    protected function getUploadError($errorCode)
253
-    {
254
-        $errors = [
255
-            UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'),
256
-            UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'),
257
-            UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'),
258
-            UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'),
259
-            UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'),
260
-            UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'),
261
-            UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'),
262
-        ];
263
-        return Arr::get($errors, $errorCode, __('Unknown upload error.', 'site-reviews'));
264
-    }
248
+	/**
249
+	 * @param int $errorCode
250
+	 * @return string
251
+	 */
252
+	protected function getUploadError($errorCode)
253
+	{
254
+		$errors = [
255
+			UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'),
256
+			UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'),
257
+			UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'),
258
+			UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'),
259
+			UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'),
260
+			UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'),
261
+			UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'),
262
+		];
263
+		return Arr::get($errors, $errorCode, __('Unknown upload error.', 'site-reviews'));
264
+	}
265 265
 }
Please login to merge, or discard this patch.
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function enqueueAssets()
26 26
     {
27
-        $command = new EnqueueAdminAssets([
27
+        $command = new EnqueueAdminAssets( [
28 28
             'pointers' => [[
29
-                'content' => __('You can pin exceptional reviews so that they are always shown first.', 'site-reviews'),
29
+                'content' => __( 'You can pin exceptional reviews so that they are always shown first.', 'site-reviews' ),
30 30
                 'id' => 'glsr-pointer-pinned',
31 31
                 'position' => [
32 32
                     'edge' => 'right',
@@ -34,24 +34,24 @@  discard block
 block discarded – undo
34 34
                 ],
35 35
                 'screen' => Application::POST_TYPE,
36 36
                 'target' => '#misc-pub-pinned',
37
-                'title' => __('Pin Your Reviews', 'site-reviews'),
37
+                'title' => __( 'Pin Your Reviews', 'site-reviews' ),
38 38
             ]],
39
-        ]);
40
-        $this->execute($command);
39
+        ] );
40
+        $this->execute( $command );
41 41
     }
42 42
 
43 43
     /**
44 44
      * @return array
45 45
      * @filter plugin_action_links_site-reviews/site-reviews.php
46 46
      */
47
-    public function filterActionLinks(array $links)
47
+    public function filterActionLinks( array $links )
48 48
     {
49
-        $links['documentation'] = glsr(Builder::class)->a(__('Help', 'site-reviews'), [
50
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=documentation'),
51
-        ]);
52
-        $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
53
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=settings'),
54
-        ]);
49
+        $links['documentation'] = glsr( Builder::class )->a( __( 'Help', 'site-reviews' ), [
50
+            'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=documentation' ),
51
+        ] );
52
+        $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [
53
+            'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=settings' ),
54
+        ] );
55 55
         return $links;
56 56
     }
57 57
 
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
      * @return array
62 62
      * @filter map_meta_cap
63 63
      */
64
-    public function filterCreateCapability($capabilities, $capability)
64
+    public function filterCreateCapability( $capabilities, $capability )
65 65
     {
66
-        if ($capability == 'create_'.Application::POST_TYPE) {
66
+        if( $capability == 'create_'.Application::POST_TYPE ) {
67 67
             $capabilities[] = 'do_not_allow';
68 68
         }
69 69
         return $capabilities;
@@ -74,23 +74,23 @@  discard block
 block discarded – undo
74 74
      * @return array
75 75
      * @filter dashboard_glance_items
76 76
      */
77
-    public function filterDashboardGlanceItems($items)
77
+    public function filterDashboardGlanceItems( $items )
78 78
     {
79
-        $postCount = wp_count_posts(Application::POST_TYPE);
80
-        if (empty($postCount->publish)) {
79
+        $postCount = wp_count_posts( Application::POST_TYPE );
80
+        if( empty($postCount->publish) ) {
81 81
             return $items;
82 82
         }
83
-        $text = _n('%s Review', '%s Reviews', $postCount->publish, 'site-reviews');
84
-        $text = sprintf($text, number_format_i18n($postCount->publish));
85
-        $items = Arr::consolidateArray($items);
86
-        $items[] = glsr()->can('edit_posts')
87
-            ? glsr(Builder::class)->a($text, [
83
+        $text = _n( '%s Review', '%s Reviews', $postCount->publish, 'site-reviews' );
84
+        $text = sprintf( $text, number_format_i18n( $postCount->publish ) );
85
+        $items = Arr::consolidateArray( $items );
86
+        $items[] = glsr()->can( 'edit_posts' )
87
+            ? glsr( Builder::class )->a( $text, [
88 88
                 'class' => 'glsr-review-count',
89 89
                 'href' => 'edit.php?post_type='.Application::POST_TYPE,
90
-            ])
91
-            : glsr(Builder::class)->span($text, [
90
+            ] )
91
+            : glsr( Builder::class )->span( $text, [
92 92
                 'class' => 'glsr-review-count',
93
-            ]);
93
+            ] );
94 94
         return $items;
95 95
     }
96 96
 
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
      * @return array
100 100
      * @filter mce_external_plugins
101 101
      */
102
-    public function filterTinymcePlugins($plugins)
102
+    public function filterTinymcePlugins( $plugins )
103 103
     {
104
-        if (glsr()->can('edit_posts')) {
105
-            $plugins = Arr::consolidateArray($plugins);
106
-            $plugins['glsr_shortcode'] = glsr()->url('assets/scripts/mce-plugin.js');
104
+        if( glsr()->can( 'edit_posts' ) ) {
105
+            $plugins = Arr::consolidateArray( $plugins );
106
+            $plugins['glsr_shortcode'] = glsr()->url( 'assets/scripts/mce-plugin.js' );
107 107
         }
108 108
         return $plugins;
109 109
     }
@@ -114,12 +114,12 @@  discard block
 block discarded – undo
114 114
      */
115 115
     public function registerTinymcePopups()
116 116
     {
117
-        $command = new RegisterTinymcePopups([
118
-            'site_reviews' => esc_html__('Recent Reviews', 'site-reviews'),
119
-            'site_reviews_form' => esc_html__('Submit a Review', 'site-reviews'),
120
-            'site_reviews_summary' => esc_html__('Summary of Reviews', 'site-reviews'),
121
-        ]);
122
-        $this->execute($command);
117
+        $command = new RegisterTinymcePopups( [
118
+            'site_reviews' => esc_html__( 'Recent Reviews', 'site-reviews' ),
119
+            'site_reviews_form' => esc_html__( 'Submit a Review', 'site-reviews' ),
120
+            'site_reviews_summary' => esc_html__( 'Summary of Reviews', 'site-reviews' ),
121
+        ] );
122
+        $this->execute( $command );
123 123
     }
124 124
 
125 125
     /**
@@ -127,22 +127,22 @@  discard block
 block discarded – undo
127 127
      * @return void|null
128 128
      * @action media_buttons
129 129
      */
130
-    public function renderTinymceButton($editorId)
130
+    public function renderTinymceButton( $editorId )
131 131
     {
132
-        $allowedEditors = apply_filters('site-reviews/tinymce/editor-ids', ['content'], $editorId);
133
-        if ('post' != glsr_current_screen()->base || !in_array($editorId, $allowedEditors)) {
132
+        $allowedEditors = apply_filters( 'site-reviews/tinymce/editor-ids', ['content'], $editorId );
133
+        if( 'post' != glsr_current_screen()->base || !in_array( $editorId, $allowedEditors ) ) {
134 134
             return;
135 135
         }
136 136
         $shortcodes = [];
137
-        foreach (glsr()->mceShortcodes as $shortcode => $values) {
137
+        foreach( glsr()->mceShortcodes as $shortcode => $values ) {
138 138
             $shortcodes[$shortcode] = $values;
139 139
         }
140
-        if (empty($shortcodes)) {
140
+        if( empty($shortcodes) ) {
141 141
             return;
142 142
         }
143
-        glsr()->render('partials/editor/tinymce', [
143
+        glsr()->render( 'partials/editor/tinymce', [
144 144
             'shortcodes' => $shortcodes,
145
-        ]);
145
+        ] );
146 146
     }
147 147
 
148 148
     /**
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
      */
151 151
     public function routerClearConsole()
152 152
     {
153
-        glsr(Console::class)->clear();
154
-        glsr(Notice::class)->addSuccess(__('Console cleared.', 'site-reviews'));
153
+        glsr( Console::class )->clear();
154
+        glsr( Notice::class )->addSuccess( __( 'Console cleared.', 'site-reviews' ) );
155 155
     }
156 156
 
157 157
     /**
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
      */
160 160
     public function routerCountReviews()
161 161
     {
162
-        glsr(CountsManager::class)->updateAll();
163
-        glsr(Notice::class)->clear()->addSuccess(__('Recalculated rating counts.', 'site-reviews'));
162
+        glsr( CountsManager::class )->updateAll();
163
+        glsr( Notice::class )->clear()->addSuccess( __( 'Recalculated rating counts.', 'site-reviews' ) );
164 164
     }
165 165
 
166 166
     /**
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      */
169 169
     public function routerDownloadConsole()
170 170
     {
171
-        $this->download(Application::ID.'-console.txt', glsr(Console::class)->get());
171
+        $this->download( Application::ID.'-console.txt', glsr( Console::class )->get() );
172 172
     }
173 173
 
174 174
     /**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
      */
177 177
     public function routerDownloadSystemInfo()
178 178
     {
179
-        $this->download(Application::ID.'-system-info.txt', glsr(System::class)->get());
179
+        $this->download( Application::ID.'-system-info.txt', glsr( System::class )->get() );
180 180
     }
181 181
 
182 182
     /**
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      */
185 185
     public function routerExportSettings()
186 186
     {
187
-        $this->download(Application::ID.'-settings.json', glsr(OptionManager::class)->json());
187
+        $this->download( Application::ID.'-settings.json', glsr( OptionManager::class )->json() );
188 188
     }
189 189
 
190 190
     /**
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      */
193 193
     public function routerFetchConsole()
194 194
     {
195
-        glsr(Notice::class)->addSuccess(__('Console reloaded.', 'site-reviews'));
195
+        glsr( Notice::class )->addSuccess( __( 'Console reloaded.', 'site-reviews' ) );
196 196
     }
197 197
 
198 198
     /**
@@ -201,18 +201,18 @@  discard block
 block discarded – undo
201 201
     public function routerImportSettings()
202 202
     {
203 203
         $file = $_FILES['import-file'];
204
-        if (UPLOAD_ERR_OK !== $file['error']) {
205
-            return glsr(Notice::class)->addError($this->getUploadError($file['error']));
204
+        if( UPLOAD_ERR_OK !== $file['error'] ) {
205
+            return glsr( Notice::class )->addError( $this->getUploadError( $file['error'] ) );
206 206
         }
207
-        if ('application/json' !== $file['type'] || !Str::endsWith('.json', $file['name'])) {
208
-            return glsr(Notice::class)->addError(__('Please use a valid Site Reviews settings file.', 'site-reviews'));
207
+        if( 'application/json' !== $file['type'] || !Str::endsWith( '.json', $file['name'] ) ) {
208
+            return glsr( Notice::class )->addError( __( 'Please use a valid Site Reviews settings file.', 'site-reviews' ) );
209 209
         }
210
-        $settings = json_decode(file_get_contents($file['tmp_name']), true);
211
-        if (empty($settings)) {
212
-            return glsr(Notice::class)->addWarning(__('There were no settings found to import.', 'site-reviews'));
210
+        $settings = json_decode( file_get_contents( $file['tmp_name'] ), true );
211
+        if( empty($settings) ) {
212
+            return glsr( Notice::class )->addWarning( __( 'There were no settings found to import.', 'site-reviews' ) );
213 213
         }
214
-        glsr(OptionManager::class)->set(glsr(OptionManager::class)->normalize($settings));
215
-        glsr(Notice::class)->addSuccess(__('Settings imported.', 'site-reviews'));
214
+        glsr( OptionManager::class )->set( glsr( OptionManager::class )->normalize( $settings ) );
215
+        glsr( Notice::class )->addSuccess( __( 'Settings imported.', 'site-reviews' ) );
216 216
     }
217 217
 
218 218
     /**
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
      */
221 221
     public function routerMigrateReviews()
222 222
     {
223
-        glsr(Migrate::class)->runAll();
224
-        glsr(Notice::class)->clear()->addSuccess(__('The plugin has been migrated to the latest version.', 'site-reviews'));
223
+        glsr( Migrate::class )->runAll();
224
+        glsr( Notice::class )->clear()->addSuccess( __( 'The plugin has been migrated to the latest version.', 'site-reviews' ) );
225 225
     }
226 226
 
227 227
     /**
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
      */
230 230
     public function routerResetPermissions()
231 231
     {
232
-        glsr(Role::class)->resetAll();
233
-        glsr(Notice::class)->clear()->addSuccess(__('The permissions have been reset.', 'site-reviews'));
232
+        glsr( Role::class )->resetAll();
233
+        glsr( Notice::class )->clear()->addSuccess( __( 'The permissions have been reset.', 'site-reviews' ) );
234 234
     }
235 235
 
236 236
     /**
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
      */
240 240
     public function runMigrations()
241 241
     {
242
-        if (glsr(Migrate::class)->isMigrationNeeded()) {
243
-            glsr(Migrate::class)->run();
244
-            glsr(CountsManager::class)->updateAll();
242
+        if( glsr( Migrate::class )->isMigrationNeeded() ) {
243
+            glsr( Migrate::class )->run();
244
+            glsr( CountsManager::class )->updateAll();
245 245
         }
246 246
     }
247 247
 
@@ -249,17 +249,17 @@  discard block
 block discarded – undo
249 249
      * @param int $errorCode
250 250
      * @return string
251 251
      */
252
-    protected function getUploadError($errorCode)
252
+    protected function getUploadError( $errorCode )
253 253
     {
254 254
         $errors = [
255
-            UPLOAD_ERR_INI_SIZE => __('The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews'),
256
-            UPLOAD_ERR_FORM_SIZE => __('The uploaded file is too big.', 'site-reviews'),
257
-            UPLOAD_ERR_PARTIAL => __('The uploaded file was only partially uploaded.', 'site-reviews'),
258
-            UPLOAD_ERR_NO_FILE => __('No file was uploaded.', 'site-reviews'),
259
-            UPLOAD_ERR_NO_TMP_DIR => __('Missing a temporary folder.', 'site-reviews'),
260
-            UPLOAD_ERR_CANT_WRITE => __('Failed to write file to disk.', 'site-reviews'),
261
-            UPLOAD_ERR_EXTENSION => __('A PHP extension stopped the file upload.', 'site-reviews'),
255
+            UPLOAD_ERR_INI_SIZE => __( 'The uploaded file exceeds the upload_max_filesize directive in php.ini.', 'site-reviews' ),
256
+            UPLOAD_ERR_FORM_SIZE => __( 'The uploaded file is too big.', 'site-reviews' ),
257
+            UPLOAD_ERR_PARTIAL => __( 'The uploaded file was only partially uploaded.', 'site-reviews' ),
258
+            UPLOAD_ERR_NO_FILE => __( 'No file was uploaded.', 'site-reviews' ),
259
+            UPLOAD_ERR_NO_TMP_DIR => __( 'Missing a temporary folder.', 'site-reviews' ),
260
+            UPLOAD_ERR_CANT_WRITE => __( 'Failed to write file to disk.', 'site-reviews' ),
261
+            UPLOAD_ERR_EXTENSION => __( 'A PHP extension stopped the file upload.', 'site-reviews' ),
262 262
         ];
263
-        return Arr::get($errors, $errorCode, __('Unknown upload error.', 'site-reviews'));
263
+        return Arr::get( $errors, $errorCode, __( 'Unknown upload error.', 'site-reviews' ) );
264 264
     }
265 265
 }
Please login to merge, or discard this patch.
plugin/Controllers/MainController.php 2 patches
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -10,86 +10,86 @@
 block discarded – undo
10 10
 
11 11
 class MainController extends Controller
12 12
 {
13
-    /**
14
-     * @return void
15
-     * @action init
16
-     */
17
-    public function registerPostType()
18
-    {
19
-        if (!glsr()->hasPermission()) {
20
-            return;
21
-        }
22
-        $command = new RegisterPostType([
23
-            'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE],
24
-            'capability_type' => Application::POST_TYPE,
25
-            'columns' => [
26
-                'title' => '',
27
-                'category' => '',
28
-                'assigned_to' => __('Assigned To', 'site-reviews'),
29
-                'reviewer' => __('Author', 'site-reviews'),
30
-                'email' => __('Email', 'site-reviews'),
31
-                'ip_address' => __('IP Address', 'site-reviews'),
32
-                'response' => __('Response', 'site-reviews'),
33
-                'review_type' => __('Type', 'site-reviews'),
34
-                'rating' => __('Rating', 'site-reviews'),
35
-                'pinned' => __('Pinned', 'site-reviews'),
36
-                'date' => '',
37
-            ],
38
-            'menu_icon' => 'dashicons-star-half',
39
-            'menu_name' => glsr()->name,
40
-            'map_meta_cap' => true,
41
-            'plural' => __('Reviews', 'site-reviews'),
42
-            'post_type' => Application::POST_TYPE,
43
-            'rest_controller_class' => RestReviewController::class,
44
-            'show_in_rest' => true,
45
-            'single' => __('Review', 'site-reviews'),
46
-        ]);
47
-        $this->execute($command);
48
-    }
13
+	/**
14
+	 * @return void
15
+	 * @action init
16
+	 */
17
+	public function registerPostType()
18
+	{
19
+		if (!glsr()->hasPermission()) {
20
+			return;
21
+		}
22
+		$command = new RegisterPostType([
23
+			'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE],
24
+			'capability_type' => Application::POST_TYPE,
25
+			'columns' => [
26
+				'title' => '',
27
+				'category' => '',
28
+				'assigned_to' => __('Assigned To', 'site-reviews'),
29
+				'reviewer' => __('Author', 'site-reviews'),
30
+				'email' => __('Email', 'site-reviews'),
31
+				'ip_address' => __('IP Address', 'site-reviews'),
32
+				'response' => __('Response', 'site-reviews'),
33
+				'review_type' => __('Type', 'site-reviews'),
34
+				'rating' => __('Rating', 'site-reviews'),
35
+				'pinned' => __('Pinned', 'site-reviews'),
36
+				'date' => '',
37
+			],
38
+			'menu_icon' => 'dashicons-star-half',
39
+			'menu_name' => glsr()->name,
40
+			'map_meta_cap' => true,
41
+			'plural' => __('Reviews', 'site-reviews'),
42
+			'post_type' => Application::POST_TYPE,
43
+			'rest_controller_class' => RestReviewController::class,
44
+			'show_in_rest' => true,
45
+			'single' => __('Review', 'site-reviews'),
46
+		]);
47
+		$this->execute($command);
48
+	}
49 49
 
50
-    /**
51
-     * @return void
52
-     * @action init
53
-     */
54
-    public function registerShortcodes()
55
-    {
56
-        $command = new RegisterShortcodes([
57
-            'site_reviews',
58
-            'site_reviews_form',
59
-            'site_reviews_summary',
60
-        ]);
61
-        $this->execute($command);
62
-    }
50
+	/**
51
+	 * @return void
52
+	 * @action init
53
+	 */
54
+	public function registerShortcodes()
55
+	{
56
+		$command = new RegisterShortcodes([
57
+			'site_reviews',
58
+			'site_reviews_form',
59
+			'site_reviews_summary',
60
+		]);
61
+		$this->execute($command);
62
+	}
63 63
 
64
-    /**
65
-     * @return void
66
-     * @action init
67
-     */
68
-    public function registerTaxonomy()
69
-    {
70
-        $command = new RegisterTaxonomy([
71
-            'hierarchical' => true,
72
-            'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'],
73
-            'public' => false,
74
-            'rest_controller_class' => RestCategoryController::class,
75
-            'show_admin_column' => true,
76
-            'show_in_rest' => true,
77
-            'show_ui' => true,
78
-        ]);
79
-        $this->execute($command);
80
-    }
64
+	/**
65
+	 * @return void
66
+	 * @action init
67
+	 */
68
+	public function registerTaxonomy()
69
+	{
70
+		$command = new RegisterTaxonomy([
71
+			'hierarchical' => true,
72
+			'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'],
73
+			'public' => false,
74
+			'rest_controller_class' => RestCategoryController::class,
75
+			'show_admin_column' => true,
76
+			'show_in_rest' => true,
77
+			'show_ui' => true,
78
+		]);
79
+		$this->execute($command);
80
+	}
81 81
 
82
-    /**
83
-     * @return void
84
-     * @action widgets_init
85
-     */
86
-    public function registerWidgets()
87
-    {
88
-        $command = new RegisterWidgets([
89
-            'site-reviews',
90
-            'site-reviews-form',
91
-            'site-reviews-summary',
92
-        ]);
93
-        $this->execute($command);
94
-    }
82
+	/**
83
+	 * @return void
84
+	 * @action widgets_init
85
+	 */
86
+	public function registerWidgets()
87
+	{
88
+		$command = new RegisterWidgets([
89
+			'site-reviews',
90
+			'site-reviews-form',
91
+			'site-reviews-summary',
92
+		]);
93
+		$this->execute($command);
94
+	}
95 95
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -16,35 +16,35 @@  discard block
 block discarded – undo
16 16
      */
17 17
     public function registerPostType()
18 18
     {
19
-        if (!glsr()->hasPermission()) {
19
+        if( !glsr()->hasPermission() ) {
20 20
             return;
21 21
         }
22
-        $command = new RegisterPostType([
22
+        $command = new RegisterPostType( [
23 23
             'capabilities' => ['create_posts' => 'create_'.Application::POST_TYPE],
24 24
             'capability_type' => Application::POST_TYPE,
25 25
             'columns' => [
26 26
                 'title' => '',
27 27
                 'category' => '',
28
-                'assigned_to' => __('Assigned To', 'site-reviews'),
29
-                'reviewer' => __('Author', 'site-reviews'),
30
-                'email' => __('Email', 'site-reviews'),
31
-                'ip_address' => __('IP Address', 'site-reviews'),
32
-                'response' => __('Response', 'site-reviews'),
33
-                'review_type' => __('Type', 'site-reviews'),
34
-                'rating' => __('Rating', 'site-reviews'),
35
-                'pinned' => __('Pinned', 'site-reviews'),
28
+                'assigned_to' => __( 'Assigned To', 'site-reviews' ),
29
+                'reviewer' => __( 'Author', 'site-reviews' ),
30
+                'email' => __( 'Email', 'site-reviews' ),
31
+                'ip_address' => __( 'IP Address', 'site-reviews' ),
32
+                'response' => __( 'Response', 'site-reviews' ),
33
+                'review_type' => __( 'Type', 'site-reviews' ),
34
+                'rating' => __( 'Rating', 'site-reviews' ),
35
+                'pinned' => __( 'Pinned', 'site-reviews' ),
36 36
                 'date' => '',
37 37
             ],
38 38
             'menu_icon' => 'dashicons-star-half',
39 39
             'menu_name' => glsr()->name,
40 40
             'map_meta_cap' => true,
41
-            'plural' => __('Reviews', 'site-reviews'),
41
+            'plural' => __( 'Reviews', 'site-reviews' ),
42 42
             'post_type' => Application::POST_TYPE,
43 43
             'rest_controller_class' => RestReviewController::class,
44 44
             'show_in_rest' => true,
45
-            'single' => __('Review', 'site-reviews'),
46
-        ]);
47
-        $this->execute($command);
45
+            'single' => __( 'Review', 'site-reviews' ),
46
+        ] );
47
+        $this->execute( $command );
48 48
     }
49 49
 
50 50
     /**
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function registerShortcodes()
55 55
     {
56
-        $command = new RegisterShortcodes([
56
+        $command = new RegisterShortcodes( [
57 57
             'site_reviews',
58 58
             'site_reviews_form',
59 59
             'site_reviews_summary',
60
-        ]);
61
-        $this->execute($command);
60
+        ] );
61
+        $this->execute( $command );
62 62
     }
63 63
 
64 64
     /**
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function registerTaxonomy()
69 69
     {
70
-        $command = new RegisterTaxonomy([
70
+        $command = new RegisterTaxonomy( [
71 71
             'hierarchical' => true,
72
-            'meta_box_cb' => [glsr(EditorController::class), 'renderTaxonomyMetabox'],
72
+            'meta_box_cb' => [glsr( EditorController::class ), 'renderTaxonomyMetabox'],
73 73
             'public' => false,
74 74
             'rest_controller_class' => RestCategoryController::class,
75 75
             'show_admin_column' => true,
76 76
             'show_in_rest' => true,
77 77
             'show_ui' => true,
78
-        ]);
79
-        $this->execute($command);
78
+        ] );
79
+        $this->execute( $command );
80 80
     }
81 81
 
82 82
     /**
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function registerWidgets()
87 87
     {
88
-        $command = new RegisterWidgets([
88
+        $command = new RegisterWidgets( [
89 89
             'site-reviews',
90 90
             'site-reviews-form',
91 91
             'site-reviews-summary',
92
-        ]);
93
-        $this->execute($command);
92
+        ] );
93
+        $this->execute( $command );
94 94
     }
95 95
 }
Please login to merge, or discard this patch.
views/pages/addons/index.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -6,16 +6,16 @@
 block discarded – undo
6 6
     <p><?= __('Add-ons extend the functionality of Site Reviews.', 'site-reviews'); ?></p>
7 7
     <div class="glsr-addons wp-clearfix">
8 8
     <?php
9
-        $template->render('partials/addons/addon', [
10
-            'beta' => true,
11
-            'context' => [
12
-                'description' => __('This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews'),
13
-                'link' => 'https://niftyplugins.com/plugins/images/',
14
-                'slug' => 'images',
15
-                'title' => 'Images',
16
-            ],
17
-            'plugin' => 'site-reviews-images/site-reviews-images.php',
18
-        ]);
19
-    ?>
9
+		$template->render('partials/addons/addon', [
10
+			'beta' => true,
11
+			'context' => [
12
+				'description' => __('This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews'),
13
+				'link' => 'https://niftyplugins.com/plugins/images/',
14
+				'slug' => 'images',
15
+				'title' => 'Images',
16
+			],
17
+			'plugin' => 'site-reviews-images/site-reviews-images.php',
18
+		]);
19
+	?>
20 20
     </div>
21 21
 </div>
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <div class="wrap">
4
-    <h1 class="wp-heading-inline"><?= esc_html(get_admin_page_title()); ?></h1>
4
+    <h1 class="wp-heading-inline"><?= esc_html( get_admin_page_title() ); ?></h1>
5 5
     <?= $notices; ?>
6
-    <p><?= __('Add-ons extend the functionality of Site Reviews.', 'site-reviews'); ?></p>
6
+    <p><?= __( 'Add-ons extend the functionality of Site Reviews.', 'site-reviews' ); ?></p>
7 7
     <div class="glsr-addons wp-clearfix">
8 8
     <?php
9
-        $template->render('partials/addons/addon', [
9
+        $template->render( 'partials/addons/addon', [
10 10
             'beta' => true,
11 11
             'context' => [
12
-                'description' => __('This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews'),
12
+                'description' => __( 'This add-on allows your site visitors to submit images with their reviews. Apply now to test the unreleased beta version.', 'site-reviews' ),
13 13
                 'link' => 'https://niftyplugins.com/plugins/images/',
14 14
                 'slug' => 'images',
15 15
                 'title' => 'Images',
16 16
             ],
17 17
             'plugin' => 'site-reviews-images/site-reviews-images.php',
18
-        ]);
18
+        ] );
19 19
     ?>
20 20
     </div>
21 21
 </div>
Please login to merge, or discard this patch.
plugin/Modules/System.php 2 patches
Indentation   +352 added lines, -352 removed lines patch added patch discarded remove patch
@@ -13,378 +13,378 @@
 block discarded – undo
13 13
 
14 14
 class System
15 15
 {
16
-    const PAD = 40;
16
+	const PAD = 40;
17 17
 
18
-    /**
19
-     * @return string
20
-     */
21
-    public function __toString()
22
-    {
23
-        return $this->get();
24
-    }
18
+	/**
19
+	 * @return string
20
+	 */
21
+	public function __toString()
22
+	{
23
+		return $this->get();
24
+	}
25 25
 
26
-    /**
27
-     * @return string
28
-     */
29
-    public function get()
30
-    {
31
-        $details = [
32
-            'plugin' => 'Plugin Details',
33
-            'addon' => 'Addon Details',
34
-            'browser' => 'Browser Details',
35
-            'server' => 'Server Details',
36
-            'php' => 'PHP Configuration',
37
-            'wordpress' => 'WordPress Configuration',
38
-            'mu-plugin' => 'Must-Use Plugins',
39
-            'multisite-plugin' => 'Network Active Plugins',
40
-            'active-plugin' => 'Active Plugins',
41
-            'inactive-plugin' => 'Inactive Plugins',
42
-            'setting' => 'Plugin Settings',
43
-            'reviews' => 'Review Counts',
44
-        ];
45
-        $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
46
-            $methodName = Helper::buildMethodName('get-'.$key.'-details');
47
-            if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
48
-                return $carry.$this->implode(
49
-                    strtoupper($details[$key]),
50
-                    apply_filters('site-reviews/system/'.$key, $systemDetails)
51
-                );
52
-            }
53
-            return $carry;
54
-        });
55
-        return trim($systemInfo);
56
-    }
26
+	/**
27
+	 * @return string
28
+	 */
29
+	public function get()
30
+	{
31
+		$details = [
32
+			'plugin' => 'Plugin Details',
33
+			'addon' => 'Addon Details',
34
+			'browser' => 'Browser Details',
35
+			'server' => 'Server Details',
36
+			'php' => 'PHP Configuration',
37
+			'wordpress' => 'WordPress Configuration',
38
+			'mu-plugin' => 'Must-Use Plugins',
39
+			'multisite-plugin' => 'Network Active Plugins',
40
+			'active-plugin' => 'Active Plugins',
41
+			'inactive-plugin' => 'Inactive Plugins',
42
+			'setting' => 'Plugin Settings',
43
+			'reviews' => 'Review Counts',
44
+		];
45
+		$systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
46
+			$methodName = Helper::buildMethodName('get-'.$key.'-details');
47
+			if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
48
+				return $carry.$this->implode(
49
+					strtoupper($details[$key]),
50
+					apply_filters('site-reviews/system/'.$key, $systemDetails)
51
+				);
52
+			}
53
+			return $carry;
54
+		});
55
+		return trim($systemInfo);
56
+	}
57 57
 
58
-    /**
59
-     * @return array
60
-     */
61
-    public function getActivePluginDetails()
62
-    {
63
-        $plugins = get_plugins();
64
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
65
-        $inactive = array_diff_key($plugins, array_flip($activePlugins));
66
-        return $this->normalizePluginList(array_diff_key($plugins, $inactive));
67
-    }
58
+	/**
59
+	 * @return array
60
+	 */
61
+	public function getActivePluginDetails()
62
+	{
63
+		$plugins = get_plugins();
64
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
65
+		$inactive = array_diff_key($plugins, array_flip($activePlugins));
66
+		return $this->normalizePluginList(array_diff_key($plugins, $inactive));
67
+	}
68 68
 
69
-    /**
70
-     * @return array
71
-     */
72
-    public function getAddonDetails()
73
-    {
74
-        $details = apply_filters('site-reviews/addon/system-info', []);
75
-        ksort($details);
76
-        return $details;
77
-    }
69
+	/**
70
+	 * @return array
71
+	 */
72
+	public function getAddonDetails()
73
+	{
74
+		$details = apply_filters('site-reviews/addon/system-info', []);
75
+		ksort($details);
76
+		return $details;
77
+	}
78 78
 
79
-    /**
80
-     * @return array
81
-     */
82
-    public function getBrowserDetails()
83
-    {
84
-        $browser = new Browser();
85
-        $name = esc_attr($browser->getName());
86
-        $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
87
-        $version = esc_attr($browser->getVersion());
88
-        return [
89
-            'Browser Name' => sprintf('%s %s', $name, $version),
90
-            'Browser UA' => $userAgent,
91
-        ];
92
-    }
79
+	/**
80
+	 * @return array
81
+	 */
82
+	public function getBrowserDetails()
83
+	{
84
+		$browser = new Browser();
85
+		$name = esc_attr($browser->getName());
86
+		$userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
87
+		$version = esc_attr($browser->getVersion());
88
+		return [
89
+			'Browser Name' => sprintf('%s %s', $name, $version),
90
+			'Browser UA' => $userAgent,
91
+		];
92
+	}
93 93
 
94
-    /**
95
-     * @return array
96
-     */
97
-    public function getInactivePluginDetails()
98
-    {
99
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
100
-        $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
101
-        $multisitePlugins = $this->getMultisitePluginDetails();
102
-        return empty($multisitePlugins)
103
-            ? $inactivePlugins
104
-            : array_diff($inactivePlugins, $multisitePlugins);
105
-    }
94
+	/**
95
+	 * @return array
96
+	 */
97
+	public function getInactivePluginDetails()
98
+	{
99
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
100
+		$inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
101
+		$multisitePlugins = $this->getMultisitePluginDetails();
102
+		return empty($multisitePlugins)
103
+			? $inactivePlugins
104
+			: array_diff($inactivePlugins, $multisitePlugins);
105
+	}
106 106
 
107
-    /**
108
-     * @return array
109
-     */
110
-    public function getMuPluginDetails()
111
-    {
112
-        if (empty($plugins = get_mu_plugins())) {
113
-            return [];
114
-        }
115
-        return $this->normalizePluginList($plugins);
116
-    }
107
+	/**
108
+	 * @return array
109
+	 */
110
+	public function getMuPluginDetails()
111
+	{
112
+		if (empty($plugins = get_mu_plugins())) {
113
+			return [];
114
+		}
115
+		return $this->normalizePluginList($plugins);
116
+	}
117 117
 
118
-    /**
119
-     * @return array
120
-     */
121
-    public function getMultisitePluginDetails()
122
-    {
123
-        $activePlugins = (array) get_site_option('active_sitewide_plugins', []);
124
-        if (!is_multisite() || empty($activePlugins)) {
125
-            return [];
126
-        }
127
-        return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
128
-    }
118
+	/**
119
+	 * @return array
120
+	 */
121
+	public function getMultisitePluginDetails()
122
+	{
123
+		$activePlugins = (array) get_site_option('active_sitewide_plugins', []);
124
+		if (!is_multisite() || empty($activePlugins)) {
125
+			return [];
126
+		}
127
+		return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
128
+	}
129 129
 
130
-    /**
131
-     * @return array
132
-     */
133
-    public function getPhpDetails()
134
-    {
135
-        $displayErrors = $this->getINI('display_errors', null)
136
-            ? 'On ('.$this->getINI('display_errors').')'
137
-            : 'N/A';
138
-        $intlSupport = extension_loaded('intl')
139
-            ? phpversion('intl')
140
-            : 'false';
141
-        return [
142
-            'cURL' => var_export(function_exists('curl_init'), true),
143
-            'Default Charset' => $this->getINI('default_charset'),
144
-            'Display Errors' => $displayErrors,
145
-            'fsockopen' => var_export(function_exists('fsockopen'), true),
146
-            'Intl' => $intlSupport,
147
-            'IPv6' => var_export(defined('AF_INET6'), true),
148
-            'Max Execution Time' => $this->getINI('max_execution_time'),
149
-            'Max Input Nesting Level' => $this->getINI('max_input_nesting_level'),
150
-            'Max Input Vars' => $this->getINI('max_input_vars'),
151
-            'Memory Limit' => $this->getINI('memory_limit'),
152
-            'Post Max Size' => $this->getINI('post_max_size'),
153
-            'Sendmail Path' => $this->getINI('sendmail_path'),
154
-            'Session Cookie Path' => esc_html($this->getINI('session.cookie_path')),
155
-            'Session Name' => esc_html($this->getINI('session.name')),
156
-            'Session Save Path' => esc_html($this->getINI('session.save_path')),
157
-            'Session Use Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_cookies', false)), true),
158
-            'Session Use Only Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_only_cookies', false)), true),
159
-            'Upload Max Filesize' => $this->getINI('upload_max_filesize'),
160
-        ];
161
-    }
130
+	/**
131
+	 * @return array
132
+	 */
133
+	public function getPhpDetails()
134
+	{
135
+		$displayErrors = $this->getINI('display_errors', null)
136
+			? 'On ('.$this->getINI('display_errors').')'
137
+			: 'N/A';
138
+		$intlSupport = extension_loaded('intl')
139
+			? phpversion('intl')
140
+			: 'false';
141
+		return [
142
+			'cURL' => var_export(function_exists('curl_init'), true),
143
+			'Default Charset' => $this->getINI('default_charset'),
144
+			'Display Errors' => $displayErrors,
145
+			'fsockopen' => var_export(function_exists('fsockopen'), true),
146
+			'Intl' => $intlSupport,
147
+			'IPv6' => var_export(defined('AF_INET6'), true),
148
+			'Max Execution Time' => $this->getINI('max_execution_time'),
149
+			'Max Input Nesting Level' => $this->getINI('max_input_nesting_level'),
150
+			'Max Input Vars' => $this->getINI('max_input_vars'),
151
+			'Memory Limit' => $this->getINI('memory_limit'),
152
+			'Post Max Size' => $this->getINI('post_max_size'),
153
+			'Sendmail Path' => $this->getINI('sendmail_path'),
154
+			'Session Cookie Path' => esc_html($this->getINI('session.cookie_path')),
155
+			'Session Name' => esc_html($this->getINI('session.name')),
156
+			'Session Save Path' => esc_html($this->getINI('session.save_path')),
157
+			'Session Use Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_cookies', false)), true),
158
+			'Session Use Only Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_only_cookies', false)), true),
159
+			'Upload Max Filesize' => $this->getINI('upload_max_filesize'),
160
+		];
161
+	}
162 162
 
163
-    /**
164
-     * @return array
165
-     */
166
-    public function getReviewsDetails()
167
-    {
168
-        $counts = glsr(CountsManager::class)->getCounts();
169
-        $counts = Arr::flattenArray($counts);
170
-        array_walk($counts, function (&$ratings) use ($counts) {
171
-            if (is_array($ratings)) {
172
-                $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
173
-                return;
174
-            }
175
-            glsr_log()
176
-                ->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
177
-                ->debug($ratings)
178
-                ->debug($counts);
179
-        });
180
-        ksort($counts);
181
-        return $counts;
182
-    }
163
+	/**
164
+	 * @return array
165
+	 */
166
+	public function getReviewsDetails()
167
+	{
168
+		$counts = glsr(CountsManager::class)->getCounts();
169
+		$counts = Arr::flattenArray($counts);
170
+		array_walk($counts, function (&$ratings) use ($counts) {
171
+			if (is_array($ratings)) {
172
+				$ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
173
+				return;
174
+			}
175
+			glsr_log()
176
+				->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
177
+				->debug($ratings)
178
+				->debug($counts);
179
+		});
180
+		ksort($counts);
181
+		return $counts;
182
+	}
183 183
 
184
-    /**
185
-     * @return array
186
-     */
187
-    public function getServerDetails()
188
-    {
189
-        global $wpdb;
190
-        return [
191
-            'Host Name' => $this->getHostName(),
192
-            'MySQL Version' => $wpdb->db_version(),
193
-            'PHP Version' => PHP_VERSION,
194
-            'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
195
-        ];
196
-    }
184
+	/**
185
+	 * @return array
186
+	 */
187
+	public function getServerDetails()
188
+	{
189
+		global $wpdb;
190
+		return [
191
+			'Host Name' => $this->getHostName(),
192
+			'MySQL Version' => $wpdb->db_version(),
193
+			'PHP Version' => PHP_VERSION,
194
+			'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
195
+		];
196
+	}
197 197
 
198
-    /**
199
-     * @return array
200
-     */
201
-    public function getSettingDetails()
202
-    {
203
-        $settings = glsr(OptionManager::class)->get('settings', []);
204
-        $settings = Arr::flattenArray($settings, true);
205
-        $settings = $this->purgeSensitiveData($settings);
206
-        ksort($settings);
207
-        $details = [];
208
-        foreach ($settings as $key => $value) {
209
-            if (Str::startsWith('strings', $key) && Str::endsWith('id', $key)) {
210
-                continue;
211
-            }
212
-            $value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
213
-            $details[$key] = $value;
214
-        }
215
-        return $details;
216
-    }
198
+	/**
199
+	 * @return array
200
+	 */
201
+	public function getSettingDetails()
202
+	{
203
+		$settings = glsr(OptionManager::class)->get('settings', []);
204
+		$settings = Arr::flattenArray($settings, true);
205
+		$settings = $this->purgeSensitiveData($settings);
206
+		ksort($settings);
207
+		$details = [];
208
+		foreach ($settings as $key => $value) {
209
+			if (Str::startsWith('strings', $key) && Str::endsWith('id', $key)) {
210
+				continue;
211
+			}
212
+			$value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
213
+			$details[$key] = $value;
214
+		}
215
+		return $details;
216
+	}
217 217
 
218
-    /**
219
-     * @return array
220
-     */
221
-    public function getPluginDetails()
222
-    {
223
-        return [
224
-            'Console level' => glsr(Console::class)->humanLevel(),
225
-            'Console size' => glsr(Console::class)->humanSize('0'),
226
-            'Last Migration Run' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_migration_run'), 'unknown'),
227
-            'Last Rating Count' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_review_count'), 'unknown'),
228
-            'Version (current)' => glsr()->version,
229
-            'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
230
-        ];
231
-    }
218
+	/**
219
+	 * @return array
220
+	 */
221
+	public function getPluginDetails()
222
+	{
223
+		return [
224
+			'Console level' => glsr(Console::class)->humanLevel(),
225
+			'Console size' => glsr(Console::class)->humanSize('0'),
226
+			'Last Migration Run' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_migration_run'), 'unknown'),
227
+			'Last Rating Count' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_review_count'), 'unknown'),
228
+			'Version (current)' => glsr()->version,
229
+			'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
230
+		];
231
+	}
232 232
 
233
-    /**
234
-     * @return array
235
-     */
236
-    public function getWordpressDetails()
237
-    {
238
-        global $wpdb;
239
-        $theme = wp_get_theme();
240
-        return [
241
-            'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
242
-            'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
243
-            'Home URL' => home_url(),
244
-            'Language' => get_locale(),
245
-            'Memory Limit' => WP_MEMORY_LIMIT,
246
-            'Multisite' => var_export(is_multisite(), true),
247
-            'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
248
-            'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
249
-            'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
250
-            'Post Stati' => implode(', ', get_post_stati()),
251
-            'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
252
-            'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
253
-            'Site URL' => site_url(),
254
-            'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', $this->getINI('date.timezone').' (PHP)'),
255
-            'Version' => get_bloginfo('version'),
256
-            'WP Debug' => var_export(defined('WP_DEBUG'), true),
257
-            'WP Max Upload Size' => size_format(wp_max_upload_size()),
258
-            'WP Memory Limit' => WP_MEMORY_LIMIT,
259
-        ];
260
-    }
233
+	/**
234
+	 * @return array
235
+	 */
236
+	public function getWordpressDetails()
237
+	{
238
+		global $wpdb;
239
+		$theme = wp_get_theme();
240
+		return [
241
+			'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
242
+			'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
243
+			'Home URL' => home_url(),
244
+			'Language' => get_locale(),
245
+			'Memory Limit' => WP_MEMORY_LIMIT,
246
+			'Multisite' => var_export(is_multisite(), true),
247
+			'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
248
+			'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
249
+			'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
250
+			'Post Stati' => implode(', ', get_post_stati()),
251
+			'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
252
+			'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
253
+			'Site URL' => site_url(),
254
+			'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', $this->getINI('date.timezone').' (PHP)'),
255
+			'Version' => get_bloginfo('version'),
256
+			'WP Debug' => var_export(defined('WP_DEBUG'), true),
257
+			'WP Max Upload Size' => size_format(wp_max_upload_size()),
258
+			'WP Memory Limit' => WP_MEMORY_LIMIT,
259
+		];
260
+	}
261 261
 
262
-    /**
263
-     * @return string
264
-     */
265
-    protected function detectWebhostProvider()
266
-    {
267
-        $checks = [
268
-            '.accountservergroup.com' => 'Site5',
269
-            '.gridserver.com' => 'MediaTemple Grid',
270
-            '.inmotionhosting.com' => 'InMotion Hosting',
271
-            '.ovh.net' => 'OVH',
272
-            '.pair.com' => 'pair Networks',
273
-            '.stabletransit.com' => 'Rackspace Cloud',
274
-            '.stratoserver.net' => 'STRATO',
275
-            '.sysfix.eu' => 'SysFix.eu Power Hosting',
276
-            'bluehost.com' => 'Bluehost',
277
-            'DH_USER' => 'DreamHost',
278
-            'Flywheel' => 'Flywheel',
279
-            'ipagemysql.com' => 'iPage',
280
-            'ipowermysql.com' => 'IPower',
281
-            'localhost:/tmp/mysql5.sock' => 'ICDSoft',
282
-            'mysqlv5' => 'NetworkSolutions',
283
-            'PAGELYBIN' => 'Pagely',
284
-            'secureserver.net' => 'GoDaddy',
285
-            'WPE_APIKEY' => 'WP Engine',
286
-        ];
287
-        foreach ($checks as $key => $value) {
288
-            if (!$this->isWebhostCheckValid($key)) {
289
-                continue;
290
-            }
291
-            return $value;
292
-        }
293
-        return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
294
-    }
262
+	/**
263
+	 * @return string
264
+	 */
265
+	protected function detectWebhostProvider()
266
+	{
267
+		$checks = [
268
+			'.accountservergroup.com' => 'Site5',
269
+			'.gridserver.com' => 'MediaTemple Grid',
270
+			'.inmotionhosting.com' => 'InMotion Hosting',
271
+			'.ovh.net' => 'OVH',
272
+			'.pair.com' => 'pair Networks',
273
+			'.stabletransit.com' => 'Rackspace Cloud',
274
+			'.stratoserver.net' => 'STRATO',
275
+			'.sysfix.eu' => 'SysFix.eu Power Hosting',
276
+			'bluehost.com' => 'Bluehost',
277
+			'DH_USER' => 'DreamHost',
278
+			'Flywheel' => 'Flywheel',
279
+			'ipagemysql.com' => 'iPage',
280
+			'ipowermysql.com' => 'IPower',
281
+			'localhost:/tmp/mysql5.sock' => 'ICDSoft',
282
+			'mysqlv5' => 'NetworkSolutions',
283
+			'PAGELYBIN' => 'Pagely',
284
+			'secureserver.net' => 'GoDaddy',
285
+			'WPE_APIKEY' => 'WP Engine',
286
+		];
287
+		foreach ($checks as $key => $value) {
288
+			if (!$this->isWebhostCheckValid($key)) {
289
+				continue;
290
+			}
291
+			return $value;
292
+		}
293
+		return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
294
+	}
295 295
 
296
-    /**
297
-     * @return string
298
-     */
299
-    protected function getHostName()
300
-    {
301
-        return sprintf('%s (%s)',
302
-            $this->detectWebhostProvider(),
303
-            Helper::getIpAddress()
304
-        );
305
-    }
296
+	/**
297
+	 * @return string
298
+	 */
299
+	protected function getHostName()
300
+	{
301
+		return sprintf('%s (%s)',
302
+			$this->detectWebhostProvider(),
303
+			Helper::getIpAddress()
304
+		);
305
+	}
306 306
 
307
-    protected function getINI($name, $disabledValue = 'ini_get() is disabled.')
308
-    {
309
-        return function_exists('ini_get')
310
-            ? ini_get($name)
311
-            : $disabledValue;
312
-    }
307
+	protected function getINI($name, $disabledValue = 'ini_get() is disabled.')
308
+	{
309
+		return function_exists('ini_get')
310
+			? ini_get($name)
311
+			: $disabledValue;
312
+	}
313 313
 
314
-    /**
315
-     * @return array
316
-     */
317
-    protected function getWordpressPlugins()
318
-    {
319
-        $plugins = get_plugins();
320
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
321
-        $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
322
-        $active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
323
-        return $active + $inactive;
324
-    }
314
+	/**
315
+	 * @return array
316
+	 */
317
+	protected function getWordpressPlugins()
318
+	{
319
+		$plugins = get_plugins();
320
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
321
+		$inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
322
+		$active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
323
+		return $active + $inactive;
324
+	}
325 325
 
326
-    /**
327
-     * @param string $title
328
-     * @return string
329
-     */
330
-    protected function implode($title, array $details)
331
-    {
332
-        $strings = ['['.$title.']'];
333
-        $padding = max(array_map('strlen', array_keys($details)));
334
-        $padding = max([$padding, static::PAD]);
335
-        foreach ($details as $key => $value) {
336
-            $strings[] = is_string($key)
337
-                ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
338
-                : ' - '.$value;
339
-        }
340
-        return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
341
-    }
326
+	/**
327
+	 * @param string $title
328
+	 * @return string
329
+	 */
330
+	protected function implode($title, array $details)
331
+	{
332
+		$strings = ['['.$title.']'];
333
+		$padding = max(array_map('strlen', array_keys($details)));
334
+		$padding = max([$padding, static::PAD]);
335
+		foreach ($details as $key => $value) {
336
+			$strings[] = is_string($key)
337
+				? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
338
+				: ' - '.$value;
339
+		}
340
+		return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
341
+	}
342 342
 
343
-    /**
344
-     * @param string $key
345
-     * @return bool
346
-     */
347
-    protected function isWebhostCheckValid($key)
348
-    {
349
-        return defined($key)
350
-            || filter_input(INPUT_SERVER, $key)
351
-            || Str::contains(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
352
-            || Str::contains(DB_HOST, $key)
353
-            || Str::contains(php_uname(), $key);
354
-    }
343
+	/**
344
+	 * @param string $key
345
+	 * @return bool
346
+	 */
347
+	protected function isWebhostCheckValid($key)
348
+	{
349
+		return defined($key)
350
+			|| filter_input(INPUT_SERVER, $key)
351
+			|| Str::contains(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
352
+			|| Str::contains(DB_HOST, $key)
353
+			|| Str::contains(php_uname(), $key);
354
+	}
355 355
 
356
-    /**
357
-     * @return array
358
-     */
359
-    protected function normalizePluginList(array $plugins)
360
-    {
361
-        $plugins = array_map(function ($plugin) {
362
-            return sprintf('%s v%s', Arr::get($plugin, 'Name'), Arr::get($plugin, 'Version'));
363
-        }, $plugins);
364
-        natcasesort($plugins);
365
-        return array_flip($plugins);
366
-    }
356
+	/**
357
+	 * @return array
358
+	 */
359
+	protected function normalizePluginList(array $plugins)
360
+	{
361
+		$plugins = array_map(function ($plugin) {
362
+			return sprintf('%s v%s', Arr::get($plugin, 'Name'), Arr::get($plugin, 'Version'));
363
+		}, $plugins);
364
+		natcasesort($plugins);
365
+		return array_flip($plugins);
366
+	}
367 367
 
368
-    /**
369
-     * @return array
370
-     */
371
-    protected function purgeSensitiveData(array $settings)
372
-    {
373
-        $keys = [
374
-            'general.trustalyze_serial',
375
-            'licenses.',
376
-            'submissions.recaptcha.key',
377
-            'submissions.recaptcha.secret',
378
-        ];
379
-        array_walk($settings, function (&$value, $setting) use ($keys) {
380
-            foreach ($keys as $key) {
381
-                if (!Str::startsWith($key, $setting) || empty($value)) {
382
-                    continue;
383
-                }
384
-                $value = str_repeat('•', 13);
385
-                return;
386
-            }
387
-        });
388
-        return $settings;
389
-    }
368
+	/**
369
+	 * @return array
370
+	 */
371
+	protected function purgeSensitiveData(array $settings)
372
+	{
373
+		$keys = [
374
+			'general.trustalyze_serial',
375
+			'licenses.',
376
+			'submissions.recaptcha.key',
377
+			'submissions.recaptcha.secret',
378
+		];
379
+		array_walk($settings, function (&$value, $setting) use ($keys) {
380
+			foreach ($keys as $key) {
381
+				if (!Str::startsWith($key, $setting) || empty($value)) {
382
+					continue;
383
+				}
384
+				$value = str_repeat('•', 13);
385
+				return;
386
+			}
387
+		});
388
+		return $settings;
389
+	}
390 390
 }
Please login to merge, or discard this patch.
Spacing   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -42,17 +42,17 @@  discard block
 block discarded – undo
42 42
             'setting' => 'Plugin Settings',
43 43
             'reviews' => 'Review Counts',
44 44
         ];
45
-        $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
46
-            $methodName = Helper::buildMethodName('get-'.$key.'-details');
47
-            if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
45
+        $systemInfo = array_reduce( array_keys( $details ), function( $carry, $key ) use ($details) {
46
+            $methodName = Helper::buildMethodName( 'get-'.$key.'-details' );
47
+            if( method_exists( $this, $methodName ) && $systemDetails = $this->$methodName() ) {
48 48
                 return $carry.$this->implode(
49
-                    strtoupper($details[$key]),
50
-                    apply_filters('site-reviews/system/'.$key, $systemDetails)
49
+                    strtoupper( $details[$key] ),
50
+                    apply_filters( 'site-reviews/system/'.$key, $systemDetails )
51 51
                 );
52 52
             }
53 53
             return $carry;
54 54
         });
55
-        return trim($systemInfo);
55
+        return trim( $systemInfo );
56 56
     }
57 57
 
58 58
     /**
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
     public function getActivePluginDetails()
62 62
     {
63 63
         $plugins = get_plugins();
64
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
65
-        $inactive = array_diff_key($plugins, array_flip($activePlugins));
66
-        return $this->normalizePluginList(array_diff_key($plugins, $inactive));
64
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
65
+        $inactive = array_diff_key( $plugins, array_flip( $activePlugins ) );
66
+        return $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
67 67
     }
68 68
 
69 69
     /**
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function getAddonDetails()
73 73
     {
74
-        $details = apply_filters('site-reviews/addon/system-info', []);
75
-        ksort($details);
74
+        $details = apply_filters( 'site-reviews/addon/system-info', [] );
75
+        ksort( $details );
76 76
         return $details;
77 77
     }
78 78
 
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
     public function getBrowserDetails()
83 83
     {
84 84
         $browser = new Browser();
85
-        $name = esc_attr($browser->getName());
86
-        $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
87
-        $version = esc_attr($browser->getVersion());
85
+        $name = esc_attr( $browser->getName() );
86
+        $userAgent = esc_attr( $browser->getUserAgent()->getUserAgentString() );
87
+        $version = esc_attr( $browser->getVersion() );
88 88
         return [
89
-            'Browser Name' => sprintf('%s %s', $name, $version),
89
+            'Browser Name' => sprintf( '%s %s', $name, $version ),
90 90
             'Browser UA' => $userAgent,
91 91
         ];
92 92
     }
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
      */
97 97
     public function getInactivePluginDetails()
98 98
     {
99
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
100
-        $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
99
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
100
+        $inactivePlugins = $this->normalizePluginList( array_diff_key( get_plugins(), array_flip( $activePlugins ) ) );
101 101
         $multisitePlugins = $this->getMultisitePluginDetails();
102 102
         return empty($multisitePlugins)
103 103
             ? $inactivePlugins
104
-            : array_diff($inactivePlugins, $multisitePlugins);
104
+            : array_diff( $inactivePlugins, $multisitePlugins );
105 105
     }
106 106
 
107 107
     /**
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function getMuPluginDetails()
111 111
     {
112
-        if (empty($plugins = get_mu_plugins())) {
112
+        if( empty($plugins = get_mu_plugins()) ) {
113 113
             return [];
114 114
         }
115
-        return $this->normalizePluginList($plugins);
115
+        return $this->normalizePluginList( $plugins );
116 116
     }
117 117
 
118 118
     /**
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public function getMultisitePluginDetails()
122 122
     {
123
-        $activePlugins = (array) get_site_option('active_sitewide_plugins', []);
124
-        if (!is_multisite() || empty($activePlugins)) {
123
+        $activePlugins = (array)get_site_option( 'active_sitewide_plugins', [] );
124
+        if( !is_multisite() || empty($activePlugins) ) {
125 125
             return [];
126 126
         }
127
-        return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
127
+        return $this->normalizePluginList( array_intersect_key( get_plugins(), $activePlugins ) );
128 128
     }
129 129
 
130 130
     /**
@@ -132,31 +132,31 @@  discard block
 block discarded – undo
132 132
      */
133 133
     public function getPhpDetails()
134 134
     {
135
-        $displayErrors = $this->getINI('display_errors', null)
136
-            ? 'On ('.$this->getINI('display_errors').')'
135
+        $displayErrors = $this->getINI( 'display_errors', null )
136
+            ? 'On ('.$this->getINI( 'display_errors' ).')'
137 137
             : 'N/A';
138
-        $intlSupport = extension_loaded('intl')
139
-            ? phpversion('intl')
138
+        $intlSupport = extension_loaded( 'intl' )
139
+            ? phpversion( 'intl' )
140 140
             : 'false';
141 141
         return [
142
-            'cURL' => var_export(function_exists('curl_init'), true),
143
-            'Default Charset' => $this->getINI('default_charset'),
142
+            'cURL' => var_export( function_exists( 'curl_init' ), true ),
143
+            'Default Charset' => $this->getINI( 'default_charset' ),
144 144
             'Display Errors' => $displayErrors,
145
-            'fsockopen' => var_export(function_exists('fsockopen'), true),
145
+            'fsockopen' => var_export( function_exists( 'fsockopen' ), true ),
146 146
             'Intl' => $intlSupport,
147
-            'IPv6' => var_export(defined('AF_INET6'), true),
148
-            'Max Execution Time' => $this->getINI('max_execution_time'),
149
-            'Max Input Nesting Level' => $this->getINI('max_input_nesting_level'),
150
-            'Max Input Vars' => $this->getINI('max_input_vars'),
151
-            'Memory Limit' => $this->getINI('memory_limit'),
152
-            'Post Max Size' => $this->getINI('post_max_size'),
153
-            'Sendmail Path' => $this->getINI('sendmail_path'),
154
-            'Session Cookie Path' => esc_html($this->getINI('session.cookie_path')),
155
-            'Session Name' => esc_html($this->getINI('session.name')),
156
-            'Session Save Path' => esc_html($this->getINI('session.save_path')),
157
-            'Session Use Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_cookies', false)), true),
158
-            'Session Use Only Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_only_cookies', false)), true),
159
-            'Upload Max Filesize' => $this->getINI('upload_max_filesize'),
147
+            'IPv6' => var_export( defined( 'AF_INET6' ), true ),
148
+            'Max Execution Time' => $this->getINI( 'max_execution_time' ),
149
+            'Max Input Nesting Level' => $this->getINI( 'max_input_nesting_level' ),
150
+            'Max Input Vars' => $this->getINI( 'max_input_vars' ),
151
+            'Memory Limit' => $this->getINI( 'memory_limit' ),
152
+            'Post Max Size' => $this->getINI( 'post_max_size' ),
153
+            'Sendmail Path' => $this->getINI( 'sendmail_path' ),
154
+            'Session Cookie Path' => esc_html( $this->getINI( 'session.cookie_path' ) ),
155
+            'Session Name' => esc_html( $this->getINI( 'session.name' ) ),
156
+            'Session Save Path' => esc_html( $this->getINI( 'session.save_path' ) ),
157
+            'Session Use Cookies' => var_export( wp_validate_boolean( $this->getINI( 'session.use_cookies', false ) ), true ),
158
+            'Session Use Only Cookies' => var_export( wp_validate_boolean( $this->getINI( 'session.use_only_cookies', false ) ), true ),
159
+            'Upload Max Filesize' => $this->getINI( 'upload_max_filesize' ),
160 160
         ];
161 161
     }
162 162
 
@@ -165,19 +165,19 @@  discard block
 block discarded – undo
165 165
      */
166 166
     public function getReviewsDetails()
167 167
     {
168
-        $counts = glsr(CountsManager::class)->getCounts();
169
-        $counts = Arr::flattenArray($counts);
170
-        array_walk($counts, function (&$ratings) use ($counts) {
171
-            if (is_array($ratings)) {
172
-                $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
168
+        $counts = glsr( CountsManager::class )->getCounts();
169
+        $counts = Arr::flattenArray( $counts );
170
+        array_walk( $counts, function( &$ratings ) use ($counts) {
171
+            if( is_array( $ratings ) ) {
172
+                $ratings = array_sum( $ratings ).' ('.implode( ', ', $ratings ).')';
173 173
                 return;
174 174
             }
175 175
             glsr_log()
176
-                ->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
177
-                ->debug($ratings)
178
-                ->debug($counts);
176
+                ->error( '$ratings is not an array, possibly due to incorrectly imported reviews.' )
177
+                ->debug( $ratings )
178
+                ->debug( $counts );
179 179
         });
180
-        ksort($counts);
180
+        ksort( $counts );
181 181
         return $counts;
182 182
     }
183 183
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
             'Host Name' => $this->getHostName(),
192 192
             'MySQL Version' => $wpdb->db_version(),
193 193
             'PHP Version' => PHP_VERSION,
194
-            'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
194
+            'Server Software' => filter_input( INPUT_SERVER, 'SERVER_SOFTWARE' ),
195 195
         ];
196 196
     }
197 197
 
@@ -200,16 +200,16 @@  discard block
 block discarded – undo
200 200
      */
201 201
     public function getSettingDetails()
202 202
     {
203
-        $settings = glsr(OptionManager::class)->get('settings', []);
204
-        $settings = Arr::flattenArray($settings, true);
205
-        $settings = $this->purgeSensitiveData($settings);
206
-        ksort($settings);
203
+        $settings = glsr( OptionManager::class )->get( 'settings', [] );
204
+        $settings = Arr::flattenArray( $settings, true );
205
+        $settings = $this->purgeSensitiveData( $settings );
206
+        ksort( $settings );
207 207
         $details = [];
208
-        foreach ($settings as $key => $value) {
209
-            if (Str::startsWith('strings', $key) && Str::endsWith('id', $key)) {
208
+        foreach( $settings as $key => $value ) {
209
+            if( Str::startsWith( 'strings', $key ) && Str::endsWith( 'id', $key ) ) {
210 210
                 continue;
211 211
             }
212
-            $value = htmlspecialchars(trim(preg_replace('/\s\s+/', '\\n', $value)), ENT_QUOTES, 'UTF-8');
212
+            $value = htmlspecialchars( trim( preg_replace( '/\s\s+/', '\\n', $value ) ), ENT_QUOTES, 'UTF-8' );
213 213
             $details[$key] = $value;
214 214
         }
215 215
         return $details;
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
     public function getPluginDetails()
222 222
     {
223 223
         return [
224
-            'Console level' => glsr(Console::class)->humanLevel(),
225
-            'Console size' => glsr(Console::class)->humanSize('0'),
226
-            'Last Migration Run' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_migration_run'), 'unknown'),
227
-            'Last Rating Count' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_review_count'), 'unknown'),
224
+            'Console level' => glsr( Console::class )->humanLevel(),
225
+            'Console size' => glsr( Console::class )->humanSize( '0' ),
226
+            'Last Migration Run' => glsr( Date::class )->localized( glsr( OptionManager::class )->get( 'last_migration_run' ), 'unknown' ),
227
+            'Last Rating Count' => glsr( Date::class )->localized( glsr( OptionManager::class )->get( 'last_review_count' ), 'unknown' ),
228 228
             'Version (current)' => glsr()->version,
229
-            'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
229
+            'Version (previous)' => glsr( OptionManager::class )->get( 'version_upgraded_from' ),
230 230
         ];
231 231
     }
232 232
 
@@ -238,23 +238,23 @@  discard block
 block discarded – undo
238 238
         global $wpdb;
239 239
         $theme = wp_get_theme();
240 240
         return [
241
-            'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
242
-            'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
241
+            'Active Theme' => sprintf( '%s v%s', (string)$theme->Name, (string)$theme->Version ),
242
+            'Email Domain' => substr( strrchr( glsr( OptionManager::class )->getWP( 'admin_email' ), '@' ), 1 ),
243 243
             'Home URL' => home_url(),
244 244
             'Language' => get_locale(),
245 245
             'Memory Limit' => WP_MEMORY_LIMIT,
246
-            'Multisite' => var_export(is_multisite(), true),
247
-            'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
248
-            'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
249
-            'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
250
-            'Post Stati' => implode(', ', get_post_stati()),
251
-            'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
252
-            'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
246
+            'Multisite' => var_export( is_multisite(), true ),
247
+            'Page For Posts ID' => glsr( OptionManager::class )->getWP( 'page_for_posts' ),
248
+            'Page On Front ID' => glsr( OptionManager::class )->getWP( 'page_on_front' ),
249
+            'Permalink Structure' => glsr( OptionManager::class )->getWP( 'permalink_structure', 'default' ),
250
+            'Post Stati' => implode( ', ', get_post_stati() ),
251
+            'Remote Post' => glsr( Cache::class )->getRemotePostTest(),
252
+            'Show On Front' => glsr( OptionManager::class )->getWP( 'show_on_front' ),
253 253
             'Site URL' => site_url(),
254
-            'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', $this->getINI('date.timezone').' (PHP)'),
255
-            'Version' => get_bloginfo('version'),
256
-            'WP Debug' => var_export(defined('WP_DEBUG'), true),
257
-            'WP Max Upload Size' => size_format(wp_max_upload_size()),
254
+            'Timezone' => glsr( OptionManager::class )->getWP( 'timezone_string', $this->getINI( 'date.timezone' ).' (PHP)' ),
255
+            'Version' => get_bloginfo( 'version' ),
256
+            'WP Debug' => var_export( defined( 'WP_DEBUG' ), true ),
257
+            'WP Max Upload Size' => size_format( wp_max_upload_size() ),
258 258
             'WP Memory Limit' => WP_MEMORY_LIMIT,
259 259
         ];
260 260
     }
@@ -284,13 +284,13 @@  discard block
 block discarded – undo
284 284
             'secureserver.net' => 'GoDaddy',
285 285
             'WPE_APIKEY' => 'WP Engine',
286 286
         ];
287
-        foreach ($checks as $key => $value) {
288
-            if (!$this->isWebhostCheckValid($key)) {
287
+        foreach( $checks as $key => $value ) {
288
+            if( !$this->isWebhostCheckValid( $key ) ) {
289 289
                 continue;
290 290
             }
291 291
             return $value;
292 292
         }
293
-        return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
293
+        return implode( ',', array_filter( [DB_HOST, filter_input( INPUT_SERVER, 'SERVER_NAME' )] ) );
294 294
     }
295 295
 
296 296
     /**
@@ -298,16 +298,16 @@  discard block
 block discarded – undo
298 298
      */
299 299
     protected function getHostName()
300 300
     {
301
-        return sprintf('%s (%s)',
301
+        return sprintf( '%s (%s)',
302 302
             $this->detectWebhostProvider(),
303 303
             Helper::getIpAddress()
304 304
         );
305 305
     }
306 306
 
307
-    protected function getINI($name, $disabledValue = 'ini_get() is disabled.')
307
+    protected function getINI( $name, $disabledValue = 'ini_get() is disabled.' )
308 308
     {
309
-        return function_exists('ini_get')
310
-            ? ini_get($name)
309
+        return function_exists( 'ini_get' )
310
+            ? ini_get( $name )
311 311
             : $disabledValue;
312 312
     }
313 313
 
@@ -317,9 +317,9 @@  discard block
 block discarded – undo
317 317
     protected function getWordpressPlugins()
318 318
     {
319 319
         $plugins = get_plugins();
320
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
321
-        $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
322
-        $active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
320
+        $activePlugins = glsr( OptionManager::class )->getWP( 'active_plugins', [], 'array' );
321
+        $inactive = $this->normalizePluginList( array_diff_key( $plugins, array_flip( $activePlugins ) ) );
322
+        $active = $this->normalizePluginList( array_diff_key( $plugins, $inactive ) );
323 323
         return $active + $inactive;
324 324
     }
325 325
 
@@ -327,48 +327,48 @@  discard block
 block discarded – undo
327 327
      * @param string $title
328 328
      * @return string
329 329
      */
330
-    protected function implode($title, array $details)
330
+    protected function implode( $title, array $details )
331 331
     {
332 332
         $strings = ['['.$title.']'];
333
-        $padding = max(array_map('strlen', array_keys($details)));
334
-        $padding = max([$padding, static::PAD]);
335
-        foreach ($details as $key => $value) {
336
-            $strings[] = is_string($key)
337
-                ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
333
+        $padding = max( array_map( 'strlen', array_keys( $details ) ) );
334
+        $padding = max( [$padding, static::PAD] );
335
+        foreach( $details as $key => $value ) {
336
+            $strings[] = is_string( $key )
337
+                ? sprintf( '%s : %s', str_pad( $key, $padding, '.' ), $value )
338 338
                 : ' - '.$value;
339 339
         }
340
-        return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
340
+        return implode( PHP_EOL, $strings ).PHP_EOL.PHP_EOL;
341 341
     }
342 342
 
343 343
     /**
344 344
      * @param string $key
345 345
      * @return bool
346 346
      */
347
-    protected function isWebhostCheckValid($key)
347
+    protected function isWebhostCheckValid( $key )
348 348
     {
349
-        return defined($key)
350
-            || filter_input(INPUT_SERVER, $key)
351
-            || Str::contains(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
352
-            || Str::contains(DB_HOST, $key)
353
-            || Str::contains(php_uname(), $key);
349
+        return defined( $key )
350
+            || filter_input( INPUT_SERVER, $key )
351
+            || Str::contains( filter_input( INPUT_SERVER, 'SERVER_NAME' ), $key )
352
+            || Str::contains( DB_HOST, $key )
353
+            || Str::contains( php_uname(), $key );
354 354
     }
355 355
 
356 356
     /**
357 357
      * @return array
358 358
      */
359
-    protected function normalizePluginList(array $plugins)
359
+    protected function normalizePluginList( array $plugins )
360 360
     {
361
-        $plugins = array_map(function ($plugin) {
362
-            return sprintf('%s v%s', Arr::get($plugin, 'Name'), Arr::get($plugin, 'Version'));
363
-        }, $plugins);
364
-        natcasesort($plugins);
365
-        return array_flip($plugins);
361
+        $plugins = array_map( function( $plugin ) {
362
+            return sprintf( '%s v%s', Arr::get( $plugin, 'Name' ), Arr::get( $plugin, 'Version' ) );
363
+        }, $plugins );
364
+        natcasesort( $plugins );
365
+        return array_flip( $plugins );
366 366
     }
367 367
 
368 368
     /**
369 369
      * @return array
370 370
      */
371
-    protected function purgeSensitiveData(array $settings)
371
+    protected function purgeSensitiveData( array $settings )
372 372
     {
373 373
         $keys = [
374 374
             'general.trustalyze_serial',
@@ -376,12 +376,12 @@  discard block
 block discarded – undo
376 376
             'submissions.recaptcha.key',
377 377
             'submissions.recaptcha.secret',
378 378
         ];
379
-        array_walk($settings, function (&$value, $setting) use ($keys) {
380
-            foreach ($keys as $key) {
381
-                if (!Str::startsWith($key, $setting) || empty($value)) {
379
+        array_walk( $settings, function( &$value, $setting ) use ($keys) {
380
+            foreach( $keys as $key ) {
381
+                if( !Str::startsWith( $key, $setting ) || empty($value) ) {
382 382
                     continue;
383 383
                 }
384
-                $value = str_repeat('•', 13);
384
+                $value = str_repeat( '•', 13 );
385 385
                 return;
386 386
             }
387 387
         });
Please login to merge, or discard this patch.
views/pages/documentation/shortcodes.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <p>This page shows all of the available shortcode options with examples of how to use them. You can use multiple options in the same shortcode.</p>
4 4
 
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
     <div class="glsr-card-header">
7 7
         <h3>[site_reviews]</h3>
8 8
         <button type="button" class="handlediv" aria-expanded="true">
9
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
9
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
10 10
             <span class="toggle-indicator" aria-hidden="true"></span>
11 11
         </button>
12 12
     </div>
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
     <div class="glsr-card-header">
81 81
         <h3>[site_reviews_form]</h3>
82 82
         <button type="button" class="handlediv" aria-expanded="true">
83
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
83
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
84 84
             <span class="toggle-indicator" aria-hidden="true"></span>
85 85
         </button>
86 86
     </div>
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
     <div class="glsr-card-header">
129 129
         <h3>[site_reviews_summary]</h3>
130 130
         <button type="button" class="handlediv" aria-expanded="true">
131
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
131
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
132 132
             <span class="toggle-indicator" aria-hidden="true"></span>
133 133
         </button>
134 134
     </div>
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         <pre><code>[site_reviews_summary hide="bars,if_empty,rating,stars,summary"]</code></pre>
159 159
 
160 160
         <p class="glsr-heading">labels</p>
161
-        <p>The "labels" attribute allows you to enter custom labels for the percentage bar levels (from high to low), each level should be separated with a comma. However, rather than using this attribute to change the labels it's recommended to instead create a custom translation for them in the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations'); ?>">Settings &rarr; Translations</a></code> page.</p>
161
+        <p>The "labels" attribute allows you to enter custom labels for the percentage bar levels (from high to low), each level should be separated with a comma. However, rather than using this attribute to change the labels it's recommended to instead create a custom translation for them in the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations' ); ?>">Settings &rarr; Translations</a></code> page.</p>
162 162
         <p>The default labels value is: <code>"Excellent,Very good,Average,Poor,Terrible"</code></p>
163 163
         <pre><code>[site_reviews_summary labels="5 star,4 star,3 star,2 star,1 star"]</code></pre>
164 164
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
         <pre><code>[site_reviews_summary schema="true"]</code></pre>
176 176
 
177 177
         <p class="glsr-heading">text</p>
178
-        <p>The "text" attribute allows you to change the summary text. Available template tags to use are, "{rating}" which represents the calculated average rating, "{max}" which represents the maximum star rating available, and "{num}" which represents the total number of reviews. However, rather than using this attribute to change the summary text it's recommended to instead create a custom translation for it in the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations'); ?>">Settings &rarr; Translations</a></code> page. That way, you will be able to customize both the singular (1 review) and plural (2 reviews) summary texts.</p>
178
+        <p>The "text" attribute allows you to change the summary text. Available template tags to use are, "{rating}" which represents the calculated average rating, "{max}" which represents the maximum star rating available, and "{num}" which represents the total number of reviews. However, rather than using this attribute to change the summary text it's recommended to instead create a custom translation for it in the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations' ); ?>">Settings &rarr; Translations</a></code> page. That way, you will be able to customize both the singular (1 review) and plural (2 reviews) summary texts.</p>
179 179
         <p>The default text value is: <code>"{rating} out of {max} stars (based on {num} reviews)"</code></p>
180 180
         <pre><code>[site_reviews_summary text="{num} customer reviews"]</code></pre>
181 181
 
Please login to merge, or discard this patch.
views/pages/documentation/faq.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <div id="faq-01" class="glsr-card postbox">
4 4
     <div class="glsr-card-header">
5 5
         <h3>How do I add additional values to the schema?</h3>
6 6
         <button type="button" class="handlediv" aria-expanded="true">
7
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
7
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
8 8
             <span class="toggle-indicator" aria-hidden="true"></span>
9 9
         </button>
10 10
     </div>
11 11
     <div class="inside">
12
-        <p>To add additional values to the generated schema, use the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks'); ?>" data-expand="#hooks-07">site-reviews/schema/[SCHEMA_TYPE]</a></code> hook in your theme's functions.php file.</p>
12
+        <p>To add additional values to the generated schema, use the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks' ); ?>" data-expand="#hooks-07">site-reviews/schema/[SCHEMA_TYPE]</a></code> hook in your theme's functions.php file.</p>
13 13
         <p>Make sure to use Google's <a href="https://search.google.com/structured-data/testing-tool">Structured Data Testing Tool</a> to test the schema after any custom modifications have been made.</p>
14 14
         <pre><code class="php">/**
15 15
  * Modifies the schema created by Site Reviews.
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     <div class="glsr-card-header">
35 35
         <h3>How do I add pagination to my reviews?</h3>
36 36
         <button type="button" class="handlediv" aria-expanded="true">
37
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
37
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
38 38
             <span class="toggle-indicator" aria-hidden="true"></span>
39 39
         </button>
40 40
     </div>
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         <p>If you are using the shortcodes, then use the <code>pagination</code> and <code>count</code> options.</p>
44 44
         <p>For example, this will paginate reviews to 10 reviews per-page:</p>
45 45
         <pre><code class="php">[site_reviews pagination=ajax count=10]</code></pre>
46
-        <p>To lean more about the available shortcode options and how to use them, please see the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes'); ?>">Documentation > Shortcodes</a></code> page.</p>
46
+        <p>To lean more about the available shortcode options and how to use them, please see the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes' ); ?>">Documentation > Shortcodes</a></code> page.</p>
47 47
     </div>
48 48
 </div>
49 49
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     <div class="glsr-card-header">
52 52
         <h3>How do I assign reviews to a page?</h3>
53 53
         <button type="button" class="handlediv" aria-expanded="true">
54
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
54
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
55 55
             <span class="toggle-indicator" aria-hidden="true"></span>
56 56
         </button>
57 57
     </div>
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         <p>If you use <code>post_id</code> as the value, then Site Reviews will know to automatically use the Page ID of the current page.</p>
70 70
         <p>If you use <code>parent_id</code> as the value, then Site Reviews will know to automatically use the Page ID of the current page's Parent.</p>
71 71
         <p>You can, of course, also directly enter the numerical WordPress Page ID of the page instead if your prefer.</p>
72
-        <p>To lean more about the available shortcode options and how to use them, please see the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes'); ?>">Documentation > Shortcodes</a></code> page.</p>
72
+        <p>To lean more about the available shortcode options and how to use them, please see the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-shortcodes' ); ?>">Documentation > Shortcodes</a></code> page.</p>
73 73
     </div>
74 74
 </div>
75 75
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     <div class="glsr-card-header">
78 78
         <h3>How do I change the font?</h3>
79 79
         <button type="button" class="handlediv" aria-expanded="true">
80
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
80
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
81 81
             <span class="toggle-indicator" aria-hidden="true"></span>
82 82
         </button>
83 83
     </div>
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     <div class="glsr-card-header">
94 94
         <h3>How do I change the order of the review fields?</h3>
95 95
         <button type="button" class="handlediv" aria-expanded="true">
96
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
96
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
97 97
             <span class="toggle-indicator" aria-hidden="true"></span>
98 98
         </button>
99 99
     </div>
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     <div class="glsr-card-header">
122 122
         <h3>How do I change the order of the reviews summary fields?</h3>
123 123
         <button type="button" class="handlediv" aria-expanded="true">
124
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
124
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
125 125
             <span class="toggle-indicator" aria-hidden="true"></span>
126 126
         </button>
127 127
     </div>
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
     <div class="glsr-card-header">
148 148
         <h3>How do I change the order of the submission form fields?</h3>
149 149
         <button type="button" class="handlediv" aria-expanded="true">
150
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
150
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
151 151
             <span class="toggle-indicator" aria-hidden="true"></span>
152 152
         </button>
153 153
     </div>
154 154
     <div class="inside">
155
-        <p>To customise the order of the fields in the review submission form, use the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks'); ?>" data-expand="#hooks-01">site-reviews/submission-form/order</a></code> filter hook in your theme's <code>functions.php</code> file.</p>
155
+        <p>To customise the order of the fields in the review submission form, use the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks' ); ?>" data-expand="#hooks-01">site-reviews/submission-form/order</a></code> filter hook in your theme's <code>functions.php</code> file.</p>
156 156
         <pre><code class="php">/**
157 157
  * Customises the order of the fields used in the Site Reviews submission form.
158 158
  * Paste this in your active theme's functions.php file.
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
         'terms',
172 172
     ];
173 173
 });</code></pre>
174
-        <p>If you have used the example above and the submission-form fields are not working correctly, check the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=tools#tab-console'); ?>">Tools &rarr; Console</a></code> for errors.</p>
174
+        <p>If you have used the example above and the submission-form fields are not working correctly, check the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=tools#tab-console' ); ?>">Tools &rarr; Console</a></code> for errors.</p>
175 175
     </div>
176 176
 </div>
177 177
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     <div class="glsr-card-header">
180 180
         <h3>How do I change the pagination query string?</h3>
181 181
         <button type="button" class="handlediv" aria-expanded="true">
182
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
182
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
183 183
             <span class="toggle-indicator" aria-hidden="true"></span>
184 184
         </button>
185 185
     </div>
@@ -201,12 +201,12 @@  discard block
 block discarded – undo
201 201
     <div class="glsr-card-header">
202 202
         <h3>How do I change the text of...?</h3>
203 203
         <button type="button" class="handlediv" aria-expanded="true">
204
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
204
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
205 205
             <span class="toggle-indicator" aria-hidden="true"></span>
206 206
         </button>
207 207
     </div>
208 208
     <div class="inside">
209
-        <p>You can change any text in the plugin on the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations'); ?>">Settings &rarr; Translations</a></code> page.</p>
209
+        <p>You can change any text in the plugin on the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations' ); ?>">Settings &rarr; Translations</a></code> page.</p>
210 210
     </div>
211 211
 </div>
212 212
 
@@ -214,12 +214,12 @@  discard block
 block discarded – undo
214 214
     <div class="glsr-card-header">
215 215
         <h3>How do I create a review programmatically?</h3>
216 216
         <button type="button" class="handlediv" aria-expanded="true">
217
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
217
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
218 218
             <span class="toggle-indicator" aria-hidden="true"></span>
219 219
         </button>
220 220
     </div>
221 221
     <div class="inside">
222
-        <p>Site Reviews provides a <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-functions'); ?>" data-expand="#functions-02">glsr_create_review()</a></code> helper function to easily create a review.</p>
222
+        <p>Site Reviews provides a <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-functions' ); ?>" data-expand="#functions-02">glsr_create_review()</a></code> helper function to easily create a review.</p>
223 223
         <p>Here is an example:</p>
224 224
         <pre><code class="php">if (function_exists('glsr_create_review')) {
225 225
     $review = glsr_create_review([
@@ -239,12 +239,12 @@  discard block
 block discarded – undo
239 239
     <div class="glsr-card-header">
240 240
         <h3>How do I customise the stars?</h3>
241 241
         <button type="button" class="handlediv" aria-expanded="true">
242
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
242
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
243 243
             <span class="toggle-indicator" aria-hidden="true"></span>
244 244
         </button>
245 245
     </div>
246 246
     <div class="inside">
247
-        <p>To customise the star images used by the plugin, use the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks'); ?>" data-expand="#hooks-02">site-reviews/config/inline-styles</a></code> filter hook in your theme's <code>functions.php</code> file.</p>
247
+        <p>To customise the star images used by the plugin, use the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=documentation#tab-hooks' ); ?>" data-expand="#hooks-02">site-reviews/config/inline-styles</a></code> filter hook in your theme's <code>functions.php</code> file.</p>
248 248
         <p>Here is an example:</p>
249 249
         <pre><code class="php">/**
250 250
  * Customises the stars used by Site Reviews.
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
             <li>Open the SVG images that you copied with a text editor</li>
267 267
             <li>Change the <a target="_blank" href="https://www.hexcolortool.com">hex colour code</a> to the one you want</li>
268 268
             <li>Install and activate the <a target="_blank" href="https://wordpress.org/plugins/safe-svg/">Safe SVG</a> plugin</li>
269
-            <li>Upload the edited SVG images to your <a href="<?= admin_url('upload.php'); ?>">Media Library</a></li>
269
+            <li>Upload the edited SVG images to your <a href="<?= admin_url( 'upload.php' ); ?>">Media Library</a></li>
270 270
             <li>Copy the File URL of the uploaded SVG images and paste them into the snippet above</li>
271 271
         </ol>
272 272
     </div>
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
     <div class="glsr-card-header">
277 277
         <h3>How do I hide the form after a review is submitted?</h3>
278 278
         <button type="button" class="handlediv" aria-expanded="true">
279
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
279
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
280 280
             <span class="toggle-indicator" aria-hidden="true"></span>
281 281
         </button>
282 282
     </div>
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
     });";
299 299
 });</code></pre>
300 300
         <p>You can also hide the form from registered users who have already submitted a review.</p>
301
-        <p>To do this, you will need to first make sure that the "Limit Reviews" setting on the <code><a href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions'); ?>">Settings &rarr; Submissions</a></code> page is set to "By Username". Once that is done, you can use the following code snippet:</p>
301
+        <p>To do this, you will need to first make sure that the "Limit Reviews" setting on the <code><a href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-submissions' ); ?>">Settings &rarr; Submissions</a></code> page is set to "By Username". Once that is done, you can use the following code snippet:</p>
302 302
         <pre><code class="php">/**
303 303
  * Hides the submission form from registered users who have already submitted a review
304 304
  * Paste this in your active theme's functions.php file
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
     <div class="glsr-card-header">
320 320
         <h3>How do I limit the submitted review length?</h3>
321 321
         <button type="button" class="handlediv" aria-expanded="true">
322
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
322
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
323 323
             <span class="toggle-indicator" aria-hidden="true"></span>
324 324
         </button>
325 325
     </div>
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
     <div class="glsr-card-header">
358 358
         <h3>How do I order pages with assigned reviews by rating or ranking?</h3>
359 359
         <button type="button" class="handlediv" aria-expanded="true">
360
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
360
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
361 361
             <span class="toggle-indicator" aria-hidden="true"></span>
362 362
         </button>
363 363
     </div>
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
     <div class="glsr-card-header">
414 414
         <h3>How do I prevent search engines from indexing paginated reviews?</h3>
415 415
         <button type="button" class="handlediv" aria-expanded="true">
416
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
416
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
417 417
             <span class="toggle-indicator" aria-hidden="true"></span>
418 418
         </button>
419 419
     </div>
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
         <p>Here is how to prevent search engines from indexing your paginated reviews:</p>
423 423
         <ol>
424 424
             <li>Install and activate the <a href="https://wordpress.org/plugins/robots-txt-editor/">Robots.txt Editor</a> plugin.</li>
425
-            <li>Go to the <code><a href="<?= admin_url('options-reading.php'); ?>">WordPress > Settings > Reading</a></code> page.</li>
425
+            <li>Go to the <code><a href="<?= admin_url( 'options-reading.php' ); ?>">WordPress > Settings > Reading</a></code> page.</li>
426 426
             <li>Make sure that the Robots.txt starts with: <code>User-Agent: *</code></li>
427 427
             <li>Add the following lines:
428 428
                 <pre><code>Disallow: /*?reviews-page=*
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
     <div class="glsr-card-header">
444 444
         <h3>How do I redirect to a custom URL after a form is submitted?</h3>
445 445
         <button type="button" class="handlediv" aria-expanded="true">
446
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
446
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
447 447
             <span class="toggle-indicator" aria-hidden="true"></span>
448 448
         </button>
449 449
     </div>
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
     <div class="glsr-card-header">
457 457
         <h3>How do I remove the dash in front of the author's name?</h3>
458 458
         <button type="button" class="handlediv" aria-expanded="true">
459
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
459
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
460 460
             <span class="toggle-indicator" aria-hidden="true"></span>
461 461
         </button>
462 462
     </div>
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
     <div class="glsr-card-header">
473 473
         <h3>How do I use the plugin templates in my theme?</h3>
474 474
         <button type="button" class="handlediv" aria-expanded="true">
475
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
475
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
476 476
             <span class="toggle-indicator" aria-hidden="true"></span>
477 477
         </button>
478 478
     </div>
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
     <div class="glsr-card-header">
491 491
         <h3>Why are the IP Addresses being detected as 127.0.0.1?</h3>
492 492
         <button type="button" class="handlediv" aria-expanded="true">
493
-            <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span>
493
+            <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span>
494 494
             <span class="toggle-indicator" aria-hidden="true"></span>
495 495
         </button>
496 496
     </div>
Please login to merge, or discard this patch.
plugin/Shortcodes/Shortcode.php 2 patches
Indentation   +234 added lines, -234 removed lines patch added patch discarded remove patch
@@ -12,238 +12,238 @@
 block discarded – undo
12 12
 
13 13
 abstract class Shortcode implements ShortcodeContract
14 14
 {
15
-    /**
16
-     * @var string
17
-     */
18
-    protected $partialName;
19
-
20
-    /**
21
-     * @var string
22
-     */
23
-    protected $shortcodeName;
24
-
25
-    public function __construct()
26
-    {
27
-        $this->partialName = $this->getShortcodePartialName();
28
-        $this->shortcodeName = $this->getShortcodeName();
29
-    }
30
-
31
-    /**
32
-     * @param string|array $atts
33
-     * @param string $type
34
-     * @return string
35
-     */
36
-    public function build($atts, array $args = [], $type = 'shortcode')
37
-    {
38
-        $args = $this->normalizeArgs($args, $type);
39
-        $atts = $this->normalizeAtts($atts, $type);
40
-        $partial = glsr(Partial::class)->build($this->partialName, $atts);
41
-        $title = !empty($atts['title'])
42
-            ? $args['before_title'].$atts['title'].$args['after_title']
43
-            : '';
44
-        $debug = sprintf('<glsr-%1$s hidden data-atts=\'%2$s\'></glsr-%1$s>', $type, $atts['json']);
45
-        return $args['before_widget'].$title.$partial.$debug.$args['after_widget'];
46
-    }
47
-
48
-    /**
49
-     * @param string|array $atts
50
-     * @return string
51
-     */
52
-    public function buildShortcode($atts = [])
53
-    {
54
-        return $this->build($atts);
55
-    }
56
-
57
-    /**
58
-     * @return array
59
-     */
60
-    public function getDefaults($atts)
61
-    {
62
-        return glsr($this->getShortcodeDefaultsClassName())->restrict(wp_parse_args($atts));
63
-    }
64
-
65
-    /**
66
-     * @return array
67
-     */
68
-    public function getHideOptions()
69
-    {
70
-        $options = $this->hideOptions();
71
-        return apply_filters('site-reviews/shortcode/hide-options', $options, $this->shortcodeName);
72
-    }
73
-
74
-    /**
75
-     * @return string
76
-     */
77
-    public function getShortcodeClassName($replace = '', $search = 'Shortcode')
78
-    {
79
-        return str_replace($search, $replace, (new ReflectionClass($this))->getShortName());
80
-    }
81
-
82
-    /**
83
-     * @return string
84
-     */
85
-    public function getShortcodeDefaultsClassName()
86
-    {
87
-        return Helper::buildClassName(
88
-            $this->getShortcodeClassName('Defaults'),
89
-            'Defaults'
90
-        );
91
-    }
92
-
93
-    /**
94
-     * @return string
95
-     */
96
-    public function getShortcodeName()
97
-    {
98
-        return Str::snakeCase($this->getShortcodeClassName());
99
-    }
100
-
101
-    /**
102
-     * @return string
103
-     */
104
-    public function getShortcodePartialName()
105
-    {
106
-        return Str::dashCase($this->getShortcodeClassName());
107
-    }
108
-
109
-    /**
110
-     * @param array|string $args
111
-     * @param string $type
112
-     * @return array
113
-     */
114
-    public function normalizeArgs($args, $type = 'shortcode')
115
-    {
116
-        $args = wp_parse_args($args, [
117
-            'before_widget' => '<div class="glsr-'.$type.' '.$type.'-'.$this->partialName.'">',
118
-            'after_widget' => '</div>',
119
-            'before_title' => '<h3 class="glsr-'.$type.'-title">',
120
-            'after_title' => '</h3>',
121
-        ]);
122
-        return apply_filters('site-reviews/shortcode/args', $args, $type, $this->partialName);
123
-    }
124
-
125
-    /**
126
-     * @param array|string $atts
127
-     * @param string $type
128
-     * @return array
129
-     */
130
-    public function normalizeAtts($atts, $type = 'shortcode')
131
-    {
132
-        $atts = apply_filters('site-reviews/shortcode/atts', $atts, $type, $this->partialName);
133
-        $atts = $this->getDefaults($atts);
134
-        array_walk($atts, function (&$value, $key) {
135
-            $methodName = Helper::buildMethodName($key, 'normalize');
136
-            if (!method_exists($this, $methodName)) {
137
-                return;
138
-            }
139
-            $value = $this->$methodName($value);
140
-        });
141
-        $this->setId($atts);
142
-        return $atts;
143
-    }
144
-
145
-    /**
146
-     * @return array
147
-     */
148
-    abstract protected function hideOptions();
149
-
150
-    /**
151
-     * @param string $postId
152
-     * @return int|string
153
-     */
154
-    protected function normalizeAssignedTo($postId)
155
-    {
156
-        if ('parent_id' == $postId) {
157
-            $postId = intval(wp_get_post_parent_id(intval(get_the_ID())));
158
-        } elseif ('post_id' == $postId) {
159
-            $postId = intval(get_the_ID());
160
-        }
161
-        return $postId;
162
-    }
163
-
164
-    /**
165
-     * @param string $postId
166
-     * @return int|string
167
-     */
168
-    protected function normalizeAssignTo($postId)
169
-    {
170
-        return $this->normalizeAssignedTo($postId);
171
-    }
172
-
173
-    /**
174
-     * @param string|array $hide
175
-     * @return array
176
-     */
177
-    protected function normalizeHide($hide)
178
-    {
179
-        if (is_string($hide)) {
180
-            $hide = explode(',', $hide);
181
-        }
182
-        $hideKeys = array_keys($this->getHideOptions());
183
-        return array_filter(array_map('trim', $hide), function ($value) use ($hideKeys) {
184
-            return in_array($value, $hideKeys);
185
-        });
186
-    }
187
-
188
-    /**
189
-     * @param string $id
190
-     * @return string
191
-     */
192
-    protected function normalizeId($id)
193
-    {
194
-        return sanitize_title($id);
195
-    }
196
-
197
-    /**
198
-     * @param string $labels
199
-     * @return array
200
-     */
201
-    protected function normalizeLabels($labels)
202
-    {
203
-        $defaults = [
204
-            __('Excellent', 'site-reviews'),
205
-            __('Very good', 'site-reviews'),
206
-            __('Average', 'site-reviews'),
207
-            __('Poor', 'site-reviews'),
208
-            __('Terrible', 'site-reviews'),
209
-        ];
210
-        $maxRating = (int) glsr()->constant('MAX_RATING', Rating::class);
211
-        $defaults = array_pad(array_slice($defaults, 0, $maxRating), $maxRating, '');
212
-        $labels = array_map('trim', explode(',', $labels));
213
-        foreach ($defaults as $i => $label) {
214
-            if (empty($labels[$i])) {
215
-                continue;
216
-            }
217
-            $defaults[$i] = $labels[$i];
218
-        }
219
-        return array_combine(range($maxRating, 1), $defaults);
220
-    }
221
-
222
-    /**
223
-     * @param string $schema
224
-     * @return bool
225
-     */
226
-    protected function normalizeSchema($schema)
227
-    {
228
-        return wp_validate_boolean($schema);
229
-    }
230
-
231
-    /**
232
-     * @param string $text
233
-     * @return string
234
-     */
235
-    protected function normalizeText($text)
236
-    {
237
-        return trim($text);
238
-    }
239
-
240
-    /**
241
-     * @return void
242
-     */
243
-    protected function setId(array &$atts)
244
-    {
245
-        if (empty($atts['id'])) {
246
-            $atts['id'] = Application::PREFIX.substr(md5(serialize($atts)), 0, 8);
247
-        }
248
-    }
15
+	/**
16
+	 * @var string
17
+	 */
18
+	protected $partialName;
19
+
20
+	/**
21
+	 * @var string
22
+	 */
23
+	protected $shortcodeName;
24
+
25
+	public function __construct()
26
+	{
27
+		$this->partialName = $this->getShortcodePartialName();
28
+		$this->shortcodeName = $this->getShortcodeName();
29
+	}
30
+
31
+	/**
32
+	 * @param string|array $atts
33
+	 * @param string $type
34
+	 * @return string
35
+	 */
36
+	public function build($atts, array $args = [], $type = 'shortcode')
37
+	{
38
+		$args = $this->normalizeArgs($args, $type);
39
+		$atts = $this->normalizeAtts($atts, $type);
40
+		$partial = glsr(Partial::class)->build($this->partialName, $atts);
41
+		$title = !empty($atts['title'])
42
+			? $args['before_title'].$atts['title'].$args['after_title']
43
+			: '';
44
+		$debug = sprintf('<glsr-%1$s hidden data-atts=\'%2$s\'></glsr-%1$s>', $type, $atts['json']);
45
+		return $args['before_widget'].$title.$partial.$debug.$args['after_widget'];
46
+	}
47
+
48
+	/**
49
+	 * @param string|array $atts
50
+	 * @return string
51
+	 */
52
+	public function buildShortcode($atts = [])
53
+	{
54
+		return $this->build($atts);
55
+	}
56
+
57
+	/**
58
+	 * @return array
59
+	 */
60
+	public function getDefaults($atts)
61
+	{
62
+		return glsr($this->getShortcodeDefaultsClassName())->restrict(wp_parse_args($atts));
63
+	}
64
+
65
+	/**
66
+	 * @return array
67
+	 */
68
+	public function getHideOptions()
69
+	{
70
+		$options = $this->hideOptions();
71
+		return apply_filters('site-reviews/shortcode/hide-options', $options, $this->shortcodeName);
72
+	}
73
+
74
+	/**
75
+	 * @return string
76
+	 */
77
+	public function getShortcodeClassName($replace = '', $search = 'Shortcode')
78
+	{
79
+		return str_replace($search, $replace, (new ReflectionClass($this))->getShortName());
80
+	}
81
+
82
+	/**
83
+	 * @return string
84
+	 */
85
+	public function getShortcodeDefaultsClassName()
86
+	{
87
+		return Helper::buildClassName(
88
+			$this->getShortcodeClassName('Defaults'),
89
+			'Defaults'
90
+		);
91
+	}
92
+
93
+	/**
94
+	 * @return string
95
+	 */
96
+	public function getShortcodeName()
97
+	{
98
+		return Str::snakeCase($this->getShortcodeClassName());
99
+	}
100
+
101
+	/**
102
+	 * @return string
103
+	 */
104
+	public function getShortcodePartialName()
105
+	{
106
+		return Str::dashCase($this->getShortcodeClassName());
107
+	}
108
+
109
+	/**
110
+	 * @param array|string $args
111
+	 * @param string $type
112
+	 * @return array
113
+	 */
114
+	public function normalizeArgs($args, $type = 'shortcode')
115
+	{
116
+		$args = wp_parse_args($args, [
117
+			'before_widget' => '<div class="glsr-'.$type.' '.$type.'-'.$this->partialName.'">',
118
+			'after_widget' => '</div>',
119
+			'before_title' => '<h3 class="glsr-'.$type.'-title">',
120
+			'after_title' => '</h3>',
121
+		]);
122
+		return apply_filters('site-reviews/shortcode/args', $args, $type, $this->partialName);
123
+	}
124
+
125
+	/**
126
+	 * @param array|string $atts
127
+	 * @param string $type
128
+	 * @return array
129
+	 */
130
+	public function normalizeAtts($atts, $type = 'shortcode')
131
+	{
132
+		$atts = apply_filters('site-reviews/shortcode/atts', $atts, $type, $this->partialName);
133
+		$atts = $this->getDefaults($atts);
134
+		array_walk($atts, function (&$value, $key) {
135
+			$methodName = Helper::buildMethodName($key, 'normalize');
136
+			if (!method_exists($this, $methodName)) {
137
+				return;
138
+			}
139
+			$value = $this->$methodName($value);
140
+		});
141
+		$this->setId($atts);
142
+		return $atts;
143
+	}
144
+
145
+	/**
146
+	 * @return array
147
+	 */
148
+	abstract protected function hideOptions();
149
+
150
+	/**
151
+	 * @param string $postId
152
+	 * @return int|string
153
+	 */
154
+	protected function normalizeAssignedTo($postId)
155
+	{
156
+		if ('parent_id' == $postId) {
157
+			$postId = intval(wp_get_post_parent_id(intval(get_the_ID())));
158
+		} elseif ('post_id' == $postId) {
159
+			$postId = intval(get_the_ID());
160
+		}
161
+		return $postId;
162
+	}
163
+
164
+	/**
165
+	 * @param string $postId
166
+	 * @return int|string
167
+	 */
168
+	protected function normalizeAssignTo($postId)
169
+	{
170
+		return $this->normalizeAssignedTo($postId);
171
+	}
172
+
173
+	/**
174
+	 * @param string|array $hide
175
+	 * @return array
176
+	 */
177
+	protected function normalizeHide($hide)
178
+	{
179
+		if (is_string($hide)) {
180
+			$hide = explode(',', $hide);
181
+		}
182
+		$hideKeys = array_keys($this->getHideOptions());
183
+		return array_filter(array_map('trim', $hide), function ($value) use ($hideKeys) {
184
+			return in_array($value, $hideKeys);
185
+		});
186
+	}
187
+
188
+	/**
189
+	 * @param string $id
190
+	 * @return string
191
+	 */
192
+	protected function normalizeId($id)
193
+	{
194
+		return sanitize_title($id);
195
+	}
196
+
197
+	/**
198
+	 * @param string $labels
199
+	 * @return array
200
+	 */
201
+	protected function normalizeLabels($labels)
202
+	{
203
+		$defaults = [
204
+			__('Excellent', 'site-reviews'),
205
+			__('Very good', 'site-reviews'),
206
+			__('Average', 'site-reviews'),
207
+			__('Poor', 'site-reviews'),
208
+			__('Terrible', 'site-reviews'),
209
+		];
210
+		$maxRating = (int) glsr()->constant('MAX_RATING', Rating::class);
211
+		$defaults = array_pad(array_slice($defaults, 0, $maxRating), $maxRating, '');
212
+		$labels = array_map('trim', explode(',', $labels));
213
+		foreach ($defaults as $i => $label) {
214
+			if (empty($labels[$i])) {
215
+				continue;
216
+			}
217
+			$defaults[$i] = $labels[$i];
218
+		}
219
+		return array_combine(range($maxRating, 1), $defaults);
220
+	}
221
+
222
+	/**
223
+	 * @param string $schema
224
+	 * @return bool
225
+	 */
226
+	protected function normalizeSchema($schema)
227
+	{
228
+		return wp_validate_boolean($schema);
229
+	}
230
+
231
+	/**
232
+	 * @param string $text
233
+	 * @return string
234
+	 */
235
+	protected function normalizeText($text)
236
+	{
237
+		return trim($text);
238
+	}
239
+
240
+	/**
241
+	 * @return void
242
+	 */
243
+	protected function setId(array &$atts)
244
+	{
245
+		if (empty($atts['id'])) {
246
+			$atts['id'] = Application::PREFIX.substr(md5(serialize($atts)), 0, 8);
247
+		}
248
+	}
249 249
 }
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
      * @param string $type
34 34
      * @return string
35 35
      */
36
-    public function build($atts, array $args = [], $type = 'shortcode')
36
+    public function build( $atts, array $args = [], $type = 'shortcode' )
37 37
     {
38
-        $args = $this->normalizeArgs($args, $type);
39
-        $atts = $this->normalizeAtts($atts, $type);
40
-        $partial = glsr(Partial::class)->build($this->partialName, $atts);
38
+        $args = $this->normalizeArgs( $args, $type );
39
+        $atts = $this->normalizeAtts( $atts, $type );
40
+        $partial = glsr( Partial::class )->build( $this->partialName, $atts );
41 41
         $title = !empty($atts['title'])
42 42
             ? $args['before_title'].$atts['title'].$args['after_title']
43 43
             : '';
44
-        $debug = sprintf('<glsr-%1$s hidden data-atts=\'%2$s\'></glsr-%1$s>', $type, $atts['json']);
44
+        $debug = sprintf( '<glsr-%1$s hidden data-atts=\'%2$s\'></glsr-%1$s>', $type, $atts['json'] );
45 45
         return $args['before_widget'].$title.$partial.$debug.$args['after_widget'];
46 46
     }
47 47
 
@@ -49,17 +49,17 @@  discard block
 block discarded – undo
49 49
      * @param string|array $atts
50 50
      * @return string
51 51
      */
52
-    public function buildShortcode($atts = [])
52
+    public function buildShortcode( $atts = [] )
53 53
     {
54
-        return $this->build($atts);
54
+        return $this->build( $atts );
55 55
     }
56 56
 
57 57
     /**
58 58
      * @return array
59 59
      */
60
-    public function getDefaults($atts)
60
+    public function getDefaults( $atts )
61 61
     {
62
-        return glsr($this->getShortcodeDefaultsClassName())->restrict(wp_parse_args($atts));
62
+        return glsr( $this->getShortcodeDefaultsClassName() )->restrict( wp_parse_args( $atts ) );
63 63
     }
64 64
 
65 65
     /**
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
     public function getHideOptions()
69 69
     {
70 70
         $options = $this->hideOptions();
71
-        return apply_filters('site-reviews/shortcode/hide-options', $options, $this->shortcodeName);
71
+        return apply_filters( 'site-reviews/shortcode/hide-options', $options, $this->shortcodeName );
72 72
     }
73 73
 
74 74
     /**
75 75
      * @return string
76 76
      */
77
-    public function getShortcodeClassName($replace = '', $search = 'Shortcode')
77
+    public function getShortcodeClassName( $replace = '', $search = 'Shortcode' )
78 78
     {
79
-        return str_replace($search, $replace, (new ReflectionClass($this))->getShortName());
79
+        return str_replace( $search, $replace, (new ReflectionClass( $this ))->getShortName() );
80 80
     }
81 81
 
82 82
     /**
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     public function getShortcodeDefaultsClassName()
86 86
     {
87 87
         return Helper::buildClassName(
88
-            $this->getShortcodeClassName('Defaults'),
88
+            $this->getShortcodeClassName( 'Defaults' ),
89 89
             'Defaults'
90 90
         );
91 91
     }
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function getShortcodeName()
97 97
     {
98
-        return Str::snakeCase($this->getShortcodeClassName());
98
+        return Str::snakeCase( $this->getShortcodeClassName() );
99 99
     }
100 100
 
101 101
     /**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function getShortcodePartialName()
105 105
     {
106
-        return Str::dashCase($this->getShortcodeClassName());
106
+        return Str::dashCase( $this->getShortcodeClassName() );
107 107
     }
108 108
 
109 109
     /**
@@ -111,15 +111,15 @@  discard block
 block discarded – undo
111 111
      * @param string $type
112 112
      * @return array
113 113
      */
114
-    public function normalizeArgs($args, $type = 'shortcode')
114
+    public function normalizeArgs( $args, $type = 'shortcode' )
115 115
     {
116
-        $args = wp_parse_args($args, [
116
+        $args = wp_parse_args( $args, [
117 117
             'before_widget' => '<div class="glsr-'.$type.' '.$type.'-'.$this->partialName.'">',
118 118
             'after_widget' => '</div>',
119 119
             'before_title' => '<h3 class="glsr-'.$type.'-title">',
120 120
             'after_title' => '</h3>',
121
-        ]);
122
-        return apply_filters('site-reviews/shortcode/args', $args, $type, $this->partialName);
121
+        ] );
122
+        return apply_filters( 'site-reviews/shortcode/args', $args, $type, $this->partialName );
123 123
     }
124 124
 
125 125
     /**
@@ -127,18 +127,18 @@  discard block
 block discarded – undo
127 127
      * @param string $type
128 128
      * @return array
129 129
      */
130
-    public function normalizeAtts($atts, $type = 'shortcode')
130
+    public function normalizeAtts( $atts, $type = 'shortcode' )
131 131
     {
132
-        $atts = apply_filters('site-reviews/shortcode/atts', $atts, $type, $this->partialName);
133
-        $atts = $this->getDefaults($atts);
134
-        array_walk($atts, function (&$value, $key) {
135
-            $methodName = Helper::buildMethodName($key, 'normalize');
136
-            if (!method_exists($this, $methodName)) {
132
+        $atts = apply_filters( 'site-reviews/shortcode/atts', $atts, $type, $this->partialName );
133
+        $atts = $this->getDefaults( $atts );
134
+        array_walk( $atts, function( &$value, $key ) {
135
+            $methodName = Helper::buildMethodName( $key, 'normalize' );
136
+            if( !method_exists( $this, $methodName ) ) {
137 137
                 return;
138 138
             }
139
-            $value = $this->$methodName($value);
139
+            $value = $this->$methodName( $value );
140 140
         });
141
-        $this->setId($atts);
141
+        $this->setId( $atts );
142 142
         return $atts;
143 143
     }
144 144
 
@@ -151,12 +151,12 @@  discard block
 block discarded – undo
151 151
      * @param string $postId
152 152
      * @return int|string
153 153
      */
154
-    protected function normalizeAssignedTo($postId)
154
+    protected function normalizeAssignedTo( $postId )
155 155
     {
156
-        if ('parent_id' == $postId) {
157
-            $postId = intval(wp_get_post_parent_id(intval(get_the_ID())));
158
-        } elseif ('post_id' == $postId) {
159
-            $postId = intval(get_the_ID());
156
+        if( 'parent_id' == $postId ) {
157
+            $postId = intval( wp_get_post_parent_id( intval( get_the_ID() ) ) );
158
+        } elseif( 'post_id' == $postId ) {
159
+            $postId = intval( get_the_ID() );
160 160
         }
161 161
         return $postId;
162 162
     }
@@ -165,23 +165,23 @@  discard block
 block discarded – undo
165 165
      * @param string $postId
166 166
      * @return int|string
167 167
      */
168
-    protected function normalizeAssignTo($postId)
168
+    protected function normalizeAssignTo( $postId )
169 169
     {
170
-        return $this->normalizeAssignedTo($postId);
170
+        return $this->normalizeAssignedTo( $postId );
171 171
     }
172 172
 
173 173
     /**
174 174
      * @param string|array $hide
175 175
      * @return array
176 176
      */
177
-    protected function normalizeHide($hide)
177
+    protected function normalizeHide( $hide )
178 178
     {
179
-        if (is_string($hide)) {
180
-            $hide = explode(',', $hide);
179
+        if( is_string( $hide ) ) {
180
+            $hide = explode( ',', $hide );
181 181
         }
182
-        $hideKeys = array_keys($this->getHideOptions());
183
-        return array_filter(array_map('trim', $hide), function ($value) use ($hideKeys) {
184
-            return in_array($value, $hideKeys);
182
+        $hideKeys = array_keys( $this->getHideOptions() );
183
+        return array_filter( array_map( 'trim', $hide ), function( $value ) use ($hideKeys) {
184
+            return in_array( $value, $hideKeys );
185 185
         });
186 186
     }
187 187
 
@@ -189,61 +189,61 @@  discard block
 block discarded – undo
189 189
      * @param string $id
190 190
      * @return string
191 191
      */
192
-    protected function normalizeId($id)
192
+    protected function normalizeId( $id )
193 193
     {
194
-        return sanitize_title($id);
194
+        return sanitize_title( $id );
195 195
     }
196 196
 
197 197
     /**
198 198
      * @param string $labels
199 199
      * @return array
200 200
      */
201
-    protected function normalizeLabels($labels)
201
+    protected function normalizeLabels( $labels )
202 202
     {
203 203
         $defaults = [
204
-            __('Excellent', 'site-reviews'),
205
-            __('Very good', 'site-reviews'),
206
-            __('Average', 'site-reviews'),
207
-            __('Poor', 'site-reviews'),
208
-            __('Terrible', 'site-reviews'),
204
+            __( 'Excellent', 'site-reviews' ),
205
+            __( 'Very good', 'site-reviews' ),
206
+            __( 'Average', 'site-reviews' ),
207
+            __( 'Poor', 'site-reviews' ),
208
+            __( 'Terrible', 'site-reviews' ),
209 209
         ];
210
-        $maxRating = (int) glsr()->constant('MAX_RATING', Rating::class);
211
-        $defaults = array_pad(array_slice($defaults, 0, $maxRating), $maxRating, '');
212
-        $labels = array_map('trim', explode(',', $labels));
213
-        foreach ($defaults as $i => $label) {
214
-            if (empty($labels[$i])) {
210
+        $maxRating = (int)glsr()->constant( 'MAX_RATING', Rating::class );
211
+        $defaults = array_pad( array_slice( $defaults, 0, $maxRating ), $maxRating, '' );
212
+        $labels = array_map( 'trim', explode( ',', $labels ) );
213
+        foreach( $defaults as $i => $label ) {
214
+            if( empty($labels[$i]) ) {
215 215
                 continue;
216 216
             }
217 217
             $defaults[$i] = $labels[$i];
218 218
         }
219
-        return array_combine(range($maxRating, 1), $defaults);
219
+        return array_combine( range( $maxRating, 1 ), $defaults );
220 220
     }
221 221
 
222 222
     /**
223 223
      * @param string $schema
224 224
      * @return bool
225 225
      */
226
-    protected function normalizeSchema($schema)
226
+    protected function normalizeSchema( $schema )
227 227
     {
228
-        return wp_validate_boolean($schema);
228
+        return wp_validate_boolean( $schema );
229 229
     }
230 230
 
231 231
     /**
232 232
      * @param string $text
233 233
      * @return string
234 234
      */
235
-    protected function normalizeText($text)
235
+    protected function normalizeText( $text )
236 236
     {
237
-        return trim($text);
237
+        return trim( $text );
238 238
     }
239 239
 
240 240
     /**
241 241
      * @return void
242 242
      */
243
-    protected function setId(array &$atts)
243
+    protected function setId( array &$atts )
244 244
     {
245
-        if (empty($atts['id'])) {
246
-            $atts['id'] = Application::PREFIX.substr(md5(serialize($atts)), 0, 8);
245
+        if( empty($atts['id']) ) {
246
+            $atts['id'] = Application::PREFIX.substr( md5( serialize( $atts ) ), 0, 8 );
247 247
         }
248 248
     }
249 249
 }
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/SiteReviewsSummary.php 2 patches
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -10,197 +10,197 @@
 block discarded – undo
10 10
 
11 11
 class SiteReviewsSummary
12 12
 {
13
-    /**
14
-     * @var array
15
-     */
16
-    protected $args;
17
-
18
-    /**
19
-     * @var float
20
-     */
21
-    protected $averageRating;
22
-
23
-    /**
24
-     * @var array
25
-     */
26
-    protected $ratingCounts;
27
-
28
-    /**
29
-     * @return void|string
30
-     */
31
-    public function build(array $args = [])
32
-    {
33
-        $this->args = $args;
34
-        $this->ratingCounts = glsr(ReviewManager::class)->getRatingCounts($args);
35
-        if (!array_sum($this->ratingCounts) && $this->isHidden('if_empty')) {
36
-            return;
37
-        }
38
-        $this->averageRating = glsr(Rating::class)->getAverage($this->ratingCounts);
39
-        $this->generateSchema();
40
-        return glsr(Template::class)->build('templates/reviews-summary', [
41
-            'context' => [
42
-                'assigned_to' => $this->args['assigned_to'],
43
-                'category' => $this->args['category'],
44
-                'class' => $this->getClass(),
45
-                'id' => $this->args['id'],
46
-                'percentages' => $this->buildPercentage(),
47
-                'rating' => $this->buildRating(),
48
-                'stars' => $this->buildStars(),
49
-                'text' => $this->buildText(),
50
-            ],
51
-        ]);
52
-    }
53
-
54
-    /**
55
-     * @return void|string
56
-     */
57
-    protected function buildPercentage()
58
-    {
59
-        if ($this->isHidden('bars')) {
60
-            return;
61
-        }
62
-        $percentages = preg_filter('/$/', '%', glsr(Rating::class)->getPercentages($this->ratingCounts));
63
-        $bars = array_reduce(range(glsr()->constant('MAX_RATING', Rating::class), 1), function ($carry, $level) use ($percentages) {
64
-            $label = $this->buildPercentageLabel($this->args['labels'][$level]);
65
-            $background = $this->buildPercentageBackground($percentages[$level]);
66
-            $count = apply_filters('site-reviews/summary/counts',
67
-                $percentages[$level],
68
-                $this->ratingCounts[$level]
69
-            );
70
-            $percent = $this->buildPercentageCount($count);
71
-            $value = $label.$background.$percent;
72
-            $value = apply_filters('site-reviews/summary/wrap/bar', $value, $this->args, [
73
-                'percent' => wp_strip_all_tags($count, true),
74
-                'rating' => $level,
75
-            ]);
76
-            return $carry.glsr(Builder::class)->div($value, [
77
-                'class' => 'glsr-bar',
78
-            ]);
79
-        });
80
-        return $this->wrap('percentage', $bars);
81
-    }
82
-
83
-    /**
84
-     * @param string $percent
85
-     * @return string
86
-     */
87
-    protected function buildPercentageBackground($percent)
88
-    {
89
-        $backgroundPercent = glsr(Builder::class)->span([
90
-            'class' => 'glsr-bar-background-percent',
91
-            'style' => 'width:'.$percent,
92
-        ]);
93
-        return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>';
94
-    }
95
-
96
-    /**
97
-     * @param string $count
98
-     * @return string
99
-     */
100
-    protected function buildPercentageCount($count)
101
-    {
102
-        return '<span class="glsr-bar-percent">'.$count.'</span>';
103
-    }
104
-
105
-    /**
106
-     * @param string $label
107
-     * @return string
108
-     */
109
-    protected function buildPercentageLabel($label)
110
-    {
111
-        return '<span class="glsr-bar-label">'.$label.'</span>';
112
-    }
113
-
114
-    /**
115
-     * @return void|string
116
-     */
117
-    protected function buildRating()
118
-    {
119
-        if ($this->isHidden('rating')) {
120
-            return;
121
-        }
122
-        return $this->wrap('rating', '<span>'.$this->averageRating.'</span>');
123
-    }
124
-
125
-    /**
126
-     * @return void|string
127
-     */
128
-    protected function buildStars()
129
-    {
130
-        if ($this->isHidden('stars')) {
131
-            return;
132
-        }
133
-        $stars = glsr_star_rating($this->averageRating);
134
-        return $this->wrap('stars', $stars);
135
-    }
136
-
137
-    /**
138
-     * @return void|string
139
-     */
140
-    protected function buildText()
141
-    {
142
-        if ($this->isHidden('summary')) {
143
-            return;
144
-        }
145
-        $count = intval(array_sum($this->ratingCounts));
146
-        if (empty($this->args['text'])) {
147
-            // @todo document this change
148
-            $this->args['text'] = _nx(
149
-                '{rating} out of {max} stars (based on {num} review)',
150
-                '{rating} out of {max} stars (based on {num} reviews)',
151
-                $count,
152
-                'Do not translate {rating}, {max}, and {num}, they are template tags.',
153
-                'site-reviews'
154
-            );
155
-        }
156
-        $summary = str_replace(
157
-            ['{rating}', '{max}', '{num}'],
158
-            [$this->averageRating, glsr()->constant('MAX_RATING', Rating::class), $count],
159
-            $this->args['text']
160
-        );
161
-        return $this->wrap('text', '<span>'.$summary.'</span>');
162
-    }
163
-
164
-    /**
165
-     * @return void
166
-     */
167
-    protected function generateSchema()
168
-    {
169
-        if (!wp_validate_boolean($this->args['schema'])) {
170
-            return;
171
-        }
172
-        glsr(Schema::class)->store(
173
-            glsr(Schema::class)->buildSummary($this->args)
174
-        );
175
-    }
176
-
177
-    /**
178
-     * @return string
179
-     */
180
-    protected function getClass()
181
-    {
182
-        return trim('glsr-summary glsr-default '.$this->args['class']);
183
-    }
184
-
185
-    /**
186
-     * @param string $key
187
-     * @return bool
188
-     */
189
-    protected function isHidden($key)
190
-    {
191
-        return in_array($key, $this->args['hide']);
192
-    }
193
-
194
-    /**
195
-     * @param string $key
196
-     * @param string $value
197
-     * @return string
198
-     */
199
-    protected function wrap($key, $value)
200
-    {
201
-        $value = apply_filters('site-reviews/summary/wrap/'.$key, $value, $this->args);
202
-        return glsr(Builder::class)->div($value, [
203
-            'class' => 'glsr-summary-'.$key,
204
-        ]);
205
-    }
13
+	/**
14
+	 * @var array
15
+	 */
16
+	protected $args;
17
+
18
+	/**
19
+	 * @var float
20
+	 */
21
+	protected $averageRating;
22
+
23
+	/**
24
+	 * @var array
25
+	 */
26
+	protected $ratingCounts;
27
+
28
+	/**
29
+	 * @return void|string
30
+	 */
31
+	public function build(array $args = [])
32
+	{
33
+		$this->args = $args;
34
+		$this->ratingCounts = glsr(ReviewManager::class)->getRatingCounts($args);
35
+		if (!array_sum($this->ratingCounts) && $this->isHidden('if_empty')) {
36
+			return;
37
+		}
38
+		$this->averageRating = glsr(Rating::class)->getAverage($this->ratingCounts);
39
+		$this->generateSchema();
40
+		return glsr(Template::class)->build('templates/reviews-summary', [
41
+			'context' => [
42
+				'assigned_to' => $this->args['assigned_to'],
43
+				'category' => $this->args['category'],
44
+				'class' => $this->getClass(),
45
+				'id' => $this->args['id'],
46
+				'percentages' => $this->buildPercentage(),
47
+				'rating' => $this->buildRating(),
48
+				'stars' => $this->buildStars(),
49
+				'text' => $this->buildText(),
50
+			],
51
+		]);
52
+	}
53
+
54
+	/**
55
+	 * @return void|string
56
+	 */
57
+	protected function buildPercentage()
58
+	{
59
+		if ($this->isHidden('bars')) {
60
+			return;
61
+		}
62
+		$percentages = preg_filter('/$/', '%', glsr(Rating::class)->getPercentages($this->ratingCounts));
63
+		$bars = array_reduce(range(glsr()->constant('MAX_RATING', Rating::class), 1), function ($carry, $level) use ($percentages) {
64
+			$label = $this->buildPercentageLabel($this->args['labels'][$level]);
65
+			$background = $this->buildPercentageBackground($percentages[$level]);
66
+			$count = apply_filters('site-reviews/summary/counts',
67
+				$percentages[$level],
68
+				$this->ratingCounts[$level]
69
+			);
70
+			$percent = $this->buildPercentageCount($count);
71
+			$value = $label.$background.$percent;
72
+			$value = apply_filters('site-reviews/summary/wrap/bar', $value, $this->args, [
73
+				'percent' => wp_strip_all_tags($count, true),
74
+				'rating' => $level,
75
+			]);
76
+			return $carry.glsr(Builder::class)->div($value, [
77
+				'class' => 'glsr-bar',
78
+			]);
79
+		});
80
+		return $this->wrap('percentage', $bars);
81
+	}
82
+
83
+	/**
84
+	 * @param string $percent
85
+	 * @return string
86
+	 */
87
+	protected function buildPercentageBackground($percent)
88
+	{
89
+		$backgroundPercent = glsr(Builder::class)->span([
90
+			'class' => 'glsr-bar-background-percent',
91
+			'style' => 'width:'.$percent,
92
+		]);
93
+		return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>';
94
+	}
95
+
96
+	/**
97
+	 * @param string $count
98
+	 * @return string
99
+	 */
100
+	protected function buildPercentageCount($count)
101
+	{
102
+		return '<span class="glsr-bar-percent">'.$count.'</span>';
103
+	}
104
+
105
+	/**
106
+	 * @param string $label
107
+	 * @return string
108
+	 */
109
+	protected function buildPercentageLabel($label)
110
+	{
111
+		return '<span class="glsr-bar-label">'.$label.'</span>';
112
+	}
113
+
114
+	/**
115
+	 * @return void|string
116
+	 */
117
+	protected function buildRating()
118
+	{
119
+		if ($this->isHidden('rating')) {
120
+			return;
121
+		}
122
+		return $this->wrap('rating', '<span>'.$this->averageRating.'</span>');
123
+	}
124
+
125
+	/**
126
+	 * @return void|string
127
+	 */
128
+	protected function buildStars()
129
+	{
130
+		if ($this->isHidden('stars')) {
131
+			return;
132
+		}
133
+		$stars = glsr_star_rating($this->averageRating);
134
+		return $this->wrap('stars', $stars);
135
+	}
136
+
137
+	/**
138
+	 * @return void|string
139
+	 */
140
+	protected function buildText()
141
+	{
142
+		if ($this->isHidden('summary')) {
143
+			return;
144
+		}
145
+		$count = intval(array_sum($this->ratingCounts));
146
+		if (empty($this->args['text'])) {
147
+			// @todo document this change
148
+			$this->args['text'] = _nx(
149
+				'{rating} out of {max} stars (based on {num} review)',
150
+				'{rating} out of {max} stars (based on {num} reviews)',
151
+				$count,
152
+				'Do not translate {rating}, {max}, and {num}, they are template tags.',
153
+				'site-reviews'
154
+			);
155
+		}
156
+		$summary = str_replace(
157
+			['{rating}', '{max}', '{num}'],
158
+			[$this->averageRating, glsr()->constant('MAX_RATING', Rating::class), $count],
159
+			$this->args['text']
160
+		);
161
+		return $this->wrap('text', '<span>'.$summary.'</span>');
162
+	}
163
+
164
+	/**
165
+	 * @return void
166
+	 */
167
+	protected function generateSchema()
168
+	{
169
+		if (!wp_validate_boolean($this->args['schema'])) {
170
+			return;
171
+		}
172
+		glsr(Schema::class)->store(
173
+			glsr(Schema::class)->buildSummary($this->args)
174
+		);
175
+	}
176
+
177
+	/**
178
+	 * @return string
179
+	 */
180
+	protected function getClass()
181
+	{
182
+		return trim('glsr-summary glsr-default '.$this->args['class']);
183
+	}
184
+
185
+	/**
186
+	 * @param string $key
187
+	 * @return bool
188
+	 */
189
+	protected function isHidden($key)
190
+	{
191
+		return in_array($key, $this->args['hide']);
192
+	}
193
+
194
+	/**
195
+	 * @param string $key
196
+	 * @param string $value
197
+	 * @return string
198
+	 */
199
+	protected function wrap($key, $value)
200
+	{
201
+		$value = apply_filters('site-reviews/summary/wrap/'.$key, $value, $this->args);
202
+		return glsr(Builder::class)->div($value, [
203
+			'class' => 'glsr-summary-'.$key,
204
+		]);
205
+	}
206 206
 }
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -28,16 +28,16 @@  discard block
 block discarded – undo
28 28
     /**
29 29
      * @return void|string
30 30
      */
31
-    public function build(array $args = [])
31
+    public function build( array $args = [] )
32 32
     {
33 33
         $this->args = $args;
34
-        $this->ratingCounts = glsr(ReviewManager::class)->getRatingCounts($args);
35
-        if (!array_sum($this->ratingCounts) && $this->isHidden('if_empty')) {
34
+        $this->ratingCounts = glsr( ReviewManager::class )->getRatingCounts( $args );
35
+        if( !array_sum( $this->ratingCounts ) && $this->isHidden( 'if_empty' ) ) {
36 36
             return;
37 37
         }
38
-        $this->averageRating = glsr(Rating::class)->getAverage($this->ratingCounts);
38
+        $this->averageRating = glsr( Rating::class )->getAverage( $this->ratingCounts );
39 39
         $this->generateSchema();
40
-        return glsr(Template::class)->build('templates/reviews-summary', [
40
+        return glsr( Template::class )->build( 'templates/reviews-summary', [
41 41
             'context' => [
42 42
                 'assigned_to' => $this->args['assigned_to'],
43 43
                 'category' => $this->args['category'],
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
                 'stars' => $this->buildStars(),
49 49
                 'text' => $this->buildText(),
50 50
             ],
51
-        ]);
51
+        ] );
52 52
     }
53 53
 
54 54
     /**
@@ -56,40 +56,40 @@  discard block
 block discarded – undo
56 56
      */
57 57
     protected function buildPercentage()
58 58
     {
59
-        if ($this->isHidden('bars')) {
59
+        if( $this->isHidden( 'bars' ) ) {
60 60
             return;
61 61
         }
62
-        $percentages = preg_filter('/$/', '%', glsr(Rating::class)->getPercentages($this->ratingCounts));
63
-        $bars = array_reduce(range(glsr()->constant('MAX_RATING', Rating::class), 1), function ($carry, $level) use ($percentages) {
64
-            $label = $this->buildPercentageLabel($this->args['labels'][$level]);
65
-            $background = $this->buildPercentageBackground($percentages[$level]);
66
-            $count = apply_filters('site-reviews/summary/counts',
62
+        $percentages = preg_filter( '/$/', '%', glsr( Rating::class )->getPercentages( $this->ratingCounts ) );
63
+        $bars = array_reduce( range( glsr()->constant( 'MAX_RATING', Rating::class ), 1 ), function( $carry, $level ) use ($percentages) {
64
+            $label = $this->buildPercentageLabel( $this->args['labels'][$level] );
65
+            $background = $this->buildPercentageBackground( $percentages[$level] );
66
+            $count = apply_filters( 'site-reviews/summary/counts',
67 67
                 $percentages[$level],
68 68
                 $this->ratingCounts[$level]
69 69
             );
70
-            $percent = $this->buildPercentageCount($count);
70
+            $percent = $this->buildPercentageCount( $count );
71 71
             $value = $label.$background.$percent;
72
-            $value = apply_filters('site-reviews/summary/wrap/bar', $value, $this->args, [
73
-                'percent' => wp_strip_all_tags($count, true),
72
+            $value = apply_filters( 'site-reviews/summary/wrap/bar', $value, $this->args, [
73
+                'percent' => wp_strip_all_tags( $count, true ),
74 74
                 'rating' => $level,
75
-            ]);
76
-            return $carry.glsr(Builder::class)->div($value, [
75
+            ] );
76
+            return $carry.glsr( Builder::class )->div( $value, [
77 77
                 'class' => 'glsr-bar',
78
-            ]);
78
+            ] );
79 79
         });
80
-        return $this->wrap('percentage', $bars);
80
+        return $this->wrap( 'percentage', $bars );
81 81
     }
82 82
 
83 83
     /**
84 84
      * @param string $percent
85 85
      * @return string
86 86
      */
87
-    protected function buildPercentageBackground($percent)
87
+    protected function buildPercentageBackground( $percent )
88 88
     {
89
-        $backgroundPercent = glsr(Builder::class)->span([
89
+        $backgroundPercent = glsr( Builder::class )->span( [
90 90
             'class' => 'glsr-bar-background-percent',
91 91
             'style' => 'width:'.$percent,
92
-        ]);
92
+        ] );
93 93
         return '<span class="glsr-bar-background">'.$backgroundPercent.'</span>';
94 94
     }
95 95
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      * @param string $count
98 98
      * @return string
99 99
      */
100
-    protected function buildPercentageCount($count)
100
+    protected function buildPercentageCount( $count )
101 101
     {
102 102
         return '<span class="glsr-bar-percent">'.$count.'</span>';
103 103
     }
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      * @param string $label
107 107
      * @return string
108 108
      */
109
-    protected function buildPercentageLabel($label)
109
+    protected function buildPercentageLabel( $label )
110 110
     {
111 111
         return '<span class="glsr-bar-label">'.$label.'</span>';
112 112
     }
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
      */
117 117
     protected function buildRating()
118 118
     {
119
-        if ($this->isHidden('rating')) {
119
+        if( $this->isHidden( 'rating' ) ) {
120 120
             return;
121 121
         }
122
-        return $this->wrap('rating', '<span>'.$this->averageRating.'</span>');
122
+        return $this->wrap( 'rating', '<span>'.$this->averageRating.'</span>' );
123 123
     }
124 124
 
125 125
     /**
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
      */
128 128
     protected function buildStars()
129 129
     {
130
-        if ($this->isHidden('stars')) {
130
+        if( $this->isHidden( 'stars' ) ) {
131 131
             return;
132 132
         }
133
-        $stars = glsr_star_rating($this->averageRating);
134
-        return $this->wrap('stars', $stars);
133
+        $stars = glsr_star_rating( $this->averageRating );
134
+        return $this->wrap( 'stars', $stars );
135 135
     }
136 136
 
137 137
     /**
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
      */
140 140
     protected function buildText()
141 141
     {
142
-        if ($this->isHidden('summary')) {
142
+        if( $this->isHidden( 'summary' ) ) {
143 143
             return;
144 144
         }
145
-        $count = intval(array_sum($this->ratingCounts));
146
-        if (empty($this->args['text'])) {
145
+        $count = intval( array_sum( $this->ratingCounts ) );
146
+        if( empty($this->args['text']) ) {
147 147
             // @todo document this change
148 148
             $this->args['text'] = _nx(
149 149
                 '{rating} out of {max} stars (based on {num} review)',
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
         }
156 156
         $summary = str_replace(
157 157
             ['{rating}', '{max}', '{num}'],
158
-            [$this->averageRating, glsr()->constant('MAX_RATING', Rating::class), $count],
158
+            [$this->averageRating, glsr()->constant( 'MAX_RATING', Rating::class ), $count],
159 159
             $this->args['text']
160 160
         );
161
-        return $this->wrap('text', '<span>'.$summary.'</span>');
161
+        return $this->wrap( 'text', '<span>'.$summary.'</span>' );
162 162
     }
163 163
 
164 164
     /**
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
      */
167 167
     protected function generateSchema()
168 168
     {
169
-        if (!wp_validate_boolean($this->args['schema'])) {
169
+        if( !wp_validate_boolean( $this->args['schema'] ) ) {
170 170
             return;
171 171
         }
172
-        glsr(Schema::class)->store(
173
-            glsr(Schema::class)->buildSummary($this->args)
172
+        glsr( Schema::class )->store(
173
+            glsr( Schema::class )->buildSummary( $this->args )
174 174
         );
175 175
     }
176 176
 
@@ -179,16 +179,16 @@  discard block
 block discarded – undo
179 179
      */
180 180
     protected function getClass()
181 181
     {
182
-        return trim('glsr-summary glsr-default '.$this->args['class']);
182
+        return trim( 'glsr-summary glsr-default '.$this->args['class'] );
183 183
     }
184 184
 
185 185
     /**
186 186
      * @param string $key
187 187
      * @return bool
188 188
      */
189
-    protected function isHidden($key)
189
+    protected function isHidden( $key )
190 190
     {
191
-        return in_array($key, $this->args['hide']);
191
+        return in_array( $key, $this->args['hide'] );
192 192
     }
193 193
 
194 194
     /**
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
      * @param string $value
197 197
      * @return string
198 198
      */
199
-    protected function wrap($key, $value)
199
+    protected function wrap( $key, $value )
200 200
     {
201
-        $value = apply_filters('site-reviews/summary/wrap/'.$key, $value, $this->args);
202
-        return glsr(Builder::class)->div($value, [
201
+        $value = apply_filters( 'site-reviews/summary/wrap/'.$key, $value, $this->args );
202
+        return glsr( Builder::class )->div( $value, [
203 203
             'class' => 'glsr-summary-'.$key,
204
-        ]);
204
+        ] );
205 205
     }
206 206
 }
Please login to merge, or discard this patch.