Passed
Push — master ( ae1954...aab291 )
by Paul
08:17 queued 04:15
created
plugin/Modules/Upgrader/Upgrade_4_0_0.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -9,67 +9,67 @@
 block discarded – undo
9 9
 
10 10
 class Upgrade_4_0_0
11 11
 {
12
-    public function __construct()
13
-    {
14
-        $this->migrateSettings();
15
-        $this->protectMetaKeys();
16
-        $this->deleteSessions();
17
-        delete_transient(Application::ID.'_cloudflare_ips');
18
-    }
12
+	public function __construct()
13
+	{
14
+		$this->migrateSettings();
15
+		$this->protectMetaKeys();
16
+		$this->deleteSessions();
17
+		delete_transient(Application::ID.'_cloudflare_ips');
18
+	}
19 19
 
20
-    /**
21
-     * @return void
22
-     */
23
-    public function deleteSessions()
24
-    {
25
-        global $wpdb;
26
-        $wpdb->query("
20
+	/**
21
+	 * @return void
22
+	 */
23
+	public function deleteSessions()
24
+	{
25
+		global $wpdb;
26
+		$wpdb->query("
27 27
             DELETE
28 28
             FROM {$wpdb->options}
29 29
             WHERE option_name LIKE '_glsr_session%'
30 30
         ");
31
-    }
31
+	}
32 32
 
33
-    /**
34
-     * @return void
35
-     */
36
-    public function migrateSettings()
37
-    {
38
-        if ($settings = get_option(OptionManager::databaseKey(3))) {
39
-            $multilingual = 'yes' == glsr(Helper::class)->dataGet($settings, 'settings.general.support.polylang')
40
-                ? 'polylang'
41
-                : '';
42
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.general.multilingual', $multilingual);
43
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.general.rebusify', 'no');
44
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.general.rebusify_email', '');
45
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.general.rebusify_serial', '');
46
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.reviews.name.format', '');
47
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.reviews.name.initial', '');
48
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.blacklist.integration', '');
49
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit', '');
50
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.email', '');
51
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.ip_address', '');
52
-            $settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.username', '');
53
-            unset($settings['settings']['general']['support']);
54
-            update_option(OptionManager::databaseKey(4), $settings);
55
-        }
56
-    }
33
+	/**
34
+	 * @return void
35
+	 */
36
+	public function migrateSettings()
37
+	{
38
+		if ($settings = get_option(OptionManager::databaseKey(3))) {
39
+			$multilingual = 'yes' == glsr(Helper::class)->dataGet($settings, 'settings.general.support.polylang')
40
+				? 'polylang'
41
+				: '';
42
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.general.multilingual', $multilingual);
43
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.general.rebusify', 'no');
44
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.general.rebusify_email', '');
45
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.general.rebusify_serial', '');
46
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.reviews.name.format', '');
47
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.reviews.name.initial', '');
48
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.blacklist.integration', '');
49
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit', '');
50
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.email', '');
51
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.ip_address', '');
52
+			$settings = glsr(Helper::class)->dataSet($settings, 'settings.submissions.limit_whitelist.username', '');
53
+			unset($settings['settings']['general']['support']);
54
+			update_option(OptionManager::databaseKey(4), $settings);
55
+		}
56
+	}
57 57
 
58
-    /**
59
-     * @return void
60
-     */
61
-    public function protectMetaKeys()
62
-    {
63
-        global $wpdb;
64
-        $keys = array_keys(glsr(CreateReviewDefaults::class)->defaults());
65
-        $keys = implode("','", $keys);
66
-        $postType = Application::POST_TYPE;
67
-        $wpdb->query("
58
+	/**
59
+	 * @return void
60
+	 */
61
+	public function protectMetaKeys()
62
+	{
63
+		global $wpdb;
64
+		$keys = array_keys(glsr(CreateReviewDefaults::class)->defaults());
65
+		$keys = implode("','", $keys);
66
+		$postType = Application::POST_TYPE;
67
+		$wpdb->query("
68 68
             UPDATE {$wpdb->postmeta} pm
69 69
             INNER JOIN {$wpdb->posts} p ON p.id = pm.post_id
70 70
             SET pm.meta_key = CONCAT('_', pm.meta_key)
71 71
             WHERE pm.meta_key IN ('{$keys}')
72 72
             AND p.post_type = '{$postType}'
73 73
         ");
74
-    }
74
+	}
75 75
 }
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/SiteReviews.php 1 patch
Indentation   +353 added lines, -353 removed lines patch added patch discarded remove patch
@@ -19,382 +19,382 @@
 block discarded – undo
19 19
 
20 20
 class SiteReviews
21 21
 {
22
-    /**
23
-     * @var array
24
-     */
25
-    public $args;
22
+	/**
23
+	 * @var array
24
+	 */
25
+	public $args;
26 26
 
27
-    /**
28
-     * @var Review
29
-     */
30
-    public $current;
27
+	/**
28
+	 * @var Review
29
+	 */
30
+	public $current;
31 31
 
32
-    /**
33
-     * @var array
34
-     */
35
-    public $options;
32
+	/**
33
+	 * @var array
34
+	 */
35
+	public $options;
36 36
 
37
-    /**
38
-     * @var Reviews
39
-     */
40
-    protected $reviews;
37
+	/**
38
+	 * @var Reviews
39
+	 */
40
+	protected $reviews;
41 41
 
42
-    /**
43
-     * @param Reviews|null $reviews
44
-     * @return ReviewsHtml
45
-     */
46
-    public function build(array $args = [], $reviews = null)
47
-    {
48
-        $this->args = glsr(SiteReviewsDefaults::class)->merge($args);
49
-        $this->options = glsr(Helper::class)->flattenArray(glsr(OptionManager::class)->all());
50
-        $this->reviews = $reviews instanceof Reviews
51
-            ? $reviews
52
-            : glsr(ReviewManager::class)->get($args);
53
-        $this->generateSchema();
54
-        return $this->buildReviews();
55
-    }
42
+	/**
43
+	 * @param Reviews|null $reviews
44
+	 * @return ReviewsHtml
45
+	 */
46
+	public function build(array $args = [], $reviews = null)
47
+	{
48
+		$this->args = glsr(SiteReviewsDefaults::class)->merge($args);
49
+		$this->options = glsr(Helper::class)->flattenArray(glsr(OptionManager::class)->all());
50
+		$this->reviews = $reviews instanceof Reviews
51
+			? $reviews
52
+			: glsr(ReviewManager::class)->get($args);
53
+		$this->generateSchema();
54
+		return $this->buildReviews();
55
+	}
56 56
 
57
-    /**
58
-     * @return ReviewHtml
59
-     */
60
-    public function buildReview(Review $review)
61
-    {
62
-        $review = apply_filters('site-reviews/review/build/before', $review);
63
-        $this->current = $review;
64
-        $renderedFields = [];
65
-        foreach ($review as $key => $value) {
66
-            $method = glsr(Helper::class)->buildMethodName($key, 'buildOption');
67
-            $field = method_exists($this, $method)
68
-                ? $this->$method($key, $value)
69
-                : false;
70
-            $field = apply_filters('site-reviews/review/build/'.$key, $field, $value, $this, $review);
71
-            if (false === $field) {
72
-                continue;
73
-            }
74
-            $renderedFields[$key] = $field;
75
-        }
76
-        $this->wrap($renderedFields, $review);
77
-        $renderedFields = apply_filters('site-reviews/review/build/after', $renderedFields, $review, $this);
78
-        $this->current = null;
79
-        return new ReviewHtml($review, (array) $renderedFields);
80
-    }
57
+	/**
58
+	 * @return ReviewHtml
59
+	 */
60
+	public function buildReview(Review $review)
61
+	{
62
+		$review = apply_filters('site-reviews/review/build/before', $review);
63
+		$this->current = $review;
64
+		$renderedFields = [];
65
+		foreach ($review as $key => $value) {
66
+			$method = glsr(Helper::class)->buildMethodName($key, 'buildOption');
67
+			$field = method_exists($this, $method)
68
+				? $this->$method($key, $value)
69
+				: false;
70
+			$field = apply_filters('site-reviews/review/build/'.$key, $field, $value, $this, $review);
71
+			if (false === $field) {
72
+				continue;
73
+			}
74
+			$renderedFields[$key] = $field;
75
+		}
76
+		$this->wrap($renderedFields, $review);
77
+		$renderedFields = apply_filters('site-reviews/review/build/after', $renderedFields, $review, $this);
78
+		$this->current = null;
79
+		return new ReviewHtml($review, (array) $renderedFields);
80
+	}
81 81
 
82
-    /**
83
-     * @return ReviewsHtml
84
-     */
85
-    public function buildReviews()
86
-    {
87
-        $renderedReviews = [];
88
-        foreach ($this->reviews as $index => $review) {
89
-            $renderedReviews[] = $this->buildReview($review);
90
-        }
91
-        return new ReviewsHtml($renderedReviews, $this->reviews->max_num_pages, $this->args);
92
-    }
82
+	/**
83
+	 * @return ReviewsHtml
84
+	 */
85
+	public function buildReviews()
86
+	{
87
+		$renderedReviews = [];
88
+		foreach ($this->reviews as $index => $review) {
89
+			$renderedReviews[] = $this->buildReview($review);
90
+		}
91
+		return new ReviewsHtml($renderedReviews, $this->reviews->max_num_pages, $this->args);
92
+	}
93 93
 
94
-    /**
95
-     * @return void
96
-     */
97
-    public function generateSchema()
98
-    {
99
-        if (!wp_validate_boolean($this->args['schema'])) {
100
-            return;
101
-        }
102
-        glsr(Schema::class)->store(
103
-            glsr(Schema::class)->build($this->args)
104
-        );
105
-    }
94
+	/**
95
+	 * @return void
96
+	 */
97
+	public function generateSchema()
98
+	{
99
+		if (!wp_validate_boolean($this->args['schema'])) {
100
+			return;
101
+		}
102
+		glsr(Schema::class)->store(
103
+			glsr(Schema::class)->build($this->args)
104
+		);
105
+	}
106 106
 
107
-    /**
108
-     * @param string $key
109
-     * @param string $path
110
-     * @return bool
111
-     */
112
-    public function isHidden($key, $path = '')
113
-    {
114
-        $isOptionEnabled = !empty($path)
115
-            ? $this->isOptionEnabled($path)
116
-            : true;
117
-        return in_array($key, $this->args['hide']) || !$isOptionEnabled;
118
-    }
107
+	/**
108
+	 * @param string $key
109
+	 * @param string $path
110
+	 * @return bool
111
+	 */
112
+	public function isHidden($key, $path = '')
113
+	{
114
+		$isOptionEnabled = !empty($path)
115
+			? $this->isOptionEnabled($path)
116
+			: true;
117
+		return in_array($key, $this->args['hide']) || !$isOptionEnabled;
118
+	}
119 119
 
120
-    /**
121
-     * @param string $key
122
-     * @param string $value
123
-     * @return void|string
124
-     */
125
-    protected function buildOptionAssignedTo($key, $value)
126
-    {
127
-        if ($this->isHidden($key, 'settings.reviews.assigned_links')) {
128
-            return;
129
-        }
130
-        $post = glsr(Polylang::class)->getPost($value);
131
-        if (!($post instanceof WP_Post)) {
132
-            return;
133
-        }
134
-        $permalink = glsr(Builder::class)->a(get_the_title($post->ID), [
135
-            'href' => get_the_permalink($post->ID),
136
-        ]);
137
-        $assignedTo = sprintf(__('Review of %s', 'site-reviews'), $permalink);
138
-        return '<span>'.$assignedTo.'</span>';
139
-    }
120
+	/**
121
+	 * @param string $key
122
+	 * @param string $value
123
+	 * @return void|string
124
+	 */
125
+	protected function buildOptionAssignedTo($key, $value)
126
+	{
127
+		if ($this->isHidden($key, 'settings.reviews.assigned_links')) {
128
+			return;
129
+		}
130
+		$post = glsr(Polylang::class)->getPost($value);
131
+		if (!($post instanceof WP_Post)) {
132
+			return;
133
+		}
134
+		$permalink = glsr(Builder::class)->a(get_the_title($post->ID), [
135
+			'href' => get_the_permalink($post->ID),
136
+		]);
137
+		$assignedTo = sprintf(__('Review of %s', 'site-reviews'), $permalink);
138
+		return '<span>'.$assignedTo.'</span>';
139
+	}
140 140
 
141
-    /**
142
-     * @param string $key
143
-     * @param string $value
144
-     * @return void|string
145
-     */
146
-    protected function buildOptionAuthor($key, $value)
147
-    {
148
-        if (!$this->isHidden($key)) {
149
-            $name = glsr(Helper::class)->convertName(
150
-                $value,
151
-                glsr_get_option('reviews.name.format'),
152
-                glsr_get_option('reviews.name.initial')
153
-            );
154
-            return '<span>'.$name.'</span>';
155
-        }
156
-    }
141
+	/**
142
+	 * @param string $key
143
+	 * @param string $value
144
+	 * @return void|string
145
+	 */
146
+	protected function buildOptionAuthor($key, $value)
147
+	{
148
+		if (!$this->isHidden($key)) {
149
+			$name = glsr(Helper::class)->convertName(
150
+				$value,
151
+				glsr_get_option('reviews.name.format'),
152
+				glsr_get_option('reviews.name.initial')
153
+			);
154
+			return '<span>'.$name.'</span>';
155
+		}
156
+	}
157 157
 
158
-    /**
159
-     * @param string $key
160
-     * @param string $value
161
-     * @return void|string
162
-     */
163
-    protected function buildOptionAvatar($key, $value)
164
-    {
165
-        if ($this->isHidden($key, 'settings.reviews.avatars')) {
166
-            return;
167
-        }
168
-        $size = $this->getOption('settings.reviews.avatars_size', 40);
169
-        return glsr(Builder::class)->img([
170
-            'height' => $size,
171
-            'src' => $this->generateAvatar($value),
172
-            'style' => sprintf('width:%1$spx; height:%1$spx;', $size),
173
-            'width' => $size,
174
-        ]);
175
-    }
158
+	/**
159
+	 * @param string $key
160
+	 * @param string $value
161
+	 * @return void|string
162
+	 */
163
+	protected function buildOptionAvatar($key, $value)
164
+	{
165
+		if ($this->isHidden($key, 'settings.reviews.avatars')) {
166
+			return;
167
+		}
168
+		$size = $this->getOption('settings.reviews.avatars_size', 40);
169
+		return glsr(Builder::class)->img([
170
+			'height' => $size,
171
+			'src' => $this->generateAvatar($value),
172
+			'style' => sprintf('width:%1$spx; height:%1$spx;', $size),
173
+			'width' => $size,
174
+		]);
175
+	}
176 176
 
177
-    /**
178
-     * @param string $key
179
-     * @param string $value
180
-     * @return void|string
181
-     */
182
-    protected function buildOptionContent($key, $value)
183
-    {
184
-        $text = $this->normalizeText($value);
185
-        if (!$this->isHiddenOrEmpty($key, $text)) {
186
-            return '<p>'.$text.'</p>';
187
-        }
188
-    }
177
+	/**
178
+	 * @param string $key
179
+	 * @param string $value
180
+	 * @return void|string
181
+	 */
182
+	protected function buildOptionContent($key, $value)
183
+	{
184
+		$text = $this->normalizeText($value);
185
+		if (!$this->isHiddenOrEmpty($key, $text)) {
186
+			return '<p>'.$text.'</p>';
187
+		}
188
+	}
189 189
 
190
-    /**
191
-     * @param string $key
192
-     * @param string $value
193
-     * @return void|string
194
-     */
195
-    protected function buildOptionDate($key, $value)
196
-    {
197
-        if ($this->isHidden($key)) {
198
-            return;
199
-        }
200
-        $dateFormat = $this->getOption('settings.reviews.date.format', 'default');
201
-        if ('relative' == $dateFormat) {
202
-            $date = glsr(Date::class)->relative($value);
203
-        } else {
204
-            $format = 'custom' == $dateFormat
205
-                ? $this->getOption('settings.reviews.date.custom', 'M j, Y')
206
-                : glsr(OptionManager::class)->getWP('date_format', 'F j, Y');
207
-            $date = date_i18n($format, strtotime($value));
208
-        }
209
-        return '<span>'.$date.'</span>';
210
-    }
190
+	/**
191
+	 * @param string $key
192
+	 * @param string $value
193
+	 * @return void|string
194
+	 */
195
+	protected function buildOptionDate($key, $value)
196
+	{
197
+		if ($this->isHidden($key)) {
198
+			return;
199
+		}
200
+		$dateFormat = $this->getOption('settings.reviews.date.format', 'default');
201
+		if ('relative' == $dateFormat) {
202
+			$date = glsr(Date::class)->relative($value);
203
+		} else {
204
+			$format = 'custom' == $dateFormat
205
+				? $this->getOption('settings.reviews.date.custom', 'M j, Y')
206
+				: glsr(OptionManager::class)->getWP('date_format', 'F j, Y');
207
+			$date = date_i18n($format, strtotime($value));
208
+		}
209
+		return '<span>'.$date.'</span>';
210
+	}
211 211
 
212
-    /**
213
-     * @param string $key
214
-     * @param string $value
215
-     * @return void|string
216
-     */
217
-    protected function buildOptionRating($key, $value)
218
-    {
219
-        if (!$this->isHiddenOrEmpty($key, $value)) {
220
-            return glsr_star_rating($value);
221
-        }
222
-    }
212
+	/**
213
+	 * @param string $key
214
+	 * @param string $value
215
+	 * @return void|string
216
+	 */
217
+	protected function buildOptionRating($key, $value)
218
+	{
219
+		if (!$this->isHiddenOrEmpty($key, $value)) {
220
+			return glsr_star_rating($value);
221
+		}
222
+	}
223 223
 
224
-    /**
225
-     * @param string $key
226
-     * @param string $value
227
-     * @return void|string
228
-     */
229
-    protected function buildOptionResponse($key, $value)
230
-    {
231
-        if ($this->isHiddenOrEmpty($key, $value)) {
232
-            return;
233
-        }
234
-        $title = sprintf(__('Response from %s', 'site-reviews'), get_bloginfo('name'));
235
-        $text = $this->normalizeText($value);
236
-        $text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>';
237
-        $response = glsr(Builder::class)->div($text, ['class' => 'glsr-review-response-inner']);
238
-        $background = glsr(Builder::class)->div(['class' => 'glsr-review-response-background']);
239
-        return $response.$background;
240
-    }
224
+	/**
225
+	 * @param string $key
226
+	 * @param string $value
227
+	 * @return void|string
228
+	 */
229
+	protected function buildOptionResponse($key, $value)
230
+	{
231
+		if ($this->isHiddenOrEmpty($key, $value)) {
232
+			return;
233
+		}
234
+		$title = sprintf(__('Response from %s', 'site-reviews'), get_bloginfo('name'));
235
+		$text = $this->normalizeText($value);
236
+		$text = '<p><strong>'.$title.'</strong></p><p>'.$text.'</p>';
237
+		$response = glsr(Builder::class)->div($text, ['class' => 'glsr-review-response-inner']);
238
+		$background = glsr(Builder::class)->div(['class' => 'glsr-review-response-background']);
239
+		return $response.$background;
240
+	}
241 241
 
242
-    /**
243
-     * @param string $key
244
-     * @param string $value
245
-     * @return void|string
246
-     */
247
-    protected function buildOptionTitle($key, $value)
248
-    {
249
-        if ($this->isHidden($key)) {
250
-            return;
251
-        }
252
-        if (empty($value)) {
253
-            $value = __('No Title', 'site-reviews');
254
-        }
255
-        return '<h3>'.$value.'</h3>';
256
-    }
242
+	/**
243
+	 * @param string $key
244
+	 * @param string $value
245
+	 * @return void|string
246
+	 */
247
+	protected function buildOptionTitle($key, $value)
248
+	{
249
+		if ($this->isHidden($key)) {
250
+			return;
251
+		}
252
+		if (empty($value)) {
253
+			$value = __('No Title', 'site-reviews');
254
+		}
255
+		return '<h3>'.$value.'</h3>';
256
+	}
257 257
 
258
-    /**
259
-     * @param string $avatarUrl
260
-     * @return string
261
-     */
262
-    protected function generateAvatar($avatarUrl)
263
-    {
264
-        if (!$this->isOptionEnabled('settings.reviews.avatars_regenerate') || 'local' != $this->current->review_type) {
265
-            return $avatarUrl;
266
-        }
267
-        $authorIdOrEmail = get_the_author_meta('ID', $this->current->user_id);
268
-        if (empty($authorIdOrEmail)) {
269
-            $authorIdOrEmail = $this->current->email;
270
-        }
271
-        if ($newAvatar = get_avatar_url($authorIdOrEmail)) {
272
-            return $newAvatar;
273
-        }
274
-        return $avatarUrl;
275
-    }
258
+	/**
259
+	 * @param string $avatarUrl
260
+	 * @return string
261
+	 */
262
+	protected function generateAvatar($avatarUrl)
263
+	{
264
+		if (!$this->isOptionEnabled('settings.reviews.avatars_regenerate') || 'local' != $this->current->review_type) {
265
+			return $avatarUrl;
266
+		}
267
+		$authorIdOrEmail = get_the_author_meta('ID', $this->current->user_id);
268
+		if (empty($authorIdOrEmail)) {
269
+			$authorIdOrEmail = $this->current->email;
270
+		}
271
+		if ($newAvatar = get_avatar_url($authorIdOrEmail)) {
272
+			return $newAvatar;
273
+		}
274
+		return $avatarUrl;
275
+	}
276 276
 
277
-    /**
278
-     * @param string $text
279
-     * @return string
280
-     */
281
-    protected function getExcerpt($text)
282
-    {
283
-        $limit = intval($this->getOption('settings.reviews.excerpts_length', 55));
284
-        $split = extension_loaded('intl')
285
-            ? $this->getExcerptIntlSplit($text, $limit)
286
-            : $this->getExcerptSplit($text, $limit);
287
-        $hiddenText = substr($text, $split);
288
-        if (!empty($hiddenText)) {
289
-            $showMore = glsr(Builder::class)->span($hiddenText, [
290
-                'class' => 'glsr-hidden glsr-hidden-text',
291
-                'data-show-less' => __('Show less', 'site-reviews'),
292
-                'data-show-more' => __('Show more', 'site-reviews'),
293
-            ]);
294
-            $text = ltrim(substr($text, 0, $split)).$showMore;
295
-        }
296
-        return $text;
297
-    }
277
+	/**
278
+	 * @param string $text
279
+	 * @return string
280
+	 */
281
+	protected function getExcerpt($text)
282
+	{
283
+		$limit = intval($this->getOption('settings.reviews.excerpts_length', 55));
284
+		$split = extension_loaded('intl')
285
+			? $this->getExcerptIntlSplit($text, $limit)
286
+			: $this->getExcerptSplit($text, $limit);
287
+		$hiddenText = substr($text, $split);
288
+		if (!empty($hiddenText)) {
289
+			$showMore = glsr(Builder::class)->span($hiddenText, [
290
+				'class' => 'glsr-hidden glsr-hidden-text',
291
+				'data-show-less' => __('Show less', 'site-reviews'),
292
+				'data-show-more' => __('Show more', 'site-reviews'),
293
+			]);
294
+			$text = ltrim(substr($text, 0, $split)).$showMore;
295
+		}
296
+		return $text;
297
+	}
298 298
 
299
-    /**
300
-     * @param string $text
301
-     * @param int $limit
302
-     * @return int
303
-     */
304
-    protected function getExcerptIntlSplit($text, $limit)
305
-    {
306
-        $words = IntlRuleBasedBreakIterator::createWordInstance('');
307
-        $words->setText($text);
308
-        $count = 0;
309
-        foreach ($words as $offset) {
310
-            if (IntlRuleBasedBreakIterator::WORD_NONE === $words->getRuleStatus()) {
311
-                continue;
312
-            }
313
-            ++$count;
314
-            if ($count != $limit) {
315
-                continue;
316
-            }
317
-            return $offset;
318
-        }
319
-        return strlen($text);
320
-    }
299
+	/**
300
+	 * @param string $text
301
+	 * @param int $limit
302
+	 * @return int
303
+	 */
304
+	protected function getExcerptIntlSplit($text, $limit)
305
+	{
306
+		$words = IntlRuleBasedBreakIterator::createWordInstance('');
307
+		$words->setText($text);
308
+		$count = 0;
309
+		foreach ($words as $offset) {
310
+			if (IntlRuleBasedBreakIterator::WORD_NONE === $words->getRuleStatus()) {
311
+				continue;
312
+			}
313
+			++$count;
314
+			if ($count != $limit) {
315
+				continue;
316
+			}
317
+			return $offset;
318
+		}
319
+		return strlen($text);
320
+	}
321 321
 
322
-    /**
323
-     * @param string $text
324
-     * @param int $limit
325
-     * @return int
326
-     */
327
-    protected function getExcerptSplit($text, $limit)
328
-    {
329
-        if (str_word_count($text, 0) > $limit) {
330
-            $words = array_keys(str_word_count($text, 2));
331
-            return $words[$limit];
332
-        }
333
-        return strlen($text);
334
-    }
322
+	/**
323
+	 * @param string $text
324
+	 * @param int $limit
325
+	 * @return int
326
+	 */
327
+	protected function getExcerptSplit($text, $limit)
328
+	{
329
+		if (str_word_count($text, 0) > $limit) {
330
+			$words = array_keys(str_word_count($text, 2));
331
+			return $words[$limit];
332
+		}
333
+		return strlen($text);
334
+	}
335 335
 
336
-    /**
337
-     * @param string $path
338
-     * @param mixed $fallback
339
-     * @return mixed
340
-     */
341
-    protected function getOption($path, $fallback = '')
342
-    {
343
-        if (array_key_exists($path, $this->options)) {
344
-            return $this->options[$path];
345
-        }
346
-        return $fallback;
347
-    }
336
+	/**
337
+	 * @param string $path
338
+	 * @param mixed $fallback
339
+	 * @return mixed
340
+	 */
341
+	protected function getOption($path, $fallback = '')
342
+	{
343
+		if (array_key_exists($path, $this->options)) {
344
+			return $this->options[$path];
345
+		}
346
+		return $fallback;
347
+	}
348 348
 
349
-    /**
350
-     * @param string $key
351
-     * @param string $value
352
-     * @return bool
353
-     */
354
-    protected function isHiddenOrEmpty($key, $value)
355
-    {
356
-        return $this->isHidden($key) || empty($value);
357
-    }
349
+	/**
350
+	 * @param string $key
351
+	 * @param string $value
352
+	 * @return bool
353
+	 */
354
+	protected function isHiddenOrEmpty($key, $value)
355
+	{
356
+		return $this->isHidden($key) || empty($value);
357
+	}
358 358
 
359
-    /**
360
-     * @param string $path
361
-     * @return bool
362
-     */
363
-    protected function isOptionEnabled($path)
364
-    {
365
-        return 'yes' == $this->getOption($path);
366
-    }
359
+	/**
360
+	 * @param string $path
361
+	 * @return bool
362
+	 */
363
+	protected function isOptionEnabled($path)
364
+	{
365
+		return 'yes' == $this->getOption($path);
366
+	}
367 367
 
368
-    /**
369
-     * @param string $text
370
-     * @return string
371
-     */
372
-    protected function normalizeText($text)
373
-    {
374
-        $text = wp_kses($text, wp_kses_allowed_html());
375
-        $text = convert_smilies(strip_shortcodes($text));
376
-        $text = str_replace(']]>', ']]&gt;', $text);
377
-        $text = preg_replace('/(\R){2,}/', '$1', $text);
378
-        if ($this->isOptionEnabled('settings.reviews.excerpts')) {
379
-            $text = $this->getExcerpt($text);
380
-        }
381
-        return wptexturize(nl2br($text));
382
-    }
368
+	/**
369
+	 * @param string $text
370
+	 * @return string
371
+	 */
372
+	protected function normalizeText($text)
373
+	{
374
+		$text = wp_kses($text, wp_kses_allowed_html());
375
+		$text = convert_smilies(strip_shortcodes($text));
376
+		$text = str_replace(']]>', ']]&gt;', $text);
377
+		$text = preg_replace('/(\R){2,}/', '$1', $text);
378
+		if ($this->isOptionEnabled('settings.reviews.excerpts')) {
379
+			$text = $this->getExcerpt($text);
380
+		}
381
+		return wptexturize(nl2br($text));
382
+	}
383 383
 
384
-    /**
385
-     * @return void
386
-     */
387
-    protected function wrap(array &$renderedFields, Review $review)
388
-    {
389
-        $renderedFields = apply_filters('site-reviews/review/wrap', $renderedFields, $review, $this);
390
-        array_walk($renderedFields, function (&$value, $key) use ($review) {
391
-            $value = apply_filters('site-reviews/review/wrap/'.$key, $value, $review);
392
-            if (empty($value)) {
393
-                return;
394
-            }
395
-            $value = glsr(Builder::class)->div($value, [
396
-                'class' => 'glsr-review-'.$key,
397
-            ]);
398
-        });
399
-    }
384
+	/**
385
+	 * @return void
386
+	 */
387
+	protected function wrap(array &$renderedFields, Review $review)
388
+	{
389
+		$renderedFields = apply_filters('site-reviews/review/wrap', $renderedFields, $review, $this);
390
+		array_walk($renderedFields, function (&$value, $key) use ($review) {
391
+			$value = apply_filters('site-reviews/review/wrap/'.$key, $value, $review);
392
+			if (empty($value)) {
393
+				return;
394
+			}
395
+			$value = glsr(Builder::class)->div($value, [
396
+				'class' => 'glsr-review-'.$key,
397
+			]);
398
+		});
399
+	}
400 400
 }
Please login to merge, or discard this patch.
config/settings.php 1 patch
Indentation   +548 added lines, -548 removed lines patch added patch discarded remove patch
@@ -1,552 +1,552 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 return [
4
-    'settings.general.style' => [
5
-        'default' => 'default',
6
-        'description' => __('Site Reviews relies on the CSS of your theme to style the submission form. If your theme does not provide proper CSS rules for form elements and you are using a WordPress plugin/theme or CSS Framework listed here, please try selecting it, otherwise choose "Site Reviews (default)".', 'site-reviews'),
7
-        'label' => __('Plugin Style', 'site-reviews'),
8
-        'options' => [
9
-            'bootstrap_4' => 'CSS Framework: Bootstrap 4',
10
-            'bootstrap_4_custom' => 'CSS Framework: Bootstrap 4 (Custom Forms)',
11
-            'contact_form_7' => 'Plugin: Contact Form 7 (v5)',
12
-            'ninja_forms' => 'Plugin: Ninja Forms (v3)',
13
-            'wpforms' => 'Plugin: WPForms Lite (v1)',
14
-            'default' => __('Site Reviews (default)', 'site-reviews'),
15
-            'minimal' => __('Site Reviews (minimal)', 'site-reviews'),
16
-            'divi' => 'Theme: Divi (v3)',
17
-            'materialize' => 'Theme: Materialize',
18
-            'twentyfifteen' => 'Theme: Twenty Fifteen',
19
-            'twentyseventeen' => 'Theme: Twenty Seventeen',
20
-            'twentynineteen' => 'Theme: Twenty Nineteen',
21
-        ],
22
-        'type' => 'select',
23
-    ],
24
-    'settings.general.require.approval' => [
25
-        'default' => 'no',
26
-        'description' => __('Set the status of new review submissions to "unapproved".', 'site-reviews'),
27
-        'label' => __('Require Approval', 'site-reviews'),
28
-        'type' => 'yes_no',
29
-    ],
30
-    'settings.general.require.login' => [
31
-        'default' => 'no',
32
-        'description' => __('Only allow review submissions from registered users.', 'site-reviews'),
33
-        'label' => __('Require Login', 'site-reviews'),
34
-        'type' => 'yes_no',
35
-    ],
36
-    'settings.general.require.login_register' => [
37
-        'default' => 'no',
38
-        'depends_on' => [
39
-            'settings.general.require.login' => 'yes',
40
-        ],
41
-        'description' => sprintf(__('Show a link for a new user to register. The %s Membership option must be enabled in General Settings for this to work.', 'site-reviews'),
42
-            '<a href="'.admin_url('options-general.php#users_can_register').'">'.__('Anyone can register', 'site-reviews').'</a>'
43
-        ),
44
-        'label' => __('Show Registration Link', 'site-reviews'),
45
-        'type' => 'yes_no',
46
-    ],
47
-    'settings.general.multilingual' => [
48
-        'default' => '',
49
-        'description' => __('Integrate with a multilingual plugin to calculate ratings for all languages of a post.', 'site-reviews'),
50
-        'label' => __('Multilingual', 'site-reviews'),
51
-        'options' => [
52
-            '' => __('No Integration', 'site-reviews'),
53
-            'polylang' => __('Integrate with Polylang', 'site-reviews'),
54
-            'wpml' => __('Integrate with WPML', 'site-reviews'),
55
-        ],
56
-        'type' => 'select',
57
-    ],
58
-    'settings.general.rebusify' => [
59
-        'default' => 'no',
60
-        'description' => sprintf(__('Integrate with the %s and validate your reviews on the blockchain to increase online reputation, trust, and transparency.', 'site-reviews'),
61
-            '<a href="https://rebusify.com/plans?ref=105" target="_blank">Rebusify Confidence System</a>'
62
-        ),
63
-        'label' => __('Blockchain Validation', 'site-reviews'),
64
-        'type' => 'yes_no',
65
-    ],
66
-    'settings.general.rebusify_email' => [
67
-        'default' => '',
68
-        'depends_on' => [
69
-            'settings.general.rebusify' => ['yes'],
70
-        ],
71
-        'description' => __('Enter your Rebusify account email here.', 'site-reviews'),
72
-        'label' => __('Rebusify Email', 'site-reviews'),
73
-        'type' => 'email',
74
-    ],
75
-    'settings.general.rebusify_serial' => [
76
-        'default' => '',
77
-        'depends_on' => [
78
-            'settings.general.rebusify' => ['yes'],
79
-        ],
80
-        'description' => __('Enter your Rebusify account serial key here.', 'site-reviews'),
81
-        'label' => __('Rebusify Serial Key', 'site-reviews'),
82
-        'type' => 'password',
83
-    ],
84
-    'settings.general.notifications' => [
85
-        'default' => [],
86
-        'label' => __('Notifications', 'site-reviews'),
87
-        'options' => [
88
-            'admin' => __('Send to administrator', 'site-reviews').' <code>'.(string) get_option('admin_email').'</code>',
89
-            'author' => __('Send to author of the page that the review is assigned to', 'site-reviews'),
90
-            'custom' => __('Send to one or more email addresses', 'site-reviews'),
91
-            'slack' => __('Send to <a href="https://slack.com/">Slack</a>', 'site-reviews'),
92
-        ],
93
-        'type' => 'checkbox',
94
-    ],
95
-    'settings.general.notification_email' => [
96
-        'default' => '',
97
-        'depends_on' => [
98
-            'settings.general.notifications' => ['custom'],
99
-        ],
100
-        'label' => __('Send Notification Emails To', 'site-reviews'),
101
-        'placeholder' => __('Separate multiple emails with a comma', 'site-reviews'),
102
-        'type' => 'text',
103
-    ],
104
-    'settings.general.notification_slack' => [
105
-        'default' => '',
106
-        'depends_on' => [
107
-            'settings.general.notifications' => ['slack'],
108
-        ],
109
-        'description' => sprintf(__('To send notifications to Slack, create a new %s and then paste the provided Webhook URL in the field above.', 'site-reviews'),
110
-            '<a href="https://api.slack.com/incoming-webhooks">'.__('Incoming WebHook', 'site-reviews').'</a>'
111
-        ),
112
-        'label' => __('Slack Webhook URL', 'site-reviews'),
113
-        'type' => 'text',
114
-    ],
115
-    'settings.general.notification_message' => [
116
-        'default' => glsr('Modules\Html\Template')->build('templates/email-notification'),
117
-        'depends_on' => [
118
-            'settings.general.notifications' => ['admin', 'author', 'custom', 'slack'],
119
-        ],
120
-        'description' => __(
121
-            'To restore the default text, save an empty template. '.
122
-            'If you are sending notifications to Slack then this template will only be used as a fallback in the event that <a href="https://api.slack.com/docs/attachments">Message Attachments</a> have been disabled. Available template tags:'.
123
-            '<br><code>{review_rating}</code> The review rating number (1-5)'.
124
-            '<br><code>{review_title}</code> The review title'.
125
-            '<br><code>{review_content}</code> The review content'.
126
-            '<br><code>{review_author}</code> The review author'.
127
-            '<br><code>{review_email}</code> The email of the review author'.
128
-            '<br><code>{review_ip}</code> The IP address of the review author'.
129
-            '<br><code>{review_link}</code> The link to edit/view a review',
130
-            'site-reviews'
131
-        ),
132
-        'label' => __('Notification Template', 'site-reviews'),
133
-        'rows' => 10,
134
-        'type' => 'code',
135
-    ],
136
-    'settings.reviews.date.format' => [
137
-        'default' => '',
138
-        'description' => sprintf(__('The default date format is the one set in your %s.', 'site-reviews'),
139
-            '<a href="'.admin_url('options-general.php#date_format_custom').'">'.__('WordPress settings', 'site-reviews').'</a>'
140
-        ),
141
-        'label' => __('Date Format', 'site-reviews'),
142
-        'options' => [
143
-            '' => __('Use the default date format', 'site-reviews'),
144
-            'relative' => __('Use a relative date format', 'site-reviews'),
145
-            'custom' => __('Use a custom date format', 'site-reviews'),
146
-        ],
147
-        'type' => 'select',
148
-    ],
149
-    'settings.reviews.date.custom' => [
150
-        'default' => get_option('date_format'),
151
-        'depends_on' => [
152
-            'settings.reviews.date.format' => 'custom',
153
-        ],
154
-        'description' => __('Enter a custom date format (<a href="https://codex.wordpress.org/Formatting_Date_and_Time">documentation on date and time formatting</a>).', 'site-reviews'),
155
-        'label' => __('Custom Date Format', 'site-reviews'),
156
-        'type' => 'text',
157
-    ],
158
-    'settings.reviews.name.format' => [
159
-        'default' => '',
160
-        'description' => __('Choose how names are shown in your reviews.', 'site-reviews'),
161
-        'label' => __('Name Format', 'site-reviews'),
162
-        'options' => [
163
-            '' => __('Use the name as given', 'site-reviews'),
164
-            'first' => __('Use the first name only', 'site-reviews'),
165
-            'first_initial' => __('Convert first name to an initial', 'site-reviews'),
166
-            'last_initial' => __('Convert last name to an initial', 'site-reviews'),
167
-            'initials' => __('Convert to all initials', 'site-reviews'),
168
-        ],
169
-        'type' => 'select',
170
-    ],
171
-    'settings.reviews.name.initial' => [
172
-        'default' => '',
173
-        'depends_on' => [
174
-            'settings.reviews.name.format' => ['first_initial', 'last_initial', 'initials'],
175
-        ],
176
-        'description' => __('Choose how the initial is displayed.', 'site-reviews'),
177
-        'label' => __('Initial Format', 'site-reviews'),
178
-        'options' => [
179
-            '' => __('Initial with a space', 'site-reviews'),
180
-            'period' => __('Initial with a period', 'site-reviews'),
181
-            'period_space' => __('Initial with a period and a space', 'site-reviews'),
182
-        ],
183
-        'type' => 'select',
184
-    ],
185
-    'settings.reviews.assigned_links' => [
186
-        'default' => 'no',
187
-        'description' => __('Display a link to the assigned post of a review.', 'site-reviews'),
188
-        'label' => __('Enable Assigned Links', 'site-reviews'),
189
-        'type' => 'yes_no',
190
-    ],
191
-    'settings.reviews.avatars' => [
192
-        'default' => 'no',
193
-        'description' => __('Display reviewer avatars. These are generated from the email address of the reviewer using <a href="https://gravatar.com">Gravatar</a>.', 'site-reviews'),
194
-        'label' => __('Enable Avatars', 'site-reviews'),
195
-        'type' => 'yes_no',
196
-    ],
197
-    'settings.reviews.avatars_regenerate' => [
198
-        'default' => 'no',
199
-        'depends_on' => [
200
-            'settings.reviews.avatars' => 'yes',
201
-        ],
202
-        'description' => __('Regenerate the avatar whenever a local review is shown?', 'site-reviews'),
203
-        'label' => __('Regenerate Avatars', 'site-reviews'),
204
-        'type' => 'yes_no',
205
-    ],
206
-    'settings.reviews.avatars_size' => [
207
-        'default' => 40,
208
-        'depends_on' => [
209
-            'settings.reviews.avatars' => 'yes',
210
-        ],
211
-        'description' => __('Set the avatar size in pixels.', 'site-reviews'),
212
-        'label' => __('Avatar Size', 'site-reviews'),
213
-        'type' => 'number',
214
-    ],
215
-    'settings.reviews.excerpts' => [
216
-        'default' => 'yes',
217
-        'description' => __('Display an excerpt instead of the full review.', 'site-reviews'),
218
-        'label' => __('Enable Excerpts', 'site-reviews'),
219
-        'type' => 'yes_no',
220
-    ],
221
-    'settings.reviews.excerpts_length' => [
222
-        'default' => 55,
223
-        'depends_on' => [
224
-            'settings.reviews.excerpts' => 'yes',
225
-        ],
226
-        'description' => __('Set the excerpt word length.', 'site-reviews'),
227
-        'label' => __('Excerpt Length', 'site-reviews'),
228
-        'type' => 'number',
229
-    ],
230
-    'settings.reviews.fallback' => [
231
-        'default' => 'yes',
232
-        'description' => sprintf(__('Display the fallback text when there are no reviews to display. This can be changed on the %s page. You may also override this by using the "fallback" option on the shortcode. The default fallback text is: %s', 'site-reviews'),
233
-            '<a href="'.admin_url('edit.php?post_type=site-review&page=settings#!translations').'">'.__('Translations', 'site-reviews').'</a>',
234
-            '<code>'.__('There are no reviews yet. Be the first one to write one.', 'site-reviews').'</code>'
235
-        ),
236
-        'label' => __('Enable Fallback Text', 'site-reviews'),
237
-        'type' => 'yes_no',
238
-    ],
239
-    'settings.schema.type.default' => [
240
-        'default' => 'LocalBusiness',
241
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_type</code>',
242
-        'label' => __('Default Schema Type', 'site-reviews'),
243
-        'options' => [
244
-            'LocalBusiness' => __('Local Business', 'site-reviews'),
245
-            'Product' => __('Product', 'site-reviews'),
246
-            'custom' => __('Custom', 'site-reviews'),
247
-        ],
248
-        'type' => 'select',
249
-    ],
250
-    'settings.schema.type.custom' => [
251
-        'default' => '',
252
-        'depends_on' => [
253
-            'settings.schema.type.default' => 'custom',
254
-        ],
255
-        'description' => '<a href="https://schema.org/docs/schemas.html">'.__('View more information on schema types here', 'site-reviews').'</a>',
256
-        'label' => __('Custom Schema Type', 'site-reviews'),
257
-        'type' => 'text',
258
-    ],
259
-    'settings.schema.name.default' => [
260
-        'default' => 'post',
261
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_name</code>',
262
-        'label' => __('Default Name', 'site-reviews'),
263
-        'options' => [
264
-            'post' => __('Use the assigned or current page title', 'site-reviews'),
265
-            'custom' => __('Enter a custom title', 'site-reviews'),
266
-        ],
267
-        'type' => 'select',
268
-    ],
269
-    'settings.schema.name.custom' => [
270
-        'default' => '',
271
-        'depends_on' => [
272
-            'settings.schema.name.default' => 'custom',
273
-        ],
274
-        'label' => __('Custom Name', 'site-reviews'),
275
-        'type' => 'text',
276
-    ],
277
-    'settings.schema.description.default' => [
278
-        'default' => 'post',
279
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_description</code>',
280
-        'label' => __('Default Description', 'site-reviews'),
281
-        'options' => [
282
-            'post' => __('Use the assigned or current page excerpt', 'site-reviews'),
283
-            'custom' => __('Enter a custom description', 'site-reviews'),
284
-        ],
285
-        'type' => 'select',
286
-    ],
287
-    'settings.schema.description.custom' => [
288
-        'default' => '',
289
-        'depends_on' => [
290
-            'settings.schema.description.default' => 'custom',
291
-        ],
292
-        'label' => __('Custom Description', 'site-reviews'),
293
-        'type' => 'text',
294
-    ],
295
-    'settings.schema.url.default' => [
296
-        'default' => 'post',
297
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_url</code>',
298
-        'label' => __('Default URL', 'site-reviews'),
299
-        'options' => [
300
-            'post' => __('Use the assigned or current page URL', 'site-reviews'),
301
-            'custom' => __('Enter a custom URL', 'site-reviews'),
302
-        ],
303
-        'type' => 'select',
304
-    ],
305
-    'settings.schema.url.custom' => [
306
-        'default' => '',
307
-        'depends_on' => [
308
-            'settings.schema.url.default' => 'custom',
309
-        ],
310
-        'label' => __('Custom URL', 'site-reviews'),
311
-        'type' => 'text',
312
-    ],
313
-    'settings.schema.image.default' => [
314
-        'default' => 'post',
315
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_image</code>',
316
-        'label' => __('Default Image', 'site-reviews'),
317
-        'options' => [
318
-            'post' => __('Use the featured image of the assigned or current page', 'site-reviews'),
319
-            'custom' => __('Enter a custom image URL', 'site-reviews'),
320
-        ],
321
-        'type' => 'select',
322
-    ],
323
-    'settings.schema.image.custom' => [
324
-        'default' => '',
325
-        'depends_on' => [
326
-            'settings.schema.image.default' => 'custom',
327
-        ],
328
-        'label' => __('Custom Image URL', 'site-reviews'),
329
-        'type' => 'text',
330
-    ],
331
-    'settings.schema.address' => [
332
-        'default' => '',
333
-        'depends_on' => [
334
-            'settings.schema.type.default' => 'LocalBusiness',
335
-        ],
336
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_address</code>',
337
-        'label' => __('Address', 'site-reviews'),
338
-        'placeholder' => '60 29th Street #343, San Francisco, CA 94110, US',
339
-        'type' => 'text',
340
-    ],
341
-    'settings.schema.telephone' => [
342
-        'default' => '',
343
-        'depends_on' => [
344
-            'settings.schema.type.default' => 'LocalBusiness',
345
-        ],
346
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_telephone</code>',
347
-        'label' => __('Telephone Number', 'site-reviews'),
348
-        'placeholder' => '+1 (877) 273-3049',
349
-        'type' => 'text',
350
-    ],
351
-    'settings.schema.pricerange' => [
352
-        'default' => '',
353
-        'depends_on' => [
354
-            'settings.schema.type.default' => 'LocalBusiness',
355
-        ],
356
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricerange</code>',
357
-        'label' => __('Price Range', 'site-reviews'),
358
-        'placeholder' => '$$-$$$',
359
-        'type' => 'text',
360
-    ],
361
-    'settings.schema.offertype' => [
362
-        'default' => 'AggregateOffer',
363
-        'depends_on' => [
364
-            'settings.schema.type.default' => 'Product',
365
-        ],
366
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_offertype</code>',
367
-        'label' => __('Offer Type', 'site-reviews'),
368
-        'options' => [
369
-            'AggregateOffer' => __('AggregateOffer', 'site-reviews'),
370
-            'Offer' => __('Offer', 'site-reviews'),
371
-        ],
372
-        'type' => 'select',
373
-    ],
374
-    'settings.schema.price' => [
375
-        'default' => '',
376
-        'depends_on' => [
377
-            'settings.schema.type.default' => 'Product',
378
-            'settings.schema.offertype' => 'Offer',
379
-        ],
380
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_price</code>',
381
-        'label' => __('Price', 'site-reviews'),
382
-        'placeholder' => '50.00',
383
-        'type' => 'text',
384
-    ],
385
-    'settings.schema.lowprice' => [
386
-        'default' => '',
387
-        'depends_on' => [
388
-            'settings.schema.type.default' => 'Product',
389
-            'settings.schema.offertype' => 'AggregateOffer',
390
-        ],
391
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_lowprice</code>',
392
-        'label' => __('Low Price', 'site-reviews'),
393
-        'placeholder' => '10.00',
394
-        'type' => 'text',
395
-    ],
396
-    'settings.schema.highprice' => [
397
-        'default' => '',
398
-        'depends_on' => [
399
-            'settings.schema.type.default' => 'Product',
400
-            'settings.schema.offertype' => 'AggregateOffer',
401
-        ],
402
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_highprice</code>',
403
-        'label' => __('High Price', 'site-reviews'),
404
-        'placeholder' => '100.00',
405
-        'type' => 'text',
406
-    ],
407
-    'settings.schema.pricecurrency' => [
408
-        'default' => '',
409
-        'depends_on' => [
410
-            'settings.schema.type.default' => 'Product',
411
-        ],
412
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricecurrency</code>',
413
-        'label' => __('Price Currency', 'site-reviews'),
414
-        'placeholder' => 'USD',
415
-        'type' => 'text',
416
-    ],
417
-    'settings.submissions.required' => [
418
-        'default' => ['content', 'email', 'name', 'rating', 'terms', 'title'],
419
-        'description' => __('Choose which fields should be required in the submission form.', 'site-reviews'),
420
-        'label' => __('Required Fields', 'site-reviews'),
421
-        'options' => [
422
-            'rating' => __('Rating', 'site-reviews'),
423
-            'title' => __('Title', 'site-reviews'),
424
-            'content' => __('Review', 'site-reviews'),
425
-            'name' => __('Name', 'site-reviews'),
426
-            'email' => __('Email', 'site-reviews'),
427
-            'terms' => __('Terms', 'site-reviews'),
428
-        ],
429
-        'type' => 'checkbox',
430
-    ],
431
-    'settings.submissions.limit' => [
432
-        'default' => '',
433
-        'description' => __('Limits the number of reviews that can be submitted to one-per-person. If you are assigning reviews, then the limit will be applied to the assigned page or category.', 'site-reviews'),
434
-        'label' => __('Limit Reviews', 'site-reviews'),
435
-        'options' => [
436
-            '' => __('No Limit', 'site-reviews'),
437
-            'email' => __('By Email Address', 'site-reviews'),
438
-            'ip_address' => __('By IP Address', 'site-reviews'),
439
-            'username' => __('By Username (will only work for registered users)', 'site-reviews'),
440
-        ],
441
-        'type' => 'select',
442
-    ],
443
-    'settings.submissions.limit_whitelist.email' => [
444
-        'default' => '',
445
-        'depends_on' => [
446
-            'settings.submissions.limit' => ['email'],
447
-        ],
448
-        'description' => __('One Email per line. All emails in the whitelist will be excluded from the review submission limit.', 'site-reviews'),
449
-        'label' => __('Email Whitelist', 'site-reviews'),
450
-        'rows' => 5,
451
-        'type' => 'code',
452
-    ],
453
-    'settings.submissions.limit_whitelist.ip_address' => [
454
-        'default' => '',
455
-        'depends_on' => [
456
-            'settings.submissions.limit' => ['ip_address'],
457
-        ],
458
-        'description' => __('One IP Address per line. All IP Addresses in the whitelist will be excluded from the review submission limit..', 'site-reviews'),
459
-        'label' => __('IP Address Whitelist', 'site-reviews'),
460
-        'rows' => 5,
461
-        'type' => 'code',
462
-    ],
463
-    'settings.submissions.limit_whitelist.username' => [
464
-        'default' => '',
465
-        'depends_on' => [
466
-            'settings.submissions.limit' => ['username'],
467
-        ],
468
-        'description' => __('One Username per line. All registered users with a Username in the whitelist will be excluded from the review submission limit.', 'site-reviews'),
469
-        'label' => __('Username Whitelist', 'site-reviews'),
470
-        'rows' => 5,
471
-        'type' => 'code',
472
-    ],
473
-    'settings.submissions.recaptcha.integration' => [
474
-        'default' => '',
475
-        'description' => __('Invisible reCAPTCHA is a free anti-spam service from Google. To use it, you will need to <a href="https://www.google.com/recaptcha/admin" target="_blank">sign up</a> for an API key pair for your site.', 'site-reviews'),
476
-        'label' => __('Invisible reCAPTCHA', 'site-reviews'),
477
-        'options' => [
478
-            '' => 'Do not use reCAPTCHA',
479
-            'all' => 'Use reCAPTCHA',
480
-            'guest' => 'Use reCAPTCHA only for guest users',
481
-        ],
482
-        'type' => 'select',
483
-    ],
484
-    'settings.submissions.recaptcha.key' => [
485
-        'default' => '',
486
-        'depends_on' => [
487
-            'settings.submissions.recaptcha.integration' => ['all', 'guest'],
488
-        ],
489
-        'label' => __('Site Key', 'site-reviews'),
490
-        'type' => 'text',
491
-    ],
492
-    'settings.submissions.recaptcha.secret' => [
493
-        'default' => '',
494
-        'depends_on' => [
495
-            'settings.submissions.recaptcha.integration' => ['all', 'guest'],
496
-        ],
497
-        'label' => __('Site Secret', 'site-reviews'),
498
-        'type' => 'text',
499
-    ],
500
-    'settings.submissions.recaptcha.position' => [
501
-        'default' => 'bottomleft',
502
-        'depends_on' => [
503
-            'settings.submissions.recaptcha.integration' => ['all', 'guest'],
504
-        ],
505
-        'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'),
506
-        'label' => __('Badge Position', 'site-reviews'),
507
-        'options' => [
508
-            'bottomleft' => 'Bottom Left',
509
-            'bottomright' => 'Bottom Right',
510
-            'inline' => 'Inline',
511
-        ],
512
-        'type' => 'select',
513
-    ],
514
-    'settings.submissions.akismet' => [
515
-        'default' => 'no',
516
-        'description' => __('The <a href="https://akismet.com" target="_blank">Akismet plugin</a> integration provides spam-filtering for your reviews. In order for this setting to have any affect, you will need to first install and activate the Akismet plugin and set up a WordPress.com API key.', 'site-reviews'),
517
-        'label' => __('Enable Akismet Integration', 'site-reviews'),
518
-        'type' => 'yes_no',
519
-    ],
520
-    'settings.submissions.blacklist.integration' => [
521
-        'default' => '',
522
-        'description' => sprintf(__('Choose which Blacklist you would prefer to use for reviews. The %s can be found in the WordPress Discussion Settings page.', 'site-reviews'),
523
-            '<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>'
524
-        ),
525
-        'label' => __('Blacklist', 'site-reviews'),
526
-        'options' => [
527
-            '' => 'Use the Site Reviews Blacklist',
528
-            'comments' => 'Use the WordPress Comment Blacklist',
529
-        ],
530
-        'type' => 'select',
531
-    ],
532
-    'settings.submissions.blacklist.entries' => [
533
-        'default' => '',
534
-        'depends_on' => [
535
-            'settings.submissions.blacklist.integration' => [''],
536
-        ],
537
-        'description' => __('One entry or IP address per line. When a review contains any of these entries in its title, content, name, email, or IP address, it will be rejected. It is case-insensitive and will match partial words, so "press" will match "WordPress".', 'site-reviews'),
538
-        'label' => __('Review Blacklist', 'site-reviews'),
539
-        'rows' => 10,
540
-        'type' => 'code',
541
-    ],
542
-    'settings.submissions.blacklist.action' => [
543
-        'default' => 'unapprove',
544
-        'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'),
545
-        'label' => __('Blacklist Action', 'site-reviews'),
546
-        'options' => [
547
-            'unapprove' => __('Require approval', 'site-reviews'),
548
-            'reject' => __('Reject submission', 'site-reviews'),
549
-        ],
550
-        'type' => 'select',
551
-    ],
4
+	'settings.general.style' => [
5
+		'default' => 'default',
6
+		'description' => __('Site Reviews relies on the CSS of your theme to style the submission form. If your theme does not provide proper CSS rules for form elements and you are using a WordPress plugin/theme or CSS Framework listed here, please try selecting it, otherwise choose "Site Reviews (default)".', 'site-reviews'),
7
+		'label' => __('Plugin Style', 'site-reviews'),
8
+		'options' => [
9
+			'bootstrap_4' => 'CSS Framework: Bootstrap 4',
10
+			'bootstrap_4_custom' => 'CSS Framework: Bootstrap 4 (Custom Forms)',
11
+			'contact_form_7' => 'Plugin: Contact Form 7 (v5)',
12
+			'ninja_forms' => 'Plugin: Ninja Forms (v3)',
13
+			'wpforms' => 'Plugin: WPForms Lite (v1)',
14
+			'default' => __('Site Reviews (default)', 'site-reviews'),
15
+			'minimal' => __('Site Reviews (minimal)', 'site-reviews'),
16
+			'divi' => 'Theme: Divi (v3)',
17
+			'materialize' => 'Theme: Materialize',
18
+			'twentyfifteen' => 'Theme: Twenty Fifteen',
19
+			'twentyseventeen' => 'Theme: Twenty Seventeen',
20
+			'twentynineteen' => 'Theme: Twenty Nineteen',
21
+		],
22
+		'type' => 'select',
23
+	],
24
+	'settings.general.require.approval' => [
25
+		'default' => 'no',
26
+		'description' => __('Set the status of new review submissions to "unapproved".', 'site-reviews'),
27
+		'label' => __('Require Approval', 'site-reviews'),
28
+		'type' => 'yes_no',
29
+	],
30
+	'settings.general.require.login' => [
31
+		'default' => 'no',
32
+		'description' => __('Only allow review submissions from registered users.', 'site-reviews'),
33
+		'label' => __('Require Login', 'site-reviews'),
34
+		'type' => 'yes_no',
35
+	],
36
+	'settings.general.require.login_register' => [
37
+		'default' => 'no',
38
+		'depends_on' => [
39
+			'settings.general.require.login' => 'yes',
40
+		],
41
+		'description' => sprintf(__('Show a link for a new user to register. The %s Membership option must be enabled in General Settings for this to work.', 'site-reviews'),
42
+			'<a href="'.admin_url('options-general.php#users_can_register').'">'.__('Anyone can register', 'site-reviews').'</a>'
43
+		),
44
+		'label' => __('Show Registration Link', 'site-reviews'),
45
+		'type' => 'yes_no',
46
+	],
47
+	'settings.general.multilingual' => [
48
+		'default' => '',
49
+		'description' => __('Integrate with a multilingual plugin to calculate ratings for all languages of a post.', 'site-reviews'),
50
+		'label' => __('Multilingual', 'site-reviews'),
51
+		'options' => [
52
+			'' => __('No Integration', 'site-reviews'),
53
+			'polylang' => __('Integrate with Polylang', 'site-reviews'),
54
+			'wpml' => __('Integrate with WPML', 'site-reviews'),
55
+		],
56
+		'type' => 'select',
57
+	],
58
+	'settings.general.rebusify' => [
59
+		'default' => 'no',
60
+		'description' => sprintf(__('Integrate with the %s and validate your reviews on the blockchain to increase online reputation, trust, and transparency.', 'site-reviews'),
61
+			'<a href="https://rebusify.com/plans?ref=105" target="_blank">Rebusify Confidence System</a>'
62
+		),
63
+		'label' => __('Blockchain Validation', 'site-reviews'),
64
+		'type' => 'yes_no',
65
+	],
66
+	'settings.general.rebusify_email' => [
67
+		'default' => '',
68
+		'depends_on' => [
69
+			'settings.general.rebusify' => ['yes'],
70
+		],
71
+		'description' => __('Enter your Rebusify account email here.', 'site-reviews'),
72
+		'label' => __('Rebusify Email', 'site-reviews'),
73
+		'type' => 'email',
74
+	],
75
+	'settings.general.rebusify_serial' => [
76
+		'default' => '',
77
+		'depends_on' => [
78
+			'settings.general.rebusify' => ['yes'],
79
+		],
80
+		'description' => __('Enter your Rebusify account serial key here.', 'site-reviews'),
81
+		'label' => __('Rebusify Serial Key', 'site-reviews'),
82
+		'type' => 'password',
83
+	],
84
+	'settings.general.notifications' => [
85
+		'default' => [],
86
+		'label' => __('Notifications', 'site-reviews'),
87
+		'options' => [
88
+			'admin' => __('Send to administrator', 'site-reviews').' <code>'.(string) get_option('admin_email').'</code>',
89
+			'author' => __('Send to author of the page that the review is assigned to', 'site-reviews'),
90
+			'custom' => __('Send to one or more email addresses', 'site-reviews'),
91
+			'slack' => __('Send to <a href="https://slack.com/">Slack</a>', 'site-reviews'),
92
+		],
93
+		'type' => 'checkbox',
94
+	],
95
+	'settings.general.notification_email' => [
96
+		'default' => '',
97
+		'depends_on' => [
98
+			'settings.general.notifications' => ['custom'],
99
+		],
100
+		'label' => __('Send Notification Emails To', 'site-reviews'),
101
+		'placeholder' => __('Separate multiple emails with a comma', 'site-reviews'),
102
+		'type' => 'text',
103
+	],
104
+	'settings.general.notification_slack' => [
105
+		'default' => '',
106
+		'depends_on' => [
107
+			'settings.general.notifications' => ['slack'],
108
+		],
109
+		'description' => sprintf(__('To send notifications to Slack, create a new %s and then paste the provided Webhook URL in the field above.', 'site-reviews'),
110
+			'<a href="https://api.slack.com/incoming-webhooks">'.__('Incoming WebHook', 'site-reviews').'</a>'
111
+		),
112
+		'label' => __('Slack Webhook URL', 'site-reviews'),
113
+		'type' => 'text',
114
+	],
115
+	'settings.general.notification_message' => [
116
+		'default' => glsr('Modules\Html\Template')->build('templates/email-notification'),
117
+		'depends_on' => [
118
+			'settings.general.notifications' => ['admin', 'author', 'custom', 'slack'],
119
+		],
120
+		'description' => __(
121
+			'To restore the default text, save an empty template. '.
122
+			'If you are sending notifications to Slack then this template will only be used as a fallback in the event that <a href="https://api.slack.com/docs/attachments">Message Attachments</a> have been disabled. Available template tags:'.
123
+			'<br><code>{review_rating}</code> The review rating number (1-5)'.
124
+			'<br><code>{review_title}</code> The review title'.
125
+			'<br><code>{review_content}</code> The review content'.
126
+			'<br><code>{review_author}</code> The review author'.
127
+			'<br><code>{review_email}</code> The email of the review author'.
128
+			'<br><code>{review_ip}</code> The IP address of the review author'.
129
+			'<br><code>{review_link}</code> The link to edit/view a review',
130
+			'site-reviews'
131
+		),
132
+		'label' => __('Notification Template', 'site-reviews'),
133
+		'rows' => 10,
134
+		'type' => 'code',
135
+	],
136
+	'settings.reviews.date.format' => [
137
+		'default' => '',
138
+		'description' => sprintf(__('The default date format is the one set in your %s.', 'site-reviews'),
139
+			'<a href="'.admin_url('options-general.php#date_format_custom').'">'.__('WordPress settings', 'site-reviews').'</a>'
140
+		),
141
+		'label' => __('Date Format', 'site-reviews'),
142
+		'options' => [
143
+			'' => __('Use the default date format', 'site-reviews'),
144
+			'relative' => __('Use a relative date format', 'site-reviews'),
145
+			'custom' => __('Use a custom date format', 'site-reviews'),
146
+		],
147
+		'type' => 'select',
148
+	],
149
+	'settings.reviews.date.custom' => [
150
+		'default' => get_option('date_format'),
151
+		'depends_on' => [
152
+			'settings.reviews.date.format' => 'custom',
153
+		],
154
+		'description' => __('Enter a custom date format (<a href="https://codex.wordpress.org/Formatting_Date_and_Time">documentation on date and time formatting</a>).', 'site-reviews'),
155
+		'label' => __('Custom Date Format', 'site-reviews'),
156
+		'type' => 'text',
157
+	],
158
+	'settings.reviews.name.format' => [
159
+		'default' => '',
160
+		'description' => __('Choose how names are shown in your reviews.', 'site-reviews'),
161
+		'label' => __('Name Format', 'site-reviews'),
162
+		'options' => [
163
+			'' => __('Use the name as given', 'site-reviews'),
164
+			'first' => __('Use the first name only', 'site-reviews'),
165
+			'first_initial' => __('Convert first name to an initial', 'site-reviews'),
166
+			'last_initial' => __('Convert last name to an initial', 'site-reviews'),
167
+			'initials' => __('Convert to all initials', 'site-reviews'),
168
+		],
169
+		'type' => 'select',
170
+	],
171
+	'settings.reviews.name.initial' => [
172
+		'default' => '',
173
+		'depends_on' => [
174
+			'settings.reviews.name.format' => ['first_initial', 'last_initial', 'initials'],
175
+		],
176
+		'description' => __('Choose how the initial is displayed.', 'site-reviews'),
177
+		'label' => __('Initial Format', 'site-reviews'),
178
+		'options' => [
179
+			'' => __('Initial with a space', 'site-reviews'),
180
+			'period' => __('Initial with a period', 'site-reviews'),
181
+			'period_space' => __('Initial with a period and a space', 'site-reviews'),
182
+		],
183
+		'type' => 'select',
184
+	],
185
+	'settings.reviews.assigned_links' => [
186
+		'default' => 'no',
187
+		'description' => __('Display a link to the assigned post of a review.', 'site-reviews'),
188
+		'label' => __('Enable Assigned Links', 'site-reviews'),
189
+		'type' => 'yes_no',
190
+	],
191
+	'settings.reviews.avatars' => [
192
+		'default' => 'no',
193
+		'description' => __('Display reviewer avatars. These are generated from the email address of the reviewer using <a href="https://gravatar.com">Gravatar</a>.', 'site-reviews'),
194
+		'label' => __('Enable Avatars', 'site-reviews'),
195
+		'type' => 'yes_no',
196
+	],
197
+	'settings.reviews.avatars_regenerate' => [
198
+		'default' => 'no',
199
+		'depends_on' => [
200
+			'settings.reviews.avatars' => 'yes',
201
+		],
202
+		'description' => __('Regenerate the avatar whenever a local review is shown?', 'site-reviews'),
203
+		'label' => __('Regenerate Avatars', 'site-reviews'),
204
+		'type' => 'yes_no',
205
+	],
206
+	'settings.reviews.avatars_size' => [
207
+		'default' => 40,
208
+		'depends_on' => [
209
+			'settings.reviews.avatars' => 'yes',
210
+		],
211
+		'description' => __('Set the avatar size in pixels.', 'site-reviews'),
212
+		'label' => __('Avatar Size', 'site-reviews'),
213
+		'type' => 'number',
214
+	],
215
+	'settings.reviews.excerpts' => [
216
+		'default' => 'yes',
217
+		'description' => __('Display an excerpt instead of the full review.', 'site-reviews'),
218
+		'label' => __('Enable Excerpts', 'site-reviews'),
219
+		'type' => 'yes_no',
220
+	],
221
+	'settings.reviews.excerpts_length' => [
222
+		'default' => 55,
223
+		'depends_on' => [
224
+			'settings.reviews.excerpts' => 'yes',
225
+		],
226
+		'description' => __('Set the excerpt word length.', 'site-reviews'),
227
+		'label' => __('Excerpt Length', 'site-reviews'),
228
+		'type' => 'number',
229
+	],
230
+	'settings.reviews.fallback' => [
231
+		'default' => 'yes',
232
+		'description' => sprintf(__('Display the fallback text when there are no reviews to display. This can be changed on the %s page. You may also override this by using the "fallback" option on the shortcode. The default fallback text is: %s', 'site-reviews'),
233
+			'<a href="'.admin_url('edit.php?post_type=site-review&page=settings#!translations').'">'.__('Translations', 'site-reviews').'</a>',
234
+			'<code>'.__('There are no reviews yet. Be the first one to write one.', 'site-reviews').'</code>'
235
+		),
236
+		'label' => __('Enable Fallback Text', 'site-reviews'),
237
+		'type' => 'yes_no',
238
+	],
239
+	'settings.schema.type.default' => [
240
+		'default' => 'LocalBusiness',
241
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_type</code>',
242
+		'label' => __('Default Schema Type', 'site-reviews'),
243
+		'options' => [
244
+			'LocalBusiness' => __('Local Business', 'site-reviews'),
245
+			'Product' => __('Product', 'site-reviews'),
246
+			'custom' => __('Custom', 'site-reviews'),
247
+		],
248
+		'type' => 'select',
249
+	],
250
+	'settings.schema.type.custom' => [
251
+		'default' => '',
252
+		'depends_on' => [
253
+			'settings.schema.type.default' => 'custom',
254
+		],
255
+		'description' => '<a href="https://schema.org/docs/schemas.html">'.__('View more information on schema types here', 'site-reviews').'</a>',
256
+		'label' => __('Custom Schema Type', 'site-reviews'),
257
+		'type' => 'text',
258
+	],
259
+	'settings.schema.name.default' => [
260
+		'default' => 'post',
261
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_name</code>',
262
+		'label' => __('Default Name', 'site-reviews'),
263
+		'options' => [
264
+			'post' => __('Use the assigned or current page title', 'site-reviews'),
265
+			'custom' => __('Enter a custom title', 'site-reviews'),
266
+		],
267
+		'type' => 'select',
268
+	],
269
+	'settings.schema.name.custom' => [
270
+		'default' => '',
271
+		'depends_on' => [
272
+			'settings.schema.name.default' => 'custom',
273
+		],
274
+		'label' => __('Custom Name', 'site-reviews'),
275
+		'type' => 'text',
276
+	],
277
+	'settings.schema.description.default' => [
278
+		'default' => 'post',
279
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_description</code>',
280
+		'label' => __('Default Description', 'site-reviews'),
281
+		'options' => [
282
+			'post' => __('Use the assigned or current page excerpt', 'site-reviews'),
283
+			'custom' => __('Enter a custom description', 'site-reviews'),
284
+		],
285
+		'type' => 'select',
286
+	],
287
+	'settings.schema.description.custom' => [
288
+		'default' => '',
289
+		'depends_on' => [
290
+			'settings.schema.description.default' => 'custom',
291
+		],
292
+		'label' => __('Custom Description', 'site-reviews'),
293
+		'type' => 'text',
294
+	],
295
+	'settings.schema.url.default' => [
296
+		'default' => 'post',
297
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_url</code>',
298
+		'label' => __('Default URL', 'site-reviews'),
299
+		'options' => [
300
+			'post' => __('Use the assigned or current page URL', 'site-reviews'),
301
+			'custom' => __('Enter a custom URL', 'site-reviews'),
302
+		],
303
+		'type' => 'select',
304
+	],
305
+	'settings.schema.url.custom' => [
306
+		'default' => '',
307
+		'depends_on' => [
308
+			'settings.schema.url.default' => 'custom',
309
+		],
310
+		'label' => __('Custom URL', 'site-reviews'),
311
+		'type' => 'text',
312
+	],
313
+	'settings.schema.image.default' => [
314
+		'default' => 'post',
315
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_image</code>',
316
+		'label' => __('Default Image', 'site-reviews'),
317
+		'options' => [
318
+			'post' => __('Use the featured image of the assigned or current page', 'site-reviews'),
319
+			'custom' => __('Enter a custom image URL', 'site-reviews'),
320
+		],
321
+		'type' => 'select',
322
+	],
323
+	'settings.schema.image.custom' => [
324
+		'default' => '',
325
+		'depends_on' => [
326
+			'settings.schema.image.default' => 'custom',
327
+		],
328
+		'label' => __('Custom Image URL', 'site-reviews'),
329
+		'type' => 'text',
330
+	],
331
+	'settings.schema.address' => [
332
+		'default' => '',
333
+		'depends_on' => [
334
+			'settings.schema.type.default' => 'LocalBusiness',
335
+		],
336
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_address</code>',
337
+		'label' => __('Address', 'site-reviews'),
338
+		'placeholder' => '60 29th Street #343, San Francisco, CA 94110, US',
339
+		'type' => 'text',
340
+	],
341
+	'settings.schema.telephone' => [
342
+		'default' => '',
343
+		'depends_on' => [
344
+			'settings.schema.type.default' => 'LocalBusiness',
345
+		],
346
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_telephone</code>',
347
+		'label' => __('Telephone Number', 'site-reviews'),
348
+		'placeholder' => '+1 (877) 273-3049',
349
+		'type' => 'text',
350
+	],
351
+	'settings.schema.pricerange' => [
352
+		'default' => '',
353
+		'depends_on' => [
354
+			'settings.schema.type.default' => 'LocalBusiness',
355
+		],
356
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricerange</code>',
357
+		'label' => __('Price Range', 'site-reviews'),
358
+		'placeholder' => '$$-$$$',
359
+		'type' => 'text',
360
+	],
361
+	'settings.schema.offertype' => [
362
+		'default' => 'AggregateOffer',
363
+		'depends_on' => [
364
+			'settings.schema.type.default' => 'Product',
365
+		],
366
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_offertype</code>',
367
+		'label' => __('Offer Type', 'site-reviews'),
368
+		'options' => [
369
+			'AggregateOffer' => __('AggregateOffer', 'site-reviews'),
370
+			'Offer' => __('Offer', 'site-reviews'),
371
+		],
372
+		'type' => 'select',
373
+	],
374
+	'settings.schema.price' => [
375
+		'default' => '',
376
+		'depends_on' => [
377
+			'settings.schema.type.default' => 'Product',
378
+			'settings.schema.offertype' => 'Offer',
379
+		],
380
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_price</code>',
381
+		'label' => __('Price', 'site-reviews'),
382
+		'placeholder' => '50.00',
383
+		'type' => 'text',
384
+	],
385
+	'settings.schema.lowprice' => [
386
+		'default' => '',
387
+		'depends_on' => [
388
+			'settings.schema.type.default' => 'Product',
389
+			'settings.schema.offertype' => 'AggregateOffer',
390
+		],
391
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_lowprice</code>',
392
+		'label' => __('Low Price', 'site-reviews'),
393
+		'placeholder' => '10.00',
394
+		'type' => 'text',
395
+	],
396
+	'settings.schema.highprice' => [
397
+		'default' => '',
398
+		'depends_on' => [
399
+			'settings.schema.type.default' => 'Product',
400
+			'settings.schema.offertype' => 'AggregateOffer',
401
+		],
402
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_highprice</code>',
403
+		'label' => __('High Price', 'site-reviews'),
404
+		'placeholder' => '100.00',
405
+		'type' => 'text',
406
+	],
407
+	'settings.schema.pricecurrency' => [
408
+		'default' => '',
409
+		'depends_on' => [
410
+			'settings.schema.type.default' => 'Product',
411
+		],
412
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricecurrency</code>',
413
+		'label' => __('Price Currency', 'site-reviews'),
414
+		'placeholder' => 'USD',
415
+		'type' => 'text',
416
+	],
417
+	'settings.submissions.required' => [
418
+		'default' => ['content', 'email', 'name', 'rating', 'terms', 'title'],
419
+		'description' => __('Choose which fields should be required in the submission form.', 'site-reviews'),
420
+		'label' => __('Required Fields', 'site-reviews'),
421
+		'options' => [
422
+			'rating' => __('Rating', 'site-reviews'),
423
+			'title' => __('Title', 'site-reviews'),
424
+			'content' => __('Review', 'site-reviews'),
425
+			'name' => __('Name', 'site-reviews'),
426
+			'email' => __('Email', 'site-reviews'),
427
+			'terms' => __('Terms', 'site-reviews'),
428
+		],
429
+		'type' => 'checkbox',
430
+	],
431
+	'settings.submissions.limit' => [
432
+		'default' => '',
433
+		'description' => __('Limits the number of reviews that can be submitted to one-per-person. If you are assigning reviews, then the limit will be applied to the assigned page or category.', 'site-reviews'),
434
+		'label' => __('Limit Reviews', 'site-reviews'),
435
+		'options' => [
436
+			'' => __('No Limit', 'site-reviews'),
437
+			'email' => __('By Email Address', 'site-reviews'),
438
+			'ip_address' => __('By IP Address', 'site-reviews'),
439
+			'username' => __('By Username (will only work for registered users)', 'site-reviews'),
440
+		],
441
+		'type' => 'select',
442
+	],
443
+	'settings.submissions.limit_whitelist.email' => [
444
+		'default' => '',
445
+		'depends_on' => [
446
+			'settings.submissions.limit' => ['email'],
447
+		],
448
+		'description' => __('One Email per line. All emails in the whitelist will be excluded from the review submission limit.', 'site-reviews'),
449
+		'label' => __('Email Whitelist', 'site-reviews'),
450
+		'rows' => 5,
451
+		'type' => 'code',
452
+	],
453
+	'settings.submissions.limit_whitelist.ip_address' => [
454
+		'default' => '',
455
+		'depends_on' => [
456
+			'settings.submissions.limit' => ['ip_address'],
457
+		],
458
+		'description' => __('One IP Address per line. All IP Addresses in the whitelist will be excluded from the review submission limit..', 'site-reviews'),
459
+		'label' => __('IP Address Whitelist', 'site-reviews'),
460
+		'rows' => 5,
461
+		'type' => 'code',
462
+	],
463
+	'settings.submissions.limit_whitelist.username' => [
464
+		'default' => '',
465
+		'depends_on' => [
466
+			'settings.submissions.limit' => ['username'],
467
+		],
468
+		'description' => __('One Username per line. All registered users with a Username in the whitelist will be excluded from the review submission limit.', 'site-reviews'),
469
+		'label' => __('Username Whitelist', 'site-reviews'),
470
+		'rows' => 5,
471
+		'type' => 'code',
472
+	],
473
+	'settings.submissions.recaptcha.integration' => [
474
+		'default' => '',
475
+		'description' => __('Invisible reCAPTCHA is a free anti-spam service from Google. To use it, you will need to <a href="https://www.google.com/recaptcha/admin" target="_blank">sign up</a> for an API key pair for your site.', 'site-reviews'),
476
+		'label' => __('Invisible reCAPTCHA', 'site-reviews'),
477
+		'options' => [
478
+			'' => 'Do not use reCAPTCHA',
479
+			'all' => 'Use reCAPTCHA',
480
+			'guest' => 'Use reCAPTCHA only for guest users',
481
+		],
482
+		'type' => 'select',
483
+	],
484
+	'settings.submissions.recaptcha.key' => [
485
+		'default' => '',
486
+		'depends_on' => [
487
+			'settings.submissions.recaptcha.integration' => ['all', 'guest'],
488
+		],
489
+		'label' => __('Site Key', 'site-reviews'),
490
+		'type' => 'text',
491
+	],
492
+	'settings.submissions.recaptcha.secret' => [
493
+		'default' => '',
494
+		'depends_on' => [
495
+			'settings.submissions.recaptcha.integration' => ['all', 'guest'],
496
+		],
497
+		'label' => __('Site Secret', 'site-reviews'),
498
+		'type' => 'text',
499
+	],
500
+	'settings.submissions.recaptcha.position' => [
501
+		'default' => 'bottomleft',
502
+		'depends_on' => [
503
+			'settings.submissions.recaptcha.integration' => ['all', 'guest'],
504
+		],
505
+		'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'),
506
+		'label' => __('Badge Position', 'site-reviews'),
507
+		'options' => [
508
+			'bottomleft' => 'Bottom Left',
509
+			'bottomright' => 'Bottom Right',
510
+			'inline' => 'Inline',
511
+		],
512
+		'type' => 'select',
513
+	],
514
+	'settings.submissions.akismet' => [
515
+		'default' => 'no',
516
+		'description' => __('The <a href="https://akismet.com" target="_blank">Akismet plugin</a> integration provides spam-filtering for your reviews. In order for this setting to have any affect, you will need to first install and activate the Akismet plugin and set up a WordPress.com API key.', 'site-reviews'),
517
+		'label' => __('Enable Akismet Integration', 'site-reviews'),
518
+		'type' => 'yes_no',
519
+	],
520
+	'settings.submissions.blacklist.integration' => [
521
+		'default' => '',
522
+		'description' => sprintf(__('Choose which Blacklist you would prefer to use for reviews. The %s can be found in the WordPress Discussion Settings page.', 'site-reviews'),
523
+			'<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>'
524
+		),
525
+		'label' => __('Blacklist', 'site-reviews'),
526
+		'options' => [
527
+			'' => 'Use the Site Reviews Blacklist',
528
+			'comments' => 'Use the WordPress Comment Blacklist',
529
+		],
530
+		'type' => 'select',
531
+	],
532
+	'settings.submissions.blacklist.entries' => [
533
+		'default' => '',
534
+		'depends_on' => [
535
+			'settings.submissions.blacklist.integration' => [''],
536
+		],
537
+		'description' => __('One entry or IP address per line. When a review contains any of these entries in its title, content, name, email, or IP address, it will be rejected. It is case-insensitive and will match partial words, so "press" will match "WordPress".', 'site-reviews'),
538
+		'label' => __('Review Blacklist', 'site-reviews'),
539
+		'rows' => 10,
540
+		'type' => 'code',
541
+	],
542
+	'settings.submissions.blacklist.action' => [
543
+		'default' => 'unapprove',
544
+		'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'),
545
+		'label' => __('Blacklist Action', 'site-reviews'),
546
+		'options' => [
547
+			'unapprove' => __('Require approval', 'site-reviews'),
548
+			'reject' => __('Reject submission', 'site-reviews'),
549
+		],
550
+		'type' => 'select',
551
+	],
552 552
 ];
