Passed
Pull Request — master (#10)
by
unknown
11:54 queued 05:38
created
plugin/Database/SqlQueries.php 1 patch
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -8,47 +8,47 @@  discard block
 block discarded – undo
8 8
 
9 9
 class SqlQueries
10 10
 {
11
-    protected $db;
12
-    protected $postType;
11
+	protected $db;
12
+	protected $postType;
13 13
 
14
-    public function __construct()
15
-    {
16
-        global $wpdb;
17
-        $this->db = $wpdb;
18
-        $this->postType = Application::POST_TYPE;
19
-    }
14
+	public function __construct()
15
+	{
16
+		global $wpdb;
17
+		$this->db = $wpdb;
18
+		$this->postType = Application::POST_TYPE;
19
+	}
20 20
 
21
-    /**
22
-     * @return bool
23
-     */
24
-    public function deletePostCountMetaKeys()
25
-    {
26
-        return $this->db->query("
21
+	/**
22
+	 * @return bool
23
+	 */
24
+	public function deletePostCountMetaKeys()
25
+	{
26
+		return $this->db->query("
27 27
             DELETE
28 28
             FROM {$this->db->postmeta}
29 29
             WHERE meta_key LIKE '_glsr_%'
30 30
         ");
31
-    }
31
+	}
32 32
 
33
-    /**
34
-     * @return bool
35
-     */
36
-    public function deleteTermCountMetaKeys()
37
-    {
38
-        return $this->db->query("
33
+	/**
34
+	 * @return bool
35
+	 */
36
+	public function deleteTermCountMetaKeys()
37
+	{
38
+		return $this->db->query("
39 39
             DELETE
40 40
             FROM {$this->db->termmeta}
41 41
             WHERE meta_key LIKE '_glsr_%'
42 42
         ");
43
-    }
43
+	}
44 44
 
45
-    /**
46
-     * @param string $metaReviewId
47
-     * @return int
48
-     */
49
-    public function getPostIdFromReviewId($metaReviewId)
50
-    {
51
-        $postId = $this->db->get_var("
45
+	/**
46
+	 * @param string $metaReviewId
47
+	 * @return int
48
+	 */
49
+	public function getPostIdFromReviewId($metaReviewId)
50
+	{
51
+		$postId = $this->db->get_var("
52 52
             SELECT p.ID
53 53
             FROM {$this->db->posts} AS p
54 54
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
             AND m.meta_key = '_review_id'
57 57
             AND m.meta_value = '{$metaReviewId}'
58 58
         ");
59
-        return intval($postId);
60
-    }
59
+		return intval($postId);
60
+	}
61 61
 
62
-    /**
63
-     * @param int $lastPostId
64
-     * @param int $limit
65
-     * @return array
66
-     */
67
-    public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500)
68
-    {
69
-        return (array) $this->db->get_results("
62
+	/**
63
+	 * @param int $lastPostId
64
+	 * @param int $limit
65
+	 * @return array
66
+	 */
67
+	public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500)
68
+	{
69
+		return (array) $this->db->get_results("
70 70
             SELECT DISTINCT p.ID, m1.meta_value AS rating, m2.meta_value AS type
71 71
             FROM {$this->db->posts} AS p
72 72
             INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -81,17 +81,17 @@  discard block
 block discarded – undo
81 81
             ORDER By p.ID ASC
82 82
             LIMIT {$limit}
83 83
         ");
84
-    }
84
+	}
85 85
 
86
-    /**
87
-     * @todo remove this?
88
-     * @param string $metaKey
89
-     * @return array
90
-     */
91
-    public function getReviewCountsFor($metaKey)
92
-    {
93
-        $metaKey = Str::prefix('_', $metaKey);
94
-        return (array) $this->db->get_results("
86
+	/**
87
+	 * @todo remove this?
88
+	 * @param string $metaKey
89
+	 * @return array
90
+	 */
91
+	public function getReviewCountsFor($metaKey)
92
+	{
93
+		$metaKey = Str::prefix('_', $metaKey);
94
+		return (array) $this->db->get_results("
95 95
             SELECT DISTINCT m.meta_value AS name, COUNT(*) num_posts
96 96
             FROM {$this->db->posts} AS p
97 97
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
             AND m.meta_key = '{$metaKey}'
100 100
             GROUP BY name
101 101
         ");
102
-    }
102
+	}
103 103
 
104
-    /**
105
-     * @todo remove this?
106
-     * @param string $reviewType
107
-     * @return array
108
-     */
109
-    public function getReviewIdsByType($reviewType)
110
-    {
111
-        $results = $this->db->get_col("
104
+	/**
105
+	 * @todo remove this?
106
+	 * @param string $reviewType
107
+	 * @return array
108
+	 */
109
+	public function getReviewIdsByType($reviewType)
110
+	{
111
+		$results = $this->db->get_col("
112 112
             SELECT DISTINCT m1.meta_value AS review_id
113 113
             FROM {$this->db->posts} AS p
114 114
             INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id
@@ -118,20 +118,20 @@  discard block
 block discarded – undo
118 118
             AND m2.meta_key = '_review_type'
119 119
             AND m2.meta_value = '{$reviewType}'
120 120
         ");
121
-        return array_keys(array_flip($results));
122
-    }
121
+		return array_keys(array_flip($results));
122
+	}
123 123
 
124
-    /**
125
-     * @param int $greaterThanId
126
-     * @param int $limit
127
-     * @return array
128
-     */
129
-    public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100)
130
-    {
131
-        sort($postIds);
132
-        $postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit);
133
-        $postIds = implode(',', $postIds);
134
-        return (array) $this->db->get_results("
124
+	/**
125
+	 * @param int $greaterThanId
126
+	 * @param int $limit
127
+	 * @return array
128
+	 */
129
+	public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100)
130
+	{
131
+		sort($postIds);
132
+		$postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit);
133
+		$postIds = implode(',', $postIds);
134
+		return (array) $this->db->get_results("
135 135
             SELECT p.ID, m.meta_value AS rating
136 136
             FROM {$this->db->posts} AS p
137 137
             INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id
@@ -144,20 +144,20 @@  discard block
 block discarded – undo
144 144
             ORDER By p.ID ASC
145 145
             LIMIT {$limit}
146 146
         ");
147
-    }
147
+	}
148 148
 
149
-    /**
150
-     * @param string $key
151
-     * @param string $status
152
-     * @return array
153
-     */
154
-    public function getReviewsMeta($key, $status = 'publish')
155
-    {
156
-        $postStatusQuery = 'all' != $status && !empty($status)
157
-            ? "AND p.post_status = '{$status}'"
158
-            : '';
159
-        $key = Str::prefix('_', $key);
160
-        $values = $this->db->get_col("
149
+	/**
150
+	 * @param string $key
151
+	 * @param string $status
152
+	 * @return array
153
+	 */
154
+	public function getReviewsMeta($key, $status = 'publish')
155
+	{
156
+		$postStatusQuery = 'all' != $status && !empty($status)
157
+			? "AND p.post_status = '{$status}'"
158
+			: '';
159
+		$key = Str::prefix('_', $key);
160
+		$values = $this->db->get_col("
161 161
             SELECT DISTINCT m.meta_value
162 162
             FROM {$this->db->postmeta} m
163 163
             LEFT JOIN {$this->db->posts} p ON p.ID = m.post_id
@@ -168,42 +168,42 @@  discard block
 block discarded – undo
168 168
             GROUP BY p.ID -- remove duplicate meta_value entries
169 169
             ORDER BY m.meta_id ASC -- sort by oldest meta_value
170 170
         ");
171
-        sort($values);
172
-        return $values;
173
-    }
171
+		sort($values);
172
+		return $values;
173
+	}
174 174
 
175
-    /**
176
-     * @param string $and
177
-     * @return string
178
-     */
179
-    protected function getAndForCounts(array $args, $and = '')
180
-    {
181
-        $postIds = implode(',', array_filter(Arr::get($args, 'post_ids', [])));
182
-        $termIds = implode(',', array_filter(Arr::get($args, 'term_ids', [])));
183
-        if (!empty($args['type'])) {
184
-            $and.= "AND m2.meta_value = '{$args['type']}' ";
185
-        }
186
-        if ($postIds) {
187
-            $and.= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
188
-        }
189
-        if ($termIds) {
190
-            $and.= "AND tr.term_taxonomy_id IN ({$termIds}) ";
191
-        }
192
-        return apply_filters('site-reviews/query/and-for-counts', $and);
193
-    }
175
+	/**
176
+	 * @param string $and
177
+	 * @return string
178
+	 */
179
+	protected function getAndForCounts(array $args, $and = '')
180
+	{
181
+		$postIds = implode(',', array_filter(Arr::get($args, 'post_ids', [])));
182
+		$termIds = implode(',', array_filter(Arr::get($args, 'term_ids', [])));
183
+		if (!empty($args['type'])) {
184
+			$and.= "AND m2.meta_value = '{$args['type']}' ";
185
+		}
186
+		if ($postIds) {
187
+			$and.= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) ";
188
+		}
189
+		if ($termIds) {
190
+			$and.= "AND tr.term_taxonomy_id IN ({$termIds}) ";
191
+		}
192
+		return apply_filters('site-reviews/query/and-for-counts', $and);
193
+	}
194 194
 
195
-    /**
196
-     * @param string $innerJoin
197
-     * @return string
198
-     */
199
-    protected function getInnerJoinForCounts(array $args, $innerJoin = '')
200
-    {
201
-        if (!empty(Arr::get($args, 'post_ids'))) {
202
-            $innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
203
-        }
204
-        if (!empty(Arr::get($args, 'term_ids'))) {
205
-            $innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
206
-        }
207
-        return apply_filters('site-reviews/query/inner-join-for-counts', $innerJoin);
208
-    }
195
+	/**
196
+	 * @param string $innerJoin
197
+	 * @return string
198
+	 */
199
+	protected function getInnerJoinForCounts(array $args, $innerJoin = '')
200
+	{
201
+		if (!empty(Arr::get($args, 'post_ids'))) {
202
+			$innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id ";
203
+		}
204
+		if (!empty(Arr::get($args, 'term_ids'))) {
205
+			$innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id ";
206
+		}
207
+		return apply_filters('site-reviews/query/inner-join-for-counts', $innerJoin);
208
+	}
209 209
 }
Please login to merge, or discard this patch.
plugin/Database/TermCountsManager.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -9,91 +9,91 @@
 block discarded – undo
9 9
 
10 10
 class TermCountsManager
11 11
 {
12
-    /**
13
-     * @var CountsManager
14
-     */
15
-    protected $manager;
12
+	/**
13
+	 * @var CountsManager
14
+	 */
15
+	protected $manager;
16 16
 
17
-    public function __construct()
18
-    {
19
-        $this->manager = glsr(CountsManager::class);
20
-    }
17
+	public function __construct()
18
+	{
19
+		$this->manager = glsr(CountsManager::class);
20
+	}
21 21
 
22
-    /**
23
-     * @param int $termTaxonomyId
24
-     * @return array
25
-     */
26
-    public function build($termTaxonomyId)
27
-    {
28
-        return $this->manager->buildCounts([
29
-            'term_ids' => [$termTaxonomyId],
30
-        ]);
31
-    }
22
+	/**
23
+	 * @param int $termTaxonomyId
24
+	 * @return array
25
+	 */
26
+	public function build($termTaxonomyId)
27
+	{
28
+		return $this->manager->buildCounts([
29
+			'term_ids' => [$termTaxonomyId],
30
+		]);
31
+	}
32 32
 
33
-    /**
34
-     * @return void
35
-     */
36
-    public function decrease(Review $review)
37
-    {
38
-        foreach ($review->term_ids as $termId) {
39
-            if (empty($counts = $this->get($termId))) {
40
-                continue;
41
-            }
42
-            $this->update($termId,
43
-                $this->manager->decreaseRating($counts, $review->review_type, $review->rating)
44
-            );
45
-        }
46
-    }
33
+	/**
34
+	 * @return void
35
+	 */
36
+	public function decrease(Review $review)
37
+	{
38
+		foreach ($review->term_ids as $termId) {
39
+			if (empty($counts = $this->get($termId))) {
40
+				continue;
41
+			}
42
+			$this->update($termId,
43
+				$this->manager->decreaseRating($counts, $review->review_type, $review->rating)
44
+			);
45
+		}
46
+	}
47 47
 
48
-    /**
49
-     * @param int $termId
50
-     * @return array
51
-     */
52
-    public function get($termId)
53
-    {
54
-        return array_filter((array) get_term_meta($termId, CountsManager::META_COUNT, true));
55
-    }
48
+	/**
49
+	 * @param int $termId
50
+	 * @return array
51
+	 */
52
+	public function get($termId)
53
+	{
54
+		return array_filter((array) get_term_meta($termId, CountsManager::META_COUNT, true));
55
+	}
56 56
 
57
-    /**
58
-     * @return void
59
-     */
60
-    public function increase(Review $review)
61
-    {
62
-        $terms = glsr(ReviewManager::class)->normalizeTerms(implode(',', $review->term_ids));
63
-        foreach ($terms as $term) {
64
-            $counts = $this->get($term['term_id']);
65
-            $counts = empty($counts)
66
-                ? $this->build($term['term_taxonomy_id'])
67
-                : $this->manager->increaseRating($counts, $review->review_type, $review->rating);
68
-            $this->update($term['term_id'], $counts);
69
-        }
70
-    }
57
+	/**
58
+	 * @return void
59
+	 */
60
+	public function increase(Review $review)
61
+	{
62
+		$terms = glsr(ReviewManager::class)->normalizeTerms(implode(',', $review->term_ids));
63
+		foreach ($terms as $term) {
64
+			$counts = $this->get($term['term_id']);
65
+			$counts = empty($counts)
66
+				? $this->build($term['term_taxonomy_id'])
67
+				: $this->manager->increaseRating($counts, $review->review_type, $review->rating);
68
+			$this->update($term['term_id'], $counts);
69
+		}
70
+	}
71 71
 
72
-    /**
73
-     * @param int $termId
74
-     * @return void
75
-     */
76
-    public function update($termId, array $reviewCounts)
77
-    {
78
-        $term = get_term($termId, Application::TAXONOMY);
79
-        if (isset($term->term_id)) {
80
-            $ratingCounts = $this->manager->flatten($reviewCounts);
81
-            update_term_meta($termId, CountsManager::META_COUNT, $reviewCounts);
82
-            update_term_meta($termId, CountsManager::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
83
-            update_term_meta($termId, CountsManager::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
84
-        }
85
-    }
72
+	/**
73
+	 * @param int $termId
74
+	 * @return void
75
+	 */
76
+	public function update($termId, array $reviewCounts)
77
+	{
78
+		$term = get_term($termId, Application::TAXONOMY);
79
+		if (isset($term->term_id)) {
80
+			$ratingCounts = $this->manager->flatten($reviewCounts);
81
+			update_term_meta($termId, CountsManager::META_COUNT, $reviewCounts);
82
+			update_term_meta($termId, CountsManager::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
83
+			update_term_meta($termId, CountsManager::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
84
+		}
85
+	}
86 86
 
87
-    /**
88
-     * @return void
89
-     */
90
-    public function updateAll()
91
-    {
92
-        $terms = glsr(Database::class)->getTerms([
93
-            'fields' => 'all',
94
-        ]);
95
-        foreach ($terms as $term) {
96
-            $this->update($term->term_id, $this->build($term->term_taxonomy_id));
97
-        }
98
-    }
87
+	/**
88
+	 * @return void
89
+	 */
90
+	public function updateAll()
91
+	{
92
+		$terms = glsr(Database::class)->getTerms([
93
+			'fields' => 'all',
94
+		]);
95
+		foreach ($terms as $term) {
96
+			$this->update($term->term_id, $this->build($term->term_taxonomy_id));
97
+		}
98
+	}
99 99
 }
Please login to merge, or discard this patch.
plugin/Database/PostCountsManager.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -7,85 +7,85 @@
 block discarded – undo
7 7
 
8 8
 class PostCountsManager
9 9
 {
10
-    /**
11
-     * @var CountsManager
12
-     */
13
-    protected $manager;
10
+	/**
11
+	 * @var CountsManager
12
+	 */
13
+	protected $manager;
14 14
 
15
-    public function __construct()
16
-    {
17
-        $this->manager = glsr(CountsManager::class);
18
-    }
15
+	public function __construct()
16
+	{
17
+		$this->manager = glsr(CountsManager::class);
18
+	}
19 19
 
20
-    /**
21
-     * @param int $postId
22
-     * @return array
23
-     */
24
-    public function build($postId)
25
-    {
26
-        return $this->manager->buildCounts([
27
-            'post_ids' => [$postId],
28
-        ]);
29
-    }
20
+	/**
21
+	 * @param int $postId
22
+	 * @return array
23
+	 */
24
+	public function build($postId)
25
+	{
26
+		return $this->manager->buildCounts([
27
+			'post_ids' => [$postId],
28
+		]);
29
+	}
30 30
 
31
-    /**
32
-     * @return void
33
-     */
34
-    public function decrease(Review $review)
35
-    {
36
-        if (empty($counts = $this->get($review->assigned_to))) {
37
-            return;
38
-        }
39
-        $this->update($review->assigned_to,
40
-            $this->manager->decreaseRating($counts, $review->review_type, $review->rating)
41
-        );
42
-    }
31
+	/**
32
+	 * @return void
33
+	 */
34
+	public function decrease(Review $review)
35
+	{
36
+		if (empty($counts = $this->get($review->assigned_to))) {
37
+			return;
38
+		}
39
+		$this->update($review->assigned_to,
40
+			$this->manager->decreaseRating($counts, $review->review_type, $review->rating)
41
+		);
42
+	}
43 43
 
44
-    /**
45
-     * @param int $postId
46
-     * @return array
47
-     */
48
-    public function get($postId)
49
-    {
50
-        return array_filter((array) get_post_meta($postId, CountsManager::META_COUNT, true));
51
-    }
44
+	/**
45
+	 * @param int $postId
46
+	 * @return array
47
+	 */
48
+	public function get($postId)
49
+	{
50
+		return array_filter((array) get_post_meta($postId, CountsManager::META_COUNT, true));
51
+	}
52 52
 
53
-    /**
54
-     * @return void
55
-     */
56
-    public function increase(Review $review)
57
-    {
58
-        if (!(get_post($review->assigned_to) instanceof \WP_Post)) {
59
-            return;
60
-        }
61
-        $counts = $this->get($review->assigned_to);
62
-        $counts = empty($counts)
63
-            ? $this->build($review->assigned_to)
64
-            : $this->manager->increaseRating($counts, $review->review_type, $review->rating);
65
-        $this->update($review->assigned_to, $counts);
66
-    }
53
+	/**
54
+	 * @return void
55
+	 */
56
+	public function increase(Review $review)
57
+	{
58
+		if (!(get_post($review->assigned_to) instanceof \WP_Post)) {
59
+			return;
60
+		}
61
+		$counts = $this->get($review->assigned_to);
62
+		$counts = empty($counts)
63
+			? $this->build($review->assigned_to)
64
+			: $this->manager->increaseRating($counts, $review->review_type, $review->rating);
65
+		$this->update($review->assigned_to, $counts);
66
+	}
67 67
 
68
-    /**
69
-     * @param int $postId
70
-     * @return void
71
-     */
72
-    public function update($postId, array $reviewCounts)
73
-    {
74
-        $ratingCounts = $this->manager->flatten($reviewCounts);
75
-        update_post_meta($postId, CountsManager::META_COUNT, $reviewCounts);
76
-        update_post_meta($postId, CountsManager::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
77
-        update_post_meta($postId, CountsManager::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
78
-    }
68
+	/**
69
+	 * @param int $postId
70
+	 * @return void
71
+	 */
72
+	public function update($postId, array $reviewCounts)
73
+	{
74
+		$ratingCounts = $this->manager->flatten($reviewCounts);
75
+		update_post_meta($postId, CountsManager::META_COUNT, $reviewCounts);
76
+		update_post_meta($postId, CountsManager::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts));
77
+		update_post_meta($postId, CountsManager::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts));
78
+	}
79 79
 
80
-    /**
81
-     * @return void
82
-     */
83
-    public function updateAll()
84
-    {
85
-        glsr(SqlQueries::class)->deletePostCountMetaKeys(); // @todo test this with SiteGround for race conditions
86
-        $postIds = glsr(SqlQueries::class)->getReviewsMeta('assigned_to');
87
-        foreach ($postIds as $postId) {
88
-            $this->update($postId, $this->build($postId));
89
-        }
90
-    }
80
+	/**
81
+	 * @return void
82
+	 */
83
+	public function updateAll()
84
+	{
85
+		glsr(SqlQueries::class)->deletePostCountMetaKeys(); // @todo test this with SiteGround for race conditions
86
+		$postIds = glsr(SqlQueries::class)->getReviewsMeta('assigned_to');
87
+		foreach ($postIds as $postId) {
88
+			$this->update($postId, $this->build($postId));
89
+		}
90
+	}
91 91
 }
Please login to merge, or discard this patch.
plugin/Controllers/AjaxController.php 1 patch
Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -15,195 +15,195 @@
 block discarded – undo
15 15
 
16 16
 class AjaxController extends Controller
17 17
 {
18
-    /**
19
-     * @return void
20
-     */
21
-    public function routerChangeStatus(array $request)
22
-    {
23
-        wp_send_json_success($this->execute(new ChangeStatus($request)));
24
-    }
18
+	/**
19
+	 * @return void
20
+	 */
21
+	public function routerChangeStatus(array $request)
22
+	{
23
+		wp_send_json_success($this->execute(new ChangeStatus($request)));
24
+	}
25 25
 
26
-    /**
27
-     * @return void
28
-     */
29
-    public function routerClearConsole()
30
-    {
31
-        glsr(AdminController::class)->routerClearConsole();
32
-        wp_send_json_success([
33
-            'console' => glsr(Console::class)->get(),
34
-            'notices' => glsr(Notice::class)->get(),
35
-        ]);
36
-    }
26
+	/**
27
+	 * @return void
28
+	 */
29
+	public function routerClearConsole()
30
+	{
31
+		glsr(AdminController::class)->routerClearConsole();
32
+		wp_send_json_success([
33
+			'console' => glsr(Console::class)->get(),
34
+			'notices' => glsr(Notice::class)->get(),
35
+		]);
36
+	}
37 37
 
38
-    /**
39
-     * @return void
40
-     */
41
-    public function routerCountReviews()
42
-    {
43
-        glsr(AdminController::class)->routerCountReviews();
44
-        wp_send_json_success([
45
-            'notices' => glsr(Notice::class)->get(),
46
-        ]);
47
-    }
38
+	/**
39
+	 * @return void
40
+	 */
41
+	public function routerCountReviews()
42
+	{
43
+		glsr(AdminController::class)->routerCountReviews();
44
+		wp_send_json_success([
45
+			'notices' => glsr(Notice::class)->get(),
46
+		]);
47
+	}
48 48
 
49
-    /**
50
-     * @return void
51
-     */
52
-    public function routerMigrateReviews()
53
-    {
54
-        glsr(AdminController::class)->routerMigrateReviews();
55
-        wp_send_json_success([
56
-            'notices' => glsr(Notice::class)->get(),
57
-        ]);
58
-    }
49
+	/**
50
+	 * @return void
51
+	 */
52
+	public function routerMigrateReviews()
53
+	{
54
+		glsr(AdminController::class)->routerMigrateReviews();
55
+		wp_send_json_success([
56
+			'notices' => glsr(Notice::class)->get(),
57
+		]);
58
+	}
59 59
 
60
-    /**
61
-     * @return void
62
-     */
63
-    public function routerDismissNotice(array $request)
64
-    {
65
-        glsr(NoticeController::class)->routerDismissNotice($request);
66
-        wp_send_json_success();
67
-    }
60
+	/**
61
+	 * @return void
62
+	 */
63
+	public function routerDismissNotice(array $request)
64
+	{
65
+		glsr(NoticeController::class)->routerDismissNotice($request);
66
+		wp_send_json_success();
67
+	}
68 68
 
69
-    /**
70
-     * @return void
71
-     */
72
-    public function routerMceShortcode(array $request)
73
-    {
74
-        $shortcode = $request['shortcode'];
75
-        $response = false;
76
-        if (array_key_exists($shortcode, glsr()->mceShortcodes)) {
77
-            $data = glsr()->mceShortcodes[$shortcode];
78
-            if (!empty($data['errors'])) {
79
-                $data['btn_okay'] = [esc_html__('Okay', 'site-reviews')];
80
-            }
81
-            $response = [
82
-                'body' => $data['fields'],
83
-                'close' => $data['btn_close'],
84
-                'ok' => $data['btn_okay'],
85
-                'shortcode' => $shortcode,
86
-                'title' => $data['title'],
87
-            ];
88
-        }
89
-        wp_send_json_success($response);
90
-    }
69
+	/**
70
+	 * @return void
71
+	 */
72
+	public function routerMceShortcode(array $request)
73
+	{
74
+		$shortcode = $request['shortcode'];
75
+		$response = false;
76
+		if (array_key_exists($shortcode, glsr()->mceShortcodes)) {
77
+			$data = glsr()->mceShortcodes[$shortcode];
78
+			if (!empty($data['errors'])) {
79
+				$data['btn_okay'] = [esc_html__('Okay', 'site-reviews')];
80
+			}
81
+			$response = [
82
+				'body' => $data['fields'],
83
+				'close' => $data['btn_close'],
84
+				'ok' => $data['btn_okay'],
85
+				'shortcode' => $shortcode,
86
+				'title' => $data['title'],
87
+			];
88
+		}
89
+		wp_send_json_success($response);
90
+	}
91 91
 
92
-    /**
93
-     * @return void
94
-     */
95
-    public function routerFetchConsole()
96
-    {
97
-        glsr(AdminController::class)->routerFetchConsole();
98
-        wp_send_json_success([
99
-            'console' => glsr(Console::class)->get(),
100
-            'notices' => glsr(Notice::class)->get(),
101
-        ]);
102
-    }
92
+	/**
93
+	 * @return void
94
+	 */
95
+	public function routerFetchConsole()
96
+	{
97
+		glsr(AdminController::class)->routerFetchConsole();
98
+		wp_send_json_success([
99
+			'console' => glsr(Console::class)->get(),
100
+			'notices' => glsr(Notice::class)->get(),
101
+		]);
102
+	}
103 103
 
104
-    /**
105
-     * @return void
106
-     */
107
-    public function routerResetPermissions()
108
-    {
109
-        glsr(Role::class)->resetAll();
110
-        glsr(Notice::class)->clear()->addSuccess(__('The permissions have been reset, please reload the page for them to take effect.', 'site-reviews'));
111
-        wp_send_json_success([
112
-            'notices' => glsr(Notice::class)->get(),
113
-        ]);
114
-    }
104
+	/**
105
+	 * @return void
106
+	 */
107
+	public function routerResetPermissions()
108
+	{
109
+		glsr(Role::class)->resetAll();
110
+		glsr(Notice::class)->clear()->addSuccess(__('The permissions have been reset, please reload the page for them to take effect.', 'site-reviews'));
111
+		wp_send_json_success([
112
+			'notices' => glsr(Notice::class)->get(),
113
+		]);
114
+	}
115 115
 
116
-    /**
117
-     * @return void
118
-     */
119
-    public function routerSearchPosts(array $request)
120
-    {
121
-        $results = glsr(Database::class)->searchPosts($request['search']);
122
-        wp_send_json_success([
123
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
124
-            'items' => $results,
125
-        ]);
126
-    }
116
+	/**
117
+	 * @return void
118
+	 */
119
+	public function routerSearchPosts(array $request)
120
+	{
121
+		$results = glsr(Database::class)->searchPosts($request['search']);
122
+		wp_send_json_success([
123
+			'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
124
+			'items' => $results,
125
+		]);
126
+	}
127 127
 
128
-    /**
129
-     * @return void
130
-     */
131
-    public function routerSearchTranslations(array $request)
132
-    {
133
-        if (empty($request['exclude'])) {
134
-            $request['exclude'] = [];
135
-        }
136
-        $results = glsr(Translation::class)
137
-            ->search($request['search'])
138
-            ->exclude()
139
-            ->exclude($request['exclude'])
140
-            ->renderResults();
141
-        wp_send_json_success([
142
-            'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
143
-            'items' => $results,
144
-        ]);
145
-    }
128
+	/**
129
+	 * @return void
130
+	 */
131
+	public function routerSearchTranslations(array $request)
132
+	{
133
+		if (empty($request['exclude'])) {
134
+			$request['exclude'] = [];
135
+		}
136
+		$results = glsr(Translation::class)
137
+			->search($request['search'])
138
+			->exclude()
139
+			->exclude($request['exclude'])
140
+			->renderResults();
141
+		wp_send_json_success([
142
+			'empty' => '<div>'.__('Nothing found.', 'site-reviews').'</div>',
143
+			'items' => $results,
144
+		]);
145
+	}
146 146
 
147
-    /**
148
-     * @return void
149
-     */
150
-    public function routerSubmitReview(array $request)
151
-    {
152
-        $command = glsr(PublicController::class)->routerSubmitReview($request);
153
-        $redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true)));
154
-        $redirect = apply_filters('site-reviews/review/redirect', $redirect, $command);
155
-        $data = [
156
-            'errors' => glsr()->sessionGet($command->form_id.'errors', false),
157
-            'message' => glsr()->sessionGet($command->form_id.'message', ''),
158
-            'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false),
159
-            'redirect' => $redirect,
160
-        ];
161
-        if (false === $data['errors']) {
162
-            glsr()->sessionClear();
163
-            wp_send_json_success($data);
164
-        }
165
-        wp_send_json_error($data);
166
-    }
147
+	/**
148
+	 * @return void
149
+	 */
150
+	public function routerSubmitReview(array $request)
151
+	{
152
+		$command = glsr(PublicController::class)->routerSubmitReview($request);
153
+		$redirect = trim(strval(get_post_meta($command->post_id, 'redirect_to', true)));
154
+		$redirect = apply_filters('site-reviews/review/redirect', $redirect, $command);
155
+		$data = [
156
+			'errors' => glsr()->sessionGet($command->form_id.'errors', false),
157
+			'message' => glsr()->sessionGet($command->form_id.'message', ''),
158
+			'recaptcha' => glsr()->sessionGet($command->form_id.'recaptcha', false),
159
+			'redirect' => $redirect,
160
+		];
161
+		if (false === $data['errors']) {
162
+			glsr()->sessionClear();
163
+			wp_send_json_success($data);
164
+		}
165
+		wp_send_json_error($data);
166
+	}
167 167
 
168
-    /**
169
-     * @return void
170
-     */
171
-    public function routerFetchPagedReviews(array $request)
172
-    {
173
-        $args = [
174
-            'paged' => Arr::get($request, 'page', false),
175
-            'pagedUrl' => '',
176
-            'pagination' => 'ajax',
177
-            'schema' => false,
178
-        ];
179
-        if (!$args['paged']) {
180
-            $homePath = untrailingslashit(parse_url(home_url(), PHP_URL_PATH));
181
-            $urlPath = untrailingslashit(parse_url(Arr::get($request, 'url'), PHP_URL_PATH));
182
-            $urlQuery = [];
183
-            parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery);
184
-            $args['paged'] = (int) Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1);
185
-            $args['pagedUrl'] = $homePath === $urlPath
186
-                ? trailingslashit(home_url())
187
-                : trailingslashit(home_url($urlPath));
188
-        }
189
-        $atts = (array) json_decode(Arr::get($request, 'atts'));
190
-        $atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts);
191
-        $html = glsr(SiteReviewsPartial::class)->build(wp_parse_args($args, $atts));
192
-        return wp_send_json_success([
193
-            'pagination' => $html->getPagination(),
194
-            'reviews' => $html->getReviews(),
195
-        ]);
196
-    }
168
+	/**
169
+	 * @return void
170
+	 */
171
+	public function routerFetchPagedReviews(array $request)
172
+	{
173
+		$args = [
174
+			'paged' => Arr::get($request, 'page', false),
175
+			'pagedUrl' => '',
176
+			'pagination' => 'ajax',
177
+			'schema' => false,
178
+		];
179
+		if (!$args['paged']) {
180
+			$homePath = untrailingslashit(parse_url(home_url(), PHP_URL_PATH));
181
+			$urlPath = untrailingslashit(parse_url(Arr::get($request, 'url'), PHP_URL_PATH));
182
+			$urlQuery = [];
183
+			parse_str(parse_url(Arr::get($request, 'url'), PHP_URL_QUERY), $urlQuery);
184
+			$args['paged'] = (int) Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1);
185
+			$args['pagedUrl'] = $homePath === $urlPath
186
+				? trailingslashit(home_url())
187
+				: trailingslashit(home_url($urlPath));
188
+		}
189
+		$atts = (array) json_decode(Arr::get($request, 'atts'));
190
+		$atts = glsr(SiteReviewsShortcode::class)->normalizeAtts($atts);
191
+		$html = glsr(SiteReviewsPartial::class)->build(wp_parse_args($args, $atts));
192
+		return wp_send_json_success([
193
+			'pagination' => $html->getPagination(),
194
+			'reviews' => $html->getReviews(),
195
+		]);
196
+	}
197 197
 
198
-    /**
199
-     * @return void
200
-     */
201
-    public function routerTogglePinned(array $request)
202
-    {
203
-        $isPinned = $this->execute(new TogglePinned($request));
204
-        wp_send_json_success([
205
-            'notices' => glsr(Notice::class)->get(),
206
-            'pinned' => $isPinned,
207
-        ]);
208
-    }
198
+	/**
199
+	 * @return void
200
+	 */
201
+	public function routerTogglePinned(array $request)
202
+	{
203
+		$isPinned = $this->execute(new TogglePinned($request));
204
+		wp_send_json_success([
205
+			'notices' => glsr(Notice::class)->get(),
206
+			'pinned' => $isPinned,
207
+		]);
208
+	}
209 209
 }
Please login to merge, or discard this patch.
config/settings.php 1 patch
Indentation   +561 added lines, -561 removed lines patch added patch discarded remove patch
@@ -1,565 +1,565 @@
 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.trustalyze' => [
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://trustalyze.com/plans?ref=105" target="_blank">Trustalyze Confidence System</a>'
62
-        ),
63
-        'label' => __('Blockchain Validation', 'site-reviews'),
64
-        'type' => 'yes_no',
65
-    ],
66
-    'settings.general.trustalyze_email' => [
67
-        'default' => '',
68
-        'depends_on' => [
69
-            'settings.general.trustalyze' => ['yes'],
70
-        ],
71
-        'description' => __('Enter your Trustalyze account email here.', 'site-reviews'),
72
-        'label' => __('Trustalyze Email', 'site-reviews'),
73
-        'type' => 'text',
74
-    ],
75
-    'settings.general.trustalyze_serial' => [
76
-        'default' => '',
77
-        'depends_on' => [
78
-            'settings.general.trustalyze' => ['yes'],
79
-        ],
80
-        'description' => __('Enter your Trustalyze account serial key here.', 'site-reviews'),
81
-        'label' => __('Trustalyze 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='.glsr()->post_type.'&page=settings#tab-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.reviews.pagination.url_parameter' => [
240
-        'default' => 'yes',
241
-        'description' => sprintf(
242
-            _x('Paginated URLs include the %s URL parameter. If you would like to keep the pagination links but prevent search engines from indexing them, add the following lines to your %s file instead: %s', 'admin-text', 'site-reviews'),
243
-            '<code>?'.glsr()->constant('PAGED_QUERY_VAR').'={page_number}</code>',
244
-            '<a href="https://www.robotstxt.org/">robots.txt</a>',
245
-            '<br><code>user-agent: *</code>'.
246
-            '<br><code>Disallow: /*?'.glsr()->constant('PAGED_QUERY_VAR').'=*</code>'.
247
-            '<br><code>Disallow: /*?*'.glsr()->constant('PAGED_QUERY_VAR').'=*</code>'
248
-        ),
249
-        'label' => esc_html_x('Enable Paginated URLs', 'admin-text', 'site-reviews'),
250
-        'type' => 'yes_no',
251
-    ],
252
-    'settings.schema.type.default' => [
253
-        'default' => 'LocalBusiness',
254
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_type</code>',
255
-        'label' => __('Default Schema Type', 'site-reviews'),
256
-        'options' => [
257
-            'LocalBusiness' => __('Local Business', 'site-reviews'),
258
-            'Product' => __('Product', 'site-reviews'),
259
-            'custom' => __('Custom', 'site-reviews'),
260
-        ],
261
-        'type' => 'select',
262
-    ],
263
-    'settings.schema.type.custom' => [
264
-        'default' => '',
265
-        'depends_on' => [
266
-            'settings.schema.type.default' => 'custom',
267
-        ],
268
-        'description' => '<a href="https://schema.org/docs/schemas.html">'.__('View more information on schema types here', 'site-reviews').'</a>',
269
-        'label' => __('Custom Schema Type', 'site-reviews'),
270
-        'type' => 'text',
271
-    ],
272
-    'settings.schema.name.default' => [
273
-        'default' => 'post',
274
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_name</code>',
275
-        'label' => __('Default Name', 'site-reviews'),
276
-        'options' => [
277
-            'post' => __('Use the assigned or current page title', 'site-reviews'),
278
-            'custom' => __('Enter a custom title', 'site-reviews'),
279
-        ],
280
-        'type' => 'select',
281
-    ],
282
-    'settings.schema.name.custom' => [
283
-        'default' => '',
284
-        'depends_on' => [
285
-            'settings.schema.name.default' => 'custom',
286
-        ],
287
-        'label' => __('Custom Name', 'site-reviews'),
288
-        'type' => 'text',
289
-    ],
290
-    'settings.schema.description.default' => [
291
-        'default' => 'post',
292
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_description</code>',
293
-        'label' => __('Default Description', 'site-reviews'),
294
-        'options' => [
295
-            'post' => __('Use the assigned or current page excerpt', 'site-reviews'),
296
-            'custom' => __('Enter a custom description', 'site-reviews'),
297
-        ],
298
-        'type' => 'select',
299
-    ],
300
-    'settings.schema.description.custom' => [
301
-        'default' => '',
302
-        'depends_on' => [
303
-            'settings.schema.description.default' => 'custom',
304
-        ],
305
-        'label' => __('Custom Description', 'site-reviews'),
306
-        'type' => 'text',
307
-    ],
308
-    'settings.schema.url.default' => [
309
-        'default' => 'post',
310
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_url</code>',
311
-        'label' => __('Default URL', 'site-reviews'),
312
-        'options' => [
313
-            'post' => __('Use the assigned or current page URL', 'site-reviews'),
314
-            'custom' => __('Enter a custom URL', 'site-reviews'),
315
-        ],
316
-        'type' => 'select',
317
-    ],
318
-    'settings.schema.url.custom' => [
319
-        'default' => '',
320
-        'depends_on' => [
321
-            'settings.schema.url.default' => 'custom',
322
-        ],
323
-        'label' => __('Custom URL', 'site-reviews'),
324
-        'type' => 'text',
325
-    ],
326
-    'settings.schema.image.default' => [
327
-        'default' => 'post',
328
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_image</code>',
329
-        'label' => __('Default Image', 'site-reviews'),
330
-        'options' => [
331
-            'post' => __('Use the featured image of the assigned or current page', 'site-reviews'),
332
-            'custom' => __('Enter a custom image URL', 'site-reviews'),
333
-        ],
334
-        'type' => 'select',
335
-    ],
336
-    'settings.schema.image.custom' => [
337
-        'default' => '',
338
-        'depends_on' => [
339
-            'settings.schema.image.default' => 'custom',
340
-        ],
341
-        'label' => __('Custom Image URL', 'site-reviews'),
342
-        'type' => 'text',
343
-    ],
344
-    'settings.schema.address' => [
345
-        'default' => '',
346
-        'depends_on' => [
347
-            'settings.schema.type.default' => 'LocalBusiness',
348
-        ],
349
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_address</code>',
350
-        'label' => __('Address', 'site-reviews'),
351
-        'placeholder' => '60 29th Street #343, San Francisco, CA 94110, US',
352
-        'type' => 'text',
353
-    ],
354
-    'settings.schema.telephone' => [
355
-        'default' => '',
356
-        'depends_on' => [
357
-            'settings.schema.type.default' => 'LocalBusiness',
358
-        ],
359
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_telephone</code>',
360
-        'label' => __('Telephone Number', 'site-reviews'),
361
-        'placeholder' => '+1 (877) 273-3049',
362
-        'type' => 'text',
363
-    ],
364
-    'settings.schema.pricerange' => [
365
-        'default' => '',
366
-        'depends_on' => [
367
-            'settings.schema.type.default' => 'LocalBusiness',
368
-        ],
369
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricerange</code>',
370
-        'label' => __('Price Range', 'site-reviews'),
371
-        'placeholder' => '$$-$$$',
372
-        'type' => 'text',
373
-    ],
374
-    'settings.schema.offertype' => [
375
-        'default' => 'AggregateOffer',
376
-        'depends_on' => [
377
-            'settings.schema.type.default' => 'Product',
378
-        ],
379
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_offertype</code>',
380
-        'label' => __('Offer Type', 'site-reviews'),
381
-        'options' => [
382
-            'AggregateOffer' => __('AggregateOffer', 'site-reviews'),
383
-            'Offer' => __('Offer', 'site-reviews'),
384
-        ],
385
-        'type' => 'select',
386
-    ],
387
-    'settings.schema.price' => [
388
-        'default' => '',
389
-        'depends_on' => [
390
-            'settings.schema.type.default' => 'Product',
391
-            'settings.schema.offertype' => 'Offer',
392
-        ],
393
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_price</code>',
394
-        'label' => __('Price', 'site-reviews'),
395
-        'placeholder' => '50.00',
396
-        'type' => 'text',
397
-    ],
398
-    'settings.schema.lowprice' => [
399
-        'default' => '',
400
-        'depends_on' => [
401
-            'settings.schema.type.default' => 'Product',
402
-            'settings.schema.offertype' => 'AggregateOffer',
403
-        ],
404
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_lowprice</code>',
405
-        'label' => __('Low Price', 'site-reviews'),
406
-        'placeholder' => '10.00',
407
-        'type' => 'text',
408
-    ],
409
-    'settings.schema.highprice' => [
410
-        'default' => '',
411
-        'depends_on' => [
412
-            'settings.schema.type.default' => 'Product',
413
-            'settings.schema.offertype' => 'AggregateOffer',
414
-        ],
415
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_highprice</code>',
416
-        'label' => __('High Price', 'site-reviews'),
417
-        'placeholder' => '100.00',
418
-        'type' => 'text',
419
-    ],
420
-    'settings.schema.pricecurrency' => [
421
-        'default' => '',
422
-        'depends_on' => [
423
-            'settings.schema.type.default' => 'Product',
424
-        ],
425
-        'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricecurrency</code>',
426
-        'label' => __('Price Currency', 'site-reviews'),
427
-        'placeholder' => 'USD',
428
-        'type' => 'text',
429
-    ],
430
-    'settings.submissions.required' => [
431
-        'default' => ['content', 'email', 'name', 'rating', 'terms', 'title'],
432
-        'description' => __('Choose which fields should be required in the submission form.', 'site-reviews'),
433
-        'label' => __('Required Fields', 'site-reviews'),
434
-        'options' => [
435
-            'rating' => __('Rating', 'site-reviews'),
436
-            'title' => __('Title', 'site-reviews'),
437
-            'content' => __('Review', 'site-reviews'),
438
-            'name' => __('Name', 'site-reviews'),
439
-            'email' => __('Email', 'site-reviews'),
440
-            'terms' => __('Terms', 'site-reviews'),
441
-        ],
442
-        'type' => 'checkbox',
443
-    ],
444
-    'settings.submissions.limit' => [
445
-        'default' => '',
446
-        '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'),
447
-        'label' => __('Limit Reviews', 'site-reviews'),
448
-        'options' => [
449
-            '' => __('No Limit', 'site-reviews'),
450
-            'email' => __('By Email Address', 'site-reviews'),
451
-            'ip_address' => __('By IP Address', 'site-reviews'),
452
-            'username' => __('By Username (will only work for registered users)', 'site-reviews'),
453
-        ],
454
-        'type' => 'select',
455
-    ],
456
-    'settings.submissions.limit_whitelist.email' => [
457
-        'default' => '',
458
-        'depends_on' => [
459
-            'settings.submissions.limit' => ['email'],
460
-        ],
461
-        'description' => __('One Email per line. All emails in the whitelist will be excluded from the review submission limit.', 'site-reviews'),
462
-        'label' => __('Email Whitelist', 'site-reviews'),
463
-        'rows' => 5,
464
-        'type' => 'code',
465
-    ],
466
-    'settings.submissions.limit_whitelist.ip_address' => [
467
-        'default' => '',
468
-        'depends_on' => [
469
-            'settings.submissions.limit' => ['ip_address'],
470
-        ],
471
-        'description' => __('One IP Address per line. All IP Addresses in the whitelist will be excluded from the review submission limit..', 'site-reviews'),
472
-        'label' => __('IP Address Whitelist', 'site-reviews'),
473
-        'rows' => 5,
474
-        'type' => 'code',
475
-    ],
476
-    'settings.submissions.limit_whitelist.username' => [
477
-        'default' => '',
478
-        'depends_on' => [
479
-            'settings.submissions.limit' => ['username'],
480
-        ],
481
-        'description' => __('One Username per line. All registered users with a Username in the whitelist will be excluded from the review submission limit.', 'site-reviews'),
482
-        'label' => __('Username Whitelist', 'site-reviews'),
483
-        'rows' => 5,
484
-        'type' => 'code',
485
-    ],
486
-    'settings.submissions.recaptcha.integration' => [
487
-        'default' => '',
488
-        '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'),
489
-        'label' => __('Invisible reCAPTCHA', 'site-reviews'),
490
-        'options' => [
491
-            '' => 'Do not use reCAPTCHA',
492
-            'all' => 'Use reCAPTCHA',
493
-            'guest' => 'Use reCAPTCHA only for guest users',
494
-        ],
495
-        'type' => 'select',
496
-    ],
497
-    'settings.submissions.recaptcha.key' => [
498
-        'default' => '',
499
-        'depends_on' => [
500
-            'settings.submissions.recaptcha.integration' => ['all', 'guest'],
501
-        ],
502
-        'label' => __('Site Key', 'site-reviews'),
503
-        'type' => 'text',
504
-    ],
505
-    'settings.submissions.recaptcha.secret' => [
506
-        'default' => '',
507
-        'depends_on' => [
508
-            'settings.submissions.recaptcha.integration' => ['all', 'guest'],
509
-        ],
510
-        'label' => __('Site Secret', 'site-reviews'),
511
-        'type' => 'text',
512
-    ],
513
-    'settings.submissions.recaptcha.position' => [
514
-        'default' => 'bottomleft',
515
-        'depends_on' => [
516
-            'settings.submissions.recaptcha.integration' => ['all', 'guest'],
517
-        ],
518
-        'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'),
519
-        'label' => __('Badge Position', 'site-reviews'),
520
-        'options' => [
521
-            'bottomleft' => 'Bottom Left',
522
-            'bottomright' => 'Bottom Right',
523
-            'inline' => 'Inline',
524
-        ],
525
-        'type' => 'select',
526
-    ],
527
-    'settings.submissions.akismet' => [
528
-        'default' => 'no',
529
-        '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'),
530
-        'label' => __('Enable Akismet Integration', 'site-reviews'),
531
-        'type' => 'yes_no',
532
-    ],
533
-    'settings.submissions.blacklist.integration' => [
534
-        'default' => '',
535
-        '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'),
536
-            '<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>'
537
-        ),
538
-        'label' => __('Blacklist', 'site-reviews'),
539
-        'options' => [
540
-            '' => 'Use the Site Reviews Blacklist',
541
-            'comments' => 'Use the WordPress Comment Blacklist',
542
-        ],
543
-        'type' => 'select',
544
-    ],
545
-    'settings.submissions.blacklist.entries' => [
546
-        'default' => '',
547
-        'depends_on' => [
548
-            'settings.submissions.blacklist.integration' => [''],
549
-        ],
550
-        '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'),
551
-        'label' => __('Review Blacklist', 'site-reviews'),
552
-        'rows' => 10,
553
-        'type' => 'code',
554
-    ],
555
-    'settings.submissions.blacklist.action' => [
556
-        'default' => 'unapprove',
557
-        'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'),
558
-        'label' => __('Blacklist Action', 'site-reviews'),
559
-        'options' => [
560
-            'unapprove' => __('Require approval', 'site-reviews'),
561
-            'reject' => __('Reject submission', 'site-reviews'),
562
-        ],
563
-        'type' => 'select',
564
-    ],
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.trustalyze' => [
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://trustalyze.com/plans?ref=105" target="_blank">Trustalyze Confidence System</a>'
62
+		),
63
+		'label' => __('Blockchain Validation', 'site-reviews'),
64
+		'type' => 'yes_no',
65
+	],
66
+	'settings.general.trustalyze_email' => [
67
+		'default' => '',
68
+		'depends_on' => [
69
+			'settings.general.trustalyze' => ['yes'],
70
+		],
71
+		'description' => __('Enter your Trustalyze account email here.', 'site-reviews'),
72
+		'label' => __('Trustalyze Email', 'site-reviews'),
73
+		'type' => 'text',
74
+	],
75
+	'settings.general.trustalyze_serial' => [
76
+		'default' => '',
77
+		'depends_on' => [
78
+			'settings.general.trustalyze' => ['yes'],
79
+		],
80
+		'description' => __('Enter your Trustalyze account serial key here.', 'site-reviews'),
81
+		'label' => __('Trustalyze 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='.glsr()->post_type.'&page=settings#tab-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.reviews.pagination.url_parameter' => [
240
+		'default' => 'yes',
241
+		'description' => sprintf(
242
+			_x('Paginated URLs include the %s URL parameter. If you would like to keep the pagination links but prevent search engines from indexing them, add the following lines to your %s file instead: %s', 'admin-text', 'site-reviews'),
243
+			'<code>?'.glsr()->constant('PAGED_QUERY_VAR').'={page_number}</code>',
244
+			'<a href="https://www.robotstxt.org/">robots.txt</a>',
245
+			'<br><code>user-agent: *</code>'.
246
+			'<br><code>Disallow: /*?'.glsr()->constant('PAGED_QUERY_VAR').'=*</code>'.
247
+			'<br><code>Disallow: /*?*'.glsr()->constant('PAGED_QUERY_VAR').'=*</code>'
248
+		),
249
+		'label' => esc_html_x('Enable Paginated URLs', 'admin-text', 'site-reviews'),
250
+		'type' => 'yes_no',
251
+	],
252
+	'settings.schema.type.default' => [
253
+		'default' => 'LocalBusiness',
254
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_type</code>',
255
+		'label' => __('Default Schema Type', 'site-reviews'),
256
+		'options' => [
257
+			'LocalBusiness' => __('Local Business', 'site-reviews'),
258
+			'Product' => __('Product', 'site-reviews'),
259
+			'custom' => __('Custom', 'site-reviews'),
260
+		],
261
+		'type' => 'select',
262
+	],
263
+	'settings.schema.type.custom' => [
264
+		'default' => '',
265
+		'depends_on' => [
266
+			'settings.schema.type.default' => 'custom',
267
+		],
268
+		'description' => '<a href="https://schema.org/docs/schemas.html">'.__('View more information on schema types here', 'site-reviews').'</a>',
269
+		'label' => __('Custom Schema Type', 'site-reviews'),
270
+		'type' => 'text',
271
+	],
272
+	'settings.schema.name.default' => [
273
+		'default' => 'post',
274
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_name</code>',
275
+		'label' => __('Default Name', 'site-reviews'),
276
+		'options' => [
277
+			'post' => __('Use the assigned or current page title', 'site-reviews'),
278
+			'custom' => __('Enter a custom title', 'site-reviews'),
279
+		],
280
+		'type' => 'select',
281
+	],
282
+	'settings.schema.name.custom' => [
283
+		'default' => '',
284
+		'depends_on' => [
285
+			'settings.schema.name.default' => 'custom',
286
+		],
287
+		'label' => __('Custom Name', 'site-reviews'),
288
+		'type' => 'text',
289
+	],
290
+	'settings.schema.description.default' => [
291
+		'default' => 'post',
292
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_description</code>',
293
+		'label' => __('Default Description', 'site-reviews'),
294
+		'options' => [
295
+			'post' => __('Use the assigned or current page excerpt', 'site-reviews'),
296
+			'custom' => __('Enter a custom description', 'site-reviews'),
297
+		],
298
+		'type' => 'select',
299
+	],
300
+	'settings.schema.description.custom' => [
301
+		'default' => '',
302
+		'depends_on' => [
303
+			'settings.schema.description.default' => 'custom',
304
+		],
305
+		'label' => __('Custom Description', 'site-reviews'),
306
+		'type' => 'text',
307
+	],
308
+	'settings.schema.url.default' => [
309
+		'default' => 'post',
310
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_url</code>',
311
+		'label' => __('Default URL', 'site-reviews'),
312
+		'options' => [
313
+			'post' => __('Use the assigned or current page URL', 'site-reviews'),
314
+			'custom' => __('Enter a custom URL', 'site-reviews'),
315
+		],
316
+		'type' => 'select',
317
+	],
318
+	'settings.schema.url.custom' => [
319
+		'default' => '',
320
+		'depends_on' => [
321
+			'settings.schema.url.default' => 'custom',
322
+		],
323
+		'label' => __('Custom URL', 'site-reviews'),
324
+		'type' => 'text',
325
+	],
326
+	'settings.schema.image.default' => [
327
+		'default' => 'post',
328
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_image</code>',
329
+		'label' => __('Default Image', 'site-reviews'),
330
+		'options' => [
331
+			'post' => __('Use the featured image of the assigned or current page', 'site-reviews'),
332
+			'custom' => __('Enter a custom image URL', 'site-reviews'),
333
+		],
334
+		'type' => 'select',
335
+	],
336
+	'settings.schema.image.custom' => [
337
+		'default' => '',
338
+		'depends_on' => [
339
+			'settings.schema.image.default' => 'custom',
340
+		],
341
+		'label' => __('Custom Image URL', 'site-reviews'),
342
+		'type' => 'text',
343
+	],
344
+	'settings.schema.address' => [
345
+		'default' => '',
346
+		'depends_on' => [
347
+			'settings.schema.type.default' => 'LocalBusiness',
348
+		],
349
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_address</code>',
350
+		'label' => __('Address', 'site-reviews'),
351
+		'placeholder' => '60 29th Street #343, San Francisco, CA 94110, US',
352
+		'type' => 'text',
353
+	],
354
+	'settings.schema.telephone' => [
355
+		'default' => '',
356
+		'depends_on' => [
357
+			'settings.schema.type.default' => 'LocalBusiness',
358
+		],
359
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_telephone</code>',
360
+		'label' => __('Telephone Number', 'site-reviews'),
361
+		'placeholder' => '+1 (877) 273-3049',
362
+		'type' => 'text',
363
+	],
364
+	'settings.schema.pricerange' => [
365
+		'default' => '',
366
+		'depends_on' => [
367
+			'settings.schema.type.default' => 'LocalBusiness',
368
+		],
369
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricerange</code>',
370
+		'label' => __('Price Range', 'site-reviews'),
371
+		'placeholder' => '$$-$$$',
372
+		'type' => 'text',
373
+	],
374
+	'settings.schema.offertype' => [
375
+		'default' => 'AggregateOffer',
376
+		'depends_on' => [
377
+			'settings.schema.type.default' => 'Product',
378
+		],
379
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_offertype</code>',
380
+		'label' => __('Offer Type', 'site-reviews'),
381
+		'options' => [
382
+			'AggregateOffer' => __('AggregateOffer', 'site-reviews'),
383
+			'Offer' => __('Offer', 'site-reviews'),
384
+		],
385
+		'type' => 'select',
386
+	],
387
+	'settings.schema.price' => [
388
+		'default' => '',
389
+		'depends_on' => [
390
+			'settings.schema.type.default' => 'Product',
391
+			'settings.schema.offertype' => 'Offer',
392
+		],
393
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_price</code>',
394
+		'label' => __('Price', 'site-reviews'),
395
+		'placeholder' => '50.00',
396
+		'type' => 'text',
397
+	],
398
+	'settings.schema.lowprice' => [
399
+		'default' => '',
400
+		'depends_on' => [
401
+			'settings.schema.type.default' => 'Product',
402
+			'settings.schema.offertype' => 'AggregateOffer',
403
+		],
404
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_lowprice</code>',
405
+		'label' => __('Low Price', 'site-reviews'),
406
+		'placeholder' => '10.00',
407
+		'type' => 'text',
408
+	],
409
+	'settings.schema.highprice' => [
410
+		'default' => '',
411
+		'depends_on' => [
412
+			'settings.schema.type.default' => 'Product',
413
+			'settings.schema.offertype' => 'AggregateOffer',
414
+		],
415
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_highprice</code>',
416
+		'label' => __('High Price', 'site-reviews'),
417
+		'placeholder' => '100.00',
418
+		'type' => 'text',
419
+	],
420
+	'settings.schema.pricecurrency' => [
421
+		'default' => '',
422
+		'depends_on' => [
423
+			'settings.schema.type.default' => 'Product',
424
+		],
425
+		'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricecurrency</code>',
426
+		'label' => __('Price Currency', 'site-reviews'),
427
+		'placeholder' => 'USD',
428
+		'type' => 'text',
429
+	],
430
+	'settings.submissions.required' => [
431
+		'default' => ['content', 'email', 'name', 'rating', 'terms', 'title'],
432
+		'description' => __('Choose which fields should be required in the submission form.', 'site-reviews'),
433
+		'label' => __('Required Fields', 'site-reviews'),
434
+		'options' => [
435
+			'rating' => __('Rating', 'site-reviews'),
436
+			'title' => __('Title', 'site-reviews'),
437
+			'content' => __('Review', 'site-reviews'),
438
+			'name' => __('Name', 'site-reviews'),
439
+			'email' => __('Email', 'site-reviews'),
440
+			'terms' => __('Terms', 'site-reviews'),
441
+		],
442
+		'type' => 'checkbox',
443
+	],
444
+	'settings.submissions.limit' => [
445
+		'default' => '',
446
+		'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'),
447
+		'label' => __('Limit Reviews', 'site-reviews'),
448
+		'options' => [
449
+			'' => __('No Limit', 'site-reviews'),
450
+			'email' => __('By Email Address', 'site-reviews'),
451
+			'ip_address' => __('By IP Address', 'site-reviews'),
452
+			'username' => __('By Username (will only work for registered users)', 'site-reviews'),
453
+		],
454
+		'type' => 'select',
455
+	],
456
+	'settings.submissions.limit_whitelist.email' => [
457
+		'default' => '',
458
+		'depends_on' => [
459
+			'settings.submissions.limit' => ['email'],
460
+		],
461
+		'description' => __('One Email per line. All emails in the whitelist will be excluded from the review submission limit.', 'site-reviews'),
462
+		'label' => __('Email Whitelist', 'site-reviews'),
463
+		'rows' => 5,
464
+		'type' => 'code',
465
+	],
466
+	'settings.submissions.limit_whitelist.ip_address' => [
467
+		'default' => '',
468
+		'depends_on' => [
469
+			'settings.submissions.limit' => ['ip_address'],
470
+		],
471
+		'description' => __('One IP Address per line. All IP Addresses in the whitelist will be excluded from the review submission limit..', 'site-reviews'),
472
+		'label' => __('IP Address Whitelist', 'site-reviews'),
473
+		'rows' => 5,
474
+		'type' => 'code',
475
+	],
476
+	'settings.submissions.limit_whitelist.username' => [
477
+		'default' => '',
478
+		'depends_on' => [
479
+			'settings.submissions.limit' => ['username'],
480
+		],
481
+		'description' => __('One Username per line. All registered users with a Username in the whitelist will be excluded from the review submission limit.', 'site-reviews'),
482
+		'label' => __('Username Whitelist', 'site-reviews'),
483
+		'rows' => 5,
484
+		'type' => 'code',
485
+	],
486
+	'settings.submissions.recaptcha.integration' => [
487
+		'default' => '',
488
+		'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'),
489
+		'label' => __('Invisible reCAPTCHA', 'site-reviews'),
490
+		'options' => [
491
+			'' => 'Do not use reCAPTCHA',
492
+			'all' => 'Use reCAPTCHA',
493
+			'guest' => 'Use reCAPTCHA only for guest users',
494
+		],
495
+		'type' => 'select',
496
+	],
497
+	'settings.submissions.recaptcha.key' => [
498
+		'default' => '',
499
+		'depends_on' => [
500
+			'settings.submissions.recaptcha.integration' => ['all', 'guest'],
501
+		],
502
+		'label' => __('Site Key', 'site-reviews'),
503
+		'type' => 'text',
504
+	],
505
+	'settings.submissions.recaptcha.secret' => [
506
+		'default' => '',
507
+		'depends_on' => [
508
+			'settings.submissions.recaptcha.integration' => ['all', 'guest'],
509
+		],
510
+		'label' => __('Site Secret', 'site-reviews'),
511
+		'type' => 'text',
512
+	],
513
+	'settings.submissions.recaptcha.position' => [
514
+		'default' => 'bottomleft',
515
+		'depends_on' => [
516
+			'settings.submissions.recaptcha.integration' => ['all', 'guest'],
517
+		],
518
+		'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'),
519
+		'label' => __('Badge Position', 'site-reviews'),
520
+		'options' => [
521
+			'bottomleft' => 'Bottom Left',
522
+			'bottomright' => 'Bottom Right',
523
+			'inline' => 'Inline',
524
+		],
525
+		'type' => 'select',
526
+	],
527
+	'settings.submissions.akismet' => [
528
+		'default' => 'no',
529
+		'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'),
530
+		'label' => __('Enable Akismet Integration', 'site-reviews'),
531
+		'type' => 'yes_no',
532
+	],
533
+	'settings.submissions.blacklist.integration' => [
534
+		'default' => '',
535
+		'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'),
536
+			'<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>'
537
+		),
538
+		'label' => __('Blacklist', 'site-reviews'),
539
+		'options' => [
540
+			'' => 'Use the Site Reviews Blacklist',
541
+			'comments' => 'Use the WordPress Comment Blacklist',
542
+		],
543
+		'type' => 'select',
544
+	],
545
+	'settings.submissions.blacklist.entries' => [
546
+		'default' => '',
547
+		'depends_on' => [
548
+			'settings.submissions.blacklist.integration' => [''],
549
+		],
550
+		'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'),
551
+		'label' => __('Review Blacklist', 'site-reviews'),
552
+		'rows' => 10,
553
+		'type' => 'code',
554
+	],
555
+	'settings.submissions.blacklist.action' => [
556
+		'default' => 'unapprove',
557
+		'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'),
558
+		'label' => __('Blacklist Action', 'site-reviews'),
559
+		'options' => [
560
+			'unapprove' => __('Require approval', 'site-reviews'),
561
+			'reject' => __('Reject submission', 'site-reviews'),
562
+		],
563
+		'type' => 'select',
564
+	],
565 565
 ];
