@@ -6,54 +6,54 @@ |
||
6 | 6 | |
7 | 7 | class Blacklist |
8 | 8 | { |
9 | - /** |
|
10 | - * @return bool |
|
11 | - */ |
|
12 | - public function isBlacklisted(array $review) |
|
13 | - { |
|
14 | - $target = implode("\n", array_filter([ |
|
15 | - $review['name'], |
|
16 | - $review['content'], |
|
17 | - $review['email'], |
|
18 | - $review['ip_address'], |
|
19 | - $review['title'], |
|
20 | - ])); |
|
21 | - return (bool) apply_filters('site-reviews/blacklist/is-blacklisted', |
|
22 | - $this->check($target), |
|
23 | - $review, |
|
24 | - $target |
|
25 | - ); |
|
26 | - } |
|
9 | + /** |
|
10 | + * @return bool |
|
11 | + */ |
|
12 | + public function isBlacklisted(array $review) |
|
13 | + { |
|
14 | + $target = implode("\n", array_filter([ |
|
15 | + $review['name'], |
|
16 | + $review['content'], |
|
17 | + $review['email'], |
|
18 | + $review['ip_address'], |
|
19 | + $review['title'], |
|
20 | + ])); |
|
21 | + return (bool) apply_filters('site-reviews/blacklist/is-blacklisted', |
|
22 | + $this->check($target), |
|
23 | + $review, |
|
24 | + $target |
|
25 | + ); |
|
26 | + } |
|
27 | 27 | |
28 | - /** |
|
29 | - * @param string $target |
|
30 | - * @return bool |
|
31 | - */ |
|
32 | - protected function check($target) |
|
33 | - { |
|
34 | - $blacklist = $this->getBlacklist(); |
|
35 | - if (empty($blacklist)) { |
|
36 | - return false; |
|
37 | - } |
|
38 | - $lines = explode("\n", $blacklist); |
|
39 | - foreach ((array) $lines as $line) { |
|
40 | - $line = trim($line); |
|
41 | - if (empty($line) || 256 < strlen($line)) { |
|
42 | - continue; |
|
43 | - } |
|
44 | - $pattern = sprintf('#%s#i', preg_quote($line, '#')); |
|
45 | - if (preg_match($pattern, $target)) { |
|
46 | - return true; |
|
47 | - } |
|
48 | - } |
|
49 | - return false; |
|
50 | - } |
|
28 | + /** |
|
29 | + * @param string $target |
|
30 | + * @return bool |
|
31 | + */ |
|
32 | + protected function check($target) |
|
33 | + { |
|
34 | + $blacklist = $this->getBlacklist(); |
|
35 | + if (empty($blacklist)) { |
|
36 | + return false; |
|
37 | + } |
|
38 | + $lines = explode("\n", $blacklist); |
|
39 | + foreach ((array) $lines as $line) { |
|
40 | + $line = trim($line); |
|
41 | + if (empty($line) || 256 < strlen($line)) { |
|
42 | + continue; |
|
43 | + } |
|
44 | + $pattern = sprintf('#%s#i', preg_quote($line, '#')); |
|
45 | + if (preg_match($pattern, $target)) { |
|
46 | + return true; |
|
47 | + } |
|
48 | + } |
|
49 | + return false; |
|
50 | + } |
|
51 | 51 | |
52 | - protected function getBlacklist() |
|
53 | - { |
|
54 | - $option = glsr(OptionManager::class)->get('settings.submissions.blacklist.integration'); |
|
55 | - return $option == 'comments' |
|
56 | - ? trim(glsr(OptionManager::class)->getWP('blacklist_keys')) |
|
57 | - : trim(glsr(OptionManager::class)->get('settings.submissions.blacklist.entries')); |
|
58 | - } |
|
52 | + protected function getBlacklist() |
|
53 | + { |
|
54 | + $option = glsr(OptionManager::class)->get('settings.submissions.blacklist.integration'); |
|
55 | + return $option == 'comments' |
|
56 | + ? trim(glsr(OptionManager::class)->getWP('blacklist_keys')) |
|
57 | + : trim(glsr(OptionManager::class)->get('settings.submissions.blacklist.entries')); |
|
58 | + } |
|
59 | 59 | } |
@@ -8,164 +8,164 @@ |
||
8 | 8 | |
9 | 9 | class Notification |
10 | 10 | { |
11 | - /** |
|
12 | - * @var bool |
|
13 | - */ |
|
14 | - protected $email; |
|
11 | + /** |
|
12 | + * @var bool |
|
13 | + */ |
|
14 | + protected $email; |
|
15 | 15 | |
16 | - /** |
|
17 | - * @var Review |
|
18 | - */ |
|
19 | - protected $review; |
|
16 | + /** |
|
17 | + * @var Review |
|
18 | + */ |
|
19 | + protected $review; |
|
20 | 20 | |
21 | - /** |
|
22 | - * @var bool |
|
23 | - */ |
|
24 | - protected $slack; |
|
21 | + /** |
|
22 | + * @var bool |
|
23 | + */ |
|
24 | + protected $slack; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected $types; |
|
26 | + /** |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected $types; |
|
30 | 30 | |
31 | - public function __construct() |
|
32 | - { |
|
33 | - $types = glsr(OptionManager::class)->get('settings.general.notifications', []); |
|
34 | - $this->email = count(array_intersect(['admin', 'custom'], $types)) > 0; |
|
35 | - $this->slack = in_array('slack', $types); |
|
36 | - $this->types = $types; |
|
37 | - } |
|
31 | + public function __construct() |
|
32 | + { |
|
33 | + $types = glsr(OptionManager::class)->get('settings.general.notifications', []); |
|
34 | + $this->email = count(array_intersect(['admin', 'custom'], $types)) > 0; |
|
35 | + $this->slack = in_array('slack', $types); |
|
36 | + $this->types = $types; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - public function send(Review $review) |
|
43 | - { |
|
44 | - if (empty($this->types)) { |
|
45 | - return; |
|
46 | - } |
|
47 | - $this->review = $review; |
|
48 | - $args = [ |
|
49 | - 'link' => $this->getLink(), |
|
50 | - 'title' => $this->getTitle(), |
|
51 | - ]; |
|
52 | - $this->sendToEmail($args); |
|
53 | - $this->sendToSlack($args); |
|
54 | - } |
|
39 | + /** |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + public function send(Review $review) |
|
43 | + { |
|
44 | + if (empty($this->types)) { |
|
45 | + return; |
|
46 | + } |
|
47 | + $this->review = $review; |
|
48 | + $args = [ |
|
49 | + 'link' => $this->getLink(), |
|
50 | + 'title' => $this->getTitle(), |
|
51 | + ]; |
|
52 | + $this->sendToEmail($args); |
|
53 | + $this->sendToSlack($args); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return Email |
|
58 | - */ |
|
59 | - protected function buildEmail(array $args) |
|
60 | - { |
|
61 | - return glsr(Email::class)->compose([ |
|
62 | - 'to' => $this->getEmailAddresses(), |
|
63 | - 'subject' => $args['title'], |
|
64 | - 'template' => 'email-notification', |
|
65 | - 'template-tags' => [ |
|
66 | - 'review_author' => $this->review->author ?: __('Anonymous', 'site-reviews'), |
|
67 | - 'review_content' => $this->review->content, |
|
68 | - 'review_email' => $this->review->email, |
|
69 | - 'review_ip' => $this->review->ip_address, |
|
70 | - 'review_link' => sprintf('<a href="%1$s">%1$s</a>', $args['link']), |
|
71 | - 'review_rating' => $this->review->rating, |
|
72 | - 'review_title' => $this->review->title, |
|
73 | - ], |
|
74 | - ]); |
|
75 | - } |
|
56 | + /** |
|
57 | + * @return Email |
|
58 | + */ |
|
59 | + protected function buildEmail(array $args) |
|
60 | + { |
|
61 | + return glsr(Email::class)->compose([ |
|
62 | + 'to' => $this->getEmailAddresses(), |
|
63 | + 'subject' => $args['title'], |
|
64 | + 'template' => 'email-notification', |
|
65 | + 'template-tags' => [ |
|
66 | + 'review_author' => $this->review->author ?: __('Anonymous', 'site-reviews'), |
|
67 | + 'review_content' => $this->review->content, |
|
68 | + 'review_email' => $this->review->email, |
|
69 | + 'review_ip' => $this->review->ip_address, |
|
70 | + 'review_link' => sprintf('<a href="%1$s">%1$s</a>', $args['link']), |
|
71 | + 'review_rating' => $this->review->rating, |
|
72 | + 'review_title' => $this->review->title, |
|
73 | + ], |
|
74 | + ]); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return Slack |
|
79 | - */ |
|
80 | - protected function buildSlackNotification(array $args) |
|
81 | - { |
|
82 | - return glsr(Slack::class)->compose($this->review, [ |
|
83 | - 'button_url' => $args['link'], |
|
84 | - 'fallback' => $this->buildEmail($args)->read('plaintext'), |
|
85 | - 'pretext' => $args['title'], |
|
86 | - ]); |
|
87 | - } |
|
77 | + /** |
|
78 | + * @return Slack |
|
79 | + */ |
|
80 | + protected function buildSlackNotification(array $args) |
|
81 | + { |
|
82 | + return glsr(Slack::class)->compose($this->review, [ |
|
83 | + 'button_url' => $args['link'], |
|
84 | + 'fallback' => $this->buildEmail($args)->read('plaintext'), |
|
85 | + 'pretext' => $args['title'], |
|
86 | + ]); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @return array |
|
91 | - */ |
|
92 | - protected function getEmailAddresses() |
|
93 | - { |
|
94 | - $emails = []; |
|
95 | - if (in_array('admin', $this->types)) { |
|
96 | - $emails[] = glsr(OptionManager::class)->getWP('admin_email'); |
|
97 | - } |
|
98 | - if (in_array('author', $this->types)) { |
|
99 | - $assignedPost = get_post(intval($this->review->assigned_to)); |
|
100 | - if ($assignedPost instanceof WP_Post) { |
|
101 | - $this->email = true; |
|
102 | - $emails[] = get_the_author_meta('user_email', intval($assignedPost->post_author)); |
|
103 | - } |
|
104 | - } |
|
105 | - if (in_array('custom', $this->types)) { |
|
106 | - $customEmails = glsr(OptionManager::class)->get('settings.general.notification_email'); |
|
107 | - $customEmails = str_replace([' ', ',', ';'], ',', $customEmails); |
|
108 | - $customEmails = explode(',', $customEmails); |
|
109 | - $emails = array_merge($emails, $customEmails); |
|
110 | - } |
|
111 | - $emails = array_filter(array_keys(array_flip($emails))); |
|
112 | - return apply_filters('site-reviews/notification/emails', $emails, $this->review); |
|
113 | - } |
|
89 | + /** |
|
90 | + * @return array |
|
91 | + */ |
|
92 | + protected function getEmailAddresses() |
|
93 | + { |
|
94 | + $emails = []; |
|
95 | + if (in_array('admin', $this->types)) { |
|
96 | + $emails[] = glsr(OptionManager::class)->getWP('admin_email'); |
|
97 | + } |
|
98 | + if (in_array('author', $this->types)) { |
|
99 | + $assignedPost = get_post(intval($this->review->assigned_to)); |
|
100 | + if ($assignedPost instanceof WP_Post) { |
|
101 | + $this->email = true; |
|
102 | + $emails[] = get_the_author_meta('user_email', intval($assignedPost->post_author)); |
|
103 | + } |
|
104 | + } |
|
105 | + if (in_array('custom', $this->types)) { |
|
106 | + $customEmails = glsr(OptionManager::class)->get('settings.general.notification_email'); |
|
107 | + $customEmails = str_replace([' ', ',', ';'], ',', $customEmails); |
|
108 | + $customEmails = explode(',', $customEmails); |
|
109 | + $emails = array_merge($emails, $customEmails); |
|
110 | + } |
|
111 | + $emails = array_filter(array_keys(array_flip($emails))); |
|
112 | + return apply_filters('site-reviews/notification/emails', $emails, $this->review); |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * @return string |
|
117 | - */ |
|
118 | - protected function getLink() |
|
119 | - { |
|
120 | - return admin_url('post.php?post='.$this->review->ID.'&action=edit'); |
|
121 | - } |
|
115 | + /** |
|
116 | + * @return string |
|
117 | + */ |
|
118 | + protected function getLink() |
|
119 | + { |
|
120 | + return admin_url('post.php?post='.$this->review->ID.'&action=edit'); |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * @return string |
|
125 | - */ |
|
126 | - protected function getTitle() |
|
127 | - { |
|
128 | - $assignedTitle = get_the_title(intval($this->review->assigned_to)); |
|
129 | - $title = _nx( |
|
130 | - 'New %s-star review', |
|
131 | - 'New %s-star review of: %s', |
|
132 | - intval(empty($assignedTitle)), |
|
133 | - 'This string differs depending on whether or not the review has been assigned to a post.', |
|
134 | - 'site-reviews' |
|
135 | - ); |
|
136 | - $title = sprintf('[%s] %s', |
|
137 | - wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES), |
|
138 | - sprintf($title, $this->review->rating, $assignedTitle) |
|
139 | - ); |
|
140 | - return apply_filters('site-reviews/notification/title', $title, $this->review); |
|
141 | - } |
|
123 | + /** |
|
124 | + * @return string |
|
125 | + */ |
|
126 | + protected function getTitle() |
|
127 | + { |
|
128 | + $assignedTitle = get_the_title(intval($this->review->assigned_to)); |
|
129 | + $title = _nx( |
|
130 | + 'New %s-star review', |
|
131 | + 'New %s-star review of: %s', |
|
132 | + intval(empty($assignedTitle)), |
|
133 | + 'This string differs depending on whether or not the review has been assigned to a post.', |
|
134 | + 'site-reviews' |
|
135 | + ); |
|
136 | + $title = sprintf('[%s] %s', |
|
137 | + wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES), |
|
138 | + sprintf($title, $this->review->rating, $assignedTitle) |
|
139 | + ); |
|
140 | + return apply_filters('site-reviews/notification/title', $title, $this->review); |
|
141 | + } |
|
142 | 142 | |
143 | - /** |
|
144 | - * @return void |
|
145 | - */ |
|
146 | - protected function sendToEmail(array $args) |
|
147 | - { |
|
148 | - $email = $this->buildEmail($args); |
|
149 | - if (empty($email->to)) { |
|
150 | - glsr_log()->error('Email notification was not sent (missing email address)'); |
|
151 | - return; |
|
152 | - } |
|
153 | - $email->send(); |
|
154 | - } |
|
143 | + /** |
|
144 | + * @return void |
|
145 | + */ |
|
146 | + protected function sendToEmail(array $args) |
|
147 | + { |
|
148 | + $email = $this->buildEmail($args); |
|
149 | + if (empty($email->to)) { |
|
150 | + glsr_log()->error('Email notification was not sent (missing email address)'); |
|
151 | + return; |
|
152 | + } |
|
153 | + $email->send(); |
|
154 | + } |
|
155 | 155 | |
156 | - /** |
|
157 | - * @return void |
|
158 | - */ |
|
159 | - protected function sendToSlack(array $args) |
|
160 | - { |
|
161 | - if (!$this->slack) { |
|
162 | - return; |
|
163 | - } |
|
164 | - $notification = $this->buildSlackNotification($args); |
|
165 | - $result = $notification->send(); |
|
166 | - if (is_wp_error($result)) { |
|
167 | - $notification->review = null; |
|
168 | - glsr_log()->error($result->get_error_message())->debug($notification); |
|
169 | - } |
|
170 | - } |
|
156 | + /** |
|
157 | + * @return void |
|
158 | + */ |
|
159 | + protected function sendToSlack(array $args) |
|
160 | + { |
|
161 | + if (!$this->slack) { |
|
162 | + return; |
|
163 | + } |
|
164 | + $notification = $this->buildSlackNotification($args); |
|
165 | + $result = $notification->send(); |
|
166 | + if (is_wp_error($result)) { |
|
167 | + $notification->review = null; |
|
168 | + glsr_log()->error($result->get_error_message())->debug($notification); |
|
169 | + } |
|
170 | + } |
|
171 | 171 | } |
@@ -7,33 +7,33 @@ |
||
7 | 7 | |
8 | 8 | class Metaboxes |
9 | 9 | { |
10 | - /** |
|
11 | - * @param int $postId |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function saveAssignedToMetabox($postId) |
|
15 | - { |
|
16 | - if (!wp_verify_nonce(glsr(Helper::class)->filterInput('_nonce-assigned-to'), 'assigned_to')) { |
|
17 | - return; |
|
18 | - } |
|
19 | - $assignedTo = strval(glsr(Helper::class)->filterInput('assigned_to')); |
|
20 | - glsr(Database::class)->update($postId, 'assigned_to', $assignedTo); |
|
21 | - } |
|
10 | + /** |
|
11 | + * @param int $postId |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function saveAssignedToMetabox($postId) |
|
15 | + { |
|
16 | + if (!wp_verify_nonce(glsr(Helper::class)->filterInput('_nonce-assigned-to'), 'assigned_to')) { |
|
17 | + return; |
|
18 | + } |
|
19 | + $assignedTo = strval(glsr(Helper::class)->filterInput('assigned_to')); |
|
20 | + glsr(Database::class)->update($postId, 'assigned_to', $assignedTo); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * @param int $postId |
|
25 | - * @return mixed |
|
26 | - */ |
|
27 | - public function saveResponseMetabox($postId) |
|
28 | - { |
|
29 | - if (!wp_verify_nonce(glsr(Helper::class)->filterInput('_nonce-response'), 'response')) { |
|
30 | - return; |
|
31 | - } |
|
32 | - $response = strval(glsr(Helper::class)->filterInput('response')); |
|
33 | - glsr(Database::class)->update($postId, 'response', trim(wp_kses($response, [ |
|
34 | - 'a' => ['href' => [], 'title' => []], |
|
35 | - 'em' => [], |
|
36 | - 'strong' => [], |
|
37 | - ]))); |
|
38 | - } |
|
23 | + /** |
|
24 | + * @param int $postId |
|
25 | + * @return mixed |
|
26 | + */ |
|
27 | + public function saveResponseMetabox($postId) |
|
28 | + { |
|
29 | + if (!wp_verify_nonce(glsr(Helper::class)->filterInput('_nonce-response'), 'response')) { |
|
30 | + return; |
|
31 | + } |
|
32 | + $response = strval(glsr(Helper::class)->filterInput('response')); |
|
33 | + glsr(Database::class)->update($postId, 'response', trim(wp_kses($response, [ |
|
34 | + 'a' => ['href' => [], 'title' => []], |
|
35 | + 'em' => [], |
|
36 | + 'strong' => [], |
|
37 | + ]))); |
|
38 | + } |
|
39 | 39 | } |
@@ -7,84 +7,84 @@ |
||
7 | 7 | |
8 | 8 | class Customization |
9 | 9 | { |
10 | - /** |
|
11 | - * @return array |
|
12 | - */ |
|
13 | - public function filterEditorSettings(array $settings) |
|
14 | - { |
|
15 | - if ($this->isReviewEditable()) { |
|
16 | - $settings = [ |
|
17 | - 'media_buttons' => false, |
|
18 | - 'quicktags' => false, |
|
19 | - 'textarea_rows' => 12, |
|
20 | - 'tinymce' => false, |
|
21 | - ]; |
|
22 | - } |
|
23 | - return $settings; |
|
24 | - } |
|
10 | + /** |
|
11 | + * @return array |
|
12 | + */ |
|
13 | + public function filterEditorSettings(array $settings) |
|
14 | + { |
|
15 | + if ($this->isReviewEditable()) { |
|
16 | + $settings = [ |
|
17 | + 'media_buttons' => false, |
|
18 | + 'quicktags' => false, |
|
19 | + 'textarea_rows' => 12, |
|
20 | + 'tinymce' => false, |
|
21 | + ]; |
|
22 | + } |
|
23 | + return $settings; |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * @param string $html |
|
28 | - * @return string |
|
29 | - */ |
|
30 | - public function filterEditorTextarea($html) |
|
31 | - { |
|
32 | - if ($this->isReviewEditable()) { |
|
33 | - $html = str_replace('<textarea', '<div id="ed_toolbar"></div><textarea', $html); |
|
34 | - } |
|
35 | - return $html; |
|
36 | - } |
|
26 | + /** |
|
27 | + * @param string $html |
|
28 | + * @return string |
|
29 | + */ |
|
30 | + public function filterEditorTextarea($html) |
|
31 | + { |
|
32 | + if ($this->isReviewEditable()) { |
|
33 | + $html = str_replace('<textarea', '<div id="ed_toolbar"></div><textarea', $html); |
|
34 | + } |
|
35 | + return $html; |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @return void |
|
40 | - */ |
|
41 | - public function removeAutosave() |
|
42 | - { |
|
43 | - if (!$this->isReviewEditor() || $this->isReviewEditable()) { |
|
44 | - return; |
|
45 | - } |
|
46 | - wp_deregister_script('autosave'); |
|
47 | - } |
|
38 | + /** |
|
39 | + * @return void |
|
40 | + */ |
|
41 | + public function removeAutosave() |
|
42 | + { |
|
43 | + if (!$this->isReviewEditor() || $this->isReviewEditable()) { |
|
44 | + return; |
|
45 | + } |
|
46 | + wp_deregister_script('autosave'); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - public function removeMetaBoxes() |
|
53 | - { |
|
54 | - remove_meta_box('slugdiv', Application::POST_TYPE, 'advanced'); |
|
55 | - } |
|
49 | + /** |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + public function removeMetaBoxes() |
|
53 | + { |
|
54 | + remove_meta_box('slugdiv', Application::POST_TYPE, 'advanced'); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return void |
|
59 | - */ |
|
60 | - public function removePostTypeSupport() |
|
61 | - { |
|
62 | - if (!$this->isReviewEditor() || $this->isReviewEditable()) { |
|
63 | - return; |
|
64 | - } |
|
65 | - remove_post_type_support(Application::POST_TYPE, 'title'); |
|
66 | - remove_post_type_support(Application::POST_TYPE, 'editor'); |
|
67 | - } |
|
57 | + /** |
|
58 | + * @return void |
|
59 | + */ |
|
60 | + public function removePostTypeSupport() |
|
61 | + { |
|
62 | + if (!$this->isReviewEditor() || $this->isReviewEditable()) { |
|
63 | + return; |
|
64 | + } |
|
65 | + remove_post_type_support(Application::POST_TYPE, 'title'); |
|
66 | + remove_post_type_support(Application::POST_TYPE, 'editor'); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @return bool |
|
71 | - */ |
|
72 | - protected function isReviewEditable() |
|
73 | - { |
|
74 | - $postId = intval(filter_input(INPUT_GET, 'post')); |
|
75 | - return $postId > 0 |
|
76 | - && 'local' == glsr(Database::class)->get($postId, 'review_type') |
|
77 | - && $this->isReviewEditor(); |
|
78 | - } |
|
69 | + /** |
|
70 | + * @return bool |
|
71 | + */ |
|
72 | + protected function isReviewEditable() |
|
73 | + { |
|
74 | + $postId = intval(filter_input(INPUT_GET, 'post')); |
|
75 | + return $postId > 0 |
|
76 | + && 'local' == glsr(Database::class)->get($postId, 'review_type') |
|
77 | + && $this->isReviewEditor(); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @return bool |
|
82 | - */ |
|
83 | - protected function isReviewEditor() |
|
84 | - { |
|
85 | - $screen = glsr_current_screen(); |
|
86 | - return 'post' == $screen->base |
|
87 | - && Application::POST_TYPE == $screen->id |
|
88 | - && Application::POST_TYPE == $screen->post_type; |
|
89 | - } |
|
80 | + /** |
|
81 | + * @return bool |
|
82 | + */ |
|
83 | + protected function isReviewEditor() |
|
84 | + { |
|
85 | + $screen = glsr_current_screen(); |
|
86 | + return 'post' == $screen->base |
|
87 | + && Application::POST_TYPE == $screen->id |
|
88 | + && Application::POST_TYPE == $screen->post_type; |
|
89 | + } |
|
90 | 90 | } |
@@ -10,141 +10,141 @@ |
||
10 | 10 | |
11 | 11 | class Columns |
12 | 12 | { |
13 | - /** |
|
14 | - * @param int $postId |
|
15 | - * @return string |
|
16 | - */ |
|
17 | - public function buildColumnAssignedTo($postId) |
|
18 | - { |
|
19 | - $assignedPost = glsr(Database::class)->getAssignedToPost($postId); |
|
20 | - $column = '—'; |
|
21 | - if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) { |
|
22 | - $column = glsr(Builder::class)->a(get_the_title($assignedPost->ID), [ |
|
23 | - 'href' => (string) get_the_permalink($assignedPost->ID), |
|
24 | - ]); |
|
25 | - } |
|
26 | - return $column; |
|
27 | - } |
|
13 | + /** |
|
14 | + * @param int $postId |
|
15 | + * @return string |
|
16 | + */ |
|
17 | + public function buildColumnAssignedTo($postId) |
|
18 | + { |
|
19 | + $assignedPost = glsr(Database::class)->getAssignedToPost($postId); |
|
20 | + $column = '—'; |
|
21 | + if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) { |
|
22 | + $column = glsr(Builder::class)->a(get_the_title($assignedPost->ID), [ |
|
23 | + 'href' => (string) get_the_permalink($assignedPost->ID), |
|
24 | + ]); |
|
25 | + } |
|
26 | + return $column; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * @param int $postId |
|
31 | - * @return string |
|
32 | - */ |
|
33 | - public function buildColumnPinned($postId) |
|
34 | - { |
|
35 | - $pinned = glsr(Database::class)->get($postId, 'pinned') |
|
36 | - ? 'pinned ' |
|
37 | - : ''; |
|
38 | - return glsr(Builder::class)->i([ |
|
39 | - 'class' => $pinned.'dashicons dashicons-sticky', |
|
40 | - 'data-id' => $postId, |
|
41 | - ]); |
|
42 | - } |
|
29 | + /** |
|
30 | + * @param int $postId |
|
31 | + * @return string |
|
32 | + */ |
|
33 | + public function buildColumnPinned($postId) |
|
34 | + { |
|
35 | + $pinned = glsr(Database::class)->get($postId, 'pinned') |
|
36 | + ? 'pinned ' |
|
37 | + : ''; |
|
38 | + return glsr(Builder::class)->i([ |
|
39 | + 'class' => $pinned.'dashicons dashicons-sticky', |
|
40 | + 'data-id' => $postId, |
|
41 | + ]); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param int $postId |
|
46 | - * @return string |
|
47 | - */ |
|
48 | - public function buildColumnReviewer($postId) |
|
49 | - { |
|
50 | - return strval(glsr(Database::class)->get($postId, 'author')); |
|
51 | - } |
|
44 | + /** |
|
45 | + * @param int $postId |
|
46 | + * @return string |
|
47 | + */ |
|
48 | + public function buildColumnReviewer($postId) |
|
49 | + { |
|
50 | + return strval(glsr(Database::class)->get($postId, 'author')); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @param int $postId |
|
55 | - * @param int|null $rating |
|
56 | - * @return string |
|
57 | - */ |
|
58 | - public function buildColumnRating($postId) |
|
59 | - { |
|
60 | - return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating'))); |
|
61 | - } |
|
53 | + /** |
|
54 | + * @param int $postId |
|
55 | + * @param int|null $rating |
|
56 | + * @return string |
|
57 | + */ |
|
58 | + public function buildColumnRating($postId) |
|
59 | + { |
|
60 | + return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating'))); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @param int $postId |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function buildColumnReviewType($postId) |
|
68 | - { |
|
69 | - $type = glsr(Database::class)->get($postId, 'review_type'); |
|
70 | - return array_key_exists($type, glsr()->reviewTypes) |
|
71 | - ? glsr()->reviewTypes[$type] |
|
72 | - : __('Unsupported Type', 'site-reviews'); |
|
73 | - } |
|
63 | + /** |
|
64 | + * @param int $postId |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function buildColumnReviewType($postId) |
|
68 | + { |
|
69 | + $type = glsr(Database::class)->get($postId, 'review_type'); |
|
70 | + return array_key_exists($type, glsr()->reviewTypes) |
|
71 | + ? glsr()->reviewTypes[$type] |
|
72 | + : __('Unsupported Type', 'site-reviews'); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @param string $postType |
|
77 | - * @return void |
|
78 | - */ |
|
79 | - public function renderFilters($postType) |
|
80 | - { |
|
81 | - if (Application::POST_TYPE !== $postType) { |
|
82 | - return; |
|
83 | - } |
|
84 | - if (!($status = filter_input(INPUT_GET, 'post_status'))) { |
|
85 | - $status = 'publish'; |
|
86 | - } |
|
87 | - $ratings = glsr(Database::class)->getReviewsMeta('rating', $status); |
|
88 | - $types = glsr(Database::class)->getReviewsMeta('review_type', $status); |
|
89 | - $this->renderFilterRatings($ratings); |
|
90 | - $this->renderFilterTypes($types); |
|
91 | - } |
|
75 | + /** |
|
76 | + * @param string $postType |
|
77 | + * @return void |
|
78 | + */ |
|
79 | + public function renderFilters($postType) |
|
80 | + { |
|
81 | + if (Application::POST_TYPE !== $postType) { |
|
82 | + return; |
|
83 | + } |
|
84 | + if (!($status = filter_input(INPUT_GET, 'post_status'))) { |
|
85 | + $status = 'publish'; |
|
86 | + } |
|
87 | + $ratings = glsr(Database::class)->getReviewsMeta('rating', $status); |
|
88 | + $types = glsr(Database::class)->getReviewsMeta('review_type', $status); |
|
89 | + $this->renderFilterRatings($ratings); |
|
90 | + $this->renderFilterTypes($types); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * @param string $column |
|
95 | - * @param int $postId |
|
96 | - * @return void |
|
97 | - */ |
|
98 | - public function renderValues($column, $postId) |
|
99 | - { |
|
100 | - $method = glsr(Helper::class)->buildMethodName($column, 'buildColumn'); |
|
101 | - echo method_exists($this, $method) |
|
102 | - ? call_user_func([$this, $method], $postId) |
|
103 | - : apply_filters('site-reviews/columns/'.$column, '', $postId); |
|
104 | - } |
|
93 | + /** |
|
94 | + * @param string $column |
|
95 | + * @param int $postId |
|
96 | + * @return void |
|
97 | + */ |
|
98 | + public function renderValues($column, $postId) |
|
99 | + { |
|
100 | + $method = glsr(Helper::class)->buildMethodName($column, 'buildColumn'); |
|
101 | + echo method_exists($this, $method) |
|
102 | + ? call_user_func([$this, $method], $postId) |
|
103 | + : apply_filters('site-reviews/columns/'.$column, '', $postId); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * @param array $ratings |
|
108 | - * @return void |
|
109 | - */ |
|
110 | - protected function renderFilterRatings($ratings) |
|
111 | - { |
|
112 | - if (empty($ratings)) { |
|
113 | - return; |
|
114 | - } |
|
115 | - $ratings = array_flip(array_reverse($ratings)); |
|
116 | - array_walk($ratings, function (&$value, $key) { |
|
117 | - $label = _n('%s star', '%s stars', $key, 'site-reviews'); |
|
118 | - $value = sprintf($label, $key); |
|
119 | - }); |
|
120 | - echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [ |
|
121 | - 'class' => 'screen-reader-text', |
|
122 | - 'for' => 'rating', |
|
123 | - ]); |
|
124 | - echo glsr(Builder::class)->select([ |
|
125 | - 'name' => 'rating', |
|
126 | - 'options' => ['' => __('All ratings', 'site-reviews')] + $ratings, |
|
127 | - 'value' => filter_input(INPUT_GET, 'rating'), |
|
128 | - ]); |
|
129 | - } |
|
106 | + /** |
|
107 | + * @param array $ratings |
|
108 | + * @return void |
|
109 | + */ |
|
110 | + protected function renderFilterRatings($ratings) |
|
111 | + { |
|
112 | + if (empty($ratings)) { |
|
113 | + return; |
|
114 | + } |
|
115 | + $ratings = array_flip(array_reverse($ratings)); |
|
116 | + array_walk($ratings, function (&$value, $key) { |
|
117 | + $label = _n('%s star', '%s stars', $key, 'site-reviews'); |
|
118 | + $value = sprintf($label, $key); |
|
119 | + }); |
|
120 | + echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [ |
|
121 | + 'class' => 'screen-reader-text', |
|
122 | + 'for' => 'rating', |
|
123 | + ]); |
|
124 | + echo glsr(Builder::class)->select([ |
|
125 | + 'name' => 'rating', |
|
126 | + 'options' => ['' => __('All ratings', 'site-reviews')] + $ratings, |
|
127 | + 'value' => filter_input(INPUT_GET, 'rating'), |
|
128 | + ]); |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * @param array $types |
|
133 | - * @return void |
|
134 | - */ |
|
135 | - protected function renderFilterTypes($types) |
|
136 | - { |
|
137 | - if (count(glsr()->reviewTypes) < 2) { |
|
138 | - return; |
|
139 | - } |
|
140 | - echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [ |
|
141 | - 'class' => 'screen-reader-text', |
|
142 | - 'for' => 'review_type', |
|
143 | - ]); |
|
144 | - echo glsr(Builder::class)->select([ |
|
145 | - 'name' => 'review_type', |
|
146 | - 'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes, |
|
147 | - 'value' => filter_input(INPUT_GET, 'review_type'), |
|
148 | - ]); |
|
149 | - } |
|
131 | + /** |
|
132 | + * @param array $types |
|
133 | + * @return void |
|
134 | + */ |
|
135 | + protected function renderFilterTypes($types) |
|
136 | + { |
|
137 | + if (count(glsr()->reviewTypes) < 2) { |
|
138 | + return; |
|
139 | + } |
|
140 | + echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [ |
|
141 | + 'class' => 'screen-reader-text', |
|
142 | + 'for' => 'review_type', |
|
143 | + ]); |
|
144 | + echo glsr(Builder::class)->select([ |
|
145 | + 'name' => 'review_type', |
|
146 | + 'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes, |
|
147 | + 'value' => filter_input(INPUT_GET, 'review_type'), |
|
148 | + ]); |
|
149 | + } |
|
150 | 150 | } |
@@ -7,26 +7,26 @@ |
||
7 | 7 | |
8 | 8 | class EmailDefaults extends Defaults |
9 | 9 | { |
10 | - /** |
|
11 | - * @return array |
|
12 | - */ |
|
13 | - protected function defaults() |
|
14 | - { |
|
15 | - $fromName = wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES); |
|
16 | - $fromEmail = glsr(OptionManager::class)->getWP('admin_email'); |
|
17 | - return [ |
|
18 | - 'after' => '', |
|
19 | - 'attachments' => [], |
|
20 | - 'bcc' => '', |
|
21 | - 'before' => '', |
|
22 | - 'cc' => '', |
|
23 | - 'from' => $fromName.' <'.$fromEmail.'>', |
|
24 | - 'message' => '', |
|
25 | - 'reply-to' => '', |
|
26 | - 'subject' => '', |
|
27 | - 'template' => '', |
|
28 | - 'template-tags' => [], |
|
29 | - 'to' => '', |
|
30 | - ]; |
|
31 | - } |
|
10 | + /** |
|
11 | + * @return array |
|
12 | + */ |
|
13 | + protected function defaults() |
|
14 | + { |
|
15 | + $fromName = wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES); |
|
16 | + $fromEmail = glsr(OptionManager::class)->getWP('admin_email'); |
|
17 | + return [ |
|
18 | + 'after' => '', |
|
19 | + 'attachments' => [], |
|
20 | + 'bcc' => '', |
|
21 | + 'before' => '', |
|
22 | + 'cc' => '', |
|
23 | + 'from' => $fromName.' <'.$fromEmail.'>', |
|
24 | + 'message' => '', |
|
25 | + 'reply-to' => '', |
|
26 | + 'subject' => '', |
|
27 | + 'template' => '', |
|
28 | + 'template-tags' => [], |
|
29 | + 'to' => '', |
|
30 | + ]; |
|
31 | + } |
|
32 | 32 | } |
@@ -21,22 +21,22 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | * @action set_object_terms |
23 | 23 | */ |
24 | - public function onAfterChangeCategory($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds) |
|
24 | + public function onAfterChangeCategory($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds) |
|
25 | 25 | { |
26 | - sort($newTTIds); |
|
27 | - sort($oldTTIds); |
|
28 | - if ($newTTIds === $oldTTIds || !$this->isReviewPostId($postId)) { |
|
29 | - return; |
|
26 | + sort($newTTIds); |
|
27 | + sort($oldTTIds); |
|
28 | + if ($newTTIds === $oldTTIds || !$this->isReviewPostId($postId)) { |
|
29 | + return; |
|
30 | 30 | } |
31 | - $review = glsr_get_review($postId); |
|
32 | - $ignoredIds = array_intersect($oldTTIds, $newTTIds); |
|
33 | - $decreasedIds = array_diff($oldTTIds, $ignoredIds); |
|
34 | - $increasedIds = array_diff($newTTIds, $ignoredIds); |
|
35 | - if ($review->term_ids = glsr(Database::class)->getTermIds($decreasedIds, 'term_taxonomy_id')) { |
|
36 | - glsr(CountsManager::class)->decreaseTermCounts($review); |
|
37 | - } |
|
38 | - if ($review->term_ids = glsr(Database::class)->getTermIds($increasedIds, 'term_taxonomy_id')) { |
|
39 | - glsr(CountsManager::class)->increaseTermCounts($review); |
|
31 | + $review = glsr_get_review($postId); |
|
32 | + $ignoredIds = array_intersect($oldTTIds, $newTTIds); |
|
33 | + $decreasedIds = array_diff($oldTTIds, $ignoredIds); |
|
34 | + $increasedIds = array_diff($newTTIds, $ignoredIds); |
|
35 | + if ($review->term_ids = glsr(Database::class)->getTermIds($decreasedIds, 'term_taxonomy_id')) { |
|
36 | + glsr(CountsManager::class)->decreaseTermCounts($review); |
|
37 | + } |
|
38 | + if ($review->term_ids = glsr(Database::class)->getTermIds($increasedIds, 'term_taxonomy_id')) { |
|
39 | + glsr(CountsManager::class)->increaseTermCounts($review); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
@@ -47,16 +47,16 @@ discard block |
||
47 | 47 | * @return void |
48 | 48 | * @action transition_post_status |
49 | 49 | */ |
50 | - public function onAfterChangeStatus($newStatus, $oldStatus, $post) |
|
50 | + public function onAfterChangeStatus($newStatus, $oldStatus, $post) |
|
51 | 51 | { |
52 | - if (Application::POST_TYPE != glsr_get($post, 'post_type') || in_array($oldStatus, ['new', $newStatus])) { |
|
53 | - return; |
|
52 | + if (Application::POST_TYPE != glsr_get($post, 'post_type') || in_array($oldStatus, ['new', $newStatus])) { |
|
53 | + return; |
|
54 | 54 | } |
55 | - $review = glsr_get_review($post); |
|
56 | - if ('publish' == $post->post_status) { |
|
57 | - glsr(CountsManager::class)->increase($review); |
|
58 | - } else { |
|
59 | - glsr(CountsManager::class)->decrease($review); |
|
55 | + $review = glsr_get_review($post); |
|
56 | + if ('publish' == $post->post_status) { |
|
57 | + glsr(CountsManager::class)->increase($review); |
|
58 | + } else { |
|
59 | + glsr(CountsManager::class)->decrease($review); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | * @return void |
65 | 65 | * @action site-reviews/review/created |
66 | 66 | */ |
67 | - public function onAfterCreate(Review $review) |
|
67 | + public function onAfterCreate(Review $review) |
|
68 | 68 | { |
69 | - if ('publish' !== $review->status) { |
|
70 | - return; |
|
71 | - } |
|
72 | - glsr(CountsManager::class)->increase($review); |
|
69 | + if ('publish' !== $review->status) { |
|
70 | + return; |
|
71 | + } |
|
72 | + glsr(CountsManager::class)->increase($review); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | * @return void |
78 | 78 | * @action before_delete_post |
79 | 79 | */ |
80 | - public function onBeforeDelete($postId) |
|
80 | + public function onBeforeDelete($postId) |
|
81 | 81 | { |
82 | - if (!$this->isReviewPostId($postId)) { |
|
83 | - return; |
|
84 | - } |
|
85 | - $review = glsr_get_review($postId); |
|
86 | - glsr(CountsManager::class)->decrease($review); |
|
82 | + if (!$this->isReviewPostId($postId)) { |
|
83 | + return; |
|
84 | + } |
|
85 | + $review = glsr_get_review($postId); |
|
86 | + glsr(CountsManager::class)->decrease($review); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -94,53 +94,53 @@ discard block |
||
94 | 94 | * @return void |
95 | 95 | * @action update_postmeta |
96 | 96 | */ |
97 | - public function onBeforeUpdate($metaId, $postId, $metaKey, $metaValue) |
|
97 | + public function onBeforeUpdate($metaId, $postId, $metaKey, $metaValue) |
|
98 | 98 | { |
99 | - if (!$this->isReviewPostId($postId)) { |
|
100 | - return; |
|
101 | - } |
|
102 | - $metaKeys = glsr(Helper::class)->prefixArrayKeys(['assigned_to', 'rating', 'review_type']); |
|
103 | - if (!in_array($metaKey, $metaKeys)) { |
|
104 | - return; |
|
105 | - } |
|
106 | - $review = glsr_get_review($postId); |
|
107 | - if ($review->$metaKey == $metaValue) { |
|
108 | - return; |
|
109 | - } |
|
110 | - $method = glsr(Helper::class)->buildMethodName($metaKey, 'onBeforeChange'); |
|
111 | - call_user_func([$this, $method], $review, $metaValue); |
|
99 | + if (!$this->isReviewPostId($postId)) { |
|
100 | + return; |
|
101 | + } |
|
102 | + $metaKeys = glsr(Helper::class)->prefixArrayKeys(['assigned_to', 'rating', 'review_type']); |
|
103 | + if (!in_array($metaKey, $metaKeys)) { |
|
104 | + return; |
|
105 | + } |
|
106 | + $review = glsr_get_review($postId); |
|
107 | + if ($review->$metaKey == $metaValue) { |
|
108 | + return; |
|
109 | + } |
|
110 | + $method = glsr(Helper::class)->buildMethodName($metaKey, 'onBeforeChange'); |
|
111 | + call_user_func([$this, $method], $review, $metaValue); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @param string|int $assignedTo |
116 | 116 | * @return void |
117 | 117 | */ |
118 | - public function onBeforeChangeAssignedTo(Review $review, $assignedTo) |
|
118 | + public function onBeforeChangeAssignedTo(Review $review, $assignedTo) |
|
119 | 119 | { |
120 | - glsr(CountsManager::class)->decreasePostCounts($review); |
|
120 | + glsr(CountsManager::class)->decreasePostCounts($review); |
|
121 | 121 | $review->assigned_to = $assignedTo; |
122 | - glsr(CountsManager::class)->increasePostCounts($review); |
|
122 | + glsr(CountsManager::class)->increasePostCounts($review); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
126 | 126 | * @param string|int $rating |
127 | 127 | * @return void |
128 | 128 | */ |
129 | - public function onBeforeChangeRating(Review $review, $rating) |
|
129 | + public function onBeforeChangeRating(Review $review, $rating) |
|
130 | 130 | { |
131 | - glsr(CountsManager::class)->decrease($review); |
|
131 | + glsr(CountsManager::class)->decrease($review); |
|
132 | 132 | $review->rating = $rating; |
133 | - glsr(CountsManager::class)->increase($review); |
|
133 | + glsr(CountsManager::class)->increase($review); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
137 | 137 | * @param string $reviewType |
138 | 138 | * @return void |
139 | 139 | */ |
140 | - public function onBeforeChangeReviewType(Review $review, $reviewType) |
|
140 | + public function onBeforeChangeReviewType(Review $review, $reviewType) |
|
141 | 141 | { |
142 | - glsr(CountsManager::class)->decrease($review); |
|
142 | + glsr(CountsManager::class)->decrease($review); |
|
143 | 143 | $review->review_type = $reviewType; |
144 | - glsr(CountsManager::class)->increase($review); |
|
144 | + glsr(CountsManager::class)->increase($review); |
|
145 | 145 | } |
146 | 146 | } |
@@ -19,430 +19,430 @@ |
||
19 | 19 | |
20 | 20 | class EditorController extends Controller |
21 | 21 | { |
22 | - /** |
|
23 | - * @return void |
|
24 | - * @action admin_enqueue_scripts |
|
25 | - */ |
|
26 | - public function customizePostStatusLabels() |
|
27 | - { |
|
28 | - glsr(Labels::class)->customizePostStatusLabels(); |
|
29 | - } |
|
22 | + /** |
|
23 | + * @return void |
|
24 | + * @action admin_enqueue_scripts |
|
25 | + */ |
|
26 | + public function customizePostStatusLabels() |
|
27 | + { |
|
28 | + glsr(Labels::class)->customizePostStatusLabels(); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * @param array $settings |
|
33 | - * @return array |
|
34 | - * @filter wp_editor_settings |
|
35 | - */ |
|
36 | - public function filterEditorSettings($settings) |
|
37 | - { |
|
38 | - return glsr(Customization::class)->filterEditorSettings( |
|
39 | - glsr(Helper::class)->consolidateArray($settings) |
|
40 | - ); |
|
41 | - } |
|
31 | + /** |
|
32 | + * @param array $settings |
|
33 | + * @return array |
|
34 | + * @filter wp_editor_settings |
|
35 | + */ |
|
36 | + public function filterEditorSettings($settings) |
|
37 | + { |
|
38 | + return glsr(Customization::class)->filterEditorSettings( |
|
39 | + glsr(Helper::class)->consolidateArray($settings) |
|
40 | + ); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script. |
|
45 | - * @param string $html |
|
46 | - * @return string |
|
47 | - * @filter the_editor |
|
48 | - */ |
|
49 | - public function filterEditorTextarea($html) |
|
50 | - { |
|
51 | - return glsr(Customization::class)->filterEditorTextarea($html); |
|
52 | - } |
|
43 | + /** |
|
44 | + * Modify the WP_Editor html to allow autosizing without breaking the `editor-expand` script. |
|
45 | + * @param string $html |
|
46 | + * @return string |
|
47 | + * @filter the_editor |
|
48 | + */ |
|
49 | + public function filterEditorTextarea($html) |
|
50 | + { |
|
51 | + return glsr(Customization::class)->filterEditorTextarea($html); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @param bool $protected |
|
56 | - * @param string $metaKey |
|
57 | - * @param string $metaType |
|
58 | - * @return bool |
|
59 | - * @filter is_protected_meta |
|
60 | - */ |
|
61 | - public function filterIsProtectedMeta($protected, $metaKey, $metaType) |
|
62 | - { |
|
63 | - if ('post' == $metaType && Application::POST_TYPE == get_post_type()) { |
|
64 | - $values = glsr(CreateReviewDefaults::class)->unguarded(); |
|
65 | - $values = glsr(Helper::class)->prefixArrayKeys($values); |
|
66 | - if (array_key_exists($metaKey, $values)) { |
|
67 | - $protected = false; |
|
68 | - } |
|
69 | - } |
|
70 | - return $protected; |
|
71 | - } |
|
54 | + /** |
|
55 | + * @param bool $protected |
|
56 | + * @param string $metaKey |
|
57 | + * @param string $metaType |
|
58 | + * @return bool |
|
59 | + * @filter is_protected_meta |
|
60 | + */ |
|
61 | + public function filterIsProtectedMeta($protected, $metaKey, $metaType) |
|
62 | + { |
|
63 | + if ('post' == $metaType && Application::POST_TYPE == get_post_type()) { |
|
64 | + $values = glsr(CreateReviewDefaults::class)->unguarded(); |
|
65 | + $values = glsr(Helper::class)->prefixArrayKeys($values); |
|
66 | + if (array_key_exists($metaKey, $values)) { |
|
67 | + $protected = false; |
|
68 | + } |
|
69 | + } |
|
70 | + return $protected; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @param string $translation |
|
75 | - * @param string $test |
|
76 | - * @param string $domain |
|
77 | - * @return string |
|
78 | - * @filter gettext |
|
79 | - */ |
|
80 | - public function filterPostStatusLabels($translation, $text, $domain) |
|
81 | - { |
|
82 | - return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain); |
|
83 | - } |
|
73 | + /** |
|
74 | + * @param string $translation |
|
75 | + * @param string $test |
|
76 | + * @param string $domain |
|
77 | + * @return string |
|
78 | + * @filter gettext |
|
79 | + */ |
|
80 | + public function filterPostStatusLabels($translation, $text, $domain) |
|
81 | + { |
|
82 | + return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * @param string $translation |
|
87 | - * @param string $test |
|
88 | - * @param string $domain |
|
89 | - * @return string |
|
90 | - * @filter gettext_with_context |
|
91 | - */ |
|
92 | - public function filterPostStatusLabelsWithContext($translation, $text, $context, $domain) |
|
93 | - { |
|
94 | - return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain); |
|
95 | - } |
|
85 | + /** |
|
86 | + * @param string $translation |
|
87 | + * @param string $test |
|
88 | + * @param string $domain |
|
89 | + * @return string |
|
90 | + * @filter gettext_with_context |
|
91 | + */ |
|
92 | + public function filterPostStatusLabelsWithContext($translation, $text, $context, $domain) |
|
93 | + { |
|
94 | + return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * @param array $messages |
|
99 | - * @return array |
|
100 | - * @filter post_updated_messages |
|
101 | - */ |
|
102 | - public function filterUpdateMessages($messages) |
|
103 | - { |
|
104 | - return glsr(Labels::class)->filterUpdateMessages( |
|
105 | - glsr(Helper::class)->consolidateArray($messages) |
|
106 | - ); |
|
107 | - } |
|
97 | + /** |
|
98 | + * @param array $messages |
|
99 | + * @return array |
|
100 | + * @filter post_updated_messages |
|
101 | + */ |
|
102 | + public function filterUpdateMessages($messages) |
|
103 | + { |
|
104 | + return glsr(Labels::class)->filterUpdateMessages( |
|
105 | + glsr(Helper::class)->consolidateArray($messages) |
|
106 | + ); |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * @return void |
|
111 | - * @action add_meta_boxes_{Application::POST_TYPE} |
|
112 | - */ |
|
113 | - public function registerMetaBoxes($post) |
|
114 | - { |
|
115 | - add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side'); |
|
116 | - add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side'); |
|
117 | - if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) { |
|
118 | - return; |
|
119 | - } |
|
120 | - add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal'); |
|
121 | - } |
|
109 | + /** |
|
110 | + * @return void |
|
111 | + * @action add_meta_boxes_{Application::POST_TYPE} |
|
112 | + */ |
|
113 | + public function registerMetaBoxes($post) |
|
114 | + { |
|
115 | + add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side'); |
|
116 | + add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side'); |
|
117 | + if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) { |
|
118 | + return; |
|
119 | + } |
|
120 | + add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal'); |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * @return void |
|
125 | - * @action admin_print_scripts |
|
126 | - */ |
|
127 | - public function removeAutosave() |
|
128 | - { |
|
129 | - glsr(Customization::class)->removeAutosave(); |
|
130 | - } |
|
123 | + /** |
|
124 | + * @return void |
|
125 | + * @action admin_print_scripts |
|
126 | + */ |
|
127 | + public function removeAutosave() |
|
128 | + { |
|
129 | + glsr(Customization::class)->removeAutosave(); |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * @return void |
|
134 | - * @action admin_menu |
|
135 | - */ |
|
136 | - public function removeMetaBoxes() |
|
137 | - { |
|
138 | - glsr(Customization::class)->removeMetaBoxes(); |
|
139 | - } |
|
132 | + /** |
|
133 | + * @return void |
|
134 | + * @action admin_menu |
|
135 | + */ |
|
136 | + public function removeMetaBoxes() |
|
137 | + { |
|
138 | + glsr(Customization::class)->removeMetaBoxes(); |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * @return void |
|
143 | - */ |
|
144 | - public function removePostTypeSupport() |
|
145 | - { |
|
146 | - glsr(Customization::class)->removePostTypeSupport(); |
|
147 | - } |
|
141 | + /** |
|
142 | + * @return void |
|
143 | + */ |
|
144 | + public function removePostTypeSupport() |
|
145 | + { |
|
146 | + glsr(Customization::class)->removePostTypeSupport(); |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * @param WP_Post $post |
|
151 | - * @return void |
|
152 | - * @callback add_meta_box |
|
153 | - */ |
|
154 | - public function renderAssignedToMetabox($post) |
|
155 | - { |
|
156 | - if (!$this->isReviewPostType($post)) { |
|
157 | - return; |
|
158 | - } |
|
159 | - $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to'); |
|
160 | - wp_nonce_field('assigned_to', '_nonce-assigned-to', false); |
|
161 | - glsr()->render('partials/editor/metabox-assigned-to', [ |
|
162 | - 'id' => $assignedTo, |
|
163 | - 'template' => $this->buildAssignedToTemplate($assignedTo, $post), |
|
164 | - ]); |
|
165 | - } |
|
149 | + /** |
|
150 | + * @param WP_Post $post |
|
151 | + * @return void |
|
152 | + * @callback add_meta_box |
|
153 | + */ |
|
154 | + public function renderAssignedToMetabox($post) |
|
155 | + { |
|
156 | + if (!$this->isReviewPostType($post)) { |
|
157 | + return; |
|
158 | + } |
|
159 | + $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to'); |
|
160 | + wp_nonce_field('assigned_to', '_nonce-assigned-to', false); |
|
161 | + glsr()->render('partials/editor/metabox-assigned-to', [ |
|
162 | + 'id' => $assignedTo, |
|
163 | + 'template' => $this->buildAssignedToTemplate($assignedTo, $post), |
|
164 | + ]); |
|
165 | + } |
|
166 | 166 | |
167 | - /** |
|
168 | - * @param WP_Post $post |
|
169 | - * @return void |
|
170 | - * @callback add_meta_box |
|
171 | - */ |
|
172 | - public function renderDetailsMetaBox($post) |
|
173 | - { |
|
174 | - if (!$this->isReviewPostType($post)) { |
|
175 | - return; |
|
176 | - } |
|
177 | - $review = glsr_get_review($post); |
|
178 | - glsr()->render('partials/editor/metabox-details', [ |
|
179 | - 'button' => $this->buildDetailsMetaBoxRevertButton($review, $post), |
|
180 | - 'metabox' => $this->normalizeDetailsMetaBox($review), |
|
181 | - ]); |
|
182 | - } |
|
167 | + /** |
|
168 | + * @param WP_Post $post |
|
169 | + * @return void |
|
170 | + * @callback add_meta_box |
|
171 | + */ |
|
172 | + public function renderDetailsMetaBox($post) |
|
173 | + { |
|
174 | + if (!$this->isReviewPostType($post)) { |
|
175 | + return; |
|
176 | + } |
|
177 | + $review = glsr_get_review($post); |
|
178 | + glsr()->render('partials/editor/metabox-details', [ |
|
179 | + 'button' => $this->buildDetailsMetaBoxRevertButton($review, $post), |
|
180 | + 'metabox' => $this->normalizeDetailsMetaBox($review), |
|
181 | + ]); |
|
182 | + } |
|
183 | 183 | |
184 | - /** |
|
185 | - * @return void |
|
186 | - * @action post_submitbox_misc_actions |
|
187 | - */ |
|
188 | - public function renderPinnedInPublishMetaBox() |
|
189 | - { |
|
190 | - if (!$this->isReviewPostType(get_post())) { |
|
191 | - return; |
|
192 | - } |
|
193 | - glsr(Template::class)->render('partials/editor/pinned', [ |
|
194 | - 'context' => [ |
|
195 | - 'no' => __('No', 'site-reviews'), |
|
196 | - 'yes' => __('Yes', 'site-reviews'), |
|
197 | - ], |
|
198 | - 'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')), |
|
199 | - ]); |
|
200 | - } |
|
184 | + /** |
|
185 | + * @return void |
|
186 | + * @action post_submitbox_misc_actions |
|
187 | + */ |
|
188 | + public function renderPinnedInPublishMetaBox() |
|
189 | + { |
|
190 | + if (!$this->isReviewPostType(get_post())) { |
|
191 | + return; |
|
192 | + } |
|
193 | + glsr(Template::class)->render('partials/editor/pinned', [ |
|
194 | + 'context' => [ |
|
195 | + 'no' => __('No', 'site-reviews'), |
|
196 | + 'yes' => __('Yes', 'site-reviews'), |
|
197 | + ], |
|
198 | + 'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')), |
|
199 | + ]); |
|
200 | + } |
|
201 | 201 | |
202 | - /** |
|
203 | - * @param WP_Post $post |
|
204 | - * @return void |
|
205 | - * @callback add_meta_box |
|
206 | - */ |
|
207 | - public function renderResponseMetaBox($post) |
|
208 | - { |
|
209 | - if (!$this->isReviewPostType($post)) { |
|
210 | - return; |
|
211 | - } |
|
212 | - wp_nonce_field('response', '_nonce-response', false); |
|
213 | - glsr()->render('partials/editor/metabox-response', [ |
|
214 | - 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
215 | - ]); |
|
216 | - } |
|
202 | + /** |
|
203 | + * @param WP_Post $post |
|
204 | + * @return void |
|
205 | + * @callback add_meta_box |
|
206 | + */ |
|
207 | + public function renderResponseMetaBox($post) |
|
208 | + { |
|
209 | + if (!$this->isReviewPostType($post)) { |
|
210 | + return; |
|
211 | + } |
|
212 | + wp_nonce_field('response', '_nonce-response', false); |
|
213 | + glsr()->render('partials/editor/metabox-response', [ |
|
214 | + 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
215 | + ]); |
|
216 | + } |
|
217 | 217 | |
218 | - /** |
|
219 | - * @param WP_Post $post |
|
220 | - * @return void |
|
221 | - * @action edit_form_after_title |
|
222 | - */ |
|
223 | - public function renderReviewEditor($post) |
|
224 | - { |
|
225 | - if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
226 | - return; |
|
227 | - } |
|
228 | - glsr()->render('partials/editor/review', [ |
|
229 | - 'post' => $post, |
|
230 | - 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
231 | - ]); |
|
232 | - } |
|
218 | + /** |
|
219 | + * @param WP_Post $post |
|
220 | + * @return void |
|
221 | + * @action edit_form_after_title |
|
222 | + */ |
|
223 | + public function renderReviewEditor($post) |
|
224 | + { |
|
225 | + if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
226 | + return; |
|
227 | + } |
|
228 | + glsr()->render('partials/editor/review', [ |
|
229 | + 'post' => $post, |
|
230 | + 'response' => glsr(Database::class)->get($post->ID, 'response'), |
|
231 | + ]); |
|
232 | + } |
|
233 | 233 | |
234 | - /** |
|
235 | - * @return void |
|
236 | - * @action admin_head |
|
237 | - */ |
|
238 | - public function renderReviewFields() |
|
239 | - { |
|
240 | - $screen = glsr_current_screen(); |
|
241 | - if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) { |
|
242 | - return; |
|
243 | - } |
|
244 | - add_action('edit_form_after_title', [$this, 'renderReviewEditor']); |
|
245 | - add_action('edit_form_top', [$this, 'renderReviewNotice']); |
|
246 | - } |
|
234 | + /** |
|
235 | + * @return void |
|
236 | + * @action admin_head |
|
237 | + */ |
|
238 | + public function renderReviewFields() |
|
239 | + { |
|
240 | + $screen = glsr_current_screen(); |
|
241 | + if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) { |
|
242 | + return; |
|
243 | + } |
|
244 | + add_action('edit_form_after_title', [$this, 'renderReviewEditor']); |
|
245 | + add_action('edit_form_top', [$this, 'renderReviewNotice']); |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * @param WP_Post $post |
|
250 | - * @return void |
|
251 | - * @action edit_form_top |
|
252 | - */ |
|
253 | - public function renderReviewNotice($post) |
|
254 | - { |
|
255 | - if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
256 | - return; |
|
257 | - } |
|
258 | - glsr(Notice::class)->addWarning(sprintf( |
|
259 | - __('%s reviews are read-only.', 'site-reviews'), |
|
260 | - glsr(Columns::class)->buildColumnReviewType($post->ID) |
|
261 | - )); |
|
262 | - glsr(Template::class)->render('partials/editor/notice', [ |
|
263 | - 'context' => [ |
|
264 | - 'notices' => glsr(Notice::class)->get(), |
|
265 | - ], |
|
266 | - ]); |
|
267 | - } |
|
248 | + /** |
|
249 | + * @param WP_Post $post |
|
250 | + * @return void |
|
251 | + * @action edit_form_top |
|
252 | + */ |
|
253 | + public function renderReviewNotice($post) |
|
254 | + { |
|
255 | + if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) { |
|
256 | + return; |
|
257 | + } |
|
258 | + glsr(Notice::class)->addWarning(sprintf( |
|
259 | + __('%s reviews are read-only.', 'site-reviews'), |
|
260 | + glsr(Columns::class)->buildColumnReviewType($post->ID) |
|
261 | + )); |
|
262 | + glsr(Template::class)->render('partials/editor/notice', [ |
|
263 | + 'context' => [ |
|
264 | + 'notices' => glsr(Notice::class)->get(), |
|
265 | + ], |
|
266 | + ]); |
|
267 | + } |
|
268 | 268 | |
269 | - /** |
|
270 | - * @param WP_Post $post |
|
271 | - * @return void |
|
272 | - * @see glsr_categories_meta_box() |
|
273 | - * @callback register_taxonomy |
|
274 | - */ |
|
275 | - public function renderTaxonomyMetabox($post) |
|
276 | - { |
|
277 | - if (!$this->isReviewPostType($post)) { |
|
278 | - return; |
|
279 | - } |
|
280 | - glsr()->render('partials/editor/metabox-categories', [ |
|
281 | - 'post' => $post, |
|
282 | - 'tax_name' => Application::TAXONOMY, |
|
283 | - 'taxonomy' => get_taxonomy(Application::TAXONOMY), |
|
284 | - ]); |
|
285 | - } |
|
269 | + /** |
|
270 | + * @param WP_Post $post |
|
271 | + * @return void |
|
272 | + * @see glsr_categories_meta_box() |
|
273 | + * @callback register_taxonomy |
|
274 | + */ |
|
275 | + public function renderTaxonomyMetabox($post) |
|
276 | + { |
|
277 | + if (!$this->isReviewPostType($post)) { |
|
278 | + return; |
|
279 | + } |
|
280 | + glsr()->render('partials/editor/metabox-categories', [ |
|
281 | + 'post' => $post, |
|
282 | + 'tax_name' => Application::TAXONOMY, |
|
283 | + 'taxonomy' => get_taxonomy(Application::TAXONOMY), |
|
284 | + ]); |
|
285 | + } |
|
286 | 286 | |
287 | - /** |
|
288 | - * @return void |
|
289 | - * @see $this->filterUpdateMessages() |
|
290 | - * @action admin_action_revert |
|
291 | - */ |
|
292 | - public function revertReview() |
|
293 | - { |
|
294 | - if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
295 | - return; |
|
296 | - } |
|
297 | - check_admin_referer('revert-review_'.($postId = $this->getPostId())); |
|
298 | - glsr(ReviewManager::class)->revert($postId); |
|
299 | - $this->redirect($postId, 52); |
|
300 | - } |
|
287 | + /** |
|
288 | + * @return void |
|
289 | + * @see $this->filterUpdateMessages() |
|
290 | + * @action admin_action_revert |
|
291 | + */ |
|
292 | + public function revertReview() |
|
293 | + { |
|
294 | + if (Application::ID != filter_input(INPUT_GET, 'plugin')) { |
|
295 | + return; |
|
296 | + } |
|
297 | + check_admin_referer('revert-review_'.($postId = $this->getPostId())); |
|
298 | + glsr(ReviewManager::class)->revert($postId); |
|
299 | + $this->redirect($postId, 52); |
|
300 | + } |
|
301 | 301 | |
302 | - /** |
|
303 | - * @param int $postId |
|
304 | - * @return void |
|
305 | - * @action save_post_.Application::POST_TYPE |
|
306 | - */ |
|
307 | - public function saveMetaboxes($postId) |
|
308 | - { |
|
309 | - glsr(Metaboxes::class)->saveAssignedToMetabox($postId); |
|
310 | - glsr(Metaboxes::class)->saveResponseMetabox($postId); |
|
311 | - do_action('site-reviews/review/saved', glsr_get_review($postId)); |
|
312 | - } |
|
302 | + /** |
|
303 | + * @param int $postId |
|
304 | + * @return void |
|
305 | + * @action save_post_.Application::POST_TYPE |
|
306 | + */ |
|
307 | + public function saveMetaboxes($postId) |
|
308 | + { |
|
309 | + glsr(Metaboxes::class)->saveAssignedToMetabox($postId); |
|
310 | + glsr(Metaboxes::class)->saveResponseMetabox($postId); |
|
311 | + do_action('site-reviews/review/saved', glsr_get_review($postId)); |
|
312 | + } |
|
313 | 313 | |
314 | - /** |
|
315 | - * @param string $assignedTo |
|
316 | - * @return string |
|
317 | - */ |
|
318 | - protected function buildAssignedToTemplate($assignedTo, WP_Post $post) |
|
319 | - { |
|
320 | - $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo); |
|
321 | - if (!($assignedPost instanceof WP_Post)) { |
|
322 | - return; |
|
323 | - } |
|
324 | - return glsr(Template::class)->build('partials/editor/assigned-post', [ |
|
325 | - 'context' => [ |
|
326 | - 'data.url' => (string) get_permalink($assignedPost), |
|
327 | - 'data.title' => get_the_title($assignedPost), |
|
328 | - ], |
|
329 | - ]); |
|
330 | - } |
|
314 | + /** |
|
315 | + * @param string $assignedTo |
|
316 | + * @return string |
|
317 | + */ |
|
318 | + protected function buildAssignedToTemplate($assignedTo, WP_Post $post) |
|
319 | + { |
|
320 | + $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo); |
|
321 | + if (!($assignedPost instanceof WP_Post)) { |
|
322 | + return; |
|
323 | + } |
|
324 | + return glsr(Template::class)->build('partials/editor/assigned-post', [ |
|
325 | + 'context' => [ |
|
326 | + 'data.url' => (string) get_permalink($assignedPost), |
|
327 | + 'data.title' => get_the_title($assignedPost), |
|
328 | + ], |
|
329 | + ]); |
|
330 | + } |
|
331 | 331 | |
332 | - /** |
|
333 | - * @return string |
|
334 | - */ |
|
335 | - protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post) |
|
336 | - { |
|
337 | - $isModified = !glsr(Helper::class)->compareArrays( |
|
338 | - [$review->title, $review->content, $review->date], |
|
339 | - [ |
|
340 | - glsr(Database::class)->get($post->ID, 'title'), |
|
341 | - glsr(Database::class)->get($post->ID, 'content'), |
|
342 | - glsr(Database::class)->get($post->ID, 'date'), |
|
343 | - ] |
|
344 | - ); |
|
345 | - if ($isModified) { |
|
346 | - $revertUrl = wp_nonce_url( |
|
347 | - admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID), |
|
348 | - 'revert-review_'.$post->ID |
|
349 | - ); |
|
350 | - return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [ |
|
351 | - 'class' => 'button button-large', |
|
352 | - 'href' => $revertUrl, |
|
353 | - 'id' => 'revert', |
|
354 | - ]); |
|
355 | - } |
|
356 | - return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [ |
|
357 | - 'class' => 'button-large', |
|
358 | - 'disabled' => true, |
|
359 | - 'id' => 'revert', |
|
360 | - ]); |
|
361 | - } |
|
332 | + /** |
|
333 | + * @return string |
|
334 | + */ |
|
335 | + protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post) |
|
336 | + { |
|
337 | + $isModified = !glsr(Helper::class)->compareArrays( |
|
338 | + [$review->title, $review->content, $review->date], |
|
339 | + [ |
|
340 | + glsr(Database::class)->get($post->ID, 'title'), |
|
341 | + glsr(Database::class)->get($post->ID, 'content'), |
|
342 | + glsr(Database::class)->get($post->ID, 'date'), |
|
343 | + ] |
|
344 | + ); |
|
345 | + if ($isModified) { |
|
346 | + $revertUrl = wp_nonce_url( |
|
347 | + admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID), |
|
348 | + 'revert-review_'.$post->ID |
|
349 | + ); |
|
350 | + return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [ |
|
351 | + 'class' => 'button button-large', |
|
352 | + 'href' => $revertUrl, |
|
353 | + 'id' => 'revert', |
|
354 | + ]); |
|
355 | + } |
|
356 | + return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [ |
|
357 | + 'class' => 'button-large', |
|
358 | + 'disabled' => true, |
|
359 | + 'id' => 'revert', |
|
360 | + ]); |
|
361 | + } |
|
362 | 362 | |
363 | - /** |
|
364 | - * @param object $review |
|
365 | - * @return string|void |
|
366 | - */ |
|
367 | - protected function getReviewType($review) |
|
368 | - { |
|
369 | - if (count(glsr()->reviewTypes) < 2) { |
|
370 | - return; |
|
371 | - } |
|
372 | - $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes) |
|
373 | - ? glsr()->reviewTypes[$review->review_type] |
|
374 | - : __('Unknown', 'site-reviews'); |
|
375 | - if (!empty($review->url)) { |
|
376 | - $reviewType = glsr(Builder::class)->a($reviewType, [ |
|
377 | - 'href' => $review->url, |
|
378 | - 'target' => '_blank', |
|
379 | - ]); |
|
380 | - } |
|
381 | - return $reviewType; |
|
382 | - } |
|
363 | + /** |
|
364 | + * @param object $review |
|
365 | + * @return string|void |
|
366 | + */ |
|
367 | + protected function getReviewType($review) |
|
368 | + { |
|
369 | + if (count(glsr()->reviewTypes) < 2) { |
|
370 | + return; |
|
371 | + } |
|
372 | + $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes) |
|
373 | + ? glsr()->reviewTypes[$review->review_type] |
|
374 | + : __('Unknown', 'site-reviews'); |
|
375 | + if (!empty($review->url)) { |
|
376 | + $reviewType = glsr(Builder::class)->a($reviewType, [ |
|
377 | + 'href' => $review->url, |
|
378 | + 'target' => '_blank', |
|
379 | + ]); |
|
380 | + } |
|
381 | + return $reviewType; |
|
382 | + } |
|
383 | 383 | |
384 | - /** |
|
385 | - * @return bool |
|
386 | - */ |
|
387 | - protected function isReviewEditable($post) |
|
388 | - { |
|
389 | - return $this->isReviewPostType($post) |
|
390 | - && post_type_supports(Application::POST_TYPE, 'title') |
|
391 | - && 'local' == glsr(Database::class)->get($post->ID, 'review_type'); |
|
392 | - } |
|
384 | + /** |
|
385 | + * @return bool |
|
386 | + */ |
|
387 | + protected function isReviewEditable($post) |
|
388 | + { |
|
389 | + return $this->isReviewPostType($post) |
|
390 | + && post_type_supports(Application::POST_TYPE, 'title') |
|
391 | + && 'local' == glsr(Database::class)->get($post->ID, 'review_type'); |
|
392 | + } |
|
393 | 393 | |
394 | - /** |
|
395 | - * @param mixed $post |
|
396 | - * @return bool |
|
397 | - */ |
|
398 | - protected function isReviewPostType($post) |
|
399 | - { |
|
400 | - return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type; |
|
401 | - } |
|
394 | + /** |
|
395 | + * @param mixed $post |
|
396 | + * @return bool |
|
397 | + */ |
|
398 | + protected function isReviewPostType($post) |
|
399 | + { |
|
400 | + return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type; |
|
401 | + } |
|
402 | 402 | |
403 | - /** |
|
404 | - * @return array |
|
405 | - */ |
|
406 | - protected function normalizeDetailsMetaBox(Review $review) |
|
407 | - { |
|
408 | - $user = empty($review->user_id) |
|
409 | - ? __('Unregistered user', 'site-reviews') |
|
410 | - : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [ |
|
411 | - 'href' => get_author_posts_url($review->user_id), |
|
412 | - ]); |
|
413 | - $email = empty($review->email) |
|
414 | - ? '—' |
|
415 | - : glsr(Builder::class)->a($review->email, [ |
|
416 | - 'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title), |
|
417 | - ]); |
|
418 | - $metabox = [ |
|
419 | - __('Rating', 'site-reviews') => glsr_star_rating($review->rating), |
|
420 | - __('Type', 'site-reviews') => $this->getReviewType($review), |
|
421 | - __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'), |
|
422 | - __('Name', 'site-reviews') => $review->author, |
|
423 | - __('Email', 'site-reviews') => $email, |
|
424 | - __('User', 'site-reviews') => $user, |
|
425 | - __('IP Address', 'site-reviews') => $review->ip_address, |
|
426 | - __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar), |
|
427 | - ]; |
|
428 | - return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review)); |
|
429 | - } |
|
403 | + /** |
|
404 | + * @return array |
|
405 | + */ |
|
406 | + protected function normalizeDetailsMetaBox(Review $review) |
|
407 | + { |
|
408 | + $user = empty($review->user_id) |
|
409 | + ? __('Unregistered user', 'site-reviews') |
|
410 | + : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [ |
|
411 | + 'href' => get_author_posts_url($review->user_id), |
|
412 | + ]); |
|
413 | + $email = empty($review->email) |
|
414 | + ? '—' |
|
415 | + : glsr(Builder::class)->a($review->email, [ |
|
416 | + 'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title), |
|
417 | + ]); |
|
418 | + $metabox = [ |
|
419 | + __('Rating', 'site-reviews') => glsr_star_rating($review->rating), |
|
420 | + __('Type', 'site-reviews') => $this->getReviewType($review), |
|
421 | + __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'), |
|
422 | + __('Name', 'site-reviews') => $review->author, |
|
423 | + __('Email', 'site-reviews') => $email, |
|
424 | + __('User', 'site-reviews') => $user, |
|
425 | + __('IP Address', 'site-reviews') => $review->ip_address, |
|
426 | + __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar), |
|
427 | + ]; |
|
428 | + return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review)); |
|
429 | + } |
|
430 | 430 | |
431 | - /** |
|
432 | - * @param int $postId |
|
433 | - * @param int $messageIndex |
|
434 | - * @return void |
|
435 | - */ |
|
436 | - protected function redirect($postId, $messageIndex) |
|
437 | - { |
|
438 | - $referer = wp_get_referer(); |
|
439 | - $hasReferer = !$referer |
|
440 | - || false !== strpos($referer, 'post.php') |
|
441 | - || false !== strpos($referer, 'post-new.php'); |
|
442 | - $redirectUri = $hasReferer |
|
443 | - ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer) |
|
444 | - : get_edit_post_link($postId); |
|
445 | - wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri)); |
|
446 | - exit; |
|
447 | - } |
|
431 | + /** |
|
432 | + * @param int $postId |
|
433 | + * @param int $messageIndex |
|
434 | + * @return void |
|
435 | + */ |
|
436 | + protected function redirect($postId, $messageIndex) |
|
437 | + { |
|
438 | + $referer = wp_get_referer(); |
|
439 | + $hasReferer = !$referer |
|
440 | + || false !== strpos($referer, 'post.php') |
|
441 | + || false !== strpos($referer, 'post-new.php'); |
|
442 | + $redirectUri = $hasReferer |
|
443 | + ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer) |
|
444 | + : get_edit_post_link($postId); |
|
445 | + wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri)); |
|
446 | + exit; |
|
447 | + } |
|
448 | 448 | } |
@@ -18,100 +18,100 @@ |
||
18 | 18 | |
19 | 19 | class Actions implements HooksContract |
20 | 20 | { |
21 | - protected $admin; |
|
22 | - protected $app; |
|
23 | - protected $blocks; |
|
24 | - protected $console; |
|
25 | - protected $editor; |
|
26 | - protected $listtable; |
|
27 | - protected $menu; |
|
28 | - protected $main; |
|
29 | - protected $public; |
|
30 | - protected $rebusify; |
|
31 | - protected $review; |
|
32 | - protected $router; |
|
33 | - protected $settings; |
|
34 | - protected $taxonomy; |
|
21 | + protected $admin; |
|
22 | + protected $app; |
|
23 | + protected $blocks; |
|
24 | + protected $console; |
|
25 | + protected $editor; |
|
26 | + protected $listtable; |
|
27 | + protected $menu; |
|
28 | + protected $main; |
|
29 | + protected $public; |
|
30 | + protected $rebusify; |
|
31 | + protected $review; |
|
32 | + protected $router; |
|
33 | + protected $settings; |
|
34 | + protected $taxonomy; |
|
35 | 35 | |
36 | - public function __construct(Application $app ) { |
|
37 | - $this->app = $app; |
|
38 | - $this->admin = $app->make(AdminController::class); |
|
39 | - $this->blocks = $app->make(BlocksController::class); |
|
40 | - $this->console = $app->make(Console::class); |
|
41 | - $this->editor = $app->make(EditorController::class); |
|
42 | - $this->listtable = $app->make(ListTableController::class); |
|
43 | - $this->main = $app->make(MainController::class); |
|
44 | - $this->menu = $app->make(MenuController::class); |
|
45 | - $this->public = $app->make(PublicController::class); |
|
46 | - $this->rebusify = $app->make(RebusifyController::class); |
|
47 | - $this->review = $app->make(ReviewController::class); |
|
48 | - $this->router = $app->make(Router::class); |
|
49 | - $this->settings = $app->make(SettingsController::class); |
|
50 | - $this->taxonomy = $app->make(TaxonomyController::class); |
|
51 | - } |
|
36 | + public function __construct(Application $app ) { |
|
37 | + $this->app = $app; |
|
38 | + $this->admin = $app->make(AdminController::class); |
|
39 | + $this->blocks = $app->make(BlocksController::class); |
|
40 | + $this->console = $app->make(Console::class); |
|
41 | + $this->editor = $app->make(EditorController::class); |
|
42 | + $this->listtable = $app->make(ListTableController::class); |
|
43 | + $this->main = $app->make(MainController::class); |
|
44 | + $this->menu = $app->make(MenuController::class); |
|
45 | + $this->public = $app->make(PublicController::class); |
|
46 | + $this->rebusify = $app->make(RebusifyController::class); |
|
47 | + $this->review = $app->make(ReviewController::class); |
|
48 | + $this->router = $app->make(Router::class); |
|
49 | + $this->settings = $app->make(SettingsController::class); |
|
50 | + $this->taxonomy = $app->make(TaxonomyController::class); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return void |
|
55 | - */ |
|
56 | - public function run() |
|
57 | - { |
|
58 | - add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']); |
|
59 | - add_action('admin_init', [$this->admin, 'registerTinymcePopups']); |
|
60 | - add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11); |
|
61 | - add_action('plugins_loaded', [$this->app, 'getDefaults'], 11); |
|
62 | - add_action('plugins_loaded', [$this->app, 'registerAddons']); |
|
63 | - add_action('plugins_loaded', [$this->app, 'registerLanguages']); |
|
64 | - add_action('plugins_loaded', [$this->app, 'registerReviewTypes']); |
|
65 | - add_action('upgrader_process_complete', [$this->app, 'upgraded'], 10, 2); |
|
66 | - add_action('init', [$this->blocks, 'registerAssets'], 9); |
|
67 | - add_action('init', [$this->blocks, 'registerBlocks']); |
|
68 | - add_action('admin_footer', [$this->console, 'logOnce']); |
|
69 | - add_action('wp_footer', [$this->console, 'logOnce']); |
|
70 | - add_action('admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels']); |
|
71 | - add_action('add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes']); |
|
72 | - add_action('admin_print_scripts', [$this->editor, 'removeAutosave'], 999); |
|
73 | - add_action('admin_menu', [$this->editor, 'removeMetaBoxes']); |
|
74 | - add_action('current_screen', [$this->editor, 'removePostTypeSupport']); |
|
75 | - add_action('post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox']); |
|
76 | - add_action('admin_head', [$this->editor, 'renderReviewFields']); |
|
77 | - add_action('admin_action_revert', [$this->editor, 'revertReview']); |
|
78 | - add_action('save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes']); |
|
79 | - add_action('admin_action_approve', [$this->listtable, 'approve']); |
|
80 | - add_action('bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2); |
|
81 | - add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']); |
|
82 | - add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2); |
|
83 | - add_action('save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields']); |
|
84 | - add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']); |
|
85 | - add_action('admin_action_unapprove', [$this->listtable, 'unapprove']); |
|
86 | - add_action('init', [$this->main, 'registerPostType'], 8); |
|
87 | - add_action('init', [$this->main, 'registerShortcodes']); |
|
88 | - add_action('init', [$this->main, 'registerTaxonomy']); |
|
89 | - add_action('widgets_init', [$this->main, 'registerWidgets']); |
|
90 | - add_action('admin_menu', [$this->menu, 'registerMenuCount']); |
|
91 | - add_action('admin_menu', [$this->menu, 'registerSubMenus']); |
|
92 | - add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999); |
|
93 | - add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999); |
|
94 | - add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']); |
|
95 | - add_action('wp_footer', [$this->public, 'renderSchema']); |
|
96 | - add_action('site-reviews/review/created', [$this->rebusify, 'onCreated']); |
|
97 | - add_action('site-reviews/review/reverted', [$this->rebusify, 'onReverted']); |
|
98 | - add_action('site-reviews/review/saved', [$this->rebusify, 'onSaved']); |
|
99 | - add_action('updated_postmeta', [$this->rebusify, 'onUpdatedMeta'], 10, 4); |
|
100 | - add_action('set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6); |
|
101 | - add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3); |
|
102 | - add_action('site-reviews/review/created', [$this->review, 'onAfterCreate']); |
|
103 | - add_action('before_delete_post', [$this->review, 'onBeforeDelete']); |
|
104 | - add_action('update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4); |
|
105 | - add_action('admin_init', [$this->router, 'routeAdminPostRequest']); |
|
106 | - add_action('wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
107 | - add_action('wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
108 | - add_action('init', [$this->router, 'routePublicPostRequest']); |
|
109 | - add_action('admin_init', [$this->settings, 'registerSettings']); |
|
110 | - add_action(Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents']); |
|
111 | - add_action(Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents']); |
|
112 | - add_action(Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents']); |
|
113 | - add_action(Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents']); |
|
114 | - add_action('restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9); |
|
115 | - add_action('set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6); |
|
116 | - } |
|
53 | + /** |
|
54 | + * @return void |
|
55 | + */ |
|
56 | + public function run() |
|
57 | + { |
|
58 | + add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']); |
|
59 | + add_action('admin_init', [$this->admin, 'registerTinymcePopups']); |
|
60 | + add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11); |
|
61 | + add_action('plugins_loaded', [$this->app, 'getDefaults'], 11); |
|
62 | + add_action('plugins_loaded', [$this->app, 'registerAddons']); |
|
63 | + add_action('plugins_loaded', [$this->app, 'registerLanguages']); |
|
64 | + add_action('plugins_loaded', [$this->app, 'registerReviewTypes']); |
|
65 | + add_action('upgrader_process_complete', [$this->app, 'upgraded'], 10, 2); |
|
66 | + add_action('init', [$this->blocks, 'registerAssets'], 9); |
|
67 | + add_action('init', [$this->blocks, 'registerBlocks']); |
|
68 | + add_action('admin_footer', [$this->console, 'logOnce']); |
|
69 | + add_action('wp_footer', [$this->console, 'logOnce']); |
|
70 | + add_action('admin_enqueue_scripts', [$this->editor, 'customizePostStatusLabels']); |
|
71 | + add_action('add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes']); |
|
72 | + add_action('admin_print_scripts', [$this->editor, 'removeAutosave'], 999); |
|
73 | + add_action('admin_menu', [$this->editor, 'removeMetaBoxes']); |
|
74 | + add_action('current_screen', [$this->editor, 'removePostTypeSupport']); |
|
75 | + add_action('post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox']); |
|
76 | + add_action('admin_head', [$this->editor, 'renderReviewFields']); |
|
77 | + add_action('admin_action_revert', [$this->editor, 'revertReview']); |
|
78 | + add_action('save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes']); |
|
79 | + add_action('admin_action_approve', [$this->listtable, 'approve']); |
|
80 | + add_action('bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2); |
|
81 | + add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']); |
|
82 | + add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2); |
|
83 | + add_action('save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields']); |
|
84 | + add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']); |
|
85 | + add_action('admin_action_unapprove', [$this->listtable, 'unapprove']); |
|
86 | + add_action('init', [$this->main, 'registerPostType'], 8); |
|
87 | + add_action('init', [$this->main, 'registerShortcodes']); |
|
88 | + add_action('init', [$this->main, 'registerTaxonomy']); |
|
89 | + add_action('widgets_init', [$this->main, 'registerWidgets']); |
|
90 | + add_action('admin_menu', [$this->menu, 'registerMenuCount']); |
|
91 | + add_action('admin_menu', [$this->menu, 'registerSubMenus']); |
|
92 | + add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999); |
|
93 | + add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999); |
|
94 | + add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']); |
|
95 | + add_action('wp_footer', [$this->public, 'renderSchema']); |
|
96 | + add_action('site-reviews/review/created', [$this->rebusify, 'onCreated']); |
|
97 | + add_action('site-reviews/review/reverted', [$this->rebusify, 'onReverted']); |
|
98 | + add_action('site-reviews/review/saved', [$this->rebusify, 'onSaved']); |
|
99 | + add_action('updated_postmeta', [$this->rebusify, 'onUpdatedMeta'], 10, 4); |
|
100 | + add_action('set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6); |
|
101 | + add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3); |
|
102 | + add_action('site-reviews/review/created', [$this->review, 'onAfterCreate']); |
|
103 | + add_action('before_delete_post', [$this->review, 'onBeforeDelete']); |
|
104 | + add_action('update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4); |
|
105 | + add_action('admin_init', [$this->router, 'routeAdminPostRequest']); |
|
106 | + add_action('wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
107 | + add_action('wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
108 | + add_action('init', [$this->router, 'routePublicPostRequest']); |
|
109 | + add_action('admin_init', [$this->settings, 'registerSettings']); |
|
110 | + add_action(Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents']); |
|
111 | + add_action(Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents']); |
|
112 | + add_action(Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents']); |
|
113 | + add_action(Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents']); |
|
114 | + add_action('restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9); |
|
115 | + add_action('set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6); |
|
116 | + } |
|
117 | 117 | } |