Please login to merge, or discard this patch.
plugin/HelperTraits/Str.php 1 patch
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -4,164 +4,164 @@
 block discarded – undo
4 4
 
5 5
 trait Str
6 6
 {
7
-    /**
8
-     * @param string $string
9
-     * @return string
10
-     */
11
-    public function camelCase($string)
12
-    {
13
-        $string = ucwords(str_replace(['-', '_'], ' ', trim($string)));
14
-        return str_replace(' ', '', $string);
15
-    }
7
+	/**
8
+	 * @param string $string
9
+	 * @return string
10
+	 */
11
+	public function camelCase($string)
12
+	{
13
+		$string = ucwords(str_replace(['-', '_'], ' ', trim($string)));
14
+		return str_replace(' ', '', $string);
15
+	}
16 16
 
17
-    /**
18
-     * @param string $name
19
-     * @param string $nameType first|first_initial|initials|last|last_initial
20
-     * @param string $initialType period|period_space|space
21
-     * @return string
22
-     */
23
-    public function convertName($name, $nameType = '', $initialType = '')
24
-    {
25
-        $names = preg_split('/\W/', $name, 0, PREG_SPLIT_NO_EMPTY);
26
-        $firstName = array_shift($names);
27
-        $lastName = array_pop($names);
28
-        $initialTypes = [
29
-            'period' => '.',
30
-            'period_space' => '. ',
31
-            'space' => ' ',
32
-        ];
33
-        $initialPunctuation = glsr_get($initialTypes, $initialType, ' ');
34
-        if ('initials' == $nameType) {
35
-            return $this->convertToInitials($name, $initialPunctuation);
36
-        }
37
-        $nameTypes = [
38
-            'first' => $firstName,
39
-            'first_initial' => substr($firstName, 0, 1).$initialPunctuation.$lastName,
40
-            'last' => $lastName,
41
-            'last_initial' => $firstName.' '.substr($lastName, 0, 1).$initialPunctuation,
42
-        ];
43
-        return trim(glsr_get($nameTypes, $nameType, $name));
44
-    }
17
+	/**
18
+	 * @param string $name
19
+	 * @param string $nameType first|first_initial|initials|last|last_initial
20
+	 * @param string $initialType period|period_space|space
21
+	 * @return string
22
+	 */
23
+	public function convertName($name, $nameType = '', $initialType = '')
24
+	{
25
+		$names = preg_split('/\W/', $name, 0, PREG_SPLIT_NO_EMPTY);
26
+		$firstName = array_shift($names);
27
+		$lastName = array_pop($names);
28
+		$initialTypes = [
29
+			'period' => '.',
30
+			'period_space' => '. ',
31
+			'space' => ' ',
32
+		];
33
+		$initialPunctuation = glsr_get($initialTypes, $initialType, ' ');
34
+		if ('initials' == $nameType) {
35
+			return $this->convertToInitials($name, $initialPunctuation);
36
+		}
37
+		$nameTypes = [
38
+			'first' => $firstName,
39
+			'first_initial' => substr($firstName, 0, 1).$initialPunctuation.$lastName,
40
+			'last' => $lastName,
41
+			'last_initial' => $firstName.' '.substr($lastName, 0, 1).$initialPunctuation,
42
+		];
43
+		return trim(glsr_get($nameTypes, $nameType, $name));
44
+	}
45 45
 
46
-    /**
47
-     * @param string $path
48
-     * @param string $prefix
49
-     * @return string
50
-     */
51
-    public function convertPathToId($path, $prefix = '')
52
-    {
53
-        return str_replace(['[', ']'], ['-', ''], $this->convertPathToName($path, $prefix));
54
-    }
46
+	/**
47
+	 * @param string $path
48
+	 * @param string $prefix
49
+	 * @return string
50
+	 */
51
+	public function convertPathToId($path, $prefix = '')
52
+	{
53
+		return str_replace(['[', ']'], ['-', ''], $this->convertPathToName($path, $prefix));
54
+	}
55 55
 
56
-    /**
57
-     * @param string $path
58
-     * @param string $prefix
59
-     * @return string
60
-     */
61
-    public function convertPathToName($path, $prefix = '')
62
-    {
63
-        $levels = explode('.', $path);
64
-        return array_reduce($levels, function ($result, $value) {
65
-            return $result .= '['.$value.']';
66
-        }, $prefix);
67
-    }
56
+	/**
57
+	 * @param string $path
58
+	 * @param string $prefix
59
+	 * @return string
60
+	 */
61
+	public function convertPathToName($path, $prefix = '')
62
+	{
63
+		$levels = explode('.', $path);
64
+		return array_reduce($levels, function ($result, $value) {
65
+			return $result .= '['.$value.']';
66
+		}, $prefix);
67
+	}
68 68
 
69
-    /**
70
-     * @param string $name
71
-     * @param string $initialPunctuation
72
-     * @return string
73
-     */
74
-    public function convertToInitials($name, $initialPunctuation = '')
75
-    {
76
-        preg_match_all('/(?<=\s|\b)\pL/u', $name, $matches);
77
-        return array_reduce($matches[0], function ($carry, $word) use ($initialPunctuation) {
78
-            return $carry.strtoupper(substr($word, 0, 1)).$initialPunctuation;
79
-        });
80
-    }
69
+	/**
70
+	 * @param string $name
71
+	 * @param string $initialPunctuation
72
+	 * @return string
73
+	 */
74
+	public function convertToInitials($name, $initialPunctuation = '')
75
+	{
76
+		preg_match_all('/(?<=\s|\b)\pL/u', $name, $matches);
77
+		return array_reduce($matches[0], function ($carry, $word) use ($initialPunctuation) {
78
+			return $carry.strtoupper(substr($word, 0, 1)).$initialPunctuation;
79
+		});
80
+	}
81 81
 
82
-    /**
83
-     * @param string $string
84
-     * @return string
85
-     */
86
-    public function dashCase($string)
87
-    {
88
-        return str_replace('_', '-', $this->snakeCase($string));
89
-    }
82
+	/**
83
+	 * @param string $string
84
+	 * @return string
85
+	 */
86
+	public function dashCase($string)
87
+	{
88
+		return str_replace('_', '-', $this->snakeCase($string));
89
+	}
90 90
 
91
-    /**
92
-     * @param string $needle
93
-     * @param string $haystack
94
-     * @return bool
95
-     */
96
-    public function endsWith($needle, $haystack)
97
-    {
98
-        $length = strlen($needle);
99
-        return 0 != $length
100
-            ? substr($haystack, -$length) === $needle
101
-            : true;
102
-    }
91
+	/**
92
+	 * @param string $needle
93
+	 * @param string $haystack
94
+	 * @return bool
95
+	 */
96
+	public function endsWith($needle, $haystack)
97
+	{
98
+		$length = strlen($needle);
99
+		return 0 != $length
100
+			? substr($haystack, -$length) === $needle
101
+			: true;
102
+	}
103 103
 
104
-    /**
105
-     * @param string $prefix
106
-     * @param string $string
107
-     * @param string|null $trim
108
-     * @return string
109
-     */
110
-    public function prefix($prefix, $string, $trim = null)
111
-    {
112
-        if (null === $trim) {
113
-            $trim = $prefix;
114
-        }
115
-        return $prefix.trim($this->removePrefix($trim, $string));
116
-    }
104
+	/**
105
+	 * @param string $prefix
106
+	 * @param string $string
107
+	 * @param string|null $trim
108
+	 * @return string
109
+	 */
110
+	public function prefix($prefix, $string, $trim = null)
111
+	{
112
+		if (null === $trim) {
113
+			$trim = $prefix;
114
+		}
115
+		return $prefix.trim($this->removePrefix($trim, $string));
116
+	}
117 117
 
118
-    /**
119
-     * @param string $prefix
120
-     * @param string $string
121
-     * @return string
122
-     */
123
-    public function removePrefix($prefix, $string)
124
-    {
125
-        return $this->startsWith($prefix, $string)
126
-            ? substr($string, strlen($prefix))
127
-            : $string;
128
-    }
118
+	/**
119
+	 * @param string $prefix
120
+	 * @param string $string
121
+	 * @return string
122
+	 */
123
+	public function removePrefix($prefix, $string)
124
+	{
125
+		return $this->startsWith($prefix, $string)
126
+			? substr($string, strlen($prefix))
127
+			: $string;
128
+	}
129 129
 
130
-    /**
131
-     * @param string $string
132
-     * @return string
133
-     */
134
-    public function snakeCase($string)
135
-    {
136
-        if (!ctype_lower($string)) {
137
-            $string = preg_replace('/\s+/u', '', $string);
138
-            $string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string);
139
-            $string = function_exists('mb_strtolower')
140
-                ? mb_strtolower($string, 'UTF-8')
141
-                : strtolower($string);
142
-        }
143
-        return str_replace('-', '_', $string);
144
-    }
130
+	/**
131
+	 * @param string $string
132
+	 * @return string
133
+	 */
134
+	public function snakeCase($string)
135
+	{
136
+		if (!ctype_lower($string)) {
137
+			$string = preg_replace('/\s+/u', '', $string);
138
+			$string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string);
139
+			$string = function_exists('mb_strtolower')
140
+				? mb_strtolower($string, 'UTF-8')
141
+				: strtolower($string);
142
+		}
143
+		return str_replace('-', '_', $string);
144
+	}
145 145
 
