@@ -49,7 +49,8 @@ |
||
49 | 49 | if ($this->currentVersion !== glsr()->version) { |
50 | 50 | $this->setReviewCounts(); |
51 | 51 | $this->updateVersionFrom($this->currentVersion); |
52 | - } elseif (!glsr(OptionManager::class)->get('last_review_count', false)) { |
|
52 | + } |
|
53 | + elseif (!glsr(OptionManager::class)->get('last_review_count', false)) { |
|
53 | 54 | $this->setReviewCounts(); |
54 | 55 | } |
55 | 56 | } |
@@ -19,7 +19,8 @@ |
||
19 | 19 | if (is_null($command->pinned)) { |
20 | 20 | $meta = glsr(Database::class)->get($command->id, 'pinned'); |
21 | 21 | $command->pinned = !wp_validate_boolean($meta); |
22 | - } else { |
|
22 | + } |
|
23 | + else { |
|
23 | 24 | $notice = $command->pinned |
24 | 25 | ? __('Review pinned.', 'site-reviews') |
25 | 26 | : __('Review unpinned.', 'site-reviews'); |
@@ -194,7 +194,8 @@ |
||
194 | 194 | $dateFormat = $this->getOption('settings.reviews.date.format', 'default'); |
195 | 195 | if ('relative' == $dateFormat) { |
196 | 196 | $date = glsr(Date::class)->relative($value); |
197 | - } else { |
|
197 | + } |
|
198 | + else { |
|
198 | 199 | $format = 'custom' == $dateFormat |
199 | 200 | ? $this->getOption('settings.reviews.date.custom', 'M j, Y') |
200 | 201 | : glsr(OptionManager::class)->getWP('date_format', 'F j, Y'); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @return int |
22 | 22 | */ |
23 | 23 | public function getPostIdFromReviewId($metaReviewId) |
24 | - { |
|
24 | + { |
|
25 | 25 | $postId = $this->db->get_var(" |
26 | 26 | SELECT p.ID |
27 | 27 | FROM {$this->db->posts} AS p |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @return array |
40 | 40 | */ |
41 | 41 | public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500) |
42 | - { |
|
42 | + { |
|
43 | 43 | return (array) $this->db->get_results(" |
44 | 44 | SELECT DISTINCT p.ID, m1.meta_value AS rating, m2.meta_value AS type |
45 | 45 | FROM {$this->db->posts} AS p |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @return array |
64 | 64 | */ |
65 | 65 | public function getReviewCountsFor($metaKey) |
66 | - { |
|
66 | + { |
|
67 | 67 | $metaKey = glsr(Helper::class)->prefixString($metaKey); |
68 | 68 | return (array) $this->db->get_results(" |
69 | 69 | SELECT DISTINCT m.meta_value AS name, COUNT(*) num_posts |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @return array |
82 | 82 | */ |
83 | 83 | public function getReviewIdsByType($reviewType) |
84 | - { |
|
84 | + { |
|
85 | 85 | $results = $this->db->get_col(" |
86 | 86 | SELECT DISTINCT m1.meta_value AS review_id |
87 | 87 | FROM {$this->db->posts} AS p |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @return array |
102 | 102 | */ |
103 | 103 | public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100) |
104 | - { |
|
104 | + { |
|
105 | 105 | sort($postIds); |
106 | 106 | $postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit); |
107 | 107 | $postIds = implode(',', $postIds); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @return array |
127 | 127 | */ |
128 | 128 | public function getReviewsMeta($key, $status = 'publish') |
129 | - { |
|
129 | + { |
|
130 | 130 | $key = glsr(Helper::class)->prefixString($key); |
131 | 131 | $values = $this->db->get_col(" |
132 | 132 | SELECT DISTINCT m.meta_value |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @return string |
149 | 149 | */ |
150 | 150 | protected function getAndForCounts(array $args, $and = '') |
151 | - { |
|
151 | + { |
|
152 | 152 | $postIds = implode(',', array_filter(glsr_get($args, 'post_ids'))); |
153 | 153 | $termIds = implode(',', array_filter(glsr_get($args, 'term_ids'))); |
154 | 154 | if (!empty($args['type'])) { |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @return string |
169 | 169 | */ |
170 | 170 | protected function getInnerJoinForCounts(array $args, $innerJoin = '') |
171 | - { |
|
171 | + { |
|
172 | 172 | if (!empty(glsr_get($args, 'post_ids'))) { |
173 | 173 | $innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id "; |
174 | 174 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @action set_object_terms |
23 | 23 | */ |
24 | 24 | public function onAfterChangeCategory($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds) |
25 | - { |
|
25 | + { |
|
26 | 26 | sort($newTTIds); |
27 | 27 | sort($oldTTIds); |
28 | 28 | if ($newTTIds === $oldTTIds || !$this->isReviewPostId($postId)) { |
@@ -48,14 +48,15 @@ discard block |
||
48 | 48 | * @action transition_post_status |
49 | 49 | */ |
50 | 50 | public function onAfterChangeStatus($newStatus, $oldStatus, $post) |
51 | - { |
|
51 | + { |
|
52 | 52 | if (Application::POST_TYPE != glsr_get($post, 'post_type') || in_array($oldStatus, ['new', $newStatus])) { |
53 | 53 | return; |
54 | 54 | } |
55 | 55 | $review = glsr_get_review($post); |
56 | 56 | if ('publish' == $post->post_status) { |
57 | 57 | glsr(CountsManager::class)->increase($review); |
58 | - } else { |
|
58 | + } |
|
59 | + else { |
|
59 | 60 | glsr(CountsManager::class)->decrease($review); |
60 | 61 | } |
61 | 62 | } |
@@ -65,7 +66,7 @@ discard block |
||
65 | 66 | * @action site-reviews/review/created |
66 | 67 | */ |
67 | 68 | public function onAfterCreate(Review $review) |
68 | - { |
|
69 | + { |
|
69 | 70 | if ('publish' !== $review->status) { |
70 | 71 | return; |
71 | 72 | } |
@@ -78,7 +79,7 @@ discard block |
||
78 | 79 | * @action before_delete_post |
79 | 80 | */ |
80 | 81 | public function onBeforeDelete($postId) |
81 | - { |
|
82 | + { |
|
82 | 83 | if (!$this->isReviewPostId($postId)) { |
83 | 84 | return; |
84 | 85 | } |
@@ -95,7 +96,7 @@ discard block |
||
95 | 96 | * @action update_postmeta |
96 | 97 | */ |
97 | 98 | public function onBeforeUpdate($metaId, $postId, $metaKey, $metaValue) |
98 | - { |
|
99 | + { |
|
99 | 100 | if (!$this->isReviewPostId($postId)) { |
100 | 101 | return; |
101 | 102 | } |
@@ -116,7 +117,7 @@ discard block |
||
116 | 117 | * @return void |
117 | 118 | */ |
118 | 119 | public function onBeforeChangeAssignedTo(Review $review, $assignedTo) |
119 | - { |
|
120 | + { |
|
120 | 121 | glsr(CountsManager::class)->decreasePostCounts($review); |
121 | 122 | $review->assigned_to = $assignedTo; |
122 | 123 | glsr(CountsManager::class)->increasePostCounts($review); |
@@ -127,7 +128,7 @@ discard block |
||
127 | 128 | * @return void |
128 | 129 | */ |
129 | 130 | public function onBeforeChangeRating(Review $review, $rating) |
130 | - { |
|
131 | + { |
|
131 | 132 | glsr(CountsManager::class)->decrease($review); |
132 | 133 | $review->rating = $rating; |
133 | 134 | glsr(CountsManager::class)->increase($review); |
@@ -138,7 +139,7 @@ discard block |
||
138 | 139 | * @return void |
139 | 140 | */ |
140 | 141 | public function onBeforeChangeReviewType(Review $review, $reviewType) |
141 | - { |
|
142 | + { |
|
142 | 143 | glsr(CountsManager::class)->decrease($review); |
143 | 144 | $review->review_type = $reviewType; |
144 | 145 | glsr(CountsManager::class)->increase($review); |