Test Failed
Push — tmp ( 15f615...89cc97 )
by Paul
10:31 queued 04:40
created
plugin/Commands/EnqueueAdminAssets.php 1 patch
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -12,170 +12,170 @@
 block discarded – undo
12 12
 
13 13
 class EnqueueAdminAssets implements Contract
14 14
 {
15
-    public $pointers;
15
+	public $pointers;
16 16
 
17
-    public function __construct()
18
-    {
19
-        $this->pointers = $this->generatePointers([[
20
-            'content' => _x('You can pin exceptional reviews so that they are always shown first.', 'admin-text', 'site-reviews'),
21
-            'id' => 'glsr-pointer-pinned',
22
-            'position' => [
23
-                'edge' => 'right',
24
-                'align' => 'middle',
25
-            ],
26
-            'screen' => Application::POST_TYPE,
27
-            'target' => '#misc-pub-pinned',
28
-            'title' => _x('Pin Your Reviews', 'admin-text', 'site-reviews'),
29
-        ]]);
30
-    }
17
+	public function __construct()
18
+	{
19
+		$this->pointers = $this->generatePointers([[
20
+			'content' => _x('You can pin exceptional reviews so that they are always shown first.', 'admin-text', 'site-reviews'),
21
+			'id' => 'glsr-pointer-pinned',
22
+			'position' => [
23
+				'edge' => 'right',
24
+				'align' => 'middle',
25
+			],
26
+			'screen' => Application::POST_TYPE,
27
+			'target' => '#misc-pub-pinned',
28
+			'title' => _x('Pin Your Reviews', 'admin-text', 'site-reviews'),
29
+		]]);
30
+	}
31 31
 
32
-    /**
33
-     * @return void
34
-     */
35
-    public function handle()
36
-    {
37
-        $this->enqueueAssets();
38
-        $this->localizeAssets();
39
-    }
32
+	/**
33
+	 * @return void
34
+	 */
35
+	public function handle()
36
+	{
37
+		$this->enqueueAssets();
38
+		$this->localizeAssets();
39
+	}
40 40
 
41
-    /**
42
-     * @return void
43
-     */
44
-    public function enqueueAssets()
45
-    {
46
-        if (!$this->isCurrentScreen()) {
47
-            return;
48
-        }
49
-        wp_enqueue_style(
50
-            Application::ID.'/admin',
51
-            glsr()->url('assets/styles/'.Application::ID.'-admin.css'),
52
-            [],
53
-            glsr()->version
54
-        );
55
-        wp_enqueue_script(
56
-            Application::ID.'/admin',
57
-            glsr()->url('assets/scripts/'.Application::ID.'-admin.js'),
58
-            $this->getDependencies(),
59
-            glsr()->version,
60
-            true
61
-        );
62
-        if (!empty($this->pointers)) {
63
-            wp_enqueue_style('wp-pointer');
64
-            wp_enqueue_script('wp-pointer');
65
-        }
66
-    }
41
+	/**
42
+	 * @return void
43
+	 */
44
+	public function enqueueAssets()
45
+	{
46
+		if (!$this->isCurrentScreen()) {
47
+			return;
48
+		}
49
+		wp_enqueue_style(
50
+			Application::ID.'/admin',
51
+			glsr()->url('assets/styles/'.Application::ID.'-admin.css'),
52
+			[],
53
+			glsr()->version
54
+		);
55
+		wp_enqueue_script(
56
+			Application::ID.'/admin',
57
+			glsr()->url('assets/scripts/'.Application::ID.'-admin.js'),
58
+			$this->getDependencies(),
59
+			glsr()->version,
60
+			true
61
+		);
62
+		if (!empty($this->pointers)) {
63
+			wp_enqueue_style('wp-pointer');
64
+			wp_enqueue_script('wp-pointer');
65
+		}
66
+	}
67 67
 
68
-    /**
69
-     * @return void
70
-     */
71
-    public function localizeAssets()
72
-    {
73
-        $variables = [
74
-            'action' => Application::PREFIX.'action',
75
-            'addons' => [],
76
-            'ajaxurl' => admin_url('admin-ajax.php'),
77
-            'hideoptions' => [
78
-                'site_reviews' => glsr(SiteReviewsShortcode::class)->getHideOptions(),
79
-                'site_reviews_form' => glsr(SiteReviewsFormShortcode::class)->getHideOptions(),
80
-                'site_reviews_summary' => glsr(SiteReviewsSummaryShortcode::class)->getHideOptions(),
81
-            ],
82
-            'maxrating' => glsr()->constant('MAX_RATING', Rating::class),
83
-            'minrating' => glsr()->constant('MIN_RATING', Rating::class),
84
-            'nameprefix' => Application::ID,
85
-            'nonce' => [
86
-                'clear-console' => wp_create_nonce('clear-console'),
87
-                'fetch-console' => wp_create_nonce('fetch-console'),
88
-                'mce-shortcode' => wp_create_nonce('mce-shortcode'),
89
-                'sync-reviews' => wp_create_nonce('sync-reviews'),
90
-                'toggle-pinned' => wp_create_nonce('toggle-pinned'),
91
-                'toggle-status' => wp_create_nonce('toggle-status'),
92
-            ],
93
-            'pointers' => $this->pointers,
94
-            'shortcodes' => [],
95
-            'tinymce' => [
96
-                'glsr_shortcode' => glsr()->url('assets/scripts/mce-plugin.js'),
97
-            ],
98
-        ];
99
-        if (user_can_richedit()) {
100
-            $variables['shortcodes'] = $this->localizeShortcodes();
101
-        }
102
-        $variables = glsr()->filterArray('enqueue/admin/localize', $variables);
103
-        wp_localize_script(Application::ID.'/admin', 'GLSR', $variables);
104
-    }
68
+	/**
69
+	 * @return void
70
+	 */
71
+	public function localizeAssets()
72
+	{
73
+		$variables = [
74
+			'action' => Application::PREFIX.'action',
75
+			'addons' => [],
76
+			'ajaxurl' => admin_url('admin-ajax.php'),
77
+			'hideoptions' => [
78
+				'site_reviews' => glsr(SiteReviewsShortcode::class)->getHideOptions(),
79
+				'site_reviews_form' => glsr(SiteReviewsFormShortcode::class)->getHideOptions(),
80
+				'site_reviews_summary' => glsr(SiteReviewsSummaryShortcode::class)->getHideOptions(),
81
+			],
82
+			'maxrating' => glsr()->constant('MAX_RATING', Rating::class),
83
+			'minrating' => glsr()->constant('MIN_RATING', Rating::class),
84
+			'nameprefix' => Application::ID,
85
+			'nonce' => [
86
+				'clear-console' => wp_create_nonce('clear-console'),
87
+				'fetch-console' => wp_create_nonce('fetch-console'),
88
+				'mce-shortcode' => wp_create_nonce('mce-shortcode'),
89
+				'sync-reviews' => wp_create_nonce('sync-reviews'),
90
+				'toggle-pinned' => wp_create_nonce('toggle-pinned'),
91
+				'toggle-status' => wp_create_nonce('toggle-status'),
92
+			],
93
+			'pointers' => $this->pointers,
94
+			'shortcodes' => [],
95
+			'tinymce' => [
96
+				'glsr_shortcode' => glsr()->url('assets/scripts/mce-plugin.js'),
97
+			],
98
+		];
99
+		if (user_can_richedit()) {
100
+			$variables['shortcodes'] = $this->localizeShortcodes();
101
+		}
102
+		$variables = glsr()->filterArray('enqueue/admin/localize', $variables);
103
+		wp_localize_script(Application::ID.'/admin', 'GLSR', $variables);
104
+	}
105 105
 
106
-    /**
107
-     * @return array
108
-     */
109
-    protected function getDependencies()
110
-    {
111
-        $dependencies = glsr()->filterArray('enqueue/admin/dependencies', []);
112
-        $dependencies = array_merge($dependencies, [
113
-            'jquery', 'jquery-ui-sortable', 'underscore', 'wp-util',
114
-        ]);
115
-        return $dependencies;
116
-    }
106
+	/**
107
+	 * @return array
108
+	 */
109
+	protected function getDependencies()
110
+	{
111
+		$dependencies = glsr()->filterArray('enqueue/admin/dependencies', []);
112
+		$dependencies = array_merge($dependencies, [
113
+			'jquery', 'jquery-ui-sortable', 'underscore', 'wp-util',
114
+		]);
115
+		return $dependencies;
116
+	}
117 117
 
118
-    /**
119
-     * @return array
120
-     */
121
-    protected function generatePointer(array $pointer)
122
-    {
123
-        return [
124
-            'id' => $pointer['id'],
125
-            'options' => [
126
-                'content' => '<h3>'.$pointer['title'].'</h3><p>'.$pointer['content'].'</p>',
127
-                'position' => $pointer['position'],
128
-            ],
129
-            'screen' => $pointer['screen'],
130
-            'target' => $pointer['target'],
131
-        ];
132
-    }
118
+	/**
119
+	 * @return array
120
+	 */
121
+	protected function generatePointer(array $pointer)
122
+	{
123
+		return [
124
+			'id' => $pointer['id'],
125
+			'options' => [
126
+				'content' => '<h3>'.$pointer['title'].'</h3><p>'.$pointer['content'].'</p>',
127
+				'position' => $pointer['position'],
128
+			],
129
+			'screen' => $pointer['screen'],
130
+			'target' => $pointer['target'],
131
+		];
132
+	}
133 133
 
134
-    /**
135
-     * @return array
136
-     */
137
-    protected function generatePointers(array $pointers)
138
-    {
139
-        $dismissedPointers = get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true);
140
-        $dismissedPointers = explode(',', (string) $dismissedPointers);
141
-        $generatedPointers = [];
142
-        foreach ($pointers as $pointer) {
143
-            if ($pointer['screen'] != glsr_current_screen()->id) {
144
-                continue;
145
-            }
146
-            if (in_array($pointer['id'], $dismissedPointers)) {
147
-                continue;
148
-            }
149
-            $generatedPointers[] = $this->generatePointer($pointer);
150
-        }
151
-        return $generatedPointers;
152
-    }
134
+	/**
135
+	 * @return array
136
+	 */
137
+	protected function generatePointers(array $pointers)
138
+	{
139
+		$dismissedPointers = get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true);
140
+		$dismissedPointers = explode(',', (string) $dismissedPointers);
141
+		$generatedPointers = [];
142
+		foreach ($pointers as $pointer) {
143
+			if ($pointer['screen'] != glsr_current_screen()->id) {
144
+				continue;
145
+			}
146
+			if (in_array($pointer['id'], $dismissedPointers)) {
147
+				continue;
148
+			}
149
+			$generatedPointers[] = $this->generatePointer($pointer);
150
+		}
151
+		return $generatedPointers;
152
+	}
153 153
 
154
-    /**
155
-     * @return bool
156
-     */
157
-    protected function isCurrentScreen()
158
-    {
159
-        $screen = glsr_current_screen();
160
-        return Application::POST_TYPE == $screen->post_type
161
-            || 'dashboard' == $screen->id
162
-            || 'plugins_page_'.Application::ID == $screen->id
163
-            || 'post' == $screen->base
164
-            || 'widgets' == $screen->id;
165
-    }
154
+	/**
155
+	 * @return bool
156
+	 */
157
+	protected function isCurrentScreen()
158
+	{
159
+		$screen = glsr_current_screen();
160
+		return Application::POST_TYPE == $screen->post_type
161
+			|| 'dashboard' == $screen->id
162
+			|| 'plugins_page_'.Application::ID == $screen->id
163
+			|| 'post' == $screen->base
164
+			|| 'widgets' == $screen->id;
165
+	}
166 166
 
167
-    /**
168
-     * @return array
169
-     */
170
-    protected function localizeShortcodes()
171
-    {
172
-        $variables = [];
173
-        foreach (glsr()->retrieve('mce', []) as $tag => $args) {
174
-            if (empty($args['required'])) {
175
-                continue;
176
-            }
177
-            $variables[$tag] = $args['required'];
178
-        }
179
-        return $variables;
180
-    }
167
+	/**
168
+	 * @return array
169
+	 */
170
+	protected function localizeShortcodes()
171
+	{
172
+		$variables = [];
173
+		foreach (glsr()->retrieve('mce', []) as $tag => $args) {
174
+			if (empty($args['required'])) {
175
+				continue;
176
+			}
177
+			$variables[$tag] = $args['required'];
178
+		}
179
+		return $variables;
180
+	}
181 181
 }
Please login to merge, or discard this patch.
plugin/Commands/CreateReview.php 1 patch
Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -10,216 +10,216 @@
 block discarded – undo
10 10
 
11 11
 class CreateReview implements Contract
