@@ -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 | } |
@@ -30,18 +30,18 @@ discard block |
||
30 | 30 | |
31 | 31 | public function __construct() |
32 | 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); |
|
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 | 36 | $this->types = $types; |
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
40 | 40 | * @return void |
41 | 41 | */ |
42 | - public function send(Review $review) |
|
42 | + public function send( Review $review ) |
|
43 | 43 | { |
44 | - if (empty($this->types)) { |
|
44 | + if( empty($this->types) ) { |
|
45 | 45 | return; |
46 | 46 | } |
47 | 47 | $this->review = $review; |
@@ -49,41 +49,41 @@ discard block |
||
49 | 49 | 'link' => $this->getLink(), |
50 | 50 | 'title' => $this->getTitle(), |
51 | 51 | ]; |
52 | - $this->sendToEmail($args); |
|
53 | - $this->sendToSlack($args); |
|
52 | + $this->sendToEmail( $args ); |
|
53 | + $this->sendToSlack( $args ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * @return Email |
58 | 58 | */ |
59 | - protected function buildEmail(array $args) |
|
59 | + protected function buildEmail( array $args ) |
|
60 | 60 | { |
61 | - return glsr(Email::class)->compose([ |
|
61 | + return glsr( Email::class )->compose( [ |
|
62 | 62 | 'to' => $this->getEmailAddresses(), |
63 | 63 | 'subject' => $args['title'], |
64 | 64 | 'template' => 'email-notification', |
65 | 65 | 'template-tags' => [ |
66 | - 'review_author' => $this->review->author ?: __('Anonymous', 'site-reviews'), |
|
66 | + 'review_author' => $this->review->author ?: __( 'Anonymous', 'site-reviews' ), |
|
67 | 67 | 'review_content' => $this->review->content, |
68 | 68 | 'review_email' => $this->review->email, |
69 | 69 | 'review_ip' => $this->review->ip_address, |
70 | - 'review_link' => sprintf('<a href="%1$s">%1$s</a>', $args['link']), |
|
70 | + 'review_link' => sprintf( '<a href="%1$s">%1$s</a>', $args['link'] ), |
|
71 | 71 | 'review_rating' => $this->review->rating, |
72 | 72 | 'review_title' => $this->review->title, |
73 | 73 | ], |
74 | - ]); |
|
74 | + ] ); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @return Slack |
79 | 79 | */ |
80 | - protected function buildSlackNotification(array $args) |
|
80 | + protected function buildSlackNotification( array $args ) |
|
81 | 81 | { |
82 | - return glsr(Slack::class)->compose($this->review, [ |
|
82 | + return glsr( Slack::class )->compose( $this->review, [ |
|
83 | 83 | 'button_url' => $args['link'], |
84 | - 'fallback' => $this->buildEmail($args)->read('plaintext'), |
|
84 | + 'fallback' => $this->buildEmail( $args )->read( 'plaintext' ), |
|
85 | 85 | 'pretext' => $args['title'], |
86 | - ]); |
|
86 | + ] ); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,24 +92,24 @@ discard block |
||
92 | 92 | protected function getEmailAddresses() |
93 | 93 | { |
94 | 94 | $emails = []; |
95 | - if (in_array('admin', $this->types)) { |
|
96 | - $emails[] = glsr(OptionManager::class)->getWP('admin_email'); |
|
95 | + if( in_array( 'admin', $this->types ) ) { |
|
96 | + $emails[] = glsr( OptionManager::class )->getWP( 'admin_email' ); |
|
97 | 97 | } |
98 | - if (in_array('author', $this->types)) { |
|
99 | - $assignedPost = get_post(intval($this->review->assigned_to)); |
|
100 | - if ($assignedPost instanceof WP_Post) { |
|
98 | + if( in_array( 'author', $this->types ) ) { |
|
99 | + $assignedPost = get_post( intval( $this->review->assigned_to ) ); |
|
100 | + if( $assignedPost instanceof WP_Post ) { |
|
101 | 101 | $this->email = true; |
102 | - $emails[] = get_the_author_meta('user_email', intval($assignedPost->post_author)); |
|
102 | + $emails[] = get_the_author_meta( 'user_email', intval( $assignedPost->post_author ) ); |
|
103 | 103 | } |
104 | 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); |
|
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 | 110 | } |
111 | - $emails = array_filter(array_keys(array_flip($emails))); |
|
112 | - return apply_filters('site-reviews/notification/emails', $emails, $this->review); |
|
111 | + $emails = array_filter( array_keys( array_flip( $emails ) ) ); |
|
112 | + return apply_filters( 'site-reviews/notification/emails', $emails, $this->review ); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function getLink() |
119 | 119 | { |
120 | - return admin_url('post.php?post='.$this->review->ID.'&action=edit'); |
|
120 | + return admin_url( 'post.php?post='.$this->review->ID.'&action=edit' ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -125,29 +125,29 @@ discard block |
||
125 | 125 | */ |
126 | 126 | protected function getTitle() |
127 | 127 | { |
128 | - $assignedTitle = get_the_title(intval($this->review->assigned_to)); |
|
128 | + $assignedTitle = get_the_title( intval( $this->review->assigned_to ) ); |
|
129 | 129 | $title = _nx( |
130 | 130 | 'New %s-star review', |
131 | 131 | 'New %s-star review of: %s', |
132 | - intval(empty($assignedTitle)), |
|
132 | + intval( empty($assignedTitle) ), |
|
133 | 133 | 'This string differs depending on whether or not the review has been assigned to a post.', |
134 | 134 | 'site-reviews' |
135 | 135 | ); |
136 | - $title = sprintf('[%s] %s', |
|
137 | - wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES), |
|
138 | - sprintf($title, $this->review->rating, $assignedTitle) |
|
136 | + $title = sprintf( '[%s] %s', |
|
137 | + wp_specialchars_decode( glsr( OptionManager::class )->getWP( 'blogname' ), ENT_QUOTES ), |
|
138 | + sprintf( $title, $this->review->rating, $assignedTitle ) |
|
139 | 139 | ); |
140 | - return apply_filters('site-reviews/notification/title', $title, $this->review); |
|
140 | + return apply_filters( 'site-reviews/notification/title', $title, $this->review ); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
144 | 144 | * @return void |
145 | 145 | */ |
146 | - protected function sendToEmail(array $args) |
|
146 | + protected function sendToEmail( array $args ) |
|
147 | 147 | { |
148 | - $email = $this->buildEmail($args); |
|
149 | - if (empty($email->to)) { |
|
150 | - glsr_log()->error('Email notification was not sent (missing email address)'); |
|
148 | + $email = $this->buildEmail( $args ); |
|
149 | + if( empty($email->to) ) { |
|
150 | + glsr_log()->error( 'Email notification was not sent (missing email address)' ); |
|
151 | 151 | return; |
152 | 152 | } |
153 | 153 | $email->send(); |
@@ -156,16 +156,16 @@ discard block |
||
156 | 156 | /** |
157 | 157 | * @return void |
158 | 158 | */ |
159 | - protected function sendToSlack(array $args) |
|
159 | + protected function sendToSlack( array $args ) |
|
160 | 160 | { |
161 | - if (!$this->slack) { |
|
161 | + if( !$this->slack ) { |
|
162 | 162 | return; |
163 | 163 | } |
164 | - $notification = $this->buildSlackNotification($args); |
|
164 | + $notification = $this->buildSlackNotification( $args ); |
|
165 | 165 | $result = $notification->send(); |
166 | - if (is_wp_error($result)) { |
|
166 | + if( is_wp_error( $result ) ) { |
|
167 | 167 | $notification->review = null; |
168 | - glsr_log()->error($result->get_error_message())->debug($notification); |
|
168 | + glsr_log()->error( $result->get_error_message() )->debug( $notification ); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | } |
@@ -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,9 +10,9 @@ discard block |
||
10 | 10 | /** |
11 | 11 | * @return array |
12 | 12 | */ |
13 | - public function filterEditorSettings(array $settings) |
|
13 | + public function filterEditorSettings( array $settings ) |
|
14 | 14 | { |
15 | - if ($this->isReviewEditable()) { |
|
15 | + if( $this->isReviewEditable() ) { |
|
16 | 16 | $settings = [ |
17 | 17 | 'media_buttons' => false, |
18 | 18 | 'quicktags' => false, |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | * @param string $html |
28 | 28 | * @return string |
29 | 29 | */ |
30 | - public function filterEditorTextarea($html) |
|
30 | + public function filterEditorTextarea( $html ) |
|
31 | 31 | { |
32 | - if ($this->isReviewEditable()) { |
|
33 | - $html = str_replace('<textarea', '<div id="ed_toolbar"></div><textarea', $html); |
|
32 | + if( $this->isReviewEditable() ) { |
|
33 | + $html = str_replace( '<textarea', '<div id="ed_toolbar"></div><textarea', $html ); |
|
34 | 34 | } |
35 | 35 | return $html; |
36 | 36 | } |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function removeAutosave() |
42 | 42 | { |
43 | - if (!$this->isReviewEditor() || $this->isReviewEditable()) { |
|
43 | + if( !$this->isReviewEditor() || $this->isReviewEditable() ) { |
|
44 | 44 | return; |
45 | 45 | } |
46 | - wp_deregister_script('autosave'); |
|
46 | + wp_deregister_script( 'autosave' ); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function removeMetaBoxes() |
53 | 53 | { |
54 | - remove_meta_box('slugdiv', Application::POST_TYPE, 'advanced'); |
|
54 | + remove_meta_box( 'slugdiv', Application::POST_TYPE, 'advanced' ); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function removePostTypeSupport() |
61 | 61 | { |
62 | - if (!$this->isReviewEditor() || $this->isReviewEditable()) { |
|
62 | + if( !$this->isReviewEditor() || $this->isReviewEditable() ) { |
|
63 | 63 | return; |
64 | 64 | } |
65 | - remove_post_type_support(Application::POST_TYPE, 'title'); |
|
66 | - remove_post_type_support(Application::POST_TYPE, 'editor'); |
|
65 | + remove_post_type_support( Application::POST_TYPE, 'title' ); |
|
66 | + remove_post_type_support( Application::POST_TYPE, 'editor' ); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | */ |
72 | 72 | protected function isReviewEditable() |
73 | 73 | { |
74 | - $postId = intval(filter_input(INPUT_GET, 'post')); |
|
74 | + $postId = intval( filter_input( INPUT_GET, 'post' ) ); |
|
75 | 75 | return $postId > 0 |
76 | - && 'local' == glsr(Database::class)->get($postId, 'review_type') |
|
76 | + && 'local' == glsr( Database::class )->get( $postId, 'review_type' ) |
|
77 | 77 | && $this->isReviewEditor(); |
78 | 78 | } |
79 | 79 |
@@ -108,7 +108,8 @@ |
||
108 | 108 | constant($integrationClass.'::PLUGIN_NAME') |
109 | 109 | )); |
110 | 110 | return false; |
111 | - } elseif (!glsr($integrationClass)->isSupported()) { |
|
111 | + } |
|
112 | + elseif (!glsr($integrationClass)->isSupported()) { |
|
112 | 113 | glsr(Notice::class)->addError(sprintf( |
113 | 114 | __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'), |
114 | 115 | constant($integrationClass.'::PLUGIN_NAME'), |
@@ -9,120 +9,120 @@ |
||
9 | 9 | |
10 | 10 | class SettingsController extends Controller |
11 | 11 | { |
12 | - /** |
|
13 | - * @param mixed $input |
|
14 | - * @return array |
|
15 | - * @callback register_setting |
|
16 | - */ |
|
17 | - public function callbackRegisterSettings($input) |
|
18 | - { |
|
19 | - $settings = Arr::consolidateArray($input); |
|
20 | - if (1 === count($settings) && array_key_exists('settings', $settings)) { |
|
21 | - $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input); |
|
22 | - $options = $this->sanitizeGeneral($input, $options); |
|
23 | - $options = $this->sanitizeSubmissions($input, $options); |
|
24 | - $options = $this->sanitizeTranslations($input, $options); |
|
25 | - $options = apply_filters('site-reviews/settings/callback', $options, $settings); |
|
26 | - if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') { |
|
27 | - glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews')); |
|
28 | - } |
|
29 | - return $options; |
|
30 | - } |
|
31 | - return $input; |
|
32 | - } |
|
12 | + /** |
|
13 | + * @param mixed $input |
|
14 | + * @return array |
|
15 | + * @callback register_setting |
|
16 | + */ |
|
17 | + public function callbackRegisterSettings($input) |
|
18 | + { |
|
19 | + $settings = Arr::consolidateArray($input); |
|
20 | + if (1 === count($settings) && array_key_exists('settings', $settings)) { |
|
21 | + $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input); |
|
22 | + $options = $this->sanitizeGeneral($input, $options); |
|
23 | + $options = $this->sanitizeSubmissions($input, $options); |
|
24 | + $options = $this->sanitizeTranslations($input, $options); |
|
25 | + $options = apply_filters('site-reviews/settings/callback', $options, $settings); |
|
26 | + if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') { |
|
27 | + glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews')); |
|
28 | + } |
|
29 | + return $options; |
|
30 | + } |
|
31 | + return $input; |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @return void |
|
36 | - * @action admin_init |
|
37 | - */ |
|
38 | - public function registerSettings() |
|
39 | - { |
|
40 | - register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
41 | - 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
|
42 | - ]); |
|
43 | - } |
|
34 | + /** |
|
35 | + * @return void |
|
36 | + * @action admin_init |
|
37 | + */ |
|
38 | + public function registerSettings() |
|
39 | + { |
|
40 | + register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
41 | + 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
|
42 | + ]); |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @return array |
|
47 | - */ |
|
48 | - protected function sanitizeGeneral(array $input, array $options) |
|
49 | - { |
|
50 | - $key = 'settings.general'; |
|
51 | - $inputForm = Arr::get($input, $key); |
|
52 | - if (!$this->hasMultilingualIntegration(Arr::get($inputForm, 'multilingual'))) { |
|
53 | - $options = Arr::set($options, $key.'.multilingual', ''); |
|
54 | - } |
|
55 | - if ('' == trim(Arr::get($inputForm, 'notification_message'))) { |
|
56 | - $defaultValue = Arr::get(glsr()->defaults, $key.'.notification_message'); |
|
57 | - $options = Arr::set($options, $key.'.notification_message', $defaultValue); |
|
58 | - } |
|
59 | - $defaultValue = Arr::get($inputForm, 'notifications', []); |
|
60 | - $options = Arr::set($options, $key.'.notifications', $defaultValue); |
|
61 | - return $options; |
|
62 | - } |
|
45 | + /** |
|
46 | + * @return array |
|
47 | + */ |
|
48 | + protected function sanitizeGeneral(array $input, array $options) |
|
49 | + { |
|
50 | + $key = 'settings.general'; |
|
51 | + $inputForm = Arr::get($input, $key); |
|
52 | + if (!$this->hasMultilingualIntegration(Arr::get($inputForm, 'multilingual'))) { |
|
53 | + $options = Arr::set($options, $key.'.multilingual', ''); |
|
54 | + } |
|
55 | + if ('' == trim(Arr::get($inputForm, 'notification_message'))) { |
|
56 | + $defaultValue = Arr::get(glsr()->defaults, $key.'.notification_message'); |
|
57 | + $options = Arr::set($options, $key.'.notification_message', $defaultValue); |
|
58 | + } |
|
59 | + $defaultValue = Arr::get($inputForm, 'notifications', []); |
|
60 | + $options = Arr::set($options, $key.'.notifications', $defaultValue); |
|
61 | + return $options; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return array |
|
66 | - */ |
|
67 | - protected function sanitizeSubmissions(array $input, array $options) |
|
68 | - { |
|
69 | - $key = 'settings.submissions'; |
|
70 | - $inputForm = Arr::get($input, $key); |
|
71 | - $defaultValue = isset($inputForm['required']) |
|
72 | - ? $inputForm['required'] |
|
73 | - : []; |
|
74 | - $options = Arr::set($options, $key.'.required', $defaultValue); |
|
75 | - return $options; |
|
76 | - } |
|
64 | + /** |
|
65 | + * @return array |
|
66 | + */ |
|
67 | + protected function sanitizeSubmissions(array $input, array $options) |
|
68 | + { |
|
69 | + $key = 'settings.submissions'; |
|
70 | + $inputForm = Arr::get($input, $key); |
|
71 | + $defaultValue = isset($inputForm['required']) |
|
72 | + ? $inputForm['required'] |
|
73 | + : []; |
|
74 | + $options = Arr::set($options, $key.'.required', $defaultValue); |
|
75 | + return $options; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @return array |
|
80 | - */ |
|
81 | - protected function sanitizeTranslations(array $input, array $options) |
|
82 | - { |
|
83 | - $key = 'settings.strings'; |
|
84 | - $inputForm = Arr::consolidateArray(Arr::get($input, $key)); |
|
85 | - if (!empty($inputForm)) { |
|
86 | - $options = Arr::set($options, $key, array_values(array_filter($inputForm))); |
|
87 | - $allowedTags = [ |
|
88 | - 'a' => ['class' => [], 'href' => [], 'target' => []], |
|
89 | - 'span' => ['class' => []], |
|
90 | - ]; |
|
91 | - array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) { |
|
92 | - if (isset($string['s2'])) { |
|
93 | - $string['s2'] = wp_kses($string['s2'], $allowedTags); |
|
94 | - } |
|
95 | - if (isset($string['p2'])) { |
|
96 | - $string['p2'] = wp_kses($string['p2'], $allowedTags); |
|
97 | - } |
|
98 | - }); |
|
99 | - } |
|
100 | - return $options; |
|
101 | - } |
|
78 | + /** |
|
79 | + * @return array |
|
80 | + */ |
|
81 | + protected function sanitizeTranslations(array $input, array $options) |
|
82 | + { |
|
83 | + $key = 'settings.strings'; |
|
84 | + $inputForm = Arr::consolidateArray(Arr::get($input, $key)); |
|
85 | + if (!empty($inputForm)) { |
|
86 | + $options = Arr::set($options, $key, array_values(array_filter($inputForm))); |
|
87 | + $allowedTags = [ |
|
88 | + 'a' => ['class' => [], 'href' => [], 'target' => []], |
|
89 | + 'span' => ['class' => []], |
|
90 | + ]; |
|
91 | + array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) { |
|
92 | + if (isset($string['s2'])) { |
|
93 | + $string['s2'] = wp_kses($string['s2'], $allowedTags); |
|
94 | + } |
|
95 | + if (isset($string['p2'])) { |
|
96 | + $string['p2'] = wp_kses($string['p2'], $allowedTags); |
|
97 | + } |
|
98 | + }); |
|
99 | + } |
|
100 | + return $options; |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * @return bool |
|
105 | - */ |
|
106 | - protected function hasMultilingualIntegration($integration) |
|
107 | - { |
|
108 | - if (!in_array($integration, ['polylang', 'wpml'])) { |
|
109 | - return false; |
|
110 | - } |
|
111 | - $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst($integration); |
|
112 | - if (!glsr($integrationClass)->isActive()) { |
|
113 | - glsr(Notice::class)->addError(sprintf( |
|
114 | - __('Please install/activate the %s plugin to enable integration.', 'site-reviews'), |
|
115 | - constant($integrationClass.'::PLUGIN_NAME') |
|
116 | - )); |
|
117 | - return false; |
|
118 | - } elseif (!glsr($integrationClass)->isSupported()) { |
|
119 | - glsr(Notice::class)->addError(sprintf( |
|
120 | - __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'), |
|
121 | - constant($integrationClass.'::PLUGIN_NAME'), |
|
122 | - constant($integrationClass.'::SUPPORTED_VERSION') |
|
123 | - )); |
|
124 | - return false; |
|
125 | - } |
|
126 | - return true; |
|
127 | - } |
|
103 | + /** |
|
104 | + * @return bool |
|
105 | + */ |
|
106 | + protected function hasMultilingualIntegration($integration) |
|
107 | + { |
|
108 | + if (!in_array($integration, ['polylang', 'wpml'])) { |
|
109 | + return false; |
|
110 | + } |
|
111 | + $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst($integration); |
|
112 | + if (!glsr($integrationClass)->isActive()) { |
|
113 | + glsr(Notice::class)->addError(sprintf( |
|
114 | + __('Please install/activate the %s plugin to enable integration.', 'site-reviews'), |
|
115 | + constant($integrationClass.'::PLUGIN_NAME') |
|
116 | + )); |
|
117 | + return false; |
|
118 | + } elseif (!glsr($integrationClass)->isSupported()) { |
|
119 | + glsr(Notice::class)->addError(sprintf( |
|
120 | + __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'), |
|
121 | + constant($integrationClass.'::PLUGIN_NAME'), |
|
122 | + constant($integrationClass.'::SUPPORTED_VERSION') |
|
123 | + )); |
|
124 | + return false; |
|
125 | + } |
|
126 | + return true; |
|
127 | + } |
|
128 | 128 | } |
@@ -14,17 +14,17 @@ discard block |
||
14 | 14 | * @return array |
15 | 15 | * @callback register_setting |
16 | 16 | */ |
17 | - public function callbackRegisterSettings($input) |
|
17 | + public function callbackRegisterSettings( $input ) |
|
18 | 18 | { |
19 | - $settings = Arr::consolidateArray($input); |
|
20 | - if (1 === count($settings) && array_key_exists('settings', $settings)) { |
|
21 | - $options = array_replace_recursive(glsr(OptionManager::class)->all(), $input); |
|
22 | - $options = $this->sanitizeGeneral($input, $options); |
|
23 | - $options = $this->sanitizeSubmissions($input, $options); |
|
24 | - $options = $this->sanitizeTranslations($input, $options); |
|
25 | - $options = apply_filters('site-reviews/settings/callback', $options, $settings); |
|
26 | - if (filter_input(INPUT_POST, 'option_page') == Application::ID.'-settings') { |
|
27 | - glsr(Notice::class)->addSuccess(__('Settings updated.', 'site-reviews')); |
|
19 | + $settings = Arr::consolidateArray( $input ); |
|
20 | + if( 1 === count( $settings ) && array_key_exists( 'settings', $settings ) ) { |
|
21 | + $options = array_replace_recursive( glsr( OptionManager::class )->all(), $input ); |
|
22 | + $options = $this->sanitizeGeneral( $input, $options ); |
|
23 | + $options = $this->sanitizeSubmissions( $input, $options ); |
|
24 | + $options = $this->sanitizeTranslations( $input, $options ); |
|
25 | + $options = apply_filters( 'site-reviews/settings/callback', $options, $settings ); |
|
26 | + if( filter_input( INPUT_POST, 'option_page' ) == Application::ID.'-settings' ) { |
|
27 | + glsr( Notice::class )->addSuccess( __( 'Settings updated.', 'site-reviews' ) ); |
|
28 | 28 | } |
29 | 29 | return $options; |
30 | 30 | } |
@@ -37,63 +37,63 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function registerSettings() |
39 | 39 | { |
40 | - register_setting(Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
40 | + register_setting( Application::ID.'-settings', OptionManager::databaseKey(), [ |
|
41 | 41 | 'sanitize_callback' => [$this, 'callbackRegisterSettings'], |
42 | - ]); |
|
42 | + ] ); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @return array |
47 | 47 | */ |
48 | - protected function sanitizeGeneral(array $input, array $options) |
|
48 | + protected function sanitizeGeneral( array $input, array $options ) |
|
49 | 49 | { |
50 | 50 | $key = 'settings.general'; |
51 | - $inputForm = Arr::get($input, $key); |
|
52 | - if (!$this->hasMultilingualIntegration(Arr::get($inputForm, 'multilingual'))) { |
|
53 | - $options = Arr::set($options, $key.'.multilingual', ''); |
|
51 | + $inputForm = Arr::get( $input, $key ); |
|
52 | + if( !$this->hasMultilingualIntegration( Arr::get( $inputForm, 'multilingual' ) ) ) { |
|
53 | + $options = Arr::set( $options, $key.'.multilingual', '' ); |
|
54 | 54 | } |
55 | - if ('' == trim(Arr::get($inputForm, 'notification_message'))) { |
|
56 | - $defaultValue = Arr::get(glsr()->defaults, $key.'.notification_message'); |
|
57 | - $options = Arr::set($options, $key.'.notification_message', $defaultValue); |
|
55 | + if( '' == trim( Arr::get( $inputForm, 'notification_message' ) ) ) { |
|
56 | + $defaultValue = Arr::get( glsr()->defaults, $key.'.notification_message' ); |
|
57 | + $options = Arr::set( $options, $key.'.notification_message', $defaultValue ); |
|
58 | 58 | } |
59 | - $defaultValue = Arr::get($inputForm, 'notifications', []); |
|
60 | - $options = Arr::set($options, $key.'.notifications', $defaultValue); |
|
59 | + $defaultValue = Arr::get( $inputForm, 'notifications', [] ); |
|
60 | + $options = Arr::set( $options, $key.'.notifications', $defaultValue ); |
|
61 | 61 | return $options; |
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
65 | 65 | * @return array |
66 | 66 | */ |
67 | - protected function sanitizeSubmissions(array $input, array $options) |
|
67 | + protected function sanitizeSubmissions( array $input, array $options ) |
|
68 | 68 | { |
69 | 69 | $key = 'settings.submissions'; |
70 | - $inputForm = Arr::get($input, $key); |
|
70 | + $inputForm = Arr::get( $input, $key ); |
|
71 | 71 | $defaultValue = isset($inputForm['required']) |
72 | 72 | ? $inputForm['required'] |
73 | 73 | : []; |
74 | - $options = Arr::set($options, $key.'.required', $defaultValue); |
|
74 | + $options = Arr::set( $options, $key.'.required', $defaultValue ); |
|
75 | 75 | return $options; |
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * @return array |
80 | 80 | */ |
81 | - protected function sanitizeTranslations(array $input, array $options) |
|
81 | + protected function sanitizeTranslations( array $input, array $options ) |
|
82 | 82 | { |
83 | 83 | $key = 'settings.strings'; |
84 | - $inputForm = Arr::consolidateArray(Arr::get($input, $key)); |
|
85 | - if (!empty($inputForm)) { |
|
86 | - $options = Arr::set($options, $key, array_values(array_filter($inputForm))); |
|
84 | + $inputForm = Arr::consolidateArray( Arr::get( $input, $key ) ); |
|
85 | + if( !empty($inputForm) ) { |
|
86 | + $options = Arr::set( $options, $key, array_values( array_filter( $inputForm ) ) ); |
|
87 | 87 | $allowedTags = [ |
88 | 88 | 'a' => ['class' => [], 'href' => [], 'target' => []], |
89 | 89 | 'span' => ['class' => []], |
90 | 90 | ]; |
91 | - array_walk($options['settings']['strings'], function (&$string) use ($allowedTags) { |
|
92 | - if (isset($string['s2'])) { |
|
93 | - $string['s2'] = wp_kses($string['s2'], $allowedTags); |
|
91 | + array_walk( $options['settings']['strings'], function( &$string ) use ($allowedTags) { |
|
92 | + if( isset($string['s2']) ) { |
|
93 | + $string['s2'] = wp_kses( $string['s2'], $allowedTags ); |
|
94 | 94 | } |
95 | - if (isset($string['p2'])) { |
|
96 | - $string['p2'] = wp_kses($string['p2'], $allowedTags); |
|
95 | + if( isset($string['p2']) ) { |
|
96 | + $string['p2'] = wp_kses( $string['p2'], $allowedTags ); |
|
97 | 97 | } |
98 | 98 | }); |
99 | 99 | } |
@@ -103,24 +103,24 @@ discard block |
||
103 | 103 | /** |
104 | 104 | * @return bool |
105 | 105 | */ |
106 | - protected function hasMultilingualIntegration($integration) |
|
106 | + protected function hasMultilingualIntegration( $integration ) |
|
107 | 107 | { |
108 | - if (!in_array($integration, ['polylang', 'wpml'])) { |
|
108 | + if( !in_array( $integration, ['polylang', 'wpml'] ) ) { |
|
109 | 109 | return false; |
110 | 110 | } |
111 | - $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst($integration); |
|
112 | - if (!glsr($integrationClass)->isActive()) { |
|
113 | - glsr(Notice::class)->addError(sprintf( |
|
114 | - __('Please install/activate the %s plugin to enable integration.', 'site-reviews'), |
|
115 | - constant($integrationClass.'::PLUGIN_NAME') |
|
116 | - )); |
|
111 | + $integrationClass = 'GeminiLabs\SiteReviews\Modules\\'.ucfirst( $integration ); |
|
112 | + if( !glsr( $integrationClass )->isActive() ) { |
|
113 | + glsr( Notice::class )->addError( sprintf( |
|
114 | + __( 'Please install/activate the %s plugin to enable integration.', 'site-reviews' ), |
|
115 | + constant( $integrationClass.'::PLUGIN_NAME' ) |
|
116 | + ) ); |
|
117 | 117 | return false; |
118 | - } elseif (!glsr($integrationClass)->isSupported()) { |
|
119 | - glsr(Notice::class)->addError(sprintf( |
|
120 | - __('Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews'), |
|
121 | - constant($integrationClass.'::PLUGIN_NAME'), |
|
122 | - constant($integrationClass.'::SUPPORTED_VERSION') |
|
123 | - )); |
|
118 | + } elseif( !glsr( $integrationClass )->isSupported() ) { |
|
119 | + glsr( Notice::class )->addError( sprintf( |
|
120 | + __( 'Please update the %s plugin to v%s or greater to enable integration.', 'site-reviews' ), |
|
121 | + constant( $integrationClass.'::PLUGIN_NAME' ), |
|
122 | + constant( $integrationClass.'::SUPPORTED_VERSION' ) |
|
123 | + ) ); |
|
124 | 124 | return false; |
125 | 125 | } |
126 | 126 | return true; |
@@ -4,29 +4,29 @@ |
||
4 | 4 | |
5 | 5 | interface MultilingualContract |
6 | 6 | { |
7 | - /** |
|
8 | - * @param int|string $postId |
|
9 | - * @return \WP_Post|void|null |
|
10 | - */ |
|
11 | - public function getPost($postId); |
|
7 | + /** |
|
8 | + * @param int|string $postId |
|
9 | + * @return \WP_Post|void|null |
|
10 | + */ |
|
11 | + public function getPost($postId); |
|
12 | 12 | |
13 | - /** |
|
14 | - * @return array |
|
15 | - */ |
|
16 | - public function getPostIds(array $postIds); |
|
13 | + /** |
|
14 | + * @return array |
|
15 | + */ |
|
16 | + public function getPostIds(array $postIds); |
|
17 | 17 | |
18 | - /** |
|
19 | - * @return bool |
|
20 | - */ |
|
21 | - public function isActive(); |
|
18 | + /** |
|
19 | + * @return bool |
|
20 | + */ |
|
21 | + public function isActive(); |
|
22 | 22 | |
23 | - /** |
|
24 | - * @return bool |
|
25 | - */ |
|
26 | - public function isEnabled(); |
|
23 | + /** |
|
24 | + * @return bool |
|
25 | + */ |
|
26 | + public function isEnabled(); |
|
27 | 27 | |
28 | - /** |
|
29 | - * @return bool |
|
30 | - */ |
|
31 | - public function isSupported(); |
|
28 | + /** |
|
29 | + * @return bool |
|
30 | + */ |
|
31 | + public function isSupported(); |
|
32 | 32 | } |
@@ -8,12 +8,12 @@ |
||
8 | 8 | * @param int|string $postId |
9 | 9 | * @return \WP_Post|void|null |
10 | 10 | */ |
11 | - public function getPost($postId); |
|
11 | + public function getPost( $postId ); |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * @return array |
15 | 15 | */ |
16 | - public function getPostIds(array $postIds); |
|
16 | + public function getPostIds( array $postIds ); |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * @return bool |
@@ -7,40 +7,40 @@ |
||
7 | 7 | |
8 | 8 | class EmailDefaults extends Defaults |
9 | 9 | { |
10 | - /** |
|
11 | - * @return array |
|
12 | - */ |
|
13 | - protected function defaults() |
|
14 | - { |
|
15 | - return [ |
|
16 | - 'after' => '', |
|
17 | - 'attachments' => [], |
|
18 | - 'bcc' => '', |
|
19 | - 'before' => '', |
|
20 | - 'cc' => '', |
|
21 | - 'from' => $this->getFromName().' <'.$this->getFromEmail().'>', |
|
22 | - 'message' => '', |
|
23 | - 'reply-to' => '', |
|
24 | - 'subject' => '', |
|
25 | - 'template' => '', |
|
26 | - 'template-tags' => [], |
|
27 | - 'to' => '', |
|
28 | - ]; |
|
29 | - } |
|
10 | + /** |
|
11 | + * @return array |
|
12 | + */ |
|
13 | + protected function defaults() |
|
14 | + { |
|
15 | + return [ |
|
16 | + 'after' => '', |
|
17 | + 'attachments' => [], |
|
18 | + 'bcc' => '', |
|
19 | + 'before' => '', |
|
20 | + 'cc' => '', |
|
21 | + 'from' => $this->getFromName().' <'.$this->getFromEmail().'>', |
|
22 | + 'message' => '', |
|
23 | + 'reply-to' => '', |
|
24 | + 'subject' => '', |
|
25 | + 'template' => '', |
|
26 | + 'template-tags' => [], |
|
27 | + 'to' => '', |
|
28 | + ]; |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * @return string |
|
33 | - */ |
|
34 | - protected function getFromEmail() |
|
35 | - { |
|
36 | - return glsr(OptionManager::class)->getWP('admin_email'); |
|
37 | - } |
|
31 | + /** |
|
32 | + * @return string |
|
33 | + */ |
|
34 | + protected function getFromEmail() |
|
35 | + { |
|
36 | + return glsr(OptionManager::class)->getWP('admin_email'); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - protected function getFromName() |
|
43 | - { |
|
44 | - return wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES); |
|
45 | - } |
|
39 | + /** |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + protected function getFromName() |
|
43 | + { |
|
44 | + return wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES); |
|
45 | + } |
|
46 | 46 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | protected function getFromEmail() |
35 | 35 | { |
36 | - return glsr(OptionManager::class)->getWP('admin_email'); |
|
36 | + return glsr( OptionManager::class )->getWP( 'admin_email' ); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -41,6 +41,6 @@ discard block |
||
41 | 41 | */ |
42 | 42 | protected function getFromName() |
43 | 43 | { |
44 | - return wp_specialchars_decode(glsr(OptionManager::class)->getWP('blogname'), ENT_QUOTES); |
|
44 | + return wp_specialchars_decode( glsr( OptionManager::class )->getWP( 'blogname' ), ENT_QUOTES ); |
|
45 | 45 | } |
46 | 46 | } |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <p class="about-description">We think you'll love the changes in this new release!</p> |
4 | 4 | <div class="is-fullwidth"> |
@@ -1,23 +1,23 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-welcome wrap about-wrap about-wrap-content"> |
4 | 4 | <h1>Welcome to <?= glsr()->name; ?></h1> |
5 | 5 | <div class="about-text">Site Reviews is a free WordPress review plugin with advanced features that makes it easy to manage reviews on your website. Follow the instructions below to get started!</div> |
6 | 6 | <div class="wp-badge">Version <?= glsr()->version; ?></div> |
7 | 7 | <p class="about-buttons"> |
8 | - <a class="button" href="<?= admin_url('edit.php?post_type=site-review&page=documentation'); ?>">Documentation</a> |
|
8 | + <a class="button" href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation' ); ?>">Documentation</a> |
|
9 | 9 | <a class="button" href="https://wordpress.org/support/plugin/site-reviews/">Support</a> |
10 | 10 | <a target="_blank" class="button" href="https://www.facebook.com/sharer/sharer.php?u=https%3A//geminilabs.io/site-reviews"><span class="dashicons dashicons-facebook-alt"></span> Share</a> |
11 | 11 | <a target="_blank" class="button" href="https://twitter.com/intent/tweet?text=Site Reviews is a fantastic WordPress review plugin with advanced features that makes it easy to manage reviews on your website.&url=https://geminilabs.io/site-reviews&hashtags=WordPress,reviewplugins,"><span class="dashicons dashicons-twitter"></span> Tweet</a> |
12 | 12 | </p> |
13 | 13 | <nav class="glsr-nav-tab-wrapper nav-tab-wrapper"> |
14 | - <?php foreach ($tabs as $id => $title) : ?> |
|
14 | + <?php foreach( $tabs as $id => $title ) : ?> |
|
15 | 15 | <a class="glsr-nav-tab nav-tab" href="#<?= $id; ?>"><?= $title; ?></a> |
16 | 16 | <?php endforeach; ?> |
17 | 17 | </nav> |
18 | - <?php foreach ($tabs as $id => $title) : ?> |
|
18 | + <?php foreach( $tabs as $id => $title ) : ?> |
|
19 | 19 | <div class="glsr-nav-view ui-tabs-hide" id="<?= $id; ?>"> |
20 | - <?php $template->render('pages/welcome/'.$id, $data); ?> |
|
20 | + <?php $template->render( 'pages/welcome/'.$id, $data ); ?> |
|
21 | 21 | </div> |
22 | 22 | <?php endforeach; ?> |
23 | 23 | <input type="hidden" name="_active_tab"> |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <p>Hooks (also known as <a href="https://developer.wordpress.org/plugins/hooks/index.html">Actions and Filters</a>) are used in your theme's <code>functions.php</code> file to make changes to the plugin.</p> |
4 | 4 | |
@@ -6,13 +6,13 @@ discard block |
||
6 | 6 | <div class="glsr-card-header"> |
7 | 7 | <h3>Customise the order of the fields in the review submission form</h3> |
8 | 8 | <button type="button" class="handlediv" aria-expanded="true"> |
9 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
9 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
10 | 10 | <span class="toggle-indicator" aria-hidden="true"></span> |
11 | 11 | </button> |
12 | 12 | </div> |
13 | 13 | <div class="inside"> |
14 | 14 | <p>Use this hook to customise the order of the fields in the review submission form used by Site Reviews.</p> |
15 | - <p>See the <code><a data-expand="#faq-07" href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!faq'); ?>">FAQ</a></code> for a detailed example of how to use this hook.</p> |
|
15 | + <p>See the <code><a data-expand="#faq-07" href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!faq' ); ?>">FAQ</a></code> for a detailed example of how to use this hook.</p> |
|
16 | 16 | <pre><code class="php">/** |
17 | 17 | * Customises the order of the fields used in the Site Reviews submission form. |
18 | 18 | * Paste this in your active theme's functions.php file. |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | <div class="glsr-card-header"> |
31 | 31 | <h3>Customise the star images</h3> |
32 | 32 | <button type="button" class="handlediv" aria-expanded="true"> |
33 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
33 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
34 | 34 | <span class="toggle-indicator" aria-hidden="true"></span> |
35 | 35 | </button> |
36 | 36 | </div> |
37 | 37 | <div class="inside"> |
38 | 38 | <p>Use this hook to customise the star images used by Site Reviews.</p> |
39 | - <p>See the <code><a data-expand="#faq-11" href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!faq'); ?>">FAQ</a></code> for a detailed example of how to use this hook.</p> |
|
39 | + <p>See the <code><a data-expand="#faq-11" href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!faq' ); ?>">FAQ</a></code> for a detailed example of how to use this hook.</p> |
|
40 | 40 | <pre><code class="php">/** |
41 | 41 | * Customises the stars used by Site Reviews. |
42 | 42 | * Paste this in your active theme's functions.php file. |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | <div class="glsr-card-header"> |
55 | 55 | <h3>Disable the plugin javascript</h3> |
56 | 56 | <button type="button" class="handlediv" aria-expanded="true"> |
57 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
57 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
58 | 58 | <span class="toggle-indicator" aria-hidden="true"></span> |
59 | 59 | </button> |
60 | 60 | </div> |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | <div class="glsr-card-header"> |
74 | 74 | <h3>Disable the plugin stylesheet</h3> |
75 | 75 | <button type="button" class="handlediv" aria-expanded="true"> |
76 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
76 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
77 | 77 | <span class="toggle-indicator" aria-hidden="true"></span> |
78 | 78 | </button> |
79 | 79 | </div> |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | <div class="glsr-card-header"> |
93 | 93 | <h3>Disable the polyfill.io script</h3> |
94 | 94 | <button type="button" class="handlediv" aria-expanded="true"> |
95 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
95 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
96 | 96 | <span class="toggle-indicator" aria-hidden="true"></span> |
97 | 97 | </button> |
98 | 98 | </div> |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | <div class="glsr-card-header"> |
113 | 113 | <h3>Do something immediately after a review has been submitted</h3> |
114 | 114 | <button type="button" class="handlediv" aria-expanded="true"> |
115 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
115 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
116 | 116 | <span class="toggle-indicator" aria-hidden="true"></span> |
117 | 117 | </button> |
118 | 118 | </div> |
@@ -136,14 +136,14 @@ discard block |
||
136 | 136 | <div class="glsr-card-header"> |
137 | 137 | <h3>Modify the schema</h3> |
138 | 138 | <button type="button" class="handlediv" aria-expanded="true"> |
139 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
139 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
140 | 140 | <span class="toggle-indicator" aria-hidden="true"></span> |
141 | 141 | </button> |
142 | 142 | </div> |
143 | 143 | <div class="inside"> |
144 | 144 | <p>Use this hook if you would like to modify the schema type properties.</p> |
145 | 145 | <p>This hook is specific to the schema type. For example, to modify the schema properties for the LocalBusiness schema type you would use the <code>site-reviews/schema/LocalBusiness</code> hook, but to modify the schema properties for the Product schema type you would use the <code>site-reviews/schema/Product</code> hook.</p> |
146 | - <p>See the <code><a data-expand="#faq-01" href="<?= admin_url('edit.php?post_type=site-review&page=documentation#!faq'); ?>">FAQ</a></code> for a detailed example of how to use this hook.</p> |
|
146 | + <p>See the <code><a data-expand="#faq-01" href="<?= admin_url( 'edit.php?post_type=site-review&page=documentation#!faq' ); ?>">FAQ</a></code> for a detailed example of how to use this hook.</p> |
|
147 | 147 | <p>Make sure to use Google's <a href="https://search.google.com/structured-data/testing-tool">Structured Data Testing Tool</a> to test the schema after any custom modifications have been made.</p> |
148 | 148 | <pre><code class="php">/** |
149 | 149 | * Modifies the properties of the schema created by Site Reviews. |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | <div class="glsr-card-header"> |
164 | 164 | <h3>Modify the submitted review before it is saved</h3> |
165 | 165 | <button type="button" class="handlediv" aria-expanded="true"> |
166 | - <span class="screen-reader-text"><?= __('Toggle documentation panel', 'site-reviews'); ?></span> |
|
166 | + <span class="screen-reader-text"><?= __( 'Toggle documentation panel', 'site-reviews' ); ?></span> |
|
167 | 167 | <span class="toggle-indicator" aria-hidden="true"></span> |
168 | 168 | </button> |
169 | 169 | </div> |
@@ -1,7 +1,7 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | -<p><?= __('The JSON-LD schema is disabled by default. To use it, please enable the option in your blocks or shortcodes. The schema appears in Google\'s search results and shows the star rating and other information about your reviews. If the schema has been enabled, you can use Google\'s <a href="https://search.google.com/structured-data/testing-tool">Structured Data Testing Tool</a> to test your pages for valid schema data.', 'site-reviews'); ?></p> |
|
4 | -<p><?= __('You may override any of these options on a per-post/page basis by using its Custom Field name and adding a custom value using the <a href="https://codex.wordpress.org/Using_Custom_Fields#Usage">Custom Fields</a> metabox.', 'site-reviews'); ?></p> |
|
3 | +<p><?= __( 'The JSON-LD schema is disabled by default. To use it, please enable the option in your blocks or shortcodes. The schema appears in Google\'s search results and shows the star rating and other information about your reviews. If the schema has been enabled, you can use Google\'s <a href="https://search.google.com/structured-data/testing-tool">Structured Data Testing Tool</a> to test your pages for valid schema data.', 'site-reviews' ); ?></p> |
|
4 | +<p><?= __( 'You may override any of these options on a per-post/page basis by using its Custom Field name and adding a custom value using the <a href="https://codex.wordpress.org/Using_Custom_Fields#Usage">Custom Fields</a> metabox.', 'site-reviews' ); ?></p> |
|
5 | 5 | <table class="form-table"> |
6 | 6 | <tbody> |
7 | 7 | {{ rows }} |