Passed
Push — master ( a9546d...6aabd8 )
by Paul
05:58
created
plugin/Shortcodes/SiteReviewsFormShortcode.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -6,29 +6,29 @@
 block discarded – undo
6 6
 
7 7
 class SiteReviewsFormShortcode extends Shortcode
8 8
 {
9
-    protected function hideOptions()
10
-    {
11
-        return [
12
-            'rating' => __('Hide the rating field', 'site-reviews'),
13
-            'title' => __('Hide the title field', 'site-reviews'),
14
-            'content' => __('Hide the review field', 'site-reviews'),
15
-            'name' => __('Hide the name field', 'site-reviews'),
16
-            'email' => __('Hide the email field', 'site-reviews'),
17
-            'terms' => __('Hide the terms field', 'site-reviews'),
18
-        ];
19
-    }
9
+	protected function hideOptions()
10
+	{
11
+		return [
12
+			'rating' => __('Hide the rating field', 'site-reviews'),
13
+			'title' => __('Hide the title field', 'site-reviews'),
14
+			'content' => __('Hide the review field', 'site-reviews'),
15
+			'name' => __('Hide the name field', 'site-reviews'),
16
+			'email' => __('Hide the email field', 'site-reviews'),
17
+			'terms' => __('Hide the terms field', 'site-reviews'),
18
+		];
19
+	}
20 20
 
21
-    /**
22
-     * @param array|string $atts
23
-     * @param string $type
24
-     * @return array
25
-     */
26
-    public function normalizeAtts($atts, $type = 'shortcode')
27
-    {
28
-        $atts = parent::normalizeAtts($atts, $type);
29
-        if (empty($atts['id'])) {
30
-            $atts['id'] = Application::PREFIX.substr(md5(serialize($atts)), 0, 8);
31
-        }
32
-        return $atts;
33
-    }
21
+	/**
22
+	 * @param array|string $atts
23
+	 * @param string $type
24
+	 * @return array
25
+	 */
26
+	public function normalizeAtts($atts, $type = 'shortcode')
27
+	{
28
+		$atts = parent::normalizeAtts($atts, $type);
29
+		if (empty($atts['id'])) {
30
+			$atts['id'] = Application::PREFIX.substr(md5(serialize($atts)), 0, 8);
31
+		}
32
+		return $atts;
33
+	}
34 34
 }
Please login to merge, or discard this patch.
plugin/Database/QueryBuilder.php 1 patch
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -12,190 +12,190 @@
 block discarded – undo
12 12
 
13 13
 class QueryBuilder