12 12
 {
13
-    public $ajax_request;
14
-    public $assigned_post_ids;
15
-    public $assigned_term_ids;
16
-    public $assigned_user_ids;
17
-    public $author;
18
-    public $avatar;
19
-    public $blacklisted;
20
-    public $content;
21
-    public $custom;
22
-    public $date;
23
-    public $email;
24
-    public $form_id;
25
-    public $ip_address;
26
-    public $post_id;
27
-    public $rating;
28
-    public $referer;
29
-    public $request;
30
-    public $response;
31
-    public $terms;
32
-    public $title;
33
-    public $url;
34
-
35
-    public function __construct($input)
36
-    {
37
-        $this->request = $input;
38
-        $this->ajax_request = isset($input['_ajax_request']);
39
-        $this->assigned_post_ids = $this->getAssignedPosts();
40
-        $this->assigned_term_ids = $this->getAssignedTerms();
41
-        $this->assigned_user_ids = $this->getAssignedUsers();
42
-        $this->author = sanitize_text_field($this->getUser('name'));
43
-        $this->avatar = $this->getAvatar();
44
-        $this->blacklisted = isset($input['blacklisted']);
45
-        $this->content = sanitize_textarea_field($this->get('content'));
46
-        $this->custom = $this->getCustom();
47
-        $this->date = $this->getDate('date');
48
-        $this->email = sanitize_email($this->getUser('email'));
49
-        $this->form_id = sanitize_key($this->get('form_id'));
50
-        $this->ip_address = $this->get('ip_address');
51
-        $this->post_id = absint($this->get('_post_id'));
52
-        $this->rating = absint($this->get('rating'));
53
-        $this->referer = sanitize_text_field($this->get('_referer'));
54
-        $this->response = sanitize_textarea_field($this->get('response'));
55
-        $this->terms = !empty($input['terms']);
56
-        $this->title = sanitize_text_field($this->get('title'));
57
-        $this->url = esc_url_raw(sanitize_text_field($this->get('url')));
58
-    }
59
-
60
-    /**
61
-     * @return \GeminiLabs\SiteReviews\Review|void
62
-     */
63
-    public function handle()
64
-    {
65
-        if (!$this->validate()) {
66
-            return;
67
-        }
68
-        if ($review = glsr(ReviewManager::class)->create($this)) {
69
-            glsr()->sessionSet($this->form_id.'message', __('Your review has been submitted!', 'site-reviews'));
70
-            glsr(Notification::class)->send($review);
71
-            return $review;
72
-        }
73
-        glsr()->sessionSet($this->form_id.'errors', []);
74
-        glsr()->sessionSet($this->form_id.'message', __('Your review could not be submitted and the error has been logged. Please notify the site admin.', 'site-reviews'));
75
-    }
76
-
77
-    /**
78
-     * @return string
79
-     */
80
-    public function redirect($fallback = '')
81
-    {
82
-        $redirect = trim(strval(get_post_meta($this->post_id, 'redirect_to', true)));
83
-        $redirect = glsr()->filterString('review/redirect', $redirect, $this);
84
-        if (empty($redirect)) {
85
-            $redirect = $fallback;
86
-        }
87
-        return sanitize_text_field($redirect);
88
-    }
89
-
90
-    /**
91
-     * @return string
92
-     */
93
-    public function referer()
94
-    {
95
-        if ($referer = $this->redirect($this->referer)) {
96
-            return $referer;
97
-        }
98
-        glsr_log()->warning('The form referer ($_SERVER[REQUEST_URI]) was empty.')->debug($this);
99
-        return home_url();
100
-    }
101
-
102
-    /**
103
-     * @return bool
104
-     */
105
-    public function validate()
106
-    {
107
-        $validated = glsr(ValidateReview::class)->validate($this->request);
108
-        return empty($validated->error) && !$validated->recaptchaIsUnset;
109
-    }
110
-
111
-    /**
112
-     * @param string $key
113
-     * @return string
114
-     */
115
-    protected function get($key)
116
-    {
117
-        return (string) Arr::get($this->request, $key);
118
-    }
119
-
120
-    /**
121
-     * @return array
122
-     */
123
-    protected function getAssignedPosts()
124
-    {
125
-        $postIds = Arr::convertFromString($this->get('assign_to'));
126
-        return array_map('sanitize_key', $postIds);
127
-    }
128
-
129
-    /**
130
-     * @return array
131
-     */
132
-    protected function getAssignedTerms()
133
-    {
134
-        $termIds = Arr::convertFromString($this->get('category'));
135
-        return array_map('sanitize_key', $termIds);
136
-    }
137
-
138
-    /**
139
-     * @return array
140
-     */
141
-    protected function getAssignedUsers()
142
-    {
143
-        $userIds = Arr::convertFromString($this->get('user'));
144
-        return array_map('sanitize_key', $userIds);
145
-    }
146
-
147
-    /**
148
-     * @return string
149
-     */
150
-    protected function getAvatar()
151
-    {
152
-        $avatar = $this->get('avatar');
153
-        return !filter_var($avatar, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)
154
-            ? (string) get_avatar_url($this->get('email'))
155
-            : $avatar;
156
-    }
157
-
158
-    /**
159
-     * @return array
160
-     */
161
-    protected function getCustom()
162
-    {
163
-        $unset = [
164
-            '_action', '_ajax_request', '_counter', '_nonce', '_post_id', '_recaptcha-token',
165
-            '_referer', 'assign_to', 'category', 'content', 'date', 'email', 'excluded', 'form_id',
166
-            'gotcha', 'ip_address', 'name', 'rating', 'response', 'terms', 'title', 'url', 'user',
167
-        ];
168
-        $unset = glsr()->filterArray('create/unset-keys-from-custom', $unset);
169
-        $custom = $this->request;
170
-        foreach ($unset as $key) {
171
-            unset($custom[$key]);
172
-        }
173
-        foreach ($custom as $key => $value) {
174
-            if (is_string($value)) {
175
-                $custom[$key] = sanitize_text_field($value);
176
-            }
177
-        }
178
-        return $custom;
179
-    }
180
-
181
-    /**
182
-     * @param string $key
183
-     * @return string
184
-     */
185
-    protected function getDate($key)
186
-    {
187
-        $date = strtotime($this->get($key));
188
-        if (false === $date) {
189
-            $date = time();
190
-        }
191
-        return get_date_from_gmt(gmdate('Y-m-d H:i:s', $date));
192
-    }
193
-
194
-    /**
195
-     * @param string $key
196
-     * @return string
197
-     */
198
-    protected function getNumeric($key)
199
-    {
200
-        $value = $this->get($key);
201
-        return is_numeric($value)
202
-            ? $value
203
-            : '';
204
-    }
205
-
206
-    /**
207
-     * @param string $key
208
-     * @return string
209
-     */
210
-    protected function getUser($key)
211
-    {
212
-        $value = $this->get($key);
213
-        if (empty($value)) {
214
-            $user = wp_get_current_user();
215
-            $userValues = [
216
-                'email' => 'user_email',
217
-                'name' => 'display_name',
218
-            ];
219
-            if ($user->exists() && array_key_exists($key, $userValues)) {
220
-                return $user->{$userValues[$key]};
221
-            }
222
-        }
223
-        return $value;
224
-    }
13
+	public $ajax_request;
14
+	public $assigned_post_ids;
15
+	public $assigned_term_ids;
16
+	public $assigned_user_ids;
17
+	public $author;
18
+	public $avatar;
19
+	public $blacklisted;
20
+	public $content;
21
+	public $custom;
22
+	public $date;
23
+	public $email;
24
+	public $form_id;
25
+	public $ip_address;
26
+	public $post_id;
27
+	public $rating;
28
+	public $referer;
29
+	public $request;
30
+	public $response;
31
+	public $terms;
32
+	public $title;
33
+	public $url;
34
+
35
+	public function __construct($input)
36
+	{
37
+		$this->request = $input;
38
+		$this->ajax_request = isset($input['_ajax_request']);
39
+		$this->assigned_post_ids = $this->getAssignedPosts();
40
+		$this->assigned_term_ids = $this->getAssignedTerms();
41
+		$this->assigned_user_ids = $this->getAssignedUsers();
42
+		$this->author = sanitize_text_field($this->getUser('name'));
43
+		$this->avatar = $this->getAvatar();
44
+		$this->blacklisted = isset($input['blacklisted']);
45
+		$this->content = sanitize_textarea_field($this->get('content'));
46
+		$this->custom = $this->getCustom();
47
+		$this->date = $this->getDate('date');
48
+		$this->email = sanitize_email($this->getUser('email'));
49
+		$this->form_id = sanitize_key($this->get('form_id'));
50
+		$this->ip_address = $this->get('ip_address');
51
+		$this->post_id = absint($this->get('_post_id'));
52
+		$this->rating = absint($this->get('rating'));
53
+		$this->referer = sanitize_text_field($this->get('_referer'));
54
+		$this->response = sanitize_textarea_field($this->get('response'));
55
+		$this->terms = !empty($input['terms']);
56
+		$this->title = sanitize_text_field($this->get('title'));
57
+		$this->url = esc_url_raw(sanitize_text_field($this->get('url')));
58
+	}
59
+
60
+	/**
61
+	 * @return \GeminiLabs\SiteReviews\Review|void
62
+	 */
63
+	public function handle()
64
+	{
65
+		if (!$this->validate()) {
66
+			return;
67
+		}
68
+		if ($review = glsr(ReviewManager::class)->create($this)) {
69
+			glsr()->sessionSet($this->form_id.'message', __('Your review has been submitted!', 'site-reviews'));
70
+			glsr(Notification::class)->send($review);
71
+			return $review;
72
+		}
73
+		glsr()->sessionSet($this->form_id.'errors', []);
74
+		glsr()->sessionSet($this->form_id.'message', __('Your review could not be submitted and the error has been logged. Please notify the site admin.', 'site-reviews'));
75
+	}
76
+
77
+	/**
78
+	 * @return string
79
+	 */
80
+	public function redirect($fallback = '')
81
+	{
82
+		$redirect = trim(strval(get_post_meta($this->post_id, 'redirect_to', true)));
83
+		$redirect = glsr()->filterString('review/redirect', $redirect, $this);
84
+		if (empty($redirect)) {
85
+			$redirect = $fallback;
86
+		}
87
+		return sanitize_text_field($redirect);
88
+	}
89
+
90
+	/**
91
+	 * @return string
92
+	 */
93
+	public function referer()
94
+	{
95
+		if ($referer = $this->redirect($this->referer)) {
96
+			return $referer;
97
+		}
98
+		glsr_log()->warning('The form referer ($_SERVER[REQUEST_URI]) was empty.')->debug($this);
99
+		return home_url();
100
+	}
101
+
102
+	/**
103
+	 * @return bool
104
+	 */
105
+	public function validate()
106
+	{
107
+		$validated = glsr(ValidateReview::class)->validate($this->request);
108
+		return empty($validated->error) && !$validated->recaptchaIsUnset;
109
+	}
110
+
111
+	/**
112
+	 * @param string $key
113
+	 * @return string
114
+	 */
115
+	protected function get($key)
116
+	{
117
+		return (string) Arr::get($this->request, $key);
118
+	}
119
+
120
+	/**
121
+	 * @return array
122
+	 */
123
+	protected function getAssignedPosts()
124
+	{
125
+		$postIds = Arr::convertFromString($this->get('assign_to'));
126
+		return array_map('sanitize_key', $postIds);
127
+	}
128
+
129
+	/**
130
+	 * @return array
131
+	 */
132
+	protected function getAssignedTerms()
133
+	{
134
+		$termIds = Arr::convertFromString($this->get('category'));
135
+		return array_map('sanitize_key', $termIds);
136
+	}
137
+
138
+	/**
139
+	 * @return array
140
+	 */
141
+	protected function getAssignedUsers()
142
+	{
143
+		$userIds = Arr::convertFromString($this->get('user'));
144
+		return array_map('sanitize_key', $userIds);
145
+	}
146
+
147
+	/**
148
+	 * @return string
149
+	 */
150
+	protected function getAvatar()
151
+	{
152
+		$avatar = $this->get('avatar');
153
+		return !filter_var($avatar, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)
154
+			? (string) get_avatar_url($this->get('email'))
155
+			: $avatar;
156
+	}
157
+
158
+	/**
159
+	 * @return array
160
+	 */
161
+	protected function getCustom()
162
+	{
163
+		$unset = [
164
+			'_action', '_ajax_request', '_counter', '_nonce', '_post_id', '_recaptcha-token',
165
+			'_referer', 'assign_to', 'category', 'content', 'date', 'email', 'excluded', 'form_id',
166
+			'gotcha', 'ip_address', 'name', 'rating', 'response', 'terms', 'title', 'url', 'user',
167
+		];
168
+		$unset = glsr()->filterArray('create/unset-keys-from-custom', $unset);
169
+		$custom = $this->request;
170
+		foreach ($unset as $key) {
171
+			unset($custom[$key]);
172
+		}
173
+		foreach ($custom as $key => $value) {
174
+			if (is_string($value)) {
175
+				$custom[$key] = sanitize_text_field($value);
176
+			}
177
+		}
178
+		return $custom;
179
+	}
180
+
181
+	/**
182
+	 * @param string $key
183
+	 * @return string
184
+	 */
185
+	protected function getDate($key)
186
+	{
187
+		$date = strtotime($this->get($key));
188
+		if (false === $date) {
189
+			$date = time();
190
+		}
191
+		return get_date_from_gmt(gmdate('Y-m-d H:i:s', $date));
192
+	}
193
+
194
+	/**
195
+	 * @param string $key
196
+	 * @return string
197
+	 */
198
+	protected function getNumeric($key)
199
+	{
200
+		$value = $this->get($key);
201
+		return is_numeric($value)
202
+			? $value
203
+			: '';
204
+	}
205
+
206
+	/**
207
+	 * @param string $key
208
+	 * @return string
209
+	 */
210
+	protected function getUser($key)
211
+	{
212
+		$value = $this->get($key);
213
+		if (empty($value)) {
214
+			$user = wp_get_current_user();
215
+			$userValues = [
216
+				'email' => 'user_email',
217
+				'name' => 'display_name',
218
+			];
219
+			if ($user->exists() && array_key_exists($key, $userValues)) {
220
+				return $user->{$userValues[$key]};
221
+			}
222
+		}
223
+		return $value;
224
+	}
225 225
 }
Please login to merge, or discard this patch.
plugin/Commands/EnqueuePublicAssets.php 1 patch
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -10,149 +10,149 @@
 block discarded – undo
10 10
 
11 11
 class EnqueuePublicAssets implements Contract
12 12
 {
13
-    /**
14
-     * @return void
15
-     */
16
-    public function handle()
17
-    {
18
-        $this->enqueueAssets();
19
-        $this->enqueuePolyfillService();
20
-        $this->enqueueRecaptchaScript();
21
-        $this->inlineScript();
22
-        $this->inlineStyles();
23
-    }
13
+	/**
14
+	 * @return void
15
+	 */
16
+	public function handle()
17
+	{
18
+		$this->enqueueAssets();
19
+		$this->enqueuePolyfillService();
20
+		$this->enqueueRecaptchaScript();
21
+		$this->inlineScript();
22
+		$this->inlineStyles();
23
+	}
24 24
 
25
-    /**
26
-     * @return void
27
-     */
28
-    public function enqueueAssets()
29
-    {
30
-        if (glsr()->filterBool('assets/css', true)) {
31
-            wp_enqueue_style(
32
-                Application::ID,
33
-                $this->getStylesheet(),
34
-                [],
35
-                glsr()->version
36
-            );
37
-        }
38
-        if (glsr()->filterBool('assets/js', true)) {
39
-            $dependencies = glsr()->filterBool('assets/polyfill', true)
40
-                ? [Application::ID.'/polyfill']
41
-                : [];
42
-            $dependencies = glsr()->filterArray('enqueue/public/dependencies', $dependencies);
43
-            wp_enqueue_script(
44
-                Application::ID,
45
-                glsr()->url('assets/scripts/'.Application::ID.'.js'),
46
-                $dependencies,
47
-                glsr()->version,
48
-                true
49
-            );
50
-        }
51
-    }
25
+	/**
26
+	 * @return void
27
+	 */
28
+	public function enqueueAssets()
29
+	{
30
+		if (glsr()->filterBool('assets/css', true)) {
31
+			wp_enqueue_style(
32
+				Application::ID,
33
+				$this->getStylesheet(),
34
+				[],
35
+				glsr()->version
36
+			);
37
+		}
38
+		if (glsr()->filterBool('assets/js', true)) {
39
+			$dependencies = glsr()->filterBool('assets/polyfill', true)
40
+				? [Application::ID.'/polyfill']
41
+				: [];
42
+			$dependencies = glsr()->filterArray('enqueue/public/dependencies', $dependencies);
43
+			wp_enqueue_script(
44
+				Application::ID,
45
+				glsr()->url('assets/scripts/'.Application::ID.'.js'),
46
+				$dependencies,
47
+				glsr()->version,
48
+				true
49
+			);
50
+		}
51
+	}
52 52
 
53
-    /**
54
-     * @return void
55
-     */
56
-    public function enqueuePolyfillService()
57
-    {
58
-        if (!glsr()->filterBool('assets/polyfill', true)) {
59
-            return;
60
-        }
61
-        wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([
62
-            'features' => 'Array.prototype.findIndex,CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver',
63
-            'flags' => 'gated',
64
-        ], 'https://polyfill.io/v3/polyfill.min.js'));
65
-    }
53
+	/**
54
+	 * @return void
55
+	 */
56
+	public function enqueuePolyfillService()
57
+	{
58
+		if (!glsr()->filterBool('assets/polyfill', true)) {
59
+			return;
60
+		}
61
+		wp_enqueue_script(Application::ID.'/polyfill', add_query_arg([
62
+			'features' => 'Array.prototype.findIndex,CustomEvent,Element.prototype.closest,Element.prototype.dataset,Event,XMLHttpRequest,MutationObserver',
63
+			'flags' => 'gated',
64
+		], 'https://polyfill.io/v3/polyfill.min.js'));
65
+	}
66 66
 