Please login to merge, or discard this patch.
plugin/Modules/Html/Partials/Pagination.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -11,70 +11,70 @@
 block discarded – undo
11 11
 
12 12
 class Pagination implements PartialContract
13 13
 {
14
-    /**
15
-     * @var array
16
-     */
17
-    protected $args;
14
+	/**
15
+	 * @var array
16
+	 */
17
+	protected $args;
18 18
 
19
-    /**
20
-     * @return string
21
-     */
22
-    public function build(array $args = [])
23
-    {
24
-        $this->args = $this->normalize($args);
25
-        if ($this->args['total'] < 2) {
26
-            return '';
27
-        }
28
-        return glsr(Template::class)->build('templates/pagination', [
29
-            'context' => [
30
-                'links' => apply_filters('site-reviews/paginate_links', $this->buildLinks(), $this->args),
31
-                'loader' => '<div class="glsr-loader"></div>',
32
-                'screen_reader_text' => __('Site Reviews navigation', 'site-reviews'),
33
-            ],
34
-        ]);
35
-    }
19
+	/**
20
+	 * @return string
21
+	 */
22
+	public function build(array $args = [])
23
+	{
24
+		$this->args = $this->normalize($args);
25
+		if ($this->args['total'] < 2) {
26
+			return '';
27
+		}
28
+		return glsr(Template::class)->build('templates/pagination', [
29
+			'context' => [
30
+				'links' => apply_filters('site-reviews/paginate_links', $this->buildLinks(), $this->args),
31
+				'loader' => '<div class="glsr-loader"></div>',
32
+				'screen_reader_text' => __('Site Reviews navigation', 'site-reviews'),
33
+			],
34
+		]);
35
+	}
36 36
 
37
-    /**
38
-     * @return string
39
-     */
40
-    protected function buildFauxLinks()
41
-    {
42
-        $links = (array) paginate_links(wp_parse_args(['type' => 'array'], $this->args));
43
-        $pattern = '/(href=["\'])([^"\']*?)(["\'])/i';
44
-        foreach ($links as &$link) {
45
-            if (!preg_match($pattern, $link, $matches)) {
46
-                continue;
47
-            }
48
-            parse_str(parse_url(Arr::get($matches, 2), PHP_URL_QUERY), $urlQuery);
49
-            $page = (int) Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1);
50
-            $replacement = sprintf('data-page="%d" href="#"', $page);
51
-            $link = str_replace(Arr::get($matches, 0), $replacement, $link);
52
-        }
53
-        return implode("\n", $links);
54
-    }
37
+	/**
38
+	 * @return string
39
+	 */
40
+	protected function buildFauxLinks()
41
+	{
42
+		$links = (array) paginate_links(wp_parse_args(['type' => 'array'], $this->args));
43
+		$pattern = '/(href=["\'])([^"\']*?)(["\'])/i';
44
+		foreach ($links as &$link) {
45
+			if (!preg_match($pattern, $link, $matches)) {
46
+				continue;
47
+			}
48
+			parse_str(parse_url(Arr::get($matches, 2), PHP_URL_QUERY), $urlQuery);
49
+			$page = (int) Arr::get($urlQuery, glsr()->constant('PAGED_QUERY_VAR'), 1);
50
+			$replacement = sprintf('data-page="%d" href="#"', $page);
51
+			$link = str_replace(Arr::get($matches, 0), $replacement, $link);
52
+		}
53
+		return implode("\n", $links);
54
+	}
55 55
 