14 14
 {
15
-    /**
16
-     * Build a WP_Query meta_query/tax_query.
17
-     * @return array
18
-     */
19
-    public function buildQuery(array $keys = [], array $values = [])
20
-    {
21
-        $queries = [];
22
-        foreach ($keys as $key) {
23
-            if (!array_key_exists($key, $values)) {
24
-                continue;
25
-            }
26
-            $methodName = Helper::buildMethodName($key, __FUNCTION__);
27
-            if (!method_exists($this, $methodName)) {
28
-                continue;
29
-            }
30
-            $query = call_user_func([$this, $methodName], $values[$key]);
31
-            if (is_array($query)) {
32
-                $queries[] = $query;
33
-            }
34
-        }
35
-        return $queries;
36
-    }
15
+	/**
16
+	 * Build a WP_Query meta_query/tax_query.
17
+	 * @return array
18
+	 */
19
+	public function buildQuery(array $keys = [], array $values = [])
20
+	{
21
+		$queries = [];
22
+		foreach ($keys as $key) {
23
+			if (!array_key_exists($key, $values)) {
24
+				continue;
25
+			}
26
+			$methodName = Helper::buildMethodName($key, __FUNCTION__);
27
+			if (!method_exists($this, $methodName)) {
28
+				continue;
29
+			}
30
+			$query = call_user_func([$this, $methodName], $values[$key]);
31
+			if (is_array($query)) {
32
+				$queries[] = $query;
33
+			}
34
+		}
35
+		return $queries;
36
+	}
37 37
 
38
-    /**
39
-     * @return string
40
-     */
41
-    public function buildSqlLines(array $values, array $conditions)
42
-    {
43
-        $string = '';
44
-        $values = array_filter($values);
45
-        foreach ($conditions as $key => $value) {
46
-            if (!isset($values[$key])) {
47
-                continue;
48
-            }
49
-            $values[$key] = implode(',', (array) $values[$key]);
50
-            $string.= Str::contains($value, '%s')
51
-                ? sprintf($value, strval($values[$key]))
52
-                : $value;
53
-        }
54
-        return $string;
55
-    }
38
+	/**
39
+	 * @return string
40
+	 */
41
+	public function buildSqlLines(array $values, array $conditions)
42
+	{
43
+		$string = '';
44
+		$values = array_filter($values);
45
+		foreach ($conditions as $key => $value) {
46
+			if (!isset($values[$key])) {
47
+				continue;
48
+			}
49
+			$values[$key] = implode(',', (array) $values[$key]);
50
+			$string.= Str::contains($value, '%s')
51
+				? sprintf($value, strval($values[$key]))
52
+				: $value;
53
+		}
54
+		return $string;
55
+	}
56 56
 
57
-    /**
58
-     * Build a SQL 'OR' string from an array.
59
-     * @param string|array $values
60
-     * @param string $sprintfFormat
61
-     * @return string
62
-     */
63
-    public function buildSqlOr($values, $sprintfFormat)
64
-    {
65
-        if (!is_array($values)) {
66
-            $values = explode(',', $values);
67
-        }
68
-        $values = array_filter(array_map('trim', (array) $values));
69
-        $values = array_map(function ($value) use ($sprintfFormat) {
70
-            return sprintf($sprintfFormat, $value);
71
-        }, $values);
72
-        return implode(' OR ', $values);
73
-    }
57
+	/**
58
+	 * Build a SQL 'OR' string from an array.
59
+	 * @param string|array $values
60
+	 * @param string $sprintfFormat
61
+	 * @return string
62
+	 */
63
+	public function buildSqlOr($values, $sprintfFormat)
64
+	{
65
+		if (!is_array($values)) {
66
+			$values = explode(',', $values);
67
+		}
68
+		$values = array_filter(array_map('trim', (array) $values));
69
+		$values = array_map(function ($value) use ($sprintfFormat) {
70
+			return sprintf($sprintfFormat, $value);
71
+		}, $values);
72
+		return implode(' OR ', $values);
73
+	}
74 74
 
75
-    /**
76
-     * Search SQL filter for matching against post title only.
77
-     * @see http://wordpress.stackexchange.com/a/11826/1685
78
-     * @param string $search
79
-     * @return string
80
-     * @filter posts_search
81
-     */
82
-    public function filterSearchByTitle($search, WP_Query $query)
83
-    {
84
-        if (empty($search) || empty($query->get('search_terms'))) {
85
-            return $search;
86
-        }
87
-        global $wpdb;
88
-        $n = empty($query->get('exact'))
89
-            ? '%'
90
-            : '';
91
-        $search = [];
92
-        foreach ((array) $query->get('search_terms') as $term) {
93
-            $search[] = $wpdb->prepare("{$wpdb->posts}.post_title LIKE %s", $n.$wpdb->esc_like($term).$n);
94
-        }
95
-        if (!is_user_logged_in()) {
96
-            $search[] = "{$wpdb->posts}.post_password = ''";
97
-        }
98
-        return ' AND '.implode(' AND ', $search);
99
-    }
75
+	/**
76
+	 * Search SQL filter for matching against post title only.
77
+	 * @see http://wordpress.stackexchange.com/a/11826/1685
78
+	 * @param string $search
79
+	 * @return string
80
+	 * @filter posts_search
81
+	 */
82
+	public function filterSearchByTitle($search, WP_Query $query)
83
+	{
84
+		if (empty($search) || empty($query->get('search_terms'))) {
85
+			return $search;
86
+		}
87
+		global $wpdb;
88
+		$n = empty($query->get('exact'))
89
+			? '%'
90
+			: '';
91
+		$search = [];
92
+		foreach ((array) $query->get('search_terms') as $term) {
93
+			$search[] = $wpdb->prepare("{$wpdb->posts}.post_title LIKE %s", $n.$wpdb->esc_like($term).$n);
94
+		}
95
+		if (!is_user_logged_in()) {
96
+			$search[] = "{$wpdb->posts}.post_password = ''";
97
+		}
98
+		return ' AND '.implode(' AND ', $search);
99
+	}
100 100
 
101
-    /**
102
-     * Get the current page number from the global query.
103
-     * @param bool $isEnabled
104
-     * @return int
105
-     */
106
-    public function getPaged($isEnabled = true)
107
-    {
108
-        return $isEnabled
109
-            ? max(1, intval(filter_input(INPUT_GET, glsr()->constant('PAGED_QUERY_VAR'))))
110
-            : 1;
111
-    }
101
+	/**
102
+	 * Get the current page number from the global query.
103
+	 * @param bool $isEnabled
104
+	 * @return int
105
+	 */
106
+	public function getPaged($isEnabled = true)
107
+	{
108
+		return $isEnabled
109
+			? max(1, intval(filter_input(INPUT_GET, glsr()->constant('PAGED_QUERY_VAR'))))
110
+			: 1;
111
+	}
112 112
 
113
-    /**
114
-     * @param string $value
115
-     * @return void|array
116
-     */
117
-    protected function buildQueryAssignedTo($value)
118
-    {
119
-        if (!empty($value)) {
120
-            $postIds = Arr::convertStringToArray($value, 'is_numeric');
121
-            return [
122
-                'compare' => 'IN',
123
-                'key' => '_assigned_to',
124
-                'value' => glsr(Multilingual::class)->getPostIds($postIds),
125
-            ];
126
-        }
127
-    }
113
+	/**
114
+	 * @param string $value
115
+	 * @return void|array
116
+	 */
117
+	protected function buildQueryAssignedTo($value)
118
+	{
119
+		if (!empty($value)) {
120
+			$postIds = Arr::convertStringToArray($value, 'is_numeric');
121
+			return [
122
+				'compare' => 'IN',
123
+				'key' => '_assigned_to',
124
+				'value' => glsr(Multilingual::class)->getPostIds($postIds),
125
+			];
126
+		}
127
+	}
128 128
 
129
-    /**
130
-     * @param array $value
131
-     * @return void|array
132
-     */
133
-    protected function buildQueryCategory($value)
134
-    {
135
-        if (!empty($value)) {
136
-            return [
137
-                'field' => 'term_id',
138
-                'taxonomy' => Application::TAXONOMY,
139
-                'terms' => $value,
140
-            ];
141
-        }
142
-    }
129
+	/**
130
+	 * @param array $value
131
+	 * @return void|array
132
+	 */
133
+	protected function buildQueryCategory($value)
134
+	{
135
+		if (!empty($value)) {
136
+			return [
137
+				'field' => 'term_id',
138
+				'taxonomy' => Application::TAXONOMY,
139
+				'terms' => $value,
140
+			];
141
+		}
142
+	}
143 143
 
144
-    /**
145
-     * @param string $value
146
-     * @return void|array
147
-     */
148
-    protected function buildQueryEmail($value)
149
-    {
150
-        if (!empty($value)) {
151
-            return [
152
-                'key' => '_email',
153
-                'value' => $value,
154
-            ];
155
-        }
156
-    }
144
+	/**
145
+	 * @param string $value
146
+	 * @return void|array
147
+	 */
148
+	protected function buildQueryEmail($value)
149
+	{
150
+		if (!empty($value)) {
151
+			return [
152
+				'key' => '_email',
153
+				'value' => $value,
154
+			];
155
+		}
156
+	}
157 157
 
158
-    /**
159
-     * @param string $value
160
-     * @return void|array
161
-     */
162
-    protected function buildQueryIpAddress($value)
163
-    {
164
-        if (!empty($value)) {
165
-            return [
166
-                'key' => '_ip_address',
167
-                'value' => $value,
168
-            ];
169
-        }
170
-    }
158
+	/**
159
+	 * @param string $value
160
+	 * @return void|array
161
+	 */
162
+	protected function buildQueryIpAddress($value)
163
+	{
164
+		if (!empty($value)) {
165
+			return [
166
+				'key' => '_ip_address',
167
+				'value' => $value,
168
+			];
169
+		}
170
+	}
171 171
 
172
-    /**
173
-     * @param string $value
174
-     * @return void|array
175
-     */
176
-    protected function buildQueryRating($value)
177
-    {
178
-        if (is_numeric($value)
179
-            && in_array(intval($value), range(1, glsr()->constant('MAX_RATING', Rating::class)))) {
180
-            return [
181
-                'compare' => '>=',
182
-                'key' => '_rating',
183
-                'value' => $value,
184
-            ];
185
-        }
186
-    }
172
+	/**
173
+	 * @param string $value
174
+	 * @return void|array
175
+	 */
176
+	protected function buildQueryRating($value)
177
+	{
178
+		if (is_numeric($value)
179
+			&& in_array(intval($value), range(1, glsr()->constant('MAX_RATING', Rating::class)))) {
180
+			return [
181
+				'compare' => '>=',
182
+				'key' => '_rating',
183
+				'value' => $value,
184
+			];
185
+		}
186
+	}
187 187
 
188
-    /**
189
-     * @param string $value
190
-     * @return void|array
191
-     */
192
-    protected function buildQueryType($value)
193
-    {
194
-        if (!in_array($value, ['', 'all'])) {
195
-            return [
196
-                'key' => '_review_type',
197
-                'value' => $value,
198
-            ];
199
-        }
200
-    }
188
+	/**
189
+	 * @param string $value
190
+	 * @return void|array
191
+	 */
192
+	protected function buildQueryType($value)
193
+	{
194
+		if (!in_array($value, ['', 'all'])) {
195
+			return [
196
+				'key' => '_review_type',
197
+				'value' => $value,
198
+			];
199
+		}
200
+	}
201 201
 }
Please login to merge, or discard this patch.
plugin/Helpers/Arr.php 1 patch
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -4,197 +4,197 @@
 block discarded – undo
4 4
 
5 5
 class Arr