146
-    /**
147
-     * @param string $needle
148
-     * @param string $haystack
149
-     * @return bool
150
-     */
151
-    public function startsWith($needle, $haystack)
152
-    {
153
-        return substr($haystack, 0, strlen($needle)) === $needle;
154
-    }
146
+	/**
147
+	 * @param string $needle
148
+	 * @param string $haystack
149
+	 * @return bool
150
+	 */
151
+	public function startsWith($needle, $haystack)
152
+	{
153
+		return substr($haystack, 0, strlen($needle)) === $needle;
154
+	}
155 155
 
156
-    /**
157
-     * @param string $string
158
-     * @param int $length
159
-     * @return string
160
-     */
161
-    public function truncate($string, $length)
162
-    {
163
-        return strlen($string) > $length
164
-            ? substr($string, 0, $length)
165
-            : $string;
166
-    }
156
+	/**
157
+	 * @param string $string
158
+	 * @param int $length
159
+	 * @return string
160
+	 */
161
+	public function truncate($string, $length)
162
+	{
163
+		return strlen($string) > $length
164
+			? substr($string, 0, $length)
165
+			: $string;
166
+	}
167 167
 }
Please login to merge, or discard this patch.
plugin/Reviews.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -9,65 +9,65 @@
 block discarded – undo