56
-    /**
57
-     * @return string
58
-     */
59
-    protected function buildLinks()
60
-    {
61
-        return glsr(OptionManager::class)->getBool('settings.reviews.pagination.url_parameter')
62
-            ? paginate_links(wp_parse_args(['type' => 'plain'], $this->args))
63
-            : $this->buildFauxLinks();
64
-    }
56
+	/**
57
+	 * @return string
58
+	 */
59
+	protected function buildLinks()
60
+	{
61
+		return glsr(OptionManager::class)->getBool('settings.reviews.pagination.url_parameter')
62
+			? paginate_links(wp_parse_args(['type' => 'plain'], $this->args))
63
+			: $this->buildFauxLinks();
64
+	}
65 65
 
66
-    /**
67
-     * @return array
68
-     */
69
-    protected function normalize(array $args)
70
-    {
71
-        if ($baseUrl = Arr::get($args, 'baseUrl')) {
72
-            $args['base'] = $baseUrl.'%_%';
73
-        }
74
-        $args = wp_parse_args(array_filter($args), [
75
-            'current' => glsr(QueryBuilder::class)->getPaged(),
76
-            'total' => 1,
77
-        ]);
78
-        return glsr(Style::class)->paginationArgs($args);
79
-    }
66
+	/**
67
+	 * @return array
68
+	 */
69
+	protected function normalize(array $args)
70
+	{
71
+		if ($baseUrl = Arr::get($args, 'baseUrl')) {
72
+			$args['base'] = $baseUrl.'%_%';
73
+		}
74
+		$args = wp_parse_args(array_filter($args), [
75
+			'current' => glsr(QueryBuilder::class)->getPaged(),
76
+			'total' => 1,
77
+		]);
78
+		return glsr(Style::class)->paginationArgs($args);
79
+	}
80 80
 }