6 6
 {
7
-    /**
8
-     * @return bool
9
-     */
10
-    public static function compareArrays(array $arr1, array $arr2)
11
-    {
12
-        sort($arr1);
13
-        sort($arr2);
14
-        return $arr1 == $arr2;
15
-    }
7
+	/**
8
+	 * @return bool
9
+	 */
10
+	public static function compareArrays(array $arr1, array $arr2)
11
+	{
12
+		sort($arr1);
13
+		sort($arr2);
14
+		return $arr1 == $arr2;
15
+	}
16 16
 
17
-    /**
18
-     * @param mixed $array
19
-     * @return array
20
-     */
21
-    public static function consolidateArray($array)
22
-    {
23
-        return is_array($array) || is_object($array)
24
-            ? (array) $array
25
-            : [];
26
-    }
17
+	/**
18
+	 * @param mixed $array
19
+	 * @return array
20
+	 */
21
+	public static function consolidateArray($array)
22
+	{
23
+		return is_array($array) || is_object($array)
24
+			? (array) $array
25
+			: [];
26
+	}
27 27
 
28
-    /**
29
-     * @return array
30
-     */
31
-    public static function convertDotNotationArray(array $array)
32
-    {
33
-        $results = [];
34
-        foreach ($array as $path => $value) {
35
-            $results = static::set($results, $path, $value);
36
-        }
37
-        return $results;
38
-    }
28
+	/**
29
+	 * @return array
30
+	 */
31
+	public static function convertDotNotationArray(array $array)
32
+	{
33
+		$results = [];
34
+		foreach ($array as $path => $value) {
35
+			$results = static::set($results, $path, $value);
36
+		}
37
+		return $results;
38
+	}
39 39
 
40
-    /**
41
-     * @param string $string
42
-     * @param mixed $callback
43
-     * @return array
44
-     */
45
-    public static function convertStringToArray($string, $callback = null)
46
-    {
47
-        $array = array_map('trim', explode(',', $string));
48
-        return $callback
49
-            ? array_filter($array, $callback)
50
-            : array_filter($array);
51
-    }
40
+	/**
41
+	 * @param string $string
42
+	 * @param mixed $callback
43
+	 * @return array
44
+	 */
45
+	public static function convertStringToArray($string, $callback = null)
46
+	{
47
+		$array = array_map('trim', explode(',', $string));
48
+		return $callback
49
+			? array_filter($array, $callback)
50
+			: array_filter($array);
51
+	}
52 52
 
53
-    /**
54
-     * @param bool $flattenValue
55
-     * @param string $prefix
56
-     * @return array
57
-     */
58
-    public static function flattenArray(array $array, $flattenValue = false, $prefix = '')
59
-    {
60
-        $result = [];
61
-        foreach ($array as $key => $value) {
62
-            $newKey = ltrim($prefix.'.'.$key, '.');
63
-            if (static::isIndexedFlatArray($value)) {
64
-                if ($flattenValue) {
65
-                    $value = '['.implode(', ', $value).']';
66
-                }
67
-            } elseif (is_array($value)) {
68
-                $result = array_merge($result, static::flattenArray($value, $flattenValue, $newKey));
69
-                continue;
70
-            }
71
-            $result[$newKey] = $value;
72
-        }
73
-        return $result;
74
-    }
53
+	/**
54
+	 * @param bool $flattenValue
55
+	 * @param string $prefix
56
+	 * @return array
57
+	 */
58
+	public static function flattenArray(array $array, $flattenValue = false, $prefix = '')
59
+	{
60
+		$result = [];
61
+		foreach ($array as $key => $value) {
62
+			$newKey = ltrim($prefix.'.'.$key, '.');
63
+			if (static::isIndexedFlatArray($value)) {
64
+				if ($flattenValue) {
65
+					$value = '['.implode(', ', $value).']';
66
+				}
67
+			} elseif (is_array($value)) {
68
+				$result = array_merge($result, static::flattenArray($value, $flattenValue, $newKey));
69
+				continue;
70
+			}
71
+			$result[$newKey] = $value;
72
+		}
73
+		return $result;
74
+	}
75 75
 
76
-    /**
77
-     * Get a value from an array of values using a dot-notation path as reference.
78
-     * @param mixed $data
79
-     * @param string $path
80
-     * @param mixed $fallback
81
-     * @return mixed
82
-     */
83
-    public static function get($data, $path = '', $fallback = '')
84
-    {
85
-        $data = static::consolidateArray($data);
86
-        $keys = explode('.', $path);
87
-        foreach ($keys as $key) {
88
-            if (!isset($data[$key])) {
89
-                return $fallback;
90
-            }
91
-            $data = $data[$key];
92
-        }
93
-        return $data;
94
-    }
76
+	/**
77
+	 * Get a value from an array of values using a dot-notation path as reference.
78
+	 * @param mixed $data
79
+	 * @param string $path
80
+	 * @param mixed $fallback
81
+	 * @return mixed
82
+	 */
83
+	public static function get($data, $path = '', $fallback = '')
84
+	{
85
+		$data = static::consolidateArray($data);
86
+		$keys = explode('.', $path);
87
+		foreach ($keys as $key) {
88
+			if (!isset($data[$key])) {
89
+				return $fallback;
90
+			}
91
+			$data = $data[$key];
92
+		}
93
+		return $data;
94
+	}
95 95
 
96
-    /**
97
-     * @param string $key
98
-     * @param string $position
99
-     * @return array
100
-     */
101
-    public static function insertInArray(array $array, array $insert, $key, $position = 'before')
102
-    {
103
-        $keyPosition = intval(array_search($key, array_keys($array)));
104
-        if ('after' == $position) {
105
-            ++$keyPosition;
106
-        }
107
-        if (false !== $keyPosition) {
108
-            $result = array_slice($array, 0, $keyPosition);
109
-            $result = array_merge($result, $insert);
110
-            return array_merge($result, array_slice($array, $keyPosition));
111
-        }
112
-        return array_merge($array, $insert);
113
-    }
96
+	/**
97
+	 * @param string $key
98
+	 * @param string $position
99
+	 * @return array
100
+	 */
101
+	public static function insertInArray(array $array, array $insert, $key, $position = 'before')
102
+	{
103
+		$keyPosition = intval(array_search($key, array_keys($array)));
104
+		if ('after' == $position) {
105
+			++$keyPosition;
106
+		}
107
+		if (false !== $keyPosition) {
108
+			$result = array_slice($array, 0, $keyPosition);
109
+			$result = array_merge($result, $insert);
110
+			return array_merge($result, array_slice($array, $keyPosition));
111
+		}
112
+		return array_merge($array, $insert);
113
+	}
114 114
 
115
-    /**
116
-     * @param mixed $array
117
-     * @return bool
118
-     */
119
-    public static function isIndexedFlatArray($array)
120
-    {
121
-        if (!is_array($array) || array_filter($array, 'is_array')) {
122
-            return false;
123
-        }
124
-        return wp_is_numeric_array($array);
125
-    }
115
+	/**
116
+	 * @param mixed $array
117
+	 * @return bool
118
+	 */
119
+	public static function isIndexedFlatArray($array)
120
+	{
121
+		if (!is_array($array) || array_filter($array, 'is_array')) {
122
+			return false;
123
+		}
124
+		return wp_is_numeric_array($array);
125
+	}
126 126
 
127
-    /**
128
-     * @param bool $prefixed
129
-     * @return array
130
-     */
131
-    public static function prefixArrayKeys(array $values, $prefixed = true)
132
-    {
133
-        $trim = '_';
134
-        $prefix = $prefixed
135
-            ? $trim
136
-            : '';
137
-        $prefixed = [];
138
-        foreach ($values as $key => $value) {
139
-            $key = trim($key);
140
-            if (0 === strpos($key, $trim)) {
141
-                $key = substr($key, strlen($trim));
142
-            }
143
-            $prefixed[$prefix.$key] = $value;
144
-        }
145
-        return $prefixed;
146
-    }
127
+	/**
128
+	 * @param bool $prefixed
129
+	 * @return array
130
+	 */
131
+	public static function prefixArrayKeys(array $values, $prefixed = true)
132
+	{
133
+		$trim = '_';
134
+		$prefix = $prefixed
135
+			? $trim
136
+			: '';
137
+		$prefixed = [];
138
+		foreach ($values as $key => $value) {
139
+			$key = trim($key);
140
+			if (0 === strpos($key, $trim)) {
141
+				$key = substr($key, strlen($trim));
142
+			}
143
+			$prefixed[$prefix.$key] = $value;
144
+		}
145
+		return $prefixed;
146
+	}
147 147
 
148
-    /**
149
-     * @return array
150
-     */
151
-    public static function removeEmptyArrayValues(array $array)
152
-    {
153
-        $result = [];
154
-        foreach ($array as $key => $value) {
155
-            if (!$value) {
156
-                continue;
157
-            }
158
-            $result[$key] = is_array($value)
159
-                ? static::removeEmptyArrayValues($value)
160
-                : $value;
161
-        }
162
-        return $result;
163
-    }
148
+	/**
149
+	 * @return array
150
+	 */
151
+	public static function removeEmptyArrayValues(array $array)
152
+	{
153
+		$result = [];
154
+		foreach ($array as $key => $value) {
155
+			if (!$value) {
156
+				continue;
157
+			}
158
+			$result[$key] = is_array($value)
159
+				? static::removeEmptyArrayValues($value)
160
+				: $value;
161
+		}
162
+		return $result;
163
+	}
164 164
 
165 165
 
166
-    /**
167
-     * Set a value to an array of values using a dot-notation path as reference.
168
-     * @param string $path
169
-     * @param mixed $value
170
-     * @return array
171
-     */
172
-    public static function set(array $data, $path, $value)
173
-    {
174
-        $token = strtok($path, '.');
175
-        $ref = &$data;
176
-        while (false !== $token) {
177
-            $ref = static::consolidateArray($ref);
178
-            $ref = &$ref[$token];
179
-            $token = strtok('.');
180
-        }
181
-        $ref = $value;
182
-        return $data;
183
-    }
166
+	/**
167
+	 * Set a value to an array of values using a dot-notation path as reference.
168
+	 * @param string $path
169
+	 * @param mixed $value
170
+	 * @return array
171
+	 */
172
+	public static function set(array $data, $path, $value)
173
+	{
174
+		$token = strtok($path, '.');
175
+		$ref = &$data;
176
+		while (false !== $token) {
177
+			$ref = static::consolidateArray($ref);
178
+			$ref = &$ref[$token];
179
+			$token = strtok('.');
180
+		}
181
+		$ref = $value;
182
+		return $data;
183
+	}
184 184
 
185
-    /**
186
-     * @return array
187
-     */
188
-    public static function unique(array $values)
189
-    {
190
-        return array_filter(array_unique($values));
191
-    }
185
+	/**
186
+	 * @return array
187
+	 */
188
+	public static function unique(array $values)
189
+	{
190
+		return array_filter(array_unique($values));
191
+	}
192 192
 
193
-    /**
194
-     * @return array
195
-     */
196
-    public static function unprefixArrayKeys(array $values)
197
-    {
198
-        return static::prefixArrayKeys($values, false);
199
-    }
193
+	/**
194
+	 * @return array
195
+	 */
196
+	public static function unprefixArrayKeys(array $values)
197
+	{
198
+		return static::prefixArrayKeys($values, false);
199
+	}
200 200
 }