9 9
 
10 10
 class Reviews extends ArrayObject
11 11
 {
12
-    /**
13
-     * @var array
14
-     */
15
-    public $args;
12
+	/**
13
+	 * @var array
14
+	 */
15
+	public $args;
16 16
 
17
-    /**
18
-     * @var int
19
-     */
20
-    public $max_num_pages;
17
+	/**
18
+	 * @var int
19
+	 */
20
+	public $max_num_pages;
21 21
 
22
-    /**
23
-     * @var array
24
-     */
25
-    public $reviews;
22
+	/**
23
+	 * @var array
24
+	 */
25
+	public $reviews;
26 26
 
27
-    public function __construct(array $reviews, $maxPageCount, array $args)
28
-    {
29
-        $this->args = $args;
30
-        $this->max_num_pages = $maxPageCount;
31
-        $this->reviews = $reviews;
32
-        parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
33
-    }
27
+	public function __construct(array $reviews, $maxPageCount, array $args)
28
+	{
29
+		$this->args = $args;
30
+		$this->max_num_pages = $maxPageCount;
31
+		$this->reviews = $reviews;
32
+		parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
33
+	}
34 34
 
35
-    /**
36
-     * @return string
37
-     */
38
-    public function __toString()
39
-    {
40
-        return (string) $this->build();
41
-    }
35
+	/**
36
+	 * @return string
37
+	 */
38
+	public function __toString()
39
+	{
40
+		return (string) $this->build();
41
+	}
42 42
 
43
-    /**
44
-     * @return ReviewsHtml
45
-     */
46
-    public function build()
47
-    {
48
-        $args = glsr(SiteReviewsDefaults::class)->merge($this->args);
49
-        return glsr(SiteReviewsPartial::class)->build($args, $this);
50
-    }
43
+	/**
44
+	 * @return ReviewsHtml
45
+	 */
46
+	public function build()
47
+	{
48
+		$args = glsr(SiteReviewsDefaults::class)->merge($this->args);
49
+		return glsr(SiteReviewsPartial::class)->build($args, $this);
50
+	}
51 51
 
52
-    /**
53
-     * @param mixed $key
54
-     * @return mixed
55
-     */
56
-    public function offsetGet($key)
57
-    {
58
-        if (property_exists($this, $key)) {
59
-            return $this->$key;
60
-        }
61
-        return array_key_exists($key, $this->reviews)
62
-            ? $this->reviews[$key]
63
-            : null;
64
-    }
52
+	/**
53
+	 * @param mixed $key
54
+	 * @return mixed
55
+	 */
56
+	public function offsetGet($key)
57
+	{
58
+		if (property_exists($this, $key)) {
59
+			return $this->$key;
60
+		}
61
+		return array_key_exists($key, $this->reviews)
62
+			? $this->reviews[$key]
63
+			: null;
64
+	}
65 65
 
66
-    /**
67
-     * @return void
68
-     */
69
-    public function render()
70
-    {
71
-        echo $this->build();
72
-    }
66
+	/**
67
+	 * @return void
68
+	 */
69
+	public function render()
70
+	{
71
+		echo $this->build();
72
+	}
73 73
 }