Please login to merge, or discard this patch.
plugin/Application.php 1 patch
Indentation   +325 added lines, -325 removed lines patch added patch discarded remove patch
@@ -17,356 +17,356 @@
 block discarded – undo
17 17
  */
18 18
 final class Application extends Container
19 19
 {
20
-    const CAPABILITY = 'edit_others_posts';
21
-    const CRON_EVENT = 'site-reviews/schedule/session/purge';
22
-    const ID = 'site-reviews';
23
-    const PAGED_QUERY_VAR = 'reviews-page';
24
-    const POST_TYPE = 'site-review';
25
-    const PREFIX = 'glsr_';
26
-    const TAXONOMY = 'site-review-category';
20
+	const CAPABILITY = 'edit_others_posts';
21
+	const CRON_EVENT = 'site-reviews/schedule/session/purge';
22
+	const ID = 'site-reviews';
23
+	const PAGED_QUERY_VAR = 'reviews-page';
24
+	const POST_TYPE = 'site-review';
25
+	const PREFIX = 'glsr_';
26
+	const TAXONOMY = 'site-review-category';
27 27
 
28
-    public $addons = [];
29
-    public $defaults;
30
-    public $deprecated = [];
31
-    public $file;
32
-    public $languages;
33
-    public $mceShortcodes = []; //defined elsewhere
34
-    public $name;
35
-    public $postTypeColumns = []; // defined elsewhere
36
-    public $reviewTypes;
37
-    public $schemas = []; //defined elsewhere
38
-    public $version;
28
+	public $addons = [];
29
+	public $defaults;
30
+	public $deprecated = [];
31
+	public $file;
32
+	public $languages;
33
+	public $mceShortcodes = []; //defined elsewhere
34
+	public $name;
35
+	public $postTypeColumns = []; // defined elsewhere
36
+	public $reviewTypes;
37
+	public $schemas = []; //defined elsewhere
38
+	public $version;
39 39
 
40
-    public function __construct()
41
-    {
42
-        static::$instance = $this;
43
-        $this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php');
44
-        $plugin = get_file_data($this->file, [
45
-            'languages' => 'Domain Path',
46
-            'name' => 'Plugin Name',
47
-            'version' => 'Version',
48
-        ], 'plugin');
49
-        array_walk($plugin, function ($value, $key) {
50
-            $this->$key = $value;
51
-        });
52
-    }
40
+	public function __construct()
41
+	{
42
+		static::$instance = $this;
43
+		$this->file = realpath(trailingslashit(dirname(__DIR__)).static::ID.'.php');
44
+		$plugin = get_file_data($this->file, [
45
+			'languages' => 'Domain Path',
46
+			'name' => 'Plugin Name',
47
+			'version' => 'Version',
48
+		], 'plugin');
49
+		array_walk($plugin, function ($value, $key) {
50
+			$this->$key = $value;
51
+		});
52
+	}
53 53
 
54
-    /**
55
-     * @return void
56
-     */
57
-    public function activate()
58
-    {
59
-        $this->scheduleCronJob();
60
-        add_option(static::PREFIX.'activated', true);
61
-    }
54
+	/**
55
+	 * @return void
56
+	 */
57
+	public function activate()
58
+	{
59
+		$this->scheduleCronJob();
60
+		add_option(static::PREFIX.'activated', true);
61
+	}
62 62
 
63
-    /**
64
-     * @param string $view
65
-     * @return string
66
-     */
67
-    public function build($view, array $data = [])
68
-    {
69
-        ob_start();
70
-        $this->render($view, $data);
71
-        return ob_get_clean();
72
-    }
63
+	/**
64
+	 * @param string $view
65
+	 * @return string
66
+	 */
67
+	public function build($view, array $data = [])
68
+	{
69
+		ob_start();
70
+		$this->render($view, $data);
71
+		return ob_get_clean();
72
+	}
73 73
 
74
-    /**
75
-     * @param string $capability
76
-     * @return bool
77
-     */
78
-    public function can($capability)
79
-    {
80
-        return $this->make(Role::class)->can($capability);
81
-    }
74
+	/**
75
+	 * @param string $capability
76
+	 * @return bool
77
+	 */
78
+	public function can($capability)
79
+	{
80
+		return $this->make(Role::class)->can($capability);
81
+	}
82 82
 
83
-    /**
84
-     * @return void
85
-     */
86
-    public function catchFatalError()
87
-    {
88
-        $error = error_get_last();
89
-        if (E_ERROR !== Arr::get($error, 'type') || !Str::contains(Arr::get($error, 'message'), $this->path())) {
90
-            return;
91
-        }
92
-        glsr_log()->error($error['message']);
93
-    }
83
+	/**
84
+	 * @return void
85
+	 */
86
+	public function catchFatalError()
87
+	{
88
+		$error = error_get_last();
89
+		if (E_ERROR !== Arr::get($error, 'type') || !Str::contains(Arr::get($error, 'message'), $this->path())) {
90
+			return;
91
+		}
92
+		glsr_log()->error($error['message']);
93
+	}
94 94
 
95
-    /**
96
-     * @param string $name
97
-     * @return array
98
-     */
99
-    public function config($name)
100
-    {
101
-        $configFile = $this->path('config/'.$name.'.php');
102
-        $config = file_exists($configFile)
103
-            ? include $configFile
104
-            : [];
105
-        return apply_filters('site-reviews/config/'.$name, $config);
106
-    }
95
+	/**
96
+	 * @param string $name
97
+	 * @return array
98
+	 */
99
+	public function config($name)
100
+	{
101
+		$configFile = $this->path('config/'.$name.'.php');
102
+		$config = file_exists($configFile)
103
+			? include $configFile
104
+			: [];
105
+		return apply_filters('site-reviews/config/'.$name, $config);
106
+	}
107 107
 
108
-    /**
109
-     * @param string $property
110
-     * @return string
111
-     */
112
-    public function constant($property, $className = 'static')
113
-    {
114
-        $constant = $className.'::'.$property;
115
-        return defined($constant)
116
-            ? apply_filters('site-reviews/const/'.$property, constant($constant))
117
-            : '';
118
-    }
108
+	/**
109
+	 * @param string $property
110
+	 * @return string
111
+	 */
112
+	public function constant($property, $className = 'static')
113
+	{
114
+		$constant = $className.'::'.$property;
115
+		return defined($constant)
116
+			? apply_filters('site-reviews/const/'.$property, constant($constant))
117
+			: '';
118
+	}
119 119
 
120
-    /**
121
-     * @return void
122
-     */
123
-    public function deactivate()
124
-    {
125
-        $this->unscheduleCronJob();
126
-    }
120
+	/**
121
+	 * @return void
122
+	 */
123
+	public function deactivate()
124
+	{
125
+		$this->unscheduleCronJob();
126
+	}
127 127
 
128
-    /**
129
-     * @param string $view
130
-     * @return void|string
131
-     */
132
-    public function file($view)
133
-    {
134
-        $view.= '.php';
135
-        $filePaths = [];
136
-        if (Str::startsWith('templates/', $view)) {
137
-            $filePaths[] = $this->themePath(Str::removePrefix('templates/', $view));
138
-        }
139
-        $filePaths[] = $this->path($view);
140
-        $filePaths[] = $this->path('views/'.$view);
141
-        foreach ($filePaths as $file) {
142
-            if (!file_exists($file)) {
143
-                continue;
144
-            }
145
-            return $file;
146
-        }
147
-    }
128
+	/**
129
+	 * @param string $view
130
+	 * @return void|string
131
+	 */
132
+	public function file($view)
133
+	{
134
+		$view.= '.php';
135
+		$filePaths = [];
136
+		if (Str::startsWith('templates/', $view)) {
137
+			$filePaths[] = $this->themePath(Str::removePrefix('templates/', $view));
138
+		}
139
+		$filePaths[] = $this->path($view);
140
+		$filePaths[] = $this->path('views/'.$view);
141
+		foreach ($filePaths as $file) {
142
+			if (!file_exists($file)) {
143
+				continue;
144
+			}
145
+			return $file;
146
+		}
147
+	}
148 148
 
149
-    /**
150
-     * @return array
151
-     */
152
-    public function getDefaults()
153
-    {
154
-        if (empty($this->defaults)) {
155
-            $this->defaults = $this->make(DefaultsManager::class)->get();
156
-        }
157
-        return apply_filters('site-reviews/get/defaults', $this->defaults);
158
-    }
149
+	/**
150
+	 * @return array
151
+	 */
152
+	public function getDefaults()
153
+	{
154
+		if (empty($this->defaults)) {
155
+			$this->defaults = $this->make(DefaultsManager::class)->get();
156
+		}
157
+		return apply_filters('site-reviews/get/defaults', $this->defaults);
158
+	}
159 159
 
160
-    /**
161
-     * @param string $page
162
-     * @param string $tab
163
-     * @return string
164
-     */
165
-    public function getPermission($page = '', $tab = 'index')
166
-    {
167
-        $fallback = 'edit_posts';
168
-        $permissions = [
169
-            'addons' => 'install_plugins',
170
-            'documentation' => [
171
-                'faq' => 'edit_others_posts',
172
-                'functions' => 'manage_options',
173
-                'hooks' => 'edit_others_posts',
174
-                'index' => 'edit_posts',
175
-                'support' => 'edit_others_posts',
176
-            ],
177
-            'settings' => 'manage_options',
178
-            'tools' => [
179
-                'console' => 'edit_others_posts',
180
-                'general' => 'edit_others_posts',
181
-                'index' => 'edit_others_posts',
182
-                'sync' => 'manage_options',
183
-                'system-info' => 'edit_others_posts',
184
-            ]
185
-        ];
186
-        $permission = Arr::get($permissions, $page, $fallback);
187
-        if (is_array($permission)) {
188
-            $permission = Arr::get($permission, $tab, $fallback);
189
-        }
190
-        return empty($permission) || !is_string($permission)
191
-            ? $fallback
192
-            : $permission;
193
-    }
160
+	/**
161
+	 * @param string $page
162
+	 * @param string $tab
163
+	 * @return string
164
+	 */
165
+	public function getPermission($page = '', $tab = 'index')
166
+	{
167
+		$fallback = 'edit_posts';
168
+		$permissions = [
169
+			'addons' => 'install_plugins',
170
+			'documentation' => [
171
+				'faq' => 'edit_others_posts',
172
+				'functions' => 'manage_options',
173
+				'hooks' => 'edit_others_posts',
174
+				'index' => 'edit_posts',
175
+				'support' => 'edit_others_posts',
176
+			],
177
+			'settings' => 'manage_options',
178
+			'tools' => [
179
+				'console' => 'edit_others_posts',
180
+				'general' => 'edit_others_posts',
181
+				'index' => 'edit_others_posts',
182
+				'sync' => 'manage_options',
183
+				'system-info' => 'edit_others_posts',
184
+			]
185
+		];
186
+		$permission = Arr::get($permissions, $page, $fallback);
187
+		if (is_array($permission)) {
188
+			$permission = Arr::get($permission, $tab, $fallback);
189
+		}
190
+		return empty($permission) || !is_string($permission)
191
+			? $fallback
192
+			: $permission;
193
+	}
194 194
 
195
-    /**
196
-     * @param string $page
197
-     * @param string $tab
198
-     * @return bool
199
-     */
200
-    public function hasPermission($page = '', $tab = 'index')
201
-    {
202
-        $isAdmin = $this->isAdmin();
203
-        return !$isAdmin || ($isAdmin && $this->can($this->getPermission($page, $tab)));
204
-    }
195
+	/**
196
+	 * @param string $page
197
+	 * @param string $tab
198
+	 * @return bool
199
+	 */
200
+	public function hasPermission($page = '', $tab = 'index')
201
+	{
202
+		$isAdmin = $this->isAdmin();
203
+		return !$isAdmin || ($isAdmin && $this->can($this->getPermission($page, $tab)));
204
+	}
205 205
 
206
-    /**
207
-     * @return void
208
-     */
209
-    public function init()
210
-    {
211
-        $this->make(Actions::class)->run();
212
-        $this->make(Filters::class)->run();
213
-    }
206
+	/**
207
+	 * @return void
208
+	 */
209
+	public function init()
210
+	{
211
+		$this->make(Actions::class)->run();
212
+		$this->make(Filters::class)->run();
213
+	}
214 214
 
215
-    /**
216
-     * @return bool
217
-     */
218
-    public function isAdmin()
219
-    {
220
-        return is_admin() && !wp_doing_ajax();
221
-    }
215
+	/**
216
+	 * @return bool
217
+	 */
218
+	public function isAdmin()
219
+	{
220
+		return is_admin() && !wp_doing_ajax();
221
+	}
222 222
 
223
-    /**
224
-     * @param string $file
225
-     * @return string
226
-     */
227
-    public function path($file = '', $realpath = true)
228
-    {
229
-        $path = plugin_dir_path($this->file);
230
-        if (!$realpath) {
231
-            $path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file));
232
-        }
233
-        $path = trailingslashit($path).ltrim(trim($file), '/');
234
-        return apply_filters('site-reviews/path', $path, $file);
235
-    }
223
+	/**
224
+	 * @param string $file
225
+	 * @return string
226
+	 */
227
+	public function path($file = '', $realpath = true)
228
+	{
229
+		$path = plugin_dir_path($this->file);
230
+		if (!$realpath) {
231
+			$path = trailingslashit(WP_PLUGIN_DIR).basename(dirname($this->file));
232
+		}
233
+		$path = trailingslashit($path).ltrim(trim($file), '/');
234
+		return apply_filters('site-reviews/path', $path, $file);
235
+	}
236 236
 
