Test Failed
Push — tmp ( 15f615...89cc97 )
by Paul
10:31 queued 04:40
created
plugin/Controllers/ListTableColumns/ColumnValueAssignedTo.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -10,32 +10,32 @@
 block discarded – undo
10 10
 
11 11
 class ColumnValueAssignedTo implements ColumnValue
12 12
 {
13
-    /**
14
-     * @return array
15
-     */
16
-    public function assignedLinks(array $postIds)
17
-    {
18
-        $links = [];
19
-        $usedIds = [];
20
-        foreach ($postIds as $postId) {
21
-            $post = get_post(glsr(Multilingual::class)->getPostId($postId));
22
-            if (!empty($post->ID) && !in_array($post->ID, $usedIds)) {
23
-                $links[] = glsr(Builder::class)->a([
24
-                    'href' => get_the_permalink($post->ID),
25
-                    'text' => get_the_title($post->ID),
26
-                ]);
27
-                $usedIds[] = $post->ID;
28
-                $usedIds = Arr::unique($usedIds);
29
-            }
30
-        }
31
-        return $links;
32
-    }
13
+	/**
14
+	 * @return array
15
+	 */
16
+	public function assignedLinks(array $postIds)
17
+	{
18
+		$links = [];
19
+		$usedIds = [];
20
+		foreach ($postIds as $postId) {
21
+			$post = get_post(glsr(Multilingual::class)->getPostId($postId));
22
+			if (!empty($post->ID) && !in_array($post->ID, $usedIds)) {
23
+				$links[] = glsr(Builder::class)->a([
24
+					'href' => get_the_permalink($post->ID),
25
+					'text' => get_the_title($post->ID),
26
+				]);
27
+				$usedIds[] = $post->ID;
28
+				$usedIds = Arr::unique($usedIds);
29
+			}
30
+		}
31
+		return $links;
32
+	}
33 33
 
34
-    /**
35
-     * {@inheritdoc}
36
-     */
37
-    public function handle(Review $review)
38
-    {
39
-        return Str::naturalJoin($this->assignedLinks($review->assigned_post_ids));
40
-    }
34
+	/**
35
+	 * {@inheritdoc}
36
+	 */
37
+	public function handle(Review $review)
38
+	{
39
+		return Str::naturalJoin($this->assignedLinks($review->assigned_post_ids));
40
+	}
41 41
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@  discard block
 block discarded – undo
13 13
     /**
14 14
      * @return array
15 15
      */
16
-    public function assignedLinks(array $postIds)
16
+    public function assignedLinks( array $postIds )
17 17
     {
18 18
         $links = [];
19 19
         $usedIds = [];
20
-        foreach ($postIds as $postId) {
21
-            $post = get_post(glsr(Multilingual::class)->getPostId($postId));
22
-            if (!empty($post->ID) && !in_array($post->ID, $usedIds)) {
23
-                $links[] = glsr(Builder::class)->a([
24
-                    'href' => get_the_permalink($post->ID),
25
-                    'text' => get_the_title($post->ID),
26
-                ]);
20
+        foreach( $postIds as $postId ) {
21
+            $post = get_post( glsr( Multilingual::class )->getPostId( $postId ) );
22
+            if( !empty($post->ID) && !in_array( $post->ID, $usedIds ) ) {
23
+                $links[] = glsr( Builder::class )->a( [
24
+                    'href' => get_the_permalink( $post->ID ),
25
+                    'text' => get_the_title( $post->ID ),
26
+                ] );
27 27
                 $usedIds[] = $post->ID;
28
-                $usedIds = Arr::unique($usedIds);
28
+                $usedIds = Arr::unique( $usedIds );
29 29
             }
30 30
         }
31 31
         return $links;
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
     /**
35 35
      * {@inheritdoc}
36 36
      */
37
-    public function handle(Review $review)
37
+    public function handle( Review $review )
38 38
     {
39
-        return Str::naturalJoin($this->assignedLinks($review->assigned_post_ids));
39
+        return Str::naturalJoin( $this->assignedLinks( $review->assigned_post_ids ) );
40 40
     }
41 41
 }
Please login to merge, or discard this patch.
plugin/Controllers/ListTableColumns/ColumnValue.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@
 block discarded – undo
6 6
 
7 7
 interface ColumnValue
8 8
 {
9
-    /**
10
-     * @return string|void
11
-     */
12
-    public function handle(Review $review);
9
+	/**
10
+	 * @return string|void
11
+	 */
12
+	public function handle(Review $review);
13 13
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,5 +9,5 @@
 block discarded – undo
9 9
     /**
10 10
      * @return string|void
11 11
      */
12
-    public function handle(Review $review);
12
+    public function handle( Review $review );
13 13
 }
Please login to merge, or discard this patch.
plugin/Controllers/ListTableColumns/ColumnValueIpAddress.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@
 block discarded – undo
6 6
 
7 7
 class ColumnValueIpAddress implements ColumnValue
8 8
 {
9
-    /**
10
-     * {@inheritdoc}
11
-     */
12
-    public function handle(Review $review)
13
-    {
14
-        return $review->ip_address;
15
-    }
9
+	/**
10
+	 * {@inheritdoc}
11
+	 */
12
+	public function handle(Review $review)
13
+	{
14
+		return $review->ip_address;
15
+	}
16 16
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
     /**
10 10
      * {@inheritdoc}
11 11
      */
12
-    public function handle(Review $review)
12
+    public function handle( Review $review )
13 13
     {
14 14
         return $review->ip_address;
15 15
     }
Please login to merge, or discard this patch.
plugin/Controllers/ListTableColumns/ColumnValueReviewType.php 2 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@
 block discarded – undo
6 6
 
7 7
 class ColumnValueReviewType implements ColumnValue
8 8
 {
9
-    /**
10
-     * {@inheritdoc}
11
-     */
12
-    public function handle(Review $review)
13
-    {
14
-        return array_key_exists($review->type, glsr()->reviewTypes)
15
-            ? glsr()->reviewTypes[$review->type]
16
-            : _x('Unsupported Type', 'admin-text', 'site-reviews');
17
-    }
9
+	/**
10
+	 * {@inheritdoc}
11
+	 */
12
+	public function handle(Review $review)
13
+	{
14
+		return array_key_exists($review->type, glsr()->reviewTypes)
15
+			? glsr()->reviewTypes[$review->type]
16
+			: _x('Unsupported Type', 'admin-text', 'site-reviews');
17
+	}
18 18
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@
 block discarded – undo
9 9
     /**
10 10
      * {@inheritdoc}
11 11
      */
12
-    public function handle(Review $review)
12
+    public function handle( Review $review )
13 13
     {
14
-        return array_key_exists($review->type, glsr()->reviewTypes)
14
+        return array_key_exists( $review->type, glsr()->reviewTypes )
15 15
             ? glsr()->reviewTypes[$review->type]
16
-            : _x('Unsupported Type', 'admin-text', 'site-reviews');
16
+            : _x( 'Unsupported Type', 'admin-text', 'site-reviews' );
17 17
     }
18 18
 }
Please login to merge, or discard this patch.
plugin/Controllers/ListTableColumns/ColumnValueEmail.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@
 block discarded – undo
6 6
 
7 7
 class ColumnValueEmail implements ColumnValue
8 8
 {
9
-    /**
10
-     * {@inheritdoc}
11
-     */
12
-    public function handle(Review $review)
13
-    {
14
-        return $review->email;
15
-    }
9
+	/**
10
+	 * {@inheritdoc}
11
+	 */
12
+	public function handle(Review $review)
13
+	{
14
+		return $review->email;
15
+	}
16 16
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
     /**
10 10
      * {@inheritdoc}
11 11
      */
12
-    public function handle(Review $review)
12
+    public function handle( Review $review )
13 13
     {
14 14
         return $review->email;
15 15
     }
Please login to merge, or discard this patch.
plugin/Controllers/ListTableColumns/ColumnValueRating.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@
 block discarded – undo
6 6
 
7 7
 class ColumnValueRating implements ColumnValue
8 8
 {
9
-    /**
10
-     * {@inheritdoc}
11
-     */
12
-    public function handle(Review $review)
13
-    {
14
-        return glsr_star_rating($review->rating);
15
-    }
9
+	/**
10
+	 * {@inheritdoc}
11
+	 */
12
+	public function handle(Review $review)
13
+	{
14
+		return glsr_star_rating($review->rating);
15
+	}
16 16
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@
 block discarded – undo
9 9
     /**
10 10
      * {@inheritdoc}
11 11
      */
12
-    public function handle(Review $review)
12
+    public function handle( Review $review )
13 13
     {
14
-        return glsr_star_rating($review->rating);
14
+        return glsr_star_rating( $review->rating );
15 15
     }
16 16
 }
Please login to merge, or discard this patch.
plugin/Controllers/ListTableColumns/ColumnValueReviewer.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,17 +8,17 @@
 block discarded – undo
8 8
 
9 9
 class ColumnValueReviewer implements ColumnValue
10 10
 {
11
-    /**
12
-     * {@inheritdoc}
13
-     */
14
-    public function handle(Review $review)
15
-    {
16
-        if ($userId = (int) $review->author_id) {
17
-            return glsr(Builder::class)->a([
18
-                'href' => get_author_posts_url($userId),
19
-                'text' => Helper::ifEmpty($review->author, __('Unknown', 'admin-text', 'site-reviews')),
20
-            ]);
21
-        }
22
-        return $review->author;
23
-    }
11
+	/**
12
+	 * {@inheritdoc}
13
+	 */
14
+	public function handle(Review $review)
15
+	{
16
+		if ($userId = (int) $review->author_id) {
17
+			return glsr(Builder::class)->a([
18
+				'href' => get_author_posts_url($userId),
19
+				'text' => Helper::ifEmpty($review->author, __('Unknown', 'admin-text', 'site-reviews')),
20
+			]);
21
+		}
22
+		return $review->author;
23
+	}
24 24
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,13 +11,13 @@
 block discarded – undo
11 11
     /**
12 12
      * {@inheritdoc}
13 13
      */
14
-    public function handle(Review $review)
14
+    public function handle( Review $review )
15 15
     {
16
-        if ($userId = (int) $review->author_id) {
17
-            return glsr(Builder::class)->a([
18
-                'href' => get_author_posts_url($userId),
19
-                'text' => Helper::ifEmpty($review->author, __('Unknown', 'admin-text', 'site-reviews')),
20
-            ]);
16
+        if( $userId = (int)$review->author_id ) {
17
+            return glsr( Builder::class )->a( [
18
+                'href' => get_author_posts_url( $userId ),
19
+                'text' => Helper::ifEmpty( $review->author, __( 'Unknown', 'admin-text', 'site-reviews' ) ),
20
+            ] );
21 21
         }
22 22
         return $review->author;
23 23
     }
Please login to merge, or discard this patch.
plugin/Controllers/EditorController.php 2 patches
Indentation   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -19,315 +19,315 @@
 block discarded – undo
19 19
 
20 20
 class EditorController extends Controller
21 21
 {
22
-    /**
23
-     * @param array $settings
24
-     * @return array
25
-     * @filter wp_editor_settings
26
-     */
27
-    public function filterEditorSettings($settings)
28
-    {
29
-        return glsr(Customization::class)->filterEditorSettings(
30
-            Arr::consolidate($settings)
31
-        );
32
-    }
22
+	/**
23
+	 * @param array $settings
24
+	 * @return array
25
+	 * @filter wp_editor_settings
26
+	 */
27
+	public function filterEditorSettings($settings)
28
+	{
29
+		return glsr(Customization::class)->filterEditorSettings(
30
+			Arr::consolidate($settings)
31
+		);
32
+	}
33 33
 
34
-    /**
35
-     * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script.
36
-     * @param string $html
37
-     * @return string
38
-     * @filter the_editor
39
-     */
40
-    public function filterEditorTextarea($html)
41
-    {
42
-        return glsr(Customization::class)->filterEditorTextarea($html);
43
-    }
34
+	/**
35
+	 * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script.
36
+	 * @param string $html
37
+	 * @return string
38
+	 * @filter the_editor
39
+	 */
40
+	public function filterEditorTextarea($html)
41
+	{
42
+		return glsr(Customization::class)->filterEditorTextarea($html);
43
+	}
44 44
 
45
-    /**
46
-     * @param bool $protected
47
-     * @param string $metaKey
48
-     * @param string $metaType
49
-     * @return bool
50
-     * @filter is_protected_meta
51
-     */
52
-    public function filterIsProtectedMeta($protected, $metaKey, $metaType)
53
-    {
54
-        if ('post' == $metaType && glsr()->post_type == get_post_type()) {
55
-            $values = glsr(CreateReviewDefaults::class)->unguarded();
56
-            $values = Arr::prefixKeys($values);
57
-            if (array_key_exists($metaKey, $values)) {
58
-                $protected = false;
59
-            }
60
-        }
61
-        return $protected;
62
-    }
45
+	/**
46
+	 * @param bool $protected
47
+	 * @param string $metaKey
48
+	 * @param string $metaType
49
+	 * @return bool
50
+	 * @filter is_protected_meta
51
+	 */
52
+	public function filterIsProtectedMeta($protected, $metaKey, $metaType)
53
+	{
54
+		if ('post' == $metaType && glsr()->post_type == get_post_type()) {
55
+			$values = glsr(CreateReviewDefaults::class)->unguarded();
56
+			$values = Arr::prefixKeys($values);
57
+			if (array_key_exists($metaKey, $values)) {
58
+				$protected = false;
59
+			}
60
+		}
61
+		return $protected;
62
+	}
63 63
 
64
-    /**
65
-     * @param array $messages
66
-     * @return array
67
-     * @filter post_updated_messages
68
-     */
69
-    public function filterUpdateMessages($messages)
70
-    {
71
-        return glsr(Labels::class)->filterUpdateMessages(
72
-            Arr::consolidate($messages)
73
-        );
74
-    }
64
+	/**
65
+	 * @param array $messages
66
+	 * @return array
67
+	 * @filter post_updated_messages
68
+	 */
69
+	public function filterUpdateMessages($messages)
70
+	{
71
+		return glsr(Labels::class)->filterUpdateMessages(
72
+			Arr::consolidate($messages)
73
+		);
74
+	}
75 75
 
76
-    /**
77
-     * @return void
78
-     * @action add_meta_boxes_{Application::POST_TYPE}
79
-     */
80
-    public function registerMetaBoxes($post)
81
-    {
82
-        add_meta_box(Application::ID.'_assigned_to', _x('Assigned To', 'admin-text', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side');
83
-        add_meta_box(Application::ID.'_review', _x('Details', 'admin-text', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side');
84
-        if ('local' === glsr(Query::class)->review($post->ID)->type) {
85
-            add_meta_box(Application::ID.'_response', _x('Respond Publicly', 'admin-text', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal');
86
-        }
87
-    }
76
+	/**
77
+	 * @return void
78
+	 * @action add_meta_boxes_{Application::POST_TYPE}
79
+	 */
80
+	public function registerMetaBoxes($post)
81
+	{
82
+		add_meta_box(Application::ID.'_assigned_to', _x('Assigned To', 'admin-text', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side');
83
+		add_meta_box(Application::ID.'_review', _x('Details', 'admin-text', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side');
84
+		if ('local' === glsr(Query::class)->review($post->ID)->type) {
85
+			add_meta_box(Application::ID.'_response', _x('Respond Publicly', 'admin-text', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal');
86
+		}
87
+	}
88 88
 
89
-    /**
90
-     * @return void
91
-     * @action admin_print_scripts
92
-     */
93
-    public function removeAutosave()
94
-    {
95
-        glsr(Customization::class)->removeAutosave();
96
-    }
89
+	/**
90
+	 * @return void
91
+	 * @action admin_print_scripts
92
+	 */
93
+	public function removeAutosave()
94
+	{
95
+		glsr(Customization::class)->removeAutosave();
96
+	}
97 97
 
98
-    /**
99
-     * @return void
100
-     * @action admin_menu
101
-     */
102
-    public function removeMetaBoxes()
103
-    {
104
-        glsr(Customization::class)->removeMetaBoxes();
105
-    }
98
+	/**
99
+	 * @return void
100
+	 * @action admin_menu
101
+	 */
102
+	public function removeMetaBoxes()
103
+	{
104
+		glsr(Customization::class)->removeMetaBoxes();
105
+	}
106 106
 
107
-    /**
108
-     * @return void
109
-     */
110
-    public function removePostTypeSupport()
111
-    {
112
-        glsr(Customization::class)->removePostTypeSupport();
113
-    }
107
+	/**
108
+	 * @return void
109
+	 */
110
+	public function removePostTypeSupport()
111
+	{
112
+		glsr(Customization::class)->removePostTypeSupport();
113
+	}
114 114
 
115
-    /**
116
-     * @param WP_Post $post
117
-     * @return void
118
-     * @callback add_meta_box
119
-     */
120
-    public function renderAssignedToMetabox($post)
121
-    {
122
-        if (Review::isReview($post)) {
123
-            $review = glsr(Query::class)->review($post->ID);
124
-            wp_nonce_field('assigned_to', '_nonce-assigned-to', false);
125
-            $templates = array_reduce($review->assigned_post_ids, function ($carry, $postId) {
126
-                return $carry.glsr(Template::class)->build('partials/editor/assigned-post', [
127
-                    'context' => [
128
-                        'data.id' => $postId,
129
-                        'data.url' => (string) get_permalink($postId),
130
-                        'data.title' => get_the_title($postId),
131
-                    ],
132
-                ]);
133
-            });
134
-            glsr()->render('partials/editor/metabox-assigned-to', [
135
-                'templates' => $templates,
136
-            ]);
137
-        }
138
-    }
115
+	/**
116
+	 * @param WP_Post $post
117
+	 * @return void
118
+	 * @callback add_meta_box
119
+	 */
120
+	public function renderAssignedToMetabox($post)
121
+	{
122
+		if (Review::isReview($post)) {
123
+			$review = glsr(Query::class)->review($post->ID);
124
+			wp_nonce_field('assigned_to', '_nonce-assigned-to', false);
125
+			$templates = array_reduce($review->assigned_post_ids, function ($carry, $postId) {
126
+				return $carry.glsr(Template::class)->build('partials/editor/assigned-post', [
127
+					'context' => [
128
+						'data.id' => $postId,
129
+						'data.url' => (string) get_permalink($postId),
130
+						'data.title' => get_the_title($postId),
131
+					],
132
+				]);
133
+			});
134
+			glsr()->render('partials/editor/metabox-assigned-to', [
135
+				'templates' => $templates,
136
+			]);
137
+		}
138
+	}
139 139
 
140
-    /**
141
-     * @param WP_Post $post
142
-     * @return void
143
-     * @callback add_meta_box
144
-     */
145
-    public function renderDetailsMetaBox($post)
146
-    {
147
-        if (Review::isReview($post)) {
148
-            $review = glsr(Query::class)->review($post);
149
-            glsr()->render('partials/editor/metabox-details', [
150
-                'metabox' => $this->normalizeDetailsMetaBox($review),
151
-            ]);
152
-        }
153
-    }
140
+	/**
141
+	 * @param WP_Post $post
142
+	 * @return void
143
+	 * @callback add_meta_box
144
+	 */
145
+	public function renderDetailsMetaBox($post)
146
+	{
147
+		if (Review::isReview($post)) {
148
+			$review = glsr(Query::class)->review($post);
149
+			glsr()->render('partials/editor/metabox-details', [
150
+				'metabox' => $this->normalizeDetailsMetaBox($review),
151
+			]);
152
+		}
153
+	}
154 154
 
155
-    /**
156
-     * @return void
157
-     * @action post_submitbox_misc_actions
158
-     */
159
-    public function renderPinnedInPublishMetaBox()
160
-    {
161
-        $review = glsr(Query::class)->review(get_post()->ID);
162
-        if ($review->isValid() && glsr()->can('edit_others_posts')) {
163
-            glsr(Template::class)->render('partials/editor/pinned', [
164
-                'context' => [
165
-                    'no' => _x('No', 'admin-text', 'site-reviews'),
166
-                    'yes' => _x('Yes', 'admin-text', 'site-reviews'),
167
-                ],
168
-                'pinned' => $review->is_pinned,
169
-            ]);
170
-        }
171
-    }
155
+	/**
156
+	 * @return void
157
+	 * @action post_submitbox_misc_actions
158
+	 */
159
+	public function renderPinnedInPublishMetaBox()
160
+	{
161
+		$review = glsr(Query::class)->review(get_post()->ID);
162
+		if ($review->isValid() && glsr()->can('edit_others_posts')) {
163
+			glsr(Template::class)->render('partials/editor/pinned', [
164
+				'context' => [
165
+					'no' => _x('No', 'admin-text', 'site-reviews'),
166
+					'yes' => _x('Yes', 'admin-text', 'site-reviews'),
167
+				],
168
+				'pinned' => $review->is_pinned,
169
+			]);
170
+		}
171
+	}
172 172
 
173
-    /**
174
-     * @param WP_Post $post
175
-     * @return void
176
-     * @callback add_meta_box
177
-     */
178
-    public function renderResponseMetaBox($post)
179
-    {
180
-        if (Review::isReview($post)) {
181
-            wp_nonce_field('response', '_nonce-response', false);
182
-            glsr()->render('partials/editor/metabox-response', [
183
-                'response' => glsr(Database::class)->meta($post->ID, 'response'),
184
-            ]);
185
-        }
186
-    }
173
+	/**
174
+	 * @param WP_Post $post
175
+	 * @return void
176
+	 * @callback add_meta_box
177
+	 */
178
+	public function renderResponseMetaBox($post)
179
+	{
180
+		if (Review::isReview($post)) {
181
+			wp_nonce_field('response', '_nonce-response', false);
182
+			glsr()->render('partials/editor/metabox-response', [
183
+				'response' => glsr(Database::class)->meta($post->ID, 'response'),
184
+			]);
185
+		}
186
+	}
187 187
 
188
-    /**
189
-     * @param WP_Post $post
190
-     * @return void
191
-     * @action edit_form_after_title
192
-     */
193
-    public function renderReviewEditor($post)
194
-    {
195
-        if (Review::isReview($post) && !Review::isEditable($post)) {
196
-            glsr()->render('partials/editor/review', [
197
-                'post' => $post,
198
-                'response' => glsr(Database::class)->meta($post->ID, 'response'),
199
-            ]);
200
-        }
201
-    }
188
+	/**
189
+	 * @param WP_Post $post
190
+	 * @return void
191
+	 * @action edit_form_after_title
192
+	 */
193
+	public function renderReviewEditor($post)
194
+	{
195
+		if (Review::isReview($post) && !Review::isEditable($post)) {
196
+			glsr()->render('partials/editor/review', [
197
+				'post' => $post,
198
+				'response' => glsr(Database::class)->meta($post->ID, 'response'),
199
+			]);
200
+		}
201
+	}
202 202
 
203
-    /**
204
-     * @return void
205
-     * @action admin_head
206
-     */
207
-    public function renderReviewFields()
208
-    {
209
-        $screen = glsr_current_screen();
210
-        if ('post' === $screen->base && glsr()->post_type === $screen->post_type) {
211
-            add_action('edit_form_after_title', [$this, 'renderReviewEditor']);
212
-            add_action('edit_form_top', [$this, 'renderReviewNotice']);
213
-        }
214
-    }
203
+	/**
204
+	 * @return void
205
+	 * @action admin_head
206
+	 */
207
+	public function renderReviewFields()
208
+	{
209
+		$screen = glsr_current_screen();
210
+		if ('post' === $screen->base && glsr()->post_type === $screen->post_type) {
211
+			add_action('edit_form_after_title', [$this, 'renderReviewEditor']);
212
+			add_action('edit_form_top', [$this, 'renderReviewNotice']);
213
+		}
214
+	}
215 215
 
216
-    /**
217
-     * @param WP_Post $post
218
-     * @return void
219
-     * @action edit_form_top
220
-     */
221
-    public function renderReviewNotice($post)
222
-    {
223
-        if (Review::isReview($post) && !Review::isEditable($post)) {
224
-            glsr(Notice::class)->addWarning(sprintf(
225
-                _x('%s reviews are read-only.', 'admin-text', 'site-reviews'),
226
-                glsr(ColumnValueReviewType::class)->handle(glsr(Query::class)->review($post->ID))
227
-            ));
228
-            glsr(Template::class)->render('partials/editor/notice', [
229
-                'context' => [
230
-                    'notices' => glsr(Notice::class)->get(),
231
-                ],
232
-            ]);
233
-        }
234
-    }
216
+	/**
217
+	 * @param WP_Post $post
218
+	 * @return void
219
+	 * @action edit_form_top
220
+	 */
221
+	public function renderReviewNotice($post)
222
+	{
223
+		if (Review::isReview($post) && !Review::isEditable($post)) {
224
+			glsr(Notice::class)->addWarning(sprintf(
225
+				_x('%s reviews are read-only.', 'admin-text', 'site-reviews'),
226
+				glsr(ColumnValueReviewType::class)->handle(glsr(Query::class)->review($post->ID))
227
+			));
228
+			glsr(Template::class)->render('partials/editor/notice', [
229
+				'context' => [
230
+					'notices' => glsr(Notice::class)->get(),
231
+				],
232
+			]);
233
+		}
234
+	}
235 235
 
236
-    /**
237
-     * @param WP_Post $post
238
-     * @return void
239
-     * @see glsr_categories_meta_box()
240
-     * @callback register_taxonomy
241
-     */
242
-    public function renderTaxonomyMetabox($post)
243
-    {
244
-        if (Review::isReview($post)) {
245
-            glsr()->render('partials/editor/metabox-categories', [
246
-                'post' => $post,
247
-                'tax_name' => glsr()->taxonomy,
248
-                'taxonomy' => get_taxonomy(glsr()->taxonomy),
249
-            ]);
250
-        }
251
-    }
236
+	/**
237
+	 * @param WP_Post $post
238
+	 * @return void
239
+	 * @see glsr_categories_meta_box()
240
+	 * @callback register_taxonomy
241
+	 */
242
+	public function renderTaxonomyMetabox($post)
243
+	{
244
+		if (Review::isReview($post)) {
245
+			glsr()->render('partials/editor/metabox-categories', [
246
+				'post' => $post,
247
+				'tax_name' => glsr()->taxonomy,
248
+				'taxonomy' => get_taxonomy(glsr()->taxonomy),
249
+			]);
250
+		}
251
+	}
252 252
 
253
-    /**
254
-     * @param int $postId
255
-     * @param \WP_Post $post
256
-     * @param bool $isUpdate
257
-     * @return void
258
-     * @action save_post_.Application::POST_TYPE
259
-     */
260
-    public function saveMetaboxes($postId, $post, $isUpdating)
261
-    {
262
-        glsr(Metaboxes::class)->saveAssignedToMetabox($postId);
263
-        glsr(Metaboxes::class)->saveResponseMetabox($postId);
264
-        if ($isUpdating) {
265
-            glsr()->action('review/saved', glsr(Query::class)->review($postId));
266
-        }
267
-    }
253
+	/**
254
+	 * @param int $postId
255
+	 * @param \WP_Post $post
256
+	 * @param bool $isUpdate
257
+	 * @return void
258
+	 * @action save_post_.Application::POST_TYPE
259
+	 */
260
+	public function saveMetaboxes($postId, $post, $isUpdating)
261
+	{
262
+		glsr(Metaboxes::class)->saveAssignedToMetabox($postId);
263
+		glsr(Metaboxes::class)->saveResponseMetabox($postId);
264
+		if ($isUpdating) {
265
+			glsr()->action('review/saved', glsr(Query::class)->review($postId));
266
+		}
267
+	}
268 268
 
269
-    /**
270
-     * @return string|void
271
-     */
272
-    protected function getReviewType(Review $review)
273
-    {
274
-        if (count(glsr()->reviewTypes) < 2) {
275
-            return;
276
-        }
277
-        $type = $review->type();
278
-        if (!empty($review->url)) {
279
-            return glsr(Builder::class)->a([
280
-                'href' => $review->url,
281
-                'target' => '_blank',
282
-                'text' => $type,
283
-            ]);
284
-        }
285
-        return $type;
286
-    }
269
+	/**
270
+	 * @return string|void
271
+	 */
272
+	protected function getReviewType(Review $review)
273
+	{
274
+		if (count(glsr()->reviewTypes) < 2) {
275
+			return;
276
+		}
277
+		$type = $review->type();
278
+		if (!empty($review->url)) {
279
+			return glsr(Builder::class)->a([
280
+				'href' => $review->url,
281
+				'target' => '_blank',
282
+				'text' => $type,
283
+			]);
284
+		}
285
+		return $type;
286
+	}
287 287
 
288
-    /**
289
-     * @return array
290
-     */
291
-    protected function normalizeDetailsMetaBox(Review $review)
292
-    {
293
-        $user = empty($review->author_id)
294
-            ? _x('Unregistered user', 'admin-text', 'site-reviews')
295
-            : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->author_id), [
296
-                'href' => get_author_posts_url($review->author_id),
297
-            ]);
298
-        $email = empty($review->email)
299
-            ? '&mdash;'
300
-            : glsr(Builder::class)->a($review->email, [
301
-                'href' => 'mailto:'.$review->email.'?subject='.esc_attr(_x('RE:', 'admin-text', 'site-reviews').' '.$review->title),
302
-            ]);
303
-        $metabox = [
304
-            _x('Rating', 'admin-text', 'site-reviews') => $review->rating(),
305
-            _x('Type', 'admin-text', 'site-reviews') => $this->getReviewType($review),
306
-            _x('Date', 'admin-text', 'site-reviews') => $review->date(),
307
-            _x('Name', 'admin-text', 'site-reviews') => $review->author,
308
-            _x('Email', 'admin-text', 'site-reviews') => $email,
309
-            _x('User', 'admin-text', 'site-reviews') => $user,
310
-            _x('IP Address', 'admin-text', 'site-reviews') => $review->ip_address,
311
-            _x('Avatar', 'admin-text', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar),
312
-        ];
313
-        return array_filter(glsr()->filterArray('metabox/details', $metabox, $review));
314
-    }
288
+	/**
289
+	 * @return array
290
+	 */
291
+	protected function normalizeDetailsMetaBox(Review $review)
292
+	{
293
+		$user = empty($review->author_id)
294
+			? _x('Unregistered user', 'admin-text', 'site-reviews')
295
+			: glsr(Builder::class)->a(get_the_author_meta('display_name', $review->author_id), [
296
+				'href' => get_author_posts_url($review->author_id),
297
+			]);
298
+		$email = empty($review->email)
299
+			? '&mdash;'
300
+			: glsr(Builder::class)->a($review->email, [
301
+				'href' => 'mailto:'.$review->email.'?subject='.esc_attr(_x('RE:', 'admin-text', 'site-reviews').' '.$review->title),
302
+			]);
303
+		$metabox = [
304
+			_x('Rating', 'admin-text', 'site-reviews') => $review->rating(),
305
+			_x('Type', 'admin-text', 'site-reviews') => $this->getReviewType($review),
306
+			_x('Date', 'admin-text', 'site-reviews') => $review->date(),
307
+			_x('Name', 'admin-text', 'site-reviews') => $review->author,
308
+			_x('Email', 'admin-text', 'site-reviews') => $email,
309
+			_x('User', 'admin-text', 'site-reviews') => $user,
310
+			_x('IP Address', 'admin-text', 'site-reviews') => $review->ip_address,
311
+			_x('Avatar', 'admin-text', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar),
312
+		];
313
+		return array_filter(glsr()->filterArray('metabox/details', $metabox, $review));
314
+	}
315 315
 
316
-    /**
317
-     * @param int $postId
318
-     * @param int $messageIndex
319
-     * @return void
320
-     */
321
-    protected function redirect($postId, $messageIndex)
322
-    {
323
-        $referer = wp_get_referer();
324
-        $hasReferer = !$referer
325
-            || Str::contains($referer, 'post.php')
326
-            || Str::contains($referer, 'post-new.php');
327
-        $redirectUri = $hasReferer
328
-            ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer)
329
-            : get_edit_post_link($postId);
330
-        wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri));
331
-        exit;
332
-    }
316
+	/**
317
+	 * @param int $postId
318
+	 * @param int $messageIndex
319
+	 * @return void
320
+	 */
321
+	protected function redirect($postId, $messageIndex)
322
+	{
323
+		$referer = wp_get_referer();
324
+		$hasReferer = !$referer
325
+			|| Str::contains($referer, 'post.php')
326
+			|| Str::contains($referer, 'post-new.php');
327
+		$redirectUri = $hasReferer
328
+			? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer)
329
+			: get_edit_post_link($postId);
330
+		wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri));
331
+		exit;
332
+	}
333 333
 }
Please login to merge, or discard this patch.
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
      * @return array
25 25
      * @filter wp_editor_settings
26 26
      */
27
-    public function filterEditorSettings($settings)
27
+    public function filterEditorSettings( $settings )
28 28
     {
29
-        return glsr(Customization::class)->filterEditorSettings(
30
-            Arr::consolidate($settings)
29
+        return glsr( Customization::class )->filterEditorSettings(
30
+            Arr::consolidate( $settings )
31 31
         );
32 32
     }
33 33
 
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
      * @return string
38 38
      * @filter the_editor
39 39
      */
40
-    public function filterEditorTextarea($html)
40
+    public function filterEditorTextarea( $html )
41 41
     {
42
-        return glsr(Customization::class)->filterEditorTextarea($html);
42
+        return glsr( Customization::class )->filterEditorTextarea( $html );
43 43
     }
44 44
 
45 45
     /**
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
      * @return bool
50 50
      * @filter is_protected_meta
51 51
      */
52
-    public function filterIsProtectedMeta($protected, $metaKey, $metaType)
52
+    public function filterIsProtectedMeta( $protected, $metaKey, $metaType )
53 53
     {
54
-        if ('post' == $metaType && glsr()->post_type == get_post_type()) {
55
-            $values = glsr(CreateReviewDefaults::class)->unguarded();
56
-            $values = Arr::prefixKeys($values);
57
-            if (array_key_exists($metaKey, $values)) {
54
+        if( 'post' == $metaType && glsr()->post_type == get_post_type() ) {
55
+            $values = glsr( CreateReviewDefaults::class )->unguarded();
56
+            $values = Arr::prefixKeys( $values );
57
+            if( array_key_exists( $metaKey, $values ) ) {
58 58
                 $protected = false;
59 59
             }
60 60
         }
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
      * @return array
67 67
      * @filter post_updated_messages
68 68
      */
69
-    public function filterUpdateMessages($messages)
69
+    public function filterUpdateMessages( $messages )
70 70
     {
71
-        return glsr(Labels::class)->filterUpdateMessages(
72
-            Arr::consolidate($messages)
71
+        return glsr( Labels::class )->filterUpdateMessages(
72
+            Arr::consolidate( $messages )
73 73
         );
74 74
     }
75 75
 
@@ -77,12 +77,12 @@  discard block
 block discarded – undo
77 77
      * @return void
78 78
      * @action add_meta_boxes_{Application::POST_TYPE}
79 79
      */
80
-    public function registerMetaBoxes($post)
80
+    public function registerMetaBoxes( $post )
81 81
     {
82
-        add_meta_box(Application::ID.'_assigned_to', _x('Assigned To', 'admin-text', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side');
83
-        add_meta_box(Application::ID.'_review', _x('Details', 'admin-text', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side');
84
-        if ('local' === glsr(Query::class)->review($post->ID)->type) {
85
-            add_meta_box(Application::ID.'_response', _x('Respond Publicly', 'admin-text', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal');
82
+        add_meta_box( Application::ID.'_assigned_to', _x( 'Assigned To', 'admin-text', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' );
83
+        add_meta_box( Application::ID.'_review', _x( 'Details', 'admin-text', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' );
84
+        if( 'local' === glsr( Query::class )->review( $post->ID )->type ) {
85
+            add_meta_box( Application::ID.'_response', _x( 'Respond Publicly', 'admin-text', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' );
86 86
         }
87 87
     }
88 88
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function removeAutosave()
94 94
     {
95
-        glsr(Customization::class)->removeAutosave();
95
+        glsr( Customization::class )->removeAutosave();
96 96
     }
97 97
 
98 98
     /**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      */
102 102
     public function removeMetaBoxes()
103 103
     {
104
-        glsr(Customization::class)->removeMetaBoxes();
104
+        glsr( Customization::class )->removeMetaBoxes();
105 105
     }
106 106
 
107 107
     /**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function removePostTypeSupport()
111 111
     {
112
-        glsr(Customization::class)->removePostTypeSupport();
112
+        glsr( Customization::class )->removePostTypeSupport();
113 113
     }
114 114
 
115 115
     /**
@@ -117,23 +117,23 @@  discard block
 block discarded – undo
117 117
      * @return void
118 118
      * @callback add_meta_box
119 119
      */
120
-    public function renderAssignedToMetabox($post)
120
+    public function renderAssignedToMetabox( $post )
121 121
     {
122
-        if (Review::isReview($post)) {
123
-            $review = glsr(Query::class)->review($post->ID);
124
-            wp_nonce_field('assigned_to', '_nonce-assigned-to', false);
125
-            $templates = array_reduce($review->assigned_post_ids, function ($carry, $postId) {
126
-                return $carry.glsr(Template::class)->build('partials/editor/assigned-post', [
122
+        if( Review::isReview( $post ) ) {
123
+            $review = glsr( Query::class )->review( $post->ID );
124
+            wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false );
125
+            $templates = array_reduce( $review->assigned_post_ids, function( $carry, $postId ) {
126
+                return $carry.glsr( Template::class )->build( 'partials/editor/assigned-post', [
127 127
                     'context' => [
128 128
                         'data.id' => $postId,
129
-                        'data.url' => (string) get_permalink($postId),
130
-                        'data.title' => get_the_title($postId),
129
+                        'data.url' => (string)get_permalink( $postId ),
130
+                        'data.title' => get_the_title( $postId ),
131 131
                     ],
132
-                ]);
132
+                ] );
133 133
             });
134
-            glsr()->render('partials/editor/metabox-assigned-to', [
134
+            glsr()->render( 'partials/editor/metabox-assigned-to', [
135 135
                 'templates' => $templates,
136
-            ]);
136
+            ] );
137 137
         }
138 138
     }
139 139
 
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
      * @return void
143 143
      * @callback add_meta_box
144 144
      */
145
-    public function renderDetailsMetaBox($post)
145
+    public function renderDetailsMetaBox( $post )
146 146
     {
147
-        if (Review::isReview($post)) {
148
-            $review = glsr(Query::class)->review($post);
149
-            glsr()->render('partials/editor/metabox-details', [
150
-                'metabox' => $this->normalizeDetailsMetaBox($review),
151
-            ]);
147
+        if( Review::isReview( $post ) ) {
148
+            $review = glsr( Query::class )->review( $post );
149
+            glsr()->render( 'partials/editor/metabox-details', [
150
+                'metabox' => $this->normalizeDetailsMetaBox( $review ),
151
+            ] );
152 152
         }
153 153
     }
154 154
 
@@ -158,15 +158,15 @@  discard block
 block discarded – undo
158 158
      */
159 159
     public function renderPinnedInPublishMetaBox()
160 160
     {
161
-        $review = glsr(Query::class)->review(get_post()->ID);
162
-        if ($review->isValid() && glsr()->can('edit_others_posts')) {
163
-            glsr(Template::class)->render('partials/editor/pinned', [
161
+        $review = glsr( Query::class )->review( get_post()->ID );
162
+        if( $review->isValid() && glsr()->can( 'edit_others_posts' ) ) {
163
+            glsr( Template::class )->render( 'partials/editor/pinned', [
164 164
                 'context' => [
165
-                    'no' => _x('No', 'admin-text', 'site-reviews'),
166
-                    'yes' => _x('Yes', 'admin-text', 'site-reviews'),
165
+                    'no' => _x( 'No', 'admin-text', 'site-reviews' ),
166
+                    'yes' => _x( 'Yes', 'admin-text', 'site-reviews' ),
167 167
                 ],
168 168
                 'pinned' => $review->is_pinned,
169
-            ]);
169
+            ] );
170 170
         }
171 171
     }
172 172
 
@@ -175,13 +175,13 @@  discard block
 block discarded – undo
175 175
      * @return void
176 176
      * @callback add_meta_box
177 177
      */
178
-    public function renderResponseMetaBox($post)
178
+    public function renderResponseMetaBox( $post )
179 179
     {
180
-        if (Review::isReview($post)) {
181
-            wp_nonce_field('response', '_nonce-response', false);
182
-            glsr()->render('partials/editor/metabox-response', [
183
-                'response' => glsr(Database::class)->meta($post->ID, 'response'),
184
-            ]);
180
+        if( Review::isReview( $post ) ) {
181
+            wp_nonce_field( 'response', '_nonce-response', false );
182
+            glsr()->render( 'partials/editor/metabox-response', [
183
+                'response' => glsr( Database::class )->meta( $post->ID, 'response' ),
184
+            ] );
185 185
         }
186 186
     }
187 187
 
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
      * @return void
191 191
      * @action edit_form_after_title
192 192
      */
193
-    public function renderReviewEditor($post)
193
+    public function renderReviewEditor( $post )
194 194
     {
195
-        if (Review::isReview($post) && !Review::isEditable($post)) {
196
-            glsr()->render('partials/editor/review', [
195
+        if( Review::isReview( $post ) && !Review::isEditable( $post ) ) {
196
+            glsr()->render( 'partials/editor/review', [
197 197
                 'post' => $post,
198
-                'response' => glsr(Database::class)->meta($post->ID, 'response'),
199
-            ]);
198
+                'response' => glsr( Database::class )->meta( $post->ID, 'response' ),
199
+            ] );
200 200
         }
201 201
     }
202 202
 
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
     public function renderReviewFields()
208 208
     {
209 209
         $screen = glsr_current_screen();
210
-        if ('post' === $screen->base && glsr()->post_type === $screen->post_type) {
211
-            add_action('edit_form_after_title', [$this, 'renderReviewEditor']);
212
-            add_action('edit_form_top', [$this, 'renderReviewNotice']);
210
+        if( 'post' === $screen->base && glsr()->post_type === $screen->post_type ) {
211
+            add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] );
212
+            add_action( 'edit_form_top', [$this, 'renderReviewNotice'] );
213 213
         }
214 214
     }
215 215
 
@@ -218,18 +218,18 @@  discard block
 block discarded – undo
218 218
      * @return void
219 219
      * @action edit_form_top
220 220
      */
221
-    public function renderReviewNotice($post)
221
+    public function renderReviewNotice( $post )
222 222
     {
223
-        if (Review::isReview($post) && !Review::isEditable($post)) {
224
-            glsr(Notice::class)->addWarning(sprintf(
225
-                _x('%s reviews are read-only.', 'admin-text', 'site-reviews'),
226
-                glsr(ColumnValueReviewType::class)->handle(glsr(Query::class)->review($post->ID))
227
-            ));
228
-            glsr(Template::class)->render('partials/editor/notice', [
223
+        if( Review::isReview( $post ) && !Review::isEditable( $post ) ) {
224
+            glsr( Notice::class )->addWarning( sprintf(
225
+                _x( '%s reviews are read-only.', 'admin-text', 'site-reviews' ),
226
+                glsr( ColumnValueReviewType::class )->handle( glsr( Query::class )->review( $post->ID ) )
227
+            ) );
228
+            glsr( Template::class )->render( 'partials/editor/notice', [
229 229
                 'context' => [
230
-                    'notices' => glsr(Notice::class)->get(),
230
+                    'notices' => glsr( Notice::class )->get(),
231 231
                 ],
232
-            ]);
232
+            ] );
233 233
         }
234 234
     }
235 235
 
@@ -239,14 +239,14 @@  discard block
 block discarded – undo
239 239
      * @see glsr_categories_meta_box()
240 240
      * @callback register_taxonomy
241 241
      */
242
-    public function renderTaxonomyMetabox($post)
242
+    public function renderTaxonomyMetabox( $post )
243 243
     {
244
-        if (Review::isReview($post)) {
245
-            glsr()->render('partials/editor/metabox-categories', [
244
+        if( Review::isReview( $post ) ) {
245
+            glsr()->render( 'partials/editor/metabox-categories', [
246 246
                 'post' => $post,
247 247
                 'tax_name' => glsr()->taxonomy,
248
-                'taxonomy' => get_taxonomy(glsr()->taxonomy),
249
-            ]);
248
+                'taxonomy' => get_taxonomy( glsr()->taxonomy ),
249
+            ] );
250 250
         }
251 251
     }
252 252
 
@@ -257,30 +257,30 @@  discard block
 block discarded – undo
257 257
      * @return void
258 258
      * @action save_post_.Application::POST_TYPE
259 259
      */
260
-    public function saveMetaboxes($postId, $post, $isUpdating)
260
+    public function saveMetaboxes( $postId, $post, $isUpdating )
261 261
     {
262
-        glsr(Metaboxes::class)->saveAssignedToMetabox($postId);
263
-        glsr(Metaboxes::class)->saveResponseMetabox($postId);
264
-        if ($isUpdating) {
265
-            glsr()->action('review/saved', glsr(Query::class)->review($postId));
262
+        glsr( Metaboxes::class )->saveAssignedToMetabox( $postId );
263
+        glsr( Metaboxes::class )->saveResponseMetabox( $postId );
264
+        if( $isUpdating ) {
265
+            glsr()->action( 'review/saved', glsr( Query::class )->review( $postId ) );
266 266
         }
267 267
     }
268 268
 
269 269
     /**
270 270
      * @return string|void
271 271
      */
272
-    protected function getReviewType(Review $review)
272
+    protected function getReviewType( Review $review )
273 273
     {
274
-        if (count(glsr()->reviewTypes) < 2) {
274
+        if( count( glsr()->reviewTypes ) < 2 ) {
275 275
             return;
276 276
         }
277 277
         $type = $review->type();
278
-        if (!empty($review->url)) {
279
-            return glsr(Builder::class)->a([
278
+        if( !empty($review->url) ) {
279
+            return glsr( Builder::class )->a( [
280 280
                 'href' => $review->url,
281 281
                 'target' => '_blank',
282 282
                 'text' => $type,
283
-            ]);
283
+            ] );
284 284
         }
285 285
         return $type;
286 286
     }
@@ -288,29 +288,29 @@  discard block
 block discarded – undo
288 288
     /**
289 289
      * @return array
290 290
      */
291
-    protected function normalizeDetailsMetaBox(Review $review)
291
+    protected function normalizeDetailsMetaBox( Review $review )
292 292
     {
293 293
         $user = empty($review->author_id)
294
-            ? _x('Unregistered user', 'admin-text', 'site-reviews')
295
-            : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->author_id), [
296
-                'href' => get_author_posts_url($review->author_id),
297
-            ]);
294
+            ? _x( 'Unregistered user', 'admin-text', 'site-reviews' )
295
+            : glsr( Builder::class )->a( get_the_author_meta( 'display_name', $review->author_id ), [
296
+                'href' => get_author_posts_url( $review->author_id ),
297
+            ] );
298 298
         $email = empty($review->email)
299 299
             ? '&mdash;'
300
-            : glsr(Builder::class)->a($review->email, [
301
-                'href' => 'mailto:'.$review->email.'?subject='.esc_attr(_x('RE:', 'admin-text', 'site-reviews').' '.$review->title),
302
-            ]);
300
+            : glsr( Builder::class )->a( $review->email, [
301
+                'href' => 'mailto:'.$review->email.'?subject='.esc_attr( _x( 'RE:', 'admin-text', 'site-reviews' ).' '.$review->title ),
302
+            ] );
303 303
         $metabox = [
304
-            _x('Rating', 'admin-text', 'site-reviews') => $review->rating(),
305
-            _x('Type', 'admin-text', 'site-reviews') => $this->getReviewType($review),
306
-            _x('Date', 'admin-text', 'site-reviews') => $review->date(),
307
-            _x('Name', 'admin-text', 'site-reviews') => $review->author,
308
-            _x('Email', 'admin-text', 'site-reviews') => $email,
309
-            _x('User', 'admin-text', 'site-reviews') => $user,
310
-            _x('IP Address', 'admin-text', 'site-reviews') => $review->ip_address,
311
-            _x('Avatar', 'admin-text', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar),
304
+            _x( 'Rating', 'admin-text', 'site-reviews' ) => $review->rating(),
305
+            _x( 'Type', 'admin-text', 'site-reviews' ) => $this->getReviewType( $review ),
306
+            _x( 'Date', 'admin-text', 'site-reviews' ) => $review->date(),
307
+            _x( 'Name', 'admin-text', 'site-reviews' ) => $review->author,
308
+            _x( 'Email', 'admin-text', 'site-reviews' ) => $email,
309
+            _x( 'User', 'admin-text', 'site-reviews' ) => $user,
310
+            _x( 'IP Address', 'admin-text', 'site-reviews' ) => $review->ip_address,
311
+            _x( 'Avatar', 'admin-text', 'site-reviews' ) => sprintf( '<img src="%s" width="96">', $review->avatar ),
312 312
         ];
313
-        return array_filter(glsr()->filterArray('metabox/details', $metabox, $review));
313
+        return array_filter( glsr()->filterArray( 'metabox/details', $metabox, $review ) );
314 314
     }
315 315
 
316 316
     /**
@@ -318,16 +318,16 @@  discard block
 block discarded – undo
318 318
      * @param int $messageIndex
319 319
      * @return void
320 320
      */
321
-    protected function redirect($postId, $messageIndex)
321
+    protected function redirect( $postId, $messageIndex )
322 322
     {
323 323
         $referer = wp_get_referer();
324 324
         $hasReferer = !$referer
325
-            || Str::contains($referer, 'post.php')
326
-            || Str::contains($referer, 'post-new.php');
325
+            || Str::contains( $referer, 'post.php' )
326
+            || Str::contains( $referer, 'post-new.php' );
327 327
         $redirectUri = $hasReferer
328
-            ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer)
329
-            : get_edit_post_link($postId);
330
-        wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri));
328
+            ? remove_query_arg( ['deleted', 'ids', 'trashed', 'untrashed'], $referer )
329
+            : get_edit_post_link( $postId );
330
+        wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri ) );
331 331
         exit;
332 332
     }
333 333
 }
Please login to merge, or discard this patch.
plugin/Controllers/TrustalyzeController.php 2 patches
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -12,210 +12,210 @@
 block discarded – undo
12 12
 
13 13
 class TrustalyzeController extends Controller
14 14
 {
15
-    protected $apiKey = 'settings.general.trustalyze_serial';
16
-    protected $emailKey = 'settings.general.trustalyze_email';
17
-    protected $enabledKey = 'settings.general.trustalyze';
18
-    protected $trustalyzeKey = '_glsr_trustalyze';
19
-
20
-    /**
21
-     * @return array
22
-     * @filter site-reviews/settings/callback
23
-     */
24
-    public function filterSettingsCallback(array $settings)
25
-    {
26
-        if ('yes' !== Arr::get($settings, $this->enabledKey)) {
27
-            return $settings;
28
-        }
29
-        $isApiKeyModified = $this->isEmptyOrModified($this->apiKey, $settings);
30
-        $isEmailModified = $this->isEmptyOrModified($this->emailKey, $settings);
31
-        $isAccountVerified = glsr(OptionManager::class)->getWP($this->trustalyzeKey, false);
32
-        if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) {
33
-            $settings = $this->sanitizeTrustalyzeSettings($settings);
34
-        }
35
-        return $settings;
36
-    }
37
-
38
-    /**
39
-     * @param string $template
40
-     * @return array
41
-     * @filter site-reviews/interpolate/partials/form/table-row-multiple
42
-     */
43
-    public function filterSettingsTableRow(array $context, $template, array $data)
44
-    {
45
-        if ($this->enabledKey !== Arr::get($data, 'field.path')) {
46
-            return $context;
47
-        }
48
-        $isAccountValidated = !empty(glsr(OptionManager::class)->getWP($this->trustalyzeKey));
49
-        $isIntegrationEnabled = glsr(OptionManager::class)->getBool('settings.general.trustalyze');
50
-        if ($isAccountValidated && $isIntegrationEnabled) {
51
-            return $context;
52
-        }
53
-        $context['field'] .= $this->buildCreateButton();
54
-        return $context;
55
-    }
56
-
57
-    /**
58
-     * Triggered when a review is created.
59
-     * @return void
60
-     * @action site-reviews/review/created
61
-     */
62
-    public function onCreated(Review $review)
63
-    {
64
-        if (!$this->canPostReview($review)) {
65
-            return;
66
-        }
67
-        $trustalyze = glsr(Trustalyze::class)->sendReview($review);
68
-        if ($trustalyze->success) {
69
-            glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
70
-        }
71
-    }
72
-
73
-    /**
74
-     * Triggered when a review is reverted to its original title/content/date_timestamp.
75
-     * @return void
76
-     * @action site-reviews/review/reverted
77
-     */
78
-    public function onReverted(Review $review)
79
-    {
80
-        if (!$this->canPostReview($review)) {
81
-            return;
82
-        }
83
-        $trustalyze = glsr(Trustalyze::class)->sendReview($review);
84
-        if ($trustalyze->success) {
85
-            glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
86
-        }
87
-    }
88
-
89
-    /**
90
-     * Triggered when an existing review is updated.
91
-     * @return void
92
-     * @action site-reviews/review/saved
93
-     */
94
-    public function onSaved(Review $review)
95
-    {
96
-        if (!$this->canPostReview($review)) {
97
-            return;
98
-        }
99
-        $trustalyze = glsr(Trustalyze::class)->sendReview($review);
100
-        if ($trustalyze->success) {
101
-            glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
102
-        }
103
-    }
104
-
105
-    /**
106
-     * Triggered when a review's response is added or updated.
107
-     * @param int $metaId
108
-     * @param int $postId
109
-     * @param string $metaKey
110
-     * @return void
111
-     * @action updated_postmeta
112
-     */
113
-    public function onUpdatedMeta($metaId, $postId, $metaKey)
114
-    {
115
-        $review = glsr_get_review($postId);
116
-        if (!$this->canPostResponse($review) || '_response' !== $metaKey) {
117
-            return;
118
-        }
119
-        $trustalyze = glsr(Trustalyze::class)->sendReviewResponse($review);
120
-        if ($trustalyze->success) {
121
-            glsr(Database::class)->set($review->ID, 'trustalyze_response', true);
122
-        }
123
-    }
124
-
125
-    /**
126
-     * @return string
127
-     */
128
-    protected function buildCreateButton()
129
-    {
130
-        return glsr(Builder::class)->a(_x('Create Your Trustalyze Account', 'admin-text', 'site-reviews'), [
131
-            'class' => 'button',
132
-            'href' => Trustalyze::WEB_URL,
133
-            'target' => '_blank',
134
-        ]);
135
-    }
136
-
137
-    /**
138
-     * @return bool
139
-     */
140
-    protected function canPostResponse(Review $review)
141
-    {
142
-        $requiredValues = [
143
-            glsr(Database::class)->get($review->ID, 'trustalyze'),
144
-            $review->response,
145
-            $review->review_id,
146
-        ];
147
-        return $this->canProceed($review, 'trustalyze_response')
148
-            && 'publish' === $review->status
149
-            && 3 === count(array_filter($requiredValues));
150
-    }
151
-
152
-    /**
153
-     * @return bool
154
-     */
155
-    protected function canPostReview(Review $review)
156
-    {
157
-        $requiredValues = [
158
-            $review->author,
159
-            $review->content,
160
-            $review->rating,
161
-            $review->review_id,
162
-            $review->title,
163
-        ];
164
-        return $this->canProceed($review)
165
-            && 'publish' === $review->status
166
-            && 5 === count(array_filter($requiredValues));
167
-    }
168
-
169
-    /**
170
-     * @param string $metaKey
171
-     * @return bool
172
-     */
173
-    protected function canProceed(Review $review, $metaKey = 'trustalyze')
174
-    {
175
-        return glsr(OptionManager::class)->getBool($this->enabledKey)
176
-            && Review::isReview($review->ID)
177
-            && !$this->hasMetaKey($review, $metaKey);
178
-    }
179
-
180
-    /**
181
-     * @param string $metaKey
182
-     * @return bool
183
-     */
184
-    protected function hasMetaKey(Review $review, $metaKey = 'trustalyze')
185
-    {
186
-        return '' !== glsr(Database::class)->get($review->ID, $metaKey);
187
-    }
188
-
189
-    /**
190
-     * @param string $key
191
-     * @return bool
192
-     */
193
-    protected function isEmptyOrModified($key, array $settings)
194
-    {
195
-        $oldValue = glsr_get_option($key);
196
-        $newValue = Arr::get($settings, $key);
197
-        return empty($newValue) || $newValue !== $oldValue;
198
-    }
199
-
200
-    /**
201
-     * @return array
202
-     */
203
-    protected function sanitizeTrustalyzeSettings(array $settings)
204
-    {
205
-        $trustalyze = glsr(Trustalyze::class)->activateKey(
206
-            Arr::get($settings, $this->apiKey),
207
-            Arr::get($settings, $this->emailKey)
208
-        );
209
-        if ($trustalyze->success) {
210
-            update_option($this->trustalyzeKey, Arr::get($trustalyze->response, 'producttype'));
211
-        } else {
212
-            delete_option($this->trustalyzeKey);
213
-            $settings = Arr::set($settings, $this->enabledKey, 'no');
214
-            glsr(Notice::class)->addError(sprintf(
215
-                _x('Your Trustalyze account details could not be verified, please try again. %s', 'admin-text', 'site-reviews'),
216
-                '('.$trustalyze->message.')'
217
-            ));
218
-        }
219
-        return $settings;
220
-    }
15
+	protected $apiKey = 'settings.general.trustalyze_serial';
16
+	protected $emailKey = 'settings.general.trustalyze_email';
17
+	protected $enabledKey = 'settings.general.trustalyze';
18
+	protected $trustalyzeKey = '_glsr_trustalyze';
19
+
20
+	/**
21
+	 * @return array
22
+	 * @filter site-reviews/settings/callback
23
+	 */
24
+	public function filterSettingsCallback(array $settings)
25
+	{
26
+		if ('yes' !== Arr::get($settings, $this->enabledKey)) {
27
+			return $settings;
28
+		}
29
+		$isApiKeyModified = $this->isEmptyOrModified($this->apiKey, $settings);
30
+		$isEmailModified = $this->isEmptyOrModified($this->emailKey, $settings);
31
+		$isAccountVerified = glsr(OptionManager::class)->getWP($this->trustalyzeKey, false);
32
+		if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) {
33
+			$settings = $this->sanitizeTrustalyzeSettings($settings);
34
+		}
35
+		return $settings;
36
+	}
37
+
38
+	/**
39
+	 * @param string $template
40
+	 * @return array
41
+	 * @filter site-reviews/interpolate/partials/form/table-row-multiple
42
+	 */
43
+	public function filterSettingsTableRow(array $context, $template, array $data)
44
+	{
45
+		if ($this->enabledKey !== Arr::get($data, 'field.path')) {
46
+			return $context;
47
+		}
48
+		$isAccountValidated = !empty(glsr(OptionManager::class)->getWP($this->trustalyzeKey));
49
+		$isIntegrationEnabled = glsr(OptionManager::class)->getBool('settings.general.trustalyze');
50
+		if ($isAccountValidated && $isIntegrationEnabled) {
51
+			return $context;
52
+		}
53
+		$context['field'] .= $this->buildCreateButton();
54
+		return $context;
55
+	}
56
+
57
+	/**
58
+	 * Triggered when a review is created.
59
+	 * @return void
60
+	 * @action site-reviews/review/created
61
+	 */
62
+	public function onCreated(Review $review)
63
+	{
64
+		if (!$this->canPostReview($review)) {
65
+			return;
66
+		}
67
+		$trustalyze = glsr(Trustalyze::class)->sendReview($review);
68
+		if ($trustalyze->success) {
69
+			glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
70
+		}
71
+	}
72
+
73
+	/**
74
+	 * Triggered when a review is reverted to its original title/content/date_timestamp.
75
+	 * @return void
76
+	 * @action site-reviews/review/reverted
77
+	 */
78
+	public function onReverted(Review $review)
79
+	{
80
+		if (!$this->canPostReview($review)) {
81
+			return;
82
+		}
83
+		$trustalyze = glsr(Trustalyze::class)->sendReview($review);
84
+		if ($trustalyze->success) {
85
+			glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
86
+		}
87
+	}
88
+
89
+	/**
90
+	 * Triggered when an existing review is updated.
91
+	 * @return void
92
+	 * @action site-reviews/review/saved
93
+	 */
94
+	public function onSaved(Review $review)
95
+	{
96
+		if (!$this->canPostReview($review)) {
97
+			return;
98
+		}
99
+		$trustalyze = glsr(Trustalyze::class)->sendReview($review);
100
+		if ($trustalyze->success) {
101
+			glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
102
+		}
103
+	}
104
+
105
+	/**
106
+	 * Triggered when a review's response is added or updated.
107
+	 * @param int $metaId
108
+	 * @param int $postId
109
+	 * @param string $metaKey
110
+	 * @return void
111
+	 * @action updated_postmeta
112
+	 */
113
+	public function onUpdatedMeta($metaId, $postId, $metaKey)
114
+	{
115
+		$review = glsr_get_review($postId);
116
+		if (!$this->canPostResponse($review) || '_response' !== $metaKey) {
117
+			return;
118
+		}
119
+		$trustalyze = glsr(Trustalyze::class)->sendReviewResponse($review);
120
+		if ($trustalyze->success) {
121
+			glsr(Database::class)->set($review->ID, 'trustalyze_response', true);
122
+		}
123
+	}
124
+
125
+	/**
126
+	 * @return string
127
+	 */
128
+	protected function buildCreateButton()
129
+	{
130
+		return glsr(Builder::class)->a(_x('Create Your Trustalyze Account', 'admin-text', 'site-reviews'), [
131
+			'class' => 'button',
132
+			'href' => Trustalyze::WEB_URL,
133
+			'target' => '_blank',
134
+		]);
135
+	}
136
+
137
+	/**
138
+	 * @return bool
139
+	 */
140
+	protected function canPostResponse(Review $review)
141
+	{
142
+		$requiredValues = [
143
+			glsr(Database::class)->get($review->ID, 'trustalyze'),
144
+			$review->response,
145
+			$review->review_id,
146
+		];
147
+		return $this->canProceed($review, 'trustalyze_response')
148
+			&& 'publish' === $review->status
149
+			&& 3 === count(array_filter($requiredValues));
150
+	}
151
+
152
+	/**
153
+	 * @return bool
154
+	 */
155
+	protected function canPostReview(Review $review)
156
+	{
157
+		$requiredValues = [
158
+			$review->author,
159
+			$review->content,
160
+			$review->rating,
161
+			$review->review_id,
162
+			$review->title,
163
+		];
164
+		return $this->canProceed($review)
165
+			&& 'publish' === $review->status
166
+			&& 5 === count(array_filter($requiredValues));
167
+	}
168
+
169
+	/**
170
+	 * @param string $metaKey
171
+	 * @return bool
172
+	 */
173
+	protected function canProceed(Review $review, $metaKey = 'trustalyze')
174
+	{
175
+		return glsr(OptionManager::class)->getBool($this->enabledKey)
176
+			&& Review::isReview($review->ID)
177
+			&& !$this->hasMetaKey($review, $metaKey);
178
+	}
179
+
180
+	/**
181
+	 * @param string $metaKey
182
+	 * @return bool
183
+	 */
184
+	protected function hasMetaKey(Review $review, $metaKey = 'trustalyze')
185
+	{
186
+		return '' !== glsr(Database::class)->get($review->ID, $metaKey);
187
+	}
188
+
189
+	/**
190
+	 * @param string $key
191
+	 * @return bool
192
+	 */
193
+	protected function isEmptyOrModified($key, array $settings)
194
+	{
195
+		$oldValue = glsr_get_option($key);
196
+		$newValue = Arr::get($settings, $key);
197
+		return empty($newValue) || $newValue !== $oldValue;
198
+	}
199
+
200
+	/**
201
+	 * @return array
202
+	 */
203
+	protected function sanitizeTrustalyzeSettings(array $settings)
204
+	{
205
+		$trustalyze = glsr(Trustalyze::class)->activateKey(
206
+			Arr::get($settings, $this->apiKey),
207
+			Arr::get($settings, $this->emailKey)
208
+		);
209
+		if ($trustalyze->success) {
210
+			update_option($this->trustalyzeKey, Arr::get($trustalyze->response, 'producttype'));
211
+		} else {
212
+			delete_option($this->trustalyzeKey);
213
+			$settings = Arr::set($settings, $this->enabledKey, 'no');
214
+			glsr(Notice::class)->addError(sprintf(
215
+				_x('Your Trustalyze account details could not be verified, please try again. %s', 'admin-text', 'site-reviews'),
216
+				'('.$trustalyze->message.')'
217
+			));
218
+		}
219
+		return $settings;
220
+	}
221 221
 }
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -21,16 +21,16 @@  discard block
 block discarded – undo
21 21
      * @return array
22 22
      * @filter site-reviews/settings/callback
23 23
      */
24
-    public function filterSettingsCallback(array $settings)
24
+    public function filterSettingsCallback( array $settings )
25 25
     {
26
-        if ('yes' !== Arr::get($settings, $this->enabledKey)) {
26
+        if( 'yes' !== Arr::get( $settings, $this->enabledKey ) ) {
27 27
             return $settings;
28 28
         }
29
-        $isApiKeyModified = $this->isEmptyOrModified($this->apiKey, $settings);
30
-        $isEmailModified = $this->isEmptyOrModified($this->emailKey, $settings);
31
-        $isAccountVerified = glsr(OptionManager::class)->getWP($this->trustalyzeKey, false);
32
-        if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) {
33
-            $settings = $this->sanitizeTrustalyzeSettings($settings);
29
+        $isApiKeyModified = $this->isEmptyOrModified( $this->apiKey, $settings );
30
+        $isEmailModified = $this->isEmptyOrModified( $this->emailKey, $settings );
31
+        $isAccountVerified = glsr( OptionManager::class )->getWP( $this->trustalyzeKey, false );
32
+        if( !$isAccountVerified || $isApiKeyModified || $isEmailModified ) {
33
+            $settings = $this->sanitizeTrustalyzeSettings( $settings );
34 34
         }
35 35
         return $settings;
36 36
     }
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
      * @return array
41 41
      * @filter site-reviews/interpolate/partials/form/table-row-multiple
42 42
      */
43
-    public function filterSettingsTableRow(array $context, $template, array $data)
43
+    public function filterSettingsTableRow( array $context, $template, array $data )
44 44
     {
45
-        if ($this->enabledKey !== Arr::get($data, 'field.path')) {
45
+        if( $this->enabledKey !== Arr::get( $data, 'field.path' ) ) {
46 46
             return $context;
47 47
         }
48
-        $isAccountValidated = !empty(glsr(OptionManager::class)->getWP($this->trustalyzeKey));
49
-        $isIntegrationEnabled = glsr(OptionManager::class)->getBool('settings.general.trustalyze');
50
-        if ($isAccountValidated && $isIntegrationEnabled) {
48
+        $isAccountValidated = !empty(glsr( OptionManager::class )->getWP( $this->trustalyzeKey ));
49
+        $isIntegrationEnabled = glsr( OptionManager::class )->getBool( 'settings.general.trustalyze' );
50
+        if( $isAccountValidated && $isIntegrationEnabled ) {
51 51
             return $context;
52 52
         }
53 53
         $context['field'] .= $this->buildCreateButton();
@@ -59,14 +59,14 @@  discard block
 block discarded – undo
59 59
      * @return void
60 60
      * @action site-reviews/review/created
61 61
      */
62
-    public function onCreated(Review $review)
62
+    public function onCreated( Review $review )
63 63
     {
64
-        if (!$this->canPostReview($review)) {
64
+        if( !$this->canPostReview( $review ) ) {
65 65
             return;
66 66
         }
67
-        $trustalyze = glsr(Trustalyze::class)->sendReview($review);
68
-        if ($trustalyze->success) {
69
-            glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
67
+        $trustalyze = glsr( Trustalyze::class )->sendReview( $review );
68
+        if( $trustalyze->success ) {
69
+            glsr( Database::class )->set( $review->ID, 'trustalyze', $trustalyze->review_id );
70 70
         }
71 71
     }
72 72
 
@@ -75,14 +75,14 @@  discard block
 block discarded – undo
75 75
      * @return void
76 76
      * @action site-reviews/review/reverted
77 77
      */
78
-    public function onReverted(Review $review)
78
+    public function onReverted( Review $review )
79 79
     {
80
-        if (!$this->canPostReview($review)) {
80
+        if( !$this->canPostReview( $review ) ) {
81 81
             return;
82 82
         }
83
-        $trustalyze = glsr(Trustalyze::class)->sendReview($review);
84
-        if ($trustalyze->success) {
85
-            glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
83
+        $trustalyze = glsr( Trustalyze::class )->sendReview( $review );
84
+        if( $trustalyze->success ) {
85
+            glsr( Database::class )->set( $review->ID, 'trustalyze', $trustalyze->review_id );
86 86
         }
87 87
     }
88 88
 
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
      * @return void
92 92
      * @action site-reviews/review/saved
93 93
      */
94
-    public function onSaved(Review $review)
94
+    public function onSaved( Review $review )
95 95
     {
96
-        if (!$this->canPostReview($review)) {
96
+        if( !$this->canPostReview( $review ) ) {
97 97
             return;
98 98
         }
99
-        $trustalyze = glsr(Trustalyze::class)->sendReview($review);
100
-        if ($trustalyze->success) {
101
-            glsr(Database::class)->set($review->ID, 'trustalyze', $trustalyze->review_id);
99
+        $trustalyze = glsr( Trustalyze::class )->sendReview( $review );
100
+        if( $trustalyze->success ) {
101
+            glsr( Database::class )->set( $review->ID, 'trustalyze', $trustalyze->review_id );
102 102
         }
103 103
     }
104 104
 
@@ -110,15 +110,15 @@  discard block
 block discarded – undo
110 110
      * @return void
111 111
      * @action updated_postmeta
112 112
      */
113
-    public function onUpdatedMeta($metaId, $postId, $metaKey)
113
+    public function onUpdatedMeta( $metaId, $postId, $metaKey )
114 114
     {
115
-        $review = glsr_get_review($postId);
116
-        if (!$this->canPostResponse($review) || '_response' !== $metaKey) {
115
+        $review = glsr_get_review( $postId );
116
+        if( !$this->canPostResponse( $review ) || '_response' !== $metaKey ) {
117 117
             return;
118 118
         }
119
-        $trustalyze = glsr(Trustalyze::class)->sendReviewResponse($review);
120
-        if ($trustalyze->success) {
121
-            glsr(Database::class)->set($review->ID, 'trustalyze_response', true);
119
+        $trustalyze = glsr( Trustalyze::class )->sendReviewResponse( $review );
120
+        if( $trustalyze->success ) {
121
+            glsr( Database::class )->set( $review->ID, 'trustalyze_response', true );
122 122
         }
123 123
     }
124 124
 
@@ -127,32 +127,32 @@  discard block
 block discarded – undo
127 127
      */
128 128
     protected function buildCreateButton()
129 129
     {
130
-        return glsr(Builder::class)->a(_x('Create Your Trustalyze Account', 'admin-text', 'site-reviews'), [
130
+        return glsr( Builder::class )->a( _x( 'Create Your Trustalyze Account', 'admin-text', 'site-reviews' ), [
131 131
             'class' => 'button',
132 132
             'href' => Trustalyze::WEB_URL,
133 133
             'target' => '_blank',
134
-        ]);
134
+        ] );
135 135
     }
136 136
 
137 137
     /**
138 138
      * @return bool
139 139
      */
140
-    protected function canPostResponse(Review $review)
140
+    protected function canPostResponse( Review $review )
141 141
     {
142 142
         $requiredValues = [
143
-            glsr(Database::class)->get($review->ID, 'trustalyze'),
143
+            glsr( Database::class )->get( $review->ID, 'trustalyze' ),
144 144
             $review->response,
145 145
             $review->review_id,
146 146
         ];
147
-        return $this->canProceed($review, 'trustalyze_response')
147
+        return $this->canProceed( $review, 'trustalyze_response' )
148 148
             && 'publish' === $review->status
149
-            && 3 === count(array_filter($requiredValues));
149
+            && 3 === count( array_filter( $requiredValues ) );
150 150
     }
151 151
 
152 152
     /**
153 153
      * @return bool
154 154
      */
155
-    protected function canPostReview(Review $review)
155
+    protected function canPostReview( Review $review )
156 156
     {
157 157
         $requiredValues = [
158 158
             $review->author,
@@ -161,60 +161,60 @@  discard block
 block discarded – undo
161 161
             $review->review_id,
162 162
             $review->title,
163 163
         ];
164
-        return $this->canProceed($review)
164
+        return $this->canProceed( $review )
165 165
             && 'publish' === $review->status
166
-            && 5 === count(array_filter($requiredValues));
166
+            && 5 === count( array_filter( $requiredValues ) );
167 167
     }
168 168
 
169 169
     /**
170 170
      * @param string $metaKey
171 171
      * @return bool
172 172
      */
173
-    protected function canProceed(Review $review, $metaKey = 'trustalyze')
173
+    protected function canProceed( Review $review, $metaKey = 'trustalyze' )
174 174
     {
175
-        return glsr(OptionManager::class)->getBool($this->enabledKey)
176
-            && Review::isReview($review->ID)
177
-            && !$this->hasMetaKey($review, $metaKey);
175
+        return glsr( OptionManager::class )->getBool( $this->enabledKey )
176
+            && Review::isReview( $review->ID )
177
+            && !$this->hasMetaKey( $review, $metaKey );
178 178
     }
179 179
 
180 180
     /**
181 181
      * @param string $metaKey
182 182
      * @return bool
183 183
      */
184
-    protected function hasMetaKey(Review $review, $metaKey = 'trustalyze')
184
+    protected function hasMetaKey( Review $review, $metaKey = 'trustalyze' )
185 185
     {
186
-        return '' !== glsr(Database::class)->get($review->ID, $metaKey);
186
+        return '' !== glsr( Database::class )->get( $review->ID, $metaKey );
187 187
     }
188 188
 
189 189
     /**
190 190
      * @param string $key
191 191
      * @return bool
192 192
      */
193
-    protected function isEmptyOrModified($key, array $settings)
193
+    protected function isEmptyOrModified( $key, array $settings )
194 194
     {
195
-        $oldValue = glsr_get_option($key);
196
-        $newValue = Arr::get($settings, $key);
195
+        $oldValue = glsr_get_option( $key );
196
+        $newValue = Arr::get( $settings, $key );
197 197
         return empty($newValue) || $newValue !== $oldValue;
198 198
     }
199 199
 
200 200
     /**
201 201
      * @return array
202 202
      */
203
-    protected function sanitizeTrustalyzeSettings(array $settings)
203
+    protected function sanitizeTrustalyzeSettings( array $settings )
204 204
     {
205
-        $trustalyze = glsr(Trustalyze::class)->activateKey(
206
-            Arr::get($settings, $this->apiKey),
207
-            Arr::get($settings, $this->emailKey)
205
+        $trustalyze = glsr( Trustalyze::class )->activateKey(
206
+            Arr::get( $settings, $this->apiKey ),
207
+            Arr::get( $settings, $this->emailKey )
208 208
         );
209
-        if ($trustalyze->success) {
210
-            update_option($this->trustalyzeKey, Arr::get($trustalyze->response, 'producttype'));
209
+        if( $trustalyze->success ) {
210
+            update_option( $this->trustalyzeKey, Arr::get( $trustalyze->response, 'producttype' ) );
211 211
         } else {
212
-            delete_option($this->trustalyzeKey);
213
-            $settings = Arr::set($settings, $this->enabledKey, 'no');
214
-            glsr(Notice::class)->addError(sprintf(
215
-                _x('Your Trustalyze account details could not be verified, please try again. %s', 'admin-text', 'site-reviews'),
212
+            delete_option( $this->trustalyzeKey );
213
+            $settings = Arr::set( $settings, $this->enabledKey, 'no' );
214
+            glsr( Notice::class )->addError( sprintf(
215
+                _x( 'Your Trustalyze account details could not be verified, please try again. %s', 'admin-text', 'site-reviews' ),
216 216
                 '('.$trustalyze->message.')'
217
-            ));
217
+            ) );
218 218
         }
219 219
         return $settings;
220 220
     }
Please login to merge, or discard this patch.