Please login to merge, or discard this patch.
plugin/Controllers/WelcomeController.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -8,99 +8,99 @@
 block discarded – undo
8 8
 
9 9
 class WelcomeController extends Controller
10 10
 {
11
-    /**
12
-     * @return array
13
-     * @filter plugin_action_links_site-reviews/site-reviews.php
14
-     */
15
-    public function filterActionLinks(array $links)
16
-    {
17
-        $links['welcome'] = glsr(Builder::class)->a(__('About', 'site-reviews'), [
18
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome'),
19
-        ]);
20
-        return $links;
21
-    }
11
+	/**
12
+	 * @return array
13
+	 * @filter plugin_action_links_site-reviews/site-reviews.php
14
+	 */
15
+	public function filterActionLinks(array $links)
16
+	{
17
+		$links['welcome'] = glsr(Builder::class)->a(__('About', 'site-reviews'), [
18
+			'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome'),
19
+		]);
20
+		return $links;
21
+	}
22 22
 
23
-    /**
24
-     * @return string
25
-     * @filter admin_title
26
-     */
27
-    public function filterAdminTitle($title)
28
-    {
29
-        return Application::POST_TYPE.'_page_welcome' == glsr_current_screen()->id
30
-            ? sprintf(__('Welcome to %s &#8212; WordPress', 'site-reviews'), glsr()->name)
31
-            : $title;
32
-    }
23
+	/**
24
+	 * @return string
25
+	 * @filter admin_title
26
+	 */
27
+	public function filterAdminTitle($title)
28
+	{
29
+		return Application::POST_TYPE.'_page_welcome' == glsr_current_screen()->id
30
+			? sprintf(__('Welcome to %s &#8212; WordPress', 'site-reviews'), glsr()->name)
31
+			: $title;
32
+	}
33 33
 
34
-    /**
35
-     * @param string $text
36
-     * @return string
37
-     * @filter admin_footer_text
38
-     */
39
-    public function filterFooterText($text)
40
-    {
41
-        if (Application::POST_TYPE.'_page_welcome' != glsr_current_screen()->id) {
42
-            return $text;
43
-        }
44
-        $url = 'https://wordpress.org/support/view/plugin-reviews/site-reviews?filter=5#new-post';
45
-        return wp_kses_post(sprintf(
46
-            __('Please rate %s on %s and help us spread the word. Thank you so much!', 'site-reviews'),
47
-            '<strong>'.glsr()->name.'</strong> <a href="'.$url.'" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>',
48
-            '<a href="'.$url.'" target="_blank">wordpress.org</a>'
49
-        ));
50
-    }
34
+	/**
35
+	 * @param string $text
36
+	 * @return string
37
+	 * @filter admin_footer_text
38
+	 */
39
+	public function filterFooterText($text)
40
+	{
41
+		if (Application::POST_TYPE.'_page_welcome' != glsr_current_screen()->id) {
42
+			return $text;
43
+		}
44
+		$url = 'https://wordpress.org/support/view/plugin-reviews/site-reviews?filter=5#new-post';
45
+		return wp_kses_post(sprintf(
46
+			__('Please rate %s on %s and help us spread the word. Thank you so much!', 'site-reviews'),
47
+			'<strong>'.glsr()->name.'</strong> <a href="'.$url.'" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>',
48
+			'<a href="'.$url.'" target="_blank">wordpress.org</a>'
49
+		));
50
+	}
51 51
 