Please login to merge, or discard this patch.
plugin/Modules/Multilingual.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -14,52 +14,52 @@
 block discarded – undo
14 14
  */
15 15
 class Multilingual
16 16
 {
17
-    protected $integration;
17
+	protected $integration;
18 18
 
19
-    /**
20
-     * @param string $method
21
-     * @param array $args
22
-     * @return 
23
-     */
24
-    public function __call($method, $args = [])
25
-    {
26
-        if ($this->isIntegrated() && method_exists($this->integration, $method)) {
27
-            return call_user_func_array([$this->integration, $method], $args);
28
-        }
29
-        return Arr::get($args, 0, false);
30
-    }
19
+	/**
20
+	 * @param string $method
21
+	 * @param array $args
22
+	 * @return 
23
+	 */
24
+	public function __call($method, $args = [])
25
+	{
26
+		if ($this->isIntegrated() && method_exists($this->integration, $method)) {
27
+			return call_user_func_array([$this->integration, $method], $args);
28
+		}
29
+		return Arr::get($args, 0, false);
30
+	}
31 31
 
32
-    /**
33
-     * @param string $integration
34
-     * @return false|\GeminiLabs\SiteReviews\Modules\Multilingual\Polylang|\GeminiLabs\SiteReviews\Modules\Multilingual\Wpml
35
-     */
36
-    public function getIntegration($integration = '')
37
-    {
38
-        if (empty($integration)) {
39
-            $integration = glsr(OptionManager::class)->get('settings.general.multilingual');
40
-        }
41
-        if (!empty($integration)) {
42
-            $integrationClass = 'GeminiLabs\SiteReviews\Modules\Multilingual\\'.ucfirst($integration);
43
-            if (class_exists($integrationClass)) {
44
-                return glsr($integrationClass);
45
-            }
46
-            glsr_log()->error($integrationClass.' does not exist');
47
-        }
48
-        return false;
49
-    }
32
+	/**
33
+	 * @param string $integration
34
+	 * @return false|\GeminiLabs\SiteReviews\Modules\Multilingual\Polylang|\GeminiLabs\SiteReviews\Modules\Multilingual\Wpml
35
+	 */
36
+	public function getIntegration($integration = '')
37
+	{
38
+		if (empty($integration)) {
39
+			$integration = glsr(OptionManager::class)->get('settings.general.multilingual');
40
+		}
41
+		if (!empty($integration)) {
42
+			$integrationClass = 'GeminiLabs\SiteReviews\Modules\Multilingual\\'.ucfirst($integration);
43
+			if (class_exists($integrationClass)) {
44
+				return glsr($integrationClass);
45
+			}
46
+			glsr_log()->error($integrationClass.' does not exist');
47
+		}
48
+		return false;
49
+	}
50 50
 
51
-    /**
52
-     * return bool
53
-     */
54
-    public function isIntegrated()
55
-    {
56
-        if (!empty($this->integration)) {
57
-            return true;
58
-        }
59
-        if ($integration = $this->getIntegration()) {
60
-            $this->integration = $integration;
61
-            return true;
62
-        }
63
-        return false;
64
-    }
51
+	/**
52
+	 * return bool
53
+	 */
54
+	public function isIntegrated()
55
+	{
56
+		if (!empty($this->integration)) {
57
+			return true;
58
+		}
59
+		if ($integration = $this->getIntegration()) {
60
+			$this->integration = $integration;
61
+			return true;
62
+		}
63
+		return false;
64
+	}
65 65
 }
Please login to merge, or discard this patch.
plugin/Modules/ReviewLimits.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -8,105 +8,105 @@
 block discarded – undo
8 8
 
9 9
 class ReviewLimits