237
-    /**
238
-     * @param object $addon
239
-     * @return void
240
-     */
241
-    public function register($addon)
242
-    {
243
-        try {
244
-            $reflection = new \ReflectionClass($addon);
245
-            if ($id = $reflection->getConstant('ID')) {
246
-                $this->addons[] = $id;
247
-                $this->bind($id, $addon);
248
-                $addon->init();
249
-            }
250
-        } catch(\ReflectionException $e) {
251
-            glsr_log()->error('Attempted to register an invalid addon.');
252
-        }
253
-    }
237
+	/**
238
+	 * @param object $addon
239
+	 * @return void
240
+	 */
241
+	public function register($addon)
242
+	{
243
+		try {
244
+			$reflection = new \ReflectionClass($addon);
245
+			if ($id = $reflection->getConstant('ID')) {
246
+				$this->addons[] = $id;
247
+				$this->bind($id, $addon);
248
+				$addon->init();
249
+			}
250
+		} catch(\ReflectionException $e) {
251
+			glsr_log()->error('Attempted to register an invalid addon.');
252
+		}
253
+	}
254 254
 
255
-    /**
256
-     * @return void
257
-     */
258
-    public function registerAddons()
259
-    {
260
-        do_action('site-reviews/addon/register', $this);
261
-    }
255
+	/**
256
+	 * @return void
257
+	 */
258
+	public function registerAddons()
259
+	{
260
+		do_action('site-reviews/addon/register', $this);
261
+	}
262 262
 
