Passed
Push — master ( ccb079...7906b4 )
by Paul
04:39
created
plugin/Database/QueryBuilder.php 2 patches
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::convertFromString($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::convertFromString($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.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -16,19 +16,19 @@  discard block
 block discarded – undo
16 16
      * Build a WP_Query meta_query/tax_query.
17 17
      * @return array
18 18
      */
19
-    public function buildQuery(array $keys = [], array $values = [])
19
+    public function buildQuery( array $keys = [], array $values = [] )
20 20
     {
21 21
         $queries = [];
22
-        foreach ($keys as $key) {
23
-            if (!array_key_exists($key, $values)) {
22
+        foreach( $keys as $key ) {
23
+            if( !array_key_exists( $key, $values ) ) {
24 24
                 continue;
25 25
             }
26
-            $methodName = Helper::buildMethodName($key, __FUNCTION__);
27
-            if (!method_exists($this, $methodName)) {
26
+            $methodName = Helper::buildMethodName( $key, __FUNCTION__ );
27
+            if( !method_exists( $this, $methodName ) ) {
28 28
                 continue;
29 29
             }
30
-            $query = call_user_func([$this, $methodName], $values[$key]);
31
-            if (is_array($query)) {
30
+            $query = call_user_func( [$this, $methodName], $values[$key] );
31
+            if( is_array( $query ) ) {
32 32
                 $queries[] = $query;
33 33
             }
34 34
         }
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
     /**
39 39
      * @return string
40 40
      */
41
-    public function buildSqlLines(array $values, array $conditions)
41
+    public function buildSqlLines( array $values, array $conditions )
42 42
     {
43 43
         $string = '';
44
-        $values = array_filter($values);
45
-        foreach ($conditions as $key => $value) {
46
-            if (!isset($values[$key])) {
44
+        $values = array_filter( $values );
45
+        foreach( $conditions as $key => $value ) {
46
+            if( !isset($values[$key]) ) {
47 47
                 continue;
48 48
             }
49
-            $values[$key] = implode(',', (array) $values[$key]);
50
-            $string.= Str::contains($value, '%s')
51
-                ? sprintf($value, strval($values[$key]))
49
+            $values[$key] = implode( ',', (array)$values[$key] );
50
+            $string .= Str::contains( $value, '%s' )
51
+                ? sprintf( $value, strval( $values[$key] ) )
52 52
                 : $value;
53 53
         }
54 54
         return $string;
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
      * @param string $sprintfFormat
61 61
      * @return string
62 62
      */
63
-    public function buildSqlOr($values, $sprintfFormat)
63
+    public function buildSqlOr( $values, $sprintfFormat )
64 64
     {
65
-        if (!is_array($values)) {
66
-            $values = explode(',', $values);
65
+        if( !is_array( $values ) ) {
66
+            $values = explode( ',', $values );
67 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);
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 73
     }
74 74
 
75 75
     /**
@@ -79,23 +79,23 @@  discard block
 block discarded – undo
79 79
      * @return string
80 80
      * @filter posts_search
81 81
      */
82
-    public function filterSearchByTitle($search, WP_Query $query)
82
+    public function filterSearchByTitle( $search, WP_Query $query )
83 83
     {
84
-        if (empty($search) || empty($query->get('search_terms'))) {
84
+        if( empty($search) || empty($query->get( 'search_terms' )) ) {
85 85
             return $search;
86 86
         }
87 87
         global $wpdb;
88
-        $n = empty($query->get('exact'))
88
+        $n = empty($query->get( 'exact' ))
89 89
             ? '%'
90 90
             : '';
91 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);
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 94
         }
95
-        if (!is_user_logged_in()) {
95
+        if( !is_user_logged_in() ) {
96 96
             $search[] = "{$wpdb->posts}.post_password = ''";
97 97
         }
98
-        return ' AND '.implode(' AND ', $search);
98
+        return ' AND '.implode( ' AND ', $search );
99 99
     }
100 100
 
101 101
     /**
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
      * @param bool $isEnabled
104 104
      * @return int
105 105
      */
106
-    public function getPaged($isEnabled = true)
106
+    public function getPaged( $isEnabled = true )
107 107
     {
108 108
         return $isEnabled
109
-            ? max(1, intval(filter_input(INPUT_GET, glsr()->constant('PAGED_QUERY_VAR'))))
109
+            ? max( 1, intval( filter_input( INPUT_GET, glsr()->constant( 'PAGED_QUERY_VAR' ) ) ) )
110 110
             : 1;
111 111
     }
112 112
 
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
      * @param string $value
115 115
      * @return void|array
116 116
      */
117
-    protected function buildQueryAssignedTo($value)
117
+    protected function buildQueryAssignedTo( $value )
118 118
     {
119
-        if (!empty($value)) {
120
-            $postIds = Arr::convertFromString($value, 'is_numeric');
119
+        if( !empty($value) ) {
120
+            $postIds = Arr::convertFromString( $value, 'is_numeric' );
121 121
             return [
122 122
                 'compare' => 'IN',
123 123
                 'key' => '_assigned_to',
124
-                'value' => glsr(Multilingual::class)->getPostIds($postIds),
124
+                'value' => glsr( Multilingual::class )->getPostIds( $postIds ),
125 125
             ];
126 126
         }
127 127
     }
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
      * @param array $value
131 131
      * @return void|array
132 132
      */
133
-    protected function buildQueryCategory($value)
133
+    protected function buildQueryCategory( $value )
134 134
     {
135
-        if (!empty($value)) {
135
+        if( !empty($value) ) {
136 136
             return [
137 137
                 'field' => 'term_id',
138 138
                 'taxonomy' => Application::TAXONOMY,
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
      * @param string $value
146 146
      * @return void|array
147 147
      */
148
-    protected function buildQueryEmail($value)
148
+    protected function buildQueryEmail( $value )
149 149
     {
150
-        if (!empty($value)) {
150
+        if( !empty($value) ) {
151 151
             return [
152 152
                 'key' => '_email',
153 153
                 'value' => $value,
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
      * @param string $value
160 160
      * @return void|array
161 161
      */
162
-    protected function buildQueryIpAddress($value)
162
+    protected function buildQueryIpAddress( $value )
163 163
     {
164
-        if (!empty($value)) {
164
+        if( !empty($value) ) {
165 165
             return [
166 166
                 'key' => '_ip_address',
167 167
                 'value' => $value,
@@ -173,10 +173,10 @@  discard block
 block discarded – undo
173 173
      * @param string $value
174 174
      * @return void|array
175 175
      */
176
-    protected function buildQueryRating($value)
176
+    protected function buildQueryRating( $value )
177 177
     {
178
-        if (is_numeric($value)
179
-            && in_array(intval($value), range(1, glsr()->constant('MAX_RATING', Rating::class)))) {
178
+        if( is_numeric( $value )
179
+            && in_array( intval( $value ), range( 1, glsr()->constant( 'MAX_RATING', Rating::class ) ) ) ) {
180 180
             return [
181 181
                 'compare' => '>=',
182 182
                 'key' => '_rating',
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
      * @param string $value
190 190
      * @return void|array
191 191
      */
192
-    protected function buildQueryType($value)
192
+    protected function buildQueryType( $value )
193 193
     {
194
-        if (!in_array($value, ['', 'all'])) {
194
+        if( !in_array( $value, ['', 'all'] ) ) {
195 195
             return [
196 196
                 'key' => '_review_type',
197 197
                 'value' => $value,
Please login to merge, or discard this patch.
plugin/Database/ReviewManager.php 2 patches
Indentation   +190 added lines, -190 removed lines patch added patch discarded remove patch
@@ -16,204 +16,204 @@
 block discarded – undo
16 16
 
17 17
 class ReviewManager
18 18
 {
19
-    /**
20
-     * @return false|Review
21
-     */
22
-    public function create(CreateReview $command)
23
-    {
24
-        $reviewValues = glsr(CreateReviewDefaults::class)->restrict((array) $command);
25
-        $reviewValues = apply_filters('site-reviews/create/review-values', $reviewValues, $command);
26
-        $reviewValues = Arr::prefixKeys($reviewValues);
27
-        unset($reviewValues['json']); // @todo remove the need for this
28
-        $postValues = [
29
-            'comment_status' => 'closed',
30
-            'meta_input' => $reviewValues,
31
-            'ping_status' => 'closed',
32
-            'post_content' => $reviewValues['_content'],
33
-            'post_date' => $reviewValues['_date'],
34
-            'post_date_gmt' => get_gmt_from_date($reviewValues['_date']),
35
-            'post_name' => $reviewValues['_review_type'].'-'.$reviewValues['_review_id'],
36
-            'post_status' => $this->getNewPostStatus($reviewValues, $command->blacklisted),
37
-            'post_title' => $reviewValues['_title'],
38
-            'post_type' => Application::POST_TYPE,
39
-        ];
40
-        $postId = wp_insert_post($postValues, true);
41
-        if (is_wp_error($postId)) {
42
-            glsr_log()->error($postId->get_error_message())->debug($postValues);
43
-            return false;
44
-        }
45
-        $this->setTerms($postId, $command->category);
46
-        $review = $this->single(get_post($postId));
47
-        do_action('site-reviews/review/created', $review, $command);
48
-        return $review;
49
-    }
19
+	/**
20
+	 * @return false|Review
21
+	 */
22
+	public function create(CreateReview $command)
23
+	{
24
+		$reviewValues = glsr(CreateReviewDefaults::class)->restrict((array) $command);
25
+		$reviewValues = apply_filters('site-reviews/create/review-values', $reviewValues, $command);
26
+		$reviewValues = Arr::prefixKeys($reviewValues);
27
+		unset($reviewValues['json']); // @todo remove the need for this
28
+		$postValues = [
29
+			'comment_status' => 'closed',
30
+			'meta_input' => $reviewValues,
31
+			'ping_status' => 'closed',
32
+			'post_content' => $reviewValues['_content'],
33
+			'post_date' => $reviewValues['_date'],
34
+			'post_date_gmt' => get_gmt_from_date($reviewValues['_date']),
35
+			'post_name' => $reviewValues['_review_type'].'-'.$reviewValues['_review_id'],
36
+			'post_status' => $this->getNewPostStatus($reviewValues, $command->blacklisted),
37
+			'post_title' => $reviewValues['_title'],
38
+			'post_type' => Application::POST_TYPE,
39
+		];
40
+		$postId = wp_insert_post($postValues, true);
41
+		if (is_wp_error($postId)) {
42
+			glsr_log()->error($postId->get_error_message())->debug($postValues);
43
+			return false;
44
+		}
45
+		$this->setTerms($postId, $command->category);
46
+		$review = $this->single(get_post($postId));
47
+		do_action('site-reviews/review/created', $review, $command);
48
+		return $review;
49
+	}
50 50
 
51
-    /**
52
-     * @param string $metaReviewId
53
-     * @return void
54
-     */
55
-    public function delete($metaReviewId)
56
-    {
57
-        if ($postId = $this->getPostId($metaReviewId)) {
58
-            wp_delete_post($postId, true);
59
-        }
60
-    }
51
+	/**
52
+	 * @param string $metaReviewId
53
+	 * @return void
54
+	 */
55
+	public function delete($metaReviewId)
56
+	{
57
+		if ($postId = $this->getPostId($metaReviewId)) {
58
+			wp_delete_post($postId, true);
59
+		}
60
+	}
61 61
 
62
-    /**
63
-     * @return object
64
-     */
65
-    public function get(array $args = [])
66
-    {
67
-        $args = glsr(ReviewsDefaults::class)->merge($args);
68
-        $metaQuery = glsr(QueryBuilder::class)->buildQuery(
69
-            ['assigned_to', 'email', 'ip_address', 'type', 'rating'],
70
-            $args
71
-        );
72
-        $taxQuery = glsr(QueryBuilder::class)->buildQuery(
73
-            ['category'],
74
-            ['category' => $this->normalizeTermIds($args['category'])]
75
-        );
76
-        $paged = glsr(QueryBuilder::class)->getPaged(
77
-            wp_validate_boolean($args['pagination'])
78
-        );
79
-        $parameters = [
80
-            'meta_key' => '_pinned',
81
-            'meta_query' => $metaQuery,
82
-            'offset' => $args['offset'],
83
-            'order' => $args['order'],
84
-            'orderby' => 'meta_value '.$args['orderby'],
85
-            'paged' => Arr::get($args, 'paged', $paged),
86
-            'post__in' => $args['post__in'],
87
-            'post__not_in' => $args['post__not_in'],
88
-            'post_status' => 'publish',
89
-            'post_type' => Application::POST_TYPE,
90
-            'posts_per_page' => $args['per_page'],
91
-            'tax_query' => $taxQuery,
92
-        ];
93
-        $parameters = apply_filters('site-reviews/get/reviews/query', $parameters, $args);
94
-        $query = new WP_Query($parameters);
95
-        $results = array_map([$this, 'single'], $query->posts);
96
-        $reviews = new Reviews($results, $query->max_num_pages, $args);
97
-        return apply_filters('site-reviews/get/reviews', $reviews, $query);
98
-    }
62
+	/**
63
+	 * @return object
64
+	 */
65
+	public function get(array $args = [])
66
+	{
67
+		$args = glsr(ReviewsDefaults::class)->merge($args);
68
+		$metaQuery = glsr(QueryBuilder::class)->buildQuery(
69
+			['assigned_to', 'email', 'ip_address', 'type', 'rating'],
70
+			$args
71
+		);
72
+		$taxQuery = glsr(QueryBuilder::class)->buildQuery(
73
+			['category'],
74
+			['category' => $this->normalizeTermIds($args['category'])]
75
+		);
76
+		$paged = glsr(QueryBuilder::class)->getPaged(
77
+			wp_validate_boolean($args['pagination'])
78
+		);
79
+		$parameters = [
80
+			'meta_key' => '_pinned',
81
+			'meta_query' => $metaQuery,
82
+			'offset' => $args['offset'],
83
+			'order' => $args['order'],
84
+			'orderby' => 'meta_value '.$args['orderby'],
85
+			'paged' => Arr::get($args, 'paged', $paged),
86
+			'post__in' => $args['post__in'],
87
+			'post__not_in' => $args['post__not_in'],
88
+			'post_status' => 'publish',
89
+			'post_type' => Application::POST_TYPE,
90
+			'posts_per_page' => $args['per_page'],
91
+			'tax_query' => $taxQuery,
92
+		];
93
+		$parameters = apply_filters('site-reviews/get/reviews/query', $parameters, $args);
94
+		$query = new WP_Query($parameters);
95
+		$results = array_map([$this, 'single'], $query->posts);
96
+		$reviews = new Reviews($results, $query->max_num_pages, $args);
97
+		return apply_filters('site-reviews/get/reviews', $reviews, $query);
98
+	}
99 99
 
100
-    /**
101
-     * @param string $metaReviewId
102
-     * @return int
103
-     */
104
-    public function getPostId($metaReviewId)
105
-    {
106
-        return glsr(SqlQueries::class)->getPostIdFromReviewId($metaReviewId);
107
-    }
100
+	/**
101
+	 * @param string $metaReviewId
102
+	 * @return int
103
+	 */
104
+	public function getPostId($metaReviewId)
105
+	{
106
+		return glsr(SqlQueries::class)->getPostIdFromReviewId($metaReviewId);
107
+	}
108 108
 
109
-    /**
110
-     * @return array
111
-     */
112
-    public function getRatingCounts(array $args = [])
113
-    {
114
-        $args = glsr(SiteReviewsSummaryDefaults::class)->filter($args);
115
-        $counts = glsr(CountsManager::class)->getCounts([
116
-            'post_ids' => Arr::convertFromString($args['assigned_to']),
117
-            'term_ids' => $this->normalizeTermIds($args['category']),
118
-            'type' => $args['type'],
119
-        ]);
120
-        return glsr(CountsManager::class)->flatten($counts, [
121
-            'min' => $args['rating'],
122
-        ]);
123
-    }
109
+	/**
110
+	 * @return array
111
+	 */
112
+	public function getRatingCounts(array $args = [])
113
+	{
114
+		$args = glsr(SiteReviewsSummaryDefaults::class)->filter($args);
115
+		$counts = glsr(CountsManager::class)->getCounts([
116
+			'post_ids' => Arr::convertFromString($args['assigned_to']),
117
+			'term_ids' => $this->normalizeTermIds($args['category']),
118
+			'type' => $args['type'],
119
+		]);
120
+		return glsr(CountsManager::class)->flatten($counts, [
121
+			'min' => $args['rating'],
122
+		]);
123
+	}
124 124
 
125
-    /**
126
-     * @param string $commaSeparatedTermIds
127
-     * @return array
128
-     */
129
-    public function normalizeTermIds($commaSeparatedTermIds)
130
-    {
131
-        $termIds = glsr_array_column($this->normalizeTerms($commaSeparatedTermIds), 'term_id');
132
-        return array_unique(array_map('intval', $termIds));
133
-    }
125
+	/**
126
+	 * @param string $commaSeparatedTermIds
127
+	 * @return array
128
+	 */
129
+	public function normalizeTermIds($commaSeparatedTermIds)
130
+	{
131
+		$termIds = glsr_array_column($this->normalizeTerms($commaSeparatedTermIds), 'term_id');
132
+		return array_unique(array_map('intval', $termIds));
133
+	}
134 134
 
135
-    /**
136
-     * @param string $commaSeparatedTermIds
137
-     * @return array
138
-     */
139
-    public function normalizeTerms($commaSeparatedTermIds)
140
-    {
141
-        $terms = [];
142
-        $termIds = Arr::convertFromString($commaSeparatedTermIds);
143
-        foreach ($termIds as $termId) {
144
-            if (is_numeric($termId)) {
145
-                $termId = intval($termId);
146
-            }
147
-            $term = term_exists($termId, Application::TAXONOMY);
148
-            if (!isset($term['term_id'])) {
149
-                continue;
150
-            }
151
-            $terms[] = $term;
152
-        }
153
-        return $terms;
154
-    }
135
+	/**
136
+	 * @param string $commaSeparatedTermIds
137
+	 * @return array
138
+	 */
139
+	public function normalizeTerms($commaSeparatedTermIds)
140
+	{
141
+		$terms = [];
142
+		$termIds = Arr::convertFromString($commaSeparatedTermIds);
143
+		foreach ($termIds as $termId) {
144
+			if (is_numeric($termId)) {
145
+				$termId = intval($termId);
146
+			}
147
+			$term = term_exists($termId, Application::TAXONOMY);
148
+			if (!isset($term['term_id'])) {
149
+				continue;
150
+			}
151
+			$terms[] = $term;
152
+		}
153
+		return $terms;
154
+	}
155 155
 
156
-    /**
157
-     * @param int $postId
158
-     * @return void
159
-     */
160
-    public function revert($postId)
161
-    {
162
-        if (Application::POST_TYPE != get_post_field('post_type', $postId)) {
163
-            return;
164
-        }
165
-        delete_post_meta($postId, '_edit_last');
166
-        $result = wp_update_post([
167
-            'ID' => $postId,
168
-            'post_content' => glsr(Database::class)->get($postId, 'content'),
169
-            'post_date' => glsr(Database::class)->get($postId, 'date'),
170
-            'post_title' => glsr(Database::class)->get($postId, 'title'),
171
-        ]);
172
-        if (is_wp_error($result)) {
173
-            glsr_log()->error($result->get_error_message());
174
-            return;
175
-        }
176
-        do_action('site-reviews/review/reverted', glsr_get_review($postId));
177
-    }
156
+	/**
157
+	 * @param int $postId
158
+	 * @return void
159
+	 */
160
+	public function revert($postId)
161
+	{
162
+		if (Application::POST_TYPE != get_post_field('post_type', $postId)) {
163
+			return;
164
+		}
165
+		delete_post_meta($postId, '_edit_last');
166
+		$result = wp_update_post([
167
+			'ID' => $postId,
168
+			'post_content' => glsr(Database::class)->get($postId, 'content'),
169
+			'post_date' => glsr(Database::class)->get($postId, 'date'),
170
+			'post_title' => glsr(Database::class)->get($postId, 'title'),
171
+		]);
172
+		if (is_wp_error($result)) {
173
+			glsr_log()->error($result->get_error_message());
174
+			return;
175
+		}
176
+		do_action('site-reviews/review/reverted', glsr_get_review($postId));
177
+	}
178 178
 
179
-    /**
180
-     * @return Review
181
-     */
182
-    public function single(WP_Post $post)
183
-    {
184
-        if (Application::POST_TYPE != $post->post_type) {
185
-            $post = new WP_Post((object) []);
186
-        }
187
-        $review = new Review($post);
188
-        return apply_filters('site-reviews/get/review', $review, $post);
189
-    }
179
+	/**
180
+	 * @return Review
181
+	 */
182
+	public function single(WP_Post $post)
183
+	{
184
+		if (Application::POST_TYPE != $post->post_type) {
185
+			$post = new WP_Post((object) []);
186
+		}
187
+		$review = new Review($post);
188
+		return apply_filters('site-reviews/get/review', $review, $post);
189
+	}
190 190
 
191
-    /**
192
-     * @param bool $isBlacklisted
193
-     * @return string
194
-     */
195
-    protected function getNewPostStatus(array $reviewValues, $isBlacklisted)
196
-    {
197
-        $requireApproval = glsr(OptionManager::class)->getBool('settings.general.require.approval');
198
-        return 'local' == $reviewValues['_review_type'] && ($requireApproval || $isBlacklisted)
199
-            ? 'pending'
200
-            : 'publish';
201
-    }
191
+	/**
192
+	 * @param bool $isBlacklisted
193
+	 * @return string
194
+	 */
195
+	protected function getNewPostStatus(array $reviewValues, $isBlacklisted)
196
+	{
197
+		$requireApproval = glsr(OptionManager::class)->getBool('settings.general.require.approval');
198
+		return 'local' == $reviewValues['_review_type'] && ($requireApproval || $isBlacklisted)
199
+			? 'pending'
200
+			: 'publish';
201
+	}
202 202
 
203
-    /**
204
-     * @param int $postId
205
-     * @param string $termIds
206
-     * @return void
207
-     */
208
-    protected function setTerms($postId, $termIds)
209
-    {
210
-        $termIds = $this->normalizeTermIds($termIds);
211
-        if (empty($termIds)) {
212
-            return;
213
-        }
214
-        $termTaxonomyIds = wp_set_object_terms($postId, $termIds, Application::TAXONOMY);
215
-        if (is_wp_error($termTaxonomyIds)) {
216
-            glsr_log()->error($termTaxonomyIds->get_error_message());
217
-        }
218
-    }
203
+	/**
204
+	 * @param int $postId
205
+	 * @param string $termIds
206
+	 * @return void
207
+	 */
208
+	protected function setTerms($postId, $termIds)
209
+	{
210
+		$termIds = $this->normalizeTermIds($termIds);
211
+		if (empty($termIds)) {
212
+			return;
213
+		}
214
+		$termTaxonomyIds = wp_set_object_terms($postId, $termIds, Application::TAXONOMY);
215
+		if (is_wp_error($termTaxonomyIds)) {
216
+			glsr_log()->error($termTaxonomyIds->get_error_message());
217
+		}
218
+	}
219 219
 }
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
     /**
20 20
      * @return false|Review
21 21
      */
22
-    public function create(CreateReview $command)
22
+    public function create( CreateReview $command )
23 23
     {
24
-        $reviewValues = glsr(CreateReviewDefaults::class)->restrict((array) $command);
25
-        $reviewValues = apply_filters('site-reviews/create/review-values', $reviewValues, $command);
26
-        $reviewValues = Arr::prefixKeys($reviewValues);
24
+        $reviewValues = glsr( CreateReviewDefaults::class )->restrict( (array)$command );
25
+        $reviewValues = apply_filters( 'site-reviews/create/review-values', $reviewValues, $command );
26
+        $reviewValues = Arr::prefixKeys( $reviewValues );
27 27
         unset($reviewValues['json']); // @todo remove the need for this
28 28
         $postValues = [
29 29
             'comment_status' => 'closed',
@@ -31,20 +31,20 @@  discard block
 block discarded – undo
31 31
             'ping_status' => 'closed',
32 32
             'post_content' => $reviewValues['_content'],
33 33
             'post_date' => $reviewValues['_date'],
34
-            'post_date_gmt' => get_gmt_from_date($reviewValues['_date']),
34
+            'post_date_gmt' => get_gmt_from_date( $reviewValues['_date'] ),
35 35
             'post_name' => $reviewValues['_review_type'].'-'.$reviewValues['_review_id'],
36
-            'post_status' => $this->getNewPostStatus($reviewValues, $command->blacklisted),
36
+            'post_status' => $this->getNewPostStatus( $reviewValues, $command->blacklisted ),
37 37
             'post_title' => $reviewValues['_title'],
38 38
             'post_type' => Application::POST_TYPE,
39 39
         ];
40
-        $postId = wp_insert_post($postValues, true);
41
-        if (is_wp_error($postId)) {
42
-            glsr_log()->error($postId->get_error_message())->debug($postValues);
40
+        $postId = wp_insert_post( $postValues, true );
41
+        if( is_wp_error( $postId ) ) {
42
+            glsr_log()->error( $postId->get_error_message() )->debug( $postValues );
43 43
             return false;
44 44
         }
45
-        $this->setTerms($postId, $command->category);
46
-        $review = $this->single(get_post($postId));
47
-        do_action('site-reviews/review/created', $review, $command);
45
+        $this->setTerms( $postId, $command->category );
46
+        $review = $this->single( get_post( $postId ) );
47
+        do_action( 'site-reviews/review/created', $review, $command );
48 48
         return $review;
49 49
     }
50 50
 
@@ -52,29 +52,29 @@  discard block
 block discarded – undo
52 52
      * @param string $metaReviewId
53 53
      * @return void
54 54
      */
55
-    public function delete($metaReviewId)
55
+    public function delete( $metaReviewId )
56 56
     {
57
-        if ($postId = $this->getPostId($metaReviewId)) {
58
-            wp_delete_post($postId, true);
57
+        if( $postId = $this->getPostId( $metaReviewId ) ) {
58
+            wp_delete_post( $postId, true );
59 59
         }
60 60
     }
61 61
 
62 62
     /**
63 63
      * @return object
64 64
      */
65
-    public function get(array $args = [])
65
+    public function get( array $args = [] )
66 66
     {
67
-        $args = glsr(ReviewsDefaults::class)->merge($args);
68
-        $metaQuery = glsr(QueryBuilder::class)->buildQuery(
67
+        $args = glsr( ReviewsDefaults::class )->merge( $args );
68
+        $metaQuery = glsr( QueryBuilder::class )->buildQuery(
69 69
             ['assigned_to', 'email', 'ip_address', 'type', 'rating'],
70 70
             $args
71 71
         );
72
-        $taxQuery = glsr(QueryBuilder::class)->buildQuery(
72
+        $taxQuery = glsr( QueryBuilder::class )->buildQuery(
73 73
             ['category'],
74
-            ['category' => $this->normalizeTermIds($args['category'])]
74
+            ['category' => $this->normalizeTermIds( $args['category'] )]
75 75
         );
76
-        $paged = glsr(QueryBuilder::class)->getPaged(
77
-            wp_validate_boolean($args['pagination'])
76
+        $paged = glsr( QueryBuilder::class )->getPaged(
77
+            wp_validate_boolean( $args['pagination'] )
78 78
         );
79 79
         $parameters = [
80 80
             'meta_key' => '_pinned',
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             'offset' => $args['offset'],
83 83
             'order' => $args['order'],
84 84
             'orderby' => 'meta_value '.$args['orderby'],
85
-            'paged' => Arr::get($args, 'paged', $paged),
85
+            'paged' => Arr::get( $args, 'paged', $paged ),
86 86
             'post__in' => $args['post__in'],
87 87
             'post__not_in' => $args['post__not_in'],
88 88
             'post_status' => 'publish',
@@ -90,62 +90,62 @@  discard block
 block discarded – undo
90 90
             'posts_per_page' => $args['per_page'],
91 91
             'tax_query' => $taxQuery,
92 92
         ];
93
-        $parameters = apply_filters('site-reviews/get/reviews/query', $parameters, $args);
94
-        $query = new WP_Query($parameters);
95
-        $results = array_map([$this, 'single'], $query->posts);
96
-        $reviews = new Reviews($results, $query->max_num_pages, $args);
97
-        return apply_filters('site-reviews/get/reviews', $reviews, $query);
93
+        $parameters = apply_filters( 'site-reviews/get/reviews/query', $parameters, $args );
94
+        $query = new WP_Query( $parameters );
95
+        $results = array_map( [$this, 'single'], $query->posts );
96
+        $reviews = new Reviews( $results, $query->max_num_pages, $args );
97
+        return apply_filters( 'site-reviews/get/reviews', $reviews, $query );
98 98
     }
99 99
 
100 100
     /**
101 101
      * @param string $metaReviewId
102 102
      * @return int
103 103
      */
104
-    public function getPostId($metaReviewId)
104
+    public function getPostId( $metaReviewId )
105 105
     {
106
-        return glsr(SqlQueries::class)->getPostIdFromReviewId($metaReviewId);
106
+        return glsr( SqlQueries::class )->getPostIdFromReviewId( $metaReviewId );
107 107
     }
108 108
 
109 109
     /**
110 110
      * @return array
111 111
      */
112
-    public function getRatingCounts(array $args = [])
112
+    public function getRatingCounts( array $args = [] )
113 113
     {
114
-        $args = glsr(SiteReviewsSummaryDefaults::class)->filter($args);
115
-        $counts = glsr(CountsManager::class)->getCounts([
116
-            'post_ids' => Arr::convertFromString($args['assigned_to']),
117
-            'term_ids' => $this->normalizeTermIds($args['category']),
114
+        $args = glsr( SiteReviewsSummaryDefaults::class )->filter( $args );
115
+        $counts = glsr( CountsManager::class )->getCounts( [
116
+            'post_ids' => Arr::convertFromString( $args['assigned_to'] ),
117
+            'term_ids' => $this->normalizeTermIds( $args['category'] ),
118 118
             'type' => $args['type'],
119
-        ]);
120
-        return glsr(CountsManager::class)->flatten($counts, [
119
+        ] );
120
+        return glsr( CountsManager::class )->flatten( $counts, [
121 121
             'min' => $args['rating'],
122
-        ]);
122
+        ] );
123 123
     }
124 124
 
125 125
     /**
126 126
      * @param string $commaSeparatedTermIds
127 127
      * @return array
128 128
      */
129
-    public function normalizeTermIds($commaSeparatedTermIds)
129
+    public function normalizeTermIds( $commaSeparatedTermIds )
130 130
     {
131
-        $termIds = glsr_array_column($this->normalizeTerms($commaSeparatedTermIds), 'term_id');
132
-        return array_unique(array_map('intval', $termIds));
131
+        $termIds = glsr_array_column( $this->normalizeTerms( $commaSeparatedTermIds ), 'term_id' );
132
+        return array_unique( array_map( 'intval', $termIds ) );
133 133
     }
134 134
 
135 135
     /**
136 136
      * @param string $commaSeparatedTermIds
137 137
      * @return array
138 138
      */
139
-    public function normalizeTerms($commaSeparatedTermIds)
139
+    public function normalizeTerms( $commaSeparatedTermIds )
140 140
     {
141 141
         $terms = [];
142
-        $termIds = Arr::convertFromString($commaSeparatedTermIds);
143
-        foreach ($termIds as $termId) {
144
-            if (is_numeric($termId)) {
145
-                $termId = intval($termId);
142
+        $termIds = Arr::convertFromString( $commaSeparatedTermIds );
143
+        foreach( $termIds as $termId ) {
144
+            if( is_numeric( $termId ) ) {
145
+                $termId = intval( $termId );
146 146
             }
147
-            $term = term_exists($termId, Application::TAXONOMY);
148
-            if (!isset($term['term_id'])) {
147
+            $term = term_exists( $termId, Application::TAXONOMY );
148
+            if( !isset($term['term_id']) ) {
149 149
                 continue;
150 150
             }
151 151
             $terms[] = $term;
@@ -157,44 +157,44 @@  discard block
 block discarded – undo
157 157
      * @param int $postId
158 158
      * @return void
159 159
      */
160
-    public function revert($postId)
160
+    public function revert( $postId )
161 161
     {
162
-        if (Application::POST_TYPE != get_post_field('post_type', $postId)) {
162
+        if( Application::POST_TYPE != get_post_field( 'post_type', $postId ) ) {
163 163
             return;
164 164
         }
165
-        delete_post_meta($postId, '_edit_last');
166
-        $result = wp_update_post([
165
+        delete_post_meta( $postId, '_edit_last' );
166
+        $result = wp_update_post( [
167 167
             'ID' => $postId,
168
-            'post_content' => glsr(Database::class)->get($postId, 'content'),
169
-            'post_date' => glsr(Database::class)->get($postId, 'date'),
170
-            'post_title' => glsr(Database::class)->get($postId, 'title'),
171
-        ]);
172
-        if (is_wp_error($result)) {
173
-            glsr_log()->error($result->get_error_message());
168
+            'post_content' => glsr( Database::class )->get( $postId, 'content' ),
169
+            'post_date' => glsr( Database::class )->get( $postId, 'date' ),
170
+            'post_title' => glsr( Database::class )->get( $postId, 'title' ),
171
+        ] );
172
+        if( is_wp_error( $result ) ) {
173
+            glsr_log()->error( $result->get_error_message() );
174 174
             return;
175 175
         }
176
-        do_action('site-reviews/review/reverted', glsr_get_review($postId));
176
+        do_action( 'site-reviews/review/reverted', glsr_get_review( $postId ) );
177 177
     }
178 178
 
179 179
     /**
180 180
      * @return Review
181 181
      */
182
-    public function single(WP_Post $post)
182
+    public function single( WP_Post $post )
183 183
     {
184
-        if (Application::POST_TYPE != $post->post_type) {
185
-            $post = new WP_Post((object) []);
184
+        if( Application::POST_TYPE != $post->post_type ) {
185
+            $post = new WP_Post( (object)[] );
186 186
         }
187
-        $review = new Review($post);
188
-        return apply_filters('site-reviews/get/review', $review, $post);
187
+        $review = new Review( $post );
188
+        return apply_filters( 'site-reviews/get/review', $review, $post );
189 189
     }
190 190
 
191 191
     /**
192 192
      * @param bool $isBlacklisted
193 193
      * @return string
194 194
      */
195
-    protected function getNewPostStatus(array $reviewValues, $isBlacklisted)
195
+    protected function getNewPostStatus( array $reviewValues, $isBlacklisted )
196 196
     {
197
-        $requireApproval = glsr(OptionManager::class)->getBool('settings.general.require.approval');
197
+        $requireApproval = glsr( OptionManager::class )->getBool( 'settings.general.require.approval' );
198 198
         return 'local' == $reviewValues['_review_type'] && ($requireApproval || $isBlacklisted)
199 199
             ? 'pending'
200 200
             : 'publish';
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
      * @param string $termIds
206 206
      * @return void
207 207
      */
208
-    protected function setTerms($postId, $termIds)
208
+    protected function setTerms( $postId, $termIds )
209 209
     {
210
-        $termIds = $this->normalizeTermIds($termIds);
211
-        if (empty($termIds)) {
210
+        $termIds = $this->normalizeTermIds( $termIds );
211
+        if( empty($termIds) ) {
212 212
             return;
213 213
         }
214
-        $termTaxonomyIds = wp_set_object_terms($postId, $termIds, Application::TAXONOMY);
215
-        if (is_wp_error($termTaxonomyIds)) {
216
-            glsr_log()->error($termTaxonomyIds->get_error_message());
214
+        $termTaxonomyIds = wp_set_object_terms( $postId, $termIds, Application::TAXONOMY );
215
+        if( is_wp_error( $termTaxonomyIds ) ) {
216
+            glsr_log()->error( $termTaxonomyIds->get_error_message() );
217 217
         }
218 218
     }
219 219
 }
Please login to merge, or discard this patch.
plugin/Database/DefaultsManager.php 2 patches
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::convertFromDotNotation($this->defaults());
28
-    }
22
+	/**
23
+	 * @return array
24
+	 */
25
+	public function get()
26
+	{
27
+		return Arr::convertFromDotNotation($this->defaults());
28
+	}
29 29
 
30
-    /**
31
-     * @return array
32
-     */
33
-    public function set()
34
-    {
35
-        $settings = glsr(OptionManager::class)->all();
36
-        $currentSettings = Arr::removeEmptyValues($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::removeEmptyValues($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.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
     public function defaults()
13 13
     {
14 14
         $settings = $this->settings();
15
-        $defaults = (array) array_combine(array_keys($settings), glsr_array_column($settings, 'default'));
16
-        return wp_parse_args($defaults, [
15
+        $defaults = (array)array_combine( array_keys( $settings ), glsr_array_column( $settings, 'default' ) );
16
+        return wp_parse_args( $defaults, [
17 17
             'version' => '',
18 18
             'version_upgraded_from' => '',
19
-        ]);
19
+        ] );
20 20
     }
21 21
 
22 22
     /**
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function get()
26 26
     {
27
-        return Arr::convertFromDotNotation($this->defaults());
27
+        return Arr::convertFromDotNotation( $this->defaults() );
28 28
     }
29 29
 
30 30
     /**
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public function set()
34 34
     {
35
-        $settings = glsr(OptionManager::class)->all();
36
-        $currentSettings = Arr::removeEmptyValues($settings);
37
-        $defaultSettings = array_replace_recursive($this->get(), $currentSettings);
38
-        $updatedSettings = array_replace_recursive($settings, $defaultSettings);
39
-        update_option(OptionManager::databaseKey(), $updatedSettings);
35
+        $settings = glsr( OptionManager::class )->all();
36
+        $currentSettings = Arr::removeEmptyValues( $settings );
37
+        $defaultSettings = array_replace_recursive( $this->get(), $currentSettings );
38
+        $updatedSettings = array_replace_recursive( $settings, $defaultSettings );
39
+        update_option( OptionManager::databaseKey(), $updatedSettings );
40 40
         return $defaultSettings;
41 41
     }
42 42
 
@@ -45,17 +45,17 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function settings()
47 47
     {
48
-        $settings = apply_filters('site-reviews/addon/settings', glsr()->config('settings'));
49
-        return $this->normalize($settings);
48
+        $settings = apply_filters( 'site-reviews/addon/settings', glsr()->config( 'settings' ) );
49
+        return $this->normalize( $settings );
50 50
     }
51 51
 
52 52
     /**
53 53
      * @return array
54 54
      */
55
-    protected function normalize(array $settings)
55
+    protected function normalize( array $settings )
56 56
     {
57
-        array_walk($settings, function (&$setting) {
58
-            if (isset($setting['default'])) {
57
+        array_walk( $settings, function( &$setting ) {
58
+            if( isset($setting['default']) ) {
59 59
                 return;
60 60
             }
61 61
             $setting['default'] = '';
Please login to merge, or discard this patch.
plugin/Database/OptionManager.php 2 patches
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -9,157 +9,157 @@
 block discarded – undo
9 9
 
10 10
 class OptionManager
11 11
 {
12
-    /**
13
-     * @var array
14
-     */
15
-    protected $options;
12
+	/**
13
+	 * @var array
14
+	 */
15
+	protected $options;
16 16
 
17
-    /**
18
-     * @return string
19
-     */
20
-    public static function databaseKey($version = null)
21
-    {
22
-        if (1 == $version) {
23
-            return 'geminilabs_site_reviews_settings';
24
-        }
25
-        if (2 == $version) {
26
-            return 'geminilabs_site_reviews-v2';
27
-        }
28
-        if (null === $version) {
29
-            $version = explode('.', glsr()->version);
30
-            $version = array_shift($version);
31
-        }
32
-        return Str::snakeCase(Application::ID.'-v'.intval($version));
33
-    }
17
+	/**
18
+	 * @return string
19
+	 */
20
+	public static function databaseKey($version = null)
21
+	{
22
+		if (1 == $version) {
23
+			return 'geminilabs_site_reviews_settings';
24
+		}
25
+		if (2 == $version) {
26
+			return 'geminilabs_site_reviews-v2';
27
+		}
28
+		if (null === $version) {
29
+			$version = explode('.', glsr()->version);
30
+			$version = array_shift($version);
31
+		}
32
+		return Str::snakeCase(Application::ID.'-v'.intval($version));
33
+	}
34 34
 
35
-    /**
36
-     * @return array
37
-     */
38
-    public function all()
39
-    {
40
-        if (empty($this->options)) {
41
-            $this->reset();
42
-        }
43
-        return $this->options;
44
-    }
35
+	/**
36
+	 * @return array
37
+	 */
38
+	public function all()
39
+	{
40
+		if (empty($this->options)) {
41
+			$this->reset();
42
+		}
43
+		return $this->options;
44
+	}
45 45
 
46
-    /**
47
-     * @param string $path
48
-     * @return bool
49
-     */
50
-    public function delete($path)
51
-    {
52
-        $keys = explode('.', $path);
53
-        $last = array_pop($keys);
54
-        $options = $this->all();
55
-        $pointer = &$options;
56
-        foreach ($keys as $key) {
57
-            if (!isset($pointer[$key]) || !is_array($pointer[$key])) {
58
-                continue;
59
-            }
60
-            $pointer = &$pointer[$key];
61
-        }
62
-        unset($pointer[$last]);
63
-        return $this->set($options);
64
-    }
46
+	/**
47
+	 * @param string $path
48
+	 * @return bool
49
+	 */
50
+	public function delete($path)
51
+	{
52
+		$keys = explode('.', $path);
53
+		$last = array_pop($keys);
54
+		$options = $this->all();
55
+		$pointer = &$options;
56
+		foreach ($keys as $key) {
57
+			if (!isset($pointer[$key]) || !is_array($pointer[$key])) {
58
+				continue;
59
+			}
60
+			$pointer = &$pointer[$key];
61
+		}
62
+		unset($pointer[$last]);
63
+		return $this->set($options);
64
+	}
65 65
 
66
-    /**
67
-     * @param string $path
68
-     * @param mixed $fallback
69
-     * @param string $cast
70
-     * @return mixed
71
-     */
72
-    public function get($path = '', $fallback = '', $cast = '')
73
-    {
74
-        $result = Arr::get($this->all(), $path, $fallback);
75
-        return Helper::castTo($cast, $result);
76
-    }
66
+	/**
67
+	 * @param string $path
68
+	 * @param mixed $fallback
69
+	 * @param string $cast
70
+	 * @return mixed
71
+	 */
72
+	public function get($path = '', $fallback = '', $cast = '')
73
+	{
74
+		$result = Arr::get($this->all(), $path, $fallback);
75
+		return Helper::castTo($cast, $result);
76
+	}
77 77
 
78
-    /**
79
-     * @param string $path
80
-     * @return bool
81
-     */
82
-    public function getBool($path)
83
-    {
84
-        return Helper::castToBool($this->get($path));
85
-    }
78
+	/**
79
+	 * @param string $path
80
+	 * @return bool
81
+	 */
82
+	public function getBool($path)
83
+	{
84
+		return Helper::castToBool($this->get($path));
85
+	}
86 86
 
87
-    /**
88
-     * @param string $path
89
-     * @param mixed $fallback
90
-     * @param string $cast
91
-     * @return mixed
92
-     */
93
-    public function getWP($path, $fallback = '', $cast = '')
94
-    {
95
-        $option = get_option($path, $fallback);
96
-        if (empty($option)) {
97
-            $option = $fallback;
98
-        }
99
-        return Helper::castTo($cast, $option);
100
-    }
87
+	/**
88
+	 * @param string $path
89
+	 * @param mixed $fallback
90
+	 * @param string $cast
91
+	 * @return mixed
92
+	 */
93
+	public function getWP($path, $fallback = '', $cast = '')
94
+	{
95
+		$option = get_option($path, $fallback);
96
+		if (empty($option)) {
97
+			$option = $fallback;
98
+		}
99
+		return Helper::castTo($cast, $option);
100
+	}
101 101
 
102
-    /**
103
-     * @return string
104
-     */
105
-    public function json()
106
-    {
107
-        return json_encode($this->all());
108
-    }
102
+	/**
103
+	 * @return string
104
+	 */
105
+	public function json()
106
+	{
107
+		return json_encode($this->all());
108
+	}
109 109
 
110
-    /**
111
-     * @return array
112
-     */
113
-    public function normalize(array $options = [])
114
-    {
115
-        $options = wp_parse_args(
116
-            Arr::flatten($options),
117
-            glsr(DefaultsManager::class)->defaults()
118
-        );
119
-        array_walk($options, function (&$value) {
120
-            if (!is_string($value)) {
121
-                return;
122
-            }
123
-            $value = wp_kses($value, wp_kses_allowed_html('post'));
124
-        });
125
-        return Arr::convertFromDotNotation($options);
126
-    }
110
+	/**
111
+	 * @return array
112
+	 */
113
+	public function normalize(array $options = [])
114
+	{
115
+		$options = wp_parse_args(
116
+			Arr::flatten($options),
117
+			glsr(DefaultsManager::class)->defaults()
118
+		);
119
+		array_walk($options, function (&$value) {
120
+			if (!is_string($value)) {
121
+				return;
122
+			}
123
+			$value = wp_kses($value, wp_kses_allowed_html('post'));
124
+		});
125
+		return Arr::convertFromDotNotation($options);
126
+	}
127 127
 
128
-    /**
129
-     * @return bool
130
-     */
131
-    public function isRecaptchaEnabled()
132
-    {
133
-        $integration = $this->get('settings.submissions.recaptcha.integration');
134
-        return 'all' == $integration || ('guest' == $integration && !is_user_logged_in());
135
-    }
128
+	/**
129
+	 * @return bool
130
+	 */
131
+	public function isRecaptchaEnabled()
132
+	{
133
+		$integration = $this->get('settings.submissions.recaptcha.integration');
134
+		return 'all' == $integration || ('guest' == $integration && !is_user_logged_in());
135
+	}
136 136
 
137
-    /**
138
-     * @return array
139
-     */
140
-    public function reset()
141
-    {
142
-        $options = $this->getWP(static::databaseKey(), []);
143
-        if (!is_array($options) || empty($options)) {
144
-            delete_option(static::databaseKey());
145
-            $options = glsr()->defaults ?: [];
146
-        }
147
-        $this->options = $options;
148
-    }
137
+	/**
138
+	 * @return array
139
+	 */
140
+	public function reset()
141
+	{
142
+		$options = $this->getWP(static::databaseKey(), []);
143
+		if (!is_array($options) || empty($options)) {
144
+			delete_option(static::databaseKey());
145
+			$options = glsr()->defaults ?: [];
146
+		}
147
+		$this->options = $options;
148
+	}
149 149
 
150
-    /**
151
-     * @param string|array $pathOrOptions
152
-     * @param mixed $value
153
-     * @return bool
154
-     */
155
-    public function set($pathOrOptions, $value = '')
156
-    {
157
-        if (is_string($pathOrOptions)) {
158
-            $pathOrOptions = Arr::set($this->all(), $pathOrOptions, $value);
159
-        }
160
-        if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) {
161
-            $this->reset();
162
-        }
163
-        return $result;
164
-    }
150
+	/**
151
+	 * @param string|array $pathOrOptions
152
+	 * @param mixed $value
153
+	 * @return bool
154
+	 */
155
+	public function set($pathOrOptions, $value = '')
156
+	{
157
+		if (is_string($pathOrOptions)) {
158
+			$pathOrOptions = Arr::set($this->all(), $pathOrOptions, $value);
159
+		}
160
+		if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) {
161
+			$this->reset();
162
+		}
163
+		return $result;
164
+	}
165 165
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -17,19 +17,19 @@  discard block
 block discarded – undo
17 17
     /**
18 18
      * @return string
19 19
      */
20
-    public static function databaseKey($version = null)
20
+    public static function databaseKey( $version = null )
21 21
     {
22
-        if (1 == $version) {
22
+        if( 1 == $version ) {
23 23
             return 'geminilabs_site_reviews_settings';
24 24
         }
25
-        if (2 == $version) {
25
+        if( 2 == $version ) {
26 26
             return 'geminilabs_site_reviews-v2';
27 27
         }
28
-        if (null === $version) {
29
-            $version = explode('.', glsr()->version);
30
-            $version = array_shift($version);
28
+        if( null === $version ) {
29
+            $version = explode( '.', glsr()->version );
30
+            $version = array_shift( $version );
31 31
         }
32
-        return Str::snakeCase(Application::ID.'-v'.intval($version));
32
+        return Str::snakeCase( Application::ID.'-v'.intval( $version ) );
33 33
     }
34 34
 
35 35
     /**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function all()
39 39
     {
40
-        if (empty($this->options)) {
40
+        if( empty($this->options) ) {
41 41
             $this->reset();
42 42
         }
43 43
         return $this->options;
@@ -47,20 +47,20 @@  discard block
 block discarded – undo
47 47
      * @param string $path
48 48
      * @return bool
49 49
      */
50
-    public function delete($path)
50
+    public function delete( $path )
51 51
     {
52
-        $keys = explode('.', $path);
53
-        $last = array_pop($keys);
52
+        $keys = explode( '.', $path );
53
+        $last = array_pop( $keys );
54 54
         $options = $this->all();
55 55
         $pointer = &$options;
56
-        foreach ($keys as $key) {
57
-            if (!isset($pointer[$key]) || !is_array($pointer[$key])) {
56
+        foreach( $keys as $key ) {
57
+            if( !isset($pointer[$key]) || !is_array( $pointer[$key] ) ) {
58 58
                 continue;
59 59
             }
60 60
             $pointer = &$pointer[$key];
61 61
         }
62 62
         unset($pointer[$last]);
63
-        return $this->set($options);
63
+        return $this->set( $options );
64 64
     }
65 65
 
66 66
     /**
@@ -69,19 +69,19 @@  discard block
 block discarded – undo
69 69
      * @param string $cast
70 70
      * @return mixed
71 71
      */
72
-    public function get($path = '', $fallback = '', $cast = '')
72
+    public function get( $path = '', $fallback = '', $cast = '' )
73 73
     {
74
-        $result = Arr::get($this->all(), $path, $fallback);
75
-        return Helper::castTo($cast, $result);
74
+        $result = Arr::get( $this->all(), $path, $fallback );
75
+        return Helper::castTo( $cast, $result );
76 76
     }
77 77
 
78 78
     /**
79 79
      * @param string $path
80 80
      * @return bool
81 81
      */
82
-    public function getBool($path)
82
+    public function getBool( $path )
83 83
     {
84
-        return Helper::castToBool($this->get($path));
84
+        return Helper::castToBool( $this->get( $path ) );
85 85
     }
86 86
 
87 87
     /**
@@ -90,13 +90,13 @@  discard block
 block discarded – undo
90 90
      * @param string $cast
91 91
      * @return mixed
92 92
      */
93
-    public function getWP($path, $fallback = '', $cast = '')
93
+    public function getWP( $path, $fallback = '', $cast = '' )
94 94
     {
95
-        $option = get_option($path, $fallback);
96
-        if (empty($option)) {
95
+        $option = get_option( $path, $fallback );
96
+        if( empty($option) ) {
97 97
             $option = $fallback;
98 98
         }
99
-        return Helper::castTo($cast, $option);
99
+        return Helper::castTo( $cast, $option );
100 100
     }
101 101
 
102 102
     /**
@@ -104,25 +104,25 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function json()
106 106
     {
107
-        return json_encode($this->all());
107
+        return json_encode( $this->all() );
108 108
     }
109 109
 
110 110
     /**
111 111
      * @return array
112 112
      */
113
-    public function normalize(array $options = [])
113
+    public function normalize( array $options = [] )
114 114
     {
115 115
         $options = wp_parse_args(
116
-            Arr::flatten($options),
117
-            glsr(DefaultsManager::class)->defaults()
116
+            Arr::flatten( $options ),
117
+            glsr( DefaultsManager::class )->defaults()
118 118
         );
119
-        array_walk($options, function (&$value) {
120
-            if (!is_string($value)) {
119
+        array_walk( $options, function( &$value ) {
120
+            if( !is_string( $value ) ) {
121 121
                 return;
122 122
             }
123
-            $value = wp_kses($value, wp_kses_allowed_html('post'));
123
+            $value = wp_kses( $value, wp_kses_allowed_html( 'post' ) );
124 124
         });
125
-        return Arr::convertFromDotNotation($options);
125
+        return Arr::convertFromDotNotation( $options );
126 126
     }
127 127
 
128 128
     /**
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     public function isRecaptchaEnabled()
132 132
     {
133
-        $integration = $this->get('settings.submissions.recaptcha.integration');
133
+        $integration = $this->get( 'settings.submissions.recaptcha.integration' );
134 134
         return 'all' == $integration || ('guest' == $integration && !is_user_logged_in());
135 135
     }
136 136
 
@@ -139,9 +139,9 @@  discard block
 block discarded – undo
139 139
      */
140 140
     public function reset()
141 141
     {
142
-        $options = $this->getWP(static::databaseKey(), []);
143
-        if (!is_array($options) || empty($options)) {
144
-            delete_option(static::databaseKey());
142
+        $options = $this->getWP( static::databaseKey(), [] );
143
+        if( !is_array( $options ) || empty($options) ) {
144
+            delete_option( static::databaseKey() );
145 145
             $options = glsr()->defaults ?: [];
146 146
         }
147 147
         $this->options = $options;
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
      * @param mixed $value
153 153
      * @return bool
154 154
      */
155
-    public function set($pathOrOptions, $value = '')
155
+    public function set( $pathOrOptions, $value = '' )
156 156
     {
157
-        if (is_string($pathOrOptions)) {
158
-            $pathOrOptions = Arr::set($this->all(), $pathOrOptions, $value);
157
+        if( is_string( $pathOrOptions ) ) {
158
+            $pathOrOptions = Arr::set( $this->all(), $pathOrOptions, $value );
159 159
         }
160
-        if ($result = update_option(static::databaseKey(), (array) $pathOrOptions)) {
160
+        if( $result = update_option( static::databaseKey(), (array)$pathOrOptions ) ) {
161 161
             $this->reset();
162 162
         }
163 163
         return $result;
Please login to merge, or discard this patch.
plugin/Addons/Addon.php 3 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -11,83 +11,83 @@
 block discarded – undo
11 11
  */
12 12
 abstract class Addon
13 13
 {
14
-    const ID = '';
15
-    const SLUG = '';
16
-    const UPDATE_URL = '';
14
+	const ID = '';
15
+	const SLUG = '';
16
+	const UPDATE_URL = '';
17 17
 
18
-    public $file;
19
-    public $languages;
20
-    public $name;
21
-    public $testedTo;
22
-    public $updater;
23
-    public $version;
18
+	public $file;
19
+	public $languages;
20
+	public $name;
21
+	public $testedTo;
22
+	public $updater;
23
+	public $version;
24 24
 
25
-    public function __construct()
26
-    {
27
-        $this->file = str_replace('plugin/Application', static::ID, (new ReflectionClass($this))->getFileName());
28
-        $plugin = get_file_data($this->file, [
29
-            'languages' => 'Domain Path',
30
-            'name' => 'Plugin Name',
31
-            'testedTo' => 'Tested up to',
32
-            'version' => 'Version',
33
-        ], 'plugin');
34
-        array_walk($plugin, function ($value, $key) {
35
-            if (property_exists($this, $key)) {
36
-                $this->$key = $value;
37
-            }
38
-        });
39
-    }
25
+	public function __construct()
26
+	{
27
+		$this->file = str_replace('plugin/Application', static::ID, (new ReflectionClass($this))->getFileName());
28
+		$plugin = get_file_data($this->file, [
29
+			'languages' => 'Domain Path',
30
+			'name' => 'Plugin Name',
31
+			'testedTo' => 'Tested up to',
32
+			'version' => 'Version',
33
+		], 'plugin');
34
+		array_walk($plugin, function ($value, $key) {
35
+			if (property_exists($this, $key)) {
36
+				$this->$key = $value;
37
+			}
38
+		});
39
+	}
40 40
 
41
-    /**
42
-     * @param string $property
43
-     * @return void|string
44
-     */
45
-    public function __get($property)
46
-    {
47
-        if (property_exists($this, $property)) {
48
-            return $this->$property;
49
-        }
50
-        $constant = 'static::'.strtoupper($property);
51
-        if (defined($constant)) {
52
-            return constant($constant);
53
-        }
54
-    }
41
+	/**
42
+	 * @param string $property
43
+	 * @return void|string
44
+	 */
45
+	public function __get($property)
46
+	{
47
+		if (property_exists($this, $property)) {
48
+			return $this->$property;
49
+		}
50
+		$constant = 'static::'.strtoupper($property);
51
+		if (defined($constant)) {
52
+			return constant($constant);
53
+		}
54
+	}
55 55
 
56
-    public function make($class)
57
-    {}
56
+	public function make($class)
57
+	{}
58 58
 
59
-    /**
60
-     * @return void
61
-     */
62
-    abstract public function init();
59
+	/**
60
+	 * @return void
61
+	 */
62
+	abstract public function init();
63 63
 
64
-    /**
65
-     * @param string $file
66
-     * @return string
67
-     */
68
-    public function path($file = '')
69
-    {
70
-        return plugin_dir_path($this->file).ltrim(trim($file), '/');
71
-    }
64
+	/**
65
+	 * @param string $file
66
+	 * @return string
67
+	 */
68
+	public function path($file = '')
69
+	{
70
+		return plugin_dir_path($this->file).ltrim(trim($file), '/');
71
+	}
72 72
 
73
-    /**
74
-     * @return void
75
-     */
76
-    public function update()
77
-    {
78
-        $this->updater = new Updater(static::UPDATE_URL, $this->file, [
79
-            'license' => glsr_get_option('settings.licenses.'.static::ID),
80
-            'testedTo' => $this->testedTo,
81
-        ]);
82
-        $this->updater->init();
83
-    }
73
+	/**
74
+	 * @return void
75
+	 */
76
+	public function update()
77
+	{
78
+		$this->updater = new Updater(static::UPDATE_URL, $this->file, [
79
+			'license' => glsr_get_option('settings.licenses.'.static::ID),
80
+			'testedTo' => $this->testedTo,
81
+		]);
82
+		$this->updater->init();
83
+	}
84 84
 
85
-    /**
86
-     * @param string $path
87
-     * @return string
88
-     */
89
-    public function url($path = '')
90
-    {
91
-        return esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/'));
92
-    }
85
+	/**
86
+	 * @param string $path
87
+	 * @return string
88
+	 */
89
+	public function url($path = '')
90
+	{
91
+		return esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/'));
92
+	}
93 93
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -24,15 +24,15 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function __construct()
26 26
     {
27
-        $this->file = str_replace('plugin/Application', static::ID, (new ReflectionClass($this))->getFileName());
28
-        $plugin = get_file_data($this->file, [
27
+        $this->file = str_replace( 'plugin/Application', static::ID, (new ReflectionClass( $this ))->getFileName() );
28
+        $plugin = get_file_data( $this->file, [
29 29
             'languages' => 'Domain Path',
30 30
             'name' => 'Plugin Name',
31 31
             'testedTo' => 'Tested up to',
32 32
             'version' => 'Version',
33
-        ], 'plugin');
34
-        array_walk($plugin, function ($value, $key) {
35
-            if (property_exists($this, $key)) {
33
+        ], 'plugin' );
34
+        array_walk( $plugin, function( $value, $key ) {
35
+            if( property_exists( $this, $key ) ) {
36 36
                 $this->$key = $value;
37 37
             }
38 38
         });
@@ -42,18 +42,18 @@  discard block
 block discarded – undo
42 42
      * @param string $property
43 43
      * @return void|string
44 44
      */
45
-    public function __get($property)
45
+    public function __get( $property )
46 46
     {
47
-        if (property_exists($this, $property)) {
47
+        if( property_exists( $this, $property ) ) {
48 48
             return $this->$property;
49 49
         }
50
-        $constant = 'static::'.strtoupper($property);
51
-        if (defined($constant)) {
52
-            return constant($constant);
50
+        $constant = 'static::'.strtoupper( $property );
51
+        if( defined( $constant ) ) {
52
+            return constant( $constant );
53 53
         }
54 54
     }
55 55
 
56
-    public function make($class)
56
+    public function make( $class )
57 57
     {}
58 58
 
59 59
     /**
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
      * @param string $file
66 66
      * @return string
67 67
      */
68
-    public function path($file = '')
68
+    public function path( $file = '' )
69 69
     {
70
-        return plugin_dir_path($this->file).ltrim(trim($file), '/');
70
+        return plugin_dir_path( $this->file ).ltrim( trim( $file ), '/' );
71 71
     }
72 72
 
73 73
     /**
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
      */
76 76
     public function update()
77 77
     {
78
-        $this->updater = new Updater(static::UPDATE_URL, $this->file, [
79
-            'license' => glsr_get_option('settings.licenses.'.static::ID),
78
+        $this->updater = new Updater( static::UPDATE_URL, $this->file, [
79
+            'license' => glsr_get_option( 'settings.licenses.'.static::ID ),
80 80
             'testedTo' => $this->testedTo,
81
-        ]);
81
+        ] );
82 82
         $this->updater->init();
83 83
     }
84 84
 
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
      * @param string $path
87 87
      * @return string
88 88
      */
89
-    public function url($path = '')
89
+    public function url( $path = '' )
90 90
     {
91
-        return esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/'));
91
+        return esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) );
92 92
     }
93 93
 }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,8 @@
 block discarded – undo
54 54
     }
55 55
 
56 56
     public function make($class)
57
-    {}
57
+    {
58
+}
58 59
 
59 60
     /**
60 61
      * @return void
Please login to merge, or discard this patch.
plugin/Addons/Controller.php 2 patches
Indentation   +295 added lines, -295 removed lines patch added patch discarded remove patch
@@ -12,325 +12,325 @@
 block discarded – undo
12 12
 
13 13
 abstract class Controller extends BaseController
14 14
 {
15
-    /**
16
-     * @var Addon
17
-     */
18
-    protected $addon;
15
+	/**
16
+	 * @var Addon
17
+	 */
18
+	protected $addon;
19 19
 
20
-    public function __construct()
21
-    {
22
-        $this->setAddon();
23
-    }
20
+	public function __construct()
21
+	{
22
+		$this->setAddon();
23
+	}
24 24
 
25
-    /**
26
-     * @return void
27
-     * @action admin_enqueue_scripts
28
-     */
29
-    public function enqueueAdminAssets()
30
-    {
31
-        if (!$this->isReviewAdminPage()) {
32
-            return;
33
-        }
34
-        $this->enqueueAsset('css', ['suffix' => 'admin']);
35
-        $this->enqueueAsset('js', ['suffix' => 'admin']);
36
-    }
25
+	/**
26
+	 * @return void
27
+	 * @action admin_enqueue_scripts
28
+	 */
29
+	public function enqueueAdminAssets()
30
+	{
31
+		if (!$this->isReviewAdminPage()) {
32
+			return;
33
+		}
34
+		$this->enqueueAsset('css', ['suffix' => 'admin']);
35
+		$this->enqueueAsset('js', ['suffix' => 'admin']);
36
+	}
37 37
 
38
-    /**
39
-     * @return void
40
-     * @action enqueue_block_editor_assets
41
-     */
42
-    public function enqueueBlockAssets()
43
-    {
44
-        $this->registerAsset('css', ['suffix' => 'blocks']);
45
-        $this->registerAsset('js', ['suffix' => 'blocks']);
46
-    }
38
+	/**
39
+	 * @return void
40
+	 * @action enqueue_block_editor_assets
41
+	 */
42
+	public function enqueueBlockAssets()
43
+	{
44
+		$this->registerAsset('css', ['suffix' => 'blocks']);
45
+		$this->registerAsset('js', ['suffix' => 'blocks']);
46
+	}
47 47
 
48
-    /**
49
-     * @return void
50
-     * @action wp_enqueue_scripts
51
-     */
52
-    public function enqueuePublicAssets()
53
-    {
54
-        $this->enqueueAsset('css');
55
-        $this->enqueueAsset('js');
56
-    }
48
+	/**
49
+	 * @return void
50
+	 * @action wp_enqueue_scripts
51
+	 */
52
+	public function enqueuePublicAssets()
53
+	{
54
+		$this->enqueueAsset('css');
55
+		$this->enqueueAsset('js');
56
+	}
57 57
 
58
-    /**
59
-     * @return array
60
-     * @filter plugin_action_links_{addon_id}/{addon_id}.php
61
-     */
62
-    public function filterActionLinks(array $links)
63
-    {
64
-        $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
65
-            'href' => admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-addons'),
66
-        ]);
67
-        return $links;
68
-    }
58
+	/**
59
+	 * @return array
60
+	 * @filter plugin_action_links_{addon_id}/{addon_id}.php
61
+	 */
62
+	public function filterActionLinks(array $links)
63
+	{
64
+		$links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
65
+			'href' => admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-addons'),
66
+		]);
67
+		return $links;
68
+	}
69 69
 
70
-    /**
71
-     * @param string $path
72
-     * @return string
73
-     * @filter site-reviews/config
74
-     */
75
-    public function filterConfigPath($path)
76
-    {
77
-        $addonPrefix = $this->addon->id.'/';
78
-        return Str::contains($path, $addonPrefix)
79
-            ? $addonPrefix.str_replace($addonPrefix, '', $path)
80
-            : $path;
81
-    }
70
+	/**
71
+	 * @param string $path
72
+	 * @return string
73
+	 * @filter site-reviews/config
74
+	 */
75
+	public function filterConfigPath($path)
76
+	{
77
+		$addonPrefix = $this->addon->id.'/';
78
+		return Str::contains($path, $addonPrefix)
79
+			? $addonPrefix.str_replace($addonPrefix, '', $path)
80
+			: $path;
81
+	}
82 82
 
83
-    /**
84
-     * @return array
85
-     * @filter site-reviews/addon/documentation
86
-     */
87
-    public function filterDocumentation(array $documentation)
88
-    {
89
-        $documentation[$this->addon->name] = glsr(Template::class)->build($this->addon->id.'/documentation');
90
-        return $documentation;
91
-    }
83
+	/**
84
+	 * @return array
85
+	 * @filter site-reviews/addon/documentation
86
+	 */
87
+	public function filterDocumentation(array $documentation)
88
+	{
89
+		$documentation[$this->addon->name] = glsr(Template::class)->build($this->addon->id.'/documentation');
90
+		return $documentation;
91
+	}
92 92
 
93
-    /**
94
-     * @param string $path
95
-     * @param string $file
96
-     * @return string
97
-     * @filter site-reviews/path
98
-     */
99
-    public function filterFilePaths($path, $file)
100
-    {
101
-        $addonPrefix = $this->addon->id.'/';
102
-        return Str::startsWith($addonPrefix, $file)
103
-            ? $this->addon->path(Str::replaceFirst($addonPrefix, '', $file))
104
-            : $path;
105
-    }
93
+	/**
94
+	 * @param string $path
95
+	 * @param string $file
96
+	 * @return string
97
+	 * @filter site-reviews/path
98
+	 */
99
+	public function filterFilePaths($path, $file)
100
+	{
101
+		$addonPrefix = $this->addon->id.'/';
102
+		return Str::startsWith($addonPrefix, $file)
103
+			? $this->addon->path(Str::replaceFirst($addonPrefix, '', $file))
104
+			: $path;
105
+	}
106 106
 
107
-    /**
108
-     * @param string $translation
109
-     * @param string $text
110
-     * @return string
111
-     * @filter site-reviews/gettext/{addon_id}
112
-     */
113
-    public function filterGettext($translation, $text)
114
-    {
115
-        return glsr(Translator::class)->translate($translation, $this->addon->id, [
116
-            'single' => $text,
117
-        ]);
118
-    }
107
+	/**
108
+	 * @param string $translation
109
+	 * @param string $text
110
+	 * @return string
111
+	 * @filter site-reviews/gettext/{addon_id}
112
+	 */
113
+	public function filterGettext($translation, $text)
114
+	{
115
+		return glsr(Translator::class)->translate($translation, $this->addon->id, [
116
+			'single' => $text,
117
+		]);
118
+	}
119 119
 
120
-    /**
121
-     * @param string $translation
122
-     * @param string $text
123
-     * @param string $context
124
-     * @return string
125
-     * @filter site-reviews/gettext_with_context/{addon_id}
126
-     */
127
-    public function filterGettextWithContext($translation, $text, $context)
128
-    {
129
-        return glsr(Translator::class)->translate($translation, $this->addon->id, [
130
-            'context' => $context,
131
-            'single' => $text,
132
-        ]);
133
-    }
120
+	/**
121
+	 * @param string $translation
122
+	 * @param string $text
123
+	 * @param string $context
124
+	 * @return string
125
+	 * @filter site-reviews/gettext_with_context/{addon_id}
126
+	 */
127
+	public function filterGettextWithContext($translation, $text, $context)
128
+	{
129
+		return glsr(Translator::class)->translate($translation, $this->addon->id, [
130
+			'context' => $context,
131
+			'single' => $text,
132
+		]);
133
+	}
134 134
 
135
-    /**
136
-     * @param string $translation
137
-     * @param string $single
138
-     * @param string $plural
139
-     * @param int $number
140
-     * @return string
141
-     * @filter site-reviews/ngettext/{addon_id}
142
-     */
143
-    public function filterNgettext($translation, $single, $plural, $number)
144
-    {
145
-        return glsr(Translator::class)->translate($translation, $this->addon->id, [
146
-            'number' => $number,
147
-            'plural' => $plural,
148
-            'single' => $single,
149
-        ]);
150
-    }
135
+	/**
136
+	 * @param string $translation
137
+	 * @param string $single
138
+	 * @param string $plural
139
+	 * @param int $number
140
+	 * @return string
141
+	 * @filter site-reviews/ngettext/{addon_id}
142
+	 */
143
+	public function filterNgettext($translation, $single, $plural, $number)
144
+	{
145
+		return glsr(Translator::class)->translate($translation, $this->addon->id, [
146
+			'number' => $number,
147
+			'plural' => $plural,
148
+			'single' => $single,
149
+		]);
150
+	}
151 151
 
152
-    /**
153
-     * @param string $translation
154
-     * @param string $single
155
-     * @param string $plural
156
-     * @param int $number
157
-     * @param string $context
158
-     * @return string
159
-     * @filter site-reviews/ngettext_with_context/{addon_id}
160
-     */
161
-    public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context)
162
-    {
163
-        return glsr(Translator::class)->translate($translation, $this->addon->id, [
164
-            'context' => $context,
165
-            'number' => $number,
166
-            'plural' => $plural,
167
-            'single' => $single,
168
-        ]);
169
-    }
152
+	/**
153
+	 * @param string $translation
154
+	 * @param string $single
155
+	 * @param string $plural
156
+	 * @param int $number
157
+	 * @param string $context
158
+	 * @return string
159
+	 * @filter site-reviews/ngettext_with_context/{addon_id}
160
+	 */
161
+	public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context)
162
+	{
163
+		return glsr(Translator::class)->translate($translation, $this->addon->id, [
164
+			'context' => $context,
165
+			'number' => $number,
166
+			'plural' => $plural,
167
+			'single' => $single,
168
+		]);
169
+	}
170 170
 
171
-    /**
172
-     * @return array
173
-     * @filter site-reviews/addon/settings
174
-     */
175
-    public function filterSettings(array $settings)
176
-    {
177
-        $settingsFile = $this->addon->path('config/settings.php');
178
-        if (file_exists($settingsFile)) {
179
-            $settings = array_merge((include $settingsFile), $settings);
180
-        }
181
-        return $settings;
182
-    }
171
+	/**
172
+	 * @return array
173
+	 * @filter site-reviews/addon/settings
174
+	 */
175
+	public function filterSettings(array $settings)
176
+	{
177
+		$settingsFile = $this->addon->path('config/settings.php');
178
+		if (file_exists($settingsFile)) {
179
+			$settings = array_merge((include $settingsFile), $settings);
180
+		}
181
+		return $settings;
182
+	}
183 183
 
184
-    /**
185
-     * @return array
186
-     * @filter site-reviews/addon/system-info
187
-     */
188
-    public function filterSystemInfo(array $details)
189
-    {
190
-        $version = $this->addon->version;
191
-        $previousVersion = glsr(OptionManager::class)->get('addons.'.$this->addon->id.'.version_upgraded_from');
192
-        if (empty($previousVersion)) {
193
-            $previousVersion = $version;
194
-        }
195
-        $details[$this->addon->name] = sprintf('%s (%s)', $this->addon->version, $previousVersion);
196
-        return $details;
197
-    }
184
+	/**
185
+	 * @return array
186
+	 * @filter site-reviews/addon/system-info
187
+	 */
188
+	public function filterSystemInfo(array $details)
189
+	{
190
+		$version = $this->addon->version;
191
+		$previousVersion = glsr(OptionManager::class)->get('addons.'.$this->addon->id.'.version_upgraded_from');
192
+		if (empty($previousVersion)) {
193
+			$previousVersion = $version;
194
+		}
195
+		$details[$this->addon->name] = sprintf('%s (%s)', $this->addon->version, $previousVersion);
196
+		return $details;
197
+	}
198 198
 
199
-    /**
200
-     * @return array
201
-     * @filter site-reviews/translation/entries
202
-     */
203
-    public function filterTranslationEntries(array $entries)
204
-    {
205
-        $potFile = $this->addon->path($this->addon->languages.'/'.$this->addon->id.'.pot');
206
-        return glsr(Translation::class)->extractEntriesFromPotFile($potFile, $entries);
207
-    }
199
+	/**
200
+	 * @return array
201
+	 * @filter site-reviews/translation/entries
202
+	 */
203
+	public function filterTranslationEntries(array $entries)
204
+	{
205
+		$potFile = $this->addon->path($this->addon->languages.'/'.$this->addon->id.'.pot');
206
+		return glsr(Translation::class)->extractEntriesFromPotFile($potFile, $entries);
207
+	}
208 208
 
209
-    /**
210
-     * @return array
211
-     * @filter site-reviews/translator/domains
212
-     */
213
-    public function filterTranslatorDomains(array $domains)
214
-    {
215
-        $domains[] = $this->addon->id;
216
-        return $domains;
217
-    }
209
+	/**
210
+	 * @return array
211
+	 * @filter site-reviews/translator/domains
212
+	 */
213
+	public function filterTranslatorDomains(array $domains)
214
+	{
215
+		$domains[] = $this->addon->id;
216
+		return $domains;
217
+	}
218 218
 
219
-    /**
220
-     * @return void
221
-     * @action init
222
-     */
223
-    public function registerBlocks()
224
-    {
225
-    }
219
+	/**
220
+	 * @return void
221
+	 * @action init
222
+	 */
223
+	public function registerBlocks()
224
+	{
225
+	}
226 226
 
227
-    /**
228
-     * @return void
229
-     * @action plugins_loaded
230
-     */
231
-    public function registerLanguages()
232
-    {
233
-        load_plugin_textdomain($this->addon->id, false,
234
-            trailingslashit(plugin_basename($this->addon->path()).'/'.$this->addon->languages)
235
-        );
236
-    }
227
+	/**
228
+	 * @return void
229
+	 * @action plugins_loaded
230
+	 */
231
+	public function registerLanguages()
232
+	{
233
+		load_plugin_textdomain($this->addon->id, false,
234
+			trailingslashit(plugin_basename($this->addon->path()).'/'.$this->addon->languages)
235
+		);
236
+	}
237 237
 
238
-    /**
239
-     * @return void
240
-     * @action init
241
-     */
242
-    public function registerShortcodes()
243
-    {
244
-    }
238
+	/**
239
+	 * @return void
240
+	 * @action init
241
+	 */
242
+	public function registerShortcodes()
243
+	{
244
+	}
245 245
 
246
-    /**
247
-     * @return void
248
-     * @action admin_init
249
-     */
250
-    public function registerTinymcePopups()
251
-    {
252
-    }
246
+	/**
247
+	 * @return void
248
+	 * @action admin_init
249
+	 */
250
+	public function registerTinymcePopups()
251
+	{
252
+	}
253 253
 
254
-    /**
255
-     * @return void
256
-     * @action widgets_init
257
-     */
258
-    public function registerWidgets()
259
-    {
260
-    }
254
+	/**
255
+	 * @return void
256
+	 * @action widgets_init
257
+	 */
258
+	public function registerWidgets()
259
+	{
260
+	}
261 261
 
262
-    /**
263
-     * @param string $rows
264
-     * @return void
265
-     * @action site-reviews/addon/settings/{addon_slug}
266
-     */
267
-    public function renderSettings($rows)
268
-    {
269
-        glsr(Template::class)->render($this->addon->id.'/views/settings', [
270
-            'context' => [
271
-                'rows' => $rows,
272
-                'title' => $this->addon->name,
273
-            ],
274
-        ]);
275
-    }
262
+	/**
263
+	 * @param string $rows
264
+	 * @return void
265
+	 * @action site-reviews/addon/settings/{addon_slug}
266
+	 */
267
+	public function renderSettings($rows)
268
+	{
269
+		glsr(Template::class)->render($this->addon->id.'/views/settings', [
270
+			'context' => [
271
+				'rows' => $rows,
272
+				'title' => $this->addon->name,
273
+			],
274
+		]);
275
+	}
276 276
 
277
-    /**
278
-     * @param string $extension
279
-     * @return array
280
-     */
281
-    protected function buildAssetArgs($extension, array $args = [])
282
-    {
283
-        $args = wp_parse_args($args, [
284
-            'dependencies' => [],
285
-            'in_footer' => true,
286
-            'suffix' => '',
287
-        ]);
288
-        $path = 'assets/'.$this->addon->id.Str::prefix('-', $args['suffix']).'.'.$extension;
289
-        if (!file_exists($this->addon->path($path)) || !in_array($extension, ['css', 'js'])) {
290
-            return [];
291
-        }
292
-        $funcArgs = [
293
-            $this->addon->id.Str::prefix('/', $args['suffix']),
294
-            $this->addon->url($path),
295
-            array_merge([glsr()->id.Str::prefix('/', $args['suffix'])], $args['dependencies']),
296
-            $this->addon->version,
297
-        ];
298
-        if ('js' === $extension && $args['in_footer']) {
299
-            $funcArgs[] = true; // load script in the footer
300
-        }
301
-        return $funcArgs;
302
-    }
277
+	/**
278
+	 * @param string $extension
279
+	 * @return array
280
+	 */
281
+	protected function buildAssetArgs($extension, array $args = [])
282
+	{
283
+		$args = wp_parse_args($args, [
284
+			'dependencies' => [],
285
+			'in_footer' => true,
286
+			'suffix' => '',
287
+		]);
288
+		$path = 'assets/'.$this->addon->id.Str::prefix('-', $args['suffix']).'.'.$extension;
289
+		if (!file_exists($this->addon->path($path)) || !in_array($extension, ['css', 'js'])) {
290
+			return [];
291
+		}
292
+		$funcArgs = [
293
+			$this->addon->id.Str::prefix('/', $args['suffix']),
294
+			$this->addon->url($path),
295
+			array_merge([glsr()->id.Str::prefix('/', $args['suffix'])], $args['dependencies']),
296
+			$this->addon->version,
297
+		];
298
+		if ('js' === $extension && $args['in_footer']) {
299
+			$funcArgs[] = true; // load script in the footer
300
+		}
301
+		return $funcArgs;
302
+	}
303 303
 
304
-    /**
305
-     * @param string $extension
306
-     * @return void
307
-     */
308
-    protected function enqueueAsset($extension, array $args = [])
309
-    {
310
-        if ($args = $this->buildAssetArgs($extension, $args)) {
311
-            $function = 'js' === $extension
312
-                ? 'wp_enqueue_script'
313
-                : 'wp_enqueue_style';
314
-            call_user_func_array($function, $args);
315
-        }
316
-    }
304
+	/**
305
+	 * @param string $extension
306
+	 * @return void
307
+	 */
308
+	protected function enqueueAsset($extension, array $args = [])
309
+	{
310
+		if ($args = $this->buildAssetArgs($extension, $args)) {
311
+			$function = 'js' === $extension
312
+				? 'wp_enqueue_script'
313
+				: 'wp_enqueue_style';
314
+			call_user_func_array($function, $args);
315
+		}
316
+	}
317 317
 
318
-    /**
319
-     * @param string $extension
320
-     * @return void
321
-     */
322
-    protected function registerAsset($extension, array $args = [])
323
-    {
324
-        if ($args = $this->buildAssetArgs($extension, $args)) {
325
-            $function = 'js' === $extension
326
-                ? 'wp_register_script'
327
-                : 'wp_register_style';
328
-            call_user_func_array($function, $args);
329
-        }
330
-    }
318
+	/**
319
+	 * @param string $extension
320
+	 * @return void
321
+	 */
322
+	protected function registerAsset($extension, array $args = [])
323
+	{
324
+		if ($args = $this->buildAssetArgs($extension, $args)) {
325
+			$function = 'js' === $extension
326
+				? 'wp_register_script'
327
+				: 'wp_register_style';
328
+			call_user_func_array($function, $args);
329
+		}
330
+	}
331 331
 
332
-    /**
333
-     * @return void
334
-     */
335
-    abstract protected function setAddon();
332
+	/**
333
+	 * @return void
334
+	 */
335
+	abstract protected function setAddon();
336 336
 }
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function enqueueAdminAssets()
30 30
     {
31
-        if (!$this->isReviewAdminPage()) {
31
+        if( !$this->isReviewAdminPage() ) {
32 32
             return;
33 33
         }
34
-        $this->enqueueAsset('css', ['suffix' => 'admin']);
35
-        $this->enqueueAsset('js', ['suffix' => 'admin']);
34
+        $this->enqueueAsset( 'css', ['suffix' => 'admin'] );
35
+        $this->enqueueAsset( 'js', ['suffix' => 'admin'] );
36 36
     }
37 37
 
38 38
     /**
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function enqueueBlockAssets()
43 43
     {
44
-        $this->registerAsset('css', ['suffix' => 'blocks']);
45
-        $this->registerAsset('js', ['suffix' => 'blocks']);
44
+        $this->registerAsset( 'css', ['suffix' => 'blocks'] );
45
+        $this->registerAsset( 'js', ['suffix' => 'blocks'] );
46 46
     }
47 47
 
48 48
     /**
@@ -51,19 +51,19 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function enqueuePublicAssets()
53 53
     {
54
-        $this->enqueueAsset('css');
55
-        $this->enqueueAsset('js');
54
+        $this->enqueueAsset( 'css' );
55
+        $this->enqueueAsset( 'js' );
56 56
     }
57 57
 
58 58
     /**
59 59
      * @return array
60 60
      * @filter plugin_action_links_{addon_id}/{addon_id}.php
61 61
      */
62
-    public function filterActionLinks(array $links)
62
+    public function filterActionLinks( array $links )
63 63
     {
64
-        $links['settings'] = glsr(Builder::class)->a(__('Settings', 'site-reviews'), [
65
-            'href' => admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-addons'),
66
-        ]);
64
+        $links['settings'] = glsr( Builder::class )->a( __( 'Settings', 'site-reviews' ), [
65
+            'href' => admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=settings#tab-addons' ),
66
+        ] );
67 67
         return $links;
68 68
     }
69 69
 
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
      * @return string
73 73
      * @filter site-reviews/config
74 74
      */
75
-    public function filterConfigPath($path)
75
+    public function filterConfigPath( $path )
76 76
     {
77 77
         $addonPrefix = $this->addon->id.'/';
78
-        return Str::contains($path, $addonPrefix)
79
-            ? $addonPrefix.str_replace($addonPrefix, '', $path)
78
+        return Str::contains( $path, $addonPrefix )
79
+            ? $addonPrefix.str_replace( $addonPrefix, '', $path )
80 80
             : $path;
81 81
     }
82 82
 
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
      * @return array
85 85
      * @filter site-reviews/addon/documentation
86 86
      */
87
-    public function filterDocumentation(array $documentation)
87
+    public function filterDocumentation( array $documentation )
88 88
     {
89
-        $documentation[$this->addon->name] = glsr(Template::class)->build($this->addon->id.'/documentation');
89
+        $documentation[$this->addon->name] = glsr( Template::class )->build( $this->addon->id.'/documentation' );
90 90
         return $documentation;
91 91
     }
92 92
 
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
      * @return string
97 97
      * @filter site-reviews/path
98 98
      */
99
-    public function filterFilePaths($path, $file)
99
+    public function filterFilePaths( $path, $file )
100 100
     {
101 101
         $addonPrefix = $this->addon->id.'/';
102
-        return Str::startsWith($addonPrefix, $file)
103
-            ? $this->addon->path(Str::replaceFirst($addonPrefix, '', $file))
102
+        return Str::startsWith( $addonPrefix, $file )
103
+            ? $this->addon->path( Str::replaceFirst( $addonPrefix, '', $file ) )
104 104
             : $path;
105 105
     }
106 106
 
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
      * @return string
111 111
      * @filter site-reviews/gettext/{addon_id}
112 112
      */
113
-    public function filterGettext($translation, $text)
113
+    public function filterGettext( $translation, $text )
114 114
     {
115
-        return glsr(Translator::class)->translate($translation, $this->addon->id, [
115
+        return glsr( Translator::class )->translate( $translation, $this->addon->id, [
116 116
             'single' => $text,
117
-        ]);
117
+        ] );
118 118
     }
119 119
 
120 120
     /**
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
      * @return string
125 125
      * @filter site-reviews/gettext_with_context/{addon_id}
126 126
      */
127
-    public function filterGettextWithContext($translation, $text, $context)
127
+    public function filterGettextWithContext( $translation, $text, $context )
128 128
     {
129
-        return glsr(Translator::class)->translate($translation, $this->addon->id, [
129
+        return glsr( Translator::class )->translate( $translation, $this->addon->id, [
130 130
             'context' => $context,
131 131
             'single' => $text,
132
-        ]);
132
+        ] );
133 133
     }
134 134
 
135 135
     /**
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
      * @return string
141 141
      * @filter site-reviews/ngettext/{addon_id}
142 142
      */
143
-    public function filterNgettext($translation, $single, $plural, $number)
143
+    public function filterNgettext( $translation, $single, $plural, $number )
144 144
     {
145
-        return glsr(Translator::class)->translate($translation, $this->addon->id, [
145
+        return glsr( Translator::class )->translate( $translation, $this->addon->id, [
146 146
             'number' => $number,
147 147
             'plural' => $plural,
148 148
             'single' => $single,
149
-        ]);
149
+        ] );
150 150
     }
151 151
 
152 152
     /**
@@ -158,25 +158,25 @@  discard block
 block discarded – undo
158 158
      * @return string
159 159
      * @filter site-reviews/ngettext_with_context/{addon_id}
160 160
      */
161
-    public function filterNgettextWithContextSiteReviews($translation, $single, $plural, $number, $context)
161
+    public function filterNgettextWithContextSiteReviews( $translation, $single, $plural, $number, $context )
162 162
     {
163
-        return glsr(Translator::class)->translate($translation, $this->addon->id, [
163
+        return glsr( Translator::class )->translate( $translation, $this->addon->id, [
164 164
             'context' => $context,
165 165
             'number' => $number,
166 166
             'plural' => $plural,
167 167
             'single' => $single,
168
-        ]);
168
+        ] );
169 169
     }
170 170
 
171 171
     /**
172 172
      * @return array
173 173
      * @filter site-reviews/addon/settings
174 174
      */
175
-    public function filterSettings(array $settings)
175
+    public function filterSettings( array $settings )
176 176
     {
177
-        $settingsFile = $this->addon->path('config/settings.php');
178
-        if (file_exists($settingsFile)) {
179
-            $settings = array_merge((include $settingsFile), $settings);
177
+        $settingsFile = $this->addon->path( 'config/settings.php' );
178
+        if( file_exists( $settingsFile ) ) {
179
+            $settings = array_merge( (include $settingsFile), $settings );
180 180
         }
181 181
         return $settings;
182 182
     }
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
      * @return array
186 186
      * @filter site-reviews/addon/system-info
187 187
      */
188
-    public function filterSystemInfo(array $details)
188
+    public function filterSystemInfo( array $details )
189 189
     {
190 190
         $version = $this->addon->version;
191
-        $previousVersion = glsr(OptionManager::class)->get('addons.'.$this->addon->id.'.version_upgraded_from');
192
-        if (empty($previousVersion)) {
191
+        $previousVersion = glsr( OptionManager::class )->get( 'addons.'.$this->addon->id.'.version_upgraded_from' );
192
+        if( empty($previousVersion) ) {
193 193
             $previousVersion = $version;
194 194
         }
195
-        $details[$this->addon->name] = sprintf('%s (%s)', $this->addon->version, $previousVersion);
195
+        $details[$this->addon->name] = sprintf( '%s (%s)', $this->addon->version, $previousVersion );
196 196
         return $details;
197 197
     }
198 198
 
@@ -200,17 +200,17 @@  discard block
 block discarded – undo
200 200
      * @return array
201 201
      * @filter site-reviews/translation/entries
202 202
      */
203
-    public function filterTranslationEntries(array $entries)
203
+    public function filterTranslationEntries( array $entries )
204 204
     {
205
-        $potFile = $this->addon->path($this->addon->languages.'/'.$this->addon->id.'.pot');
206
-        return glsr(Translation::class)->extractEntriesFromPotFile($potFile, $entries);
205
+        $potFile = $this->addon->path( $this->addon->languages.'/'.$this->addon->id.'.pot' );
206
+        return glsr( Translation::class )->extractEntriesFromPotFile( $potFile, $entries );
207 207
     }
208 208
 
209 209
     /**
210 210
      * @return array
211 211
      * @filter site-reviews/translator/domains
212 212
      */
213
-    public function filterTranslatorDomains(array $domains)
213
+    public function filterTranslatorDomains( array $domains )
214 214
     {
215 215
         $domains[] = $this->addon->id;
216 216
         return $domains;
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
      */
231 231
     public function registerLanguages()
232 232
     {
233
-        load_plugin_textdomain($this->addon->id, false,
234
-            trailingslashit(plugin_basename($this->addon->path()).'/'.$this->addon->languages)
233
+        load_plugin_textdomain( $this->addon->id, false,
234
+            trailingslashit( plugin_basename( $this->addon->path() ).'/'.$this->addon->languages )
235 235
         );
236 236
     }
237 237
 
@@ -264,38 +264,38 @@  discard block
 block discarded – undo
264 264
      * @return void
265 265
      * @action site-reviews/addon/settings/{addon_slug}
266 266
      */
267
-    public function renderSettings($rows)
267
+    public function renderSettings( $rows )
268 268
     {
269
-        glsr(Template::class)->render($this->addon->id.'/views/settings', [
269
+        glsr( Template::class )->render( $this->addon->id.'/views/settings', [
270 270
             'context' => [
271 271
                 'rows' => $rows,
272 272
                 'title' => $this->addon->name,
273 273
             ],
274
-        ]);
274
+        ] );
275 275
     }
276 276
 
277 277
     /**
278 278
      * @param string $extension
279 279
      * @return array
280 280
      */
281
-    protected function buildAssetArgs($extension, array $args = [])
281
+    protected function buildAssetArgs( $extension, array $args = [] )
282 282
     {
283
-        $args = wp_parse_args($args, [
283
+        $args = wp_parse_args( $args, [
284 284
             'dependencies' => [],
285 285
             'in_footer' => true,
286 286
             'suffix' => '',
287
-        ]);
288
-        $path = 'assets/'.$this->addon->id.Str::prefix('-', $args['suffix']).'.'.$extension;
289
-        if (!file_exists($this->addon->path($path)) || !in_array($extension, ['css', 'js'])) {
287
+        ] );
288
+        $path = 'assets/'.$this->addon->id.Str::prefix( '-', $args['suffix'] ).'.'.$extension;
289
+        if( !file_exists( $this->addon->path( $path ) ) || !in_array( $extension, ['css', 'js'] ) ) {
290 290
             return [];
291 291
         }
292 292
         $funcArgs = [
293
-            $this->addon->id.Str::prefix('/', $args['suffix']),
294
-            $this->addon->url($path),
295
-            array_merge([glsr()->id.Str::prefix('/', $args['suffix'])], $args['dependencies']),
293
+            $this->addon->id.Str::prefix( '/', $args['suffix'] ),
294
+            $this->addon->url( $path ),
295
+            array_merge( [glsr()->id.Str::prefix( '/', $args['suffix'] )], $args['dependencies'] ),
296 296
             $this->addon->version,
297 297
         ];
298
-        if ('js' === $extension && $args['in_footer']) {
298
+        if( 'js' === $extension && $args['in_footer'] ) {
299 299
             $funcArgs[] = true; // load script in the footer
300 300
         }
301 301
         return $funcArgs;
@@ -305,13 +305,13 @@  discard block
 block discarded – undo
305 305
      * @param string $extension
306 306
      * @return void
307 307
      */
308
-    protected function enqueueAsset($extension, array $args = [])
308
+    protected function enqueueAsset( $extension, array $args = [] )
309 309
     {
310
-        if ($args = $this->buildAssetArgs($extension, $args)) {
310
+        if( $args = $this->buildAssetArgs( $extension, $args ) ) {
311 311
             $function = 'js' === $extension
312 312
                 ? 'wp_enqueue_script'
313 313
                 : 'wp_enqueue_style';
314
-            call_user_func_array($function, $args);
314
+            call_user_func_array( $function, $args );
315 315
         }
316 316
     }
317 317
 
@@ -319,13 +319,13 @@  discard block
 block discarded – undo
319 319
      * @param string $extension
320 320
      * @return void
321 321
      */
322
-    protected function registerAsset($extension, array $args = [])
322
+    protected function registerAsset( $extension, array $args = [] )
323 323
     {
324
-        if ($args = $this->buildAssetArgs($extension, $args)) {
324
+        if( $args = $this->buildAssetArgs( $extension, $args ) ) {
325 325
             $function = 'js' === $extension
326 326
                 ? 'wp_register_script'
327 327
                 : 'wp_register_style';
328
-            call_user_func_array($function, $args);
328
+            call_user_func_array( $function, $args );
329 329
         }
330 330
     }
331 331
 
Please login to merge, or discard this patch.
plugin/Addons/Hooks.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -4,36 +4,36 @@
 block discarded – undo
4 4
 
5 5
 abstract class Hooks
6 6
 {
7
-    protected $addon;
8
-    protected $basename;
9
-    protected $controller;
7
+	protected $addon;
8
+	protected $basename;
9
+	protected $controller;
10 10
 
11
-    /**
12
-     * @return void
13
-     */
14
-    public function run()
15
-    {
16
-        add_action('init',                                                   [$this->addon, 'update']);
17
-        add_action('admin_enqueue_scripts',                                  [$this->controller, 'enqueueAdminAssets']);
18
-        add_action('enqueue_block_editor_assets',                            [$this->controller, 'enqueueBlockAssets']);
19
-        add_action('wp_enqueue_scripts',                                     [$this->controller, 'enqueuePublicAssets']);
20
-        add_filter('plugin_action_links_'.$this->basename,                   [$this->controller, 'filterActionLinks']);
21
-        add_filter('site-reviews/config',                                    [$this->controller, 'filterConfigPath']);
22
-        add_filter('site-reviews/addon/documentation',                       [$this->controller, 'filterDocumentation']);
23
-        add_filter('site-reviews/gettext/site-reviews-images',               [$this->controller, 'filterGettext'], 10, 2);
24
-        add_filter('site-reviews/gettext_with_context/site-reviews-images',  [$this->controller, 'filterGettextWithContext'], 10, 3);
25
-        add_filter('site-reviews/ngettext/site-reviews-images',              [$this->controller, 'filterNgettext'], 10, 4);
26
-        add_filter('site-reviews/ngettext_with_context/site-reviews-images', [$this->controller, 'filterNgettextWithContext'], 10, 5);
27
-        add_filter('site-reviews/path',                                      [$this->controller, 'filterFilePaths'], 10, 2);
28
-        add_filter('site-reviews/addon/settings',                            [$this->controller, 'filterSettings']);
29
-        add_filter('site-reviews/addon/system-info',                         [$this->controller, 'filterSystemInfo']);
30
-        add_filter('site-reviews/translation/entries',                       [$this->controller, 'filterTranslationEntries']);
31
-        add_filter('site-reviews/translator/domains',                        [$this->controller, 'filterTranslatorDomains']);
32
-        add_action('init',                                                   [$this->controller, 'registerBlocks']);
33
-        add_action('plugins_loaded',                                         [$this->controller, 'registerLanguages']);
34
-        add_action('init',                                                   [$this->controller, 'registerShortcodes']);
35
-        add_action('init',                                                   [$this->controller, 'registerTinymcePopups']);
36
-        add_action('widgets_init',                                           [$this->controller, 'registerWidgets']);
37
-        add_action('site-reviews/addon/settings/'.$this->addon->slug,        [$this->controller, 'renderSettings']);
38
-    }
11
+	/**
12
+	 * @return void
13
+	 */
14
+	public function run()
15
+	{
16
+		add_action('init',                                                   [$this->addon, 'update']);
17
+		add_action('admin_enqueue_scripts',                                  [$this->controller, 'enqueueAdminAssets']);
18
+		add_action('enqueue_block_editor_assets',                            [$this->controller, 'enqueueBlockAssets']);
19
+		add_action('wp_enqueue_scripts',                                     [$this->controller, 'enqueuePublicAssets']);
20
+		add_filter('plugin_action_links_'.$this->basename,                   [$this->controller, 'filterActionLinks']);
21
+		add_filter('site-reviews/config',                                    [$this->controller, 'filterConfigPath']);
22
+		add_filter('site-reviews/addon/documentation',                       [$this->controller, 'filterDocumentation']);
23
+		add_filter('site-reviews/gettext/site-reviews-images',               [$this->controller, 'filterGettext'], 10, 2);
24
+		add_filter('site-reviews/gettext_with_context/site-reviews-images',  [$this->controller, 'filterGettextWithContext'], 10, 3);
25
+		add_filter('site-reviews/ngettext/site-reviews-images',              [$this->controller, 'filterNgettext'], 10, 4);
26
+		add_filter('site-reviews/ngettext_with_context/site-reviews-images', [$this->controller, 'filterNgettextWithContext'], 10, 5);
27
+		add_filter('site-reviews/path',                                      [$this->controller, 'filterFilePaths'], 10, 2);
28
+		add_filter('site-reviews/addon/settings',                            [$this->controller, 'filterSettings']);
29
+		add_filter('site-reviews/addon/system-info',                         [$this->controller, 'filterSystemInfo']);
30
+		add_filter('site-reviews/translation/entries',                       [$this->controller, 'filterTranslationEntries']);
31
+		add_filter('site-reviews/translator/domains',                        [$this->controller, 'filterTranslatorDomains']);
32
+		add_action('init',                                                   [$this->controller, 'registerBlocks']);
33
+		add_action('plugins_loaded',                                         [$this->controller, 'registerLanguages']);
34
+		add_action('init',                                                   [$this->controller, 'registerShortcodes']);
35
+		add_action('init',                                                   [$this->controller, 'registerTinymcePopups']);
36
+		add_action('widgets_init',                                           [$this->controller, 'registerWidgets']);
37
+		add_action('site-reviews/addon/settings/'.$this->addon->slug,        [$this->controller, 'renderSettings']);
38
+	}
39 39
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -13,27 +13,27 @@
 block discarded – undo
13 13
      */
14 14
     public function run()
15 15
     {
16
-        add_action('init',                                                   [$this->addon, 'update']);
17
-        add_action('admin_enqueue_scripts',                                  [$this->controller, 'enqueueAdminAssets']);
18
-        add_action('enqueue_block_editor_assets',                            [$this->controller, 'enqueueBlockAssets']);
19
-        add_action('wp_enqueue_scripts',                                     [$this->controller, 'enqueuePublicAssets']);
20
-        add_filter('plugin_action_links_'.$this->basename,                   [$this->controller, 'filterActionLinks']);
21
-        add_filter('site-reviews/config',                                    [$this->controller, 'filterConfigPath']);
22
-        add_filter('site-reviews/addon/documentation',                       [$this->controller, 'filterDocumentation']);
23
-        add_filter('site-reviews/gettext/site-reviews-images',               [$this->controller, 'filterGettext'], 10, 2);
24
-        add_filter('site-reviews/gettext_with_context/site-reviews-images',  [$this->controller, 'filterGettextWithContext'], 10, 3);
25
-        add_filter('site-reviews/ngettext/site-reviews-images',              [$this->controller, 'filterNgettext'], 10, 4);
26
-        add_filter('site-reviews/ngettext_with_context/site-reviews-images', [$this->controller, 'filterNgettextWithContext'], 10, 5);
27
-        add_filter('site-reviews/path',                                      [$this->controller, 'filterFilePaths'], 10, 2);
28
-        add_filter('site-reviews/addon/settings',                            [$this->controller, 'filterSettings']);
29
-        add_filter('site-reviews/addon/system-info',                         [$this->controller, 'filterSystemInfo']);
30
-        add_filter('site-reviews/translation/entries',                       [$this->controller, 'filterTranslationEntries']);
31
-        add_filter('site-reviews/translator/domains',                        [$this->controller, 'filterTranslatorDomains']);
32
-        add_action('init',                                                   [$this->controller, 'registerBlocks']);
33
-        add_action('plugins_loaded',                                         [$this->controller, 'registerLanguages']);
34
-        add_action('init',                                                   [$this->controller, 'registerShortcodes']);
35
-        add_action('init',                                                   [$this->controller, 'registerTinymcePopups']);
36
-        add_action('widgets_init',                                           [$this->controller, 'registerWidgets']);
37
-        add_action('site-reviews/addon/settings/'.$this->addon->slug,        [$this->controller, 'renderSettings']);
16
+        add_action( 'init', [$this->addon, 'update'] );
17
+        add_action( 'admin_enqueue_scripts', [$this->controller, 'enqueueAdminAssets'] );
18
+        add_action( 'enqueue_block_editor_assets', [$this->controller, 'enqueueBlockAssets'] );
19
+        add_action( 'wp_enqueue_scripts', [$this->controller, 'enqueuePublicAssets'] );
20
+        add_filter( 'plugin_action_links_'.$this->basename, [$this->controller, 'filterActionLinks'] );
21
+        add_filter( 'site-reviews/config', [$this->controller, 'filterConfigPath'] );
22
+        add_filter( 'site-reviews/addon/documentation', [$this->controller, 'filterDocumentation'] );
23
+        add_filter( 'site-reviews/gettext/site-reviews-images', [$this->controller, 'filterGettext'], 10, 2 );
24
+        add_filter( 'site-reviews/gettext_with_context/site-reviews-images', [$this->controller, 'filterGettextWithContext'], 10, 3 );
25
+        add_filter( 'site-reviews/ngettext/site-reviews-images', [$this->controller, 'filterNgettext'], 10, 4 );
26
+        add_filter( 'site-reviews/ngettext_with_context/site-reviews-images', [$this->controller, 'filterNgettextWithContext'], 10, 5 );
27
+        add_filter( 'site-reviews/path', [$this->controller, 'filterFilePaths'], 10, 2 );
28
+        add_filter( 'site-reviews/addon/settings', [$this->controller, 'filterSettings'] );
29
+        add_filter( 'site-reviews/addon/system-info', [$this->controller, 'filterSystemInfo'] );
30
+        add_filter( 'site-reviews/translation/entries', [$this->controller, 'filterTranslationEntries'] );
31
+        add_filter( 'site-reviews/translator/domains', [$this->controller, 'filterTranslatorDomains'] );
32
+        add_action( 'init', [$this->controller, 'registerBlocks'] );
33
+        add_action( 'plugins_loaded', [$this->controller, 'registerLanguages'] );
34
+        add_action( 'init', [$this->controller, 'registerShortcodes'] );
35
+        add_action( 'init', [$this->controller, 'registerTinymcePopups'] );
36
+        add_action( 'widgets_init', [$this->controller, 'registerWidgets'] );
37
+        add_action( 'site-reviews/addon/settings/'.$this->addon->slug, [$this->controller, 'renderSettings'] );
38 38
     }
39 39
 }
Please login to merge, or discard this patch.
plugin/Addons/Updater.php 2 patches
Indentation   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -8,266 +8,266 @@
 block discarded – undo
8 8
 
9 9
 class Updater
10 10
 {
11
-    /**
12
-     * @var string
13
-     */
14
-    protected $apiUrl;
15
-    /**
16
-     * @var array
17
-     */
18
-    protected $data;
19
-    /**
20
-     * @var string
21
-     */
22
-    protected $plugin;
23
-    /**
24
-     * @var string
25
-     */
26
-    protected $transientName;
11
+	/**
12
+	 * @var string
13
+	 */
14
+	protected $apiUrl;
15
+	/**
16
+	 * @var array
17
+	 */
18
+	protected $data;
19
+	/**
20
+	 * @var string
21
+	 */
22
+	protected $plugin;
23
+	/**
24
+	 * @var string
25
+	 */
26
+	protected $transientName;
27 27
 
28
-    /**
29
-     * @param string $apiUrl
30
-     * @param string $file
31
-     */
32
-    public function __construct($apiUrl, $file, array $data = [])
33
-    {
34
-        if (!function_exists('get_plugin_data')) {
35
-            require_once ABSPATH.WPINC.'/plugin.php';
36
-        }
37
-        $this->apiUrl = trailingslashit(apply_filters('site-reviews/addon/api-url', $apiUrl));
38
-        $this->data = wp_parse_args($data, get_plugin_data($file));
39
-        $this->plugin = plugin_basename($file);
40
-        $this->transientName = Application::PREFIX.md5(Arr::get($data, 'TextDomain'));
41
-    }
28
+	/**
29
+	 * @param string $apiUrl
30
+	 * @param string $file
31
+	 */
32
+	public function __construct($apiUrl, $file, array $data = [])
33
+	{
34
+		if (!function_exists('get_plugin_data')) {
35
+			require_once ABSPATH.WPINC.'/plugin.php';
36
+		}
37
+		$this->apiUrl = trailingslashit(apply_filters('site-reviews/addon/api-url', $apiUrl));
38
+		$this->data = wp_parse_args($data, get_plugin_data($file));
39
+		$this->plugin = plugin_basename($file);
40
+		$this->transientName = Application::PREFIX.md5(Arr::get($data, 'TextDomain'));
41
+	}
42 42
 
43
-    /**
44
-     * @return object
45
-     */
46
-    public function activateLicense(array $data = [])
47
-    {
48
-        return $this->request('activate_license', $data);
49
-    }
43
+	/**
44
+	 * @return object
45
+	 */
46
+	public function activateLicense(array $data = [])
47
+	{
48
+		return $this->request('activate_license', $data);
49
+	}
50 50
 
51
-    /**
52
-     * @return object
53
-     */
54
-    public function checkLicense(array $data = [])
55
-    {
56
-        $response = $this->request('check_license', $data);
57
-        if ('valid' === Arr::get($response, 'license')) {
58
-            $this->getPluginUpdate(true);
59
-        }
60
-        return $response;
61
-    }
51
+	/**
52
+	 * @return object
53
+	 */
54
+	public function checkLicense(array $data = [])
55
+	{
56
+		$response = $this->request('check_license', $data);
57
+		if ('valid' === Arr::get($response, 'license')) {
58
+			$this->getPluginUpdate(true);
59
+		}
60
+		return $response;
61
+	}
62 62
 
63
-    /**
64
-     * @return object
65
-     */
66
-    public function deactivateLicense(array $data = [])
67
-    {
68
-        return $this->request('deactivate_license', $data);
69
-    }
63
+	/**
64
+	 * @return object
65
+	 */
66
+	public function deactivateLicense(array $data = [])
67
+	{
68
+		return $this->request('deactivate_license', $data);
69
+	}
70 70
 
71
-    /**
72
-     * @param false|object|array $result
73
-     * @param string $action
74
-     * @param object $args
75
-     * @return mixed
76
-     */
77
-    public function filterPluginUpdateDetails($result, $action, $args)
78
-    {
79
-        if ('plugin_information' != $action
80
-            || Arr::get($this->data, 'TextDomain') != Arr::get($args, 'slug')) {
81
-            return $result;
82
-        }
83
-        if ($updateInfo = $this->getPluginUpdate()) {
84
-            return $this->modifyUpdateDetails($updateInfo);
85
-        }
86
-        return $result;
87
-    }
71
+	/**
72
+	 * @param false|object|array $result
73
+	 * @param string $action
74
+	 * @param object $args
75
+	 * @return mixed
76
+	 */
77
+	public function filterPluginUpdateDetails($result, $action, $args)
78
+	{
79
+		if ('plugin_information' != $action
80
+			|| Arr::get($this->data, 'TextDomain') != Arr::get($args, 'slug')) {
81
+			return $result;
82
+		}
83
+		if ($updateInfo = $this->getPluginUpdate()) {
84
+			return $this->modifyUpdateDetails($updateInfo);
85
+		}
86
+		return $result;
87
+	}
88 88
 
89
-    /**
90
-     * @param object $transient
91
-     * @return object
92
-     */
93
-    public function filterPluginUpdates($transient)
94
-    {
95
-        if ($updateInfo = $this->getPluginUpdate()) {
96
-            return $this->modifyPluginUpdates($transient, $updateInfo);
97
-        }
98
-        return $transient;
99
-    }
89
+	/**
90
+	 * @param object $transient
91
+	 * @return object
92
+	 */
93
+	public function filterPluginUpdates($transient)
94
+	{
95
+		if ($updateInfo = $this->getPluginUpdate()) {
96
+			return $this->modifyPluginUpdates($transient, $updateInfo);
97
+		}
98
+		return $transient;
99
+	}
100 100
 
101
-    /**
102
-     * @return object
103
-     */
104
-    public function getVersion(array $data = [])
105
-    {
106
-        return $this->request('get_version', $data);
107
-    }
101
+	/**
102
+	 * @return object
103
+	 */
104
+	public function getVersion(array $data = [])
105
+	{
106
+		return $this->request('get_version', $data);
107
+	}
108 108
 
109
-    /**
110
-     * @return void
111
-     */
112
-    public function init()
113
-    {
114
-        if ($this->apiUrl === trailingslashit(home_url())) {
115
-            return;
116
-        }
117
-        add_filter('plugins_api', [$this, 'filterPluginUpdateDetails'], 10, 3);
118
-        add_filter('pre_set_site_transient_update_plugins', [$this, 'filterPluginUpdates'], 999);
119
-        add_action('load-update-core.php', [$this, 'onForceUpdateCheck'], 9);
120
-        add_action('in_plugin_update_message-'.$this->plugin, [$this, 'renderLicenseMissingLink']);
121
-    }
109
+	/**
110
+	 * @return void
111
+	 */
112
+	public function init()
113
+	{
114
+		if ($this->apiUrl === trailingslashit(home_url())) {
115
+			return;
116
+		}
117
+		add_filter('plugins_api', [$this, 'filterPluginUpdateDetails'], 10, 3);
118
+		add_filter('pre_set_site_transient_update_plugins', [$this, 'filterPluginUpdates'], 999);
119
+		add_action('load-update-core.php', [$this, 'onForceUpdateCheck'], 9);
120
+		add_action('in_plugin_update_message-'.$this->plugin, [$this, 'renderLicenseMissingLink']);
121
+	}
122 122
 
123
-    /**
124
-     * @return bool
125
-     */
126
-    public function isLicenseValid()
127
-    {
128
-        $result = $this->checkLicense();
129
-        return 'valid' === Arr::get($result, 'license');
130
-    }
123
+	/**
124
+	 * @return bool
125
+	 */
126
+	public function isLicenseValid()
127
+	{
128
+		$result = $this->checkLicense();
129
+		return 'valid' === Arr::get($result, 'license');
130
+	}
131 131
 
132
-    /**
133
-     * @return void
134
-     */
135
-    public function onForceUpdateCheck()
136
-    {
137
-        if (!filter_input(INPUT_GET, 'force-check')) {
138
-            return;
139
-        }
140
-        foreach (glsr()->addons as $addon) {
141
-            try {
142
-                glsr($addon)->updater->getPluginUpdate(true);
143
-            } catch (\Exception $e) {
144
-                glsr_log()->error($e->getMessage());
145
-            }
146
-        }
147
-    }
132
+	/**
133
+	 * @return void
134
+	 */
135
+	public function onForceUpdateCheck()
136
+	{
137
+		if (!filter_input(INPUT_GET, 'force-check')) {
138
+			return;
139
+		}
140
+		foreach (glsr()->addons as $addon) {
141
+			try {
142
+				glsr($addon)->updater->getPluginUpdate(true);
143
+			} catch (\Exception $e) {
144
+				glsr_log()->error($e->getMessage());
145
+			}
146
+		}
147
+	}
148 148
 
149
-    /**
150
-     * @return void
151
-     */
152
-    public function renderLicenseMissingLink()
153
-    {
154
-        if (!$this->isLicenseValid()) {
155
-            glsr()->render('partials/addons/license-missing');
156
-        }
157
-    }
149
+	/**
150
+	 * @return void
151
+	 */
152
+	public function renderLicenseMissingLink()
153
+	{
154
+		if (!$this->isLicenseValid()) {
155
+			glsr()->render('partials/addons/license-missing');
156
+		}
157
+	}
158 158
 
159
-    /**
160
-     * @return false|object
161
-     */
162
-    protected function getCachedVersion()
163
-    {
164
-        return get_transient($this->transientName);
165
-    }
159
+	/**
160
+	 * @return false|object
161
+	 */
162
+	protected function getCachedVersion()
163
+	{
164
+		return get_transient($this->transientName);
165
+	}
166 166
 
167
-    /**
168
-     * @param bool $force
169
-     * @return false|object
170
-     */
171
-    protected function getPluginUpdate($force = false)
172
-    {
173
-        $version = $this->getCachedVersion();
174
-        if (false === $version || $force) {
175
-            $version = $this->getVersion();
176
-            $this->setCachedVersion($version);
177
-        }
178
-        if (isset($version->error)) {
179
-            glsr_log()->error($version->error);
180
-            return false;
181
-        }
182
-        return $version;
183
-    }
167
+	/**
168
+	 * @param bool $force
169
+	 * @return false|object
170
+	 */
171
+	protected function getPluginUpdate($force = false)
172
+	{
173
+		$version = $this->getCachedVersion();
174
+		if (false === $version || $force) {
175
+			$version = $this->getVersion();
176
+			$this->setCachedVersion($version);
177
+		}
178
+		if (isset($version->error)) {
179
+			glsr_log()->error($version->error);
180
+			return false;
181
+		}
182
+		return $version;
183
+	}
184 184
 
185
-    /**
186
-     * @param object $transient
187
-     * @param object $updateInfo
188
-     * @return object
189
-     */
190
-    protected function modifyPluginUpdates($transient, $updateInfo)
191
-    {
192
-        $updateInfo->id = Application::ID.'/'.Arr::get($this->data, 'TextDomain');
193
-        $updateInfo->plugin = $this->plugin;
194
-        $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP');
195
-        $updateInfo->tested = Arr::get($this->data, 'testedTo');
196
-        $transient->checked[$this->plugin] = Arr::get($this->data, 'Version');
197
-        $transient->last_checked = time();
198
-        if (Helper::isGreaterThan($updateInfo->new_version, Arr::get($this->data, 'Version'))) {
199
-            unset($transient->no_update[$this->plugin]);
200
-            $updateInfo->update = true;
201
-            $transient->response[$this->plugin] = $updateInfo;
202
-        } else {
203
-            unset($transient->response[$this->plugin]);
204
-            $transient->no_update[$this->plugin] = $updateInfo;
205
-        }
206
-        return $transient;
207
-    }
185
+	/**
186
+	 * @param object $transient
187
+	 * @param object $updateInfo
188
+	 * @return object
189
+	 */
190
+	protected function modifyPluginUpdates($transient, $updateInfo)
191
+	{
192
+		$updateInfo->id = Application::ID.'/'.Arr::get($this->data, 'TextDomain');
193
+		$updateInfo->plugin = $this->plugin;
194
+		$updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP');
195
+		$updateInfo->tested = Arr::get($this->data, 'testedTo');
196
+		$transient->checked[$this->plugin] = Arr::get($this->data, 'Version');
197
+		$transient->last_checked = time();
198
+		if (Helper::isGreaterThan($updateInfo->new_version, Arr::get($this->data, 'Version'))) {
199
+			unset($transient->no_update[$this->plugin]);
200
+			$updateInfo->update = true;
201
+			$transient->response[$this->plugin] = $updateInfo;
202
+		} else {
203
+			unset($transient->response[$this->plugin]);
204
+			$transient->no_update[$this->plugin] = $updateInfo;
205
+		}
206
+		return $transient;
207
+	}
208 208
 
209
-    /**
210
-     * @param object $updateInfo
211
-     * @return object
212
-     */
213
-    protected function modifyUpdateDetails($updateInfo)
214
-    {
215
-        $updateInfo->author = Arr::get($this->data, 'Author');
216
-        $updateInfo->author_profile = Arr::get($this->data, 'AuthorURI');
217
-        $updateInfo->requires = Arr::get($this->data, 'RequiresWP');
218
-        $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP');
219
-        $updateInfo->tested = Arr::get($this->data, 'testedTo');
220
-        $updateInfo->version = $updateInfo->new_version;
221
-        return $updateInfo;
222
-    }
209
+	/**
210
+	 * @param object $updateInfo
211
+	 * @return object
212
+	 */
213
+	protected function modifyUpdateDetails($updateInfo)
214
+	{
215
+		$updateInfo->author = Arr::get($this->data, 'Author');
216
+		$updateInfo->author_profile = Arr::get($this->data, 'AuthorURI');
217
+		$updateInfo->requires = Arr::get($this->data, 'RequiresWP');
218
+		$updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP');
219
+		$updateInfo->tested = Arr::get($this->data, 'testedTo');
220
+		$updateInfo->version = $updateInfo->new_version;
221
+		return $updateInfo;
222
+	}
223 223
 
224
-    /**
225
-     * @param \WP_Error|array $response
226
-     * @return object
227
-     */
228
-    protected function normalizeResponse($response)
229
-    {
230
-        $body = wp_remote_retrieve_body($response);
231
-        if ($data = json_decode($body)) {
232
-            $data = array_map('maybe_unserialize', (array) $data);
233
-            return (object) $data;
234
-        }
235
-        $error = is_wp_error($response)
236
-            ? $response->get_error_message()
237
-            : 'Update server not responding ('.Arr::get($this->data, 'TextDomain').')';
238
-        return (object) ['error' => $error];
239
-    }
224
+	/**
225
+	 * @param \WP_Error|array $response
226
+	 * @return object
227
+	 */
228
+	protected function normalizeResponse($response)
229
+	{
230
+		$body = wp_remote_retrieve_body($response);
231
+		if ($data = json_decode($body)) {
232
+			$data = array_map('maybe_unserialize', (array) $data);
233
+			return (object) $data;
234
+		}
235
+		$error = is_wp_error($response)
236
+			? $response->get_error_message()
237
+			: 'Update server not responding ('.Arr::get($this->data, 'TextDomain').')';
238
+		return (object) ['error' => $error];
239
+	}
240 240
 
241
-    /**
242
-     * @param string $action activate_license|check_license|deactivate_license|get_version
243
-     * @return object
244
-     */
245
-    protected function request($action, array $data = [])
246
-    {
247
-        $data = wp_parse_args($data, $this->data);
248
-        $response = wp_remote_post($this->apiUrl, [
249
-            'body' => [
250
-                'edd_action' => $action,
251
-                'item_id' => Arr::get($data, 'item_id'),
252
-                'item_name' => Arr::get($data, 'Name'),
253
-                'license' => Arr::get($data, 'license'),
254
-                'slug' => Arr::get($data, 'TextDomain'),
255
-                'url' => home_url(),
256
-            ],
257
-            'sslverify' => apply_filters('site-reviews/sslverify/post', false),
258
-            'timeout' => 15,
259
-        ]);
260
-        return $this->normalizeResponse($response);
261
-    }
241
+	/**
242
+	 * @param string $action activate_license|check_license|deactivate_license|get_version
243
+	 * @return object
244
+	 */
245
+	protected function request($action, array $data = [])
246
+	{
247
+		$data = wp_parse_args($data, $this->data);
248
+		$response = wp_remote_post($this->apiUrl, [
249
+			'body' => [
250
+				'edd_action' => $action,
251
+				'item_id' => Arr::get($data, 'item_id'),
252
+				'item_name' => Arr::get($data, 'Name'),
253
+				'license' => Arr::get($data, 'license'),
254
+				'slug' => Arr::get($data, 'TextDomain'),
255
+				'url' => home_url(),
256
+			],
257
+			'sslverify' => apply_filters('site-reviews/sslverify/post', false),
258
+			'timeout' => 15,
259
+		]);
260
+		return $this->normalizeResponse($response);
261
+	}
262 262
 
263
-    /**
264
-     * @param object $version
265
-     * @return void
266
-     */
267
-    protected function setCachedVersion($version)
268
-    {
269
-        if (!isset($version->error)) {
270
-            set_transient($this->transientName, $version, 3 * HOUR_IN_SECONDS);
271
-        }
272
-    }
263
+	/**
264
+	 * @param object $version
265
+	 * @return void
266
+	 */
267
+	protected function setCachedVersion($version)
268
+	{
269
+		if (!isset($version->error)) {
270
+			set_transient($this->transientName, $version, 3 * HOUR_IN_SECONDS);
271
+		}
272
+	}
273 273
 }
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -29,33 +29,33 @@  discard block
 block discarded – undo
29 29
      * @param string $apiUrl
30 30
      * @param string $file
31 31
      */
32
-    public function __construct($apiUrl, $file, array $data = [])
32
+    public function __construct( $apiUrl, $file, array $data = [] )
33 33
     {
34
-        if (!function_exists('get_plugin_data')) {
34
+        if( !function_exists( 'get_plugin_data' ) ) {
35 35
             require_once ABSPATH.WPINC.'/plugin.php';
36 36
         }
37
-        $this->apiUrl = trailingslashit(apply_filters('site-reviews/addon/api-url', $apiUrl));
38
-        $this->data = wp_parse_args($data, get_plugin_data($file));
39
-        $this->plugin = plugin_basename($file);
40
-        $this->transientName = Application::PREFIX.md5(Arr::get($data, 'TextDomain'));
37
+        $this->apiUrl = trailingslashit( apply_filters( 'site-reviews/addon/api-url', $apiUrl ) );
38
+        $this->data = wp_parse_args( $data, get_plugin_data( $file ) );
39
+        $this->plugin = plugin_basename( $file );
40
+        $this->transientName = Application::PREFIX.md5( Arr::get( $data, 'TextDomain' ) );
41 41
     }
42 42
 
43 43
     /**
44 44
      * @return object
45 45
      */
46
-    public function activateLicense(array $data = [])
46
+    public function activateLicense( array $data = [] )
47 47
     {
48
-        return $this->request('activate_license', $data);
48
+        return $this->request( 'activate_license', $data );
49 49
     }
50 50
 
51 51
     /**
52 52
      * @return object
53 53
      */
54
-    public function checkLicense(array $data = [])
54
+    public function checkLicense( array $data = [] )
55 55
     {
56
-        $response = $this->request('check_license', $data);
57
-        if ('valid' === Arr::get($response, 'license')) {
58
-            $this->getPluginUpdate(true);
56
+        $response = $this->request( 'check_license', $data );
57
+        if( 'valid' === Arr::get( $response, 'license' ) ) {
58
+            $this->getPluginUpdate( true );
59 59
         }
60 60
         return $response;
61 61
     }
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
     /**
64 64
      * @return object
65 65
      */
66
-    public function deactivateLicense(array $data = [])
66
+    public function deactivateLicense( array $data = [] )
67 67
     {
68
-        return $this->request('deactivate_license', $data);
68
+        return $this->request( 'deactivate_license', $data );
69 69
     }
70 70
 
71 71
     /**
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
      * @param object $args
75 75
      * @return mixed
76 76
      */
77
-    public function filterPluginUpdateDetails($result, $action, $args)
77
+    public function filterPluginUpdateDetails( $result, $action, $args )
78 78
     {
79
-        if ('plugin_information' != $action
80
-            || Arr::get($this->data, 'TextDomain') != Arr::get($args, 'slug')) {
79
+        if( 'plugin_information' != $action
80
+            || Arr::get( $this->data, 'TextDomain' ) != Arr::get( $args, 'slug' ) ) {
81 81
             return $result;
82 82
         }
83
-        if ($updateInfo = $this->getPluginUpdate()) {
84
-            return $this->modifyUpdateDetails($updateInfo);
83
+        if( $updateInfo = $this->getPluginUpdate() ) {
84
+            return $this->modifyUpdateDetails( $updateInfo );
85 85
         }
86 86
         return $result;
87 87
     }
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
      * @param object $transient
91 91
      * @return object
92 92
      */
93
-    public function filterPluginUpdates($transient)
93
+    public function filterPluginUpdates( $transient )
94 94
     {
95
-        if ($updateInfo = $this->getPluginUpdate()) {
96
-            return $this->modifyPluginUpdates($transient, $updateInfo);
95
+        if( $updateInfo = $this->getPluginUpdate() ) {
96
+            return $this->modifyPluginUpdates( $transient, $updateInfo );
97 97
         }
98 98
         return $transient;
99 99
     }
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
     /**
102 102
      * @return object
103 103
      */
104
-    public function getVersion(array $data = [])
104
+    public function getVersion( array $data = [] )
105 105
     {
106
-        return $this->request('get_version', $data);
106
+        return $this->request( 'get_version', $data );
107 107
     }
108 108
 
109 109
     /**
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function init()
113 113
     {
114
-        if ($this->apiUrl === trailingslashit(home_url())) {
114
+        if( $this->apiUrl === trailingslashit( home_url() ) ) {
115 115
             return;
116 116
         }
117
-        add_filter('plugins_api', [$this, 'filterPluginUpdateDetails'], 10, 3);
118
-        add_filter('pre_set_site_transient_update_plugins', [$this, 'filterPluginUpdates'], 999);
119
-        add_action('load-update-core.php', [$this, 'onForceUpdateCheck'], 9);
120
-        add_action('in_plugin_update_message-'.$this->plugin, [$this, 'renderLicenseMissingLink']);
117
+        add_filter( 'plugins_api', [$this, 'filterPluginUpdateDetails'], 10, 3 );
118
+        add_filter( 'pre_set_site_transient_update_plugins', [$this, 'filterPluginUpdates'], 999 );
119
+        add_action( 'load-update-core.php', [$this, 'onForceUpdateCheck'], 9 );
120
+        add_action( 'in_plugin_update_message-'.$this->plugin, [$this, 'renderLicenseMissingLink'] );
121 121
     }
122 122
 
123 123
     /**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     public function isLicenseValid()
127 127
     {
128 128
         $result = $this->checkLicense();
129
-        return 'valid' === Arr::get($result, 'license');
129
+        return 'valid' === Arr::get( $result, 'license' );
130 130
     }
131 131
 
132 132
     /**
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
      */
135 135
     public function onForceUpdateCheck()
136 136
     {
137
-        if (!filter_input(INPUT_GET, 'force-check')) {
137
+        if( !filter_input( INPUT_GET, 'force-check' ) ) {
138 138
             return;
139 139
         }
140
-        foreach (glsr()->addons as $addon) {
140
+        foreach( glsr()->addons as $addon ) {
141 141
             try {
142
-                glsr($addon)->updater->getPluginUpdate(true);
143
-            } catch (\Exception $e) {
144
-                glsr_log()->error($e->getMessage());
142
+                glsr( $addon )->updater->getPluginUpdate( true );
143
+            } catch( \Exception $e ) {
144
+                glsr_log()->error( $e->getMessage() );
145 145
             }
146 146
         }
147 147
     }
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
      */
152 152
     public function renderLicenseMissingLink()
153 153
     {
154
-        if (!$this->isLicenseValid()) {
155
-            glsr()->render('partials/addons/license-missing');
154
+        if( !$this->isLicenseValid() ) {
155
+            glsr()->render( 'partials/addons/license-missing' );
156 156
         }
157 157
     }
158 158
 
@@ -161,22 +161,22 @@  discard block
 block discarded – undo
161 161
      */
162 162
     protected function getCachedVersion()
163 163
     {
164
-        return get_transient($this->transientName);
164
+        return get_transient( $this->transientName );
165 165
     }
166 166
 
167 167
     /**
168 168
      * @param bool $force
169 169
      * @return false|object
170 170
      */
171
-    protected function getPluginUpdate($force = false)
171
+    protected function getPluginUpdate( $force = false )
172 172
     {
173 173
         $version = $this->getCachedVersion();
174
-        if (false === $version || $force) {
174
+        if( false === $version || $force ) {
175 175
             $version = $this->getVersion();
176
-            $this->setCachedVersion($version);
176
+            $this->setCachedVersion( $version );
177 177
         }
178
-        if (isset($version->error)) {
179
-            glsr_log()->error($version->error);
178
+        if( isset($version->error) ) {
179
+            glsr_log()->error( $version->error );
180 180
             return false;
181 181
         }
182 182
         return $version;
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
      * @param object $updateInfo
188 188
      * @return object
189 189
      */
190
-    protected function modifyPluginUpdates($transient, $updateInfo)
190
+    protected function modifyPluginUpdates( $transient, $updateInfo )
191 191
     {
192
-        $updateInfo->id = Application::ID.'/'.Arr::get($this->data, 'TextDomain');
192
+        $updateInfo->id = Application::ID.'/'.Arr::get( $this->data, 'TextDomain' );
193 193
         $updateInfo->plugin = $this->plugin;
194
-        $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP');
195
-        $updateInfo->tested = Arr::get($this->data, 'testedTo');
196
-        $transient->checked[$this->plugin] = Arr::get($this->data, 'Version');
194
+        $updateInfo->requires_php = Arr::get( $this->data, 'RequiresPHP' );
195
+        $updateInfo->tested = Arr::get( $this->data, 'testedTo' );
196
+        $transient->checked[$this->plugin] = Arr::get( $this->data, 'Version' );
197 197
         $transient->last_checked = time();
198
-        if (Helper::isGreaterThan($updateInfo->new_version, Arr::get($this->data, 'Version'))) {
198
+        if( Helper::isGreaterThan( $updateInfo->new_version, Arr::get( $this->data, 'Version' ) ) ) {
199 199
             unset($transient->no_update[$this->plugin]);
200 200
             $updateInfo->update = true;
201 201
             $transient->response[$this->plugin] = $updateInfo;
@@ -210,13 +210,13 @@  discard block
 block discarded – undo
210 210
      * @param object $updateInfo
211 211
      * @return object
212 212
      */
213
-    protected function modifyUpdateDetails($updateInfo)
213
+    protected function modifyUpdateDetails( $updateInfo )
214 214
     {
215
-        $updateInfo->author = Arr::get($this->data, 'Author');
216
-        $updateInfo->author_profile = Arr::get($this->data, 'AuthorURI');
217
-        $updateInfo->requires = Arr::get($this->data, 'RequiresWP');
218
-        $updateInfo->requires_php = Arr::get($this->data, 'RequiresPHP');
219
-        $updateInfo->tested = Arr::get($this->data, 'testedTo');
215
+        $updateInfo->author = Arr::get( $this->data, 'Author' );
216
+        $updateInfo->author_profile = Arr::get( $this->data, 'AuthorURI' );
217
+        $updateInfo->requires = Arr::get( $this->data, 'RequiresWP' );
218
+        $updateInfo->requires_php = Arr::get( $this->data, 'RequiresPHP' );
219
+        $updateInfo->tested = Arr::get( $this->data, 'testedTo' );
220 220
         $updateInfo->version = $updateInfo->new_version;
221 221
         return $updateInfo;
222 222
     }
@@ -225,49 +225,49 @@  discard block
 block discarded – undo
225 225
      * @param \WP_Error|array $response
226 226
      * @return object
227 227
      */
228
-    protected function normalizeResponse($response)
228
+    protected function normalizeResponse( $response )
229 229
     {
230
-        $body = wp_remote_retrieve_body($response);
231
-        if ($data = json_decode($body)) {
232
-            $data = array_map('maybe_unserialize', (array) $data);
233
-            return (object) $data;
230
+        $body = wp_remote_retrieve_body( $response );
231
+        if( $data = json_decode( $body ) ) {
232
+            $data = array_map( 'maybe_unserialize', (array)$data );
233
+            return (object)$data;
234 234
         }
235
-        $error = is_wp_error($response)
235
+        $error = is_wp_error( $response )
236 236
             ? $response->get_error_message()
237
-            : 'Update server not responding ('.Arr::get($this->data, 'TextDomain').')';
238
-        return (object) ['error' => $error];
237
+            : 'Update server not responding ('.Arr::get( $this->data, 'TextDomain' ).')';
238
+        return (object)['error' => $error];
239 239
     }
240 240
 
241 241
     /**
242 242
      * @param string $action activate_license|check_license|deactivate_license|get_version
243 243
      * @return object
244 244
      */
245
-    protected function request($action, array $data = [])
245
+    protected function request( $action, array $data = [] )
246 246
     {
247
-        $data = wp_parse_args($data, $this->data);
248
-        $response = wp_remote_post($this->apiUrl, [
247
+        $data = wp_parse_args( $data, $this->data );
248
+        $response = wp_remote_post( $this->apiUrl, [
249 249
             'body' => [
250 250
                 'edd_action' => $action,
251
-                'item_id' => Arr::get($data, 'item_id'),
252
-                'item_name' => Arr::get($data, 'Name'),
253
-                'license' => Arr::get($data, 'license'),
254
-                'slug' => Arr::get($data, 'TextDomain'),
251
+                'item_id' => Arr::get( $data, 'item_id' ),
252
+                'item_name' => Arr::get( $data, 'Name' ),
253
+                'license' => Arr::get( $data, 'license' ),
254
+                'slug' => Arr::get( $data, 'TextDomain' ),
255 255
                 'url' => home_url(),
256 256
             ],
257
-            'sslverify' => apply_filters('site-reviews/sslverify/post', false),
257
+            'sslverify' => apply_filters( 'site-reviews/sslverify/post', false ),
258 258
             'timeout' => 15,
259
-        ]);
260
-        return $this->normalizeResponse($response);
259
+        ] );
260
+        return $this->normalizeResponse( $response );
261 261
     }
262 262
 
263 263
     /**
264 264
      * @param object $version
265 265
      * @return void
266 266
      */
267
-    protected function setCachedVersion($version)
267
+    protected function setCachedVersion( $version )
268 268
     {
269
-        if (!isset($version->error)) {
270
-            set_transient($this->transientName, $version, 3 * HOUR_IN_SECONDS);
269
+        if( !isset($version->error) ) {
270
+            set_transient( $this->transientName, $version, 3 * HOUR_IN_SECONDS );
271 271
         }
272 272
     }
273 273
 }
Please login to merge, or discard this patch.
plugin/Blocks/SiteReviewsFormBlock.php 2 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -7,105 +7,105 @@
 block discarded – undo
7 7
 
8 8
 class SiteReviewsFormBlock extends BlockGenerator
9 9
 {
10
-    /**
11
-     * @return array
12
-     */
13
-    public function attributes()
14
-    {
15
-        return [
16
-            'assign_to' => [
17
-                'default' => '',
18
-                'type' => 'string',
19
-            ],
20
-            'category' => [
21
-                'default' => '',
22
-                'type' => 'string',
23
-            ],
24
-            'className' => [
25
-                'default' => '',
26
-                'type' => 'string',
27
-            ],
28
-            'hide' => [
29
-                'default' => '',
30
-                'type' => 'string',
31
-            ],
32
-            'id' => [
33
-                'default' => '',
34
-                'type' => 'string',
35
-            ],
36
-        ];
37
-    }
10
+	/**
11
+	 * @return array
12
+	 */
13
+	public function attributes()
14
+	{
15
+		return [
16
+			'assign_to' => [
17
+				'default' => '',
18
+				'type' => 'string',
19
+			],
20
+			'category' => [
21
+				'default' => '',
22
+				'type' => 'string',
23
+			],
24
+			'className' => [
25
+				'default' => '',
26
+				'type' => 'string',
27
+			],
28
+			'hide' => [
29
+				'default' => '',
30
+				'type' => 'string',
31
+			],
32
+			'id' => [
33
+				'default' => '',
34
+				'type' => 'string',
35
+			],
36
+		];
37
+	}
38 38
 
39
-    /**
40
-     * @return string
41
-     */
42
-    public function render(array $attributes)
43
-    {
44
-        $attributes['class'] = $attributes['className'];
45
-        $shortcode = glsr(Shortcode::class);
46
-        if ('edit' == filter_input(INPUT_GET, 'context')) {
47
-            $this->filterBlockClass();
48
-            $this->filterFormFields();
49
-            $this->filterRatingField();
50
-            $this->filterSubmitButton();
51
-            if (!$this->hasVisibleFields($shortcode, $attributes)) {
52
-                $this->filterInterpolation();
53
-            }
54
-        }
55
-        return $shortcode->buildBlock($attributes);
56
-    }
39
+	/**
40
+	 * @return string
41
+	 */
42
+	public function render(array $attributes)
43
+	{
44
+		$attributes['class'] = $attributes['className'];
45
+		$shortcode = glsr(Shortcode::class);
46
+		if ('edit' == filter_input(INPUT_GET, 'context')) {
47
+			$this->filterBlockClass();
48
+			$this->filterFormFields();
49
+			$this->filterRatingField();
50
+			$this->filterSubmitButton();
51
+			if (!$this->hasVisibleFields($shortcode, $attributes)) {
52
+				$this->filterInterpolation();
53
+			}
54
+		}
55
+		return $shortcode->buildBlock($attributes);
56
+	}
57 57
 
58
-    /**
59
-     * @return void
60
-     */
61
-    protected function filterFormFields()
62
-    {
63
-        add_filter('site-reviews/config/forms/submission-form', function (array $config) {
64
-            array_walk($config, function (&$field) {
65
-                $field['disabled'] = true;
66
-                $field['tabindex'] = '-1';
67
-            });
68
-            return $config;
69
-        });
70
-    }
58
+	/**
59
+	 * @return void
60
+	 */
61
+	protected function filterFormFields()
62
+	{
63
+		add_filter('site-reviews/config/forms/submission-form', function (array $config) {
64
+			array_walk($config, function (&$field) {
65
+				$field['disabled'] = true;
66
+				$field['tabindex'] = '-1';
67
+			});
68
+			return $config;
69
+		});
70
+	}
71 71
 
72
-    /**
73
-     * @return void
74
-     */
75
-    protected function filterInterpolation()
76
-    {
77
-        add_filter('site-reviews/interpolate/reviews-form', function ($context) {
78
-            $context['class'] = 'glsr-default glsr-block-disabled';
79
-            $context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews');
80
-            $context['response'] = '';
81
-            $context['submit_button'] = '';
82
-            return $context;
83
-        });
84
-    }
72
+	/**
73
+	 * @return void
74
+	 */
75
+	protected function filterInterpolation()
76
+	{
77
+		add_filter('site-reviews/interpolate/reviews-form', function ($context) {
78
+			$context['class'] = 'glsr-default glsr-block-disabled';
79
+			$context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews');
80
+			$context['response'] = '';
81
+			$context['submit_button'] = '';
82
+			return $context;
83
+		});
84
+	}
85 85
 
86
-    /**
87
-     * @return void
88
-     */
89
-    protected function filterRatingField()
90
-    {
91
-        add_filter('site-reviews/rendered/field', function ($html, $type, $args) {
92
-            if ('rating' == $args['path']) {
93
-                $stars = '<span class="glsr-stars">';
94
-                $stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class));
95
-                $stars.= '</span>';
96
-                $html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/', '$1'.$stars.'$4', $html);
97
-            }
98
-            return $html;
99
-        }, 10, 3);
100
-    }
86
+	/**
87
+	 * @return void
88
+	 */
89
+	protected function filterRatingField()
90
+	{
91
+		add_filter('site-reviews/rendered/field', function ($html, $type, $args) {
92
+			if ('rating' == $args['path']) {
93
+				$stars = '<span class="glsr-stars">';
94
+				$stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class));
95
+				$stars.= '</span>';
96
+				$html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/', '$1'.$stars.'$4', $html);
97
+			}
98
+			return $html;
99
+		}, 10, 3);
100
+	}
101 101
 
102
-    /**
103
-     * @return void
104
-     */
105
-    protected function filterSubmitButton()
106
-    {
107
-        add_filter('site-reviews/rendered/template/form/submit-button', function ($template) {
108
-            return str_replace('type="submit"', 'tabindex="-1"', $template);
109
-        });
110
-    }
102
+	/**
103
+	 * @return void
104
+	 */
105
+	protected function filterSubmitButton()
106
+	{
107
+		add_filter('site-reviews/rendered/template/form/submit-button', function ($template) {
108
+			return str_replace('type="submit"', 'tabindex="-1"', $template);
109
+		});
110
+	}
111 111
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -39,20 +39,20 @@  discard block
 block discarded – undo
39 39
     /**
40 40
      * @return string
41 41
      */
42
-    public function render(array $attributes)
42
+    public function render( array $attributes )
43 43
     {
44 44
         $attributes['class'] = $attributes['className'];
45
-        $shortcode = glsr(Shortcode::class);
46
-        if ('edit' == filter_input(INPUT_GET, 'context')) {
45
+        $shortcode = glsr( Shortcode::class );
46
+        if( 'edit' == filter_input( INPUT_GET, 'context' ) ) {
47 47
             $this->filterBlockClass();
48 48
             $this->filterFormFields();
49 49
             $this->filterRatingField();
50 50
             $this->filterSubmitButton();
51
-            if (!$this->hasVisibleFields($shortcode, $attributes)) {
51
+            if( !$this->hasVisibleFields( $shortcode, $attributes ) ) {
52 52
                 $this->filterInterpolation();
53 53
             }
54 54
         }
55
-        return $shortcode->buildBlock($attributes);
55
+        return $shortcode->buildBlock( $attributes );
56 56
     }
57 57
 
58 58
     /**
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
      */
61 61
     protected function filterFormFields()
62 62
     {
63
-        add_filter('site-reviews/config/forms/submission-form', function (array $config) {
64
-            array_walk($config, function (&$field) {
63
+        add_filter( 'site-reviews/config/forms/submission-form', function( array $config ) {
64
+            array_walk( $config, function( &$field ) {
65 65
                 $field['disabled'] = true;
66 66
                 $field['tabindex'] = '-1';
67 67
             });
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
      */
75 75
     protected function filterInterpolation()
76 76
     {
77
-        add_filter('site-reviews/interpolate/reviews-form', function ($context) {
77
+        add_filter( 'site-reviews/interpolate/reviews-form', function( $context ) {
78 78
             $context['class'] = 'glsr-default glsr-block-disabled';
79
-            $context['fields'] = __('You have hidden all of the fields for this block.', 'site-reviews');
79
+            $context['fields'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' );
80 80
             $context['response'] = '';
81 81
             $context['submit_button'] = '';
82 82
             return $context;
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
      */
89 89
     protected function filterRatingField()
90 90
     {
91
-        add_filter('site-reviews/rendered/field', function ($html, $type, $args) {
92
-            if ('rating' == $args['path']) {
91
+        add_filter( 'site-reviews/rendered/field', function( $html, $type, $args ) {
92
+            if( 'rating' == $args['path'] ) {
93 93
                 $stars = '<span class="glsr-stars">';
94
-                $stars.= str_repeat('<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int) glsr()->constant('MAX_RATING', Rating::class));
95
-                $stars.= '</span>';
96
-                $html = preg_replace('/(.*)(<select.*)(<\/select>)(.*)/', '$1'.$stars.'$4', $html);
94
+                $stars .= str_repeat( '<span class="glsr-star glsr-star-empty" aria-hidden="true"></span>', (int)glsr()->constant( 'MAX_RATING', Rating::class ) );
95
+                $stars .= '</span>';
96
+                $html = preg_replace( '/(.*)(<select.*)(<\/select>)(.*)/', '$1'.$stars.'$4', $html );
97 97
             }
98 98
             return $html;
99
-        }, 10, 3);
99
+        }, 10, 3 );
100 100
     }
101 101
 
102 102
     /**
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
      */
105 105
     protected function filterSubmitButton()
106 106
     {
107
-        add_filter('site-reviews/rendered/template/form/submit-button', function ($template) {
108
-            return str_replace('type="submit"', 'tabindex="-1"', $template);
107
+        add_filter( 'site-reviews/rendered/template/form/submit-button', function( $template ) {
108
+            return str_replace( 'type="submit"', 'tabindex="-1"', $template );
109 109
         });
110 110
     }
111 111
 }
Please login to merge, or discard this patch.