10 10
 {
11
-    protected $request;
11
+	protected $request;
12 12
 
13
-    /**
14
-     * @return array
15
-     * @filter site-reviews/get/reviews/query
16
-     */
17
-    public function filterReviewsQuery(array $parameters, array $args)
18
-    {
19
-        if ($authorId = get_current_user_id()) {
20
-            $parameters['author'] = $authorId;
21
-        }
22
-        $parameters['post_status'] = ['pending', 'publish'];
23
-        return apply_filters('site-reviews/review-limits/query', $parameters, $args);
24
-    }
13
+	/**
14
+	 * @return array
15
+	 * @filter site-reviews/get/reviews/query
16
+	 */
17
+	public function filterReviewsQuery(array $parameters, array $args)
18
+	{
19
+		if ($authorId = get_current_user_id()) {
20
+			$parameters['author'] = $authorId;
21
+		}
22
+		$parameters['post_status'] = ['pending', 'publish'];
23
+		return apply_filters('site-reviews/review-limits/query', $parameters, $args);
24
+	}
25 25
 
26
-    /**
27
-     * @return bool
28
-     */
29
-    public function hasReachedLimit(array $request = [])
30
-    {
31
-        $this->request = $request;
32
-        $method = Helper::buildMethodName(
33
-            glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy'
34
-        );
35
-        return method_exists($this, $method)
36
-            ? !call_user_func([$this, $method])
37
-            : false;
38
-    }
26
+	/**
27
+	 * @return bool
28
+	 */
29
+	public function hasReachedLimit(array $request = [])
30
+	{
31
+		$this->request = $request;
32
+		$method = Helper::buildMethodName(
33
+			glsr(OptionManager::class)->get('settings.submissions.limit'), 'validateBy'
34
+		);
35
+		return method_exists($this, $method)
36
+			? !call_user_func([$this, $method])
37
+			: false;
38
+	}
39 39
 
40
-    /**
41
-     * @param string $value
42
-     * @param string $whitelist
43
-     * @return bool
44
-     */
45
-    public function isWhitelisted($value, $whitelist)
46
-    {
47
-        if (empty($whitelist)) {
48
-            return false;
49
-        }
50
-        return in_array($value, array_filter(explode("\n", $whitelist), 'trim'));
51
-    }
40
+	/**
41
+	 * @param string $value
42
+	 * @param string $whitelist
43
+	 * @return bool
44
+	 */
45
+	public function isWhitelisted($value, $whitelist)
46
+	{
47
+		if (empty($whitelist)) {
48
+			return false;
49
+		}
50
+		return in_array($value, array_filter(explode("\n", $whitelist), 'trim'));
51
+	}
52 52
 
53
-    /**
54
-     * @param string $whitelistName
55
-     * @return string
56
-     */
57
-    protected function getWhitelist($whitelistName)
58
-    {
59
-        return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName);
60
-    }
53
+	/**
54
+	 * @param string $whitelistName
55
+	 * @return string
56
+	 */
57
+	protected function getWhitelist($whitelistName)
58
+	{
59
+		return glsr(OptionManager::class)->get('settings.submissions.limit_whitelist.'.$whitelistName);
60
+	}
61 61
 
62
-    /**
63
-     * @return bool
64
-     */
65
-    protected function validate($key, $value, $addMetaQuery = true)
66
-    {
67
-        if ($this->isWhitelisted($value, $this->getWhitelist($key))) {
68
-            return true;
69
-        }
70
-        add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2);
71
-        $args = ['assigned_to' => Arr::get($this->request, 'assign_to')];
72
-        if ($addMetaQuery) {
73
-            $args[$key] = $value;
74
-        }
75
-        $reviews = glsr_get_reviews($args);
76
-        remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5);
77
-        $result = 0 === count($reviews);
78
-        $result = apply_filters('site-reviews/review-limits/validate', $result, $reviews, $this->request, $key);
79
-        return wp_validate_boolean($result);
80
-    }
62
+	/**
63
+	 * @return bool
64
+	 */
65
+	protected function validate($key, $value, $addMetaQuery = true)
66
+	{
67
+		if ($this->isWhitelisted($value, $this->getWhitelist($key))) {
68
+			return true;
69
+		}
70
+		add_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5, 2);
71
+		$args = ['assigned_to' => Arr::get($this->request, 'assign_to')];
72
+		if ($addMetaQuery) {
73
+			$args[$key] = $value;
74
+		}
75
+		$reviews = glsr_get_reviews($args);
76
+		remove_filter('site-reviews/get/reviews/query', [$this, 'filterReviewsQuery'], 5);
77
+		$result = 0 === count($reviews);
78
+		$result = apply_filters('site-reviews/review-limits/validate', $result, $reviews, $this->request, $key);
79
+		return wp_validate_boolean($result);
80
+	}
81 81
 
82
-    /**
83
-     * @return bool
84
-     */
85
-    protected function validateByEmail()
86
-    {
87
-        glsr_log()->debug('Email is: '.Arr::get($this->request, 'email'));
88
-        return $this->validate('email', Arr::get($this->request, 'email'));
89
-    }
82
+	/**
83
+	 * @return bool
84
+	 */
85
+	protected function validateByEmail()
86
+	{
87
+		glsr_log()->debug('Email is: '.Arr::get($this->request, 'email'));
88
+		return $this->validate('email', Arr::get($this->request, 'email'));
89
+	}
90 90
 
91
-    /**
92
-     * @return bool
93
-     */
94
-    protected function validateByIpAddress()
95
-    {
96
-        glsr_log()->debug('IP Address is: '.Arr::get($this->request, 'ip_address'));
97
-        return $this->validate('ip_address', Arr::get($this->request, 'ip_address'));
98
-    }
91
+	/**
92
+	 * @return bool
93
+	 */
94
+	protected function validateByIpAddress()
95
+	{
96
+		glsr_log()->debug('IP Address is: '.Arr::get($this->request, 'ip_address'));
97
+		return $this->validate('ip_address', Arr::get($this->request, 'ip_address'));
98
+	}
99 99
 
100
-    /**
101
-     * @return bool
102
-     */
103
-    protected function validateByUsername()
104
-    {
105
-        $user = wp_get_current_user();
106
-        if (!$user->exists()) {
107
-            return true;
108
-        }
109
-        glsr_log()->debug('Username is: '.$user->user_login);
110
-        return $this->validate('username', $user->user_login, false);
111
-    }
100
+	/**
101
+	 * @return bool
102
+	 */
103
+	protected function validateByUsername()
104
+	{
105
+		$user = wp_get_current_user();
106
+		if (!$user->exists()) {
107
+			return true;
108
+		}
109
+		glsr_log()->debug('Username is: '.$user->user_login);
110
+		return $this->validate('username', $user->user_login, false);
111
+	}
112 112
 }
Please login to merge, or discard this patch.
plugin/Modules/Validator/ValidationRules.php 1 patch
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -10,126 +10,126 @@
 block discarded – undo
10 10
  */
11 11
 trait ValidationRules