263
-    /**
264
-     * @return void
265
-     */
266
-    public function registerLanguages()
267
-    {
268
-        load_plugin_textdomain(static::ID, false,
269
-            trailingslashit(plugin_basename($this->path()).'/'.$this->languages)
270
-        );
271
-    }
263
+	/**
264
+	 * @return void
265
+	 */
266
+	public function registerLanguages()
267
+	{
268
+		load_plugin_textdomain(static::ID, false,
269
+			trailingslashit(plugin_basename($this->path()).'/'.$this->languages)
270
+		);
271
+	}
272 272
 
273
-    /**
274
-     * @return void
275
-     */
276
-    public function registerReviewTypes()
277
-    {
278
-        $types = apply_filters('site-reviews/addon/types', []);
279
-        $this->reviewTypes = wp_parse_args($types, [
280
-            'local' => __('Local', 'site-reviews'),
281
-        ]);
282
-    }
273
+	/**
274
+	 * @return void
275
+	 */
276
+	public function registerReviewTypes()
277
+	{
278
+		$types = apply_filters('site-reviews/addon/types', []);
279
+		$this->reviewTypes = wp_parse_args($types, [
280
+			'local' => __('Local', 'site-reviews'),
281
+		]);
282
+	}
283 283
 
284
-    /**
285
-     * @param string $view
286
-     * @return void
287
-     */
288
-    public function render($view, array $data = [])
289
-    {
290
-        $view = apply_filters('site-reviews/render/view', $view, $data);
291
-        $file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data);
292
-        if (!file_exists($file)) {
293
-            glsr_log()->error('File not found: '.$file);
294
-            return;
295
-        }
296
-        $data = apply_filters('site-reviews/views/data', $data, $view);
297
-        extract($data);
298
-        include $file;
299
-    }
284
+	/**
285
+	 * @param string $view
286
+	 * @return void
287
+	 */
288
+	public function render($view, array $data = [])
289
+	{
290
+		$view = apply_filters('site-reviews/render/view', $view, $data);
291
+		$file = apply_filters('site-reviews/views/file', $this->file($view), $view, $data);
292
+		if (!file_exists($file)) {
293
+			glsr_log()->error('File not found: '.$file);
294
+			return;
295
+		}
296
+		$data = apply_filters('site-reviews/views/data', $data, $view);
297
+		extract($data);
298
+		include $file;
299
+	}
300 300
 