67
-    /**
68
-     * @return void
69
-     */
70
-    public function enqueueRecaptchaScript()
71
-    {
72
-        // wpforms-recaptcha
73
-        // google-recaptcha
74
-        // nf-google-recaptcha
75
-        if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
76
-            return;
77
-        }
78
-        $language = glsr()->filterString('recaptcha/language', get_locale());
79
-        wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([
80
-            'hl' => $language,
81
-            'render' => 'explicit',
82
-        ], 'https://www.google.com/recaptcha/api.js'));
83
-    }
67
+	/**
68
+	 * @return void
69
+	 */
70
+	public function enqueueRecaptchaScript()
71
+	{
72
+		// wpforms-recaptcha
73
+		// google-recaptcha
74
+		// nf-google-recaptcha
75
+		if (!glsr(OptionManager::class)->isRecaptchaEnabled()) {
76
+			return;
77
+		}
78
+		$language = glsr()->filterString('recaptcha/language', get_locale());
79
+		wp_enqueue_script(Application::ID.'/google-recaptcha', add_query_arg([
80
+			'hl' => $language,
81
+			'render' => 'explicit',
82
+		], 'https://www.google.com/recaptcha/api.js'));
83
+	}
84 84
 
85
-    /**
86
-     * @return void
87
-     */
88
-    public function inlineScript()
89
-    {
90
-        $variables = [
91
-            'action' => Application::PREFIX.'action',
92
-            'ajaxpagination' => $this->getFixedSelectorsForPagination(),
93
-            'ajaxurl' => admin_url('admin-ajax.php'),
94
-            'nameprefix' => Application::ID,
95
-            'urlparameter' => glsr(OptionManager::class)->getBool('settings.reviews.pagination.url_parameter'),
96
-            'validationconfig' => glsr(Style::class)->validation,
97
-            'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(),
98
-        ];
99
-        $variables = glsr()->filterArray('enqueue/public/localize', $variables);
100
-        wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before');
101
-    }
85
+	/**
86
+	 * @return void
87
+	 */
88
+	public function inlineScript()
89
+	{
90
+		$variables = [
91
+			'action' => Application::PREFIX.'action',
92
+			'ajaxpagination' => $this->getFixedSelectorsForPagination(),
93
+			'ajaxurl' => admin_url('admin-ajax.php'),
94
+			'nameprefix' => Application::ID,
95
+			'urlparameter' => glsr(OptionManager::class)->getBool('settings.reviews.pagination.url_parameter'),
96
+			'validationconfig' => glsr(Style::class)->validation,
97
+			'validationstrings' => glsr(ValidationStringsDefaults::class)->defaults(),
98
+		];
99
+		$variables = glsr()->filterArray('enqueue/public/localize', $variables);
100
+		wp_add_inline_script(Application::ID, $this->buildInlineScript($variables), 'before');
101
+	}
102 102
 
103
-    /**
104
-     * @return void
105
-     */
106
-    public function inlineStyles()
107
-    {
108
-        $inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css');
109
-        if (!glsr()->filterBool('assets/css', true)) {
110
-            return;
111
-        }
112
-        if (!file_exists($inlineStylesheetPath)) {
113
-            glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath);
114
-            return;
115
-        }
116
-        $inlineStylesheetValues = glsr()->config('inline-styles');
117
-        $stylesheet = str_replace(
118
-            array_keys($inlineStylesheetValues),
119
-            array_values($inlineStylesheetValues),
120
-            file_get_contents($inlineStylesheetPath)
121
-        );
122
-        wp_add_inline_style(Application::ID, $stylesheet);
123
-    }
103
+	/**
104
+	 * @return void
105
+	 */
106
+	public function inlineStyles()
107
+	{
108
+		$inlineStylesheetPath = glsr()->path('assets/styles/inline-styles.css');
109
+		if (!glsr()->filterBool('assets/css', true)) {
110
+			return;
111
+		}
112
+		if (!file_exists($inlineStylesheetPath)) {
113
+			glsr_log()->error('Inline stylesheet is missing: '.$inlineStylesheetPath);
114
+			return;
115
+		}
116
+		$inlineStylesheetValues = glsr()->config('inline-styles');
117
+		$stylesheet = str_replace(
118
+			array_keys($inlineStylesheetValues),
119
+			array_values($inlineStylesheetValues),
120
+			file_get_contents($inlineStylesheetPath)
121
+		);
122
+		wp_add_inline_style(Application::ID, $stylesheet);
123
+	}
124 124
 
125
-    /**
126
-     * @return string
127
-     */
128
-    protected function buildInlineScript(array $variables)
129
-    {
130
-        $script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});';
131
-        foreach ($variables as $key => $value) {
132
-            $script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
133
-        }
134
-        $pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys
135
-        $optimizedScript = preg_replace($pattern, '$1$2', $script);
136
-        return glsr()->filterString('enqueue/public/inline-script', $optimizedScript, $script, $variables);
137
-    }
125
+	/**
126
+	 * @return string
127
+	 */
128
+	protected function buildInlineScript(array $variables)
129
+	{
130
+		$script = 'window.hasOwnProperty("GLSR")||(window.GLSR={});';
131
+		foreach ($variables as $key => $value) {
132
+			$script.= sprintf('GLSR.%s=%s;', $key, json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
133
+		}
134
+		$pattern = '/\"([^ \-\"]+)\"(:[{\[\"])/'; // removes unnecessary quotes surrounding object keys
135
+		$optimizedScript = preg_replace($pattern, '$1$2', $script);
136
+		return glsr()->filterString('enqueue/public/inline-script', $optimizedScript, $script, $variables);
137
+	}
138 138
 
139
-    /**
140
-     * @return array
141
-     */
142
-    protected function getFixedSelectorsForPagination()
143
-    {
144
-        $selectors = ['#wpadminbar', '.site-navigation-fixed'];
145
-        return glsr()->filterArray('enqueue/public/localize/ajax-pagination', $selectors);
146
-    }
139
+	/**
140
+	 * @return array
141
+	 */
142
+	protected function getFixedSelectorsForPagination()
143
+	{
144
+		$selectors = ['#wpadminbar', '.site-navigation-fixed'];
145
+		return glsr()->filterArray('enqueue/public/localize/ajax-pagination', $selectors);
146
+	}
147 147
 
148
-    /**
149
-     * @return string
150
-     */
151
-    protected function getStylesheet()
152
-    {
153
-        $currentStyle = glsr(Style::class)->style;
154
-        return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css'))
155
-            ? glsr()->url('assets/styles/custom/'.$currentStyle.'.css')
156
-            : glsr()->url('assets/styles/'.Application::ID.'.css');
157
-    }
148
+	/**
149
+	 * @return string
150
+	 */
151
+	protected function getStylesheet()
152
+	{
153
+		$currentStyle = glsr(Style::class)->style;
154
+		return file_exists(glsr()->path('assets/styles/custom/'.$currentStyle.'.css'))
155
+			? glsr()->url('assets/styles/custom/'.$currentStyle.'.css')
156
+			: glsr()->url('assets/styles/'.Application::ID.'.css');
157
+	}
158 158
 }
Please login to merge, or discard this patch.
plugin/Shortcodes/Shortcode.php 1 patch
Indentation   +237 added lines, -237 removed lines patch added patch discarded remove patch
@@ -15,265 +15,265 @@
 block discarded – undo
15 15
 
16 16
 abstract class Shortcode implements ShortcodeContract