52
-    /**
53
-     * @param string $plugin
54
-     * @param bool $isNetworkActivation
55
-     * @return void
56
-     * @action activated_plugin
57
-     */
58
-    public function redirectOnActivation($plugin, $isNetworkActivation)
59
-    {
60
-        if (!$isNetworkActivation
61
-            && 'cli' !== php_sapi_name()
62
-            && $plugin === plugin_basename(glsr()->file)) {
63
-            wp_safe_redirect(admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome'));
64
-            exit;
65
-        }
66
-    }
52
+	/**
53
+	 * @param string $plugin
54
+	 * @param bool $isNetworkActivation
55
+	 * @return void
56
+	 * @action activated_plugin
57
+	 */
58
+	public function redirectOnActivation($plugin, $isNetworkActivation)
59
+	{
60
+		if (!$isNetworkActivation
61
+			&& 'cli' !== php_sapi_name()
62
+			&& $plugin === plugin_basename(glsr()->file)) {
63
+			wp_safe_redirect(admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome'));
64
+			exit;
65
+		}
66
+	}
67 67
 
68
-    /**
69
-     * @return void
70
-     * @action admin_menu
71
-     */
72
-    public function registerPage()
73
-    {
74
-        add_submenu_page('edit.php?post_type='.Application::POST_TYPE,
75
-            sprintf(__('Welcome to %s', 'site-reviews'), glsr()->name),
76
-            glsr()->name,
77
-            glsr()->getPermission('welcome'),
78
-            'welcome',
79
-            [$this, 'renderPage']
80
-        );
81
-        remove_submenu_page('edit.php?post_type='.Application::POST_TYPE, 'welcome');
82
-    }
68
+	/**
69
+	 * @return void
70
+	 * @action admin_menu
71
+	 */
72
+	public function registerPage()
73
+	{
74
+		add_submenu_page('edit.php?post_type='.Application::POST_TYPE,
75
+			sprintf(__('Welcome to %s', 'site-reviews'), glsr()->name),
76
+			glsr()->name,
77
+			glsr()->getPermission('welcome'),
78
+			'welcome',
79
+			[$this, 'renderPage']
80
+		);
81
+		remove_submenu_page('edit.php?post_type='.Application::POST_TYPE, 'welcome');
82
+	}
83 83
 
84
-    /**
85
-     * @return void
86
-     * @see $this->registerPage()
87
-     * @callback add_submenu_page
88
-     */
89
-    public function renderPage()
90
-    {
91
-        $tabs = apply_filters('site-reviews/addon/welcome/tabs', [
92
-            'getting-started' => __('Getting Started', 'site-reviews'),
93
-            'whatsnew' => __('What\'s New', 'site-reviews'),
94
-            'upgrade-guide' => __('Upgrade Guide', 'site-reviews'),
95
-            'support' => __('Support', 'site-reviews'),
96
-        ]);
97
-        glsr()->render('pages/welcome/index', [
98
-            'data' => [
99
-                'context' => [],
100
-            ],
101
-            'http_referer' => (string) wp_get_referer(),
102
-            'tabs' => $tabs,
103
-            'template' => glsr(Template::class),
104
-        ]);
105
-    }
84
+	/**
85
+	 * @return void
86
+	 * @see $this->registerPage()
87
+	 * @callback add_submenu_page
88
+	 */
89
+	public function renderPage()
90
+	{
91
+		$tabs = apply_filters('site-reviews/addon/welcome/tabs', [
92
+			'getting-started' => __('Getting Started', 'site-reviews'),
93
+			'whatsnew' => __('What\'s New', 'site-reviews'),
94
+			'upgrade-guide' => __('Upgrade Guide', 'site-reviews'),
95
+			'support' => __('Support', 'site-reviews'),
96
+		]);
97
+		glsr()->render('pages/welcome/index', [
98
+			'data' => [
99
+				'context' => [],
100
+			],
101
+			'http_referer' => (string) wp_get_referer(),
102
+			'tabs' => $tabs,
103
+			'template' => glsr(Template::class),
104
+		]);
105
+	}
106 106
 }
Please login to merge, or discard this patch.
plugin/Controllers/EditorController.php 1 patch
Indentation   +403 added lines, -403 removed lines patch added patch discarded remove patch
@@ -19,434 +19,434 @@
 block discarded – undo
19 19
 
20 20
 class EditorController extends Controller
21 21
 {
22
-    /**
23
-     * @return void
24
-     * @action admin_enqueue_scripts
25
-     */
26
-    public function customizePostStatusLabels()
27
-    {
28
-        glsr(Labels::class)->customizePostStatusLabels();
29
-    }
22
+	/**
23
+	 * @return void
24
+	 * @action admin_enqueue_scripts
25
+	 */
26
+	public function customizePostStatusLabels()
27
+	{
28
+		glsr(Labels::class)->customizePostStatusLabels();
29
+	}
30 30
 
31
-    /**
32
-     * @param array $settings
33
-     * @return array
34
-     * @filter wp_editor_settings
35
-     */
36
-    public function filterEditorSettings($settings)
37
-    {
38
-        return glsr(Customization::class)->filterEditorSettings(
39
-            glsr(Helper::class)->consolidateArray($settings)
40
-        );
41
-    }
31
+	/**
32
+	 * @param array $settings
33
+	 * @return array
34
+	 * @filter wp_editor_settings
35
+	 */
36
+	public function filterEditorSettings($settings)
37
+	{
38
+		return glsr(Customization::class)->filterEditorSettings(
39
+			glsr(Helper::class)->consolidateArray($settings)
40
+		);
41
+	}
42 42
 
43
-    /**
44
-     * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script.
45
-     * @param string $html
46
-     * @return string
47
-     * @filter the_editor
48
-     */
49
-    public function filterEditorTextarea($html)
50
-    {
51
-        return glsr(Customization::class)->filterEditorTextarea($html);
52
-    }
43
+	/**
44
+	 * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script.
45
+	 * @param string $html
46
+	 * @return string
47
+	 * @filter the_editor
48
+	 */
49
+	public function filterEditorTextarea($html)
50
+	{
51
+		return glsr(Customization::class)->filterEditorTextarea($html);
52
+	}
53 53
 
54
-    /**
55
-     * @param bool $protected
56
-     * @param string $metaKey
57
-     * @param string $metaType
58
-     * @return bool
59
-     * @filter is_protected_meta
60
-     */
61
-    public function filterIsProtectedMeta($protected, $metaKey, $metaType)
62
-    {
63
-        if ('post' == $metaType && Application::POST_TYPE == get_post_type()) {
64
-            $values = glsr(CreateReviewDefaults::class)->unguarded();
65
-            $values = glsr(Helper::class)->prefixArrayKeys($values);
66
-            if (array_key_exists($metaKey, $values)) {
67
-                $protected = false;
68
-            }
69
-        }
70
-        return $protected;
71
-    }
54
+	/**
55
+	 * @param bool $protected
56
+	 * @param string $metaKey
57
+	 * @param string $metaType
58
+	 * @return bool
59
+	 * @filter is_protected_meta
60
+	 */
61
+	public function filterIsProtectedMeta($protected, $metaKey, $metaType)
62
+	{
63
+		if ('post' == $metaType && Application::POST_TYPE == get_post_type()) {
64
+			$values = glsr(CreateReviewDefaults::class)->unguarded();
65
+			$values = glsr(Helper::class)->prefixArrayKeys($values);
66
+			if (array_key_exists($metaKey, $values)) {
67
+				$protected = false;
68
+			}
69
+		}
70
+		return $protected;
71
+	}
72 72
 
73
-    /**
74
-     * @param string $translation
75
-     * @param string $test
76
-     * @param string $domain
77
-     * @return string
78
-     * @filter gettext
79
-     */
80
-    public function filterPostStatusLabels($translation, $text, $domain)
81
-    {
82
-        return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain);
83
-    }
73
+	/**
74
+	 * @param string $translation
75
+	 * @param string $test
76
+	 * @param string $domain
77
+	 * @return string
78
+	 * @filter gettext
79
+	 */
80
+	public function filterPostStatusLabels($translation, $text, $domain)
81
+	{
82
+		return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain);
83
+	}
84 84
 
85
-    /**
86
-     * @param string $translation
87
-     * @param string $test
88
-     * @param string $domain
89
-     * @return string
90
-     * @filter gettext_with_context
91
-     */
92
-    public function filterPostStatusLabelsWithContext($translation, $text, $context, $domain)
93
-    {
94
-        return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain);
95
-    }
85
+	/**
86
+	 * @param string $translation
87
+	 * @param string $test
88
+	 * @param string $domain
89
+	 * @return string
90
+	 * @filter gettext_with_context
91
+	 */
92
+	public function filterPostStatusLabelsWithContext($translation, $text, $context, $domain)
93
+	{
94
+		return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain);
95
+	}
96 96
 
97
-    /**
98
-     * @param array $messages
99
-     * @return array
100
-     * @filter post_updated_messages
101
-     */
102
-    public function filterUpdateMessages($messages)
103
-    {
104
-        return glsr(Labels::class)->filterUpdateMessages(
105
-            glsr(Helper::class)->consolidateArray($messages)
106
-        );
107
-    }
97
+	/**
98
+	 * @param array $messages
99
+	 * @return array
100
+	 * @filter post_updated_messages
101
+	 */
102
+	public function filterUpdateMessages($messages)
103
+	{
104
+		return glsr(Labels::class)->filterUpdateMessages(
105
+			glsr(Helper::class)->consolidateArray($messages)
106
+		);
107
+	}
108 108
 
109
-    /**
110
-     * @return void
111
-     * @action add_meta_boxes_{Application::POST_TYPE}
112
-     */
113
-    public function registerMetaBoxes($post)
114
-    {
115
-        add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side');
116
-        add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side');
117
-        if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) {
118
-            return;
119
-        }
120
-        add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal');
121
-    }
109
+	/**
110
+	 * @return void
111
+	 * @action add_meta_boxes_{Application::POST_TYPE}
112
+	 */
113
+	public function registerMetaBoxes($post)
114
+	{
115
+		add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side');
116
+		add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side');
117
+		if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) {
118
+			return;
119
+		}
120
+		add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal');
121
+	}
122 122
 
123
-    /**
124
-     * @return void
125
-     * @action admin_print_scripts
126
-     */
127
-    public function removeAutosave()
128
-    {
129
-        glsr(Customization::class)->removeAutosave();
130
-    }
123
+	/**
124
+	 * @return void
125
+	 * @action admin_print_scripts
126
+	 */
127
+	public function removeAutosave()
128
+	{
129
+		glsr(Customization::class)->removeAutosave();
130
+	}
131 131
 
132
-    /**
133
-     * @return void
134
-     * @action admin_menu
135
-     */
136
-    public function removeMetaBoxes()
137
-    {
138
-        glsr(Customization::class)->removeMetaBoxes();
139
-    }
132
+	/**
133
+	 * @return void
134
+	 * @action admin_menu
135
+	 */
136
+	public function removeMetaBoxes()
137
+	{
138
+		glsr(Customization::class)->removeMetaBoxes();
139
+	}
140 140
 
141
-    /**
142
-     * @return void
143
-     */
144
-    public function removePostTypeSupport()
145
-    {
146
-        glsr(Customization::class)->removePostTypeSupport();
147
-    }
141
+	/**
142
+	 * @return void
143
+	 */
144
+	public function removePostTypeSupport()
145
+	{
146
+		glsr(Customization::class)->removePostTypeSupport();
147
+	}
148 148
 
149
-    /**
150
-     * @param WP_Post $post
151
-     * @return void
152
-     * @callback add_meta_box
153
-     */
154
-    public function renderAssignedToMetabox($post)
155
-    {
156
-        if (!$this->isReviewPostType($post)) {
157
-            return;
158
-        }
159
-        $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to');
160
-        wp_nonce_field('assigned_to', '_nonce-assigned-to', false);
161
-        glsr()->render('partials/editor/metabox-assigned-to', [
162
-            'id' => $assignedTo,
163
-            'template' => $this->buildAssignedToTemplate($assignedTo, $post),
164
-        ]);
165
-    }
149
+	/**
150
+	 * @param WP_Post $post
151
+	 * @return void
152
+	 * @callback add_meta_box
153
+	 */
154
+	public function renderAssignedToMetabox($post)
155
+	{
156
+		if (!$this->isReviewPostType($post)) {
157
+			return;
158
+		}
159
+		$assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to');
160
+		wp_nonce_field('assigned_to', '_nonce-assigned-to', false);
161
+		glsr()->render('partials/editor/metabox-assigned-to', [
162
+			'id' => $assignedTo,
163
+			'template' => $this->buildAssignedToTemplate($assignedTo, $post),
164
+		]);
165
+	}
166 166
 
167
-    /**
168
-     * @param WP_Post $post
169
-     * @return void
170
-     * @callback add_meta_box
171
-     */
172
-    public function renderDetailsMetaBox($post)
173
-    {
174
-        if (!$this->isReviewPostType($post)) {
175
-            return;
176
-        }
177
-        $review = glsr_get_review($post);
178
-        glsr()->render('partials/editor/metabox-details', [
179
-            'button' => $this->buildDetailsMetaBoxRevertButton($review, $post),
180
-            'metabox' => $this->normalizeDetailsMetaBox($review),
181
-        ]);
182
-    }
167
+	/**
168
+	 * @param WP_Post $post
169
+	 * @return void
170
+	 * @callback add_meta_box
171
+	 */
172
+	public function renderDetailsMetaBox($post)
173
+	{
174
+		if (!$this->isReviewPostType($post)) {
175
+			return;
176
+		}
177
+		$review = glsr_get_review($post);
178
+		glsr()->render('partials/editor/metabox-details', [
179
+			'button' => $this->buildDetailsMetaBoxRevertButton($review, $post),
180
+			'metabox' => $this->normalizeDetailsMetaBox($review),
181
+		]);
182
+	}
183 183
 
184
-    /**
185
-     * @return void
186
-     * @action post_submitbox_misc_actions
187
-     */
188
-    public function renderPinnedInPublishMetaBox()
189
-    {
190
-        if (!$this->isReviewPostType(get_post())) {
191
-            return;
192
-        }
193
-        glsr(Template::class)->render('partials/editor/pinned', [
194
-            'context' => [
195
-                'no' => __('No', 'site-reviews'),
196
-                'yes' => __('Yes', 'site-reviews'),
197
-            ],
198
-            'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')),
199
-        ]);
200
-    }
184
+	/**
185
+	 * @return void
186
+	 * @action post_submitbox_misc_actions
187
+	 */
188
+	public function renderPinnedInPublishMetaBox()
189
+	{
190
+		if (!$this->isReviewPostType(get_post())) {
191
+			return;
192
+		}
193
+		glsr(Template::class)->render('partials/editor/pinned', [
194
+			'context' => [
195
+				'no' => __('No', 'site-reviews'),
196
+				'yes' => __('Yes', 'site-reviews'),
197
+			],
198
+			'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')),
199
+		]);
200
+	}
201 201
 
202
-    /**
203
-     * @param WP_Post $post
204
-     * @return void
205
-     * @callback add_meta_box
206
-     */
207
-    public function renderResponseMetaBox($post)
208
-    {
209
-        if (!$this->isReviewPostType($post)) {
210
-            return;
211
-        }
212
-        wp_nonce_field('response', '_nonce-response', false);
213
-        glsr()->render('partials/editor/metabox-response', [
214
-            'response' => glsr(Database::class)->get($post->ID, 'response'),
215
-        ]);
216
-    }
202
+	/**
203
+	 * @param WP_Post $post
204
+	 * @return void
205
+	 * @callback add_meta_box
206
+	 */
207
+	public function renderResponseMetaBox($post)
208
+	{
209
+		if (!$this->isReviewPostType($post)) {
210
+			return;
211
+		}
212
+		wp_nonce_field('response', '_nonce-response', false);
213
+		glsr()->render('partials/editor/metabox-response', [
214
+			'response' => glsr(Database::class)->get($post->ID, 'response'),
215
+		]);
216
+	}
217 217
 
218
-    /**
219
-     * @param WP_Post $post
220
-     * @return void
221
-     * @action edit_form_after_title
222
-     */
223
-    public function renderReviewEditor($post)
224
-    {
225
-        if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
226
-            return;
227
-        }
228
-        glsr()->render('partials/editor/review', [
229
-            'post' => $post,
230
-            'response' => glsr(Database::class)->get($post->ID, 'response'),
231
-        ]);
232
-    }
218
+	/**
219
+	 * @param WP_Post $post
220
+	 * @return void
221
+	 * @action edit_form_after_title
222
+	 */
223
+	public function renderReviewEditor($post)
224
+	{
225
+		if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
226
+			return;
227
+		}
228
+		glsr()->render('partials/editor/review', [
229
+			'post' => $post,
230
+			'response' => glsr(Database::class)->get($post->ID, 'response'),
231
+		]);
232
+	}
233 233
 
234
-    /**
235
-     * @return void
236
-     * @action admin_head
237
-     */
238
-    public function renderReviewFields()
239
-    {
240
-        $screen = glsr_current_screen();
241
-        if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) {
242
-            return;
243
-        }
244
-        add_action('edit_form_after_title', [$this, 'renderReviewEditor']);
245
-        add_action('edit_form_top', [$this, 'renderReviewNotice']);
246
-    }
234
+	/**
235
+	 * @return void
236
+	 * @action admin_head
237
+	 */
238
+	public function renderReviewFields()
239
+	{
240
+		$screen = glsr_current_screen();
241
+		if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) {
242
+			return;
243
+		}
244
+		add_action('edit_form_after_title', [$this, 'renderReviewEditor']);
245
+		add_action('edit_form_top', [$this, 'renderReviewNotice']);
246
+	}
247 247
 
248
-    /**
249
-     * @param WP_Post $post
250
-     * @return void
251
-     * @action edit_form_top
252
-     */
253
-    public function renderReviewNotice($post)
254
-    {
255
-        if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
256
-            return;
257
-        }
258
-        glsr(Notice::class)->addWarning(sprintf(
259
-            __('%s reviews are read-only.', 'site-reviews'),
260
-            glsr(Columns::class)->buildColumnReviewType($post->ID)
261
-        ));
262
-        glsr(Template::class)->render('partials/editor/notice', [
263
-            'context' => [
264
-                'notices' => glsr(Notice::class)->get(),
265
-            ],
266
-        ]);
267
-    }
248
+	/**
249
+	 * @param WP_Post $post
250
+	 * @return void
251
+	 * @action edit_form_top
252
+	 */
253
+	public function renderReviewNotice($post)
254
+	{
255
+		if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
256
+			return;
257
+		}
258
+		glsr(Notice::class)->addWarning(sprintf(
259
+			__('%s reviews are read-only.', 'site-reviews'),
260
+			glsr(Columns::class)->buildColumnReviewType($post->ID)
261
+		));
262
+		glsr(Template::class)->render('partials/editor/notice', [
263
+			'context' => [
264
+				'notices' => glsr(Notice::class)->get(),
265
+			],
266
+		]);
267
+	}
268 268
 
269
-    /**
270
-     * @param WP_Post $post
271
-     * @return void
272
-     * @see glsr_categories_meta_box()
273
-     * @callback register_taxonomy
274
-     */
275
-    public function renderTaxonomyMetabox($post)
276
-    {
277
-        if (!$this->isReviewPostType($post)) {
278
-            return;
279
-        }
280
-        glsr()->render('partials/editor/metabox-categories', [
281
-            'post' => $post,
282
-            'tax_name' => Application::TAXONOMY,
283
-            'taxonomy' => get_taxonomy(Application::TAXONOMY),
284
-        ]);
285
-    }
269
+	/**
270
+	 * @param WP_Post $post
271
+	 * @return void
272
+	 * @see glsr_categories_meta_box()
273
+	 * @callback register_taxonomy
274
+	 */
275
+	public function renderTaxonomyMetabox($post)
276
+	{
277
+		if (!$this->isReviewPostType($post)) {
278
+			return;
279
+		}
280
+		glsr()->render('partials/editor/metabox-categories', [
281
+			'post' => $post,
282
+			'tax_name' => Application::TAXONOMY,
283
+			'taxonomy' => get_taxonomy(Application::TAXONOMY),
284
+		]);
285
+	}
286 286
 
287
-    /**
288
-     * @return void
289
-     * @see $this->filterUpdateMessages()
290
-     * @action admin_action_revert
291
-     */
292
-    public function revertReview()
293
-    {
294
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
295
-            return;
296
-        }
297
-        check_admin_referer('revert-review_'.($postId = $this->getPostId()));
298
-        glsr(ReviewManager::class)->revert($postId);
299
-        $this->redirect($postId, 52);
300
-    }
287
+	/**
288
+	 * @return void
289
+	 * @see $this->filterUpdateMessages()
290
+	 * @action admin_action_revert
291
+	 */
292
+	public function revertReview()
293
+	{
294
+		if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
295
+			return;
296
+		}
297
+		check_admin_referer('revert-review_'.($postId = $this->getPostId()));
298
+		glsr(ReviewManager::class)->revert($postId);
299
+		$this->redirect($postId, 52);
300
+	}
301 301
 