301
-    /**
302
-     * @return void
303
-     */
304
-    public function scheduleCronJob()
305
-    {
306
-        if (false === wp_next_scheduled(static::CRON_EVENT)) {
307
-            wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT);
308
-        }
309
-    }
301
+	/**
302
+	 * @return void
303
+	 */
304
+	public function scheduleCronJob()
305
+	{
306
+		if (false === wp_next_scheduled(static::CRON_EVENT)) {
307
+			wp_schedule_event(time(), 'twicedaily', static::CRON_EVENT);
308
+		}
309
+	}
310 310
 
311
-    /**
312
-     * @return void
313
-     */
314
-    public function setDefaults()
315
-    {
316
-        if (get_option(static::PREFIX.'activated')) {
317
-            $this->make(DefaultsManager::class)->set();
318
-            delete_option(static::PREFIX.'activated');
319
-        }
320
-    }
311
+	/**
312
+	 * @return void
313
+	 */
314
+	public function setDefaults()
315
+	{
316
+		if (get_option(static::PREFIX.'activated')) {
317
+			$this->make(DefaultsManager::class)->set();
318
+			delete_option(static::PREFIX.'activated');
319
+		}
320
+	}
321 321
 
322
-    /**
323
-     * @param string $file
324
-     * @return string
325
-     */
326
-    public function themePath($file = '')
327
-    {
328
-        return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/');
329
-    }
322
+	/**
323
+	 * @param string $file
324
+	 * @return string
325
+	 */
326
+	public function themePath($file = '')
327
+	{
328
+		return get_stylesheet_directory().'/'.static::ID.'/'.ltrim(trim($file), '/');
329
+	}
330 330
 