17 17
 {
18
-    /**
19
-     * @var array
20
-     */
21
-    protected $data;
18
+	/**
19
+	 * @var array
20
+	 */
21
+	protected $data;
22 22
 
23
-    /**
24
-     * @var string
25
-     */
26
-    protected $partialName;
23
+	/**
24
+	 * @var string
25
+	 */
26
+	protected $partialName;
27 27
 
28
-    /**
29
-     * @var string
30
-     */
31
-    protected $shortcodeName;
28
+	/**
29
+	 * @var string
30
+	 */
31
+	protected $shortcodeName;
32 32
 
33
-    public function __construct()
34
-    {
35
-        $this->partialName = $this->getShortcodePartialName();
36
-        $this->shortcodeName = $this->getShortcodeName();
37
-    }
33
+	public function __construct()
34
+	{
35
+		$this->partialName = $this->getShortcodePartialName();
36
+		$this->shortcodeName = $this->getShortcodeName();
37
+	}
38 38
 
39
-    /**
40
-     * @param string|array $atts
41
-     * @param string $type
42
-     * @return string
43
-     */
44
-    public function build($atts, array $args = [], $type = 'shortcode')
45
-    {
46
-        $args = $this->normalizeArgs($args, $type);
47
-        $atts = $this->normalizeAtts($atts, $type);
48
-        $partial = glsr(Partial::class)->build($this->partialName, $atts);
49
-        if (!empty($atts['title'])) {
50
-            $atts = Arr::set($atts, 'title', $args['before_title'].$atts['title'].$args['after_title']);
51
-        }
52
-        $html = glsr(Builder::class)->div((string) $partial, wp_parse_args($this->data, [
53
-            'class' => 'glsr glsr-'.glsr(Style::class)->get(),
54
-            'data-'.$type => '',
55
-        ]));
56
-        return $args['before_widget'].$atts['title'].$html.$args['after_widget'];
57
-    }
39
+	/**
40
+	 * @param string|array $atts
41
+	 * @param string $type
42
+	 * @return string
43
+	 */
44
+	public function build($atts, array $args = [], $type = 'shortcode')
45
+	{
46
+		$args = $this->normalizeArgs($args, $type);
47
+		$atts = $this->normalizeAtts($atts, $type);
48
+		$partial = glsr(Partial::class)->build($this->partialName, $atts);
49
+		if (!empty($atts['title'])) {
50
+			$atts = Arr::set($atts, 'title', $args['before_title'].$atts['title'].$args['after_title']);
51
+		}
52
+		$html = glsr(Builder::class)->div((string) $partial, wp_parse_args($this->data, [
53
+			'class' => 'glsr glsr-'.glsr(Style::class)->get(),
54
+			'data-'.$type => '',
55
+		]));
56
+		return $args['before_widget'].$atts['title'].$html.$args['after_widget'];
57
+	}
58 58
 
59
-    /**
60
-     * {@inheritdoc}
61
-     */
62
-    public function buildBlock($atts = [])
63
-    {
64
-        return $this->build($atts, [], 'block');
65
-    }
59
+	/**
60
+	 * {@inheritdoc}
61
+	 */
62
+	public function buildBlock($atts = [])
63
+	{
64
+		return $this->build($atts, [], 'block');
65
+	}
66 66
 
67
-    /**
68
-     * {@inheritdoc}
69
-     */
70
-    public function buildShortcode($atts = [])
71
-    {
72
-        return $this->build($atts, [], 'shortcode');
73
-    }
67
+	/**
68
+	 * {@inheritdoc}
69
+	 */
70
+	public function buildShortcode($atts = [])
71
+	{
72
+		return $this->build($atts, [], 'shortcode');
73
+	}
74 74
 
75
-    /**
76
-     * @return array
77
-     */
78
-    public function getDefaults(array $atts)
79
-    {
80
-        return glsr($this->getShortcodeDefaultsClassName())->restrict($atts);
81
-    }
75
+	/**
76
+	 * @return array
77
+	 */
78
+	public function getDefaults(array $atts)
79
+	{
80
+		return glsr($this->getShortcodeDefaultsClassName())->restrict($atts);
81
+	}
82 82
 
83
-    /**
84
-     * @return array
85
-     */
86
-    public function getHideOptions()
87
-    {
88
-        $options = $this->hideOptions();
89
-        return glsr()->filterArray('shortcode/hide-options', $options, $this->shortcodeName);
90
-    }
83
+	/**
84
+	 * @return array
85
+	 */
86
+	public function getHideOptions()
87
+	{
88
+		$options = $this->hideOptions();
89
+		return glsr()->filterArray('shortcode/hide-options', $options, $this->shortcodeName);
90
+	}
91 91
 
92
-    /**
93
-     * @return string
94
-     */
95
-    public function getShortClassName($replace = '', $search = 'Shortcode')
96
-    {
97
-        return str_replace($search, $replace, (new ReflectionClass($this))->getShortName());
98
-    }
92
+	/**
93
+	 * @return string
94
+	 */
95
+	public function getShortClassName($replace = '', $search = 'Shortcode')
96
+	{
97
+		return str_replace($search, $replace, (new ReflectionClass($this))->getShortName());
98
+	}
99 99
 
100
-    /**
101
-     * @return string
102
-     */
103
-    public function getShortcodeDefaultsClassName()
104
-    {
105
-        $className = Str::replaceLast('Shortcode', 'Defaults', get_class($this));
106
-        return str_replace('Shortcodes', 'Defaults', $className);
107
-    }
100
+	/**
101
+	 * @return string
102
+	 */
103
+	public function getShortcodeDefaultsClassName()
104
+	{
105
+		$className = Str::replaceLast('Shortcode', 'Defaults', get_class($this));
106
+		return str_replace('Shortcodes', 'Defaults', $className);
107
+	}
108 108
 
109
-    /**
110
-     * @return string
111
-     */
112
-    public function getShortcodeName()
113
-    {
114
-        return Str::snakeCase($this->getShortClassName());
115
-    }
109
+	/**
110
+	 * @return string
111
+	 */
112
+	public function getShortcodeName()
113
+	{
114
+		return Str::snakeCase($this->getShortClassName());
115
+	}
116 116
 
117
-    /**
118
-     * @return string
119
-     */
120
-    public function getShortcodePartialName()
121
-    {
122
-        return Str::dashCase($this->getShortClassName());
123
-    }
117
+	/**
118
+	 * @return string
119
+	 */
120
+	public function getShortcodePartialName()
121
+	{
122
+		return Str::dashCase($this->getShortClassName());
123
+	}
124 124
 
125
-    /**
126
-     * @param array|string $args
127
-     * @param string $type
128
-     * @return array
129
-     */
130
-    public function normalizeArgs($args, $type = 'shortcode')
131
-    {
132
-        $args = wp_parse_args($args, [
133
-            'before_widget' => '',
134
-            'after_widget' => '',
135
-            'before_title' => '<h2 class="glsr-title">',
136
-            'after_title' => '</h2>',
137
-        ]);
138
-        return glsr()->filterArray('shortcode/args', $args, $type, $this->partialName);
139
-    }
125
+	/**
126
+	 * @param array|string $args
127
+	 * @param string $type
128
+	 * @return array
129
+	 */
130
+	public function normalizeArgs($args, $type = 'shortcode')
131
+	{
132
+		$args = wp_parse_args($args, [
133
+			'before_widget' => '',
134
+			'after_widget' => '',
135
+			'before_title' => '<h2 class="glsr-title">',
136
+			'after_title' => '</h2>',
137
+		]);
138
+		return glsr()->filterArray('shortcode/args', $args, $type, $this->partialName);
139
+	}
140 140
 
141
-    /**
142
-     * @param array|string $atts
143
-     * @param string $type
144
-     * @return array
145
-     */
146
-    public function normalizeAtts($atts, $type = 'shortcode')
147
-    {
148
-        $atts = glsr()->filterArray('shortcode/atts', $atts, $type, $this->partialName);
149
-        $atts = $this->getDefaults(wp_parse_args($atts));
150
-        foreach ($atts as $key => &$value) {
151
-            $methodName = Helper::buildMethodName($key, 'normalize');
152
-            if (method_exists($this, $methodName)) {
153
-                $value = $this->$methodName($value, $atts);
154
-            }
155
-        };
156
-        $this->setData($atts);
157
-        $this->setId($atts);
158
-        return $atts;
159
-    }
141
+	/**
142
+	 * @param array|string $atts
143
+	 * @param string $type
144
+	 * @return array
145
+	 */
146
+	public function normalizeAtts($atts, $type = 'shortcode')
147
+	{
148
+		$atts = glsr()->filterArray('shortcode/atts', $atts, $type, $this->partialName);
149
+		$atts = $this->getDefaults(wp_parse_args($atts));
150
+		foreach ($atts as $key => &$value) {
151
+			$methodName = Helper::buildMethodName($key, 'normalize');
152
+			if (method_exists($this, $methodName)) {
153
+				$value = $this->$methodName($value, $atts);
154
+			}
155
+		};
156
+		$this->setData($atts);
157
+		$this->setId($atts);
158
+		return $atts;
159
+	}
160 160
 
161
-    /**
162
-     * @return array
163
-     */
164
-    abstract protected function hideOptions();
161
+	/**
162
+	 * @return array
163
+	 */
164
+	abstract protected function hideOptions();
165 165
 
166
-    /**
167
-     * @param string $postId
168
-     * @return int|string
169
-     */
170
-    protected function normalizeAssignedTo($postId, array $atts)
171
-    {
172
-        if ('parent_id' == $postId) {
173
-            $postId = intval(wp_get_post_parent_id(intval(get_the_ID())));
174
-        } elseif ('post_id' == $postId) {
175
-            $postId = intval(get_the_ID());
176
-        } elseif ('custom' == $postId) {
177
-            $customId = Arr::get($atts, 'assigned_to_custom');
178
-            $customId = str_replace('custom', '', $customId); // prevent a possible infinite loop
179
-            $postId = $this->normalizeAssignedTo($customId, $atts);
180
-        }
181
-        return $postId;
182
-    }
166
+	/**
167
+	 * @param string $postId
168
+	 * @return int|string
169
+	 */
170
+	protected function normalizeAssignedTo($postId, array $atts)
171
+	{
172
+		if ('parent_id' == $postId) {
173
+			$postId = intval(wp_get_post_parent_id(intval(get_the_ID())));
174
+		} elseif ('post_id' == $postId) {
175
+			$postId = intval(get_the_ID());
176
+		} elseif ('custom' == $postId) {
177
+			$customId = Arr::get($atts, 'assigned_to_custom');
178
+			$customId = str_replace('custom', '', $customId); // prevent a possible infinite loop
179
+			$postId = $this->normalizeAssignedTo($customId, $atts);
180
+		}
181
+		return $postId;
182
+	}
183 183
 
184
-    /**
185
-     * @param string $postId
186
-     * @return int|string
187
-     */
188
-    protected function normalizeAssignTo($postId, array $atts)
189
-    {
190
-        return $this->normalizeAssignedTo($postId, $atts);
191
-    }
184
+	/**
185
+	 * @param string $postId
186
+	 * @return int|string
187
+	 */
188
+	protected function normalizeAssignTo($postId, array $atts)
189
+	{
190
+		return $this->normalizeAssignedTo($postId, $atts);
191
+	}
192 192
 
193
-    /**
194
-     * @param string|array $hide
195
-     * @return array
196
-     */
197
-    protected function normalizeHide($hide)
198
-    {
199
-        if (is_string($hide)) {
200
-            $hide = explode(',', $hide);
201
-        }
202
-        $hideKeys = array_keys($this->getHideOptions());
203
-        return array_filter(array_map('trim', $hide), function ($value) use ($hideKeys) {
204
-            return in_array($value, $hideKeys);
205
-        });
206
-    }
193
+	/**
194
+	 * @param string|array $hide
195
+	 * @return array
196
+	 */
197
+	protected function normalizeHide($hide)
198
+	{
199
+		if (is_string($hide)) {
200
+			$hide = explode(',', $hide);
201
+		}
202
+		$hideKeys = array_keys($this->getHideOptions());
203
+		return array_filter(array_map('trim', $hide), function ($value) use ($hideKeys) {
204
+			return in_array($value, $hideKeys);
205
+		});
206
+	}
207 207
 
208
-    /**
209
-     * @param string $id
210
-     * @return string
211
-     */
212
-    protected function normalizeId($id)
213
-    {
214
-        return sanitize_title($id);
215
-    }
208
+	/**
209
+	 * @param string $id
210
+	 * @return string
211
+	 */
212
+	protected function normalizeId($id)
213
+	{
214
+		return sanitize_title($id);
215
+	}
216 216
 
217
-    /**
218
-     * @param string $labels
219
-     * @return array
220
-     */
221
-    protected function normalizeLabels($labels)
222
-    {
223
-        $defaults = [
224
-            __('Excellent', 'site-reviews'),
225
-            __('Very good', 'site-reviews'),
226
-            __('Average', 'site-reviews'),
227
-            __('Poor', 'site-reviews'),
228
-            __('Terrible', 'site-reviews'),
229
-        ];
230
-        $maxRating = (int) glsr()->constant('MAX_RATING', Rating::class);
231
-        $defaults = array_pad(array_slice($defaults, 0, $maxRating), $maxRating, '');
232
-        $labels = array_map('trim', explode(',', $labels));
233
-        foreach ($defaults as $i => $label) {
234
-            if (empty($labels[$i])) {
235
-                continue;
236
-            }
237
-            $defaults[$i] = $labels[$i];
238
-        }
239
-        return array_combine(range($maxRating, 1), $defaults);
240
-    }
217
+	/**
218
+	 * @param string $labels
219
+	 * @return array
220
+	 */
221
+	protected function normalizeLabels($labels)
222
+	{
223
+		$defaults = [
224
+			__('Excellent', 'site-reviews'),
225
+			__('Very good', 'site-reviews'),
226
+			__('Average', 'site-reviews'),
227
+			__('Poor', 'site-reviews'),
228
+			__('Terrible', 'site-reviews'),
229
+		];
230
+		$maxRating = (int) glsr()->constant('MAX_RATING', Rating::class);
231
+		$defaults = array_pad(array_slice($defaults, 0, $maxRating), $maxRating, '');
232
+		$labels = array_map('trim', explode(',', $labels));
233
+		foreach ($defaults as $i => $label) {
234
+			if (empty($labels[$i])) {
235
+				continue;
236
+			}
237
+			$defaults[$i] = $labels[$i];
238
+		}
239
+		return array_combine(range($maxRating, 1), $defaults);
240
+	}
241 241
 
242
-    /**
243
-     * @param string $schema
244
-     * @return bool
245
-     */
246
-    protected function normalizeSchema($schema)
247
-    {
248
-        return wp_validate_boolean($schema);
249
-    }
242
+	/**
243
+	 * @param string $schema
244
+	 * @return bool
245
+	 */
246
+	protected function normalizeSchema($schema)
247
+	{
248
+		return wp_validate_boolean($schema);
249
+	}
250 250
 
251
-    /**
252
-     * @param string $text
253
-     * @return string
254
-     */
255
-    protected function normalizeText($text)
256
-    {
257
-        return trim($text);
258
-    }
251
+	/**
252
+	 * @param string $text
253
+	 * @return string
254
+	 */
255
+	protected function normalizeText($text)
256
+	{
257
+		return trim($text);
258
+	}
259 259
 
260
-    /**
261
-     * @return void
262
-     */
263
-    protected function setData(array $atts)
264
-    {
265
-        unset($atts['assign_to_custom']);
266
-        unset($atts['assigned_to_custom']);
267
-        $this->data = glsr($this->getShortcodeDefaultsClassName())->filteredData($atts);
268
-    }
260
+	/**
261
+	 * @return void
262
+	 */
263
+	protected function setData(array $atts)
264
+	{
265
+		unset($atts['assign_to_custom']);
266
+		unset($atts['assigned_to_custom']);
267
+		$this->data = glsr($this->getShortcodeDefaultsClassName())->filteredData($atts);
268
+	}
269 269
 
270
-    /**
271
-     * @return void
272
-     */
273
-    protected function setId(array &$atts)
274
-    {
275
-        if (empty($atts['id'])) {
276
-            $atts['id'] = Application::PREFIX.substr(md5(serialize($atts)), 0, 8);
277
-        }
278
-    }
270
+	/**
271
+	 * @return void
272
+	 */
273
+	protected function setId(array &$atts)
274
+	{
275
+		if (empty($atts['id'])) {
276
+			$atts['id'] = Application::PREFIX.substr(md5(serialize($atts)), 0, 8);
277
+		}
278
+	}
279 279
 }
Please login to merge, or discard this patch.
plugin/Modules/Email.php 1 patch
Indentation   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -9,212 +9,212 @@
 block discarded – undo
9 9
 
10 10
 class Email
