@@ -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 }}"> |
@@ -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 |
@@ -9,9 +9,9 @@ |
||
9 | 9 | */ |
10 | 10 | public function build() |
11 | 11 | { |
12 | - $this->builder->args = wp_parse_args($this->builder->args, [ |
|
12 | + $this->builder->args = wp_parse_args( $this->builder->args, [ |
|
13 | 13 | 'name' => $this->builder->args['text'], |
14 | - ]); |
|
14 | + ] ); |
|
15 | 15 | $this->builder->tag = 'input'; |
16 | 16 | $this->mergeFieldArgs(); |
17 | 17 | return $this->builder->getOpeningTag(); |
@@ -32,8 +32,8 @@ |
||
32 | 32 | return [ |
33 | 33 | 'is_multi' => true, |
34 | 34 | 'options' => [ |
35 | - 'no' => __('No', 'site-reviews'), |
|
36 | - 'yes' => __('Yes', 'site-reviews'), |
|
35 | + 'no' => __( 'No', 'site-reviews' ), |
|
36 | + 'yes' => __( 'Yes', 'site-reviews' ), |
|
37 | 37 | ], |
38 | 38 | 'type' => 'radio', |
39 | 39 | ]; |
@@ -21,9 +21,9 @@ |
||
21 | 21 | */ |
22 | 22 | public static function required() |
23 | 23 | { |
24 | - $options = ['' => __('Select a Rating', 'site-reviews')]; |
|
25 | - foreach (range(glsr()->constant('MAX_RATING', RatingModule::class), 1) as $rating) { |
|
26 | - $options[$rating] = sprintf(_n('%s Star', '%s Stars', $rating, 'site-reviews'), $rating); |
|
24 | + $options = ['' => __( 'Select a Rating', 'site-reviews' )]; |
|
25 | + foreach( range( glsr()->constant( 'MAX_RATING', RatingModule::class ), 1 ) as $rating ) { |
|
26 | + $options[$rating] = sprintf( _n( '%s Star', '%s Stars', $rating, 'site-reviews' ), $rating ); |
|
27 | 27 | } |
28 | 28 | return [ |
29 | 29 | 'class' => 'glsr-star-rating', |
@@ -8,9 +8,9 @@ discard block |
||
8 | 8 | * @param string $id |
9 | 9 | * @return string |
10 | 10 | */ |
11 | - public function buildFields($id) |
|
11 | + public function buildFields( $id ) |
|
12 | 12 | { |
13 | - return array_reduce($this->getFields($id), function ($carry, $field) { |
|
13 | + return array_reduce( $this->getFields( $id ), function( $carry, $field ) { |
|
14 | 14 | return $carry.$field; |
15 | 15 | }); |
16 | 16 | } |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | * @param string $id |
20 | 20 | * @return array |
21 | 21 | */ |
22 | - public function getFields($id) |
|
22 | + public function getFields( $id ) |
|
23 | 23 | { |
24 | 24 | $fields = []; |
25 | - foreach (glsr()->config('forms/'.$id) as $name => $field) { |
|
26 | - $fields[] = new Field(wp_parse_args($field, ['name' => $name])); |
|
25 | + foreach( glsr()->config( 'forms/'.$id ) as $name => $field ) { |
|
26 | + $fields[] = new Field( wp_parse_args( $field, ['name' => $name] ) ); |
|
27 | 27 | } |
28 | 28 | return $fields; |
29 | 29 | } |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | * @param string $id |
33 | 33 | * @return void |
34 | 34 | */ |
35 | - public function renderFields($id) |
|
35 | + public function renderFields( $id ) |
|
36 | 36 | { |
37 | - echo $this->buildFields($id); |
|
37 | + echo $this->buildFields( $id ); |
|
38 | 38 | } |
39 | 39 | } |
@@ -8,5 +8,5 @@ |
||
8 | 8 | * @params string|array $atts |
9 | 9 | * @return string |
10 | 10 | */ |
11 | - public function buildShortcode($atts = []); |
|
11 | + public function buildShortcode( $atts = [] ); |
|
12 | 12 | } |
@@ -9,5 +9,5 @@ |
||
9 | 9 | /** |
10 | 10 | * @return void |
11 | 11 | */ |
12 | - public function register(Application $app); |
|
12 | + public function register( Application $app ); |
|
13 | 13 | } |
@@ -50,18 +50,18 @@ discard block |
||
50 | 50 | /** |
51 | 51 | * @return string |
52 | 52 | */ |
53 | - public function render(array $attributes) |
|
53 | + public function render( array $attributes ) |
|
54 | 54 | { |
55 | 55 | $attributes['class'] = $attributes['className']; |
56 | - $shortcode = glsr(Shortcode::class); |
|
57 | - if ('edit' == filter_input(INPUT_GET, 'context')) { |
|
58 | - $attributes = $this->normalize($attributes); |
|
56 | + $shortcode = glsr( Shortcode::class ); |
|
57 | + if( 'edit' == filter_input( INPUT_GET, 'context' ) ) { |
|
58 | + $attributes = $this->normalize( $attributes ); |
|
59 | 59 | $this->filterShortcodeClass(); |
60 | - if (!$this->hasVisibleFields($shortcode, $attributes)) { |
|
60 | + if( !$this->hasVisibleFields( $shortcode, $attributes ) ) { |
|
61 | 61 | $this->filterInterpolation(); |
62 | 62 | } |
63 | 63 | } |
64 | - return $shortcode->buildShortcode($attributes); |
|
64 | + return $shortcode->buildShortcode( $attributes ); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | */ |
70 | 70 | protected function filterInterpolation() |
71 | 71 | { |
72 | - add_filter('site-reviews/interpolate/reviews-summary', function ($context) { |
|
72 | + add_filter( 'site-reviews/interpolate/reviews-summary', function( $context ) { |
|
73 | 73 | $context['class'] = 'glsr-default glsr-block-disabled'; |
74 | - $context['text'] = __('You have hidden all of the fields for this block.', 'site-reviews'); |
|
74 | + $context['text'] = __( 'You have hidden all of the fields for this block.', 'site-reviews' ); |
|
75 | 75 | return $context; |
76 | 76 | }); |
77 | 77 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | protected function filterShortcodeClass() |
83 | 83 | { |
84 | - add_filter('site-reviews/style', function () { |
|
84 | + add_filter( 'site-reviews/style', function() { |
|
85 | 85 | return 'default'; |
86 | 86 | }); |
87 | 87 | } |