331
-    /**
332
-     * @return void
333
-     */
334
-    public function unscheduleCronJob()
335
-    {
336
-        wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT);
337
-    }
331
+	/**
332
+	 * @return void
333
+	 */
334
+	public function unscheduleCronJob()
335
+	{
336
+		wp_unschedule_event(intval(wp_next_scheduled(static::CRON_EVENT)), static::CRON_EVENT);
337
+	}
338 338
 
339
-    /**
340
-     * @param string $path
341
-     * @return string
342
-     */
343
-    public function url($path = '')
344
-    {
345
-        $url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/'));
346
-        return apply_filters('site-reviews/url', $url, $path);
347
-    }
339
+	/**
340
+	 * @param string $path
341
+	 * @return string
342
+	 */
343
+	public function url($path = '')
344
+	{
345
+		$url = esc_url(plugin_dir_url($this->file).ltrim(trim($path), '/'));
346
+		return apply_filters('site-reviews/url', $url, $path);
347
+	}
348 348
 
349
-    /**
350
-     * @param string $versionLevel
351
-     * @return string
352
-     */
353
-    public function version($versionLevel = '')
354
-    {
355
-        $pattern = '/^v?(\d{1,5})(\.\d++)?(\.\d++)?(.+)?$/i';
356
-        preg_match($pattern, $this->version, $matches);
357
-        switch ($versionLevel) {
358
-            case 'major':
359
-                $version = Arr::get($matches, 1);
360
-                break;
361
-            case 'minor':
362
-                $version = Arr::get($matches, 1).Arr::get($matches, 2);
363
-                break;
364
-            case 'patch':
365
-                $version = Arr::get($matches, 1).Arr::get($matches, 2).Arr::get($matches, 3);
366
-                break;
367
-        }
368
-        return empty($version)
369
-            ? $this->version
370
-            : $version;
371
-    }
349
+	/**
350
+	 * @param string $versionLevel
351
+	 * @return string
352
+	 */
353
+	public function version($versionLevel = '')
354
+	{
355
+		$pattern = '/^v?(\d{1,5})(\.\d++)?(\.\d++)?(.+)?$/i';
356
+		preg_match($pattern, $this->version, $matches);
357
+		switch ($versionLevel) {
358
+			case 'major':
359
+				$version = Arr::get($matches, 1);
360
+				break;
361
+			case 'minor':
362
+				$version = Arr::get($matches, 1).Arr::get($matches, 2);
363
+				break;
364
+			case 'patch':
365
+				$version = Arr::get($matches, 1).Arr::get($matches, 2).Arr::get($matches, 3);
366
+				break;
367
+		}
368
+		return empty($version)
369
+			? $this->version
370
+			: $version;
371
+	}
372 372
 }
Please login to merge, or discard this patch.
plugin/Modules/Trustalyze.php 1 patch
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -10,144 +10,144 @@
 block discarded – undo
10 10
 
11 11
 class Trustalyze
12 12
 {
13
-    const API_URL = 'https://www.trustalyze.com/api/rbs/';
14
-    const WEB_URL = 'https://trustalyze.com/plans?ref=105';
13
+	const API_URL = 'https://www.trustalyze.com/api/rbs/';
14
+	const WEB_URL = 'https://trustalyze.com/plans?ref=105';
15 15
 
16
-    public $message;
17
-    public $response;
18
-    public $success;
16
+	public $message;
17
+	public $response;
18
+	public $success;
19 19
 
20
-    /**
21
-     * @return mixed
22
-     */
23
-    public function __get($key)
24
-    {
25
-        return property_exists($this, $key)
26
-            ? $this->$key
27
-            : Arr::get($this->response, $key, null);
28
-    }
20
+	/**
21
+	 * @return mixed
22
+	 */
23
+	public function __get($key)
24
+	{
25
+		return property_exists($this, $key)
26
+			? $this->$key
27
+			: Arr::get($this->response, $key, null);
28
+	}
29 29
 
30
-    /**
31
-     * @return self
32
-     */
33
-    public function activateKey($apiKey = '', $email = '')
34
-    {
35
-        $this->send('api_key_activation.php', [
36
-            'body' => [
37
-                'apikey' => $apiKey ?: 0,
38
-                'domain' => get_home_url(),
39
-                'email' => $email ?: 0,
40
-            ],
41
-        ]);
42
-        return $this;
43
-    }
30
+	/**
31
+	 * @return self
32
+	 */
33
+	public function activateKey($apiKey = '', $email = '')
34
+	{
35
+		$this->send('api_key_activation.php', [
36
+			'body' => [
37
+				'apikey' => $apiKey ?: 0,
38
+				'domain' => get_home_url(),
39
+				'email' => $email ?: 0,
40
+			],
41
+		]);
42
+		return $this;
43
+	}
44 44
 
45
-    /**
46
-     * @return self
47
-     */
48
-    public function reset()
49
-    {
50
-        $this->message = '';
51
-        $this->response = [];
52
-        $this->success = false;
53
-        return $this;
54
-    }
45
+	/**
46
+	 * @return self
47
+	 */
48
+	public function reset()
49
+	{
50
+		$this->message = '';
51
+		$this->response = [];
52
+		$this->success = false;
53
+		return $this;
54
+	}
55 55
 
56
-    /**
57
-     * @return self
58
-     */
59
-    public function sendReview(Review $review)
60
-    {
61
-        $this->send('index.php', [
62
-            'body' => $this->getBodyForReview($review),
63
-            'timeout' => 120,
64
-        ]);
65
-        return $this;
66
-    }
56
+	/**
57
+	 * @return self
58
+	 */
59
+	public function sendReview(Review $review)
60
+	{
61
+		$this->send('index.php', [
62
+			'body' => $this->getBodyForReview($review),
63
+			'timeout' => 120,
64
+		]);
65
+		return $this;
66
+	}
67 67
 
68
-    /**
69
-     * @return self
70
-     */
71
-    public function sendReviewResponse(Review $review)
72
-    {
73
-        $this->send('fetch_customer_reply.php', [
74
-            'body' => $this->getBodyForResponse($review),
75
-        ]);
76
-        return $this;
77
-    }
68
+	/**
69
+	 * @return self
70
+	 */
71
+	public function sendReviewResponse(Review $review)
72
+	{
73
+		$this->send('fetch_customer_reply.php', [
74
+			'body' => $this->getBodyForResponse($review),
75
+		]);
76
+		return $this;
77
+	}
78 78
 
79
-    /**
80
-     * @return array
81
-     */
82
-    protected function getBodyForResponse(Review $review)
83
-    {
84
-        $trustalyzeResponse = [
85
-            'reply' => Str::truncate($review->response, 300),
86
-            'review_id' => glsr(Database::class)->get($review->ID, 'trustalyze'), // this is the trustalyze review ID
87
-            'review_transaction_id' => $review->review_id,
88
-            'type' => 'M',
89
-        ];
90
-        return apply_filters('site-reviews/trustalyze/response', $trustalyzeResponse, $review);
91
-    }
79
+	/**
80
+	 * @return array
81
+	 */
82
+	protected function getBodyForResponse(Review $review)
83
+	{
84
+		$trustalyzeResponse = [
85
+			'reply' => Str::truncate($review->response, 300),
86
+			'review_id' => glsr(Database::class)->get($review->ID, 'trustalyze'), // this is the trustalyze review ID
87
+			'review_transaction_id' => $review->review_id,
88
+			'type' => 'M',
89
+		];
90
+		return apply_filters('site-reviews/trustalyze/response', $trustalyzeResponse, $review);
91
+	}
92 92
 
93
-    /**
94
-     * @return array
95
-     */
96
-    protected function getBodyForReview(Review $review)
97
-    {
98
-        $trustalyzeReview = [
99
-            'domain' => get_home_url(),
100
-            'firstname' => Str::truncate(Str::convertName($review->author, 'first'), 25),
101
-            'rate' => $review->rating,
102
-            'review_transaction_id' => $review->review_id,
103
-            'reviews' => Str::truncate($review->content, 280),
104
-            'sitereview_plugin' => 'yes',
105
-            'title' => Str::truncate($review->title, 35),
106
-            'transaction' => Application::ID, // woocommerce field, not needed for Site Reviews
107
-        ];
108
-        return apply_filters('site-reviews/trustalyze/review', $trustalyzeReview, $review);
109
-    }
93
+	/**
94
+	 * @return array
95
+	 */
96
+	protected function getBodyForReview(Review $review)
97
+	{
98
+		$trustalyzeReview = [
99
+			'domain' => get_home_url(),
100
+			'firstname' => Str::truncate(Str::convertName($review->author, 'first'), 25),
101
+			'rate' => $review->rating,
102
+			'review_transaction_id' => $review->review_id,
103
+			'reviews' => Str::truncate($review->content, 280),
104
+			'sitereview_plugin' => 'yes',
105
+			'title' => Str::truncate($review->title, 35),
106
+			'transaction' => Application::ID, // woocommerce field, not needed for Site Reviews
107
+		];
108
+		return apply_filters('site-reviews/trustalyze/review', $trustalyzeReview, $review);
109
+	}
110 110
 
111
-    /**
112
-     * @param \WP_Error|array $response
113
-     * @return void
114
-     */
115
-    protected function handleResponse($response)
116
-    {
117
-        if (is_wp_error($response)) {
118
-            $this->message = $response->get_error_message();
119
-        } else {
120
-            $responseBody = wp_remote_retrieve_body($response);
121
-            $responseCode = wp_remote_retrieve_response_code($response);
122
-            $responseData = (array) json_decode($responseBody, true);
123
-            $this->response = array_shift($responseData);
124
-            $this->message = Arr::get($this->response, 'msg');
125
-            $this->success = 'success' === Arr::get($this->response, 'result') || 'yes' === Arr::get($this->response, 'success'); // @todo remove this ugly hack!
126
-            if (200 !== $responseCode) {
127
-                glsr_log()->error('Bad response code ['.$responseCode.']');
128
-            }
129
-            if (!$this->success) {
130
-                glsr_log()->error($this->message);
131
-            }
132
-        }
133
-    }
111
+	/**
112
+	 * @param \WP_Error|array $response
113
+	 * @return void
114
+	 */
115
+	protected function handleResponse($response)
116
+	{
117
+		if (is_wp_error($response)) {
118
+			$this->message = $response->get_error_message();
119
+		} else {
120
+			$responseBody = wp_remote_retrieve_body($response);
121
+			$responseCode = wp_remote_retrieve_response_code($response);
122
+			$responseData = (array) json_decode($responseBody, true);
123
+			$this->response = array_shift($responseData);
124
+			$this->message = Arr::get($this->response, 'msg');
125
+			$this->success = 'success' === Arr::get($this->response, 'result') || 'yes' === Arr::get($this->response, 'success'); // @todo remove this ugly hack!
126
+			if (200 !== $responseCode) {
127
+				glsr_log()->error('Bad response code ['.$responseCode.']');
128
+			}
129
+			if (!$this->success) {
130
+				glsr_log()->error($this->message);
131
+			}
132
+		}
133
+	}
134 134
 
135
-    /**
136
-     * @param string $endpoint
137
-     * @return void
138
-     */
139
-    protected function send($endpoint, array $args = [])
140
-    {
141
-        $args = wp_parse_args($args, [
142
-            'body' => null,
143
-            'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
144
-            'redirection' => 5,
145
-            'sslverify' => false,
146
-            'timeout' => 5,
147
-        ]);
148
-        $this->reset();
149
-        $this->handleResponse(
150
-            wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args)
151
-        );
152
-    }
135
+	/**
136
+	 * @param string $endpoint
137
+	 * @return void
138
+	 */
139
+	protected function send($endpoint, array $args = [])
140
+	{
141
+		$args = wp_parse_args($args, [
142
+			'body' => null,
143
+			'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
144
+			'redirection' => 5,
145
+			'sslverify' => false,
146
+			'timeout' => 5,
147
+		]);
148
+		$this->reset();
149
+		$this->handleResponse(
150
+			wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args)
151
+		);
152
+	}
153 153
 }
Please login to merge, or discard this patch.