@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <button type="submit" class="glsr-button button btn"> |
4 | 4 | <span class="glsr-button-loading"></span> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <span class="glsr-field-error"> |
4 | 4 | {{ errors }} |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-field {{ class }}"> |
4 | 4 | <div class="glsr-field-choice"> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-field {{ class }}"> |
4 | 4 | {{ label }} |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="pagination"> |
4 | 4 | <nav class="navigation" role="navigation"> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <strong>A new {review_rating}-star review has been submitted:</strong> |
4 | 4 |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-login-register"> |
4 | 4 | <p>{{ text }}</p> |
@@ -1,4 +1,4 @@ |
||
1 | -<?php defined('WPINC') || die; ?> |
|
1 | +<?php defined( 'WPINC' ) || die; ?> |
|
2 | 2 | |
3 | 3 | <div class="glsr-reviews-wrap"> |
4 | 4 | <div class="{{ class }}" id="{{ id }}"> |
@@ -9,138 +9,138 @@ |
||
9 | 9 | |
10 | 10 | class Slack |
11 | 11 | { |
12 | - /** |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - public $endpoint; |
|
12 | + /** |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + public $endpoint; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @var array |
|
19 | - */ |
|
20 | - public $notification; |
|
17 | + /** |
|
18 | + * @var array |
|
19 | + */ |
|
20 | + public $notification; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @var Review |
|
24 | - */ |
|
25 | - public $review; |
|
22 | + /** |
|
23 | + * @var Review |
|
24 | + */ |
|
25 | + public $review; |
|
26 | 26 | |
27 | - public function __construct() |
|
28 | - { |
|
29 | - $this->endpoint = glsr(OptionManager::class)->get('settings.general.notification_slack'); |
|
30 | - } |
|
27 | + public function __construct() |
|
28 | + { |
|
29 | + $this->endpoint = glsr(OptionManager::class)->get('settings.general.notification_slack'); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * @return Slack |
|
34 | - */ |
|
35 | - public function compose(Review $review, array $notification) |
|
36 | - { |
|
37 | - if (empty($this->endpoint)) { |
|
38 | - return $this; |
|
39 | - } |
|
40 | - $args = shortcode_atts(glsr(SlackDefaults::class)->defaults(), $notification); |
|
41 | - $this->review = $review; |
|
42 | - $notification = [ |
|
43 | - 'icon_url' => $args['icon_url'], |
|
44 | - 'username' => $args['username'], |
|
45 | - 'attachments' => [[ |
|
46 | - 'actions' => $this->buildAction($args), |
|
47 | - 'pretext' => $args['pretext'], |
|
48 | - 'color' => $args['color'], |
|
49 | - 'fallback' => $args['fallback'], |
|
50 | - 'fields' => $this->buildFields(), |
|
51 | - ]], |
|
52 | - ]; |
|
53 | - $this->notification = apply_filters('site-reviews/slack/compose', $notification, $this); |
|
54 | - return $this; |
|
55 | - } |
|
32 | + /** |
|
33 | + * @return Slack |
|
34 | + */ |
|
35 | + public function compose(Review $review, array $notification) |
|
36 | + { |
|
37 | + if (empty($this->endpoint)) { |
|
38 | + return $this; |
|
39 | + } |
|
40 | + $args = shortcode_atts(glsr(SlackDefaults::class)->defaults(), $notification); |
|
41 | + $this->review = $review; |
|
42 | + $notification = [ |
|
43 | + 'icon_url' => $args['icon_url'], |
|
44 | + 'username' => $args['username'], |
|
45 | + 'attachments' => [[ |
|
46 | + 'actions' => $this->buildAction($args), |
|
47 | + 'pretext' => $args['pretext'], |
|
48 | + 'color' => $args['color'], |
|
49 | + 'fallback' => $args['fallback'], |
|
50 | + 'fields' => $this->buildFields(), |
|
51 | + ]], |
|
52 | + ]; |
|
53 | + $this->notification = apply_filters('site-reviews/slack/compose', $notification, $this); |
|
54 | + return $this; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return WP_Error|array |
|
59 | - */ |
|
60 | - public function send() |
|
61 | - { |
|
62 | - if (empty($this->endpoint)) { |
|
63 | - return new WP_Error('slack', 'Slack notification was not sent: missing endpoint'); |
|
64 | - } |
|
65 | - return wp_remote_post($this->endpoint, [ |
|
66 | - 'blocking' => false, |
|
67 | - 'body' => json_encode($this->notification), |
|
68 | - 'headers' => ['Content-Type' => 'application/json'], |
|
69 | - 'httpversion' => '1.0', |
|
70 | - 'method' => 'POST', |
|
71 | - 'redirection' => 5, |
|
72 | - 'sslverify' => false, |
|
73 | - 'timeout' => 45, |
|
74 | - ]); |
|
75 | - } |
|
57 | + /** |
|
58 | + * @return WP_Error|array |
|
59 | + */ |
|
60 | + public function send() |
|
61 | + { |
|
62 | + if (empty($this->endpoint)) { |
|
63 | + return new WP_Error('slack', 'Slack notification was not sent: missing endpoint'); |
|
64 | + } |
|
65 | + return wp_remote_post($this->endpoint, [ |
|
66 | + 'blocking' => false, |
|
67 | + 'body' => json_encode($this->notification), |
|
68 | + 'headers' => ['Content-Type' => 'application/json'], |
|
69 | + 'httpversion' => '1.0', |
|
70 | + 'method' => 'POST', |
|
71 | + 'redirection' => 5, |
|
72 | + 'sslverify' => false, |
|
73 | + 'timeout' => 45, |
|
74 | + ]); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return array |
|
79 | - */ |
|
80 | - protected function buildAction(array $args) |
|
81 | - { |
|
82 | - return [[ |
|
83 | - 'text' => $args['button_text'], |
|
84 | - 'type' => 'button', |
|
85 | - 'url' => $args['button_url'], |
|
86 | - ]]; |
|
87 | - } |
|
77 | + /** |
|
78 | + * @return array |
|
79 | + */ |
|
80 | + protected function buildAction(array $args) |
|
81 | + { |
|
82 | + return [[ |
|
83 | + 'text' => $args['button_text'], |
|
84 | + 'type' => 'button', |
|
85 | + 'url' => $args['button_url'], |
|
86 | + ]]; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @return array |
|
91 | - */ |
|
92 | - protected function buildAuthorField() |
|
93 | - { |
|
94 | - $email = !empty($this->review->email) |
|
95 | - ? '<'.$this->review->email.'>' |
|
96 | - : ''; |
|
97 | - $author = trim(rtrim($this->review->author).' '.$email); |
|
98 | - return ['value' => implode(' - ', array_filter([$author, $this->review->ip_address]))]; |
|
99 | - } |
|
89 | + /** |
|
90 | + * @return array |
|
91 | + */ |
|
92 | + protected function buildAuthorField() |
|
93 | + { |
|
94 | + $email = !empty($this->review->email) |
|
95 | + ? '<'.$this->review->email.'>' |
|
96 | + : ''; |
|
97 | + $author = trim(rtrim($this->review->author).' '.$email); |
|
98 | + return ['value' => implode(' - ', array_filter([$author, $this->review->ip_address]))]; |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * @return array |
|
103 | - */ |
|
104 | - protected function buildContentField() |
|
105 | - { |
|
106 | - return !empty($this->review->content) |
|
107 | - ? ['value' => $this->review->content] |
|
108 | - : []; |
|
109 | - } |
|
101 | + /** |
|
102 | + * @return array |
|
103 | + */ |
|
104 | + protected function buildContentField() |
|
105 | + { |
|
106 | + return !empty($this->review->content) |
|
107 | + ? ['value' => $this->review->content] |
|
108 | + : []; |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * @return array |
|
113 | - */ |
|
114 | - protected function buildFields() |
|
115 | - { |
|
116 | - $fields = [ |
|
117 | - $this->buildStarsField(), |
|
118 | - $this->buildTitleField(), |
|
119 | - $this->buildContentField(), |
|
120 | - $this->buildAuthorField(), |
|
121 | - ]; |
|
122 | - return array_filter($fields); |
|
123 | - } |
|
111 | + /** |
|
112 | + * @return array |
|
113 | + */ |
|
114 | + protected function buildFields() |
|
115 | + { |
|
116 | + $fields = [ |
|
117 | + $this->buildStarsField(), |
|
118 | + $this->buildTitleField(), |
|
119 | + $this->buildContentField(), |
|
120 | + $this->buildAuthorField(), |
|
121 | + ]; |
|
122 | + return array_filter($fields); |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * @return array |
|
127 | - */ |
|
128 | - protected function buildStarsField() |
|
129 | - { |
|
130 | - $solidStars = str_repeat('★', $this->review->rating); |
|
131 | - $emptyStars = str_repeat('☆', max(0, glsr()->constant('MAX_RATING', Rating::class) - $this->review->rating)); |
|
132 | - $stars = $solidStars.$emptyStars; |
|
133 | - $stars = apply_filters('site-reviews/slack/stars', $stars, $this->review->rating, glsr()->constant('MAX_RATING', Rating::class)); |
|
134 | - return ['title' => $stars]; |
|
135 | - } |
|
125 | + /** |
|
126 | + * @return array |
|
127 | + */ |
|
128 | + protected function buildStarsField() |
|
129 | + { |
|
130 | + $solidStars = str_repeat('★', $this->review->rating); |
|
131 | + $emptyStars = str_repeat('☆', max(0, glsr()->constant('MAX_RATING', Rating::class) - $this->review->rating)); |
|
132 | + $stars = $solidStars.$emptyStars; |
|
133 | + $stars = apply_filters('site-reviews/slack/stars', $stars, $this->review->rating, glsr()->constant('MAX_RATING', Rating::class)); |
|
134 | + return ['title' => $stars]; |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * @return array |
|
139 | - */ |
|
140 | - protected function buildTitleField() |
|
141 | - { |
|
142 | - return !empty($this->review->title) |
|
143 | - ? ['title' => $this->review->title] |
|
144 | - : []; |
|
145 | - } |
|
137 | + /** |
|
138 | + * @return array |
|
139 | + */ |
|
140 | + protected function buildTitleField() |
|
141 | + { |
|
142 | + return !empty($this->review->title) |
|
143 | + ? ['title' => $this->review->title] |
|
144 | + : []; |
|
145 | + } |
|
146 | 146 | } |
@@ -26,31 +26,31 @@ discard block |
||
26 | 26 | |
27 | 27 | public function __construct() |
28 | 28 | { |
29 | - $this->endpoint = glsr(OptionManager::class)->get('settings.general.notification_slack'); |
|
29 | + $this->endpoint = glsr( OptionManager::class )->get( 'settings.general.notification_slack' ); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
33 | 33 | * @return Slack |
34 | 34 | */ |
35 | - public function compose(Review $review, array $notification) |
|
35 | + public function compose( Review $review, array $notification ) |
|
36 | 36 | { |
37 | - if (empty($this->endpoint)) { |
|
37 | + if( empty($this->endpoint) ) { |
|
38 | 38 | return $this; |
39 | 39 | } |
40 | - $args = shortcode_atts(glsr(SlackDefaults::class)->defaults(), $notification); |
|
40 | + $args = shortcode_atts( glsr( SlackDefaults::class )->defaults(), $notification ); |
|
41 | 41 | $this->review = $review; |
42 | 42 | $notification = [ |
43 | 43 | 'icon_url' => $args['icon_url'], |
44 | 44 | 'username' => $args['username'], |
45 | 45 | 'attachments' => [[ |
46 | - 'actions' => $this->buildAction($args), |
|
46 | + 'actions' => $this->buildAction( $args ), |
|
47 | 47 | 'pretext' => $args['pretext'], |
48 | 48 | 'color' => $args['color'], |
49 | 49 | 'fallback' => $args['fallback'], |
50 | 50 | 'fields' => $this->buildFields(), |
51 | 51 | ]], |
52 | 52 | ]; |
53 | - $this->notification = apply_filters('site-reviews/slack/compose', $notification, $this); |
|
53 | + $this->notification = apply_filters( 'site-reviews/slack/compose', $notification, $this ); |
|
54 | 54 | return $this; |
55 | 55 | } |
56 | 56 | |
@@ -59,25 +59,25 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function send() |
61 | 61 | { |
62 | - if (empty($this->endpoint)) { |
|
63 | - return new WP_Error('slack', 'Slack notification was not sent: missing endpoint'); |
|
62 | + if( empty($this->endpoint) ) { |
|
63 | + return new WP_Error( 'slack', 'Slack notification was not sent: missing endpoint' ); |
|
64 | 64 | } |
65 | - return wp_remote_post($this->endpoint, [ |
|
65 | + return wp_remote_post( $this->endpoint, [ |
|
66 | 66 | 'blocking' => false, |
67 | - 'body' => json_encode($this->notification), |
|
67 | + 'body' => json_encode( $this->notification ), |
|
68 | 68 | 'headers' => ['Content-Type' => 'application/json'], |
69 | 69 | 'httpversion' => '1.0', |
70 | 70 | 'method' => 'POST', |
71 | 71 | 'redirection' => 5, |
72 | 72 | 'sslverify' => false, |
73 | 73 | 'timeout' => 45, |
74 | - ]); |
|
74 | + ] ); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @return array |
79 | 79 | */ |
80 | - protected function buildAction(array $args) |
|
80 | + protected function buildAction( array $args ) |
|
81 | 81 | { |
82 | 82 | return [[ |
83 | 83 | 'text' => $args['button_text'], |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | $email = !empty($this->review->email) |
95 | 95 | ? '<'.$this->review->email.'>' |
96 | 96 | : ''; |
97 | - $author = trim(rtrim($this->review->author).' '.$email); |
|
98 | - return ['value' => implode(' - ', array_filter([$author, $this->review->ip_address]))]; |
|
97 | + $author = trim( rtrim( $this->review->author ).' '.$email ); |
|
98 | + return ['value' => implode( ' - ', array_filter( [$author, $this->review->ip_address] ) )]; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $this->buildContentField(), |
120 | 120 | $this->buildAuthorField(), |
121 | 121 | ]; |
122 | - return array_filter($fields); |
|
122 | + return array_filter( $fields ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | */ |
128 | 128 | protected function buildStarsField() |
129 | 129 | { |
130 | - $solidStars = str_repeat('★', $this->review->rating); |
|
131 | - $emptyStars = str_repeat('☆', max(0, glsr()->constant('MAX_RATING', Rating::class) - $this->review->rating)); |
|
130 | + $solidStars = str_repeat( '★', $this->review->rating ); |
|
131 | + $emptyStars = str_repeat( '☆', max( 0, glsr()->constant( 'MAX_RATING', Rating::class ) - $this->review->rating ) ); |
|
132 | 132 | $stars = $solidStars.$emptyStars; |
133 | - $stars = apply_filters('site-reviews/slack/stars', $stars, $this->review->rating, glsr()->constant('MAX_RATING', Rating::class)); |
|
133 | + $stars = apply_filters( 'site-reviews/slack/stars', $stars, $this->review->rating, glsr()->constant( 'MAX_RATING', Rating::class ) ); |
|
134 | 134 | return ['title' => $stars]; |
135 | 135 | } |
136 | 136 |