Passed
Push — master ( 925e6d...054ae2 )
by Paul
08:03 queued 03:39
created
plugin/Modules/Html/Attributes.php 1 patch
Indentation   +253 added lines, -253 removed lines patch added patch discarded remove patch
@@ -6,285 +6,285 @@
 block discarded – undo
6 6
 
7 7
 class Attributes
8 8
 {
9
-    const ATTRIBUTES_A = [
10
-        'download', 'href', 'hreflang', 'ping', 'referrerpolicy', 'rel', 'target', 'type',
11
-    ];
9
+	const ATTRIBUTES_A = [
10
+		'download', 'href', 'hreflang', 'ping', 'referrerpolicy', 'rel', 'target', 'type',
11
+	];
12 12
 
13
-    const ATTRIBUTES_BUTTON = [
14
-        'autofocus', 'disabled', 'form', 'formaction', 'formenctype', 'formmethod',
15
-        'formnovalidate', 'formtarget', 'name', 'type', 'value',
16
-    ];
13
+	const ATTRIBUTES_BUTTON = [
14
+		'autofocus', 'disabled', 'form', 'formaction', 'formenctype', 'formmethod',
15
+		'formnovalidate', 'formtarget', 'name', 'type', 'value',
16
+	];
17 17
 
18
-    const ATTRIBUTES_FORM = [
19
-        'accept', 'accept-charset', 'action', 'autocapitalize', 'autocomplete', 'enctype', 'method',
20
-        'name', 'novalidate', 'target',
21
-    ];
18
+	const ATTRIBUTES_FORM = [
19
+		'accept', 'accept-charset', 'action', 'autocapitalize', 'autocomplete', 'enctype', 'method',
20
+		'name', 'novalidate', 'target',
21
+	];
22 22
 
23
-    const ATTRIBUTES_IMG = [
24
-        'alt', 'crossorigin', 'decoding', 'height', 'ismap', 'referrerpolicy', 'sizes', 'src',
25
-        'srcset', 'width', 'usemap',
26
-    ];
23
+	const ATTRIBUTES_IMG = [
24
+		'alt', 'crossorigin', 'decoding', 'height', 'ismap', 'referrerpolicy', 'sizes', 'src',
25
+		'srcset', 'width', 'usemap',
26
+	];
27 27
 
28
-    const ATTRIBUTES_INPUT = [
29
-        'accept', 'autocomplete', 'autocorrect', 'autofocus', 'capture', 'checked', 'disabled',
30
-        'form', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'height',
31
-        'incremental', 'inputmode', 'list', 'max', 'maxlength', 'min', 'minlength', 'multiple',
32
-        'name', 'pattern', 'placeholder', 'readonly', 'results', 'required', 'selectionDirection',
33
-        'selectionEnd', 'selectionStart', 'size', 'spellcheck', 'src', 'step', 'tabindex', 'type',
34
-        'value', 'webkitdirectory', 'width',
35
-    ];
28
+	const ATTRIBUTES_INPUT = [
29
+		'accept', 'autocomplete', 'autocorrect', 'autofocus', 'capture', 'checked', 'disabled',
30
+		'form', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'height',
31
+		'incremental', 'inputmode', 'list', 'max', 'maxlength', 'min', 'minlength', 'multiple',
32
+		'name', 'pattern', 'placeholder', 'readonly', 'results', 'required', 'selectionDirection',
33
+		'selectionEnd', 'selectionStart', 'size', 'spellcheck', 'src', 'step', 'tabindex', 'type',
34
+		'value', 'webkitdirectory', 'width',
35
+	];
36 36
 
37
-    const ATTRIBUTES_LABEL = [
38
-        'for',
39
-    ];
37
+	const ATTRIBUTES_LABEL = [
38
+		'for',
39
+	];
40 40
 
41
-    const ATTRIBUTES_OPTION = [
42
-        'disabled', 'label', 'selected', 'value',
43
-    ];
41
+	const ATTRIBUTES_OPTION = [
42
+		'disabled', 'label', 'selected', 'value',
43
+	];
44 44
 
45
-    const ATTRIBUTES_SELECT = [
46
-        'autofocus', 'disabled', 'form', 'multiple', 'name', 'required', 'size',
47
-    ];
45
+	const ATTRIBUTES_SELECT = [
46
+		'autofocus', 'disabled', 'form', 'multiple', 'name', 'required', 'size',
47
+	];
48 48
 
49
-    const ATTRIBUTES_TEXTAREA = [
50
-        'autocapitalize', 'autocomplete', 'autofocus', 'cols', 'disabled', 'form', 'maxlength',
51
-        'minlength', 'name', 'placeholder', 'readonly', 'required', 'rows', 'spellcheck', 'wrap',
52
-    ];
49
+	const ATTRIBUTES_TEXTAREA = [
50
+		'autocapitalize', 'autocomplete', 'autofocus', 'cols', 'disabled', 'form', 'maxlength',
51
+		'minlength', 'name', 'placeholder', 'readonly', 'required', 'rows', 'spellcheck', 'wrap',
52
+	];
53 53
 
54
-    const BOOLEAN_ATTRIBUTES = [
55
-        'autofocus', 'capture', 'checked', 'disabled', 'draggable', 'formnovalidate', 'hidden',
56
-        'multiple', 'novalidate', 'readonly', 'required', 'selected', 'spellcheck',
57
-        'webkitdirectory',
58
-    ];
54
+	const BOOLEAN_ATTRIBUTES = [
55
+		'autofocus', 'capture', 'checked', 'disabled', 'draggable', 'formnovalidate', 'hidden',
56
+		'multiple', 'novalidate', 'readonly', 'required', 'selected', 'spellcheck',
57
+		'webkitdirectory',
58
+	];
59 59
 
60
-    const GLOBAL_ATTRIBUTES = [
61
-        'accesskey', 'class', 'contenteditable', 'contextmenu', 'dir', 'draggable', 'dropzone',
62
-        'hidden', 'id', 'lang', 'spellcheck', 'style', 'tabindex', 'title',
63
-    ];
60
+	const GLOBAL_ATTRIBUTES = [
61
+		'accesskey', 'class', 'contenteditable', 'contextmenu', 'dir', 'draggable', 'dropzone',
62
+		'hidden', 'id', 'lang', 'spellcheck', 'style', 'tabindex', 'title',
63
+	];
64 64
 
65
-    const GLOBAL_WILDCARD_ATTRIBUTES = [
66
-        'aria-', 'data-', 'item', 'on',
67
-    ];
65
+	const GLOBAL_WILDCARD_ATTRIBUTES = [
66
+		'aria-', 'data-', 'item', 'on',
67
+	];
68 68
 
69
-    const INPUT_TYPES = [
70
-        'button', 'checkbox', 'color', 'date', 'datetime-local', 'email', 'file', 'hidden', 'image',
71
-        'month', 'number', 'password', 'radio', 'range', 'reset', 'search', 'submit', 'tel', 'text',
72
-        'time', 'url', 'week',
73
-    ];
69
+	const INPUT_TYPES = [
70
+		'button', 'checkbox', 'color', 'date', 'datetime-local', 'email', 'file', 'hidden', 'image',
71
+		'month', 'number', 'password', 'radio', 'range', 'reset', 'search', 'submit', 'tel', 'text',
72
+		'time', 'url', 'week',
73
+	];
74 74
 
75
-    /**
76
-     * @var array
77
-     */
78
-    protected $attributes = [];
75
+	/**
76
+	 * @var array
77
+	 */
78
+	protected $attributes = [];
79 79
 
80
-    /**
81
-     * @param string $method
82
-     * @param array $args
83
-     * @return static
84
-     */
85
-    public function __call($method, $args)
86
-    {
87
-        $args += [[], false];
88
-        $constant = 'static::ATTRIBUTES_'.strtoupper($method);
89
-        $allowedAttributeKeys = defined($constant)
90
-            ? constant($constant)
91
-            : [];
92
-        $this->normalize((array) $args[0], $allowedAttributeKeys);
93
-        $this->normalizeInputType($method);
94
-        return $this;
95
-    }
80
+	/**
81
+	 * @param string $method
82
+	 * @param array $args
83
+	 * @return static
84
+	 */
85
+	public function __call($method, $args)
86
+	{
87
+		$args += [[], false];
88
+		$constant = 'static::ATTRIBUTES_'.strtoupper($method);
89
+		$allowedAttributeKeys = defined($constant)
90
+			? constant($constant)
91
+			: [];
92
+		$this->normalize((array) $args[0], $allowedAttributeKeys);
93
+		$this->normalizeInputType($method);
94
+		return $this;
95
+	}
96 96
 
97
-    /**
98
-     * @return array
99
-     */
100
-    public function toArray()
101
-    {
102
-        return $this->attributes;
103
-    }
97
+	/**
98
+	 * @return array
99
+	 */
100
+	public function toArray()
101
+	{
102
+		return $this->attributes;
103
+	}
104 104
 
105
-    /**
106
-     * @return string
107
-     */
108
-    public function toString()
109
-    {
110
-        $attributes = [];
111
-        foreach ($this->attributes as $attribute => $value) {
112
-            $quote = $this->getQuoteChar($attribute);
113
-            $attributes[] = in_array($attribute, static::BOOLEAN_ATTRIBUTES)
114
-                ? $attribute
115
-                : $attribute.'='.$quote.implode(',', (array) $value).$quote;
116
-        }
117
-        return implode(' ', $attributes);
118
-    }
105
+	/**
106
+	 * @return string
107
+	 */
108
+	public function toString()
109
+	{
110
+		$attributes = [];
111
+		foreach ($this->attributes as $attribute => $value) {
112
+			$quote = $this->getQuoteChar($attribute);
113
+			$attributes[] = in_array($attribute, static::BOOLEAN_ATTRIBUTES)
114
+				? $attribute
115
+				: $attribute.'='.$quote.implode(',', (array) $value).$quote;
116
+		}
117
+		return implode(' ', $attributes);
118
+	}
119 119
 
120
-    /**
121
-     * @return array
122
-     */
123
-    protected function filterAttributes(array $allowedAttributeKeys)
124
-    {
125
-        return array_intersect_key($this->attributes, array_flip($allowedAttributeKeys));
126
-    }
120
+	/**
121
+	 * @return array
122
+	 */
123
+	protected function filterAttributes(array $allowedAttributeKeys)
124
+	{
125
+		return array_intersect_key($this->attributes, array_flip($allowedAttributeKeys));
126
+	}
127 127
 
128
-    /**
129
-     * @return array
130
-     */
131
-    protected function filterGlobalAttributes()
132
-    {
133
-        $globalAttributes = $this->filterAttributes(static::GLOBAL_ATTRIBUTES);
134
-        $wildcards = [];
135
-        foreach (static::GLOBAL_WILDCARD_ATTRIBUTES as $wildcard) {
136
-            $newWildcards = array_filter($this->attributes, function ($key) use ($wildcard) {
137
-                return Str::startsWith($wildcard, $key);
138
-            }, ARRAY_FILTER_USE_KEY);
139
-            $wildcards = array_merge($wildcards, $newWildcards);
140
-        }
141
-        return array_merge($globalAttributes, $wildcards);
142
-    }
128
+	/**
129
+	 * @return array
130
+	 */
131
+	protected function filterGlobalAttributes()
132
+	{
133
+		$globalAttributes = $this->filterAttributes(static::GLOBAL_ATTRIBUTES);
134
+		$wildcards = [];
135
+		foreach (static::GLOBAL_WILDCARD_ATTRIBUTES as $wildcard) {
136
+			$newWildcards = array_filter($this->attributes, function ($key) use ($wildcard) {
137
+				return Str::startsWith($wildcard, $key);
138
+			}, ARRAY_FILTER_USE_KEY);
139
+			$wildcards = array_merge($wildcards, $newWildcards);
140
+		}
141
+		return array_merge($globalAttributes, $wildcards);
142
+	}
143 143
 
144
-    /**
145
-     * @return array
146
-     */
147
-    protected function getPermanentAttributes()
148
-    {
149
-        $permanentAttributes = [];
150
-        if (array_key_exists('value', $this->attributes)) {
151
-            $permanentAttributes['value'] = $this->attributes['value'];
152
-        }
153
-        return $permanentAttributes;
154
-    }
144
+	/**
145
+	 * @return array
146
+	 */
147
+	protected function getPermanentAttributes()
148
+	{
149
+		$permanentAttributes = [];
150
+		if (array_key_exists('value', $this->attributes)) {
151
+			$permanentAttributes['value'] = $this->attributes['value'];
152
+		}
153
+		return $permanentAttributes;
154
+	}
155 155
 
156
-    /**
157
-     * @param string $attribute
158
-     * @return string
159
-     */
160
-    protected function getQuoteChar($attribute)
161
-    {
162
-        return Str::startsWith('data-', $attribute)
163
-            ? '\''
164
-            : '"';
165
-    }
156
+	/**
157
+	 * @param string $attribute
158
+	 * @return string
159
+	 */
160
+	protected function getQuoteChar($attribute)
161
+	{
162
+		return Str::startsWith('data-', $attribute)
163
+			? '\''
164
+			: '"';
165
+	}
166 166
 
167
-    /**
168
-     * @param string $key
169
-     * @param mixed $value
170
-     * @return bool
171
-     */
172
-    protected function isAttributeKeyNumeric($key, $value)
173
-    {
174
-        return is_string($value)
175
-            && is_numeric($key)
176
-            && !array_key_exists($value, $this->attributes);
177
-    }
167
+	/**
168
+	 * @param string $key
169
+	 * @param mixed $value
170
+	 * @return bool
171
+	 */
172
+	protected function isAttributeKeyNumeric($key, $value)
173
+	{
174
+		return is_string($value)
175
+			&& is_numeric($key)
176
+			&& !array_key_exists($value, $this->attributes);
177
+	}
178 178
 
179
-    /**
180
-     * @return void
181
-     */
182
-    protected function normalize(array $args, array $allowedAttributeKeys)
183
-    {
184
-        $this->attributes = array_change_key_case($args, CASE_LOWER);
185
-        $this->normalizeBooleanAttributes();
186
-        $this->normalizeDataAttributes();
187
-        $this->normalizeStringAttributes();
188
-        $this->removeEmptyAttributes();
189
-        $this->removeIndexedAttributes();
190
-        $this->attributes = array_merge(
191
-            $this->filterGlobalAttributes(),
192
-            $this->filterAttributes($allowedAttributeKeys)
193
-        );
194
-    }
179
+	/**
180
+	 * @return void
181
+	 */
182
+	protected function normalize(array $args, array $allowedAttributeKeys)
183
+	{
184
+		$this->attributes = array_change_key_case($args, CASE_LOWER);
185
+		$this->normalizeBooleanAttributes();
186
+		$this->normalizeDataAttributes();
187
+		$this->normalizeStringAttributes();
188
+		$this->removeEmptyAttributes();
189
+		$this->removeIndexedAttributes();
190
+		$this->attributes = array_merge(
191
+			$this->filterGlobalAttributes(),
192
+			$this->filterAttributes($allowedAttributeKeys)
193
+		);
194
+	}
195 195
 
196
-    /**
197
-     * @return void
198
-     */
199
-    protected function normalizeBooleanAttributes()
200
-    {
201
-        foreach ($this->attributes as $key => $value) {
202
-            if ($this->isAttributeKeyNumeric($key, $value)) {
203
-                $key = $value;
204
-                $value = true;
205
-            }
206
-            if (!in_array($key, static::BOOLEAN_ATTRIBUTES)) {
207
-                continue;
208
-            }
209
-            $this->attributes[$key] = wp_validate_boolean($value);
210
-        }
211
-    }
196
+	/**
197
+	 * @return void
198
+	 */
199
+	protected function normalizeBooleanAttributes()
200
+	{
201
+		foreach ($this->attributes as $key => $value) {
202
+			if ($this->isAttributeKeyNumeric($key, $value)) {
203
+				$key = $value;
204
+				$value = true;
205
+			}
206
+			if (!in_array($key, static::BOOLEAN_ATTRIBUTES)) {
207
+				continue;
208
+			}
209
+			$this->attributes[$key] = wp_validate_boolean($value);
210
+		}
211
+	}
212 212
 
213
-    /**
214
-     * @return void
215
-     */
216
-    protected function normalizeDataAttributes()
217
-    {
218
-        foreach ($this->attributes as $key => $value) {
219
-            if ($this->isAttributeKeyNumeric($key, $value)) {
220
-                $key = $value;
221
-                $value = '';
222
-            }
223
-            if (!Str::startsWith('data-', $key)) {
224
-                continue;
225
-            }
226
-            if (is_array($value)) {
227
-                $value = json_encode($value, JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
228
-            }
229
-            $this->attributes[$key] = $value;
230
-        }
231
-    }
213
+	/**
214
+	 * @return void
215
+	 */
216
+	protected function normalizeDataAttributes()
217
+	{
218
+		foreach ($this->attributes as $key => $value) {
219
+			if ($this->isAttributeKeyNumeric($key, $value)) {
220
+				$key = $value;
221
+				$value = '';
222
+			}
223
+			if (!Str::startsWith('data-', $key)) {
224
+				continue;
225
+			}
226
+			if (is_array($value)) {
227
+				$value = json_encode($value, JSON_HEX_APOS | JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
228
+			}
229
+			$this->attributes[$key] = $value;
230
+		}
231
+	}
232 232
 
233
-    /**
234
-     * @return void
235
-     */
236
-    protected function normalizeStringAttributes()
237
-    {
238
-        foreach ($this->attributes as $key => $value) {
239
-            if (!is_string($value)) {
240
-                continue;
241
-            }
242
-            $this->attributes[$key] = trim($value);
243
-        }
244
-    }
233
+	/**
234
+	 * @return void
235
+	 */
236
+	protected function normalizeStringAttributes()
237
+	{
238
+		foreach ($this->attributes as $key => $value) {
239
+			if (!is_string($value)) {
240
+				continue;
241
+			}
242
+			$this->attributes[$key] = trim($value);
243
+		}
244
+	}
245 245
 
246
-    /**
247
-     * @param string $method
248
-     * @return void
249
-     */
250
-    protected function normalizeInputType($method)
251
-    {
252
-        if ('input' != $method) {
253
-            return;
254
-        }
255
-        $attributes = wp_parse_args($this->attributes, ['type' => '']);
256
-        if (!in_array($attributes['type'], static::INPUT_TYPES)) {
257
-            $this->attributes['type'] = 'text';
258
-        }
259
-    }
246
+	/**
247
+	 * @param string $method
248
+	 * @return void
249
+	 */
250
+	protected function normalizeInputType($method)
251
+	{
252
+		if ('input' != $method) {
253
+			return;
254
+		}
255
+		$attributes = wp_parse_args($this->attributes, ['type' => '']);
256
+		if (!in_array($attributes['type'], static::INPUT_TYPES)) {
257
+			$this->attributes['type'] = 'text';
258
+		}
259
+	}
260 260
 
261
-    /**
262
-     * @return void
263
-     */
264
-    protected function removeEmptyAttributes()
265
-    {
266
-        $attributes = $this->attributes;
267
-        $permanentAttributes = $this->getPermanentAttributes();
268
-        foreach ($this->attributes as $key => $value) {
269
-            if (in_array($key, static::BOOLEAN_ATTRIBUTES) && !$value) {
270
-                unset($attributes[$key]);
271
-            }
272
-            if (Str::startsWith('data-', $key)) {
273
-                $permanentAttributes[$key] = $value;
274
-                unset($attributes[$key]);
275
-            }
276
-        }
277
-        $this->attributes = array_merge(array_filter($attributes), $permanentAttributes);
278
-    }
261
+	/**
262
+	 * @return void
263
+	 */
264
+	protected function removeEmptyAttributes()
265
+	{
266
+		$attributes = $this->attributes;
267
+		$permanentAttributes = $this->getPermanentAttributes();
268
+		foreach ($this->attributes as $key => $value) {
269
+			if (in_array($key, static::BOOLEAN_ATTRIBUTES) && !$value) {
270
+				unset($attributes[$key]);
271
+			}
272
+			if (Str::startsWith('data-', $key)) {
273
+				$permanentAttributes[$key] = $value;
274
+				unset($attributes[$key]);
275
+			}
276
+		}
277
+		$this->attributes = array_merge(array_filter($attributes), $permanentAttributes);
278
+	}
279 279
 
280
-    /**
281
-     * @return void
282
-     */
283
-    protected function removeIndexedAttributes()
284
-    {
285
-        $this->attributes = array_diff_key(
286
-            $this->attributes,
287
-            array_filter($this->attributes, 'is_numeric', ARRAY_FILTER_USE_KEY)
288
-        );
289
-    }
280
+	/**
281
+	 * @return void
282
+	 */
283
+	protected function removeIndexedAttributes()
284
+	{
285
+		$this->attributes = array_diff_key(
286
+			$this->attributes,
287
+			array_filter($this->attributes, 'is_numeric', ARRAY_FILTER_USE_KEY)
288
+		);
289
+	}
290 290
 }
Please login to merge, or discard this patch.
plugin/Modules/Html/Partial.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -6,30 +6,30 @@
 block discarded – undo
6 6
 
7 7
 class Partial
8 8
 {
9
-    /**
10
-     * @param string $partialPath
11
-     * @return string
12
-     */
13
-    public function build($partialPath, array $args = [])
14
-    {
15
-        $className = Helper::buildClassName($partialPath, 'Modules\Html\Partials');
16
-        if (!class_exists($className)) {
17
-            glsr_log()->error('Partial missing: '.$className);
18
-            return;
19
-        }
20
-        $args = apply_filters('site-reviews/partial/args/'.$partialPath, $args);
21
-        $partial = glsr($className)->build($args);
22
-        $partial = apply_filters('site-reviews/rendered/partial', $partial, $partialPath, $args);
23
-        $partial = apply_filters('site-reviews/rendered/partial/'.$partialPath, $partial, $args);
24
-        return $partial;
25
-    }
9
+	/**
10
+	 * @param string $partialPath
11
+	 * @return string
12
+	 */
13
+	public function build($partialPath, array $args = [])
14
+	{
15
+		$className = Helper::buildClassName($partialPath, 'Modules\Html\Partials');
16
+		if (!class_exists($className)) {
17
+			glsr_log()->error('Partial missing: '.$className);
18
+			return;
19
+		}
20
+		$args = apply_filters('site-reviews/partial/args/'.$partialPath, $args);
21
+		$partial = glsr($className)->build($args);
22
+		$partial = apply_filters('site-reviews/rendered/partial', $partial, $partialPath, $args);
23
+		$partial = apply_filters('site-reviews/rendered/partial/'.$partialPath, $partial, $args);
24
+		return $partial;
25
+	}
26 26
 
27
-    /**
28
-     * @param string $partialPath
29
-     * @return void
30
-     */
31
-    public function render($partialPath, array $args = [])
32
-    {
33
-        echo $this->build($partialPath, $args);
34
-    }
27
+	/**
28
+	 * @param string $partialPath
29
+	 * @return void
30
+	 */
31
+	public function render($partialPath, array $args = [])
32
+	{
33
+		echo $this->build($partialPath, $args);
34
+	}
35 35
 }
Please login to merge, or discard this patch.
plugin/Modules/Upgrader/Upgrade_4_0_2.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -9,67 +9,67 @@
 block discarded – undo
9 9
 
10 10
 class Upgrade_4_0_2
11 11
 {
12
-    public function __construct()
13
-    {
14
-        $this->migrateSettings();
15
-        $this->protectMetaKeys();
16
-        $this->deleteSessions();
17
-        delete_transient(Application::ID.'_cloudflare_ips');
18
-    }
12
+	public function __construct()
13
+	{
14
+		$this->migrateSettings();
15
+		$this->protectMetaKeys();
16
+		$this->deleteSessions();
17
+		delete_transient(Application::ID.'_cloudflare_ips');
18
+	}
19 19
 
20
-    /**
21
-     * @return void
22
-     */
23
-    public function deleteSessions()
24
-    {
25
-        global $wpdb;
26
-        $wpdb->query("
20
+	/**
21
+	 * @return void
22
+	 */
23
+	public function deleteSessions()
24
+	{
25
+		global $wpdb;
26
+		$wpdb->query("
27 27
             DELETE
28 28
             FROM {$wpdb->options}
29 29
             WHERE option_name LIKE '_glsr_session%'
30 30
         ");
31
-    }
31
+	}
32 32
 
33
-    /**
34
-     * @return void
35
-     */
36
-    public function migrateSettings()
37
-    {
38
-        if ($settings = get_option(OptionManager::databaseKey(3))) {
39
-            $multilingual = 'yes' == Arr::get($settings, 'settings.general.support.polylang')
40
-                ? 'polylang'
41
-                : '';
42
-            $settings = Arr::set($settings, 'settings.general.multilingual', $multilingual);
43
-            $settings = Arr::set($settings, 'settings.general.rebusify', 'no');
44
-            $settings = Arr::set($settings, 'settings.general.rebusify_email', '');
45
-            $settings = Arr::set($settings, 'settings.general.rebusify_serial', '');
46
-            $settings = Arr::set($settings, 'settings.reviews.name.format', '');
47
-            $settings = Arr::set($settings, 'settings.reviews.name.initial', '');
48
-            $settings = Arr::set($settings, 'settings.submissions.blacklist.integration', '');
49
-            $settings = Arr::set($settings, 'settings.submissions.limit', '');
50
-            $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.email', '');
51
-            $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.ip_address', '');
52
-            $settings = Arr::set($settings, 'settings.submissions.limit_whitelist.username', '');
53
-            unset($settings['settings']['general']['support']);
54
-            update_option(OptionManager::databaseKey(4), $settings);
55
-        }
56
-    }
33
+	/**
34
+	 * @return void
35
+	 */
36
+	public function migrateSettings()
37
+	{
38
+		if ($settings = get_option(OptionManager::databaseKey(3))) {
39
+			$multilingual = 'yes' == Arr::get($settings, 'settings.general.support.polylang')
40
+				? 'polylang'
41
+				: '';
42
+			$settings = Arr::set($settings, 'settings.general.multilingual', $multilingual);
43
+			$settings = Arr::set($settings, 'settings.general.rebusify', 'no');
44
+			$settings = Arr::set($settings, 'settings.general.rebusify_email', '');
45
+			$settings = Arr::set($settings, 'settings.general.rebusify_serial', '');
46
+			$settings = Arr::set($settings, 'settings.reviews.name.format', '');
47
+			$settings = Arr::set($settings, 'settings.reviews.name.initial', '');
48
+			$settings = Arr::set($settings, 'settings.submissions.blacklist.integration', '');
49
+			$settings = Arr::set($settings, 'settings.submissions.limit', '');
50
+			$settings = Arr::set($settings, 'settings.submissions.limit_whitelist.email', '');
51
+			$settings = Arr::set($settings, 'settings.submissions.limit_whitelist.ip_address', '');
52
+			$settings = Arr::set($settings, 'settings.submissions.limit_whitelist.username', '');
53
+			unset($settings['settings']['general']['support']);
54
+			update_option(OptionManager::databaseKey(4), $settings);
55
+		}
56
+	}
57 57
 
58
-    /**
59
-     * @return void
60
-     */
61
-    public function protectMetaKeys()
62
-    {
63
-        global $wpdb;
64
-        $keys = array_keys(glsr(CreateReviewDefaults::class)->defaults());
65
-        $keys = implode("','", $keys);
66
-        $postType = Application::POST_TYPE;
67
-        $wpdb->query("
58
+	/**
59
+	 * @return void
60
+	 */
61
+	public function protectMetaKeys()
62
+	{
63
+		global $wpdb;
64
+		$keys = array_keys(glsr(CreateReviewDefaults::class)->defaults());
65
+		$keys = implode("','", $keys);
66
+		$postType = Application::POST_TYPE;
67
+		$wpdb->query("
68 68
             UPDATE {$wpdb->postmeta} pm
69 69
             INNER JOIN {$wpdb->posts} p ON p.id = pm.post_id
70 70
             SET pm.meta_key = CONCAT('_', pm.meta_key)
71 71
             WHERE pm.meta_key IN ('{$keys}')
72 72
             AND p.post_type = '{$postType}'
73 73
         ");
74
-    }
74
+	}
75 75
 }
Please login to merge, or discard this patch.
plugin/Controllers/EditorController/Metaboxes.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -7,33 +7,33 @@
 block discarded – undo
7 7
 
8 8
 class Metaboxes
9 9
 {
10
-    /**
11
-     * @param int $postId
12
-     * @return void
13
-     */
14
-    public function saveAssignedToMetabox($postId)
15
-    {
16
-        if (!wp_verify_nonce(Helper::filterInput('_nonce-assigned-to'), 'assigned_to')) {
17
-            return;
18
-        }
19
-        $assignedTo = strval(Helper::filterInput('assigned_to'));
20
-        glsr(Database::class)->update($postId, 'assigned_to', $assignedTo);
21
-    }
10
+	/**
11
+	 * @param int $postId
12
+	 * @return void
13
+	 */
14
+	public function saveAssignedToMetabox($postId)
15
+	{
16
+		if (!wp_verify_nonce(Helper::filterInput('_nonce-assigned-to'), 'assigned_to')) {
17
+			return;
18
+		}
19
+		$assignedTo = strval(Helper::filterInput('assigned_to'));
20
+		glsr(Database::class)->update($postId, 'assigned_to', $assignedTo);
21
+	}
22 22
 
23
-    /**
24
-     * @param int $postId
25
-     * @return mixed
26
-     */
27
-    public function saveResponseMetabox($postId)
28
-    {
29
-        if (!wp_verify_nonce(Helper::filterInput('_nonce-response'), 'response')) {
30
-            return;
31
-        }
32
-        $response = strval(Helper::filterInput('response'));
33
-        glsr(Database::class)->update($postId, 'response', trim(wp_kses($response, [
34
-            'a' => ['href' => [], 'title' => []],
35
-            'em' => [],
36
-            'strong' => [],
37
-        ])));
38
-    }
23
+	/**
24
+	 * @param int $postId
25
+	 * @return mixed
26
+	 */
27
+	public function saveResponseMetabox($postId)
28
+	{
29
+		if (!wp_verify_nonce(Helper::filterInput('_nonce-response'), 'response')) {
30
+			return;
31
+		}
32
+		$response = strval(Helper::filterInput('response'));
33
+		glsr(Database::class)->update($postId, 'response', trim(wp_kses($response, [
34
+			'a' => ['href' => [], 'title' => []],
35
+			'em' => [],
36
+			'strong' => [],
37
+		])));
38
+	}
39 39
 }
Please login to merge, or discard this patch.
plugin/Controllers/BlocksController.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -8,85 +8,85 @@
 block discarded – undo
8 8
 
9 9
 class BlocksController extends Controller
10 10
 {
11
-    /**
12
-     * @param array $categories
13
-     * @return array
14
-     * @filter block_categories
15
-     */
16
-    public function filterBlockCategories($categories)
17
-    {
18
-        $categories = Arr::consolidateArray($categories);
19
-        $categories[] = [
20
-            'icon' => null,
21
-            'slug' => Application::ID,
22
-            'title' => glsr()->name,
23
-        ];
24
-        return $categories;
25
-    }
11
+	/**
12
+	 * @param array $categories
13
+	 * @return array
14
+	 * @filter block_categories
15
+	 */
16
+	public function filterBlockCategories($categories)
17
+	{
18
+		$categories = Arr::consolidateArray($categories);
19
+		$categories[] = [
20
+			'icon' => null,
21
+			'slug' => Application::ID,
22
+			'title' => glsr()->name,
23
+		];
24
+		return $categories;
25
+	}
26 26
 
27
-    /**
28
-     * @param array $editors
29
-     * @param string $postType
30
-     * @return array
31
-     * @filter classic_editor_enabled_editors_for_post_type
32
-     * @plugin classic-editor/classic-editor.php
33
-     */
34
-    public function filterEnabledEditors($editors, $postType)
35
-    {
36
-        return Application::POST_TYPE == $postType
37
-            ? ['block_editor' => false, 'classic_editor' => false]
38
-            : $editors;
39
-    }
27
+	/**
28
+	 * @param array $editors
29
+	 * @param string $postType
30
+	 * @return array
31
+	 * @filter classic_editor_enabled_editors_for_post_type
32
+	 * @plugin classic-editor/classic-editor.php
33
+	 */
34
+	public function filterEnabledEditors($editors, $postType)
35
+	{
36
+		return Application::POST_TYPE == $postType
37
+			? ['block_editor' => false, 'classic_editor' => false]
38
+			: $editors;
39
+	}
40 40
 
41
-    /**
42
-     * @param bool $bool
43
-     * @param string $postType
44
-     * @return bool
45
-     * @filter use_block_editor_for_post_type
46
-     */
47
-    public function filterUseBlockEditor($bool, $postType)
48
-    {
49
-        return Application::POST_TYPE == $postType
50
-            ? false
51
-            : $bool;
52
-    }
41
+	/**
42
+	 * @param bool $bool
43
+	 * @param string $postType
44
+	 * @return bool
45
+	 * @filter use_block_editor_for_post_type
46
+	 */
47
+	public function filterUseBlockEditor($bool, $postType)
48
+	{
49
+		return Application::POST_TYPE == $postType
50
+			? false
51
+			: $bool;
52
+	}
53 53
 
54
-    /**
55
-     * @return void
56
-     */
57
-    public function registerAssets()
58
-    {
59
-        wp_register_style(
60
-            Application::ID.'/blocks',
61
-            glsr()->url('assets/styles/'.Application::ID.'-blocks.css'),
62
-            ['wp-edit-blocks'],
63
-            glsr()->version
64
-        );
65
-        wp_register_script(
66
-            Application::ID.'/blocks',
67
-            glsr()->url('assets/scripts/'.Application::ID.'-blocks.js'),
68
-            ['wp-api-fetch', 'wp-blocks', 'wp-i18n', 'wp-editor', 'wp-element', Application::ID],
69
-            glsr()->version
70
-        );
71
-    }
54
+	/**
55
+	 * @return void
56
+	 */
57
+	public function registerAssets()
58
+	{
59
+		wp_register_style(
60
+			Application::ID.'/blocks',
61
+			glsr()->url('assets/styles/'.Application::ID.'-blocks.css'),
62
+			['wp-edit-blocks'],
63
+			glsr()->version
64
+		);
65
+		wp_register_script(
66
+			Application::ID.'/blocks',
67
+			glsr()->url('assets/scripts/'.Application::ID.'-blocks.js'),
68
+			['wp-api-fetch', 'wp-blocks', 'wp-i18n', 'wp-editor', 'wp-element', Application::ID],
69
+			glsr()->version
70
+		);
71
+	}
72 72
 
73
-    /**
74
-     * @return void
75
-     * @action init
76
-     */
77
-    public function registerBlocks()
78
-    {
79
-        $blocks = [
80
-            'form', 'reviews', 'summary',
81
-        ];
82
-        foreach ($blocks as $block) {
83
-            $id = str_replace('_reviews', '', Application::ID.'_'.$block);
84
-            $blockClass = Helper::buildClassName($id.'-block', 'Blocks');
85
-            if (!class_exists($blockClass)) {
86
-                glsr_log()->error(sprintf('Class missing (%s)', $blockClass));
87
-                continue;
88
-            }
89
-            glsr($blockClass)->register($block);
90
-        }
91
-    }
73
+	/**
74
+	 * @return void
75
+	 * @action init
76
+	 */
77
+	public function registerBlocks()
78
+	{
79
+		$blocks = [
80
+			'form', 'reviews', 'summary',
81
+		];
82
+		foreach ($blocks as $block) {
83
+			$id = str_replace('_reviews', '', Application::ID.'_'.$block);
84
+			$blockClass = Helper::buildClassName($id.'-block', 'Blocks');
85
+			if (!class_exists($blockClass)) {
86
+				glsr_log()->error(sprintf('Class missing (%s)', $blockClass));
87
+				continue;
88
+			}
89
+			glsr($blockClass)->register($block);
90
+		}
91
+	}
92 92
 }
Please login to merge, or discard this patch.
plugin/Handlers/RegisterShortcodes.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -7,18 +7,18 @@
 block discarded – undo
7 7
 
8 8
 class RegisterShortcodes
9 9
 {
10
-    /**
11
-     * @return void
12
-     */
13
-    public function handle(Command $command)
14
-    {
15
-        foreach ($command->shortcodes as $shortcode) {
16
-            $shortcodeClass = Helper::buildClassName($shortcode.'-shortcode', 'Shortcodes');
17
-            if (!class_exists($shortcodeClass)) {
18
-                glsr_log()->error(sprintf('Class missing (%s)', $shortcodeClass));
19
-                continue;
20
-            }
21
-            add_shortcode($shortcode, [glsr($shortcodeClass), 'buildShortcode']);
22
-        }
23
-    }
10
+	/**
11
+	 * @return void
12
+	 */
13
+	public function handle(Command $command)
14
+	{
15
+		foreach ($command->shortcodes as $shortcode) {
16
+			$shortcodeClass = Helper::buildClassName($shortcode.'-shortcode', 'Shortcodes');
17
+			if (!class_exists($shortcodeClass)) {
18
+				glsr_log()->error(sprintf('Class missing (%s)', $shortcodeClass));
19
+				continue;
20
+			}
21
+			add_shortcode($shortcode, [glsr($shortcodeClass), 'buildShortcode']);
22
+		}
23
+	}
24 24
 }
Please login to merge, or discard this patch.
plugin/Handlers/RegisterTinymcePopups.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,22 +7,22 @@
 block discarded – undo
7 7
 
8 8
 class RegisterTinymcePopups
9 9
 {
10
-    /**
11
-     * @return void
12
-     */
13
-    public function handle(Command $command)
14
-    {
15
-        foreach ($command->popups as $slug => $label) {
16
-            $buttonClass = Helper::buildClassName($slug.'-popup', 'Shortcodes');
17
-            if (!class_exists($buttonClass)) {
18
-                glsr_log()->error(sprintf('Class missing (%s)', $buttonClass));
19
-                continue;
20
-            }
21
-            $shortcode = glsr($buttonClass)->register($slug, [
22
-                'label' => $label,
23
-                'title' => $label,
24
-            ]);
25
-            glsr()->mceShortcodes[$slug] = $shortcode->properties;
26
-        }
27
-    }
10
+	/**
11
+	 * @return void
12
+	 */
13
+	public function handle(Command $command)
14
+	{
15
+		foreach ($command->popups as $slug => $label) {
16
+			$buttonClass = Helper::buildClassName($slug.'-popup', 'Shortcodes');
17
+			if (!class_exists($buttonClass)) {
18
+				glsr_log()->error(sprintf('Class missing (%s)', $buttonClass));
19
+				continue;
20
+			}
21
+			$shortcode = glsr($buttonClass)->register($slug, [
22
+				'label' => $label,
23
+				'title' => $label,
24
+			]);
25
+			glsr()->mceShortcodes[$slug] = $shortcode->properties;
26
+		}
27
+	}
28 28
 }
Please login to merge, or discard this patch.
plugin/Handlers/RegisterWidgets.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -8,21 +8,21 @@
 block discarded – undo
8 8
 
9 9
 class RegisterWidgets
10 10
 {
11
-    /**
12
-     * @return void
13
-     */
14
-    public function handle(Command $command)
15
-    {
16
-        global $wp_widget_factory;
17
-        foreach ($command->widgets as $key => $values) {
18
-            $widgetClass = Helper::buildClassName($key.'-widget', 'Widgets');
19
-            if (!class_exists($widgetClass)) {
20
-                glsr_log()->error(sprintf('Class missing (%s)', $widgetClass));
21
-                continue;
22
-            }
23
-            // Here we bypass register_widget() in order to pass our custom values to the widget
24
-            $widget = new $widgetClass(Application::ID.'_'.$key, $values['title'], $values);
25
-            $wp_widget_factory->widgets[$widgetClass] = $widget;
26
-        }
27
-    }
11
+	/**
12
+	 * @return void
13
+	 */
14
+	public function handle(Command $command)
15
+	{
16
+		global $wp_widget_factory;
17
+		foreach ($command->widgets as $key => $values) {
18
+			$widgetClass = Helper::buildClassName($key.'-widget', 'Widgets');
19
+			if (!class_exists($widgetClass)) {
20
+				glsr_log()->error(sprintf('Class missing (%s)', $widgetClass));
21
+				continue;
22
+			}
23
+			// Here we bypass register_widget() in order to pass our custom values to the widget
24
+			$widget = new $widgetClass(Application::ID.'_'.$key, $values['title'], $values);
25
+			$wp_widget_factory->widgets[$widgetClass] = $widget;
26
+		}
27
+	}
28 28
 }
Please login to merge, or discard this patch.
plugin/Database/DefaultsManager.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -6,60 +6,60 @@
 block discarded – undo
6 6
 
7 7
 class DefaultsManager
8 8
 {
9
-    /**
10
-     * @return array
11
-     */
12
-    public function defaults()
13
-    {
14
-        $settings = $this->settings();
15
-        $defaults = (array) array_combine(array_keys($settings), glsr_array_column($settings, 'default'));
16
-        return wp_parse_args($defaults, [
17
-            'version' => '',
18
-            'version_upgraded_from' => '',
19
-        ]);
20
-    }
9
+	/**
10
+	 * @return array
11
+	 */
12
+	public function defaults()
13
+	{
14
+		$settings = $this->settings();
15
+		$defaults = (array) array_combine(array_keys($settings), glsr_array_column($settings, 'default'));
16
+		return wp_parse_args($defaults, [
17
+			'version' => '',
18
+			'version_upgraded_from' => '',
19
+		]);
20
+	}
21 21
 
22
-    /**
23
-     * @return array
24
-     */
25
-    public function get()
26
-    {
27
-        return Arr::convertDotNotationArray($this->defaults());
28
-    }
22
+	/**
23
+	 * @return array
24
+	 */
25
+	public function get()
26
+	{
27
+		return Arr::convertDotNotationArray($this->defaults());
28
+	}
29 29
 
30
-    /**
31
-     * @return array
32
-     */
33
-    public function set()
34
-    {
35
-        $settings = glsr(OptionManager::class)->all();
36
-        $currentSettings = Arr::removeEmptyArrayValues($settings);
37
-        $defaultSettings = array_replace_recursive($this->get(), $currentSettings);
38
-        $updatedSettings = array_replace_recursive($settings, $defaultSettings);
39
-        update_option(OptionManager::databaseKey(), $updatedSettings);
40
-        return $defaultSettings;
41
-    }
30
+	/**
31
+	 * @return array
32
+	 */
33
+	public function set()
34
+	{
35
+		$settings = glsr(OptionManager::class)->all();
36
+		$currentSettings = Arr::removeEmptyArrayValues($settings);
37
+		$defaultSettings = array_replace_recursive($this->get(), $currentSettings);
38
+		$updatedSettings = array_replace_recursive($settings, $defaultSettings);
39
+		update_option(OptionManager::databaseKey(), $updatedSettings);
40
+		return $defaultSettings;
41
+	}
42 42
 
43
-    /**
44
-     * @return array
45
-     */
46
-    public function settings()
47
-    {
48
-        $settings = apply_filters('site-reviews/addon/settings', glsr()->config('settings'));
49
-        return $this->normalize($settings);
50
-    }
43
+	/**
44
+	 * @return array
45
+	 */
46
+	public function settings()
47
+	{
48
+		$settings = apply_filters('site-reviews/addon/settings', glsr()->config('settings'));
49
+		return $this->normalize($settings);
50
+	}
51 51
 
52
-    /**
53
-     * @return array
54
-     */
55
-    protected function normalize(array $settings)
56
-    {
57
-        array_walk($settings, function (&$setting) {
58
-            if (isset($setting['default'])) {
59
-                return;
60
-            }
61
-            $setting['default'] = '';
62
-        });
63
-        return $settings;
64
-    }
52
+	/**
53
+	 * @return array
54
+	 */
55
+	protected function normalize(array $settings)
56
+	{
57
+		array_walk($settings, function (&$setting) {
58
+			if (isset($setting['default'])) {
59
+				return;
60
+			}
61
+			$setting['default'] = '';
62
+		});
63
+		return $settings;
64
+	}
65 65
 }
Please login to merge, or discard this patch.