302
-    /**
303
-     * @param int $postId
304
-     * @param \WP_Post $post
305
-     * @param bool $isUpdate
306
-     * @return void
307
-     * @action save_post_.Application::POST_TYPE
308
-     */
309
-    public function saveMetaboxes($postId, $post, $isUpdating)
310
-    {
311
-        glsr(Metaboxes::class)->saveAssignedToMetabox($postId);
312
-        glsr(Metaboxes::class)->saveResponseMetabox($postId);
313
-        if ($isUpdating) {
314
-            do_action('site-reviews/review/saved', glsr_get_review($postId));
315
-        }
316
-    }
302
+	/**
303
+	 * @param int $postId
304
+	 * @param \WP_Post $post
305
+	 * @param bool $isUpdate
306
+	 * @return void
307
+	 * @action save_post_.Application::POST_TYPE
308
+	 */
309
+	public function saveMetaboxes($postId, $post, $isUpdating)
310
+	{
311
+		glsr(Metaboxes::class)->saveAssignedToMetabox($postId);
312
+		glsr(Metaboxes::class)->saveResponseMetabox($postId);
313
+		if ($isUpdating) {
314
+			do_action('site-reviews/review/saved', glsr_get_review($postId));
315
+		}
316
+	}
317 317
 
318
-    /**
319
-     * @param string $assignedTo
320
-     * @return string
321
-     */
322
-    protected function buildAssignedToTemplate($assignedTo, WP_Post $post)
323
-    {
324
-        $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo);
325
-        if (!($assignedPost instanceof WP_Post)) {
326
-            return;
327
-        }
328
-        return glsr(Template::class)->build('partials/editor/assigned-post', [
329
-            'context' => [
330
-                'data.url' => (string) get_permalink($assignedPost),
331
-                'data.title' => get_the_title($assignedPost),
332
-            ],
333
-        ]);
334
-    }
318
+	/**
319
+	 * @param string $assignedTo
320
+	 * @return string
321
+	 */
322
+	protected function buildAssignedToTemplate($assignedTo, WP_Post $post)
323
+	{
324
+		$assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo);
325
+		if (!($assignedPost instanceof WP_Post)) {
326
+			return;
327
+		}
328
+		return glsr(Template::class)->build('partials/editor/assigned-post', [
329
+			'context' => [
330
+				'data.url' => (string) get_permalink($assignedPost),
331
+				'data.title' => get_the_title($assignedPost),
332
+			],
333
+		]);
334
+	}
335 335
 
336
-    /**
337
-     * @return string
338
-     */
339
-    protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post)
340
-    {
341
-        $isModified = !glsr(Helper::class)->compareArrays(
342
-            [$review->title, $review->content, $review->date],
343
-            [
344
-                glsr(Database::class)->get($post->ID, 'title'),
345
-                glsr(Database::class)->get($post->ID, 'content'),
346
-                glsr(Database::class)->get($post->ID, 'date'),
347
-            ]
348
-        );
349
-        if ($isModified) {
350
-            $revertUrl = wp_nonce_url(
351
-                admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID),
352
-                'revert-review_'.$post->ID
353
-            );
354
-            return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [
355
-                'class' => 'button button-large',
356
-                'href' => $revertUrl,
357
-                'id' => 'revert',
358
-            ]);
359
-        }
360
-        return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [
361
-            'class' => 'button-large',
362
-            'disabled' => true,
363
-            'id' => 'revert',
364
-        ]);
365
-    }
336
+	/**
337
+	 * @return string
338
+	 */
339
+	protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post)
340
+	{
341
+		$isModified = !glsr(Helper::class)->compareArrays(
342
+			[$review->title, $review->content, $review->date],
343
+			[
344
+				glsr(Database::class)->get($post->ID, 'title'),
345
+				glsr(Database::class)->get($post->ID, 'content'),
346
+				glsr(Database::class)->get($post->ID, 'date'),
347
+			]
348
+		);
349
+		if ($isModified) {
350
+			$revertUrl = wp_nonce_url(
351
+				admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID),
352
+				'revert-review_'.$post->ID
353
+			);
354
+			return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [
355
+				'class' => 'button button-large',
356
+				'href' => $revertUrl,
357
+				'id' => 'revert',
358
+			]);
359
+		}
360
+		return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [
361
+			'class' => 'button-large',
362
+			'disabled' => true,
363
+			'id' => 'revert',
364
+		]);
365
+	}
366 366
 
367
-    /**
368
-     * @param object $review
369
-     * @return string|void
370
-     */
371
-    protected function getReviewType($review)
372
-    {
373
-        if (count(glsr()->reviewTypes) < 2) {
374
-            return;
375
-        }
376
-        $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes)
377
-            ? glsr()->reviewTypes[$review->review_type]
378
-            : __('Unknown', 'site-reviews');
379
-        if (!empty($review->url)) {
380
-            $reviewType = glsr(Builder::class)->a($reviewType, [
381
-                'href' => $review->url,
382
-                'target' => '_blank',
383
-            ]);
384
-        }
385
-        return $reviewType;
386
-    }
367
+	/**
368
+	 * @param object $review
369
+	 * @return string|void
370
+	 */
371
+	protected function getReviewType($review)
372
+	{
373
+		if (count(glsr()->reviewTypes) < 2) {
374
+			return;
375
+		}
376
+		$reviewType = array_key_exists($review->review_type, glsr()->reviewTypes)
377
+			? glsr()->reviewTypes[$review->review_type]
378
+			: __('Unknown', 'site-reviews');
379
+		if (!empty($review->url)) {
380
+			$reviewType = glsr(Builder::class)->a($reviewType, [
381
+				'href' => $review->url,
382
+				'target' => '_blank',
383
+			]);
384
+		}
385
+		return $reviewType;
386
+	}
387 387
 
388
-    /**
389
-     * @return bool
390
-     */
391
-    protected function isReviewEditable($post)
392
-    {
393
-        return $this->isReviewPostType($post)
394
-            && post_type_supports(Application::POST_TYPE, 'title')
395
-            && 'local' == glsr(Database::class)->get($post->ID, 'review_type');
396
-    }
388
+	/**
389
+	 * @return bool
390
+	 */
391
+	protected function isReviewEditable($post)
392
+	{
393
+		return $this->isReviewPostType($post)
394
+			&& post_type_supports(Application::POST_TYPE, 'title')
395
+			&& 'local' == glsr(Database::class)->get($post->ID, 'review_type');
396
+	}
397 397
 
398
-    /**
399
-     * @param mixed $post
400
-     * @return bool
401
-     */
402
-    protected function isReviewPostType($post)
403
-    {
404
-        return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type;
405
-    }
398
+	/**
399
+	 * @param mixed $post
400
+	 * @return bool
401
+	 */
402
+	protected function isReviewPostType($post)
403
+	{
404
+		return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type;
405
+	}
406 406
 
407
-    /**
408
-     * @return array
409
-     */
410
-    protected function normalizeDetailsMetaBox(Review $review)
411
-    {
412
-        $user = empty($review->user_id)
413
-            ? __('Unregistered user', 'site-reviews')
414
-            : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [
415
-                'href' => get_author_posts_url($review->user_id),
416
-            ]);
417
-        $email = empty($review->email)
418
-            ? '&mdash;'
419
-            : glsr(Builder::class)->a($review->email, [
420
-                'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title),
421
-            ]);
422
-        $metabox = [
423
-            __('Rating', 'site-reviews') => glsr_star_rating($review->rating),
424
-            __('Type', 'site-reviews') => $this->getReviewType($review),
425
-            __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'),
426
-            __('Name', 'site-reviews') => $review->author,
427
-            __('Email', 'site-reviews') => $email,
428
-            __('User', 'site-reviews') => $user,
429
-            __('IP Address', 'site-reviews') => $review->ip_address,
430
-            __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar),
431
-        ];
432
-        return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review));
433
-    }
407
+	/**
408
+	 * @return array
409
+	 */
410
+	protected function normalizeDetailsMetaBox(Review $review)
411
+	{
412
+		$user = empty($review->user_id)
413
+			? __('Unregistered user', 'site-reviews')
414
+			: glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [
415
+				'href' => get_author_posts_url($review->user_id),
416
+			]);
417
+		$email = empty($review->email)
418
+			? '&mdash;'
419
+			: glsr(Builder::class)->a($review->email, [
420
+				'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title),
421
+			]);
422
+		$metabox = [
423
+			__('Rating', 'site-reviews') => glsr_star_rating($review->rating),
424
+			__('Type', 'site-reviews') => $this->getReviewType($review),
425
+			__('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'),
426
+			__('Name', 'site-reviews') => $review->author,
427
+			__('Email', 'site-reviews') => $email,
428
+			__('User', 'site-reviews') => $user,
429
+			__('IP Address', 'site-reviews') => $review->ip_address,
430
+			__('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar),
431
+		];
432
+		return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review));
433
+	}
434 434
 
435
-    /**
436
-     * @param int $postId
437
-     * @param int $messageIndex
438
-     * @return void
439
-     */
440
-    protected function redirect($postId, $messageIndex)
441
-    {
442
-        $referer = wp_get_referer();
443
-        $hasReferer = !$referer
444
-            || false !== strpos($referer, 'post.php')
445
-            || false !== strpos($referer, 'post-new.php');
446
-        $redirectUri = $hasReferer
447
-            ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer)
448
-            : get_edit_post_link($postId);
449
-        wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri));
450
-        exit;
451
-    }
435
+	/**
436
+	 * @param int $postId
437
+	 * @param int $messageIndex
438
+	 * @return void
439
+	 */
440
+	protected function redirect($postId, $messageIndex)
441
+	{
442
+		$referer = wp_get_referer();
443
+		$hasReferer = !$referer
444
+			|| false !== strpos($referer, 'post.php')
445
+			|| false !== strpos($referer, 'post-new.php');
446
+		$redirectUri = $hasReferer
447
+			? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer)
448
+			: get_edit_post_link($postId);
449
+		wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri));
450
+		exit;
451
+	}
452 452
 }
Please login to merge, or discard this patch.
plugin/Controllers/RebusifyController.php 1 patch
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -12,231 +12,231 @@
 block discarded – undo
12 12
 
13 13
 class RebusifyController extends Controller
14 14
 {
15
-    protected $apiKey = 'settings.general.rebusify_serial';
16
-    protected $emailKey = 'settings.general.rebusify_email';
17
-    protected $enabledKey = 'settings.general.rebusify';
18
-    protected $rebusifyKey = '_glsr_rebusify';
19
-
20
-    /**
21
-     * @return array
22
-     * @filter site-reviews/settings/callback
23
-     */
24
-    public function filterSettingsCallback(array $settings)
25
-    {
26
-        if ('yes' !== glsr_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->rebusifyKey, false);
32
-        if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) {
33
-            $settings = $this->sanitizeRebusifySettings($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 !== glsr_get($data, 'field.path')) {
46
-            return $context;
47
-        }
48
-        $rebusifyProductType = glsr(OptionManager::class)->getWP($this->rebusifyKey);
49
-        if ('P' === $rebusifyProductType) {
50
-            return $context;
51
-        }
52
-        if ('F' === $rebusifyProductType && 'yes' === glsr_get_option('general.rebusify')) {
53
-            $button = $this->buildUpgradeButton();
54
-        } else {
55
-            $button = $this->buildCreateButton();
56
-        }
57
-        $context['field'].= $button;
58
-        return $context;
59
-    }
60
-
61
-    /**
62
-     * Triggered when a review is created.
63
-     * @return void
64
-     * @action site-reviews/review/created
65
-     */
66
-    public function onCreated(Review $review)
67
-    {
68
-        if (!$this->canPostReview($review)) {
69
-            return;
70
-        }
71
-        $rebusify = glsr(Rebusify::class)->sendReview($review);
72
-        if ($rebusify->success) {
73
-            glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id);
74
-        }
75
-    }
76
-
77
-    /**
78
-     * Triggered when a review is reverted to its original title/content/date_timestamp.
79
-     * @return void
80
-     * @action site-reviews/review/reverted
81
-     */
82
-    public function onReverted(Review $review)
83
-    {
84
-        if (!$this->canPostReview($review)) {
85
-            return;
86
-        }
87
-        $rebusify = glsr(Rebusify::class)->sendReview($review);
88
-        if ($rebusify->success) {
89
-            glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id);
90
-        }
91
-    }
92
-
93
-    /**
94
-     * Triggered when an existing review is updated.
95
-     * @return void
96
-     * @action site-reviews/review/saved
97
-     */
98
-    public function onSaved(Review $review)
99
-    {
100
-        if (!$this->canPostReview($review)) {
101
-            return;
102
-        }
103
-        $rebusify = glsr(Rebusify::class)->sendReview($review);
104
-        if ($rebusify->success) {
105
-            glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id);
106
-        }
107
-    }
108
-
109
-    /**
110
-     * Triggered when a review's response is added or updated.
111
-     * @param int $metaId
112
-     * @param int $postId
113
-     * @param string $metaKey
114
-     * @return void
115
-     * @action updated_postmeta
116
-     */
117
-    public function onUpdatedMeta($metaId, $postId, $metaKey)
118
-    {
119
-        $review = glsr_get_review($postId);
120
-        if (!$this->canPostResponse($review) || '_response' !== $metaKey) {
121
-            return;
122
-        }
123
-        $rebusify = glsr(Rebusify::class)->sendReviewResponse($review);
124
-        if ($rebusify->success) {
125
-            glsr(Database::class)->set($review->ID, 'rebusify_response', true);
126
-        }
127
-    }
128
-
129
-    /**
130
-     * @return string
131
-     */
132
-    protected function buildCreateButton()
133
-    {
134
-        return glsr(Builder::class)->a(__('Create Your Rebusify Account', 'site-reviews'), [
135
-            'class' => 'button',
136
-            'href' => Rebusify::WEB_URL,
137
-            'target' => '_blank',
138
-        ]);
139
-    }
140
-
141
-    /**
142
-     * @return string
143
-     */
144
-    protected function buildUpgradeButton()
145
-    {
146
-        $build = glsr(Builder::class);
147
-        $notice = $build->p(__('Free Rebusify accounts are limited to 500 blockchain transactions per year.', 'site-reviews'));
148
-        $button = $build->a(__('Upgrade Your Rebusify Plan', 'site-reviews'), [
149
-            'class' => 'button',
150
-            'href' => Rebusify::WEB_URL,
151
-            'target' => '_blank',
152
-        ]);
153
-        return $build->div($notice.$button, [
154
-            'class' => 'glsr-notice-inline',
155
-        ]);
156
-    }
157
-
158
-    /**
159
-     * @return bool
160
-     */
161
-    protected function canPostResponse(Review $review)
162
-    {
163
-        $requiredValues = [
164
-            glsr(Database::class)->get($review->ID, 'rebusify'),
165
-            $review->response,
166
-            $review->review_id,
167
-        ];
168
-        return $this->canProceed($review, 'rebusify_response')
169
-            && 'publish' === $review->status
170
-            && 3 === count(array_filter($requiredValues));
171
-    }
172
-
173
-    /**
174
-     * @return bool
175
-     */
176
-    protected function canPostReview(Review $review)
177
-    {
178
-        $requiredValues = [
179
-            $review->author,
180
-            $review->content,
181
-            $review->rating,
182
-            $review->review_id,
183
-            $review->title,
184
-        ];
185
-        return $this->canProceed($review)
186
-            && 'publish' === $review->status
187
-            && 5 === count(array_filter($requiredValues));
188
-    }
189
-
190
-    /**
191
-     * @param string $metaKey
192
-     * @return bool
193
-     */
194
-    protected function canProceed(Review $review, $metaKey = 'rebusify')
195
-    {
196
-        return glsr(OptionManager::class)->getBool($this->enabledKey)
197
-            && $this->isReviewPostId($review->ID)
198
-            && !$this->hasMetaKey($review, $metaKey);
199
-    }
200
-
201
-    /**
202
-     * @param string $metaKey
203
-     * @return bool
204
-     */
205
-    protected function hasMetaKey(Review $review, $metaKey = 'rebusify')
206
-    {
207
-        return '' !== glsr(Database::class)->get($review->ID, $metaKey);
208
-    }
209
-
210
-    /**
211
-     * @param string $key
212
-     * @return bool
213
-     */
214
-    protected function isEmptyOrModified($key, array $settings)
215
-    {
216
-        $oldValue = glsr_get_option($key);
217
-        $newValue = glsr_get($settings, $key);
218
-        return empty($newValue) || $newValue !== $oldValue;
219
-    }
220
-
221
-    /**
222
-     * @return array
223
-     */
224
-    protected function sanitizeRebusifySettings(array $settings)
225
-    {
226
-        $rebusify = glsr(Rebusify::class)->activateKey(
227
-            glsr_get($settings, $this->apiKey),
228
-            glsr_get($settings, $this->emailKey)
229
-        );
230
-        if ($rebusify->success) {
231
-            update_option($this->rebusifyKey, glsr_get($rebusify->response, 'producttype'));
232
-        } else {
233
-            delete_option($this->rebusifyKey);
234
-            $settings = glsr(Helper::class)->dataSet($settings, $this->enabledKey, 'no');
235
-            glsr(Notice::class)->addError(sprintf(
236
-                __('Your Rebusify account details could not be verified, please try again. %s', 'site-reviews'),
237
-                '('.$rebusify->message.')'
238
-            ));
239
-        }
240
-        return $settings;
241
-    }
15
+	protected $apiKey = 'settings.general.rebusify_serial';
16
+	protected $emailKey = 'settings.general.rebusify_email';
17
+	protected $enabledKey = 'settings.general.rebusify';
18
+	protected $rebusifyKey = '_glsr_rebusify';
19
+
20
+	/**
21
+	 * @return array
22
+	 * @filter site-reviews/settings/callback
23
+	 */
24
+	public function filterSettingsCallback(array $settings)
25
+	{
26
+		if ('yes' !== glsr_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->rebusifyKey, false);
32
+		if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) {
33
+			$settings = $this->sanitizeRebusifySettings($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 !== glsr_get($data, 'field.path')) {
46
+			return $context;
47
+		}
48
+		$rebusifyProductType = glsr(OptionManager::class)->getWP($this->rebusifyKey);
49
+		if ('P' === $rebusifyProductType) {
50
+			return $context;
51
+		}
52
+		if ('F' === $rebusifyProductType && 'yes' === glsr_get_option('general.rebusify')) {
53
+			$button = $this->buildUpgradeButton();
54
+		} else {
55
+			$button = $this->buildCreateButton();
56
+		}
57
+		$context['field'].= $button;
58
+		return $context;
59
+	}
60
+
61
+	/**
62
+	 * Triggered when a review is created.
63
+	 * @return void
64
+	 * @action site-reviews/review/created
65
+	 */
66
+	public function onCreated(Review $review)
67
+	{
68
+		if (!$this->canPostReview($review)) {
69
+			return;
70
+		}
71
+		$rebusify = glsr(Rebusify::class)->sendReview($review);
72
+		if ($rebusify->success) {
73
+			glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id);
74
+		}
75
+	}
76
+
77
+	/**
78
+	 * Triggered when a review is reverted to its original title/content/date_timestamp.
79
+	 * @return void
80
+	 * @action site-reviews/review/reverted
81
+	 */
82
+	public function onReverted(Review $review)
83
+	{
84
+		if (!$this->canPostReview($review)) {
85
+			return;
86
+		}
87
+		$rebusify = glsr(Rebusify::class)->sendReview($review);
88
+		if ($rebusify->success) {
89
+			glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id);
90
+		}
91
+	}
92
+
93
+	/**
94
+	 * Triggered when an existing review is updated.
95
+	 * @return void
96
+	 * @action site-reviews/review/saved
97
+	 */
98
+	public function onSaved(Review $review)
99
+	{
100
+		if (!$this->canPostReview($review)) {
101
+			return;
102
+		}
103
+		$rebusify = glsr(Rebusify::class)->sendReview($review);
104
+		if ($rebusify->success) {
105
+			glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id);
106
+		}
107
+	}
108
+
109
+	/**
110
+	 * Triggered when a review's response is added or updated.
111
+	 * @param int $metaId
112
+	 * @param int $postId
113
+	 * @param string $metaKey
114
+	 * @return void
115
+	 * @action updated_postmeta
116
+	 */
117
+	public function onUpdatedMeta($metaId, $postId, $metaKey)
118
+	{
119
+		$review = glsr_get_review($postId);
120
+		if (!$this->canPostResponse($review) || '_response' !== $metaKey) {
121
+			return;
122
+		}
123
+		$rebusify = glsr(Rebusify::class)->sendReviewResponse($review);
124
+		if ($rebusify->success) {
125
+			glsr(Database::class)->set($review->ID, 'rebusify_response', true);
126
+		}
127
+	}
128
+
129
+	/**
130
+	 * @return string
131
+	 */
132
+	protected function buildCreateButton()
133
+	{
134
+		return glsr(Builder::class)->a(__('Create Your Rebusify Account', 'site-reviews'), [
135
+			'class' => 'button',
136
+			'href' => Rebusify::WEB_URL,
137
+			'target' => '_blank',
138
+		]);
139
+	}
140
+
141
+	/**
142
+	 * @return string
143
+	 */
144
+	protected function buildUpgradeButton()
145
+	{
146
+		$build = glsr(Builder::class);
147
+		$notice = $build->p(__('Free Rebusify accounts are limited to 500 blockchain transactions per year.', 'site-reviews'));
148
+		$button = $build->a(__('Upgrade Your Rebusify Plan', 'site-reviews'), [
149
+			'class' => 'button',
150
+			'href' => Rebusify::WEB_URL,
151
+			'target' => '_blank',
152
+		]);
153
+		return $build->div($notice.$button, [
154
+			'class' => 'glsr-notice-inline',
155
+		]);
156
+	}
157
+
158
+	/**
159
+	 * @return bool
160
+	 */
161
+	protected function canPostResponse(Review $review)
162
+	{
163
+		$requiredValues = [
164
+			glsr(Database::class)->get($review->ID, 'rebusify'),
165
+			$review->response,
166
+			$review->review_id,
167
+		];
168
+		return $this->canProceed($review, 'rebusify_response')
169
+			&& 'publish' === $review->status
170
+			&& 3 === count(array_filter($requiredValues));
171
+	}
172
+
173
+	/**
174
+	 * @return bool
175
+	 */
176
+	protected function canPostReview(Review $review)
177
+	{
178
+		$requiredValues = [
179
+			$review->author,
180
+			$review->content,
181
+			$review->rating,
182
+			$review->review_id,
183
+			$review->title,
184
+		];
185
+		return $this->canProceed($review)
186
+			&& 'publish' === $review->status
187
+			&& 5 === count(array_filter($requiredValues));
188
+	}
189
+
190
+	/**
191
+	 * @param string $metaKey
192
+	 * @return bool
193
+	 */
194
+	protected function canProceed(Review $review, $metaKey = 'rebusify')
195
+	{
196
+		return glsr(OptionManager::class)->getBool($this->enabledKey)
197
+			&& $this->isReviewPostId($review->ID)
198
+			&& !$this->hasMetaKey($review, $metaKey);
199
+	}
200
+
201
+	/**
202
+	 * @param string $metaKey
203
+	 * @return bool
204
+	 */
205
+	protected function hasMetaKey(Review $review, $metaKey = 'rebusify')
206
+	{
207
+		return '' !== glsr(Database::class)->get($review->ID, $metaKey);
208
+	}
209
+
210
+	/**
211
+	 * @param string $key
212
+	 * @return bool
213
+	 */
214
+	protected function isEmptyOrModified($key, array $settings)
215
+	{
216
+		$oldValue = glsr_get_option($key);
217
+		$newValue = glsr_get($settings, $key);
218
+		return empty($newValue) || $newValue !== $oldValue;
219
+	}
220
+
221
+	/**
222
+	 * @return array
223
+	 */
224
+	protected function sanitizeRebusifySettings(array $settings)
225
+	{
226
+		$rebusify = glsr(Rebusify::class)->activateKey(
227
+			glsr_get($settings, $this->apiKey),
228
+			glsr_get($settings, $this->emailKey)
229
+		);
230
+		if ($rebusify->success) {
231
+			update_option($this->rebusifyKey, glsr_get($rebusify->response, 'producttype'));
232
+		} else {
233
+			delete_option($this->rebusifyKey);
234
+			$settings = glsr(Helper::class)->dataSet($settings, $this->enabledKey, 'no');
235
+			glsr(Notice::class)->addError(sprintf(
236
+				__('Your Rebusify account details could not be verified, please try again. %s', 'site-reviews'),
237
+				'('.$rebusify->message.')'
238
+			));
239
+		}
240
+		return $settings;
241
+	}
242 242
 }