12 12
 {
13
-    /**
14
-     * Get the size of an attribute.
15
-     * @param string $attribute
16
-     * @param mixed $value
17
-     * @return mixed
18
-     */
19
-    abstract protected function getSize($attribute, $value);
13
+	/**
14
+	 * Get the size of an attribute.
15
+	 * @param string $attribute
16
+	 * @param mixed $value
17
+	 * @return mixed
18
+	 */
19
+	abstract protected function getSize($attribute, $value);
20 20
 
21
-    /**
22
-     * Replace all placeholders.
23
-     * @param string $message
24
-     * @return string
25
-     */
26
-    protected function replace($message, array $parameters)
27
-    {
28
-        if (!Str::contains($message, '%s')) {
29
-            return $message;
30
-        }
31
-        return preg_replace_callback('/(%s)/', function () use (&$parameters) {
32
-            foreach ($parameters as $key => $value) {
33
-                return array_shift($parameters);
34
-            }
35
-        }, $message);
36
-    }
21
+	/**
22
+	 * Replace all placeholders.
23
+	 * @param string $message
24
+	 * @return string
25
+	 */
26
+	protected function replace($message, array $parameters)
27
+	{
28
+		if (!Str::contains($message, '%s')) {
29
+			return $message;
30
+		}
31
+		return preg_replace_callback('/(%s)/', function () use (&$parameters) {
32
+			foreach ($parameters as $key => $value) {
33
+				return array_shift($parameters);
34
+			}
35
+		}, $message);
36
+	}
37 37
 
38
-    /**
39
-     * Validate that an attribute was "accepted".
40
-     * This validation rule implies the attribute is "required".
41
-     * @param string $attribute
42
-     * @param mixed $value
43
-     * @return bool
44
-     */
45
-    public function validateAccepted($value)
46
-    {
47
-        $acceptable = ['yes', 'on', '1', 1, true, 'true'];
48
-        return $this->validateRequired($value) && in_array($value, $acceptable, true);
49
-    }
38
+	/**
39
+	 * Validate that an attribute was "accepted".
40
+	 * This validation rule implies the attribute is "required".
41
+	 * @param string $attribute
42
+	 * @param mixed $value
43
+	 * @return bool
44
+	 */
45
+	public function validateAccepted($value)
46
+	{
47
+		$acceptable = ['yes', 'on', '1', 1, true, 'true'];
48
+		return $this->validateRequired($value) && in_array($value, $acceptable, true);
49
+	}
50 50
 
51
-    /**
52
-     * Validate the size of an attribute is between a set of values.
53
-     * @param string $attribute
54
-     * @param mixed $value
55
-     * @return bool
56
-     */
57
-    public function validateBetween($value, $attribute, array $parameters)
58
-    {
59
-        $this->requireParameterCount(2, $parameters, 'between');
60
-        $size = $this->getSize($attribute, $value);
61
-        return $size >= $parameters[0] && $size <= $parameters[1];
62
-    }
51
+	/**
52
+	 * Validate the size of an attribute is between a set of values.
53
+	 * @param string $attribute
54
+	 * @param mixed $value
55
+	 * @return bool
56
+	 */
57
+	public function validateBetween($value, $attribute, array $parameters)
58
+	{
59
+		$this->requireParameterCount(2, $parameters, 'between');
60
+		$size = $this->getSize($attribute, $value);
61
+		return $size >= $parameters[0] && $size <= $parameters[1];
62
+	}
63 63
 
64
-    /**
65
-     * Validate that an attribute is a valid e-mail address.
66
-     * @param mixed $value
67
-     * @return bool
68
-     */
69
-    public function validateEmail($value)
70
-    {
71
-        return false !== filter_var($value, FILTER_VALIDATE_EMAIL);
72
-    }
64
+	/**
65
+	 * Validate that an attribute is a valid e-mail address.
66
+	 * @param mixed $value
67
+	 * @return bool
68
+	 */
69
+	public function validateEmail($value)
70
+	{
71
+		return false !== filter_var($value, FILTER_VALIDATE_EMAIL);
72
+	}
73 73
 
74
-    /**
75
-     * Validate the size of an attribute is less than a maximum value.
76
-     * @param string $attribute
77
-     * @param mixed $value
78
-     * @return bool
79
-     */
80
-    public function validateMax($value, $attribute, array $parameters)
81
-    {
82
-        $this->requireParameterCount(1, $parameters, 'max');
83
-        return $this->getSize($attribute, $value) <= $parameters[0];
84
-    }
74
+	/**
75
+	 * Validate the size of an attribute is less than a maximum value.
76
+	 * @param string $attribute
77
+	 * @param mixed $value
78
+	 * @return bool
79
+	 */
80
+	public function validateMax($value, $attribute, array $parameters)
81
+	{
82
+		$this->requireParameterCount(1, $parameters, 'max');
83
+		return $this->getSize($attribute, $value) <= $parameters[0];
84
+	}
85 85
 
86
-    /**
87
-     * Validate the size of an attribute is greater than a minimum value.
88
-     * @param string $attribute
89
-     * @param mixed $value
90
-     * @return bool
91
-     */
92
-    public function validateMin($value, $attribute, array $parameters)
93
-    {
94
-        $this->requireParameterCount(1, $parameters, 'min');
95
-        return $this->getSize($attribute, $value) >= $parameters[0];
96
-    }
86
+	/**
87
+	 * Validate the size of an attribute is greater than a minimum value.
88
+	 * @param string $attribute
89
+	 * @param mixed $value
90
+	 * @return bool
91
+	 */
92
+	public function validateMin($value, $attribute, array $parameters)
93
+	{
94
+		$this->requireParameterCount(1, $parameters, 'min');
95
+		return $this->getSize($attribute, $value) >= $parameters[0];
96
+	}
97 97
 
98
-    /**
99
-     * Validate that an attribute is numeric.
100
-     * @param mixed $value
101
-     * @return bool
102
-     */
103
-    public function validateNumber($value)
104
-    {
105
-        return is_numeric($value);
106
-    }
98
+	/**
99
+	 * Validate that an attribute is numeric.
100
+	 * @param mixed $value
101
+	 * @return bool
102
+	 */
103
+	public function validateNumber($value)
104
+	{
105
+		return is_numeric($value);
106
+	}
107 107
 
108
-    /**
109
-     * Validate that a required attribute exists.
110
-     * @param mixed $value
111
-     * @return bool
112
-     */
113
-    public function validateRequired($value)
114
-    {
115
-        return is_null($value)
116
-            || (is_string($value) && in_array(trim($value), ['', '[]']))
117
-            || (is_array($value) && empty($value))
118
-            ? false
119
-            : true;
120
-    }
108
+	/**
109
+	 * Validate that a required attribute exists.
110
+	 * @param mixed $value
111
+	 * @return bool
112
+	 */
113
+	public function validateRequired($value)
114
+	{
115
+		return is_null($value)
116
+			|| (is_string($value) && in_array(trim($value), ['', '[]']))
117
+			|| (is_array($value) && empty($value))
118
+			? false
119
+			: true;
120
+	}
121 121
 
122
-    /**
123
-     * Require a certain number of parameters to be present.
124
-     * @param int $count
125
-     * @param string $rule
126
-     * @return void
127
-     * @throws InvalidArgumentException
128
-     */
129
-    protected function requireParameterCount($count, array $parameters, $rule)
130
-    {
131
-        if (count($parameters) < $count) {
132
-            throw new InvalidArgumentException("Validation rule $rule requires at least $count parameters.");
133
-        }
134
-    }
122
+	/**
123
+	 * Require a certain number of parameters to be present.
124
+	 * @param int $count
125
+	 * @param string $rule
126
+	 * @return void
127
+	 * @throws InvalidArgumentException
128
+	 */
129
+	protected function requireParameterCount($count, array $parameters, $rule)
130
+	{
131
+		if (count($parameters) < $count) {
132
+			throw new InvalidArgumentException("Validation rule $rule requires at least $count parameters.");
133
+		}
134
+	}
135 135
 }