11 11
 {
12
-    /**
13
-     * @var array
14
-     */
15
-    public $attachments;
16
-
17
-    /**
18
-     * @var array
19
-     */
20
-    public $data;
21
-
22
-    /**
23
-     * @var array
24
-     */
25
-    public $email;
26
-
27
-    /**
28
-     * @var array
29
-     */
30
-    public $headers;
31
-
32
-    /**
33
-     * @var string
34
-     */
35
-    public $message;
36
-
37
-    /**
38
-     * @var string
39
-     */
40
-    public $subject;
41
-
42
-    /**
43
-     * @var string|array
44
-     */
45
-    public $to;
46
-
47
-    /**
48
-     * @return Email
49
-     */
50
-    public function compose(array $email, array $data = [])
51
-    {
52
-        $this->data = $data;
53
-        $this->normalize($email);
54
-        $this->attachments = $this->email['attachments'];
55
-        $this->headers = $this->buildHeaders();
56
-        $this->message = $this->buildHtmlMessage();
57
-        $this->subject = $this->email['subject'];
58
-        $this->to = $this->email['to'];
59
-        add_action('phpmailer_init', [$this, 'buildPlainTextMessage']);
60
-        return $this;
61
-    }
62
-
63
-    /**
64
-     * @param string $format
65
-     * @return string
66
-     */
67
-    public function read($format = '')
68
-    {
69
-        if ('plaintext' == $format) {
70
-            $message = $this->stripHtmlTags($this->message);
71
-            return glsr()->filterString('email/message', $message, 'text', $this);
72
-        }
73
-        return $this->message;
74
-    }
75
-
76
-    /**
77
-     * @return void|bool
78
-     */
79
-    public function send()
80
-    {
81
-        if (!$this->message || !$this->subject || !$this->to) {
82
-            return;
83
-        }
84
-        add_action('wp_mail_failed', [$this, 'logMailError']);
85
-        $sent = wp_mail(
86
-            $this->to,
87
-            $this->subject,
88
-            $this->message,
89
-            $this->headers,
90
-            $this->attachments
91
-        );
92
-        remove_action('wp_mail_failed', [$this, 'logMailError']);
93
-        $this->reset();
94
-        return $sent;
95
-    }
96
-
97
-    /**
98
-     * @return void
99
-     * @action phpmailer_init
100
-     */
101
-    public function buildPlainTextMessage(PHPMailer $phpmailer)
102
-    {
103
-        if (empty($this->email)) {
104
-            return;
105
-        }
106
-        if ('text/plain' === $phpmailer->ContentType || !empty($phpmailer->AltBody)) {
107
-            return;
108
-        }
109
-        $message = $this->stripHtmlTags($phpmailer->Body);
110
-        $phpmailer->AltBody = glsr()->filterString('email/message', $message, 'text', $this);
111
-    }
112
-
113
-    /**
114
-     * @return array
115
-     */
116
-    protected function buildHeaders()
117
-    {
118
-        $allowed = [
119
-            'bcc', 'cc', 'from', 'reply-to',
120
-        ];
121
-        $headers = array_intersect_key($this->email, array_flip($allowed));
122
-        $headers = array_filter($headers);
123
-        foreach ($headers as $key => $value) {
124
-            unset($headers[$key]);
125
-            $headers[] = $key.': '.$value;
126
-        }
127
-        $headers[] = 'Content-Type: text/html';
128
-        return glsr()->filterArray('email/headers', $headers, $this);
129
-    }
130
-
131
-    /**
132
-     * @return string
133
-     */
134
-    protected function buildHtmlMessage()
135
-    {
136
-        $template = trim(glsr(OptionManager::class)->get('settings.general.notification_message'));
137
-        if (!empty($template)) {
138
-            $message = glsr(Template::class)->interpolate(
139
-                $template, 
140
-                ['context' => $this->email['template-tags']], 
141
-                $this->email['template']
142
-            );
143
-        } elseif ($this->email['template']) {
144
-            $message = glsr(Template::class)->build('templates/'.$this->email['template'], [
145
-                'context' => $this->email['template-tags'],
146
-            ]);
147
-        }
148
-        if (!isset($message)) {
149
-            $message = $this->email['message'];
150
-        }
151
-        $message = $this->email['before'].$message.$this->email['after'];
152
-        $message = strip_shortcodes($message);
153
-        $message = wptexturize($message);
154
-        $message = wpautop($message);
155
-        $message = str_replace('&lt;&gt; ', '', $message);
156
-        $message = str_replace(']]>', ']]&gt;', $message);
157
-        $message = glsr(Template::class)->build('partials/email/index', [
158
-            'context' => ['message' => $message],
159
-        ]);
160
-        return glsr()->filterString('email/message', stripslashes($message), 'html', $this);
161
-    }
162
-
163
-    /**
164
-     * @param \WP_Error $error
165
-     * @return void
166
-     */
167
-    protected function logMailError($error)
168
-    {
169
-        glsr_log()->error('Email was not sent (wp_mail failed)')
170
-            ->debug($this)
171
-            ->debug($error);
172
-    }
173
-
174
-    /**
175
-     * @return void
176
-     */
177
-    protected function normalize(array $email = [])
178
-    {
179
-        $email = shortcode_atts(glsr(EmailDefaults::class)->defaults(), $email);
180
-        if (empty($email['reply-to'])) {
181
-            $email['reply-to'] = $email['from'];
182
-        }
183
-        $this->email = glsr()->filterArray('email/compose', $email, $this);
184
-    }
185
-
186
-    /**
187
-     * @return void
188
-     */
189
-    protected function reset()
190
-    {
191
-        $this->attachments = [];
192
-        $this->data = [];
193
-        $this->email = [];
194
-        $this->headers = [];
195
-        $this->message = null;
196
-        $this->subject = null;
197
-        $this->to = null;
198
-    }
199
-
200
-    /**
201
-     * @return string
202
-     */
203
-    protected function stripHtmlTags($string)
204
-    {
205
-        // remove invisible elements
206
-        $string = preg_replace('@<(embed|head|noembed|noscript|object|script|style)[^>]*?>.*?</\\1>@siu', '', $string);
207
-        // replace certain elements with a line-break
208
-        $string = preg_replace('@</(div|h[1-9]|p|pre|tr)@iu', "\r\n\$0", $string);
209
-        // replace other elements with a space
210
-        $string = preg_replace('@</(td|th)@iu', ' $0', $string);
211
-        // add a placeholder for plain-text bullets to list elements
212
-        $string = preg_replace('@<(li)[^>]*?>@siu', '$0-o-^-o-', $string);
213
-        // strip all remaining HTML tags
214
-        $string = wp_strip_all_tags($string);
215
-        $string = wp_specialchars_decode($string, ENT_QUOTES);
216
-        $string = preg_replace('/\v(?:[\v\h]+){2,}/u', "\r\n\r\n", $string);
217
-        $string = str_replace('-o-^-o-', ' - ', $string);
218
-        return html_entity_decode($string, ENT_QUOTES, 'UTF-8');
219
-    }
12
+	/**
13
+	 * @var array
14
+	 */
15
+	public $attachments;
16
+
17
+	/**
18
+	 * @var array
19
+	 */
20
+	public $data;
21
+
22
+	/**
23
+	 * @var array
24
+	 */
25
+	public $email;
26
+
27
+	/**
28
+	 * @var array
29
+	 */
30
+	public $headers;
31
+
32
+	/**
33
+	 * @var string
34
+	 */
35
+	public $message;
36
+
37
+	/**
38
+	 * @var string
39
+	 */
40
+	public $subject;
41
+
42
+	/**
43
+	 * @var string|array
44
+	 */
45
+	public $to;
46
+
47
+	/**
48
+	 * @return Email
49
+	 */
50
+	public function compose(array $email, array $data = [])
51
+	{
52
+		$this->data = $data;
53
+		$this->normalize($email);
54
+		$this->attachments = $this->email['attachments'];
55
+		$this->headers = $this->buildHeaders();
56
+		$this->message = $this->buildHtmlMessage();
57
+		$this->subject = $this->email['subject'];
58
+		$this->to = $this->email['to'];
59
+		add_action('phpmailer_init', [$this, 'buildPlainTextMessage']);
60
+		return $this;
61
+	}
62
+
63
+	/**
64
+	 * @param string $format
65
+	 * @return string
66
+	 */
67
+	public function read($format = '')
68
+	{
69
+		if ('plaintext' == $format) {
70
+			$message = $this->stripHtmlTags($this->message);
71
+			return glsr()->filterString('email/message', $message, 'text', $this);
72
+		}
73
+		return $this->message;
74
+	}
75
+
76
+	/**
77
+	 * @return void|bool
78
+	 */
79
+	public function send()
80
+	{
81
+		if (!$this->message || !$this->subject || !$this->to) {
82
+			return;
83
+		}
84
+		add_action('wp_mail_failed', [$this, 'logMailError']);
85
+		$sent = wp_mail(
86
+			$this->to,
87
+			$this->subject,
88
+			$this->message,
89
+			$this->headers,
90
+			$this->attachments
91
+		);
92
+		remove_action('wp_mail_failed', [$this, 'logMailError']);
93
+		$this->reset();
94
+		return $sent;
95
+	}
96
+
97
+	/**
98
+	 * @return void
99
+	 * @action phpmailer_init
100
+	 */
101
+	public function buildPlainTextMessage(PHPMailer $phpmailer)
102
+	{
103
+		if (empty($this->email)) {
104
+			return;
105
+		}
106
+		if ('text/plain' === $phpmailer->ContentType || !empty($phpmailer->AltBody)) {
107
+			return;
108
+		}
109
+		$message = $this->stripHtmlTags($phpmailer->Body);
110
+		$phpmailer->AltBody = glsr()->filterString('email/message', $message, 'text', $this);
111
+	}
112
+
113
+	/**
114
+	 * @return array
115
+	 */
116
+	protected function buildHeaders()
117
+	{
118
+		$allowed = [
119
+			'bcc', 'cc', 'from', 'reply-to',
120
+		];
121
+		$headers = array_intersect_key($this->email, array_flip($allowed));
122
+		$headers = array_filter($headers);
123
+		foreach ($headers as $key => $value) {
124
+			unset($headers[$key]);
125
+			$headers[] = $key.': '.$value;
126
+		}
127
+		$headers[] = 'Content-Type: text/html';
128
+		return glsr()->filterArray('email/headers', $headers, $this);
129
+	}
130
+
131
+	/**
132
+	 * @return string
133
+	 */
134
+	protected function buildHtmlMessage()
135
+	{
136
+		$template = trim(glsr(OptionManager::class)->get('settings.general.notification_message'));
137
+		if (!empty($template)) {
138
+			$message = glsr(Template::class)->interpolate(
139
+				$template, 
140
+				['context' => $this->email['template-tags']], 
141
+				$this->email['template']
142
+			);
143
+		} elseif ($this->email['template']) {
144
+			$message = glsr(Template::class)->build('templates/'.$this->email['template'], [
145
+				'context' => $this->email['template-tags'],
146
+			]);
147
+		}
148
+		if (!isset($message)) {
149
+			$message = $this->email['message'];
150
+		}
151
+		$message = $this->email['before'].$message.$this->email['after'];
152
+		$message = strip_shortcodes($message);
153
+		$message = wptexturize($message);
154
+		$message = wpautop($message);
155
+		$message = str_replace('&lt;&gt; ', '', $message);
156
+		$message = str_replace(']]>', ']]&gt;', $message);
157
+		$message = glsr(Template::class)->build('partials/email/index', [
158
+			'context' => ['message' => $message],
159
+		]);
160
+		return glsr()->filterString('email/message', stripslashes($message), 'html', $this);
161
+	}
162
+
163
+	/**
164
+	 * @param \WP_Error $error
165
+	 * @return void
166
+	 */
167
+	protected function logMailError($error)
168
+	{
169
+		glsr_log()->error('Email was not sent (wp_mail failed)')
170
+			->debug($this)
171
+			->debug($error);
172
+	}
173
+
174
+	/**
175
+	 * @return void
176
+	 */
177
+	protected function normalize(array $email = [])
178
+	{
179
+		$email = shortcode_atts(glsr(EmailDefaults::class)->defaults(), $email);
180
+		if (empty($email['reply-to'])) {
181
+			$email['reply-to'] = $email['from'];
182
+		}
183
+		$this->email = glsr()->filterArray('email/compose', $email, $this);
184
+	}
185
+
186
+	/**
187
+	 * @return void
188
+	 */
189
+	protected function reset()
190
+	{
191
+		$this->attachments = [];
192
+		$this->data = [];
193
+		$this->email = [];
194
+		$this->headers = [];
195
+		$this->message = null;
196
+		$this->subject = null;
197
+		$this->to = null;
198
+	}
199
+
200
+	/**
201
+	 * @return string
202
+	 */
203
+	protected function stripHtmlTags($string)
204
+	{
205
+		// remove invisible elements
206
+		$string = preg_replace('@<(embed|head|noembed|noscript|object|script|style)[^>]*?>.*?</\\1>@siu', '', $string);
207
+		// replace certain elements with a line-break
208
+		$string = preg_replace('@</(div|h[1-9]|p|pre|tr)@iu', "\r\n\$0", $string);
209
+		// replace other elements with a space
210
+		$string = preg_replace('@</(td|th)@iu', ' $0', $string);
211
+		// add a placeholder for plain-text bullets to list elements
212
+		$string = preg_replace('@<(li)[^>]*?>@siu', '$0-o-^-o-', $string);
213
+		// strip all remaining HTML tags
214
+		$string = wp_strip_all_tags($string);
215
+		$string = wp_specialchars_decode($string, ENT_QUOTES);
216
+		$string = preg_replace('/\v(?:[\v\h]+){2,}/u', "\r\n\r\n", $string);
217
+		$string = str_replace('-o-^-o-', ' - ', $string);
218
+		return html_entity_decode($string, ENT_QUOTES, 'UTF-8');
219
+	}
220 220
 }
Please login to merge, or discard this patch.
plugin/Modules/System.php 1 patch
Indentation   +352 added lines, -352 removed lines patch added patch discarded remove patch
@@ -12,378 +12,378 @@
 block discarded – undo
12 12
 
13 13
 class System
14 14
 {
15
-    const PAD = 40;
15
+	const PAD = 40;
16 16
 
17
-    /**
18
-     * @return string
19
-     */
20
-    public function __toString()
21
-    {
22
-        return $this->get();
23
-    }
17
+	/**
18
+	 * @return string
19
+	 */
20
+	public function __toString()
21
+	{
22
+		return $this->get();
23
+	}
24 24
 
25
-    /**
26
-     * @return string
27
-     */
28
-    public function get()
29
-    {
30
-        $details = [
31
-            'plugin' => 'Plugin Details',
32
-            'addon' => 'Addon Details',
33
-            'browser' => 'Browser Details',
34
-            'server' => 'Server Details',
35
-            'php' => 'PHP Configuration',
36
-            'wordpress' => 'WordPress Configuration',
37
-            'mu-plugin' => 'Must-Use Plugins',
38
-            'multisite-plugin' => 'Network Active Plugins',
39
-            'active-plugin' => 'Active Plugins',
40
-            'inactive-plugin' => 'Inactive Plugins',
41
-            'setting' => 'Plugin Settings',
42
-            'reviews' => 'Review Counts',
43
-        ];
44
-        $systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
45
-            $methodName = Helper::buildMethodName('get-'.$key.'-details');
46
-            if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
47
-                return $carry.$this->implode(
48
-                    strtoupper($details[$key]),
49
-                    glsr()->filterArray('system/'.$key, $systemDetails)
50
-                );
51
-            }
52
-            return $carry;
53
-        });
54
-        return trim($systemInfo);
55
-    }
25
+	/**
26
+	 * @return string
27
+	 */
28
+	public function get()
29
+	{
30
+		$details = [
31
+			'plugin' => 'Plugin Details',
32
+			'addon' => 'Addon Details',
33
+			'browser' => 'Browser Details',
34
+			'server' => 'Server Details',
35
+			'php' => 'PHP Configuration',
36
+			'wordpress' => 'WordPress Configuration',
37
+			'mu-plugin' => 'Must-Use Plugins',
38
+			'multisite-plugin' => 'Network Active Plugins',
39
+			'active-plugin' => 'Active Plugins',
40
+			'inactive-plugin' => 'Inactive Plugins',
41
+			'setting' => 'Plugin Settings',
42
+			'reviews' => 'Review Counts',
43
+		];
44
+		$systemInfo = array_reduce(array_keys($details), function ($carry, $key) use ($details) {
45
+			$methodName = Helper::buildMethodName('get-'.$key.'-details');
46
+			if (method_exists($this, $methodName) && $systemDetails = $this->$methodName()) {
47
+				return $carry.$this->implode(
48
+					strtoupper($details[$key]),
49
+					glsr()->filterArray('system/'.$key, $systemDetails)
50
+				);
51
+			}
52
+			return $carry;
53
+		});
54
+		return trim($systemInfo);
55
+	}
56 56
 
57
-    /**
58
-     * @return array
59
-     */
60
-    public function getActivePluginDetails()
61
-    {
62
-        $plugins = get_plugins();
63
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
64
-        $inactive = array_diff_key($plugins, array_flip($activePlugins));
65
-        return $this->normalizePluginList(array_diff_key($plugins, $inactive));
66
-    }
57
+	/**
58
+	 * @return array
59
+	 */
60
+	public function getActivePluginDetails()
61
+	{
62
+		$plugins = get_plugins();
63
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
64
+		$inactive = array_diff_key($plugins, array_flip($activePlugins));
65
+		return $this->normalizePluginList(array_diff_key($plugins, $inactive));
66
+	}
67 67
 
68
-    /**
69
-     * @return array
70
-     */
71
-    public function getAddonDetails()
72
-    {
73
-        $details = glsr()->filterArray('addon/system-info', []);
74
-        ksort($details);
75
-        return $details;
76
-    }
68
+	/**
69
+	 * @return array
70
+	 */
71
+	public function getAddonDetails()
72
+	{
73
+		$details = glsr()->filterArray('addon/system-info', []);
74
+		ksort($details);
75
+		return $details;
76
+	}
77 77
 
