Passed
Push — master ( ae1954...aab291 )
by Paul
08:17 queued 04:15
created
site-reviews.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@
 block discarded – undo
18 18
 defined('WPINC') || die;
19 19
 
20 20
 if (!class_exists('GL_Plugin_Check_v3')) {
21
-    require_once __DIR__.'/activate.php';
21
+	require_once __DIR__.'/activate.php';
22 22
 }
23 23
 $check = new GL_Plugin_Check_v3(__FILE__);
24 24
 if (!$check->canProceed()) {
25
-    return;
25
+	return;
26 26
 }
27 27
 require_once __DIR__.'/autoload.php';
28 28
 require_once __DIR__.'/compatibility.php';
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -15,13 +15,13 @@  discard block
 block discarded – undo
15 15
  * Text Domain: site-reviews
16 16
  * Domain Path: languages
17 17
  */
18
-defined('WPINC') || die;
18
+defined( 'WPINC' ) || die;
19 19
 
20
-if (!class_exists('GL_Plugin_Check_v3')) {
20
+if( !class_exists( 'GL_Plugin_Check_v3' ) ) {
21 21
     require_once __DIR__.'/activate.php';
22 22
 }
23
-$check = new GL_Plugin_Check_v3(__FILE__);
24
-if (!$check->canProceed()) {
23
+$check = new GL_Plugin_Check_v3( __FILE__ );
24
+if( !$check->canProceed() ) {
25 25
     return;
26 26
 }
27 27
 require_once __DIR__.'/autoload.php';
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 require_once __DIR__.'/helpers.php';
31 31
 
32 32
 $app = new GeminiLabs\SiteReviews\Application();
33
-$app->make('Provider')->register($app);
34
-register_activation_hook(__FILE__, array($app, 'activate'));
35
-register_deactivation_hook(__FILE__, array($app, 'deactivate'));
36
-register_shutdown_function(array($app, 'catchFatalError'));
33
+$app->make( 'Provider' )->register( $app );
34
+register_activation_hook( __FILE__, array( $app, 'activate' ) );
35
+register_deactivation_hook( __FILE__, array( $app, 'deactivate' ) );
36
+register_shutdown_function( array( $app, 'catchFatalError' ) );
37 37
 $app->init();
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 = glsr(Helper::class)->prefixArrayKeys($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 = glsr(Helper::class)->prefixArrayKeys($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' => glsr_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['count'],
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' => glsr_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['count'],
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)->get([
116
-            'post_ids' => glsr(Helper::class)->convertStringToArray($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)->get([
116
+			'post_ids' => glsr(Helper::class)->convertStringToArray($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 = glsr(Helper::class)->convertStringToArray($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 = glsr(Helper::class)->convertStringToArray($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 = glsr(Helper::class)->prefixArrayKeys($reviewValues);
24
+        $reviewValues = glsr( CreateReviewDefaults::class )->restrict( (array)$command );
25
+        $reviewValues = apply_filters( 'site-reviews/create/review-values', $reviewValues, $command );
26
+        $reviewValues = glsr( Helper::class )->prefixArrayKeys( $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' => glsr_get($args, 'paged', $paged),
85
+            'paged' => glsr_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['count'],
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)->get([
116
-            'post_ids' => glsr(Helper::class)->convertStringToArray($args['assigned_to']),
117
-            'term_ids' => $this->normalizeTermIds($args['category']),
114
+        $args = glsr( SiteReviewsSummaryDefaults::class )->filter( $args );
115
+        $counts = glsr( CountsManager::class )->get( [
116
+            'post_ids' => glsr( Helper::class )->convertStringToArray( $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 = glsr(Helper::class)->convertStringToArray($commaSeparatedTermIds);
143
-        foreach ($termIds as $termId) {
144
-            if (is_numeric($termId)) {
145
-                $termId = intval($termId);
142
+        $termIds = glsr( Helper::class )->convertStringToArray( $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/Router.php 2 patches
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -6,162 +6,162 @@
 block discarded – undo
6 6
 
7 7
 class Router
8 8
 {
9
-    /**
10
-     * @var array
11
-     */
12
-    protected $unguardedActions = [];
9
+	/**
10
+	 * @var array
11
+	 */
12
+	protected $unguardedActions = [];
13 13
 
14
-    public function __construct()
15
-    {
16
-        $this->unguardedActions = apply_filters('site-reviews/router/unguarded-actions', [
17
-            'dismiss-notice',
18
-            'fetch-paged-reviews',
19
-        ]);
20
-    }
14
+	public function __construct()
15
+	{
16
+		$this->unguardedActions = apply_filters('site-reviews/router/unguarded-actions', [
17
+			'dismiss-notice',
18
+			'fetch-paged-reviews',
19
+		]);
20
+	}
21 21
 
22
-    /**
23
-     * @return void
24
-     */
25
-    public function routeAdminPostRequest()
26
-    {
27
-        $request = $this->getRequest();
28
-        if (!$this->isValidPostRequest($request)) {
29
-            return;
30
-        }
31
-        check_admin_referer($request['_action']);
32
-        $this->routeRequest('admin', $request['_action'], $request);
33
-    }
22
+	/**
23
+	 * @return void
24
+	 */
25
+	public function routeAdminPostRequest()
26
+	{
27
+		$request = $this->getRequest();
28
+		if (!$this->isValidPostRequest($request)) {
29
+			return;
30
+		}
31
+		check_admin_referer($request['_action']);
32
+		$this->routeRequest('admin', $request['_action'], $request);
33
+	}
34 34
 
35
-    /**
36
-     * @return void
37
-     */
38
-    public function routeAjaxRequest()
39
-    {
40
-        $request = $this->getRequest();
41
-        $this->checkAjaxRequest($request);
42
-        $this->checkAjaxNonce($request);
43
-        $this->routeRequest('ajax', $request['_action'], $request);
44
-        wp_die();
45
-    }
35
+	/**
36
+	 * @return void
37
+	 */
38
+	public function routeAjaxRequest()
39
+	{
40
+		$request = $this->getRequest();
41
+		$this->checkAjaxRequest($request);
42
+		$this->checkAjaxNonce($request);
43
+		$this->routeRequest('ajax', $request['_action'], $request);
44
+		wp_die();
45
+	}
46 46
 
47
-    /**
48
-     * @return void
49
-     */
50
-    public function routePublicPostRequest()
51
-    {
52
-        if (is_admin()) {
53
-            return;
54
-        }
55
-        $request = $this->getRequest();
56
-        if (!$this->isValidPostRequest($request)) {
57
-            return;
58
-        }
59
-        if (!$this->isValidPublicNonce($request)) {
60
-            return;
61
-        }
62
-        $this->routeRequest('public', $request['_action'], $request);
63
-    }
47
+	/**
48
+	 * @return void
49
+	 */
50
+	public function routePublicPostRequest()
51
+	{
52
+		if (is_admin()) {
53
+			return;
54
+		}
55
+		$request = $this->getRequest();
56
+		if (!$this->isValidPostRequest($request)) {
57
+			return;
58
+		}
59
+		if (!$this->isValidPublicNonce($request)) {
60
+			return;
61
+		}
62
+		$this->routeRequest('public', $request['_action'], $request);
63
+	}
64 64
 
65
-    /**
66
-     * @return void
67
-     */
68
-    protected function checkAjaxNonce(array $request)
69
-    {
70
-        if (!is_user_logged_in() || in_array(glsr_get($request, '_action'), $this->unguardedActions)) {
71
-            return;
72
-        }
73
-        if (!isset($request['_nonce'])) {
74
-            $this->sendAjaxError('request is missing a nonce', $request);
75
-        }
76
-        if (!wp_verify_nonce($request['_nonce'], $request['_action'])) {
77
-            $this->sendAjaxError('request failed the nonce check', $request, 403);
78
-        }
79
-    }
65
+	/**
66
+	 * @return void
67
+	 */
68
+	protected function checkAjaxNonce(array $request)
69
+	{
70
+		if (!is_user_logged_in() || in_array(glsr_get($request, '_action'), $this->unguardedActions)) {
71
+			return;
72
+		}
73
+		if (!isset($request['_nonce'])) {
74
+			$this->sendAjaxError('request is missing a nonce', $request);
75
+		}
76
+		if (!wp_verify_nonce($request['_nonce'], $request['_action'])) {
77
+			$this->sendAjaxError('request failed the nonce check', $request, 403);
78
+		}
79
+	}
80 80
 
81
-    /**
82
-     * @return void
83
-     */
84
-    protected function checkAjaxRequest(array $request)
85
-    {
86
-        if (!isset($request['_action'])) {
87
-            $this->sendAjaxError('request must include an action', $request);
88
-        }
89
-        if (empty($request['_ajax_request'])) {
90
-            $this->sendAjaxError('request is invalid', $request);
91
-        }
92
-    }
81
+	/**
82
+	 * @return void
83
+	 */
84
+	protected function checkAjaxRequest(array $request)
85
+	{
86
+		if (!isset($request['_action'])) {
87
+			$this->sendAjaxError('request must include an action', $request);
88
+		}
89
+		if (empty($request['_ajax_request'])) {
90
+			$this->sendAjaxError('request is invalid', $request);
91
+		}
92
+	}
93 93
 
94
-    /**
95
-     * All ajax requests in the plugin are triggered by a single action hook: glsr_action,
96
-     * while each ajax route is determined by $_POST[request][_action].
97
-     * @return array
98
-     */
99
-    protected function getRequest()
100
-    {
101
-        $request = glsr(Helper::class)->filterInputArray(Application::ID);
102
-        if (glsr(Helper::class)->filterInput('action') == Application::PREFIX.'action') {
103
-            $request['_ajax_request'] = true;
104
-        }
105
-        if ('submit-review' == glsr(Helper::class)->filterInput('_action', $request)) {
106
-            $request['_recaptcha-token'] = glsr(Helper::class)->filterInput('g-recaptcha-response');
107
-        }
108
-        return $request;
109
-    }
94
+	/**
95
+	 * All ajax requests in the plugin are triggered by a single action hook: glsr_action,
96
+	 * while each ajax route is determined by $_POST[request][_action].
97
+	 * @return array
98
+	 */
99
+	protected function getRequest()
100
+	{
101
+		$request = glsr(Helper::class)->filterInputArray(Application::ID);
102
+		if (glsr(Helper::class)->filterInput('action') == Application::PREFIX.'action') {
103
+			$request['_ajax_request'] = true;
104
+		}
105
+		if ('submit-review' == glsr(Helper::class)->filterInput('_action', $request)) {
106
+			$request['_recaptcha-token'] = glsr(Helper::class)->filterInput('g-recaptcha-response');
107
+		}
108
+		return $request;
109
+	}
110 110
 
111
-    /**
112
-     * @return bool
113
-     */
114
-    protected function isValidPostRequest(array $request = [])
115
-    {
116
-        return !empty($request['_action']) && empty($request['_ajax_request']);
117
-    }
111
+	/**
112
+	 * @return bool
113
+	 */
114
+	protected function isValidPostRequest(array $request = [])
115
+	{
116
+		return !empty($request['_action']) && empty($request['_ajax_request']);
117
+	}
118 118
 
119
-    /**
120
-     * @return bool
121
-     */
122
-    protected function isValidPublicNonce(array $request)
123
-    {
124
-        if (is_user_logged_in() && !wp_verify_nonce($request['_nonce'], $request['_action'])) {
125
-            glsr_log()->error('nonce check failed for public request')->debug($request);
126
-            return false;
127
-        }
128
-        return true;
129
-    }
119
+	/**
120
+	 * @return bool
121
+	 */
122
+	protected function isValidPublicNonce(array $request)
123
+	{
124
+		if (is_user_logged_in() && !wp_verify_nonce($request['_nonce'], $request['_action'])) {
125
+			glsr_log()->error('nonce check failed for public request')->debug($request);
126
+			return false;
127
+		}
128
+		return true;
129
+	}
130 130
 
131
-    /**
132
-     * @param string $type
133
-     * @param string $action
134
-     * @return void
135
-     */
136
-    protected function routeRequest($type, $action, array $request = [])
137
-    {
138
-        $actionHook = 'site-reviews/route/'.$type.'/request';
139
-        $controller = glsr(glsr(Helper::class)->buildClassName($type.'-controller', 'Controllers'));
140
-        $method = glsr(Helper::class)->buildMethodName($action, 'router');
141
-        $request = apply_filters('site-reviews/route/request', $request, $action, $type);
142
-        do_action($actionHook, $action, $request);
143
-        if (is_callable([$controller, $method])) {
144
-            call_user_func([$controller, $method], $request);
145
-            return;
146
-        }
147
-        if (0 === did_action($actionHook)) {
148
-            glsr_log('Unknown '.$type.' router request: '.$action);
149
-        }
150
-    }
131
+	/**
132
+	 * @param string $type
133
+	 * @param string $action
134
+	 * @return void
135
+	 */
136
+	protected function routeRequest($type, $action, array $request = [])
137
+	{
138
+		$actionHook = 'site-reviews/route/'.$type.'/request';
139
+		$controller = glsr(glsr(Helper::class)->buildClassName($type.'-controller', 'Controllers'));
140
+		$method = glsr(Helper::class)->buildMethodName($action, 'router');
141
+		$request = apply_filters('site-reviews/route/request', $request, $action, $type);
142
+		do_action($actionHook, $action, $request);
143
+		if (is_callable([$controller, $method])) {
144
+			call_user_func([$controller, $method], $request);
145
+			return;
146
+		}
147
+		if (0 === did_action($actionHook)) {
148
+			glsr_log('Unknown '.$type.' router request: '.$action);
149
+		}
150
+	}
151 151
 
152
-    /**
153
-     * @param string $error
154
-     * @param int $statusCode
155
-     * @return void
156
-     */
157
-    protected function sendAjaxError($error, array $request, $statusCode = 400)
158
-    {
159
-        glsr_log()->error($error)->debug($request);
160
-        glsr(Notice::class)->addError(__('There was an error (try reloading the page).', 'site-reviews').' <code>'.$error.'</code>');
161
-        wp_send_json_error([
162
-            'message' => __('The form could not be submitted. Please notify the site administrator.', 'site-reviews'),
163
-            'notices' => glsr(Notice::class)->get(),
164
-            'error' => $error,
165
-        ]);
166
-    }
152
+	/**
153
+	 * @param string $error
154
+	 * @param int $statusCode
155
+	 * @return void
156
+	 */
157
+	protected function sendAjaxError($error, array $request, $statusCode = 400)
158
+	{
159
+		glsr_log()->error($error)->debug($request);
160
+		glsr(Notice::class)->addError(__('There was an error (try reloading the page).', 'site-reviews').' <code>'.$error.'</code>');
161
+		wp_send_json_error([
162
+			'message' => __('The form could not be submitted. Please notify the site administrator.', 'site-reviews'),
163
+			'notices' => glsr(Notice::class)->get(),
164
+			'error' => $error,
165
+		]);
166
+	}
167 167
 }
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function __construct()
15 15
     {
16
-        $this->unguardedActions = apply_filters('site-reviews/router/unguarded-actions', [
16
+        $this->unguardedActions = apply_filters( 'site-reviews/router/unguarded-actions', [
17 17
             'dismiss-notice',
18 18
             'fetch-paged-reviews',
19
-        ]);
19
+        ] );
20 20
     }
21 21
 
22 22
     /**
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
     public function routeAdminPostRequest()
26 26
     {
27 27
         $request = $this->getRequest();
28
-        if (!$this->isValidPostRequest($request)) {
28
+        if( !$this->isValidPostRequest( $request ) ) {
29 29
             return;
30 30
         }
31
-        check_admin_referer($request['_action']);
32
-        $this->routeRequest('admin', $request['_action'], $request);
31
+        check_admin_referer( $request['_action'] );
32
+        $this->routeRequest( 'admin', $request['_action'], $request );
33 33
     }
34 34
 
35 35
     /**
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
     public function routeAjaxRequest()
39 39
     {
40 40
         $request = $this->getRequest();
41
-        $this->checkAjaxRequest($request);
42
-        $this->checkAjaxNonce($request);
43
-        $this->routeRequest('ajax', $request['_action'], $request);
41
+        $this->checkAjaxRequest( $request );
42
+        $this->checkAjaxNonce( $request );
43
+        $this->routeRequest( 'ajax', $request['_action'], $request );
44 44
         wp_die();
45 45
     }
46 46
 
@@ -49,45 +49,45 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function routePublicPostRequest()
51 51
     {
52
-        if (is_admin()) {
52
+        if( is_admin() ) {
53 53
             return;
54 54
         }
55 55
         $request = $this->getRequest();
56
-        if (!$this->isValidPostRequest($request)) {
56
+        if( !$this->isValidPostRequest( $request ) ) {
57 57
             return;
58 58
         }
59
-        if (!$this->isValidPublicNonce($request)) {
59
+        if( !$this->isValidPublicNonce( $request ) ) {
60 60
             return;
61 61
         }
62
-        $this->routeRequest('public', $request['_action'], $request);
62
+        $this->routeRequest( 'public', $request['_action'], $request );
63 63
     }
64 64
 
65 65
     /**
66 66
      * @return void
67 67
      */
68
-    protected function checkAjaxNonce(array $request)
68
+    protected function checkAjaxNonce( array $request )
69 69
     {
70
-        if (!is_user_logged_in() || in_array(glsr_get($request, '_action'), $this->unguardedActions)) {
70
+        if( !is_user_logged_in() || in_array( glsr_get( $request, '_action' ), $this->unguardedActions ) ) {
71 71
             return;
72 72
         }
73
-        if (!isset($request['_nonce'])) {
74
-            $this->sendAjaxError('request is missing a nonce', $request);
73
+        if( !isset($request['_nonce']) ) {
74
+            $this->sendAjaxError( 'request is missing a nonce', $request );
75 75
         }
76
-        if (!wp_verify_nonce($request['_nonce'], $request['_action'])) {
77
-            $this->sendAjaxError('request failed the nonce check', $request, 403);
76
+        if( !wp_verify_nonce( $request['_nonce'], $request['_action'] ) ) {
77
+            $this->sendAjaxError( 'request failed the nonce check', $request, 403 );
78 78
         }
79 79
     }
80 80
 
81 81
     /**
82 82
      * @return void
83 83
      */
84
-    protected function checkAjaxRequest(array $request)
84
+    protected function checkAjaxRequest( array $request )
85 85
     {
86
-        if (!isset($request['_action'])) {
87
-            $this->sendAjaxError('request must include an action', $request);
86
+        if( !isset($request['_action']) ) {
87
+            $this->sendAjaxError( 'request must include an action', $request );
88 88
         }
89
-        if (empty($request['_ajax_request'])) {
90
-            $this->sendAjaxError('request is invalid', $request);
89
+        if( empty($request['_ajax_request']) ) {
90
+            $this->sendAjaxError( 'request is invalid', $request );
91 91
         }
92 92
     }
93 93
 
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
      */
99 99
     protected function getRequest()
100 100
     {
101
-        $request = glsr(Helper::class)->filterInputArray(Application::ID);
102
-        if (glsr(Helper::class)->filterInput('action') == Application::PREFIX.'action') {
101
+        $request = glsr( Helper::class )->filterInputArray( Application::ID );
102
+        if( glsr( Helper::class )->filterInput( 'action' ) == Application::PREFIX.'action' ) {
103 103
             $request['_ajax_request'] = true;
104 104
         }
105
-        if ('submit-review' == glsr(Helper::class)->filterInput('_action', $request)) {
106
-            $request['_recaptcha-token'] = glsr(Helper::class)->filterInput('g-recaptcha-response');
105
+        if( 'submit-review' == glsr( Helper::class )->filterInput( '_action', $request ) ) {
106
+            $request['_recaptcha-token'] = glsr( Helper::class )->filterInput( 'g-recaptcha-response' );
107 107
         }
108 108
         return $request;
109 109
     }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     /**
112 112
      * @return bool
113 113
      */
114
-    protected function isValidPostRequest(array $request = [])
114
+    protected function isValidPostRequest( array $request = [] )
115 115
     {
116 116
         return !empty($request['_action']) && empty($request['_ajax_request']);
117 117
     }
@@ -119,10 +119,10 @@  discard block
 block discarded – undo
119 119
     /**
120 120
      * @return bool
121 121
      */
122
-    protected function isValidPublicNonce(array $request)
122
+    protected function isValidPublicNonce( array $request )
123 123
     {
124
-        if (is_user_logged_in() && !wp_verify_nonce($request['_nonce'], $request['_action'])) {
125
-            glsr_log()->error('nonce check failed for public request')->debug($request);
124
+        if( is_user_logged_in() && !wp_verify_nonce( $request['_nonce'], $request['_action'] ) ) {
125
+            glsr_log()->error( 'nonce check failed for public request' )->debug( $request );
126 126
             return false;
127 127
         }
128 128
         return true;
@@ -133,19 +133,19 @@  discard block
 block discarded – undo
133 133
      * @param string $action
134 134
      * @return void
135 135
      */
136
-    protected function routeRequest($type, $action, array $request = [])
136
+    protected function routeRequest( $type, $action, array $request = [] )
137 137
     {
138 138
         $actionHook = 'site-reviews/route/'.$type.'/request';
139
-        $controller = glsr(glsr(Helper::class)->buildClassName($type.'-controller', 'Controllers'));
140
-        $method = glsr(Helper::class)->buildMethodName($action, 'router');
141
-        $request = apply_filters('site-reviews/route/request', $request, $action, $type);
142
-        do_action($actionHook, $action, $request);
143
-        if (is_callable([$controller, $method])) {
144
-            call_user_func([$controller, $method], $request);
139
+        $controller = glsr( glsr( Helper::class )->buildClassName( $type.'-controller', 'Controllers' ) );
140
+        $method = glsr( Helper::class )->buildMethodName( $action, 'router' );
141
+        $request = apply_filters( 'site-reviews/route/request', $request, $action, $type );
142
+        do_action( $actionHook, $action, $request );
143
+        if( is_callable( [$controller, $method] ) ) {
144
+            call_user_func( [$controller, $method], $request );
145 145
             return;
146 146
         }
147
-        if (0 === did_action($actionHook)) {
148
-            glsr_log('Unknown '.$type.' router request: '.$action);
147
+        if( 0 === did_action( $actionHook ) ) {
148
+            glsr_log( 'Unknown '.$type.' router request: '.$action );
149 149
         }
150 150
     }
151 151
 
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
      * @param int $statusCode
155 155
      * @return void
156 156
      */
157
-    protected function sendAjaxError($error, array $request, $statusCode = 400)
157
+    protected function sendAjaxError( $error, array $request, $statusCode = 400 )
158 158
     {
159
-        glsr_log()->error($error)->debug($request);
160
-        glsr(Notice::class)->addError(__('There was an error (try reloading the page).', 'site-reviews').' <code>'.$error.'</code>');
161
-        wp_send_json_error([
162
-            'message' => __('The form could not be submitted. Please notify the site administrator.', 'site-reviews'),
163
-            'notices' => glsr(Notice::class)->get(),
159
+        glsr_log()->error( $error )->debug( $request );
160
+        glsr( Notice::class )->addError( __( 'There was an error (try reloading the page).', 'site-reviews' ).' <code>'.$error.'</code>' );
161
+        wp_send_json_error( [
162
+            'message' => __( 'The form could not be submitted. Please notify the site administrator.', 'site-reviews' ),
163
+            'notices' => glsr( Notice::class )->get(),
164 164
             'error' => $error,
165
-        ]);
165
+        ] );
166 166
     }
167 167
 }
Please login to merge, or discard this patch.
plugin/Helper.php 2 patches
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -9,128 +9,128 @@
 block discarded – undo
9 9
 
10 10
 class Helper
11 11
 {
12
-    use Arr;
13
-    use Str;
12
+	use Arr;
13
+	use Str;
14 14
 
15
-    /**
16
-     * @param string $name
17
-     * @param string $path
18
-     * @return string
19
-     */
20
-    public function buildClassName($name, $path = '')
21
-    {
22
-        $className = $this->camelCase($name);
23
-        $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\');
24
-        return !empty($path)
25
-            ? __NAMESPACE__.'\\'.$path.'\\'.$className
26
-            : $className;
27
-    }
15
+	/**
16
+	 * @param string $name
17
+	 * @param string $path
18
+	 * @return string
19
+	 */
20
+	public function buildClassName($name, $path = '')
21
+	{
22
+		$className = $this->camelCase($name);
23
+		$path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\');
24
+		return !empty($path)
25
+			? __NAMESPACE__.'\\'.$path.'\\'.$className
26
+			: $className;
27
+	}
28 28
 
29
-    /**
30
-     * @param string $name
31
-     * @param string $prefix
32
-     * @return string
33
-     */
34
-    public function buildMethodName($name, $prefix = '')
35
-    {
36
-        return lcfirst($prefix.$this->buildClassName($name));
37
-    }
29
+	/**
30
+	 * @param string $name
31
+	 * @param string $prefix
32
+	 * @return string
33
+	 */
34
+	public function buildMethodName($name, $prefix = '')
35
+	{
36
+		return lcfirst($prefix.$this->buildClassName($name));
37
+	}
38 38
 
39
-    /**
40
-     * @param string $name
41
-     * @return string
42
-     */
43
-    public function buildPropertyName($name)
44
-    {
45
-        return lcfirst($this->buildClassName($name));
46
-    }
39
+	/**
40
+	 * @param string $name
41
+	 * @return string
42
+	 */
43
+	public function buildPropertyName($name)
44
+	{
45
+		return lcfirst($this->buildClassName($name));
46
+	}
47 47
 
48
-    /**
49
-     * @param string $cast
50
-     * @param mixed $value
51
-     * @return mixed
52
-     */
53
-    public function castTo($cast = '', $value)
54
-    {
55
-        switch ($cast) {
56
-            case 'array':
57
-                return (array) $value;
58
-            case 'bool':
59
-            case 'boolean':
60
-                return filter_var($value, FILTER_VALIDATE_BOOLEAN);
61
-            case 'float':
62
-                return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
63
-            case 'int':
64
-            case 'integer':
65
-                return (int) filter_var($value, FILTER_VALIDATE_INT);
66
-            case 'object':
67
-                return (object) (array) $value;
68
-            case 'str':
69
-            case 'string':
70
-                if (is_object($value) && in_array('__toString', get_class_methods($value))) {
71
-                    return (string) $value->__toString();
72
-                }
73
-                if (is_array($value) || is_object($value)) {
74
-                    return serialize($value);
75
-                }
76
-                return (string) $value;
77
-            default:
78
-                return $value;
79
-        }
80
-    }
48
+	/**
49
+	 * @param string $cast
50
+	 * @param mixed $value
51
+	 * @return mixed
52
+	 */
53
+	public function castTo($cast = '', $value)
54
+	{
55
+		switch ($cast) {
56
+			case 'array':
57
+				return (array) $value;
58
+			case 'bool':
59
+			case 'boolean':
60
+				return filter_var($value, FILTER_VALIDATE_BOOLEAN);
61
+			case 'float':
62
+				return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
63
+			case 'int':
64
+			case 'integer':
65
+				return (int) filter_var($value, FILTER_VALIDATE_INT);
66
+			case 'object':
67
+				return (object) (array) $value;
68
+			case 'str':
69
+			case 'string':
70
+				if (is_object($value) && in_array('__toString', get_class_methods($value))) {
71
+					return (string) $value->__toString();
72
+				}
73
+				if (is_array($value) || is_object($value)) {
74
+					return serialize($value);
75
+				}
76
+				return (string) $value;
77
+			default:
78
+				return $value;
79
+		}
80
+	}
81 81
 
82
-    /**
83
-     * @param string $key
84
-     * @return mixed
85
-     */
86
-    public function filterInput($key, array $request = [])
87
-    {
88
-        if (isset($request[$key])) {
89
-            return $request[$key];
90
-        }
91
-        $variable = filter_input(INPUT_POST, $key);
92
-        if (is_null($variable) && isset($_POST[$key])) {
93
-            $variable = $_POST[$key];
94
-        }
95
-        return $variable;
96
-    }
82
+	/**
83
+	 * @param string $key
84
+	 * @return mixed
85
+	 */
86
+	public function filterInput($key, array $request = [])
87
+	{
88
+		if (isset($request[$key])) {
89
+			return $request[$key];
90
+		}
91
+		$variable = filter_input(INPUT_POST, $key);
92
+		if (is_null($variable) && isset($_POST[$key])) {
93
+			$variable = $_POST[$key];
94
+		}
95
+		return $variable;
96
+	}
97 97
 
98
-    /**
99
-     * @param string $key
100
-     * @return array
101
-     */
102
-    public function filterInputArray($key)
103
-    {
104
-        $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
105
-        if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
106
-            $variable = $_POST[$key];
107
-        }
108
-        return (array) $variable;
109
-    }
98
+	/**
99
+	 * @param string $key
100
+	 * @return array
101
+	 */
102
+	public function filterInputArray($key)
103
+	{
104
+		$variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
105
+		if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
106
+			$variable = $_POST[$key];
107
+		}
108
+		return (array) $variable;
109
+	}
110 110
 
111
-    /**
112
-     * @return string
113
-     */
114
-    public function getIpAddress()
115
-    {
116
-        $cloudflareIps = glsr(Cache::class)->getCloudflareIps();
117
-        $ipv6 = defined('AF_INET6')
118
-            ? $cloudflareIps['v6']
119
-            : [];
120
-        $whitelist = apply_filters('site-reviews/whip/whitelist', [
121
-            Whip::CLOUDFLARE_HEADERS => [
122
-                Whip::IPV4 => $cloudflareIps['v4'],
123
-                Whip::IPV6 => $ipv6,
124
-            ],
125
-            Whip::CUSTOM_HEADERS => [
126
-                Whip::IPV4 => ['127.0.0.1'],
127
-                Whip::IPV6 => ['::1'],
128
-            ],
129
-        ]);
130
-        $methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR;
131
-        $methods = apply_filters('site-reviews/whip/methods', $methods);
132
-        $whip = new Whip($methods, $whitelist);
133
-        do_action_ref_array('site-reviews/whip', [$whip]);
134
-        return (string) $whip->getValidIpAddress();
135
-    }
111
+	/**
112
+	 * @return string
113
+	 */
114
+	public function getIpAddress()
115
+	{
116
+		$cloudflareIps = glsr(Cache::class)->getCloudflareIps();
117
+		$ipv6 = defined('AF_INET6')
118
+			? $cloudflareIps['v6']
119
+			: [];
120
+		$whitelist = apply_filters('site-reviews/whip/whitelist', [
121
+			Whip::CLOUDFLARE_HEADERS => [
122
+				Whip::IPV4 => $cloudflareIps['v4'],
123
+				Whip::IPV6 => $ipv6,
124
+			],
125
+			Whip::CUSTOM_HEADERS => [
126
+				Whip::IPV4 => ['127.0.0.1'],
127
+				Whip::IPV6 => ['::1'],
128
+			],
129
+		]);
130
+		$methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR;
131
+		$methods = apply_filters('site-reviews/whip/methods', $methods);
132
+		$whip = new Whip($methods, $whitelist);
133
+		do_action_ref_array('site-reviews/whip', [$whip]);
134
+		return (string) $whip->getValidIpAddress();
135
+	}
136 136
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
      * @param string $path
18 18
      * @return string
19 19
      */
20
-    public function buildClassName($name, $path = '')
20
+    public function buildClassName( $name, $path = '' )
21 21
     {
22
-        $className = $this->camelCase($name);
23
-        $path = ltrim(str_replace(__NAMESPACE__, '', $path), '\\');
22
+        $className = $this->camelCase( $name );
23
+        $path = ltrim( str_replace( __NAMESPACE__, '', $path ), '\\' );
24 24
         return !empty($path)
25 25
             ? __NAMESPACE__.'\\'.$path.'\\'.$className
26 26
             : $className;
@@ -31,18 +31,18 @@  discard block
 block discarded – undo
31 31
      * @param string $prefix
32 32
      * @return string
33 33
      */
34
-    public function buildMethodName($name, $prefix = '')
34
+    public function buildMethodName( $name, $prefix = '' )
35 35
     {
36
-        return lcfirst($prefix.$this->buildClassName($name));
36
+        return lcfirst( $prefix.$this->buildClassName( $name ) );
37 37
     }
38 38
 
39 39
     /**
40 40
      * @param string $name
41 41
      * @return string
42 42
      */
43
-    public function buildPropertyName($name)
43
+    public function buildPropertyName( $name )
44 44
     {
45
-        return lcfirst($this->buildClassName($name));
45
+        return lcfirst( $this->buildClassName( $name ) );
46 46
     }
47 47
 
48 48
     /**
@@ -50,30 +50,30 @@  discard block
 block discarded – undo
50 50
      * @param mixed $value
51 51
      * @return mixed
52 52
      */
53
-    public function castTo($cast = '', $value)
53
+    public function castTo( $cast = '', $value )
54 54
     {
55
-        switch ($cast) {
55
+        switch( $cast ) {
56 56
             case 'array':
57
-                return (array) $value;
57
+                return (array)$value;
58 58
             case 'bool':
59 59
             case 'boolean':
60
-                return filter_var($value, FILTER_VALIDATE_BOOLEAN);
60
+                return filter_var( $value, FILTER_VALIDATE_BOOLEAN );
61 61
             case 'float':
62
-                return (float) filter_var($value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND);
62
+                return (float)filter_var( $value, FILTER_VALIDATE_FLOAT, FILTER_FLAG_ALLOW_THOUSAND );
63 63
             case 'int':
64 64
             case 'integer':
65
-                return (int) filter_var($value, FILTER_VALIDATE_INT);
65
+                return (int)filter_var( $value, FILTER_VALIDATE_INT );
66 66
             case 'object':
67
-                return (object) (array) $value;
67
+                return (object)(array)$value;
68 68
             case 'str':
69 69
             case 'string':
70
-                if (is_object($value) && in_array('__toString', get_class_methods($value))) {
71
-                    return (string) $value->__toString();
70
+                if( is_object( $value ) && in_array( '__toString', get_class_methods( $value ) ) ) {
71
+                    return (string)$value->__toString();
72 72
                 }
73
-                if (is_array($value) || is_object($value)) {
74
-                    return serialize($value);
73
+                if( is_array( $value ) || is_object( $value ) ) {
74
+                    return serialize( $value );
75 75
                 }
76
-                return (string) $value;
76
+                return (string)$value;
77 77
             default:
78 78
                 return $value;
79 79
         }
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
      * @param string $key
84 84
      * @return mixed
85 85
      */
86
-    public function filterInput($key, array $request = [])
86
+    public function filterInput( $key, array $request = [] )
87 87
     {
88
-        if (isset($request[$key])) {
88
+        if( isset($request[$key]) ) {
89 89
             return $request[$key];
90 90
         }
91
-        $variable = filter_input(INPUT_POST, $key);
92
-        if (is_null($variable) && isset($_POST[$key])) {
91
+        $variable = filter_input( INPUT_POST, $key );
92
+        if( is_null( $variable ) && isset($_POST[$key]) ) {
93 93
             $variable = $_POST[$key];
94 94
         }
95 95
         return $variable;
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
      * @param string $key
100 100
      * @return array
101 101
      */
102
-    public function filterInputArray($key)
102
+    public function filterInputArray( $key )
103 103
     {
104
-        $variable = filter_input(INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
105
-        if (empty($variable) && !empty($_POST[$key]) && is_array($_POST[$key])) {
104
+        $variable = filter_input( INPUT_POST, $key, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
105
+        if( empty($variable) && !empty($_POST[$key]) && is_array( $_POST[$key] ) ) {
106 106
             $variable = $_POST[$key];
107 107
         }
108
-        return (array) $variable;
108
+        return (array)$variable;
109 109
     }
110 110
 
111 111
     /**
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function getIpAddress()
115 115
     {
116
-        $cloudflareIps = glsr(Cache::class)->getCloudflareIps();
117
-        $ipv6 = defined('AF_INET6')
116
+        $cloudflareIps = glsr( Cache::class )->getCloudflareIps();
117
+        $ipv6 = defined( 'AF_INET6' )
118 118
             ? $cloudflareIps['v6']
119 119
             : [];
120
-        $whitelist = apply_filters('site-reviews/whip/whitelist', [
120
+        $whitelist = apply_filters( 'site-reviews/whip/whitelist', [
121 121
             Whip::CLOUDFLARE_HEADERS => [
122 122
                 Whip::IPV4 => $cloudflareIps['v4'],
123 123
                 Whip::IPV6 => $ipv6,
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
                 Whip::IPV4 => ['127.0.0.1'],
127 127
                 Whip::IPV6 => ['::1'],
128 128
             ],
129
-        ]);
129
+        ] );
130 130
         $methods = Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR;
131
-        $methods = apply_filters('site-reviews/whip/methods', $methods);
132
-        $whip = new Whip($methods, $whitelist);
133
-        do_action_ref_array('site-reviews/whip', [$whip]);
134
-        return (string) $whip->getValidIpAddress();
131
+        $methods = apply_filters( 'site-reviews/whip/methods', $methods );
132
+        $whip = new Whip( $methods, $whitelist );
133
+        do_action_ref_array( 'site-reviews/whip', [$whip] );
134
+        return (string)$whip->getValidIpAddress();
135 135
     }
136 136
 }
Please login to merge, or discard this patch.
plugin/Application.php 2 patches
Indentation   +279 added lines, -279 removed lines patch added patch discarded remove patch
@@ -7,308 +7,308 @@
 block discarded – undo
7 7
 
8 8
 final class Application extends Container
9 9
 {
10
-    const CAPABILITY = 'edit_others_posts';
11
-    const CRON_EVENT = 'site-reviews/schedule/session/purge';
12
-    const ID = 'site-reviews';
13
-    const PAGED_QUERY_VAR = 'reviews-page';
14
-    const POST_TYPE = 'site-review';
15
-    const PREFIX = 'glsr_';
16
-    const TAXONOMY = 'site-review-category';
10
+	const CAPABILITY = 'edit_others_posts';
11
+	const CRON_EVENT = 'site-reviews/schedule/session/purge';
12
+	const ID = 'site-reviews';
13
+	const PAGED_QUERY_VAR = 'reviews-page';
14
+	const POST_TYPE = 'site-review';
15
+	const PREFIX = 'glsr_';
16
+	const TAXONOMY = 'site-review-category';
17 17
 
18
-    public $defaults;
19
-    public $deprecated = [];
20
-    public $file;
21
-    public $languages;
22
-    public $mceShortcodes = []; //defined elsewhere
23
-    public $name;
24
-    public $reviewTypes;
25
-    public $schemas = []; //defined elsewhere
26
-    public $version;
18
+	public $defaults;
19
+	public $deprecated = [];
20
+	public $file;
21
+	public $languages;
22
+	public $mceShortcodes = []; //defined elsewhere
23
+	public $name;
24
+	public $reviewTypes;
25
+	public $schemas = []; //defined elsewhere
26
+	public $version;
27 27
 
28
-    public function __construct()
29
-    {
30
-        static::$instance = $this;
31
-        $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php');
32
-        $plugin = get_file_data($this->file, [
33
-            'languages' => 'Domain Path',
34
-            'name' => 'Plugin Name',
35
-            'version' => 'Version',
36
-        ], 'plugin');
37
-        array_walk($plugin, function ($value, $key) {
38
-            $this->$key = $value;
39
-        });
40
-    }
28
+	public function __construct()
29
+	{
30
+		static::$instance = $this;
31
+		$this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php');
32
+		$plugin = get_file_data($this->file, [
33
+			'languages' => 'Domain Path',
34
+			'name' => 'Plugin Name',
35
+			'version' => 'Version',
36
+		], 'plugin');
37
+		array_walk($plugin, function ($value, $key) {
38
+			$this->$key = $value;
39
+		});
40
+	}
41 41
 
42
-    /**
43
-     * @return void
44
-     */
45
-    public function activate()
46
-    {
47
-        $this->make(DefaultsManager::class)->set();
48
-        $this->scheduleCronJob();
49
-        $this->upgrade();
50
-    }
42
+	/**
43
+	 * @return void
44
+	 */
45
+	public function activate()
46
+	{
47
+		$this->make(DefaultsManager::class)->set();
48
+		$this->scheduleCronJob();
49
+		$this->upgrade();
50
+	}
51 51
 
52
-    /**
53
-     * @return void
54
-     */
55
-    public function catchFatalError()
56
-    {
57
-        $error = error_get_last();
58
-        if (E_ERROR !== $error['type'] || false === strpos($error['message'], $this->path())) {
59
-            return;
60
-        }
61
-        glsr_log()->error($error['message']);
62
-    }
52
+	/**
53
+	 * @return void
54
+	 */
55
+	public function catchFatalError()
56
+	{
57
+		$error = error_get_last();
58
+		if (E_ERROR !== $error['type'] || false === strpos($error['message'], $this->path())) {
59
+			return;
60
+		}
61
+		glsr_log()->error($error['message']);
62
+	}
63 63
 
64
-    /**
65
-     * @param string $name
66
-     * @return array
67
-     */
68
-    public function config($name)
69
-    {
70
-        $configFile = $this->path('config/'.$name.'.php');
71
-        $config = file_exists($configFile)
72
-            ? include $configFile
73
-            : [];
74
-        return apply_filters('site-reviews/config/'.$name, $config);
75
-    }
64
+	/**
65
+	 * @param string $name
66
+	 * @return array
67
+	 */
68
+	public function config($name)
69
+	{
70
+		$configFile = $this->path('config/'.$name.'.php');
71
+		$config = file_exists($configFile)
72
+			? include $configFile
73
+			: [];
74
+		return apply_filters('site-reviews/config/'.$name, $config);
75
+	}
76 76
 
77
-    /**
78
-     * @param string $property
79
-     * @return string
80
-     */
81
-    public function constant($property, $className = 'static')
82
-    {
83
-        $constant = $className.'::'.$property;
84
-        return defined($constant)
85
-            ? apply_filters('site-reviews/const/'.$property, constant($constant))
86
-            : '';
87
-    }
77
+	/**
78
+	 * @param string $property
79
+	 * @return string
80
+	 */
81
+	public function constant($property, $className = 'static')
82
+	{
83
+		$constant = $className.'::'.$property;
84
+		return defined($constant)
85
+			? apply_filters('site-reviews/const/'.$property, constant($constant))
86
+			: '';
87
+	}
88 88
 
89
-    /**
90
-     * @return void
91
-     */
92
-    public function deactivate()
93
-    {
94
-        $this->unscheduleCronJob();
95
-    }
89
+	/**
90
+	 * @return void
91
+	 */
92
+	public function deactivate()
93
+	{
94
+		$this->unscheduleCronJob();
95
+	}
96 96
 
97
-    /**
98
-     * @param string $view
99
-     * @return void|string
100
-     */
101
-    public function file($view)
102
-    {
103
-        $view.= '.php';
104
-        $filePaths = [];
105
-        if (glsr(Helper::class)->startsWith('templates/', $view)) {
106
-            $filePaths[] = $this->themePath(glsr(Helper::class)->removePrefix('templates/', $view));
107
-        }
108
-        $filePaths[] = $this->path($view);
109
-        $filePaths[] = $this->path('views/'.$view);
110
-        foreach ($filePaths as $file) {
111
-            if (!file_exists($file)) {
112
-                continue;
113
-            }
114
-            return $file;
115
-        }
116
-    }
97
+	/**
98
+	 * @param string $view
99
+	 * @return void|string
100
+	 */
101
+	public function file($view)
102
+	{
103
+		$view.= '.php';
104
+		$filePaths = [];
105
+		if (glsr(Helper::class)->startsWith('templates/', $view)) {
106
+			$filePaths[] = $this->themePath(glsr(Helper::class)->removePrefix('templates/', $view));
107
+		}
108
+		$filePaths[] = $this->path($view);
109
+		$filePaths[] = $this->path('views/'.$view);
110
+		foreach ($filePaths as $file) {
111
+			if (!file_exists($file)) {
112
+				continue;
113
+			}
114
+			return $file;
115
+		}
116
+	}
117 117
 
118
-    /**
119
-     * @return array
120
-     */
121
-    public function getDefaults()
122
-    {
123
-        if (empty($this->defaults)) {
124
-            $this->defaults = $this->make(DefaultsManager::class)->get();
125
-            $this->upgrade();
126
-        }
127
-        return apply_filters('site-reviews/get/defaults', $this->defaults);
128
-    }
118
+	/**
119
+	 * @return array
120
+	 */
121
+	public function getDefaults()
122
+	{
123
+		if (empty($this->defaults)) {
124
+			$this->defaults = $this->make(DefaultsManager::class)->get();
125
+			$this->upgrade();
126
+		}
127
+		return apply_filters('site-reviews/get/defaults', $this->defaults);
128
+	}
129 129
 
130
-    /**
131
-     * @return bool
132
-     */
133
-    public function getPermission($page = '')
134
-    {
135
-        $permissions = [
136
-            'addons' => 'install_plugins',
137
-            'settings' => 'manage_options',
138
-            // 'welcome' => 'activate_plugins',
139
-        ];
140
-        return glsr_get($permissions, $page, $this->constant('CAPABILITY'));
141
-    }
130
+	/**
131
+	 * @return bool
132
+	 */
133
+	public function getPermission($page = '')
134
+	{
135
+		$permissions = [
136
+			'addons' => 'install_plugins',
137
+			'settings' => 'manage_options',
138
+			// 'welcome' => 'activate_plugins',
139
+		];
140
+		return glsr_get($permissions, $page, $this->constant('CAPABILITY'));
141
+	}
142 142
 
143
-    /**
144
-     * @return bool
145
-     */
146
-    public function hasPermission($page = '')
147
-    {
148
-        $isAdmin = $this->isAdmin();
149
-        return !$isAdmin || ($isAdmin && current_user_can($this->getPermission($page)));
150
-    }
143
+	/**
144
+	 * @return bool
145
+	 */
146
+	public function hasPermission($page = '')
147
+	{
148
+		$isAdmin = $this->isAdmin();
149
+		return !$isAdmin || ($isAdmin && current_user_can($this->getPermission($page)));
150
+	}
151 151
 
152
-    /**
153
-     * @return void
154
-     */
155
-    public function init()
156
-    {
157
-        $this->make(Actions::class)->run();
158
-        $this->make(Filters::class)->run();
159
-    }
152
+	/**
153
+	 * @return void
154
+	 */
155
+	public function init()
156
+	{
157
+		$this->make(Actions::class)->run();
158
+		$this->make(Filters::class)->run();
159
+	}
160 160
 
161
-    /**
162
-     * @return bool
163
-     */
164
-    public function isAdmin()
165
-    {
166
-        return is_admin() && !wp_doing_ajax();
167
-    }
161
+	/**
162
+	 * @return bool
163
+	 */
164
+	public function isAdmin()
165
+	{
166
+		return is_admin() && !wp_doing_ajax();
167
+	}
168 168
 
169
-    /**
170
-     * @param string $file
171
-     * @return string
172
-     */
173
-    public function path($file = '', $realpath = true)
174
-    {
175
-        $path = plugin_dir_path($this->file);
176
-        if (!$realpath) {
177
-            $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file));
178
-        }
179
-        $path = trailingslashit($path).ltrim(trim($file), '/');
180
-        return apply_filters('site-reviews/path', $path, $file);
181
-    }
169
+	/**
170
+	 * @param string $file
171
+	 * @return string
172
+	 */
173
+	public function path($file = '', $realpath = true)
174
+	{
175
+		$path = plugin_dir_path($this->file);
176
+		if (!$realpath) {
177
+			$path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file));
178
+		}
179
+		$path = trailingslashit($path).ltrim(trim($file), '/');
180
+		return apply_filters('site-reviews/path', $path, $file);
181
+	}
182 182
 
183
-    /**
184
-     * @return void
185
-     */
186
-    public function registerAddons()
187
-    {
188
-        do_action('site-reviews/addon/register', $this);
189
-    }
183
+	/**
184
+	 * @return void
185
+	 */
186
+	public function registerAddons()
187
+	{
188
+		do_action('site-reviews/addon/register', $this);
189
+	}
190 190
 
191
-    /**
192
-     * @return void
193
-     */
194
-    public function registerLanguages()
195
-    {
196
-        load_plugin_textdomain(static::ID, false,
197
-            trailingslashit(plugin_basename($this->path()).'/'.$this->languages)
198
-        );
199
-    }
191
+	/**
192
+	 * @return void
193
+	 */
194
+	public function registerLanguages()
195
+	{
196
+		load_plugin_textdomain(static::ID, false,
197
+			trailingslashit(plugin_basename($this->path()).'/'.$this->languages)
198
+		);
199
+	}
200 200
 
201
-    /**
202
-     * @return void
203
-     */
204
-    public function registerReviewTypes()
205
-    {
206
-        $types = apply_filters('site-reviews/addon/types', []);
207
-        $this->reviewTypes = wp_parse_args($types, [
208
-            'local' => __('Local', 'site-reviews'),
209
-        ]);
210
-    }
201
+	/**
202
+	 * @return void
203
+	 */
204
+	public function registerReviewTypes()
205
+	{
206
+		$types = apply_filters('site-reviews/addon/types', []);
207
+		$this->reviewTypes = wp_parse_args($types, [
208
+			'local' => __('Local', 'site-reviews'),
209
+		]);
210
+	}
211 211
 
212
-    /**
213
-     * @param string $view
214
-     * @return void
215
-     */
216
-    public function render($view, array $data = [])
217
-    {
218
-        $view = apply_filters('site-reviews/render/view', $view, $data);
219
-        $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data);
220
-        if (!file_exists($file)) {
221
-            glsr_log()->error('File not found: '.$file);
222
-            return;
223
-        }
224
-        $data = apply_filters('site-reviews/views/data', $data, $view);
225
-        extract($data);
226
-        include $file;
227
-    }
212
+	/**
213
+	 * @param string $view
214
+	 * @return void
215
+	 */
216
+	public function render($view, array $data = [])
217
+	{
218
+		$view = apply_filters('site-reviews/render/view', $view, $data);
219
+		$file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data);
220
+		if (!file_exists($file)) {
221
+			glsr_log()->error('File not found: '.$file);
222
+			return;
223
+		}
224
+		$data = apply_filters('site-reviews/views/data', $data, $view);
225
+		extract($data);
226
+		include $file;
227
+	}
228 228
 
229
-    /**
230
-     * @return void
231
-     */
232
-    public function scheduleCronJob()
233
-    {
234
-        if (wp_next_scheduled(static::CRON_EVENT)) {
235
-            return;
236
-        }
237
-        wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT);
238
-    }
229
+	/**
230
+	 * @return void
231
+	 */
232
+	public function scheduleCronJob()
233
+	{
234
+		if (wp_next_scheduled(static::CRON_EVENT)) {
235
+			return;
236
+		}
237
+		wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT);
238
+	}
239 239
 
240
-    /**
241
-     * @param string $file
242
-     * @return string
243
-     */
244
-    public function themePath($file = '')
245
-    {
246
-        return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/');
247
-    }
240
+	/**
241
+	 * @param string $file
242
+	 * @return string
243
+	 */
244
+	public function themePath($file = '')
245
+	{
246
+		return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/');
247
+	}
248 248
 
249
-    /**
250
-     * @return void
251
-     */
252
-    public function unscheduleCronJob()
253
-    {
254
-        wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT);
255
-    }
249
+	/**
250
+	 * @return void
251
+	 */
252
+	public function unscheduleCronJob()
253
+	{
254
+		wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT);
255
+	}
256 256
 
257
-    /**
258
-     * @return void
259
-     */
260
-    public function upgrade()
261
-    {
262
-        $this->make(Upgrader::class)->run();
263
-    }
257
+	/**
258
+	 * @return void
259
+	 */
260
+	public function upgrade()
261
+	{
262
+		$this->make(Upgrader::class)->run();
263
+	}
264 264
 
265
-    /**
266
-     * @param mixed $upgrader
267
-     * @return void
268
-     * @action upgrader_process_complete
269
-     */
270
-    public function upgraded($upgrader, array $data)
271
-    {
272
-        if (array_key_exists('plugins', $data)
273
-            && in_array(plugin_basename($this->file), $data['plugins'])
274
-            && 'update' === $data['action']
275
-            && 'plugin' === $data['type']
276
-        ) {
277
-            $this->upgrade();
278
-        }
279
-    }
265
+	/**
266
+	 * @param mixed $upgrader
267
+	 * @return void
268
+	 * @action upgrader_process_complete
269
+	 */
270
+	public function upgraded($upgrader, array $data)
271
+	{
272
+		if (array_key_exists('plugins', $data)
273
+			&& in_array(plugin_basename($this->file), $data['plugins'])
274
+			&& 'update' === $data['action']
275
+			&& 'plugin' === $data['type']
276
+		) {
277
+			$this->upgrade();
278
+		}
279
+	}
280 280
 
281
-    /**
282
-     * @param string $path
283
-     * @return string
284
-     */
285
-    public function url($path = '')
286
-    {
287
-        $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/'));
288
-        return apply_filters('site-reviews/url', $url, $path);
289
-    }
281
+	/**
282
+	 * @param string $path
283
+	 * @return string
284
+	 */
285
+	public function url($path = '')
286
+	{
287
+		$url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/'));
288
+		return apply_filters('site-reviews/url', $url, $path);
289
+	}
290 290
 
291
-    /**
292
-     * @param string $versionLevel
293
-     * @return string
294
-     */
295
-    public function version($versionLevel = '')
296
-    {
297
-        $pattern = '/^v?(\d{1,5})(\.\d++)?(\.\d++)?(.+)?$/i';
298
-        preg_match($pattern, $this->version, $matches);
299
-        switch ($versionLevel) {
300
-            case 'major':
301
-                $version = glsr_get($matches, 1);
302
-                break;
303
-            case 'minor':
304
-                $version = glsr_get($matches, 1).glsr_get($matches, 2);
305
-                break;
306
-            case 'patch':
307
-                $version = glsr_get($matches, 1).glsr_get($matches, 2).glsr_get($matches, 3);
308
-                break;
309
-        }
310
-        return empty($version)
311
-            ? $this->version
312
-            : $version;
313
-    }
291
+	/**
292
+	 * @param string $versionLevel
293
+	 * @return string
294
+	 */
295
+	public function version($versionLevel = '')
296
+	{
297
+		$pattern = '/^v?(\d{1,5})(\.\d++)?(\.\d++)?(.+)?$/i';
298
+		preg_match($pattern, $this->version, $matches);
299
+		switch ($versionLevel) {
300
+			case 'major':
301
+				$version = glsr_get($matches, 1);
302
+				break;
303
+			case 'minor':
304
+				$version = glsr_get($matches, 1).glsr_get($matches, 2);
305
+				break;
306
+			case 'patch':
307
+				$version = glsr_get($matches, 1).glsr_get($matches, 2).glsr_get($matches, 3);
308
+				break;
309
+		}
310
+		return empty($version)
311
+			? $this->version
312
+			: $version;
313
+	}
314 314
 }
Please login to merge, or discard this patch.
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
     public function __construct()
29 29
     {
30 30
         static::$instance = $this;
31
-        $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php');
32
-        $plugin = get_file_data($this->file, [
31
+        $this->file = realpath( trailingslashit( dirname( __DIR__ ) ).static::ID.'.php' );
32
+        $plugin = get_file_data( $this->file, [
33 33
             'languages' => 'Domain Path',
34 34
             'name' => 'Plugin Name',
35 35
             'version' => 'Version',
36
-        ], 'plugin');
37
-        array_walk($plugin, function ($value, $key) {
36
+        ], 'plugin' );
37
+        array_walk( $plugin, function( $value, $key ) {
38 38
             $this->$key = $value;
39 39
         });
40 40
     }
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
      */
45 45
     public function activate()
46 46
     {
47
-        $this->make(DefaultsManager::class)->set();
47
+        $this->make( DefaultsManager::class )->set();
48 48
         $this->scheduleCronJob();
49 49
         $this->upgrade();
50 50
     }
@@ -55,34 +55,34 @@  discard block
 block discarded – undo
55 55
     public function catchFatalError()
56 56
     {
57 57
         $error = error_get_last();
58
-        if (E_ERROR !== $error['type'] || false === strpos($error['message'], $this->path())) {
58
+        if( E_ERROR !== $error['type'] || false === strpos( $error['message'], $this->path() ) ) {
59 59
             return;
60 60
         }
61
-        glsr_log()->error($error['message']);
61
+        glsr_log()->error( $error['message'] );
62 62
     }
63 63
 
64 64
     /**
65 65
      * @param string $name
66 66
      * @return array
67 67
      */
68
-    public function config($name)
68
+    public function config( $name )
69 69
     {
70
-        $configFile = $this->path('config/'.$name.'.php');
71
-        $config = file_exists($configFile)
70
+        $configFile = $this->path( 'config/'.$name.'.php' );
71
+        $config = file_exists( $configFile )
72 72
             ? include $configFile
73 73
             : [];
74
-        return apply_filters('site-reviews/config/'.$name, $config);
74
+        return apply_filters( 'site-reviews/config/'.$name, $config );
75 75
     }
76 76
 
77 77
     /**
78 78
      * @param string $property
79 79
      * @return string
80 80
      */
81
-    public function constant($property, $className = 'static')
81
+    public function constant( $property, $className = 'static' )
82 82
     {
83 83
         $constant = $className.'::'.$property;
84
-        return defined($constant)
85
-            ? apply_filters('site-reviews/const/'.$property, constant($constant))
84
+        return defined( $constant )
85
+            ? apply_filters( 'site-reviews/const/'.$property, constant( $constant ) )
86 86
             : '';
87 87
     }
88 88
 
@@ -98,17 +98,17 @@  discard block
 block discarded – undo
98 98
      * @param string $view
99 99
      * @return void|string
100 100
      */
101
-    public function file($view)
101
+    public function file( $view )
102 102
     {
103
-        $view.= '.php';
103
+        $view .= '.php';
104 104
         $filePaths = [];
105
-        if (glsr(Helper::class)->startsWith('templates/', $view)) {
106
-            $filePaths[] = $this->themePath(glsr(Helper::class)->removePrefix('templates/', $view));
105
+        if( glsr( Helper::class )->startsWith( 'templates/', $view ) ) {
106
+            $filePaths[] = $this->themePath( glsr( Helper::class )->removePrefix( 'templates/', $view ) );
107 107
         }
108
-        $filePaths[] = $this->path($view);
109
-        $filePaths[] = $this->path('views/'.$view);
110
-        foreach ($filePaths as $file) {
111
-            if (!file_exists($file)) {
108
+        $filePaths[] = $this->path( $view );
109
+        $filePaths[] = $this->path( 'views/'.$view );
110
+        foreach( $filePaths as $file ) {
111
+            if( !file_exists( $file ) ) {
112 112
                 continue;
113 113
             }
114 114
             return $file;
@@ -120,33 +120,33 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public function getDefaults()
122 122
     {
123
-        if (empty($this->defaults)) {
124
-            $this->defaults = $this->make(DefaultsManager::class)->get();
123
+        if( empty($this->defaults) ) {
124
+            $this->defaults = $this->make( DefaultsManager::class )->get();
125 125
             $this->upgrade();
126 126
         }
127
-        return apply_filters('site-reviews/get/defaults', $this->defaults);
127
+        return apply_filters( 'site-reviews/get/defaults', $this->defaults );
128 128
     }
129 129
 
130 130
     /**
131 131
      * @return bool
132 132
      */
133
-    public function getPermission($page = '')
133
+    public function getPermission( $page = '' )
134 134
     {
135 135
         $permissions = [
136 136
             'addons' => 'install_plugins',
137 137
             'settings' => 'manage_options',
138 138
             // 'welcome' => 'activate_plugins',
139 139
         ];
140
-        return glsr_get($permissions, $page, $this->constant('CAPABILITY'));
140
+        return glsr_get( $permissions, $page, $this->constant( 'CAPABILITY' ) );
141 141
     }
142 142
 
143 143
     /**
144 144
      * @return bool
145 145
      */
146
-    public function hasPermission($page = '')
146
+    public function hasPermission( $page = '' )
147 147
     {
148 148
         $isAdmin = $this->isAdmin();
149
-        return !$isAdmin || ($isAdmin && current_user_can($this->getPermission($page)));
149
+        return !$isAdmin || ($isAdmin && current_user_can( $this->getPermission( $page ) ));
150 150
     }
151 151
 
152 152
     /**
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
      */
155 155
     public function init()
156 156
     {
157
-        $this->make(Actions::class)->run();
158
-        $this->make(Filters::class)->run();
157
+        $this->make( Actions::class )->run();
158
+        $this->make( Filters::class )->run();
159 159
     }
160 160
 
161 161
     /**
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
      * @param string $file
171 171
      * @return string
172 172
      */
173
-    public function path($file = '', $realpath = true)
173
+    public function path( $file = '', $realpath = true )
174 174
     {
175
-        $path = plugin_dir_path($this->file);
176
-        if (!$realpath) {
177
-            $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file));
175
+        $path = plugin_dir_path( $this->file );
176
+        if( !$realpath ) {
177
+            $path = trailingslashit( WP_PLUGIN_DIR ).basename( dirname( $this->file ) );
178 178
         }
179
-        $path = trailingslashit($path).ltrim(trim($file), '/');
180
-        return apply_filters('site-reviews/path', $path, $file);
179
+        $path = trailingslashit( $path ).ltrim( trim( $file ), '/' );
180
+        return apply_filters( 'site-reviews/path', $path, $file );
181 181
     }
182 182
 
183 183
     /**
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
      */
186 186
     public function registerAddons()
187 187
     {
188
-        do_action('site-reviews/addon/register', $this);
188
+        do_action( 'site-reviews/addon/register', $this );
189 189
     }
190 190
 
191 191
     /**
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function registerLanguages()
195 195
     {
196
-        load_plugin_textdomain(static::ID, false,
197
-            trailingslashit(plugin_basename($this->path()).'/'.$this->languages)
196
+        load_plugin_textdomain( static::ID, false,
197
+            trailingslashit( plugin_basename( $this->path() ).'/'.$this->languages )
198 198
         );
199 199
     }
200 200
 
@@ -203,26 +203,26 @@  discard block
 block discarded – undo
203 203
      */
204 204
     public function registerReviewTypes()
205 205
     {
206
-        $types = apply_filters('site-reviews/addon/types', []);
207
-        $this->reviewTypes = wp_parse_args($types, [
208
-            'local' => __('Local', 'site-reviews'),
209
-        ]);
206
+        $types = apply_filters( 'site-reviews/addon/types', [] );
207
+        $this->reviewTypes = wp_parse_args( $types, [
208
+            'local' => __( 'Local', 'site-reviews' ),
209
+        ] );
210 210
     }
211 211
 
212 212
     /**
213 213
      * @param string $view
214 214
      * @return void
215 215
      */
216
-    public function render($view, array $data = [])
216
+    public function render( $view, array $data = [] )
217 217
     {
218
-        $view = apply_filters('site-reviews/render/view', $view, $data);
219
-        $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data);
220
-        if (!file_exists($file)) {
221
-            glsr_log()->error('File not found: '.$file);
218
+        $view = apply_filters( 'site-reviews/render/view', $view, $data );
219
+        $file = apply_filters( 'site-reviews/views/file', $this->file( $view ), $view, $data );
220
+        if( !file_exists( $file ) ) {
221
+            glsr_log()->error( 'File not found: '.$file );
222 222
             return;
223 223
         }
224
-        $data = apply_filters('site-reviews/views/data', $data, $view);
225
-        extract($data);
224
+        $data = apply_filters( 'site-reviews/views/data', $data, $view );
225
+        extract( $data );
226 226
         include $file;
227 227
     }
228 228
 
@@ -231,19 +231,19 @@  discard block
 block discarded – undo
231 231
      */
232 232
     public function scheduleCronJob()
233 233
     {
234
-        if (wp_next_scheduled(static::CRON_EVENT)) {
234
+        if( wp_next_scheduled( static::CRON_EVENT ) ) {
235 235
             return;
236 236
         }
237
-        wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT);
237
+        wp_schedule_event( time(), 'twicedaily', static::CRON_EVENT );
238 238
     }
239 239
 
240 240
     /**
241 241
      * @param string $file
242 242
      * @return string
243 243
      */
244
-    public function themePath($file = '')
244
+    public function themePath( $file = '' )
245 245
     {
246
-        return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/');
246
+        return get_stylesheet_directory().'/'.static::ID.'/'.ltrim( trim( $file ), '/' );
247 247
     }
248 248
 
249 249
     /**
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      */
252 252
     public function unscheduleCronJob()
253 253
     {
254
-        wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT);
254
+        wp_unschedule_event( intval( wp_next_scheduled( static::CRON_EVENT ) ), static::CRON_EVENT );
255 255
     }
256 256
 
257 257
     /**
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
      */
260 260
     public function upgrade()
261 261
     {
262
-        $this->make(Upgrader::class)->run();
262
+        $this->make( Upgrader::class )->run();
263 263
     }
264 264
 
265 265
     /**
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
      * @return void
268 268
      * @action upgrader_process_complete
269 269
      */
270
-    public function upgraded($upgrader, array $data)
270
+    public function upgraded( $upgrader, array $data )
271 271
     {
272
-        if (array_key_exists('plugins', $data)
273
-            && in_array(plugin_basename($this->file), $data['plugins'])
272
+        if( array_key_exists( 'plugins', $data )
273
+            && in_array( plugin_basename( $this->file ), $data['plugins'] )
274 274
             && 'update' === $data['action']
275 275
             && 'plugin' === $data['type']
276 276
         ) {
@@ -282,29 +282,29 @@  discard block
 block discarded – undo
282 282
      * @param string $path
283 283
      * @return string
284 284
      */
285
-    public function url($path = '')
285
+    public function url( $path = '' )
286 286
     {
287
-        $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/'));
288
-        return apply_filters('site-reviews/url', $url, $path);
287
+        $url = esc_url( plugin_dir_url( $this->file ).ltrim( trim( $path ), '/' ) );
288
+        return apply_filters( 'site-reviews/url', $url, $path );
289 289
     }
290 290
 
291 291
     /**
292 292
      * @param string $versionLevel
293 293
      * @return string
294 294
      */
295
-    public function version($versionLevel = '')
295
+    public function version( $versionLevel = '' )
296 296
     {
297 297
         $pattern = '/^v?(\d{1,5})(\.\d++)?(\.\d++)?(.+)?$/i';
298
-        preg_match($pattern, $this->version, $matches);
299
-        switch ($versionLevel) {
298
+        preg_match( $pattern, $this->version, $matches );
299
+        switch( $versionLevel ) {
300 300
             case 'major':
301
-                $version = glsr_get($matches, 1);
301
+                $version = glsr_get( $matches, 1 );
302 302
                 break;
303 303
             case 'minor':
304
-                $version = glsr_get($matches, 1).glsr_get($matches, 2);
304
+                $version = glsr_get( $matches, 1 ).glsr_get( $matches, 2 );
305 305
                 break;
306 306
             case 'patch':
307
-                $version = glsr_get($matches, 1).glsr_get($matches, 2).glsr_get($matches, 3);
307
+                $version = glsr_get( $matches, 1 ).glsr_get( $matches, 2 ).glsr_get( $matches, 3 );
308 308
                 break;
309 309
         }
310 310
         return empty($version)
Please login to merge, or discard this patch.
plugin/Controllers/MenuController.php 2 patches
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -13,189 +13,189 @@
 block discarded – undo
13 13
 
14 14
 class MenuController extends Controller
15 15
 {
16
-    /**
17
-     * @return void
18
-     * @action admin_menu
19
-     */
20
-    public function registerMenuCount()
21
-    {
22
-        global $menu, $typenow;
23
-        foreach ($menu as $key => $value) {
24
-            if (!isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE) {
25
-                continue;
26
-            }
27
-            $postCount = wp_count_posts(Application::POST_TYPE);
28
-            $pendingCount = glsr(Builder::class)->span(number_format_i18n($postCount->pending), [
29
-                'class' => 'unapproved-count',
30
-            ]);
31
-            $awaitingModeration = glsr(Builder::class)->span($pendingCount, [
32
-                'class' => 'awaiting-mod count-'.$postCount->pending,
33
-            ]);
34
-            $menu[$key][0].= ' '.$awaitingModeration;
35
-            if (Application::POST_TYPE === $typenow) {
36
-                $menu[$key][4].= ' current';
37
-            }
38
-            break;
39
-        }
40
-    }
16
+	/**
17
+	 * @return void
18
+	 * @action admin_menu
19
+	 */
20
+	public function registerMenuCount()
21
+	{
22
+		global $menu, $typenow;
23
+		foreach ($menu as $key => $value) {
24
+			if (!isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE) {
25
+				continue;
26
+			}
27
+			$postCount = wp_count_posts(Application::POST_TYPE);
28
+			$pendingCount = glsr(Builder::class)->span(number_format_i18n($postCount->pending), [
29
+				'class' => 'unapproved-count',
30
+			]);
31
+			$awaitingModeration = glsr(Builder::class)->span($pendingCount, [
32
+				'class' => 'awaiting-mod count-'.$postCount->pending,
33
+			]);
34
+			$menu[$key][0].= ' '.$awaitingModeration;
35
+			if (Application::POST_TYPE === $typenow) {
36
+				$menu[$key][4].= ' current';
37
+			}
38
+			break;
39
+		}
40
+	}
41 41
 
42
-    /**
43
-     * @return void
44
-     * @action admin_menu
45
-     */
46
-    public function registerSubMenus()
47
-    {
48
-        $pages = $this->parseWithFilter('submenu/pages', [
49
-            'settings' => __('Settings', 'site-reviews'),
50
-            'tools' => __('Tools', 'site-reviews'),
51
-            'addons' => __('Add-ons', 'site-reviews'),
52
-            'documentation' => __('Documentation', 'site-reviews'),
53
-        ]);
54
-        foreach ($pages as $slug => $title) {
55
-            $method = glsr(Helper::class)->buildMethodName('render-'.$slug.'-menu');
56
-            $callback = apply_filters('site-reviews/addon/submenu/callback', [$this, $method], $slug);
57
-            if (!is_callable($callback)) {
58
-                continue;
59
-            }
60
-            add_submenu_page('edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission($slug), $slug, $callback);
61
-        }
62
-    }
42
+	/**
43
+	 * @return void
44
+	 * @action admin_menu
45
+	 */
46
+	public function registerSubMenus()
47
+	{
48
+		$pages = $this->parseWithFilter('submenu/pages', [
49
+			'settings' => __('Settings', 'site-reviews'),
50
+			'tools' => __('Tools', 'site-reviews'),
51
+			'addons' => __('Add-ons', 'site-reviews'),
52
+			'documentation' => __('Documentation', 'site-reviews'),
53
+		]);
54
+		foreach ($pages as $slug => $title) {
55
+			$method = glsr(Helper::class)->buildMethodName('render-'.$slug.'-menu');
56
+			$callback = apply_filters('site-reviews/addon/submenu/callback', [$this, $method], $slug);
57
+			if (!is_callable($callback)) {
58
+				continue;
59
+			}
60
+			add_submenu_page('edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission($slug), $slug, $callback);
61
+		}
62
+	}
63 63
 
64
-    /**
65
-     * @return void
66
-     * @see $this->registerSubMenus()
67
-     * @callback add_submenu_page
68
-     */
69
-    public function renderAddonsMenu()
70
-    {
71
-        $this->renderPage('addons', [
72
-            'template' => glsr(Template::class),
73
-        ]);
74
-    }
64
+	/**
65
+	 * @return void
66
+	 * @see $this->registerSubMenus()
67
+	 * @callback add_submenu_page
68
+	 */
69
+	public function renderAddonsMenu()
70
+	{
71
+		$this->renderPage('addons', [
72
+			'template' => glsr(Template::class),
73
+		]);
74
+	}
75 75
 
76
-    /**
77
-     * @return void
78
-     * @see $this->registerSubMenus()
79
-     * @callback add_submenu_page
80
-     */
81
-    public function renderDocumentationMenu()
82
-    {
83
-        $tabs = $this->parseWithFilter('documentation/tabs', [
84
-            'support' => __('Support', 'site-reviews'),
85
-            'faq' => __('FAQ', 'site-reviews'),
86
-            'shortcodes' => __('Shortcodes', 'site-reviews'),
87
-            'hooks' => __('Hooks', 'site-reviews'),
88
-            'functions' => __('Functions', 'site-reviews'),
89
-            'addons' => __('Addons', 'site-reviews'),
90
-        ]);
91
-        $addons = apply_filters('site-reviews/addon/documentation', []);
92
-        ksort($addons);
93
-        if (empty($addons)) {
94
-            unset($tabs['addons']);
95
-        }
96
-        $this->renderPage('documentation', [
97
-            'addons' => $addons,
98
-            'tabs' => $tabs,
99
-        ]);
100
-    }
76
+	/**
77
+	 * @return void
78
+	 * @see $this->registerSubMenus()
79
+	 * @callback add_submenu_page
80
+	 */
81
+	public function renderDocumentationMenu()
82
+	{
83
+		$tabs = $this->parseWithFilter('documentation/tabs', [
84
+			'support' => __('Support', 'site-reviews'),
85
+			'faq' => __('FAQ', 'site-reviews'),
86
+			'shortcodes' => __('Shortcodes', 'site-reviews'),
87
+			'hooks' => __('Hooks', 'site-reviews'),
88
+			'functions' => __('Functions', 'site-reviews'),
89
+			'addons' => __('Addons', 'site-reviews'),
90
+		]);
91
+		$addons = apply_filters('site-reviews/addon/documentation', []);
92
+		ksort($addons);
93
+		if (empty($addons)) {
94
+			unset($tabs['addons']);
95
+		}
96
+		$this->renderPage('documentation', [
97
+			'addons' => $addons,
98
+			'tabs' => $tabs,
99
+		]);
100
+	}
101 101
 
102
-    /**
103
-     * @return void
104
-     * @see $this->registerSubMenus()
105
-     * @callback add_submenu_page
106
-     */
107
-    public function renderSettingsMenu()
108
-    {
109
-        $tabs = $this->parseWithFilter('settings/tabs', [
110
-            'general' => __('General', 'site-reviews'),
111
-            'reviews' => __('Reviews', 'site-reviews'),
112
-            'submissions' => __('Submissions', 'site-reviews'),
113
-            'schema' => __('Schema', 'site-reviews'),
114
-            'translations' => __('Translations', 'site-reviews'),
115
-            'addons' => __('Addons', 'site-reviews'),
116
-            'licenses' => __('Licenses', 'site-reviews'),
117
-        ]);
118
-        if (empty(glsr(Helper::class)->dataGet(glsr()->defaults, 'settings.addons'))) {
119
-            unset($tabs['addons']);
120
-        }
121
-        if (empty(glsr(Helper::class)->dataGet(glsr()->defaults, 'settings.licenses'))) {
122
-            unset($tabs['licenses']);
123
-        }
124
-        $this->renderPage('settings', [
125
-            'settings' => glsr(Settings::class),
126
-            'tabs' => $tabs,
127
-        ]);
128
-    }
102
+	/**
103
+	 * @return void
104
+	 * @see $this->registerSubMenus()
105
+	 * @callback add_submenu_page
106
+	 */
107
+	public function renderSettingsMenu()
108
+	{
109
+		$tabs = $this->parseWithFilter('settings/tabs', [
110
+			'general' => __('General', 'site-reviews'),
111
+			'reviews' => __('Reviews', 'site-reviews'),
112
+			'submissions' => __('Submissions', 'site-reviews'),
113
+			'schema' => __('Schema', 'site-reviews'),
114
+			'translations' => __('Translations', 'site-reviews'),
115
+			'addons' => __('Addons', 'site-reviews'),
116
+			'licenses' => __('Licenses', 'site-reviews'),
117
+		]);
118
+		if (empty(glsr(Helper::class)->dataGet(glsr()->defaults, 'settings.addons'))) {
119
+			unset($tabs['addons']);
120
+		}
121
+		if (empty(glsr(Helper::class)->dataGet(glsr()->defaults, 'settings.licenses'))) {
122
+			unset($tabs['licenses']);
123
+		}
124
+		$this->renderPage('settings', [
125
+			'settings' => glsr(Settings::class),
126
+			'tabs' => $tabs,
127
+		]);
128
+	}
129 129
 
130
-    /**
131
-     * @return void
132
-     * @see $this->registerSubMenus()
133
-     * @callback add_submenu_page
134
-     */
135
-    public function renderToolsMenu()
136
-    {
137
-        $tabs = $this->parseWithFilter('tools/tabs', [
138
-            'general' => __('General', 'site-reviews'),
139
-            'sync' => __('Sync Reviews', 'site-reviews'),
140
-            'console' => __('Console', 'site-reviews'),
141
-            'system-info' => __('System Info', 'site-reviews'),
142
-        ]);
143
-        if (!apply_filters('site-reviews/addon/sync/enable', false)) {
144
-            unset($tabs['sync']);
145
-        }
146
-        $this->renderPage('tools', [
147
-            'data' => [
148
-                'context' => [
149
-                    'base_url' => admin_url('edit.php?post_type='.Application::POST_TYPE),
150
-                    'console' => strval(glsr(Console::class)),
151
-                    'id' => Application::ID,
152
-                    'system' => strval(glsr(System::class)),
153
-                ],
154
-                'services' => apply_filters('site-reviews/addon/sync/services', []),
155
-            ],
156
-            'tabs' => $tabs,
157
-            'template' => glsr(Template::class),
158
-        ]);
159
-    }
130
+	/**
131
+	 * @return void
132
+	 * @see $this->registerSubMenus()
133
+	 * @callback add_submenu_page
134
+	 */
135
+	public function renderToolsMenu()
136
+	{
137
+		$tabs = $this->parseWithFilter('tools/tabs', [
138
+			'general' => __('General', 'site-reviews'),
139
+			'sync' => __('Sync Reviews', 'site-reviews'),
140
+			'console' => __('Console', 'site-reviews'),
141
+			'system-info' => __('System Info', 'site-reviews'),
142
+		]);
143
+		if (!apply_filters('site-reviews/addon/sync/enable', false)) {
144
+			unset($tabs['sync']);
145
+		}
146
+		$this->renderPage('tools', [
147
+			'data' => [
148
+				'context' => [
149
+					'base_url' => admin_url('edit.php?post_type='.Application::POST_TYPE),
150
+					'console' => strval(glsr(Console::class)),
151
+					'id' => Application::ID,
152
+					'system' => strval(glsr(System::class)),
153
+				],
154
+				'services' => apply_filters('site-reviews/addon/sync/services', []),
155
+			],
156
+			'tabs' => $tabs,
157
+			'template' => glsr(Template::class),
158
+		]);
159
+	}
160 160
 
161
-    /**
162
-     * @return void
163
-     * @action admin_init
164
-     */
165
-    public function setCustomPermissions()
166
-    {
167
-        foreach (wp_roles()->roles as $role => $value) {
168
-            wp_roles()->remove_cap($role, 'create_'.Application::POST_TYPE);
169
-        }
170
-    }
161
+	/**
162
+	 * @return void
163
+	 * @action admin_init
164
+	 */
165
+	public function setCustomPermissions()
166
+	{
167
+		foreach (wp_roles()->roles as $role => $value) {
168
+			wp_roles()->remove_cap($role, 'create_'.Application::POST_TYPE);
169
+		}
170
+	}
171 171
 
172
-    /**
173
-     * @return string
174
-     */
175
-    protected function getNotices()
176
-    {
177
-        return glsr(Builder::class)->div(glsr(Notice::class)->get(), [
178
-            'id' => 'glsr-notices',
179
-        ]);
180
-    }
172
+	/**
173
+	 * @return string
174
+	 */
175
+	protected function getNotices()
176
+	{
177
+		return glsr(Builder::class)->div(glsr(Notice::class)->get(), [
178
+			'id' => 'glsr-notices',
179
+		]);
180
+	}
181 181
 
182
-    /**
183
-     * @param string $hookSuffix
184
-     * @return array
185
-     */
186
-    protected function parseWithFilter($hookSuffix, array $args = [])
187
-    {
188
-        return apply_filters('site-reviews/addon/'.$hookSuffix, $args);
189
-    }
182
+	/**
183
+	 * @param string $hookSuffix
184
+	 * @return array
185
+	 */
186
+	protected function parseWithFilter($hookSuffix, array $args = [])
187
+	{
188
+		return apply_filters('site-reviews/addon/'.$hookSuffix, $args);
189
+	}
190 190
 
191
-    /**
192
-     * @param string $page
193
-     * @return void
194
-     */
195
-    protected function renderPage($page, array $data = [])
196
-    {
197
-        $data['http_referer'] = (string) wp_get_referer();
198
-        $data['notices'] = $this->getNotices();
199
-        glsr()->render('pages/'.$page.'/index', $data);
200
-    }
191
+	/**
192
+	 * @param string $page
193
+	 * @return void
194
+	 */
195
+	protected function renderPage($page, array $data = [])
196
+	{
197
+		$data['http_referer'] = (string) wp_get_referer();
198
+		$data['notices'] = $this->getNotices();
199
+		glsr()->render('pages/'.$page.'/index', $data);
200
+	}
201 201
 }
Please login to merge, or discard this patch.
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -20,20 +20,20 @@  discard block
 block discarded – undo
20 20
     public function registerMenuCount()
21 21
     {
22 22
         global $menu, $typenow;
23
-        foreach ($menu as $key => $value) {
24
-            if (!isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE) {
23
+        foreach( $menu as $key => $value ) {
24
+            if( !isset($value[2]) || $value[2] != 'edit.php?post_type='.Application::POST_TYPE ) {
25 25
                 continue;
26 26
             }
27
-            $postCount = wp_count_posts(Application::POST_TYPE);
28
-            $pendingCount = glsr(Builder::class)->span(number_format_i18n($postCount->pending), [
27
+            $postCount = wp_count_posts( Application::POST_TYPE );
28
+            $pendingCount = glsr( Builder::class )->span( number_format_i18n( $postCount->pending ), [
29 29
                 'class' => 'unapproved-count',
30
-            ]);
31
-            $awaitingModeration = glsr(Builder::class)->span($pendingCount, [
30
+            ] );
31
+            $awaitingModeration = glsr( Builder::class )->span( $pendingCount, [
32 32
                 'class' => 'awaiting-mod count-'.$postCount->pending,
33
-            ]);
34
-            $menu[$key][0].= ' '.$awaitingModeration;
35
-            if (Application::POST_TYPE === $typenow) {
36
-                $menu[$key][4].= ' current';
33
+            ] );
34
+            $menu[$key][0] .= ' '.$awaitingModeration;
35
+            if( Application::POST_TYPE === $typenow ) {
36
+                $menu[$key][4] .= ' current';
37 37
             }
38 38
             break;
39 39
         }
@@ -45,19 +45,19 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function registerSubMenus()
47 47
     {
48
-        $pages = $this->parseWithFilter('submenu/pages', [
49
-            'settings' => __('Settings', 'site-reviews'),
50
-            'tools' => __('Tools', 'site-reviews'),
51
-            'addons' => __('Add-ons', 'site-reviews'),
52
-            'documentation' => __('Documentation', 'site-reviews'),
53
-        ]);
54
-        foreach ($pages as $slug => $title) {
55
-            $method = glsr(Helper::class)->buildMethodName('render-'.$slug.'-menu');
56
-            $callback = apply_filters('site-reviews/addon/submenu/callback', [$this, $method], $slug);
57
-            if (!is_callable($callback)) {
48
+        $pages = $this->parseWithFilter( 'submenu/pages', [
49
+            'settings' => __( 'Settings', 'site-reviews' ),
50
+            'tools' => __( 'Tools', 'site-reviews' ),
51
+            'addons' => __( 'Add-ons', 'site-reviews' ),
52
+            'documentation' => __( 'Documentation', 'site-reviews' ),
53
+        ] );
54
+        foreach( $pages as $slug => $title ) {
55
+            $method = glsr( Helper::class )->buildMethodName( 'render-'.$slug.'-menu' );
56
+            $callback = apply_filters( 'site-reviews/addon/submenu/callback', [$this, $method], $slug );
57
+            if( !is_callable( $callback ) ) {
58 58
                 continue;
59 59
             }
60
-            add_submenu_page('edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission($slug), $slug, $callback);
60
+            add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, $title, $title, glsr()->getPermission( $slug ), $slug, $callback );
61 61
         }
62 62
     }
63 63
 
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
      */
69 69
     public function renderAddonsMenu()
70 70
     {
71
-        $this->renderPage('addons', [
72
-            'template' => glsr(Template::class),
73
-        ]);
71
+        $this->renderPage( 'addons', [
72
+            'template' => glsr( Template::class ),
73
+        ] );
74 74
     }
75 75
 
76 76
     /**
@@ -80,23 +80,23 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function renderDocumentationMenu()
82 82
     {
83
-        $tabs = $this->parseWithFilter('documentation/tabs', [
84
-            'support' => __('Support', 'site-reviews'),
85
-            'faq' => __('FAQ', 'site-reviews'),
86
-            'shortcodes' => __('Shortcodes', 'site-reviews'),
87
-            'hooks' => __('Hooks', 'site-reviews'),
88
-            'functions' => __('Functions', 'site-reviews'),
89
-            'addons' => __('Addons', 'site-reviews'),
90
-        ]);
91
-        $addons = apply_filters('site-reviews/addon/documentation', []);
92
-        ksort($addons);
93
-        if (empty($addons)) {
83
+        $tabs = $this->parseWithFilter( 'documentation/tabs', [
84
+            'support' => __( 'Support', 'site-reviews' ),
85
+            'faq' => __( 'FAQ', 'site-reviews' ),
86
+            'shortcodes' => __( 'Shortcodes', 'site-reviews' ),
87
+            'hooks' => __( 'Hooks', 'site-reviews' ),
88
+            'functions' => __( 'Functions', 'site-reviews' ),
89
+            'addons' => __( 'Addons', 'site-reviews' ),
90
+        ] );
91
+        $addons = apply_filters( 'site-reviews/addon/documentation', [] );
92
+        ksort( $addons );
93
+        if( empty($addons) ) {
94 94
             unset($tabs['addons']);
95 95
         }
96
-        $this->renderPage('documentation', [
96
+        $this->renderPage( 'documentation', [
97 97
             'addons' => $addons,
98 98
             'tabs' => $tabs,
99
-        ]);
99
+        ] );
100 100
     }
101 101
 
102 102
     /**
@@ -106,25 +106,25 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public function renderSettingsMenu()
108 108
     {
109
-        $tabs = $this->parseWithFilter('settings/tabs', [
110
-            'general' => __('General', 'site-reviews'),
111
-            'reviews' => __('Reviews', 'site-reviews'),
112
-            'submissions' => __('Submissions', 'site-reviews'),
113
-            'schema' => __('Schema', 'site-reviews'),
114
-            'translations' => __('Translations', 'site-reviews'),
115
-            'addons' => __('Addons', 'site-reviews'),
116
-            'licenses' => __('Licenses', 'site-reviews'),
117
-        ]);
118
-        if (empty(glsr(Helper::class)->dataGet(glsr()->defaults, 'settings.addons'))) {
109
+        $tabs = $this->parseWithFilter( 'settings/tabs', [
110
+            'general' => __( 'General', 'site-reviews' ),
111
+            'reviews' => __( 'Reviews', 'site-reviews' ),
112
+            'submissions' => __( 'Submissions', 'site-reviews' ),
113
+            'schema' => __( 'Schema', 'site-reviews' ),
114
+            'translations' => __( 'Translations', 'site-reviews' ),
115
+            'addons' => __( 'Addons', 'site-reviews' ),
116
+            'licenses' => __( 'Licenses', 'site-reviews' ),
117
+        ] );
118
+        if( empty(glsr( Helper::class )->dataGet( glsr()->defaults, 'settings.addons' )) ) {
119 119
             unset($tabs['addons']);
120 120
         }
121
-        if (empty(glsr(Helper::class)->dataGet(glsr()->defaults, 'settings.licenses'))) {
121
+        if( empty(glsr( Helper::class )->dataGet( glsr()->defaults, 'settings.licenses' )) ) {
122 122
             unset($tabs['licenses']);
123 123
         }
124
-        $this->renderPage('settings', [
125
-            'settings' => glsr(Settings::class),
124
+        $this->renderPage( 'settings', [
125
+            'settings' => glsr( Settings::class ),
126 126
             'tabs' => $tabs,
127
-        ]);
127
+        ] );
128 128
     }
129 129
 
130 130
     /**
@@ -134,28 +134,28 @@  discard block
 block discarded – undo
134 134
      */
135 135
     public function renderToolsMenu()
136 136
     {
137
-        $tabs = $this->parseWithFilter('tools/tabs', [
138
-            'general' => __('General', 'site-reviews'),
139
-            'sync' => __('Sync Reviews', 'site-reviews'),
140
-            'console' => __('Console', 'site-reviews'),
141
-            'system-info' => __('System Info', 'site-reviews'),
142
-        ]);
143
-        if (!apply_filters('site-reviews/addon/sync/enable', false)) {
137
+        $tabs = $this->parseWithFilter( 'tools/tabs', [
138
+            'general' => __( 'General', 'site-reviews' ),
139
+            'sync' => __( 'Sync Reviews', 'site-reviews' ),
140
+            'console' => __( 'Console', 'site-reviews' ),
141
+            'system-info' => __( 'System Info', 'site-reviews' ),
142
+        ] );
143
+        if( !apply_filters( 'site-reviews/addon/sync/enable', false ) ) {
144 144
             unset($tabs['sync']);
145 145
         }
146
-        $this->renderPage('tools', [
146
+        $this->renderPage( 'tools', [
147 147
             'data' => [
148 148
                 'context' => [
149
-                    'base_url' => admin_url('edit.php?post_type='.Application::POST_TYPE),
150
-                    'console' => strval(glsr(Console::class)),
149
+                    'base_url' => admin_url( 'edit.php?post_type='.Application::POST_TYPE ),
150
+                    'console' => strval( glsr( Console::class ) ),
151 151
                     'id' => Application::ID,
152
-                    'system' => strval(glsr(System::class)),
152
+                    'system' => strval( glsr( System::class ) ),
153 153
                 ],
154
-                'services' => apply_filters('site-reviews/addon/sync/services', []),
154
+                'services' => apply_filters( 'site-reviews/addon/sync/services', [] ),
155 155
             ],
156 156
             'tabs' => $tabs,
157
-            'template' => glsr(Template::class),
158
-        ]);
157
+            'template' => glsr( Template::class ),
158
+        ] );
159 159
     }
160 160
 
161 161
     /**
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
      */
165 165
     public function setCustomPermissions()
166 166
     {
167
-        foreach (wp_roles()->roles as $role => $value) {
168
-            wp_roles()->remove_cap($role, 'create_'.Application::POST_TYPE);
167
+        foreach( wp_roles()->roles as $role => $value ) {
168
+            wp_roles()->remove_cap( $role, 'create_'.Application::POST_TYPE );
169 169
         }
170 170
     }
171 171
 
@@ -174,28 +174,28 @@  discard block
 block discarded – undo
174 174
      */
175 175
     protected function getNotices()
176 176
     {
177
-        return glsr(Builder::class)->div(glsr(Notice::class)->get(), [
177
+        return glsr( Builder::class )->div( glsr( Notice::class )->get(), [
178 178
             'id' => 'glsr-notices',
179
-        ]);
179
+        ] );
180 180
     }
181 181
 
182 182
     /**
183 183
      * @param string $hookSuffix
184 184
      * @return array
185 185
      */
186
-    protected function parseWithFilter($hookSuffix, array $args = [])
186
+    protected function parseWithFilter( $hookSuffix, array $args = [] )
187 187
     {
188
-        return apply_filters('site-reviews/addon/'.$hookSuffix, $args);
188
+        return apply_filters( 'site-reviews/addon/'.$hookSuffix, $args );
189 189
     }
190 190
 
191 191
     /**
192 192
      * @param string $page
193 193
      * @return void
194 194
      */
195
-    protected function renderPage($page, array $data = [])
195
+    protected function renderPage( $page, array $data = [] )
196 196
     {
197
-        $data['http_referer'] = (string) wp_get_referer();
197
+        $data['http_referer'] = (string)wp_get_referer();
198 198
         $data['notices'] = $this->getNotices();
199
-        glsr()->render('pages/'.$page.'/index', $data);
199
+        glsr()->render( 'pages/'.$page.'/index', $data );
200 200
     }
201 201
 }
Please login to merge, or discard this patch.
plugin/Controllers/AjaxController.php 2 patches
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -12,163 +12,163 @@
 block discarded – undo
12 12
 
13 13
 class AjaxController extends Controller
14 14
 {
15
-    /**
16
-     * @return void
17
-     */
18
-    public function routerChangeStatus(array $request)
19
-    {
20
-        wp_send_json_success($this->execute(new ChangeStatus($request)));
21
-    }
15
+	/**
16
+	 * @return void
17
+	 */
18
+	public function routerChangeStatus(array $request)
19
+	{
20
+		wp_send_json_success($this->execute(new ChangeStatus($request)));
21
+	}
22 22
 
23
-    /**
24
-     * @return void
25
-     */
26
-    public function routerClearConsole()
27
-    {
28
-        glsr(AdminController::class)->routerClearConsole();
29
-        wp_send_json_success([
30
-            'console' => glsr(Console::class)->get(),
31
-            'notices' => glsr(Notice::class)->get(),
32
-        ]);
33
-    }
23
+	/**
24
+	 * @return void
25
+	 */
26
+	public function routerClearConsole()
27
+	{
28
+		glsr(AdminController::class)->routerClearConsole();
29
+		wp_send_json_success([
30
+			'console' => glsr(Console::class)->get(),
31
+			'notices' => glsr(Notice::class)->get(),
32
+		]);
33
+	}
34 34
 
35
-    /**
36
-     * @return void
37
-     */
38
-    public function routerCountReviews()
39
-    {
40
-        glsr(AdminController::class)->routerCountReviews();
41
-        wp_send_json_success([
42
-            'notices' => glsr(Notice::class)->get(),
43
-        ]);
44
-    }
35
+	/**
36
+	 * @return void
37
+	 */
38
+	public function routerCountReviews()
39
+	{
40
+		glsr(AdminController::class)->routerCountReviews();
41
+		wp_send_json_success([
42
+			'notices' => glsr(Notice::class)->get(),
43
+		]);
44
+	}
45 45
 
46
-    /**
47
-     * @return void
48
-     */
49
-    public function routerDismissNotice(array $request)
50
-    {
51
-        glsr(NoticeController::class)->routerDismissNotice($request);
52
-        wp_send_json_success();
53
-    }
46
+	/**
47
+	 * @return void
48
+	 */
49
+	public function routerDismissNotice(array $request)
50
+	{
51
+		glsr(NoticeController::class)->routerDismissNotice($request);
52
+		wp_send_json_success();
53
+	}
54 54
 
55
-    /**
56
-     * @return void
57
-     */
58
-    public function routerMceShortcode(array $request)
59
-    {
60
-        $shortcode = $request['shortcode'];
61
-        $response = false;
62
-        if (array_key_exists($shortcode, glsr()->mceShortcodes)) {
63
-            $data = glsr()->mceShortcodes[$shortcode];
64
-            if (!empty($data['errors'])) {
65
-                $data['btn_okay'] = [esc_html__('Okay', 'site-reviews')];
66
-            }
67
-            $response = [
68
-                'body' => $data['fields'],
69
-                'close' => $data['btn_close'],
70
-                'ok' => $data['btn_okay'],
71
-                'shortcode' => $shortcode,
72
-                'title' => $data['title'],
73
-            ];
74
-        }
75
-        wp_send_json_success($response);
76
-    }
55
+	/**
56
+	 * @return void
57
+	 */
58
+	public function routerMceShortcode(array $request)
59
+	{
60
+		$shortcode = $request['shortcode'];
61
+		$response = false;
62
+		if (array_key_exists($shortcode, glsr()->mceShortcodes)) {
63
+			$data = glsr()->mceShortcodes[$shortcode];
64
+			if (!empty($data['errors'])) {
65
+				$data['btn_okay'] = [esc_html__('Okay', 'site-reviews')];
66
+			}
67
+			$response = [
68
+				'body' => $data['fields'],
69
+				'close' => $data['btn_close'],
70
+				'ok' => $data['btn_okay'],
71
+				'shortcode' => $shortcode,
72
+				'title' => $data['title'],
73
+			];
74
+		}
75
+		wp_send_json_success($response);
76
+	}
77 77
 
78
-    /**
79
-     * @return void
80
-     */
81
-    public function routerFetchConsole()
82
-    {
83
-        glsr(AdminController::class)->routerFetchConsole();
84
-        wp_send_json_success([
85
-            'console' => glsr(Console::class)->get(),
86
-            'notices' => glsr(Notice::class)->get(),
87
-        ]);
88
-    }
78
+	/**
79
+	 * @return void
80
+	 */
81
+	public function routerFetchConsole()
82
+	{
83
+		glsr(AdminController::class)->routerFetchConsole();
84
+		wp_send_json_success([
85
+			'console' => glsr(Console::class)->get(),
86
+			'notices' => glsr(Notice::class)->get(),
87
+		]);
88
+	}
89 89
 
90
-    /**
91
-     * @return void
92
-     */
93
-    public function routerSearchPosts(array $request)
94
-    {
95
-        $results = glsr(Database::class)->searchPosts($request['search']);
96
-        wp_send_json_success([
97
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
98
-            'items' => $results,
99
-        ]);
100
-    }
90
+	/**
91
+	 * @return void
92
+	 */
93
+	public function routerSearchPosts(array $request)
94
+	{
95
+		$results = glsr(Database::class)->searchPosts($request['search']);
96
+		wp_send_json_success([
97
+			'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
98
+			'items' => $results,
99
+		]);
100
+	}
101 101
 
102
-    /**
103
-     * @return void
104
-     */
105
-    public function routerSearchTranslations(array $request)
106
-    {
107
-        if (empty($request['exclude'])) {
108
-            $request['exclude'] = [];
109
-        }
110
-        $results = glsr(Translation::class)
111
-            ->search($request['search'])
112
-            ->exclude()
113
-            ->exclude($request['exclude'])
114
-            ->renderResults();
115
-        wp_send_json_success([
116
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
117
-            'items' => $results,
118
-        ]);
119
-    }
102
+	/**
103
+	 * @return void
104
+	 */
105
+	public function routerSearchTranslations(array $request)
106
+	{
107
+		if (empty($request['exclude'])) {
108
+			$request['exclude'] = [];
109
+		}
110
+		$results = glsr(Translation::class)
111
+			->search($request['search'])
112
+			->exclude()
113
+			->exclude($request['exclude'])
114
+			->renderResults();
115
+		wp_send_json_success([
116
+			'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
117
+			'items' => $results,
118
+		]);
119
+	}
120 120
 
121
-    /**
122
-     * @return void
123
-     */
124
-    public function routerSubmitReview(array $request)
125
-    {
126
-        $command = glsr(PublicController::class)->routerSubmitReview($request);
127
-        $redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true)));
128
-        $redirect = apply_filters('site-reviews/review/redirect', $redirect, $command);
129
-        $data = [
130
-            'errors' => glsr()->sessionGet($command->form_id.'errors', false),
131
-            'message' => glsr()->sessionGet($command->form_id.'message', ''),
132
-            'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false),
133
-            'redirect' => $redirect,
134
-        ];
135
-        if (false === $data['errors']) {
136
-            glsr()->sessionClear();
137
-            wp_send_json_success($data);
138
-        }
139
-        wp_send_json_error($data);
140
-    }
121
+	/**
122
+	 * @return void
123
+	 */
124
+	public function routerSubmitReview(array $request)
125
+	{
126
+		$command = glsr(PublicController::class)->routerSubmitReview($request);
127
+		$redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true)));
128
+		$redirect = apply_filters('site-reviews/review/redirect', $redirect, $command);
129
+		$data = [
130
+			'errors' => glsr()->sessionGet($command->form_id.'errors', false),
131
+			'message' => glsr()->sessionGet($command->form_id.'message', ''),
132
+			'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false),
133
+			'redirect' => $redirect,
134
+		];
135
+		if (false === $data['errors']) {
136
+			glsr()->sessionClear();
137
+			wp_send_json_success($data);
138
+		}
139
+		wp_send_json_error($data);
140
+	}
141 141
 
142
-    /**
143
-     * @return void
144
-     */
145
-    public function routerFetchPagedReviews(array $request)
146
-    {
147
-        $urlQuery = [];
148
-        parse_str(parse_url(glsr_get($request, 'url'), PHP_URL_QUERY), $urlQuery);
149
-        $args = [
150
-            'paged' => glsr_get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1),
151
-            'pagedUrl' => home_url(parse_url(glsr_get($request, 'url'), PHP_URL_PATH)),
152
-            'pagination' => 'ajax',
153
-            'schema' => false,
154
-        ];
155
-        $atts = (array) json_decode(glsr_get($request, 'atts'));
156
-        $html = glsr(SiteReviews::class)->build(wp_parse_args($args, $atts));
157
-        return wp_send_json_success([
158
-            'pagination' => $html->getPagination(),
159
-            'reviews' => $html->getReviews(),
160
-        ]);
161
-    }
142
+	/**
143
+	 * @return void
144
+	 */
145
+	public function routerFetchPagedReviews(array $request)
146
+	{
147
+		$urlQuery = [];
148
+		parse_str(parse_url(glsr_get($request, 'url'), PHP_URL_QUERY), $urlQuery);
149
+		$args = [
150
+			'paged' => glsr_get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1),
151
+			'pagedUrl' => home_url(parse_url(glsr_get($request, 'url'), PHP_URL_PATH)),
152
+			'pagination' => 'ajax',
153
+			'schema' => false,
154
+		];
155
+		$atts = (array) json_decode(glsr_get($request, 'atts'));
156
+		$html = glsr(SiteReviews::class)->build(wp_parse_args($args, $atts));
157
+		return wp_send_json_success([
158
+			'pagination' => $html->getPagination(),
159
+			'reviews' => $html->getReviews(),
160
+		]);
161
+	}
162 162
 
163
-    /**
164
-     * @return void
165
-     */
166
-    public function routerTogglePinned(array $request)
167
-    {
168
-        $isPinned = $this->execute(new TogglePinned($request));
169
-        wp_send_json_success([
170
-            'notices' => glsr(Notice::class)->get(),
171
-            'pinned' => $isPinned,
172
-        ]);
173
-    }
163
+	/**
164
+	 * @return void
165
+	 */
166
+	public function routerTogglePinned(array $request)
167
+	{
168
+		$isPinned = $this->execute(new TogglePinned($request));
169
+		wp_send_json_success([
170
+			'notices' => glsr(Notice::class)->get(),
171
+			'pinned' => $isPinned,
172
+		]);
173
+	}
174 174
 }
Please login to merge, or discard this patch.
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
     /**
16 16
      * @return void
17 17
      */
18
-    public function routerChangeStatus(array $request)
18
+    public function routerChangeStatus( array $request )
19 19
     {
20
-        wp_send_json_success($this->execute(new ChangeStatus($request)));
20
+        wp_send_json_success( $this->execute( new ChangeStatus( $request ) ) );
21 21
     }
22 22
 
23 23
     /**
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function routerClearConsole()
27 27
     {
28
-        glsr(AdminController::class)->routerClearConsole();
29
-        wp_send_json_success([
30
-            'console' => glsr(Console::class)->get(),
31
-            'notices' => glsr(Notice::class)->get(),
32
-        ]);
28
+        glsr( AdminController::class )->routerClearConsole();
29
+        wp_send_json_success( [
30
+            'console' => glsr( Console::class )->get(),
31
+            'notices' => glsr( Notice::class )->get(),
32
+        ] );
33 33
     }
34 34
 
35 35
     /**
@@ -37,32 +37,32 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function routerCountReviews()
39 39
     {
40
-        glsr(AdminController::class)->routerCountReviews();
41
-        wp_send_json_success([
42
-            'notices' => glsr(Notice::class)->get(),
43
-        ]);
40
+        glsr( AdminController::class )->routerCountReviews();
41
+        wp_send_json_success( [
42
+            'notices' => glsr( Notice::class )->get(),
43
+        ] );
44 44
     }
45 45
 
46 46
     /**
47 47
      * @return void
48 48
      */
49
-    public function routerDismissNotice(array $request)
49
+    public function routerDismissNotice( array $request )
50 50
     {
51
-        glsr(NoticeController::class)->routerDismissNotice($request);
51
+        glsr( NoticeController::class )->routerDismissNotice( $request );
52 52
         wp_send_json_success();
53 53
     }
54 54
 
55 55
     /**
56 56
      * @return void
57 57
      */
58
-    public function routerMceShortcode(array $request)
58
+    public function routerMceShortcode( array $request )
59 59
     {
60 60
         $shortcode = $request['shortcode'];
61 61
         $response = false;
62
-        if (array_key_exists($shortcode, glsr()->mceShortcodes)) {
62
+        if( array_key_exists( $shortcode, glsr()->mceShortcodes ) ) {
63 63
             $data = glsr()->mceShortcodes[$shortcode];
64
-            if (!empty($data['errors'])) {
65
-                $data['btn_okay'] = [esc_html__('Okay', 'site-reviews')];
64
+            if( !empty($data['errors']) ) {
65
+                $data['btn_okay'] = [esc_html__( 'Okay', 'site-reviews' )];
66 66
             }
67 67
             $response = [
68 68
                 'body' => $data['fields'],
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
                 'title' => $data['title'],
73 73
             ];
74 74
         }
75
-        wp_send_json_success($response);
75
+        wp_send_json_success( $response );
76 76
     }
77 77
 
78 78
     /**
@@ -80,95 +80,95 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function routerFetchConsole()
82 82
     {
83
-        glsr(AdminController::class)->routerFetchConsole();
84
-        wp_send_json_success([
85
-            'console' => glsr(Console::class)->get(),
86
-            'notices' => glsr(Notice::class)->get(),
87
-        ]);
83
+        glsr( AdminController::class )->routerFetchConsole();
84
+        wp_send_json_success( [
85
+            'console' => glsr( Console::class )->get(),
86
+            'notices' => glsr( Notice::class )->get(),
87
+        ] );
88 88
     }
89 89
 
90 90
     /**
91 91
      * @return void
92 92
      */
93
-    public function routerSearchPosts(array $request)
93
+    public function routerSearchPosts( array $request )
94 94
     {
95
-        $results = glsr(Database::class)->searchPosts($request['search']);
96
-        wp_send_json_success([
97
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
95
+        $results = glsr( Database::class )->searchPosts( $request['search'] );
96
+        wp_send_json_success( [
97
+            'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>',
98 98
             'items' => $results,
99
-        ]);
99
+        ] );
100 100
     }
101 101
 
102 102
     /**
103 103
      * @return void
104 104
      */
105
-    public function routerSearchTranslations(array $request)
105
+    public function routerSearchTranslations( array $request )
106 106
     {
107
-        if (empty($request['exclude'])) {
107
+        if( empty($request['exclude']) ) {
108 108
             $request['exclude'] = [];
109 109
         }
110
-        $results = glsr(Translation::class)
111
-            ->search($request['search'])
110
+        $results = glsr( Translation::class )
111
+            ->search( $request['search'] )
112 112
             ->exclude()
113
-            ->exclude($request['exclude'])
113
+            ->exclude( $request['exclude'] )
114 114
             ->renderResults();
115
-        wp_send_json_success([
116
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
115
+        wp_send_json_success( [
116
+            'empty' => '<div>'.__( 'Nothing found.', 'site-reviews' ).'</div>',
117 117
             'items' => $results,
118
-        ]);
118
+        ] );
119 119
     }
120 120
 
121 121
     /**
122 122
      * @return void
123 123
      */
124
-    public function routerSubmitReview(array $request)
124
+    public function routerSubmitReview( array $request )
125 125
     {
126
-        $command = glsr(PublicController::class)->routerSubmitReview($request);
127
-        $redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true)));
128
-        $redirect = apply_filters('site-reviews/review/redirect', $redirect, $command);
126
+        $command = glsr( PublicController::class )->routerSubmitReview( $request );
127
+        $redirect = trim( strval( get_post_meta( $command->post_id, 'redirect_to', true ) ) );
128
+        $redirect = apply_filters( 'site-reviews/review/redirect', $redirect, $command );
129 129
         $data = [
130
-            'errors' => glsr()->sessionGet($command->form_id.'errors', false),
131
-            'message' => glsr()->sessionGet($command->form_id.'message', ''),
132
-            'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false),
130
+            'errors' => glsr()->sessionGet( $command->form_id.'errors', false ),
131
+            'message' => glsr()->sessionGet( $command->form_id.'message', '' ),
132
+            'recaptcha' => glsr()->sessionGet( $command->form_id.'recaptcha', false ),
133 133
             'redirect' => $redirect,
134 134
         ];
135
-        if (false === $data['errors']) {
135
+        if( false === $data['errors'] ) {
136 136
             glsr()->sessionClear();
137
-            wp_send_json_success($data);
137
+            wp_send_json_success( $data );
138 138
         }
139
-        wp_send_json_error($data);
139
+        wp_send_json_error( $data );
140 140
     }
141 141
 
142 142
     /**
143 143
      * @return void
144 144
      */
145
-    public function routerFetchPagedReviews(array $request)
145
+    public function routerFetchPagedReviews( array $request )
146 146
     {
147 147
         $urlQuery = [];
148
-        parse_str(parse_url(glsr_get($request, 'url'), PHP_URL_QUERY), $urlQuery);
148
+        parse_str( parse_url( glsr_get( $request, 'url' ), PHP_URL_QUERY ), $urlQuery );
149 149
         $args = [
150
-            'paged' => glsr_get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1),
151
-            'pagedUrl' => home_url(parse_url(glsr_get($request, 'url'), PHP_URL_PATH)),
150
+            'paged' => glsr_get( $urlQuery, glsr()->constant( 'PAGED_QUERY_VAR' ), 1 ),
151
+            'pagedUrl' => home_url( parse_url( glsr_get( $request, 'url' ), PHP_URL_PATH ) ),
152 152
             'pagination' => 'ajax',
153 153
             'schema' => false,
154 154
         ];
155
-        $atts = (array) json_decode(glsr_get($request, 'atts'));
156
-        $html = glsr(SiteReviews::class)->build(wp_parse_args($args, $atts));
157
-        return wp_send_json_success([
155
+        $atts = (array)json_decode( glsr_get( $request, 'atts' ) );
156
+        $html = glsr( SiteReviews::class )->build( wp_parse_args( $args, $atts ) );
157
+        return wp_send_json_success( [
158 158
             'pagination' => $html->getPagination(),
159 159
             'reviews' => $html->getReviews(),
160
-        ]);
160
+        ] );
161 161
     }
162 162
 
163 163
     /**
164 164
      * @return void
165 165
      */
166
-    public function routerTogglePinned(array $request)
166
+    public function routerTogglePinned( array $request )
167 167
     {
168
-        $isPinned = $this->execute(new TogglePinned($request));
169
-        wp_send_json_success([
170
-            'notices' => glsr(Notice::class)->get(),
168
+        $isPinned = $this->execute( new TogglePinned( $request ) );
169
+        wp_send_json_success( [
170
+            'notices' => glsr( Notice::class )->get(),
171 171
             'pinned' => $isPinned,
172
-        ]);
172
+        ] );
173 173
     }
174 174
 }
Please login to merge, or discard this patch.
plugin/Modules/Notice.php 2 patches
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -8,112 +8,112 @@
 block discarded – undo
8 8
 
9 9
 class Notice
10 10
 {
11
-    /**
12
-     * @param string $type
13
-     * @param string|array|WP_Error $message
14
-     * @return void
15
-     */
16
-    public function add($type, $message, array $args = [])
17
-    {
18
-        if (empty(array_filter([$message, $type]))) {
19
-            return;
20
-        }
21
-        $args['message'] = $message;
22
-        $args['type'] = $type;
23
-        add_settings_error(Application::ID, '', json_encode($this->normalize($args)));
24
-    }
11
+	/**
12
+	 * @param string $type
13
+	 * @param string|array|WP_Error $message
14
+	 * @return void
15
+	 */
16
+	public function add($type, $message, array $args = [])
17
+	{
18
+		if (empty(array_filter([$message, $type]))) {
19
+			return;
20
+		}
21
+		$args['message'] = $message;
22
+		$args['type'] = $type;
23
+		add_settings_error(Application::ID, '', json_encode($this->normalize($args)));
24
+	}
25 25
 
26
-    /**
27
-     * @param string|array|WP_Error $message
28
-     * @return void
29
-     */
30
-    public function addError($message, array $args = [])
31
-    {
32
-        $this->add('error', $message, $args);
33
-    }
26
+	/**
27
+	 * @param string|array|WP_Error $message
28
+	 * @return void
29
+	 */
30
+	public function addError($message, array $args = [])
31
+	{
32
+		$this->add('error', $message, $args);
33
+	}
34 34
 
35
-    /**
36
-     * @param string|array|WP_Error $message
37
-     * @return void
38
-     */
39
-    public function addSuccess($message, array $args = [])
40
-    {
41
-        $this->add('success', $message, $args);
42
-    }
35
+	/**
36
+	 * @param string|array|WP_Error $message
37
+	 * @return void
38
+	 */
39
+	public function addSuccess($message, array $args = [])
40
+	{
41
+		$this->add('success', $message, $args);
42
+	}
43 43
 
44
-    /**
45
-     * @param string|array|WP_Error $message
46
-     * @return void
47
-     */
48
-    public function addWarning($message, array $args = [])
49
-    {
50
-        $this->add('warning', $message, $args);
51
-    }
44
+	/**
45
+	 * @param string|array|WP_Error $message
46
+	 * @return void
47
+	 */
48
+	public function addWarning($message, array $args = [])
49
+	{
50
+		$this->add('warning', $message, $args);
51
+	}
52 52
 
53
-    /**
54
-     * @return static
55
-     */
56
-    public function clear()
57
-    {
58
-        global $wp_settings_errors;
59
-        $wp_settings_errors = [];
60
-        delete_transient('settings_errors');
61
-        return $this;
62
-    }
53
+	/**
54
+	 * @return static
55
+	 */
56
+	public function clear()
57
+	{
58
+		global $wp_settings_errors;
59
+		$wp_settings_errors = [];
60
+		delete_transient('settings_errors');
61
+		return $this;
62
+	}
63 63
 
64
-    /**
65
-     * @return string
66
-     */
67
-    public function get()
68
-    {
69
-        $notices = array_map('unserialize',
70
-            array_unique(array_map('serialize', get_settings_errors(Application::ID)))
71
-        );
72
-        $notices = array_reduce($notices, function ($carry, $notice) {
73
-            return $carry.$this->buildNotice(json_decode($notice['message'], true));
74
-        });
75
-        return apply_filters('site-reviews/notices', $notices);
76
-    }
64
+	/**
65
+	 * @return string
66
+	 */
67
+	public function get()
68
+	{
69
+		$notices = array_map('unserialize',
70
+			array_unique(array_map('serialize', get_settings_errors(Application::ID)))
71
+		);
72
+		$notices = array_reduce($notices, function ($carry, $notice) {
73
+			return $carry.$this->buildNotice(json_decode($notice['message'], true));
74
+		});
75
+		return apply_filters('site-reviews/notices', $notices);
76
+	}
77 77
 
78
-    /**
79
-     * @return string
80
-     */
81
-    protected function buildNotice(array $args)
82
-    {
83
-        $messages = array_reduce($args['messages'], function ($carry, $message) {
84
-            return $carry.glsr(Builder::class)->p($message);
85
-        });
86
-        $class = 'notice notice-'.$args['type'];
87
-        if ($args['inline']) {
88
-            $class.= ' inline';
89
-        }
90
-        if ($args['dismissible']) {
91
-            $class.= ' is-dismissible';
92
-        }
93
-        return glsr(Builder::class)->div($messages, [
94
-            'class' => $class,
95
-        ]);
96
-    }
78
+	/**
79
+	 * @return string
80
+	 */
81
+	protected function buildNotice(array $args)
82
+	{
83
+		$messages = array_reduce($args['messages'], function ($carry, $message) {
84
+			return $carry.glsr(Builder::class)->p($message);
85
+		});
86
+		$class = 'notice notice-'.$args['type'];
87
+		if ($args['inline']) {
88
+			$class.= ' inline';
89
+		}
90
+		if ($args['dismissible']) {
91
+			$class.= ' is-dismissible';
92
+		}
93
+		return glsr(Builder::class)->div($messages, [
94
+			'class' => $class,
95
+		]);
96
+	}
97 97
 
98
-    /**
99
-     * @return array
100
-     */
101
-    protected function normalize(array $args)
102
-    {
103
-        $defaults = [
104
-            'dismissible' => true,
105
-            'inline' => true,
106
-            'message' => '',
107
-            'type' => '',
108
-        ];
109
-        $args = shortcode_atts($defaults, $args);
110
-        if (!in_array($args['type'], ['error', 'warning', 'success'])) {
111
-            $args['type'] = 'success';
112
-        }
113
-        $args['messages'] = is_wp_error($args['message'])
114
-            ? (array) $args['message']->get_error_message()
115
-            : (array) $args['message'];
116
-        unset($args['message']);
117
-        return $args;
118
-    }
98
+	/**
99
+	 * @return array
100
+	 */
101
+	protected function normalize(array $args)
102
+	{
103
+		$defaults = [
104
+			'dismissible' => true,
105
+			'inline' => true,
106
+			'message' => '',
107
+			'type' => '',
108
+		];
109
+		$args = shortcode_atts($defaults, $args);
110
+		if (!in_array($args['type'], ['error', 'warning', 'success'])) {
111
+			$args['type'] = 'success';
112
+		}
113
+		$args['messages'] = is_wp_error($args['message'])
114
+			? (array) $args['message']->get_error_message()
115
+			: (array) $args['message'];
116
+		unset($args['message']);
117
+		return $args;
118
+	}
119 119
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -13,41 +13,41 @@  discard block
 block discarded – undo
13 13
      * @param string|array|WP_Error $message
14 14
      * @return void
15 15
      */
16
-    public function add($type, $message, array $args = [])
16
+    public function add( $type, $message, array $args = [] )
17 17
     {
18
-        if (empty(array_filter([$message, $type]))) {
18
+        if( empty(array_filter( [$message, $type] )) ) {
19 19
             return;
20 20
         }
21 21
         $args['message'] = $message;
22 22
         $args['type'] = $type;
23
-        add_settings_error(Application::ID, '', json_encode($this->normalize($args)));
23
+        add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ) ) );
24 24
     }
25 25
 
26 26
     /**
27 27
      * @param string|array|WP_Error $message
28 28
      * @return void
29 29
      */
30
-    public function addError($message, array $args = [])
30
+    public function addError( $message, array $args = [] )
31 31
     {
32
-        $this->add('error', $message, $args);
32
+        $this->add( 'error', $message, $args );
33 33
     }
34 34
 
35 35
     /**
36 36
      * @param string|array|WP_Error $message
37 37
      * @return void
38 38
      */
39
-    public function addSuccess($message, array $args = [])
39
+    public function addSuccess( $message, array $args = [] )
40 40
     {
41
-        $this->add('success', $message, $args);
41
+        $this->add( 'success', $message, $args );
42 42
     }
43 43
 
44 44
     /**
45 45
      * @param string|array|WP_Error $message
46 46
      * @return void
47 47
      */
48
-    public function addWarning($message, array $args = [])
48
+    public function addWarning( $message, array $args = [] )
49 49
     {
50
-        $this->add('warning', $message, $args);
50
+        $this->add( 'warning', $message, $args );
51 51
     }
52 52
 
53 53
     /**
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     {
58 58
         global $wp_settings_errors;
59 59
         $wp_settings_errors = [];
60
-        delete_transient('settings_errors');
60
+        delete_transient( 'settings_errors' );
61 61
         return $this;
62 62
     }
63 63
 
@@ -66,39 +66,39 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function get()
68 68
     {
69
-        $notices = array_map('unserialize',
70
-            array_unique(array_map('serialize', get_settings_errors(Application::ID)))
69
+        $notices = array_map( 'unserialize',
70
+            array_unique( array_map( 'serialize', get_settings_errors( Application::ID ) ) )
71 71
         );
72
-        $notices = array_reduce($notices, function ($carry, $notice) {
73
-            return $carry.$this->buildNotice(json_decode($notice['message'], true));
72
+        $notices = array_reduce( $notices, function( $carry, $notice ) {
73
+            return $carry.$this->buildNotice( json_decode( $notice['message'], true ) );
74 74
         });
75
-        return apply_filters('site-reviews/notices', $notices);
75
+        return apply_filters( 'site-reviews/notices', $notices );
76 76
     }
77 77
 
78 78
     /**
79 79
      * @return string
80 80
      */
81
-    protected function buildNotice(array $args)
81
+    protected function buildNotice( array $args )
82 82
     {
83
-        $messages = array_reduce($args['messages'], function ($carry, $message) {
84
-            return $carry.glsr(Builder::class)->p($message);
83
+        $messages = array_reduce( $args['messages'], function( $carry, $message ) {
84
+            return $carry.glsr( Builder::class )->p( $message );
85 85
         });
86 86
         $class = 'notice notice-'.$args['type'];
87
-        if ($args['inline']) {
88
-            $class.= ' inline';
87
+        if( $args['inline'] ) {
88
+            $class .= ' inline';
89 89
         }
90
-        if ($args['dismissible']) {
91
-            $class.= ' is-dismissible';
90
+        if( $args['dismissible'] ) {
91
+            $class .= ' is-dismissible';
92 92
         }
93
-        return glsr(Builder::class)->div($messages, [
93
+        return glsr( Builder::class )->div( $messages, [
94 94
             'class' => $class,
95
-        ]);
95
+        ] );
96 96
     }
97 97
 
98 98
     /**
99 99
      * @return array
100 100
      */
101
-    protected function normalize(array $args)
101
+    protected function normalize( array $args )
102 102
     {
103 103
         $defaults = [
104 104
             'dismissible' => true,
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
             'message' => '',
107 107
             'type' => '',
108 108
         ];
109
-        $args = shortcode_atts($defaults, $args);
110
-        if (!in_array($args['type'], ['error', 'warning', 'success'])) {
109
+        $args = shortcode_atts( $defaults, $args );
110
+        if( !in_array( $args['type'], ['error', 'warning', 'success'] ) ) {
111 111
             $args['type'] = 'success';
112 112
         }
113
-        $args['messages'] = is_wp_error($args['message'])
114
-            ? (array) $args['message']->get_error_message()
115
-            : (array) $args['message'];
113
+        $args['messages'] = is_wp_error( $args['message'] )
114
+            ? (array)$args['message']->get_error_message()
115
+            : (array)$args['message'];
116 116
         unset($args['message']);
117 117
         return $args;
118 118
     }
Please login to merge, or discard this patch.
plugin/Modules/Html/Fields/Password.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,13 +4,13 @@
 block discarded – undo
4 4
 
5 5
 class Password extends Field
6 6
 {
7
-    /**
8
-     * @return array
9
-     */
10
-    public static function defaults()
11
-    {
12
-        return [
13
-            'class' => 'regular-text',
14
-        ];
15
-    }
7
+	/**
8
+	 * @return array
9
+	 */
10
+	public static function defaults()
11
+	{
12
+		return [
13
+			'class' => 'regular-text',
14
+		];
15
+	}
16 16
 }
Please login to merge, or discard this patch.