Please login to merge, or discard this patch.
plugin/Contracts/MultilingualContract.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -4,29 +4,29 @@
 block discarded – undo
4 4
 
5 5
 interface MultilingualContract
6 6
 {
7
-    /**
8
-     * @param int|string $postId
9
-     * @return int
10
-     */
11
-    public function getPostId($postId);
7
+	/**
8
+	 * @param int|string $postId
9
+	 * @return int
10
+	 */
11
+	public function getPostId($postId);
12 12
 
13
-    /**
14
-     * @return array
15
-     */
16
-    public function getPostIds(array $postIds);
13
+	/**
14
+	 * @return array
15
+	 */
16
+	public function getPostIds(array $postIds);
17 17
 
18
-    /**
19
-     * @return bool
20
-     */
21
-    public function isActive();
18
+	/**
19
+	 * @return bool
20
+	 */
21
+	public function isActive();
22 22
 
23
-    /**
24
-     * @return bool
25
-     */
26
-    public function isEnabled();
23
+	/**
24
+	 * @return bool
25
+	 */
26
+	public function isEnabled();
27 27
 
28
-    /**
29
-     * @return bool
30
-     */
31
-    public function isSupported();
28
+	/**
29
+	 * @return bool
30
+	 */
31
+	public function isSupported();
32 32
 }
Please login to merge, or discard this patch.
site-reviews.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -20,17 +20,17 @@
 block discarded – undo
20 20
 defined('WPINC') || die;
21 21
 
22 22
 if (!class_exists('GL_Plugin_Check_v4')) {
23
-    require_once __DIR__.'/activate.php';
23
+	require_once __DIR__.'/activate.php';
24 24
 }
25 25
 if ((new GL_Plugin_Check_v4(__FILE__))->canProceed()) {
26
-    require_once __DIR__.'/autoload.php';
27
-    require_once __DIR__.'/compatibility.php';
28
-    require_once __DIR__.'/deprecated.php';
29
-    require_once __DIR__.'/helpers.php';
30
-    $app = new GeminiLabs\SiteReviews\Application();
31
-    $app->make('Provider')->register($app);
32
-    register_activation_hook(__FILE__, array($app, 'activate'));
33
-    register_deactivation_hook(__FILE__, array($app, 'deactivate'));
34
-    register_shutdown_function(array($app, 'catchFatalError'));
35
-    $app->init();
26
+	require_once __DIR__.'/autoload.php';
27
+	require_once __DIR__.'/compatibility.php';
28
+	require_once __DIR__.'/deprecated.php';
29
+	require_once __DIR__.'/helpers.php';
30
+	$app = new GeminiLabs\SiteReviews\Application();
31
+	$app->make('Provider')->register($app);
32
+	register_activation_hook(__FILE__, array($app, 'activate'));
33
+	register_deactivation_hook(__FILE__, array($app, 'deactivate'));
34
+	register_shutdown_function(array($app, 'catchFatalError'));
35
+	$app->init();
36 36
 }
Please login to merge, or discard this patch.
plugin/Controllers/SettingsController.php 1 patch
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -12,160 +12,160 @@
 block discarded – undo
12 12
 
13 13
 class SettingsController extends Controller
14 14
 {
15
-    /**
16
-     * @param mixed $input
17
-     * @return array
18
-     * @callback register_setting
19
-     */
20
-    public function callbackRegisterSettings($input)
21
-    {
22
-        $settings = Arr::consolidateArray($input);
23
-        if (1 === count($settings) && array_key_exists('settings', $settings)) {
24
-            $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input);
25
-            $options = $this->sanitizeGeneral($input, $options);
26
-            $options = $this->sanitizeLicenses($input, $options);
27
-            $options = $this->sanitizeSubmissions($input, $options);
28
-            $options = $this->sanitizeTranslations($input, $options);
29
-            $options = apply_filters('site-reviews/settings/callback', $options, $settings);
30
-            if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') {
31
-                glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews'));
32
-            }
33
-            return $options;
34
-        }
35
-        return $input;
36
-    }
15
+	/**
16
+	 * @param mixed $input
17
+	 * @return array
18
+	 * @callback register_setting
19
+	 */
20
+	public function callbackRegisterSettings($input)
21
+	{
22
+		$settings = Arr::consolidateArray($input);
23
+		if (1 === count($settings) && array_key_exists('settings', $settings)) {
24
+			$options = array_replace_recursive(glsr(OptionManager::class)->all(), $input);
25
+			$options = $this->sanitizeGeneral($input, $options);
26
+			$options = $this->sanitizeLicenses($input, $options);
27
+			$options = $this->sanitizeSubmissions($input, $options);
28
+			$options = $this->sanitizeTranslations($input, $options);
29
+			$options = apply_filters('site-reviews/settings/callback', $options, $settings);
30
+			if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') {
31
+				glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews'));
32
+			}
33
+			return $options;
34
+		}
35
+		return $input;
36
+	}
37 37
 
38
-    /**
39
-     * @return void
40
-     * @action admin_init
41
-     */
42
-    public function registerSettings()
43
-    {
44
-        register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [
45
-            'sanitize_callback' => [$this, 'callbackRegisterSettings'],
46
-        ]);
47
-    }
38
+	/**
39
+	 * @return void
40
+	 * @action admin_init
41
+	 */
42
+	public function registerSettings()
43
+	{
44
+		register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [
45
+			'sanitize_callback' => [$this, 'callbackRegisterSettings'],
46
+		]);
47
+	}
48 48
 
49
-    /**
50
-     * @return array
51
-     */
52
-    protected function sanitizeGeneral(array $input, array $options)
53
-    {
54
-        $key = 'settings.general';
55
-        $inputForm = Arr::get($input, $key);
56
-        if (!$this->hasMultilingualIntegration(Arr::get($inputForm, 'multilingual'))) {
57
-            $options = Arr::set($options, $key.'.multilingual', '');
58
-        }
59
-        if ('' == trim(Arr::get($inputForm, 'notification_message'))) {
60
-            $defaultValue = Arr::get(glsr()->defaults, $key.'.notification_message');
61
-            $options = Arr::set($options, $key.'.notification_message', $defaultValue);
62
-        }
63
-        $defaultValue = Arr::get($inputForm, 'notifications', []);
64
-        $options = Arr::set($options, $key.'.notifications', $defaultValue);
65
-        return $options;
66
-    }
49
+	/**
50
+	 * @return array
51
+	 */
52
+	protected function sanitizeGeneral(array $input, array $options)
53
+	{
54
+		$key = 'settings.general';
55
+		$inputForm = Arr::get($input, $key);
56
+		if (!$this->hasMultilingualIntegration(Arr::get($inputForm, 'multilingual'))) {
57
+			$options = Arr::set($options, $key.'.multilingual', '');
58
+		}
59
+		if ('' == trim(Arr::get($inputForm, 'notification_message'))) {
60
+			$defaultValue = Arr::get(glsr()->defaults, $key.'.notification_message');
61
+			$options = Arr::set($options, $key.'.notification_message', $defaultValue);
62
+		}
63
+		$defaultValue = Arr::get($inputForm, 'notifications', []);
64
+		$options = Arr::set($options, $key.'.notifications', $defaultValue);
65
+		return $options;
66
+	}
67 67
 