78
-    /**
79
-     * @return array
80
-     */
81
-    public function getBrowserDetails()
82
-    {
83
-        $browser = new Browser();
84
-        $name = esc_attr($browser->getName());
85
-        $userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
86
-        $version = esc_attr($browser->getVersion());
87
-        return [
88
-            'Browser Name' => sprintf('%s %s', $name, $version),
89
-            'Browser UA' => $userAgent,
90
-        ];
91
-    }
78
+	/**
79
+	 * @return array
80
+	 */
81
+	public function getBrowserDetails()
82
+	{
83
+		$browser = new Browser();
84
+		$name = esc_attr($browser->getName());
85
+		$userAgent = esc_attr($browser->getUserAgent()->getUserAgentString());
86
+		$version = esc_attr($browser->getVersion());
87
+		return [
88
+			'Browser Name' => sprintf('%s %s', $name, $version),
89
+			'Browser UA' => $userAgent,
90
+		];
91
+	}
92 92
 
93
-    /**
94
-     * @return array
95
-     */
96
-    public function getInactivePluginDetails()
97
-    {
98
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
99
-        $inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
100
-        $multisitePlugins = $this->getMultisitePluginDetails();
101
-        return empty($multisitePlugins)
102
-            ? $inactivePlugins
103
-            : array_diff($inactivePlugins, $multisitePlugins);
104
-    }
93
+	/**
94
+	 * @return array
95
+	 */
96
+	public function getInactivePluginDetails()
97
+	{
98
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
99
+		$inactivePlugins = $this->normalizePluginList(array_diff_key(get_plugins(), array_flip($activePlugins)));
100
+		$multisitePlugins = $this->getMultisitePluginDetails();
101
+		return empty($multisitePlugins)
102
+			? $inactivePlugins
103
+			: array_diff($inactivePlugins, $multisitePlugins);
104
+	}
105 105
 
106
-    /**
107
-     * @return array
108
-     */
109
-    public function getMuPluginDetails()
110
-    {
111
-        if (empty($plugins = get_mu_plugins())) {
112
-            return [];
113
-        }
114
-        return $this->normalizePluginList($plugins);
115
-    }
106
+	/**
107
+	 * @return array
108
+	 */
109
+	public function getMuPluginDetails()
110
+	{
111
+		if (empty($plugins = get_mu_plugins())) {
112
+			return [];
113
+		}
114
+		return $this->normalizePluginList($plugins);
115
+	}
116 116
 
117
-    /**
118
-     * @return array
119
-     */
120
-    public function getMultisitePluginDetails()
121
-    {
122
-        $activePlugins = (array) get_site_option('active_sitewide_plugins', []);
123
-        if (!is_multisite() || empty($activePlugins)) {
124
-            return [];
125
-        }
126
-        return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
127
-    }
117
+	/**
118
+	 * @return array
119
+	 */
120
+	public function getMultisitePluginDetails()
121
+	{
122
+		$activePlugins = (array) get_site_option('active_sitewide_plugins', []);
123
+		if (!is_multisite() || empty($activePlugins)) {
124
+			return [];
125
+		}
126
+		return $this->normalizePluginList(array_intersect_key(get_plugins(), $activePlugins));
127
+	}
128 128
 
129
-    /**
130
-     * @return array
131
-     */
132
-    public function getPhpDetails()
133
-    {
134
-        $displayErrors = $this->getINI('display_errors', null)
135
-            ? 'On ('.$this->getINI('display_errors').')'
136
-            : 'N/A';
137
-        $intlSupport = extension_loaded('intl')
138
-            ? phpversion('intl')
139
-            : 'false';
140
-        return [
141
-            'cURL' => var_export(function_exists('curl_init'), true),
142
-            'Default Charset' => $this->getINI('default_charset'),
143
-            'Display Errors' => $displayErrors,
144
-            'fsockopen' => var_export(function_exists('fsockopen'), true),
145
-            'Intl' => $intlSupport,
146
-            'IPv6' => var_export(defined('AF_INET6'), true),
147
-            'Max Execution Time' => $this->getINI('max_execution_time'),
148
-            'Max Input Nesting Level' => $this->getINI('max_input_nesting_level'),
149
-            'Max Input Vars' => $this->getINI('max_input_vars'),
150
-            'Memory Limit' => $this->getINI('memory_limit'),
151
-            'Post Max Size' => $this->getINI('post_max_size'),
152
-            'Sendmail Path' => $this->getINI('sendmail_path'),
153
-            'Session Cookie Path' => esc_html($this->getINI('session.cookie_path')),
154
-            'Session Name' => esc_html($this->getINI('session.name')),
155
-            'Session Save Path' => esc_html($this->getINI('session.save_path')),
156
-            'Session Use Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_cookies', false)), true),
157
-            'Session Use Only Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_only_cookies', false)), true),
158
-            'Upload Max Filesize' => $this->getINI('upload_max_filesize'),
159
-        ];
160
-    }
129
+	/**
130
+	 * @return array
131
+	 */
132
+	public function getPhpDetails()
133
+	{
134
+		$displayErrors = $this->getINI('display_errors', null)
135
+			? 'On ('.$this->getINI('display_errors').')'
136
+			: 'N/A';
137
+		$intlSupport = extension_loaded('intl')
138
+			? phpversion('intl')
139
+			: 'false';
140
+		return [
141
+			'cURL' => var_export(function_exists('curl_init'), true),
142
+			'Default Charset' => $this->getINI('default_charset'),
143
+			'Display Errors' => $displayErrors,
144
+			'fsockopen' => var_export(function_exists('fsockopen'), true),
145
+			'Intl' => $intlSupport,
146
+			'IPv6' => var_export(defined('AF_INET6'), true),
147
+			'Max Execution Time' => $this->getINI('max_execution_time'),
148
+			'Max Input Nesting Level' => $this->getINI('max_input_nesting_level'),
149
+			'Max Input Vars' => $this->getINI('max_input_vars'),
150
+			'Memory Limit' => $this->getINI('memory_limit'),
151
+			'Post Max Size' => $this->getINI('post_max_size'),
152
+			'Sendmail Path' => $this->getINI('sendmail_path'),
153
+			'Session Cookie Path' => esc_html($this->getINI('session.cookie_path')),
154
+			'Session Name' => esc_html($this->getINI('session.name')),
155
+			'Session Save Path' => esc_html($this->getINI('session.save_path')),
156
+			'Session Use Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_cookies', false)), true),
157
+			'Session Use Only Cookies' => var_export(wp_validate_boolean($this->getINI('session.use_only_cookies', false)), true),
158
+			'Upload Max Filesize' => $this->getINI('upload_max_filesize'),
159
+		];
160
+	}
161 161
 
162
-    /**
163
-     * @return array
164
-     */
165
-    public function getReviewsDetails()
166
-    {
167
-        $counts = glsr(RatingManager::class)->ratings([], false);
168
-        $counts = Arr::flatten($counts);
169
-        array_walk($counts, function (&$ratings) use ($counts) {
170
-            if (is_array($ratings)) {
171
-                $ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
172
-                return;
173
-            }
174
-            glsr_log()
175
-                ->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
176
-                ->debug($ratings)
177
-                ->debug($counts);
178
-        });
179
-        ksort($counts);
180
-        return $counts;
181
-    }
162
+	/**
163
+	 * @return array
164
+	 */
165
+	public function getReviewsDetails()
166
+	{
167
+		$counts = glsr(RatingManager::class)->ratings([], false);
168
+		$counts = Arr::flatten($counts);
169
+		array_walk($counts, function (&$ratings) use ($counts) {
170
+			if (is_array($ratings)) {
171
+				$ratings = array_sum($ratings).' ('.implode(', ', $ratings).')';
172
+				return;
173
+			}
174
+			glsr_log()
175
+				->error('$ratings is not an array, possibly due to incorrectly imported reviews.')
176
+				->debug($ratings)
177
+				->debug($counts);
178
+		});
179
+		ksort($counts);
180
+		return $counts;
181
+	}
182 182
 
183
-    /**
184
-     * @return array
185
-     */
186
-    public function getServerDetails()
187
-    {
188
-        global $wpdb;
189
-        return [
190
-            'Host Name' => $this->getHostName(),
191
-            'MySQL Version' => $wpdb->db_version(),
192
-            'PHP Version' => PHP_VERSION,
193
-            'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
194
-        ];
195
-    }
183
+	/**
184
+	 * @return array
185
+	 */
186
+	public function getServerDetails()
187
+	{
188
+		global $wpdb;
189
+		return [
190
+			'Host Name' => $this->getHostName(),
191
+			'MySQL Version' => $wpdb->db_version(),
192
+			'PHP Version' => PHP_VERSION,
193
+			'Server Software' => filter_input(INPUT_SERVER, 'SERVER_SOFTWARE'),
194
+		];
195
+	}
196 196
 
197
-    /**
198
-     * @return array
199
-     */
200
-    public function getSettingDetails()
201
-    {
202
-        $settings = glsr(OptionManager::class)->get('settings', []);
203
-        $settings = Arr::flatten($settings, true);
204
-        $settings = $this->purgeSensitiveData($settings);
205
-        ksort($settings);
206
-        $details = [];
207
-        foreach ($settings as $key => $value) {
208
-            if (Str::startsWith('strings', $key) && Str::endsWith('id', $key)) {
209
-                continue;
210
-            }
211
-            $value = htmlspecialchars(trim(preg_replace('/\s\s+/u', '\\n', $value)), ENT_QUOTES, 'UTF-8');
212
-            $details[$key] = $value;
213
-        }
214
-        return $details;
215
-    }
197
+	/**
198
+	 * @return array
199
+	 */
200
+	public function getSettingDetails()
201
+	{
202
+		$settings = glsr(OptionManager::class)->get('settings', []);
203
+		$settings = Arr::flatten($settings, true);
204
+		$settings = $this->purgeSensitiveData($settings);
205
+		ksort($settings);
206
+		$details = [];
207
+		foreach ($settings as $key => $value) {
208
+			if (Str::startsWith('strings', $key) && Str::endsWith('id', $key)) {
209
+				continue;
210
+			}
211
+			$value = htmlspecialchars(trim(preg_replace('/\s\s+/u', '\\n', $value)), ENT_QUOTES, 'UTF-8');
212
+			$details[$key] = $value;
213
+		}
214
+		return $details;
215
+	}
216 216
 
217
-    /**
218
-     * @return array
219
-     */
220
-    public function getPluginDetails()
221
-    {
222
-        return [
223
-            'Console level' => glsr(Console::class)->humanLevel(),
224
-            'Console size' => glsr(Console::class)->humanSize('0'),
225
-            'Last Migration Run' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_migration_run'), 'unknown'),
226
-            'Last Rating Count' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_review_count'), 'unknown'),
227
-            'Version (current)' => glsr()->version,
228
-            'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
229
-        ];
230
-    }
217
+	/**
218
+	 * @return array
219
+	 */
220
+	public function getPluginDetails()
221
+	{
222
+		return [
223
+			'Console level' => glsr(Console::class)->humanLevel(),
224
+			'Console size' => glsr(Console::class)->humanSize('0'),
225
+			'Last Migration Run' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_migration_run'), 'unknown'),
226
+			'Last Rating Count' => glsr(Date::class)->localized(glsr(OptionManager::class)->get('last_review_count'), 'unknown'),
227
+			'Version (current)' => glsr()->version,
228
+			'Version (previous)' => glsr(OptionManager::class)->get('version_upgraded_from'),
229
+		];
230
+	}
231 231
 
232
-    /**
233
-     * @return array
234
-     */
235
-    public function getWordpressDetails()
236
-    {
237
-        global $wpdb;
238
-        $theme = wp_get_theme();
239
-        return [
240
-            'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
241
-            'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
242
-            'Home URL' => home_url(),
243
-            'Language' => get_locale(),
244
-            'Memory Limit' => WP_MEMORY_LIMIT,
245
-            'Multisite' => var_export(is_multisite(), true),
246
-            'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
247
-            'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
248
-            'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
249
-            'Post Stati' => implode(', ', get_post_stati()),
250
-            'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
251
-            'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
252
-            'Site URL' => site_url(),
253
-            'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', $this->getINI('date.timezone').' (PHP)'),
254
-            'Version' => get_bloginfo('version'),
255
-            'WP Debug' => var_export(defined('WP_DEBUG'), true),
256
-            'WP Max Upload Size' => size_format(wp_max_upload_size()),
257
-            'WP Memory Limit' => WP_MEMORY_LIMIT,
258
-        ];
259
-    }
232
+	/**
233
+	 * @return array
234
+	 */
235
+	public function getWordpressDetails()
236
+	{
237
+		global $wpdb;
238
+		$theme = wp_get_theme();
239
+		return [
240
+			'Active Theme' => sprintf('%s v%s', (string) $theme->Name, (string) $theme->Version),
241
+			'Email Domain' => substr(strrchr(glsr(OptionManager::class)->getWP('admin_email'), '@'), 1),
242
+			'Home URL' => home_url(),
243
+			'Language' => get_locale(),
244
+			'Memory Limit' => WP_MEMORY_LIMIT,
245
+			'Multisite' => var_export(is_multisite(), true),
246
+			'Page For Posts ID' => glsr(OptionManager::class)->getWP('page_for_posts'),
247
+			'Page On Front ID' => glsr(OptionManager::class)->getWP('page_on_front'),
248
+			'Permalink Structure' => glsr(OptionManager::class)->getWP('permalink_structure', 'default'),
249
+			'Post Stati' => implode(', ', get_post_stati()),
250
+			'Remote Post' => glsr(Cache::class)->getRemotePostTest(),
251
+			'Show On Front' => glsr(OptionManager::class)->getWP('show_on_front'),
252
+			'Site URL' => site_url(),
253
+			'Timezone' => glsr(OptionManager::class)->getWP('timezone_string', $this->getINI('date.timezone').' (PHP)'),
254
+			'Version' => get_bloginfo('version'),
255
+			'WP Debug' => var_export(defined('WP_DEBUG'), true),
256
+			'WP Max Upload Size' => size_format(wp_max_upload_size()),
257
+			'WP Memory Limit' => WP_MEMORY_LIMIT,
258
+		];
259
+	}
260 260
 