Please login to merge, or discard this patch.
plugin/Actions.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -20,108 +20,108 @@
 block discarded – undo
20 20
 
21 21
 class Actions implements HooksContract
22 22
 {
23
-    protected $about;
24
-    protected $admin;
25
-    protected $app;
26
-    protected $blocks;
27
-    protected $console;
28
-    protected $editor;
29
-    protected $listtable;
30
-    protected $menu;
31
-    protected $main;
32
-    protected $notices;
33
-    protected $public;
34
-    protected $rebusify;
35
-    protected $review;
36
-    protected $router;
37
-    protected $settings;
38
-    protected $taxonomy;
39
-    protected $welcome;
23
+	protected $about;
24
+	protected $admin;
25
+	protected $app;
26
+	protected $blocks;
27
+	protected $console;
28
+	protected $editor;
29
+	protected $listtable;
30
+	protected $menu;
31
+	protected $main;
32
+	protected $notices;
33
+	protected $public;
34
+	protected $rebusify;
35
+	protected $review;
36
+	protected $router;
37
+	protected $settings;
38
+	protected $taxonomy;
39
+	protected $welcome;
40 40
 
41
-    public function __construct(Application $app ) {
42
-        $this->app = $app;
43
-        $this->admin = $app->make(AdminController::class);
44
-        $this->blocks = $app->make(BlocksController::class);
45
-        $this->console = $app->make(Console::class);
46
-        $this->editor = $app->make(EditorController::class);
47
-        $this->listtable = $app->make(ListTableController::class);
48
-        $this->main = $app->make(MainController::class);
49
-        $this->menu = $app->make(MenuController::class);
50
-        $this->notices = $app->make(NoticeController::class);
51
-        $this->public = $app->make(PublicController::class);
52
-        $this->rebusify = $app->make(RebusifyController::class);
53
-        $this->review = $app->make(ReviewController::class);
54
-        $this->router = $app->make(Router::class);
55
-        $this->settings = $app->make(SettingsController::class);
56
-        $this->taxonomy = $app->make(TaxonomyController::class);
57
-        $this->welcome = $app->make(WelcomeController::class);
58
-    }
41
+	public function __construct(Application $app ) {
42
+		$this->app = $app;
43
+		$this->admin = $app->make(AdminController::class);
44
+		$this->blocks = $app->make(BlocksController::class);
45
+		$this->console = $app->make(Console::class);
46
+		$this->editor = $app->make(EditorController::class);
47
+		$this->listtable = $app->make(ListTableController::class);
48
+		$this->main = $app->make(MainController::class);
49
+		$this->menu = $app->make(MenuController::class);
50
+		$this->notices = $app->make(NoticeController::class);
51
+		$this->public = $app->make(PublicController::class);
52
+		$this->rebusify = $app->make(RebusifyController::class);
53
+		$this->review = $app->make(ReviewController::class);
54
+		$this->router = $app->make(Router::class);
55
+		$this->settings = $app->make(SettingsController::class);
56
+		$this->taxonomy = $app->make(TaxonomyController::class);
57
+		$this->welcome = $app->make(WelcomeController::class);
58
+	}
59 59
 
60
-    /**
61
-     * @return void
62
-     */
63
-    public function run()
64
-    {
65
-        add_action('admin_enqueue_scripts',                                 [$this->admin, 'enqueueAssets']);
66
-        add_action('admin_init',                                            [$this->admin, 'registerTinymcePopups']);
67
-        add_action('media_buttons',                                         [$this->admin, 'renderTinymceButton'], 11);
68
-        add_action('plugins_loaded',                                        [$this->app, 'getDefaults'], 11);
69
-        add_action('plugins_loaded',                                        [$this->app, 'registerAddons']);
70
-        add_action('plugins_loaded',                                        [$this->app, 'registerLanguages']);
71
-        add_action('plugins_loaded',                                        [$this->app, 'registerReviewTypes']);
72
-        add_action('upgrader_process_complete',                             [$this->app, 'upgraded'], 10, 2);
73
-        add_action('init',                                                  [$this->blocks, 'registerAssets'], 9);
74
-        add_action('init',                                                  [$this->blocks, 'registerBlocks']);
75
-        add_action('admin_footer',                                          [$this->console, 'logOnce']);
76
-        add_action('wp_footer',                                             [$this->console, 'logOnce']);
77
-        add_action('admin_enqueue_scripts',                                 [$this->editor, 'customizePostStatusLabels']);
78
-        add_action('add_meta_boxes_'.Application::POST_TYPE,                [$this->editor, 'registerMetaBoxes']);
79
-        add_action('admin_print_scripts',                                   [$this->editor, 'removeAutosave'], 999);
80
-        add_action('admin_menu',                                            [$this->editor, 'removeMetaBoxes']);
81
-        add_action('current_screen',                                        [$this->editor, 'removePostTypeSupport']);
82
-        add_action('post_submitbox_misc_actions',                           [$this->editor, 'renderPinnedInPublishMetaBox']);
83
-        add_action('admin_head',                                            [$this->editor, 'renderReviewFields']);
84
-        add_action('admin_action_revert',                                   [$this->editor, 'revertReview']);
85
-        add_action('save_post_'.Application::POST_TYPE,                     [$this->editor, 'saveMetaboxes'], 10, 3);
86
-        add_action('admin_action_approve',                                  [$this->listtable, 'approve']);
87
-        add_action('bulk_edit_custom_box',                                  [$this->listtable, 'renderBulkEditFields'], 10, 2);
88
-        add_action('restrict_manage_posts',                                 [$this->listtable, 'renderColumnFilters']);
89
-        add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2);
90
-        add_action('save_post_'.Application::POST_TYPE,                     [$this->listtable, 'saveBulkEditFields']);
91
-        add_action('pre_get_posts',                                         [$this->listtable, 'setQueryForColumn']);
92
-        add_action('admin_action_unapprove',                                [$this->listtable, 'unapprove']);
93
-        add_action('init',                                                  [$this->main, 'registerPostType'], 8);
94
-        add_action('init',                                                  [$this->main, 'registerShortcodes']);
95
-        add_action('init',                                                  [$this->main, 'registerTaxonomy']);
96
-        add_action('widgets_init',                                          [$this->main, 'registerWidgets']);
97
-        add_action('admin_menu',                                            [$this->menu, 'registerMenuCount']);
98
-        add_action('admin_menu',                                            [$this->menu, 'registerSubMenus']);
99
-        add_action('admin_init',                                            [$this->menu, 'setCustomPermissions'], 999);
100
-        add_action('admin_notices',                                         [$this->notices, 'filterAdminNotices']);
101
-        add_action('wp_enqueue_scripts',                                    [$this->public, 'enqueueAssets'], 999);
102
-        add_filter('site-reviews/builder',                                  [$this->public, 'modifyBuilder']);
103
-        add_action('wp_footer',                                             [$this->public, 'renderSchema']);
104
-        add_action('site-reviews/review/created',                           [$this->rebusify, 'onCreated']);
105
-        add_action('site-reviews/review/reverted',                          [$this->rebusify, 'onReverted']);
106
-        add_action('site-reviews/review/saved',                             [$this->rebusify, 'onSaved']);
107
-        add_action('updated_postmeta',                                      [$this->rebusify, 'onUpdatedMeta'], 10, 3);
108
-        add_action('set_object_terms',                                      [$this->review, 'onAfterChangeCategory'], 10, 6);
109
-        add_action('transition_post_status',                                [$this->review, 'onAfterChangeStatus'], 10, 3);
110
-        add_action('site-reviews/review/created',                           [$this->review, 'onAfterCreate']);
111
-        add_action('before_delete_post',                                    [$this->review, 'onBeforeDelete']);
112
-        add_action('update_postmeta',                                       [$this->review, 'onBeforeUpdate'], 10, 4);
113
-        add_action('admin_init',                                            [$this->router, 'routeAdminPostRequest']);
114
-        add_action('wp_ajax_'.Application::PREFIX.'action',                 [$this->router, 'routeAjaxRequest']);
115
-        add_action('wp_ajax_nopriv_'.Application::PREFIX.'action',          [$this->router, 'routeAjaxRequest']);
116
-        add_action('init',                                                  [$this->router, 'routePublicPostRequest']);
117
-        add_action('admin_init',                                            [$this->settings, 'registerSettings']);
118
-        add_action(Application::TAXONOMY.'_term_edit_form_top',             [$this->taxonomy, 'disableParents']);
119
-        add_action(Application::TAXONOMY.'_term_new_form_tag',              [$this->taxonomy, 'disableParents']);
120
-        add_action(Application::TAXONOMY.'_add_form_fields',                [$this->taxonomy, 'enableParents']);
121
-        add_action(Application::TAXONOMY.'_edit_form',                      [$this->taxonomy, 'enableParents']);
122
-        add_action('restrict_manage_posts',                                 [$this->taxonomy, 'renderTaxonomyFilter'], 9);
123
-        add_action('set_object_terms',                                      [$this->taxonomy, 'restrictTermSelection'], 9, 6);
124
-        add_action('activated_plugin',                                      [$this->welcome, 'redirectOnActivation'], 10, 2);
125
-        add_action('admin_menu',                                            [$this->welcome, 'registerPage']);
126
-    }
60
+	/**
61
+	 * @return void
62
+	 */
63
+	public function run()
64
+	{
65
+		add_action('admin_enqueue_scripts',                                 [$this->admin, 'enqueueAssets']);
66
+		add_action('admin_init',                                            [$this->admin, 'registerTinymcePopups']);
67
+		add_action('media_buttons',                                         [$this->admin, 'renderTinymceButton'], 11);
68
+		add_action('plugins_loaded',                                        [$this->app, 'getDefaults'], 11);
69
+		add_action('plugins_loaded',                                        [$this->app, 'registerAddons']);
70
+		add_action('plugins_loaded',                                        [$this->app, 'registerLanguages']);
71
+		add_action('plugins_loaded',                                        [$this->app, 'registerReviewTypes']);
72
+		add_action('upgrader_process_complete',                             [$this->app, 'upgraded'], 10, 2);
73
+		add_action('init',                                                  [$this->blocks, 'registerAssets'], 9);
74
+		add_action('init',                                                  [$this->blocks, 'registerBlocks']);
75
+		add_action('admin_footer',                                          [$this->console, 'logOnce']);
76
+		add_action('wp_footer',                                             [$this->console, 'logOnce']);
77
+		add_action('admin_enqueue_scripts',                                 [$this->editor, 'customizePostStatusLabels']);
78
+		add_action('add_meta_boxes_'.Application::POST_TYPE,                [$this->editor, 'registerMetaBoxes']);
79
+		add_action('admin_print_scripts',                                   [$this->editor, 'removeAutosave'], 999);
80
+		add_action('admin_menu',                                            [$this->editor, 'removeMetaBoxes']);
81
+		add_action('current_screen',                                        [$this->editor, 'removePostTypeSupport']);
82
+		add_action('post_submitbox_misc_actions',                           [$this->editor, 'renderPinnedInPublishMetaBox']);
83
+		add_action('admin_head',                                            [$this->editor, 'renderReviewFields']);
84
+		add_action('admin_action_revert',                                   [$this->editor, 'revertReview']);
85
+		add_action('save_post_'.Application::POST_TYPE,                     [$this->editor, 'saveMetaboxes'], 10, 3);
86
+		add_action('admin_action_approve',                                  [$this->listtable, 'approve']);
87
+		add_action('bulk_edit_custom_box',                                  [$this->listtable, 'renderBulkEditFields'], 10, 2);
88
+		add_action('restrict_manage_posts',                                 [$this->listtable, 'renderColumnFilters']);
89
+		add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2);
90
+		add_action('save_post_'.Application::POST_TYPE,                     [$this->listtable, 'saveBulkEditFields']);
91
+		add_action('pre_get_posts',                                         [$this->listtable, 'setQueryForColumn']);
92
+		add_action('admin_action_unapprove',                                [$this->listtable, 'unapprove']);
93
+		add_action('init',                                                  [$this->main, 'registerPostType'], 8);
94
+		add_action('init',                                                  [$this->main, 'registerShortcodes']);
95
+		add_action('init',                                                  [$this->main, 'registerTaxonomy']);
96
+		add_action('widgets_init',                                          [$this->main, 'registerWidgets']);
97
+		add_action('admin_menu',                                            [$this->menu, 'registerMenuCount']);
98
+		add_action('admin_menu',                                            [$this->menu, 'registerSubMenus']);
99
+		add_action('admin_init',                                            [$this->menu, 'setCustomPermissions'], 999);
100
+		add_action('admin_notices',                                         [$this->notices, 'filterAdminNotices']);
101
+		add_action('wp_enqueue_scripts',                                    [$this->public, 'enqueueAssets'], 999);
102
+		add_filter('site-reviews/builder',                                  [$this->public, 'modifyBuilder']);
103
+		add_action('wp_footer',                                             [$this->public, 'renderSchema']);
104
+		add_action('site-reviews/review/created',                           [$this->rebusify, 'onCreated']);
105
+		add_action('site-reviews/review/reverted',                          [$this->rebusify, 'onReverted']);
106
+		add_action('site-reviews/review/saved',                             [$this->rebusify, 'onSaved']);
107
+		add_action('updated_postmeta',                                      [$this->rebusify, 'onUpdatedMeta'], 10, 3);
108
+		add_action('set_object_terms',                                      [$this->review, 'onAfterChangeCategory'], 10, 6);
109
+		add_action('transition_post_status',                                [$this->review, 'onAfterChangeStatus'], 10, 3);
110
+		add_action('site-reviews/review/created',                           [$this->review, 'onAfterCreate']);
111
+		add_action('before_delete_post',                                    [$this->review, 'onBeforeDelete']);
112
+		add_action('update_postmeta',                                       [$this->review, 'onBeforeUpdate'], 10, 4);
113
+		add_action('admin_init',                                            [$this->router, 'routeAdminPostRequest']);
114
+		add_action('wp_ajax_'.Application::PREFIX.'action',                 [$this->router, 'routeAjaxRequest']);
115
+		add_action('wp_ajax_nopriv_'.Application::PREFIX.'action',          [$this->router, 'routeAjaxRequest']);
116
+		add_action('init',                                                  [$this->router, 'routePublicPostRequest']);
117
+		add_action('admin_init',                                            [$this->settings, 'registerSettings']);
118
+		add_action(Application::TAXONOMY.'_term_edit_form_top',             [$this->taxonomy, 'disableParents']);
119
+		add_action(Application::TAXONOMY.'_term_new_form_tag',              [$this->taxonomy, 'disableParents']);
120
+		add_action(Application::TAXONOMY.'_add_form_fields',                [$this->taxonomy, 'enableParents']);
121
+		add_action(Application::TAXONOMY.'_edit_form',                      [$this->taxonomy, 'enableParents']);
122
+		add_action('restrict_manage_posts',                                 [$this->taxonomy, 'renderTaxonomyFilter'], 9);
123
+		add_action('set_object_terms',                                      [$this->taxonomy, 'restrictTermSelection'], 9, 6);
124
+		add_action('activated_plugin',                                      [$this->welcome, 'redirectOnActivation'], 10, 2);
125
+		add_action('admin_menu',                                            [$this->welcome, 'registerPage']);
126
+	}
127 127
 }
Please login to merge, or discard this patch.