68
-    /**
69
-     * @return array
70
-     */
71
-    protected function sanitizeLicenses(array $input, array $options)
72
-    {
73
-        $key = 'settings.licenses';
74
-        $licenses = Arr::consolidateArray(Arr::get($input, $key));
75
-        foreach ($licenses as $slug => &$license) {
76
-            $license = $this->verifyLicense($license, $slug);
77
-        }
78
-        $options = Arr::set($options, $key, $licenses);
79
-        return $options;
80
-    }
68
+	/**
69
+	 * @return array
70
+	 */
71
+	protected function sanitizeLicenses(array $input, array $options)
72
+	{
73
+		$key = 'settings.licenses';
74
+		$licenses = Arr::consolidateArray(Arr::get($input, $key));
75
+		foreach ($licenses as $slug => &$license) {
76
+			$license = $this->verifyLicense($license, $slug);
77
+		}
78
+		$options = Arr::set($options, $key, $licenses);
79
+		return $options;
80
+	}
81 81
 
82
-    /**
83
-     * @return array
84
-     */
85
-    protected function sanitizeSubmissions(array $input, array $options)
86
-    {
87
-        $key = 'settings.submissions';
88
-        $inputForm = Arr::get($input, $key);
89
-        $defaultValue = isset($inputForm['required'])
90
-            ? $inputForm['required']
91
-            : [];
92
-        $options = Arr::set($options, $key.'.required', $defaultValue);
93
-        return $options;
94
-    }
82
+	/**
83
+	 * @return array
84
+	 */
85
+	protected function sanitizeSubmissions(array $input, array $options)
86
+	{
87
+		$key = 'settings.submissions';
88
+		$inputForm = Arr::get($input, $key);
89
+		$defaultValue = isset($inputForm['required'])
90
+			? $inputForm['required']
91
+			: [];
92
+		$options = Arr::set($options, $key.'.required', $defaultValue);
93
+		return $options;
94
+	}
95 95
 
96
-    /**
97
-     * @return array
98
-     */
99
-    protected function sanitizeTranslations(array $input, array $options)
100
-    {
101
-        $key = 'settings.strings';
102
-        $inputForm = Arr::consolidateArray(Arr::get($input, $key));
103
-        if (!empty($inputForm)) {
104
-            $options = Arr::set($options, $key, array_values(array_filter($inputForm)));
105
-            $allowedTags = [
106
-                'a' => ['class' => [], 'href' => [], 'target' => []],
107
-                'span' => ['class' => []],
108
-            ];
109
-            array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) {
110
-                if (isset($string['s2'])) {
111
-                    $string['s2'] = wp_kses($string['s2'], $allowedTags);
112
-                }
113
-                if (isset($string['p2'])) {
114
-                    $string['p2'] = wp_kses($string['p2'], $allowedTags);
115
-                }
116
-            });
117
-        }
118
-        return $options;
119
-    }
96
+	/**
97
+	 * @return array
98
+	 */
99
+	protected function sanitizeTranslations(array $input, array $options)
100
+	{
101
+		$key = 'settings.strings';
102
+		$inputForm = Arr::consolidateArray(Arr::get($input, $key));
103
+		if (!empty($inputForm)) {
104
+			$options = Arr::set($options, $key, array_values(array_filter($inputForm)));
105
+			$allowedTags = [
106
+				'a' => ['class' => [], 'href' => [], 'target' => []],
107
+				'span' => ['class' => []],
108
+			];
109
+			array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) {
110
+				if (isset($string['s2'])) {
111
+					$string['s2'] = wp_kses($string['s2'], $allowedTags);
112
+				}
113
+				if (isset($string['p2'])) {
114
+					$string['p2'] = wp_kses($string['p2'], $allowedTags);
115
+				}
116
+			});
117
+		}
118
+		return $options;
119
+	}
120 120
 
121
-    /**
122
-     * @param string $integrationSlug
123
-     * @return bool
124
-     */
125
-    protected function hasMultilingualIntegration($integrationSlug)
126
-    {
127
-        $integration = glsr(Multilingual::class)->getIntegration($integrationSlug);
128
-        if (!$integration) {
129
-            return false;
130
-        }
131
-        if (!$integration->isActive()) {
132
-            glsr(Notice::class)->addError(sprintf(
133
-                __('Please install/activate the %s plugin to enable integration.', 'site-reviews'),
134
-                $integration->pluginName
135
-            ));
136
-            return false;
137
-        } elseif (!$integration->isSupported()) {
138
-            glsr(Notice::class)->addError(sprintf(
139
-                __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'),
140
-                $integration->pluginName,
141
-                $integration->supportedVersion
142
-            ));
143
-            return false;
144
-        }
145
-        return true;
146
-    }
121
+	/**
122
+	 * @param string $integrationSlug
123
+	 * @return bool
124
+	 */
125
+	protected function hasMultilingualIntegration($integrationSlug)
126
+	{
127
+		$integration = glsr(Multilingual::class)->getIntegration($integrationSlug);
128
+		if (!$integration) {
129
+			return false;
130
+		}
131
+		if (!$integration->isActive()) {
132
+			glsr(Notice::class)->addError(sprintf(
133
+				__('Please install/activate the %s plugin to enable integration.', 'site-reviews'),
134
+				$integration->pluginName
135
+			));
136
+			return false;
137
+		} elseif (!$integration->isSupported()) {
138
+			glsr(Notice::class)->addError(sprintf(
139
+				__('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'),
140
+				$integration->pluginName,
141
+				$integration->supportedVersion
142
+			));
143
+			return false;
144
+		}
145
+		return true;
146
+	}
147 147
 
148
-    /**
149
-     * @param string $license
150
-     * @param string $slug
151
-     * @return string
152
-     */
153
-    protected function verifyLicense($license, $slug)
154
-    {
155
-        try {
156
-            $addon = glsr($slug);
157
-            $updater = new Updater($addon->update_url, $addon->file, [
158
-                'license' => $license,
159
-                'testedTo' => $addon->testedTo,
160
-            ]);
161
-            if (!$updater->isLicenseValid()) {
162
-                throw new Exception('Invalid license: '.$license.' ('.$addon->id.')');
163
-            }
164
-        } catch (Exception $e) {
165
-            $license = '';
166
-            glsr_log()->debug($e->getMessage());
167
-            glsr(Notice::class)->addError(__('A license you entered was invalid.', 'site-reviews'));
168
-        }
169
-        return $license;
170
-    }
148
+	/**
149
+	 * @param string $license
150
+	 * @param string $slug
151
+	 * @return string
152
+	 */
153
+	protected function verifyLicense($license, $slug)
154
+	{
155
+		try {
156
+			$addon = glsr($slug);
157
+			$updater = new Updater($addon->update_url, $addon->file, [
158
+				'license' => $license,
159
+				'testedTo' => $addon->testedTo,
160
+			]);
161
+			if (!$updater->isLicenseValid()) {
162
+				throw new Exception('Invalid license: '.$license.' ('.$addon->id.')');
163
+			}
164
+		} catch (Exception $e) {
165
+			$license = '';
166
+			glsr_log()->debug($e->getMessage());
167
+			glsr(Notice::class)->addError(__('A license you entered was invalid.', 'site-reviews'));
168
+		}
169
+		return $license;
170
+	}
171 171
 }
Please login to merge, or discard this patch.