261
-    /**
262
-     * @return string
263
-     */
264
-    protected function detectWebhostProvider()
265
-    {
266
-        $checks = [
267
-            '.accountservergroup.com' => 'Site5',
268
-            '.gridserver.com' => 'MediaTemple Grid',
269
-            '.inmotionhosting.com' => 'InMotion Hosting',
270
-            '.ovh.net' => 'OVH',
271
-            '.pair.com' => 'pair Networks',
272
-            '.stabletransit.com' => 'Rackspace Cloud',
273
-            '.stratoserver.net' => 'STRATO',
274
-            '.sysfix.eu' => 'SysFix.eu Power Hosting',
275
-            'bluehost.com' => 'Bluehost',
276
-            'DH_USER' => 'DreamHost',
277
-            'Flywheel' => 'Flywheel',
278
-            'ipagemysql.com' => 'iPage',
279
-            'ipowermysql.com' => 'IPower',
280
-            'localhost:/tmp/mysql5.sock' => 'ICDSoft',
281
-            'mysqlv5' => 'NetworkSolutions',
282
-            'PAGELYBIN' => 'Pagely',
283
-            'secureserver.net' => 'GoDaddy',
284
-            'WPE_APIKEY' => 'WP Engine',
285
-        ];
286
-        foreach ($checks as $key => $value) {
287
-            if (!$this->isWebhostCheckValid($key)) {
288
-                continue;
289
-            }
290
-            return $value;
291
-        }
292
-        return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
293
-    }
261
+	/**
262
+	 * @return string
263
+	 */
264
+	protected function detectWebhostProvider()
265
+	{
266
+		$checks = [
267
+			'.accountservergroup.com' => 'Site5',
268
+			'.gridserver.com' => 'MediaTemple Grid',
269
+			'.inmotionhosting.com' => 'InMotion Hosting',
270
+			'.ovh.net' => 'OVH',
271
+			'.pair.com' => 'pair Networks',
272
+			'.stabletransit.com' => 'Rackspace Cloud',
273
+			'.stratoserver.net' => 'STRATO',
274
+			'.sysfix.eu' => 'SysFix.eu Power Hosting',
275
+			'bluehost.com' => 'Bluehost',
276
+			'DH_USER' => 'DreamHost',
277
+			'Flywheel' => 'Flywheel',
278
+			'ipagemysql.com' => 'iPage',
279
+			'ipowermysql.com' => 'IPower',
280
+			'localhost:/tmp/mysql5.sock' => 'ICDSoft',
281
+			'mysqlv5' => 'NetworkSolutions',
282
+			'PAGELYBIN' => 'Pagely',
283
+			'secureserver.net' => 'GoDaddy',
284
+			'WPE_APIKEY' => 'WP Engine',
285
+		];
286
+		foreach ($checks as $key => $value) {
287
+			if (!$this->isWebhostCheckValid($key)) {
288
+				continue;
289
+			}
290
+			return $value;
291
+		}
292
+		return implode(',', array_filter([DB_HOST, filter_input(INPUT_SERVER, 'SERVER_NAME')]));
293
+	}
294 294
 
295
-    /**
296
-     * @return string
297
-     */
298
-    protected function getHostName()
299
-    {
300
-        return sprintf('%s (%s)',
301
-            $this->detectWebhostProvider(),
302
-            Helper::getIpAddress()
303
-        );
304
-    }
295
+	/**
296
+	 * @return string
297
+	 */
298
+	protected function getHostName()
299
+	{
300
+		return sprintf('%s (%s)',
301
+			$this->detectWebhostProvider(),
302
+			Helper::getIpAddress()
303
+		);
304
+	}
305 305
 
306
-    protected function getINI($name, $disabledValue = 'ini_get() is disabled.')
307
-    {
308
-        return function_exists('ini_get')
309
-            ? ini_get($name)
310
-            : $disabledValue;
311
-    }
306
+	protected function getINI($name, $disabledValue = 'ini_get() is disabled.')
307
+	{
308
+		return function_exists('ini_get')
309
+			? ini_get($name)
310
+			: $disabledValue;
311
+	}
312 312
 
313
-    /**
314
-     * @return array
315
-     */
316
-    protected function getWordpressPlugins()
317
-    {
318
-        $plugins = get_plugins();
319
-        $activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
320
-        $inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
321
-        $active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
322
-        return $active + $inactive;
323
-    }
313
+	/**
314
+	 * @return array
315
+	 */
316
+	protected function getWordpressPlugins()
317
+	{
318
+		$plugins = get_plugins();
319
+		$activePlugins = glsr(OptionManager::class)->getWP('active_plugins', [], 'array');
320
+		$inactive = $this->normalizePluginList(array_diff_key($plugins, array_flip($activePlugins)));
321
+		$active = $this->normalizePluginList(array_diff_key($plugins, $inactive));
322
+		return $active + $inactive;
323
+	}
324 324
 
325
-    /**
326
-     * @param string $title
327
-     * @return string
328
-     */
329
-    protected function implode($title, array $details)
330
-    {
331
-        $strings = ['['.$title.']'];
332
-        $padding = max(array_map('strlen', array_keys($details)));
333
-        $padding = max([$padding, static::PAD]);
334
-        foreach ($details as $key => $value) {
335
-            $strings[] = is_string($key)
336
-                ? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
337
-                : ' - '.$value;
338
-        }
339
-        return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
340
-    }
325
+	/**
326
+	 * @param string $title
327
+	 * @return string
328
+	 */
329
+	protected function implode($title, array $details)
330
+	{
331
+		$strings = ['['.$title.']'];
332
+		$padding = max(array_map('strlen', array_keys($details)));
333
+		$padding = max([$padding, static::PAD]);
334
+		foreach ($details as $key => $value) {
335
+			$strings[] = is_string($key)
336
+				? sprintf('%s : %s', str_pad($key, $padding, '.'), $value)
337
+				: ' - '.$value;
338
+		}
339
+		return implode(PHP_EOL, $strings).PHP_EOL.PHP_EOL;
340
+	}
341 341
 
342
-    /**
343
-     * @param string $key
344
-     * @return bool
345
-     */
346
-    protected function isWebhostCheckValid($key)
347
-    {
348
-        return defined($key)
349
-            || filter_input(INPUT_SERVER, $key)
350
-            || Str::contains(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
351
-            || Str::contains(DB_HOST, $key)
352
-            || Str::contains(php_uname(), $key);
353
-    }
342
+	/**
343
+	 * @param string $key
344
+	 * @return bool
345
+	 */
346
+	protected function isWebhostCheckValid($key)
347
+	{
348
+		return defined($key)
349
+			|| filter_input(INPUT_SERVER, $key)
350
+			|| Str::contains(filter_input(INPUT_SERVER, 'SERVER_NAME'), $key)
351
+			|| Str::contains(DB_HOST, $key)
352
+			|| Str::contains(php_uname(), $key);
353
+	}
354 354
 
355
-    /**
356
-     * @return array
357
-     */
358
-    protected function normalizePluginList(array $plugins)
359
-    {
360
-        $plugins = array_map(function ($plugin) {
361
-            return sprintf('%s v%s', Arr::get($plugin, 'Name'), Arr::get($plugin, 'Version'));
362
-        }, $plugins);
363
-        natcasesort($plugins);
364
-        return array_flip($plugins);
365
-    }
355
+	/**
356
+	 * @return array
357
+	 */
358
+	protected function normalizePluginList(array $plugins)
359
+	{
360
+		$plugins = array_map(function ($plugin) {
361
+			return sprintf('%s v%s', Arr::get($plugin, 'Name'), Arr::get($plugin, 'Version'));
362
+		}, $plugins);
363
+		natcasesort($plugins);
364
+		return array_flip($plugins);
365
+	}
366 366
 
367
-    /**
368
-     * @return array
369
-     */
370
-    protected function purgeSensitiveData(array $settings)
371
-    {
372
-        $keys = [
373
-            'general.trustalyze_serial',
374
-            'licenses.',
375
-            'submissions.recaptcha.key',
376
-            'submissions.recaptcha.secret',
377
-        ];
378
-        array_walk($settings, function (&$value, $setting) use ($keys) {
379
-            foreach ($keys as $key) {
380
-                if (!Str::startsWith($key, $setting) || empty($value)) {
381
-                    continue;
382
-                }
383
-                $value = str_repeat('•', 13);
384
-                return;
385
-            }
386
-        });
387
-        return $settings;
388
-    }
367
+	/**
368
+	 * @return array
369
+	 */
370
+	protected function purgeSensitiveData(array $settings)
371
+	{
372
+		$keys = [
373
+			'general.trustalyze_serial',
374
+			'licenses.',
375
+			'submissions.recaptcha.key',
376
+			'submissions.recaptcha.secret',
377
+		];
378
+		array_walk($settings, function (&$value, $setting) use ($keys) {
379
+			foreach ($keys as $key) {
380
+				if (!Str::startsWith($key, $setting) || empty($value)) {
381
+					continue;
382
+				}
383
+				$value = str_repeat('•', 13);
384
+				return;
385
+			}
386
+		});
387
+		return $settings;
388
+	}
389 389
 }
Please login to merge, or discard this patch.
plugin/Modules/Slack.php 1 patch
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -9,138 +9,138 @@
 block discarded – undo
9 9
 
10 10
 class Slack
11 11
 {
12
-    /**
13
-     * @var string
14
-     */
15
-    public $endpoint;
12
+	/**
13
+	 * @var string
14
+	 */
15
+	public $endpoint;
16 16
 
17
-    /**
18
-     * @var array
19
-     */
20
-    public $notification;
17
+	/**
18
+	 * @var array
19
+	 */
20
+	public $notification;
21 21
 
22
-    /**
23
-     * @var Review
24
-     */
25
-    public $review;
22
+	/**
23
+	 * @var Review
24
+	 */
25
+	public $review;
26 26
 
27
-    public function __construct()
28
-    {
29
-        $this->endpoint = glsr(OptionManager::class)->get('settings.general.notification_slack');
30
-    }
27
+	public function __construct()
28
+	{
29
+		$this->endpoint = glsr(OptionManager::class)->get('settings.general.notification_slack');
30
+	}
31 31
 
32
-    /**
33
-     * @return Slack
34
-     */
35
-    public function compose(Review $review, array $notification)
36
-    {
37
-        if (empty($this->endpoint)) {
38
-            return $this;
39
-        }
40
-        $args = shortcode_atts(glsr(SlackDefaults::class)->defaults(), $notification);
41
-        $this->review = $review;
42
-        $notification = [
43
-            'icon_url' => $args['icon_url'],
44
-            'username' => $args['username'],
45
-            'attachments' => [[
46
-                'actions' => $this->buildAction($args),
47
-                'pretext' => $args['pretext'],
48
-                'color' => $args['color'],
49
-                'fallback' => $args['fallback'],
50
-                'fields' => $this->buildFields(),
51
-            ]],
52
-        ];
53
-        $this->notification = glsr()->filterArray('slack/compose', $notification, $this);
54
-        return $this;
55
-    }
32
+	/**
33
+	 * @return Slack
34
+	 */
35
+	public function compose(Review $review, array $notification)
36
+	{
37
+		if (empty($this->endpoint)) {
38
+			return $this;
39
+		}
40
+		$args = shortcode_atts(glsr(SlackDefaults::class)->defaults(), $notification);
41
+		$this->review = $review;
42
+		$notification = [
43
+			'icon_url' => $args['icon_url'],
44
+			'username' => $args['username'],
45
+			'attachments' => [[
46
+				'actions' => $this->buildAction($args),
47
+				'pretext' => $args['pretext'],
48
+				'color' => $args['color'],
49
+				'fallback' => $args['fallback'],
50
+				'fields' => $this->buildFields(),
51
+			]],
52
+		];
53
+		$this->notification = glsr()->filterArray('slack/compose', $notification, $this);
54
+		return $this;
55
+	}
56 56
 
57
-    /**
58
-     * @return WP_Error|array
59
-     */
60
-    public function send()
61
-    {
62
-        if (empty($this->endpoint)) {
63
-            return new WP_Error('slack', 'Slack notification was not sent: missing endpoint');
64
-        }
65
-        return wp_remote_post($this->endpoint, [
66
-            'blocking' => false,
67
-            'body' => json_encode($this->notification),
68
-            'headers' => ['Content-Type' => 'application/json'],
69
-            'httpversion' => '1.0',
70
-            'method' => 'POST',
71
-            'redirection' => 5,
72
-            'sslverify' => false,
73
-            'timeout' => 45,
74
-        ]);
75
-    }
57
+	/**
58
+	 * @return WP_Error|array
59
+	 */
60
+	public function send()
61
+	{
62
+		if (empty($this->endpoint)) {
63
+			return new WP_Error('slack', 'Slack notification was not sent: missing endpoint');
64
+		}
65
+		return wp_remote_post($this->endpoint, [
66
+			'blocking' => false,
67
+			'body' => json_encode($this->notification),
68
+			'headers' => ['Content-Type' => 'application/json'],
69
+			'httpversion' => '1.0',
70
+			'method' => 'POST',
71
+			'redirection' => 5,
72
+			'sslverify' => false,
73
+			'timeout' => 45,
74
+		]);
75
+	}
76 76
 
77
-    /**
78
-     * @return array
79
-     */
80
-    protected function buildAction(array $args)
81
-    {
82
-        return [[
83
-            'text' => $args['button_text'],
84
-            'type' => 'button',
85
-            'url' => $args['button_url'],
86
-        ]];
87
-    }
77
+	/**
78
+	 * @return array
79
+	 */
80
+	protected function buildAction(array $args)
81
+	{
82
+		return [[
83
+			'text' => $args['button_text'],
84
+			'type' => 'button',
85
+			'url' => $args['button_url'],
86
+		]];
87
+	}
88 88
 
89
-    /**
90
-     * @return array
91
-     */
92
-    protected function buildAuthorField()
93
-    {
94
-        $email = !empty($this->review->email)
95
-            ? '<'.$this->review->email.'>'
96
-            : '';
97
-        $author = trim(rtrim($this->review->author).' '.$email);
98
-        return ['value' => implode(' - ', array_filter([$author, $this->review->ip_address]))];
99
-    }
89
+	/**
90
+	 * @return array
91
+	 */
92
+	protected function buildAuthorField()
93
+	{
94
+		$email = !empty($this->review->email)
95
+			? '<'.$this->review->email.'>'
96
+			: '';
97
+		$author = trim(rtrim($this->review->author).' '.$email);
98
+		return ['value' => implode(' - ', array_filter([$author, $this->review->ip_address]))];
99
+	}
100 100
 
101
-    /**
102
-     * @return array
103
-     */
104
-    protected function buildContentField()
105
-    {
106
-        return !empty($this->review->content)
107
-            ? ['value' => $this->review->content]
108
-            : [];
109
-    }
101
+	/**
102
+	 * @return array
103
+	 */
104
+	protected function buildContentField()
105
+	{
106
+		return !empty($this->review->content)
107
+			? ['value' => $this->review->content]
108
+			: [];
109
+	}
110 110
 
111
-    /**
112
-     * @return array
113
-     */
114
-    protected function buildFields()
115
-    {
116
-        $fields = [
117
-            $this->buildStarsField(),
118
-            $this->buildTitleField(),
119
-            $this->buildContentField(),
120
-            $this->buildAuthorField(),
121
-        ];
122
-        return array_filter($fields);
123
-    }
111
+	/**
112
+	 * @return array
113
+	 */
114
+	protected function buildFields()
115
+	{
116
+		$fields = [
117
+			$this->buildStarsField(),
118
+			$this->buildTitleField(),
119
+			$this->buildContentField(),
120
+			$this->buildAuthorField(),
121
+		];
122
+		return array_filter($fields);
123
+	}
124 124
 
125
-    /**
126
-     * @return array
127
-     */
128
-    protected function buildStarsField()
129
-    {
130
-        $solidStars = str_repeat('★', $this->review->rating);
131
-        $emptyStars = str_repeat('☆', max(0, glsr()->constant('MAX_RATING', Rating::class) - $this->review->rating));
132
-        $stars = $solidStars.$emptyStars;
133
-        $stars = glsr()->filterString('slack/stars', $stars, $this->review->rating, glsr()->constant('MAX_RATING', Rating::class));
134
-        return ['title' => $stars];
135
-    }
125
+	/**
126
+	 * @return array
127
+	 */
128
+	protected function buildStarsField()
129
+	{
130
+		$solidStars = str_repeat('★', $this->review->rating);
131
+		$emptyStars = str_repeat('☆', max(0, glsr()->constant('MAX_RATING', Rating::class) - $this->review->rating));
132
+		$stars = $solidStars.$emptyStars;
133
+		$stars = glsr()->filterString('slack/stars', $stars, $this->review->rating, glsr()->constant('MAX_RATING', Rating::class));
134
+		return ['title' => $stars];
135
+	}
136 136
 
137
-    /**
138
-     * @return array
139
-     */
140
-    protected function buildTitleField()
141
-    {
142
-        return !empty($this->review->title)
143
-            ? ['title' => $this->review->title]
144
-            : [];
145
-    }
137
+	/**
138
+	 * @return array
139
+	 */
140
+	protected function buildTitleField()
141
+	{
142
+		return !empty($this->review->title)
143
+			? ['title' => $this->review->title]
144
+			: [];
145
+	}
146 146
 }
Please login to merge, or discard this patch.
plugin/Modules/Translator.php 1 patch
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -6,97 +6,97 @@
 block discarded – undo
6 6
 
7 7
 class Translator
8 8
 {
9
-    /**
10
-     * @param string $original
11
-     * @param string $domain
12
-     * @return string
13
-     */
14
-    public function translate($original, $domain, array $args)
15
-    {
16
-        $domains = glsr()->filterArray('translator/domains', [Application::ID]);
17
-        if (!in_array($domain, $domains)) {
18
-            return $original;
19
-        }
20
-        $args = $this->normalizeTranslationArgs($args);
21
-        $strings = $this->getTranslationStrings($args['single'], $args['plural']);
22
-        if (empty($strings)) {
23
-            return $original;
24
-        }
25
-        $string = current($strings);
26
-        return 'plural' == $string['type']
27
-            ? $this->translatePlural($domain, $string, $args)
28
-            : $this->translateSingle($domain, $string, $args);
29
-    }
9
+	/**
10
+	 * @param string $original
11
+	 * @param string $domain
12
+	 * @return string
13
+	 */
14
+	public function translate($original, $domain, array $args)
15
+	{
16
+		$domains = glsr()->filterArray('translator/domains', [Application::ID]);
17
+		if (!in_array($domain, $domains)) {
18
+			return $original;
19
+		}
20
+		$args = $this->normalizeTranslationArgs($args);
21
+		$strings = $this->getTranslationStrings($args['single'], $args['plural']);
22
+		if (empty($strings)) {
23
+			return $original;
24
+		}
25
+		$string = current($strings);
26
+		return 'plural' == $string['type']
27
+			? $this->translatePlural($domain, $string, $args)
28
+			: $this->translateSingle($domain, $string, $args);
29
+	}
30 30
 
31
-    /**
32
-     * Used when search/replacing a default text-domain translation
33
-     * @return string
34
-     */
35
-    public function getTranslation(array $args)
36
-    {
37
-        $args = $this->normalizeTranslationArgs($args);
38
-        return get_translations_for_domain(Application::ID)->translate_plural($args['single'], $args['plural'], $args['number']);
39
-    }
31
+	/**
32
+	 * Used when search/replacing a default text-domain translation
33
+	 * @return string
34
+	 */
35
+	public function getTranslation(array $args)
36
+	{
37
+		$args = $this->normalizeTranslationArgs($args);
38
+		return get_translations_for_domain(Application::ID)->translate_plural($args['single'], $args['plural'], $args['number']);
39
+	}
40 40
 
41
-    /**
42
-     * @param string $single
43
-     * @param string $plural
44
-     * @return array
45
-     */
46
-    protected function getTranslationStrings($single, $plural)
47
-    {
48
-        return array_filter(glsr(Translation::class)->translations(), function ($string) use ($single, $plural) {
49
-            return $string['s1'] == html_entity_decode($single, ENT_COMPAT, 'UTF-8')
50
-                && $string['p1'] == html_entity_decode($plural, ENT_COMPAT, 'UTF-8');
51
-        });
52
-    }
41
+	/**
42
+	 * @param string $single
43
+	 * @param string $plural
44
+	 * @return array
45
+	 */
46
+	protected function getTranslationStrings($single, $plural)
47
+	{
48
+		return array_filter(glsr(Translation::class)->translations(), function ($string) use ($single, $plural) {
49
+			return $string['s1'] == html_entity_decode($single, ENT_COMPAT, 'UTF-8')
50
+				&& $string['p1'] == html_entity_decode($plural, ENT_COMPAT, 'UTF-8');
51
+		});
52
+	}
53 53
 
54
-    /**
55
-     * @return array
56
-     */
57
-    protected function normalizeTranslationArgs(array $args)
58
-    {
59
-        $defaults = [
60
-            'context' => '',
61
-            'number' => 1,
62
-            'plural' => '',
63
-            'single' => '',
64
-        ];
65
-        return shortcode_atts($defaults, $args);
66
-    }
54
+	/**
55
+	 * @return array
56
+	 */
57
+	protected function normalizeTranslationArgs(array $args)
58
+	{
59
+		$defaults = [
60
+			'context' => '',
61
+			'number' => 1,
62
+			'plural' => '',
63
+			'single' => '',
64
+		];
65
+		return shortcode_atts($defaults, $args);
66
+	}
67 67
 
68
-    /**
69
-     * @param string $domain
70
-     * @return string
71
-     */
72
-    protected function translatePlural($domain, array $string, array $args)
73
-    {
74
-        if (!empty($string['s2'])) {
75
-            $args['single'] = $string['s2'];
76
-        }
77
-        if (!empty($string['p2'])) {
78
-            $args['plural'] = $string['p2'];
79
-        }
80
-        return get_translations_for_domain($domain)->translate_plural(
81
-            $args['single'],
82
-            $args['plural'],
83
-            $args['number'],
84
-            $args['context']
85
-        );
86
-    }
68
+	/**
69
+	 * @param string $domain
70
+	 * @return string
71
+	 */
72
+	protected function translatePlural($domain, array $string, array $args)
73
+	{
74
+		if (!empty($string['s2'])) {
75
+			$args['single'] = $string['s2'];
76
+		}
77
+		if (!empty($string['p2'])) {
78
+			$args['plural'] = $string['p2'];
79
+		}
80
+		return get_translations_for_domain($domain)->translate_plural(
81
+			$args['single'],
82
+			$args['plural'],
83
+			$args['number'],
84
+			$args['context']
85
+		);
86
+	}
87 87
 
88
-    /**
89
-     * @param string $domain
90
-     * @return string
91
-     */
92
-    protected function translateSingle($domain, array $string, array $args)
93
-    {
94
-        if (!empty($string['s2'])) {
95
-            $args['single'] = $string['s2'];
96
-        }
97
-        return get_translations_for_domain($domain)->translate(
98
-            $args['single'],
99
-            $args['context']
100
-        );
101
-    }
88
+	/**
89
+	 * @param string $domain
90
+	 * @return string
91
+	 */
92
+	protected function translateSingle($domain, array $string, array $args)
93
+	{
94
+		if (!empty($string['s2'])) {
95
+			$args['single'] = $string['s2'];
96
+		}
97
+		return get_translations_for_domain($domain)->translate(
98
+			$args['single'],
99
+			$args['context']
100
+		);
101
+	}
102 102
 }
Please login to merge, or discard this patch.
plugin/Modules/Validator/AkismetValidator.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -8,80 +8,80 @@
 block discarded – undo
8 8
 
9 9
 class AkismetValidator
10 10
 {
11
-    /**
12
-     * @return bool
13
-     */
14
-    public function isValid(array $review)
15
-    {
16
-        if (!$this->isActive()) {
17
-            return true;
18
-        }
19
-        $submission = [
20
-            'blog' => glsr(OptionManager::class)->getWP('home'),
21
-            'blog_charset' => glsr(OptionManager::class)->getWP('blog_charset', 'UTF-8'),
22
-            'blog_lang' => get_locale(),
23
-            'comment_author' => $review['name'],
24
-            'comment_author_email' => $review['email'],
25
-            'comment_content' => $review['title']."\n\n".$review['content'],
26
-            'comment_type' => 'review',
27
-            'referrer' => filter_input(INPUT_SERVER, 'HTTP_REFERER'),
28
-            'user_agent' => filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'),
29
-            'user_ip' => $review['ip_address'],
30
-            // 'user_role' => 'administrator',
31
-            // 'is_test' => 1,
32
-        ];
33
-        foreach ($_SERVER as $key => $value) {
34
-            if (!is_array($value) && !in_array($key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'])) {
35
-                $submission[$key] = $value;
36
-            }
37
-        }
38
-        return $this->validate(
39
-            glsr()->filterArray('validate/akismet/submission', $submission, $review)
40
-        );
41
-    }
11
+	/**
12
+	 * @return bool
13
+	 */
14
+	public function isValid(array $review)
15
+	{
16
+		if (!$this->isActive()) {
17
+			return true;
18
+		}
19
+		$submission = [
20
+			'blog' => glsr(OptionManager::class)->getWP('home'),
21
+			'blog_charset' => glsr(OptionManager::class)->getWP('blog_charset', 'UTF-8'),
22
+			'blog_lang' => get_locale(),
23
+			'comment_author' => $review['name'],
24
+			'comment_author_email' => $review['email'],
25
+			'comment_content' => $review['title']."\n\n".$review['content'],
26
+			'comment_type' => 'review',
27
+			'referrer' => filter_input(INPUT_SERVER, 'HTTP_REFERER'),
28
+			'user_agent' => filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'),
29
+			'user_ip' => $review['ip_address'],
30
+			// 'user_role' => 'administrator',
31
+			// 'is_test' => 1,
32
+		];
33
+		foreach ($_SERVER as $key => $value) {
34
+			if (!is_array($value) && !in_array($key, ['HTTP_COOKIE', 'HTTP_COOKIE2', 'PHP_AUTH_PW'])) {
35
+				$submission[$key] = $value;
36
+			}
37
+		}
38
+		return $this->validate(
39
+			glsr()->filterArray('validate/akismet/submission', $submission, $review)
40
+		);
41
+	}
42 42
 
43
-    /**
44
-     * @return string
45
-     */
46
-    protected function buildQuery(array $data)
47
-    {
48
-        $query = [];
49
-        foreach ($data as $key => $value) {
50
-            if (is_array($value) || is_object($value)) {
51
-                continue;
52
-            }
53
-            if (false === $value) {
54
-                $value = '0';
55
-            }
56
-            $value = trim($value);
57
-            if (!strlen($value)) {
58
-                continue;
59
-            }
60
-            $query[] = urlencode($key).'='.urlencode($value);
61
-        }
62
-        return implode('&', $query);
63
-    }
43
+	/**
44
+	 * @return string
45
+	 */
46
+	protected function buildQuery(array $data)
47
+	{
48
+		$query = [];
49
+		foreach ($data as $key => $value) {
50
+			if (is_array($value) || is_object($value)) {
51
+				continue;
52
+			}
53
+			if (false === $value) {
54
+				$value = '0';
55
+			}
56
+			$value = trim($value);
57
+			if (!strlen($value)) {
58
+				continue;
59
+			}
60
+			$query[] = urlencode($key).'='.urlencode($value);
61
+		}
62
+		return implode('&', $query);
63
+	}
64 64
 
65
-    /**
66
-     * @return bool
67
-     */
68
-    protected function isActive()
69
-    {
70
-        $check = !glsr(OptionManager::class)->getBool('settings.submissions.akismet')
71
-            || !is_callable(['Akismet', 'get_api_key'])
72
-            || !is_callable(['Akismet', 'http_post'])
73
-            ? false
74
-            : Akismet::get_api_key();
75
-        return glsr()->filterBool('validate/akismet/is-active', $check);
76
-    }
65
+	/**
66
+	 * @return bool
67
+	 */
68
+	protected function isActive()
69
+	{
70
+		$check = !glsr(OptionManager::class)->getBool('settings.submissions.akismet')
71
+			|| !is_callable(['Akismet', 'get_api_key'])
72
+			|| !is_callable(['Akismet', 'http_post'])
73
+			? false
74
+			: Akismet::get_api_key();
75
+		return glsr()->filterBool('validate/akismet/is-active', $check);
76
+	}
77 77
 
78
-    /**
79
-     * @return bool
80
-     */
81
-    protected function validate(array $submission)
82
-    {
83
-        $response = Akismet::http_post($this->buildQuery($submission), 'comment-check');
84
-        $result = 'true' !== $response[1];
85
-        return glsr()->filterBool('validate/akismet', $result, $submission, $response);
86
-    }
78
+	/**
79
+	 * @return bool
80
+	 */
81
+	protected function validate(array $submission)
82
+	{
83
+		$response = Akismet::http_post($this->buildQuery($submission), 'comment-check');
84
+		$result = 'true' !== $response[1];
85
+		return glsr()->filterBool('validate/akismet', $result, $submission, $response);
86
+	}
87 87
 }
Please login to merge, or discard this patch.