Passed
Push — master ( 4321c5...7f1e4d )
by Paul
07:58 queued 04:14
created
plugin/Modules/Notice.php 2 patches
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -8,112 +8,112 @@
 block discarded – undo
8 8
 
9 9
 class Notice
10 10
 {
11
-    /**
12
-     * @param string $type
13
-     * @param string|array|WP_Error $message
14
-     * @return void
15
-     */
16
-    public function add($type, $message, array $args = [])
17
-    {
18
-        if (empty(array_filter([$message, $type]))) {
19
-            return;
20
-        }
21
-        $args['message'] = $message;
22
-        $args['type'] = $type;
23
-        add_settings_error(Application::ID, '', json_encode($this->normalize($args)));
24
-    }
11
+	/**
12
+	 * @param string $type
13
+	 * @param string|array|WP_Error $message
14
+	 * @return void
15
+	 */
16
+	public function add($type, $message, array $args = [])
17
+	{
18
+		if (empty(array_filter([$message, $type]))) {
19
+			return;
20
+		}
21
+		$args['message'] = $message;
22
+		$args['type'] = $type;
23
+		add_settings_error(Application::ID, '', json_encode($this->normalize($args)));
24
+	}
25 25
 
26
-    /**
27
-     * @param string|array|WP_Error $message
28
-     * @return void
29
-     */
30
-    public function addError($message, array $args = [])
31
-    {
32
-        $this->add('error', $message, $args);
33
-    }
26
+	/**
27
+	 * @param string|array|WP_Error $message
28
+	 * @return void
29
+	 */
30
+	public function addError($message, array $args = [])
31
+	{
32
+		$this->add('error', $message, $args);
33
+	}
34 34
 
35
-    /**
36
-     * @param string|array|WP_Error $message
37
-     * @return void
38
-     */
39
-    public function addSuccess($message, array $args = [])
40
-    {
41
-        $this->add('success', $message, $args);
42
-    }
35
+	/**
36
+	 * @param string|array|WP_Error $message
37
+	 * @return void
38
+	 */
39
+	public function addSuccess($message, array $args = [])
40
+	{
41
+		$this->add('success', $message, $args);
42
+	}
43 43
 
44
-    /**
45
-     * @param string|array|WP_Error $message
46
-     * @return void
47
-     */
48
-    public function addWarning($message, array $args = [])
49
-    {
50
-        $this->add('warning', $message, $args);
51
-    }
44
+	/**
45
+	 * @param string|array|WP_Error $message
46
+	 * @return void
47
+	 */
48
+	public function addWarning($message, array $args = [])
49
+	{
50
+		$this->add('warning', $message, $args);
51
+	}
52 52
 
53
-    /**
54
-     * @return static
55
-     */
56
-    public function clear()
57
-    {
58
-        global $wp_settings_errors;
59
-        $wp_settings_errors = [];
60
-        delete_transient('settings_errors');
61
-        return $this;
62
-    }
53
+	/**
54
+	 * @return static
55
+	 */
56
+	public function clear()
57
+	{
58
+		global $wp_settings_errors;
59
+		$wp_settings_errors = [];
60
+		delete_transient('settings_errors');
61
+		return $this;
62
+	}
63 63
 
64
-    /**
65
-     * @return string
66
-     */
67
-    public function get()
68
-    {
69
-        $notices = array_map('unserialize',
70
-            array_unique(array_map('serialize', get_settings_errors(Application::ID)))
71
-        );
72
-        $notices = array_reduce($notices, function ($carry, $notice) {
73
-            return $carry.$this->buildNotice(json_decode($notice['message'], true));
74
-        });
75
-        return apply_filters('site-reviews/notices', $notices);
76
-    }
64
+	/**
65
+	 * @return string
66
+	 */
67
+	public function get()
68
+	{
69
+		$notices = array_map('unserialize',
70
+			array_unique(array_map('serialize', get_settings_errors(Application::ID)))
71
+		);
72
+		$notices = array_reduce($notices, function ($carry, $notice) {
73
+			return $carry.$this->buildNotice(json_decode($notice['message'], true));
74
+		});
75
+		return apply_filters('site-reviews/notices', $notices);
76
+	}
77 77
 
78
-    /**
79
-     * @return string
80
-     */
81
-    protected function buildNotice(array $args)
82
-    {
83
-        $messages = array_reduce($args['messages'], function ($carry, $message) {
84
-            return $carry.glsr(Builder::class)->p($message);
85
-        });
86
-        $class = 'notice notice-'.$args['type'];
87
-        if ($args['inline']) {
88
-            $class.= ' inline';
89
-        }
90
-        if ($args['dismissible']) {
91
-            $class.= ' is-dismissible';
92
-        }
93
-        return glsr(Builder::class)->div($messages, [
94
-            'class' => $class,
95
-        ]);
96
-    }
78
+	/**
79
+	 * @return string
80
+	 */
81
+	protected function buildNotice(array $args)
82
+	{
83
+		$messages = array_reduce($args['messages'], function ($carry, $message) {
84
+			return $carry.glsr(Builder::class)->p($message);
85
+		});
86
+		$class = 'notice notice-'.$args['type'];
87
+		if ($args['inline']) {
88
+			$class.= ' inline';
89
+		}
90
+		if ($args['dismissible']) {
91
+			$class.= ' is-dismissible';
92
+		}
93
+		return glsr(Builder::class)->div($messages, [
94
+			'class' => $class,
95
+		]);
96
+	}
97 97
 
98
-    /**
99
-     * @return array
100
-     */
101
-    protected function normalize(array $args)
102
-    {
103
-        $defaults = [
104
-            'dismissible' => true,
105
-            'inline' => true,
106
-            'message' => '',
107
-            'type' => '',
108
-        ];
109
-        $args = shortcode_atts($defaults, $args);
110
-        if (!in_array($args['type'], ['error', 'warning', 'success'])) {
111
-            $args['type'] = 'success';
112
-        }
113
-        $args['messages'] = is_wp_error($args['message'])
114
-            ? (array) $args['message']->get_error_message()
115
-            : (array) $args['message'];
116
-        unset($args['message']);
117
-        return $args;
118
-    }
98
+	/**
99
+	 * @return array
100
+	 */
101
+	protected function normalize(array $args)
102
+	{
103
+		$defaults = [
104
+			'dismissible' => true,
105
+			'inline' => true,
106
+			'message' => '',
107
+			'type' => '',
108
+		];
109
+		$args = shortcode_atts($defaults, $args);
110
+		if (!in_array($args['type'], ['error', 'warning', 'success'])) {
111
+			$args['type'] = 'success';
112
+		}
113
+		$args['messages'] = is_wp_error($args['message'])
114
+			? (array) $args['message']->get_error_message()
115
+			: (array) $args['message'];
116
+		unset($args['message']);
117
+		return $args;
118
+	}
119 119
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -13,41 +13,41 @@  discard block
 block discarded – undo
13 13
      * @param string|array|WP_Error $message
14 14
      * @return void
15 15
      */
16
-    public function add($type, $message, array $args = [])
16
+    public function add( $type, $message, array $args = [] )
17 17
     {
18
-        if (empty(array_filter([$message, $type]))) {
18
+        if( empty(array_filter( [$message, $type] )) ) {
19 19
             return;
20 20
         }
21 21
         $args['message'] = $message;
22 22
         $args['type'] = $type;
23
-        add_settings_error(Application::ID, '', json_encode($this->normalize($args)));
23
+        add_settings_error( Application::ID, '', json_encode( $this->normalize( $args ) ) );
24 24
     }
25 25
 
26 26
     /**
27 27
      * @param string|array|WP_Error $message
28 28
      * @return void
29 29
      */
30
-    public function addError($message, array $args = [])
30
+    public function addError( $message, array $args = [] )
31 31
     {
32
-        $this->add('error', $message, $args);
32
+        $this->add( 'error', $message, $args );
33 33
     }
34 34
 
35 35
     /**
36 36
      * @param string|array|WP_Error $message
37 37
      * @return void
38 38
      */
39
-    public function addSuccess($message, array $args = [])
39
+    public function addSuccess( $message, array $args = [] )
40 40
     {
41
-        $this->add('success', $message, $args);
41
+        $this->add( 'success', $message, $args );
42 42
     }
43 43
 
44 44
     /**
45 45
      * @param string|array|WP_Error $message
46 46
      * @return void
47 47
      */
48
-    public function addWarning($message, array $args = [])
48
+    public function addWarning( $message, array $args = [] )
49 49
     {
50
-        $this->add('warning', $message, $args);
50
+        $this->add( 'warning', $message, $args );
51 51
     }
52 52
 
53 53
     /**
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
     {
58 58
         global $wp_settings_errors;
59 59
         $wp_settings_errors = [];
60
-        delete_transient('settings_errors');
60
+        delete_transient( 'settings_errors' );
61 61
         return $this;
62 62
     }
63 63
 
@@ -66,39 +66,39 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function get()
68 68
     {
69
-        $notices = array_map('unserialize',
70
-            array_unique(array_map('serialize', get_settings_errors(Application::ID)))
69
+        $notices = array_map( 'unserialize',
70
+            array_unique( array_map( 'serialize', get_settings_errors( Application::ID ) ) )
71 71
         );
72
-        $notices = array_reduce($notices, function ($carry, $notice) {
73
-            return $carry.$this->buildNotice(json_decode($notice['message'], true));
72
+        $notices = array_reduce( $notices, function( $carry, $notice ) {
73
+            return $carry.$this->buildNotice( json_decode( $notice['message'], true ) );
74 74
         });
75
-        return apply_filters('site-reviews/notices', $notices);
75
+        return apply_filters( 'site-reviews/notices', $notices );
76 76
     }
77 77
 
78 78
     /**
79 79
      * @return string
80 80
      */
81
-    protected function buildNotice(array $args)
81
+    protected function buildNotice( array $args )
82 82
     {
83
-        $messages = array_reduce($args['messages'], function ($carry, $message) {
84
-            return $carry.glsr(Builder::class)->p($message);
83
+        $messages = array_reduce( $args['messages'], function( $carry, $message ) {
84
+            return $carry.glsr( Builder::class )->p( $message );
85 85
         });
86 86
         $class = 'notice notice-'.$args['type'];
87
-        if ($args['inline']) {
88
-            $class.= ' inline';
87
+        if( $args['inline'] ) {
88
+            $class .= ' inline';
89 89
         }
90
-        if ($args['dismissible']) {
91
-            $class.= ' is-dismissible';
90
+        if( $args['dismissible'] ) {
91
+            $class .= ' is-dismissible';
92 92
         }
93
-        return glsr(Builder::class)->div($messages, [
93
+        return glsr( Builder::class )->div( $messages, [
94 94
             'class' => $class,
95
-        ]);
95
+        ] );
96 96
     }
97 97
 
98 98
     /**
99 99
      * @return array
100 100
      */
101
-    protected function normalize(array $args)
101
+    protected function normalize( array $args )
102 102
     {
103 103
         $defaults = [
104 104
             'dismissible' => true,
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
             'message' => '',
107 107
             'type' => '',
108 108
         ];
109
-        $args = shortcode_atts($defaults, $args);
110
-        if (!in_array($args['type'], ['error', 'warning', 'success'])) {
109
+        $args = shortcode_atts( $defaults, $args );
110
+        if( !in_array( $args['type'], ['error', 'warning', 'success'] ) ) {
111 111
             $args['type'] = 'success';
112 112
         }
113
-        $args['messages'] = is_wp_error($args['message'])
114
-            ? (array) $args['message']->get_error_message()
115
-            : (array) $args['message'];
113
+        $args['messages'] = is_wp_error( $args['message'] )
114
+            ? (array)$args['message']->get_error_message()
115
+            : (array)$args['message'];
116 116
         unset($args['message']);
117 117
         return $args;
118 118
     }
Please login to merge, or discard this patch.
plugin/Modules/Html/Fields/Password.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,13 +4,13 @@
 block discarded – undo
4 4
 
5 5
 class Password extends Field
6 6
 {
7
-    /**
8
-     * @return array
9
-     */
10
-    public static function defaults()
11
-    {
12
-        return [
13
-            'class' => 'regular-text',
14
-        ];
15
-    }
7
+	/**
8
+	 * @return array
9
+	 */
10
+	public static function defaults()
11
+	{
12
+		return [
13
+			'class' => 'regular-text',
14
+		];
15
+	}
16 16
 }
Please login to merge, or discard this patch.
plugin/Modules/Rebusify.php 3 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -101,7 +101,8 @@
 block discarded – undo
101 101
     {
102 102
         if (is_wp_error($response)) {
103 103
             $this->message = $response->get_error_message();
104
-        } else {
104
+        }
105
+        else {
105 106
             $responseBody = wp_remote_retrieve_body($response);
106 107
             $responseCode = wp_remote_retrieve_response_code($response);
107 108
             $responseData = (array) json_decode($responseBody, true);
Please login to merge, or discard this patch.
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -10,143 +10,143 @@
 block discarded – undo
10 10
 
11 11
 class Rebusify
12 12
 {
13
-    const API_URL = 'https://www.rebusify.com/api/rbs/';
14
-    const WEB_URL = 'https://rebusify.com/plans?ref=105';
13
+	const API_URL = 'https://www.rebusify.com/api/rbs/';
14
+	const WEB_URL = 'https://rebusify.com/plans?ref=105';
15 15
 
16
-    public $message;
17
-    public $response;
18
-    public $success;
16
+	public $message;
17
+	public $response;
18
+	public $success;
19 19
 
20
-    /**
21
-     * @return mixed
22
-     */
23
-    public function __get($key)
24
-    {
25
-        return property_exists($this, $key)
26
-            ? $this->$key
27
-            : Arr::get($this->response, $key, null);
28
-    }
20
+	/**
21
+	 * @return mixed
22
+	 */
23
+	public function __get($key)
24
+	{
25
+		return property_exists($this, $key)
26
+			? $this->$key
27
+			: Arr::get($this->response, $key, null);
28
+	}
29 29
 
30
-    /**
31
-     * @return self
32
-     */
33
-    public function activateKey($apiKey = '', $email = '')
34
-    {
35
-        $this->send('api_key_activation.php', [
36
-            'body' => [
37
-                'apikey' => $apiKey ?: 0,
38
-                'domain' => get_home_url(),
39
-                'email' => $email ?: 0,
40
-            ],
41
-        ]);
42
-        return $this;
43
-    }
30
+	/**
31
+	 * @return self
32
+	 */
33
+	public function activateKey($apiKey = '', $email = '')
34
+	{
35
+		$this->send('api_key_activation.php', [
36
+			'body' => [
37
+				'apikey' => $apiKey ?: 0,
38
+				'domain' => get_home_url(),
39
+				'email' => $email ?: 0,
40
+			],
41
+		]);
42
+		return $this;
43
+	}
44 44
 
45
-    /**
46
-     * @return self
47
-     */
48
-    public function reset()
49
-    {
50
-        $this->message = '';
51
-        $this->response = [];
52
-        $this->success = false;
53
-        return $this;
54
-    }
45
+	/**
46
+	 * @return self
47
+	 */
48
+	public function reset()
49
+	{
50
+		$this->message = '';
51
+		$this->response = [];
52
+		$this->success = false;
53
+		return $this;
54
+	}
55 55
 
56
-    /**
57
-     * @return self
58
-     */
59
-    public function sendReview(Review $review)
60
-    {
61
-        $this->send('index.php', [
62
-            'body' => $this->getBodyForReview($review),
63
-            'timeout' => 120,
64
-        ]);
65
-        return $this;
66
-    }
56
+	/**
57
+	 * @return self
58
+	 */
59
+	public function sendReview(Review $review)
60
+	{
61
+		$this->send('index.php', [
62
+			'body' => $this->getBodyForReview($review),
63
+			'timeout' => 120,
64
+		]);
65
+		return $this;
66
+	}
67 67
 
68
-    /**
69
-     * @return self
70
-     */
71
-    public function sendReviewResponse(Review $review)
72
-    {
73
-        $this->send('fetch_customer_reply.php', [
74
-            'body' => $this->getBodyForResponse($review),
75
-        ]);
76
-        return $this;
77
-    }
68
+	/**
69
+	 * @return self
70
+	 */
71
+	public function sendReviewResponse(Review $review)
72
+	{
73
+		$this->send('fetch_customer_reply.php', [
74
+			'body' => $this->getBodyForResponse($review),
75
+		]);
76
+		return $this;
77
+	}
78 78
 
79
-    /**
80
-     * @return array
81
-     */
82
-    protected function getBodyForResponse(Review $review)
83
-    {
84
-        $rebusifyResponse = [
85
-            'reply' => Str::truncate($review->response, 300),
86
-            'review_id' => glsr(Database::class)->get($review->ID, 'rebusify'), // this is the rebusify review ID
87
-            'review_transaction_id' => $review->review_id,
88
-            'type' => 'M',
89
-        ];
90
-        return apply_filters('site-reviews/rebusify/response', $rebusifyResponse, $review);
91
-    }
79
+	/**
80
+	 * @return array
81
+	 */
82
+	protected function getBodyForResponse(Review $review)
83
+	{
84
+		$rebusifyResponse = [
85
+			'reply' => Str::truncate($review->response, 300),
86
+			'review_id' => glsr(Database::class)->get($review->ID, 'rebusify'), // this is the rebusify review ID
87
+			'review_transaction_id' => $review->review_id,
88
+			'type' => 'M',
89
+		];
90
+		return apply_filters('site-reviews/rebusify/response', $rebusifyResponse, $review);
91
+	}
92 92
 
93
-    /**
94
-     * @return array
95
-     */
96
-    protected function getBodyForReview(Review $review)
97
-    {
98
-        $rebusifyReview = [
99
-            'domain' => get_home_url(),
100
-            'firstname' => Str::truncate(Str::convertName($review->author, 'first'), 25),
101
-            'rate' => $review->rating,
102
-            'review_transaction_id' => $review->review_id,
103
-            'reviews' => Str::truncate($review->content, 280),
104
-            'title' => Str::truncate($review->title, 35),
105
-            'transaction' => Application::ID, // woocommerce field, not needed for Site Reviews
106
-        ];
107
-        return apply_filters('site-reviews/rebusify/review', $rebusifyReview, $review);
108
-    }
93
+	/**
94
+	 * @return array
95
+	 */
96
+	protected function getBodyForReview(Review $review)
97
+	{
98
+		$rebusifyReview = [
99
+			'domain' => get_home_url(),
100
+			'firstname' => Str::truncate(Str::convertName($review->author, 'first'), 25),
101
+			'rate' => $review->rating,
102
+			'review_transaction_id' => $review->review_id,
103
+			'reviews' => Str::truncate($review->content, 280),
104
+			'title' => Str::truncate($review->title, 35),
105
+			'transaction' => Application::ID, // woocommerce field, not needed for Site Reviews
106
+		];
107
+		return apply_filters('site-reviews/rebusify/review', $rebusifyReview, $review);
108
+	}
109 109
 
110
-    /**
111
-     * @param \WP_Error|array $response
112
-     * @return void
113
-     */
114
-    protected function handleResponse($response)
115
-    {
116
-        if (is_wp_error($response)) {
117
-            $this->message = $response->get_error_message();
118
-        } else {
119
-            $responseBody = wp_remote_retrieve_body($response);
120
-            $responseCode = wp_remote_retrieve_response_code($response);
121
-            $responseData = (array) json_decode($responseBody, true);
122
-            $this->response = array_shift($responseData);
123
-            $this->message = Arr::get($this->response, 'msg');
124
-            $this->success = 'success' === Arr::get($this->response, 'result') || 'yes' === Arr::get($this->response, 'success'); // @todo remove this ugly hack!
125
-            if (200 !== $responseCode) {
126
-                glsr_log()->error('Bad response code ['.$responseCode.']');
127
-            }
128
-            if (!$this->success) {
129
-                glsr_log()->error($this->message);
130
-            }
131
-        }
132
-    }
110
+	/**
111
+	 * @param \WP_Error|array $response
112
+	 * @return void
113
+	 */
114
+	protected function handleResponse($response)
115
+	{
116
+		if (is_wp_error($response)) {
117
+			$this->message = $response->get_error_message();
118
+		} else {
119
+			$responseBody = wp_remote_retrieve_body($response);
120
+			$responseCode = wp_remote_retrieve_response_code($response);
121
+			$responseData = (array) json_decode($responseBody, true);
122
+			$this->response = array_shift($responseData);
123
+			$this->message = Arr::get($this->response, 'msg');
124
+			$this->success = 'success' === Arr::get($this->response, 'result') || 'yes' === Arr::get($this->response, 'success'); // @todo remove this ugly hack!
125
+			if (200 !== $responseCode) {
126
+				glsr_log()->error('Bad response code ['.$responseCode.']');
127
+			}
128
+			if (!$this->success) {
129
+				glsr_log()->error($this->message);
130
+			}
131
+		}
132
+	}
133 133
 
134
-    /**
135
-     * @param string $endpoint
136
-     * @return void
137
-     */
138
-    protected function send($endpoint, array $args = [])
139
-    {
140
-        $args = wp_parse_args($args, [
141
-            'body' => null,
142
-            'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
143
-            'redirection' => 5,
144
-            'sslverify' => false,
145
-            'timeout' => 5,
146
-        ]);
147
-        $this->reset();
148
-        $this->handleResponse(
149
-            wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args)
150
-        );
151
-    }
134
+	/**
135
+	 * @param string $endpoint
136
+	 * @return void
137
+	 */
138
+	protected function send($endpoint, array $args = [])
139
+	{
140
+		$args = wp_parse_args($args, [
141
+			'body' => null,
142
+			'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
143
+			'redirection' => 5,
144
+			'sslverify' => false,
145
+			'timeout' => 5,
146
+		]);
147
+		$this->reset();
148
+		$this->handleResponse(
149
+			wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args)
150
+		);
151
+	}
152 152
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -20,25 +20,25 @@  discard block
 block discarded – undo
20 20
     /**
21 21
      * @return mixed
22 22
      */
23
-    public function __get($key)
23
+    public function __get( $key )
24 24
     {
25
-        return property_exists($this, $key)
25
+        return property_exists( $this, $key )
26 26
             ? $this->$key
27
-            : Arr::get($this->response, $key, null);
27
+            : Arr::get( $this->response, $key, null );
28 28
     }
29 29
 
30 30
     /**
31 31
      * @return self
32 32
      */
33
-    public function activateKey($apiKey = '', $email = '')
33
+    public function activateKey( $apiKey = '', $email = '' )
34 34
     {
35
-        $this->send('api_key_activation.php', [
35
+        $this->send( 'api_key_activation.php', [
36 36
             'body' => [
37 37
                 'apikey' => $apiKey ?: 0,
38 38
                 'domain' => get_home_url(),
39 39
                 'email' => $email ?: 0,
40 40
             ],
41
-        ]);
41
+        ] );
42 42
         return $this;
43 43
     }
44 44
 
@@ -56,77 +56,77 @@  discard block
 block discarded – undo
56 56
     /**
57 57
      * @return self
58 58
      */
59
-    public function sendReview(Review $review)
59
+    public function sendReview( Review $review )
60 60
     {
61
-        $this->send('index.php', [
62
-            'body' => $this->getBodyForReview($review),
61
+        $this->send( 'index.php', [
62
+            'body' => $this->getBodyForReview( $review ),
63 63
             'timeout' => 120,
64
-        ]);
64
+        ] );
65 65
         return $this;
66 66
     }
67 67
 
68 68
     /**
69 69
      * @return self
70 70
      */
71
-    public function sendReviewResponse(Review $review)
71
+    public function sendReviewResponse( Review $review )
72 72
     {
73
-        $this->send('fetch_customer_reply.php', [
74
-            'body' => $this->getBodyForResponse($review),
75
-        ]);
73
+        $this->send( 'fetch_customer_reply.php', [
74
+            'body' => $this->getBodyForResponse( $review ),
75
+        ] );
76 76
         return $this;
77 77
     }
78 78
 
79 79
     /**
80 80
      * @return array
81 81
      */
82
-    protected function getBodyForResponse(Review $review)
82
+    protected function getBodyForResponse( Review $review )
83 83
     {
84 84
         $rebusifyResponse = [
85
-            'reply' => Str::truncate($review->response, 300),
86
-            'review_id' => glsr(Database::class)->get($review->ID, 'rebusify'), // this is the rebusify review ID
85
+            'reply' => Str::truncate( $review->response, 300 ),
86
+            'review_id' => glsr( Database::class )->get( $review->ID, 'rebusify' ), // this is the rebusify review ID
87 87
             'review_transaction_id' => $review->review_id,
88 88
             'type' => 'M',
89 89
         ];
90
-        return apply_filters('site-reviews/rebusify/response', $rebusifyResponse, $review);
90
+        return apply_filters( 'site-reviews/rebusify/response', $rebusifyResponse, $review );
91 91
     }
92 92
 
93 93
     /**
94 94
      * @return array
95 95
      */
96
-    protected function getBodyForReview(Review $review)
96
+    protected function getBodyForReview( Review $review )
97 97
     {
98 98
         $rebusifyReview = [
99 99
             'domain' => get_home_url(),
100
-            'firstname' => Str::truncate(Str::convertName($review->author, 'first'), 25),
100
+            'firstname' => Str::truncate( Str::convertName( $review->author, 'first' ), 25 ),
101 101
             'rate' => $review->rating,
102 102
             'review_transaction_id' => $review->review_id,
103
-            'reviews' => Str::truncate($review->content, 280),
104
-            'title' => Str::truncate($review->title, 35),
103
+            'reviews' => Str::truncate( $review->content, 280 ),
104
+            'title' => Str::truncate( $review->title, 35 ),
105 105
             'transaction' => Application::ID, // woocommerce field, not needed for Site Reviews
106 106
         ];
107
-        return apply_filters('site-reviews/rebusify/review', $rebusifyReview, $review);
107
+        return apply_filters( 'site-reviews/rebusify/review', $rebusifyReview, $review );
108 108
     }
109 109
 
110 110
     /**
111 111
      * @param \WP_Error|array $response
112 112
      * @return void
113 113
      */
114
-    protected function handleResponse($response)
114
+    protected function handleResponse( $response )
115 115
     {
116
-        if (is_wp_error($response)) {
116
+        if( is_wp_error( $response ) ) {
117 117
             $this->message = $response->get_error_message();
118 118
         } else {
119
-            $responseBody = wp_remote_retrieve_body($response);
120
-            $responseCode = wp_remote_retrieve_response_code($response);
121
-            $responseData = (array) json_decode($responseBody, true);
122
-            $this->response = array_shift($responseData);
123
-            $this->message = Arr::get($this->response, 'msg');
124
-            $this->success = 'success' === Arr::get($this->response, 'result') || 'yes' === Arr::get($this->response, 'success'); // @todo remove this ugly hack!
125
-            if (200 !== $responseCode) {
126
-                glsr_log()->error('Bad response code ['.$responseCode.']');
119
+            $responseBody = wp_remote_retrieve_body( $response );
120
+            $responseCode = wp_remote_retrieve_response_code( $response );
121
+            $responseData = (array)json_decode( $responseBody, true );
122
+            $this->response = array_shift( $responseData );
123
+            $this->message = Arr::get( $this->response, 'msg' );
124
+            $this->success = 'success' === Arr::get( $this->response, 'result' ) || 'yes' === Arr::get( $this->response, 'success' ); // @todo remove this ugly hack!
125
+            if( 200 !== $responseCode ) {
126
+                glsr_log()->error( 'Bad response code ['.$responseCode.']' );
127 127
             }
128
-            if (!$this->success) {
129
-                glsr_log()->error($this->message);
128
+            if( !$this->success ) {
129
+                glsr_log()->error( $this->message );
130 130
             }
131 131
         }
132 132
     }
@@ -135,18 +135,18 @@  discard block
 block discarded – undo
135 135
      * @param string $endpoint
136 136
      * @return void
137 137
      */
138
-    protected function send($endpoint, array $args = [])
138
+    protected function send( $endpoint, array $args = [] )
139 139
     {
140
-        $args = wp_parse_args($args, [
140
+        $args = wp_parse_args( $args, [
141 141
             'body' => null,
142 142
             'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
143 143
             'redirection' => 5,
144 144
             'sslverify' => false,
145 145
             'timeout' => 5,
146
-        ]);
146
+        ] );
147 147
         $this->reset();
148 148
         $this->handleResponse(
149
-            wp_remote_post(trailingslashit(static::API_URL).$endpoint, $args)
149
+            wp_remote_post( trailingslashit( static::API_URL ).$endpoint, $args )
150 150
         );
151 151
     }
152 152
 }
Please login to merge, or discard this patch.
views/partials/notices/rebusify.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <div class="notice is-dismissible glsr-notice" data-dismiss="rebusify">
2 2
     <div class="glsr-notice-icon">
3
-        <img width="96" height="96" src="<?= glsr()->url('assets/images/rebusify-badge.png'); ?>">
3
+        <img width="96" height="96" src="<?= glsr()->url( 'assets/images/rebusify-badge.png' ); ?>">
4 4
     </div>
5 5
     <div class="glsr-notice-content">
6 6
         <h3>Validate Your Reviews on the Blockchain With the Rebusify Confidence System</h3>
7
-        <p>Site Reviews now integrates with the Rebusify Confidence System which uses blockchain technology to verify to your visitors and customers that your reviews are authentic. Simply create a free Rebusify account and <a href="<?= admin_url('edit.php?post_type=site-review&page=settings#!general'); ?>">enter your credentials in the Settings</a>. Site Reviews will take care of the rest!</p>
7
+        <p>Site Reviews now integrates with the Rebusify Confidence System which uses blockchain technology to verify to your visitors and customers that your reviews are authentic. Simply create a free Rebusify account and <a href="<?= admin_url( 'edit.php?post_type=site-review&page=settings#!general' ); ?>">enter your credentials in the Settings</a>. Site Reviews will take care of the rest!</p>
8 8
         <a href="https://rebusify.com/plans?ref=105" class="button" target="_blank">Create Your Rebusify Account</a>
9 9
     </div>
10 10
 </div>
Please login to merge, or discard this patch.
views/pages/welcome/upgrade-guide.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php defined('WPINC') || die; ?>
1
+<?php defined( 'WPINC' ) || die; ?>
2 2
 
3 3
 <p class="about-description">If you are using any Site Reviews code snippets or have built any custom integrations with Site Reviews, please make sure to read this upgrade guide.</p>
4 4
 <div class="is-fullwidth">
Please login to merge, or discard this patch.
views/partials/notices/addons.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,3 +1,3 @@
 block discarded – undo
1 1
 <div class="notice notice-warning is-dismissible">
2
-    <p><?= __('Expect to see these add-ons released in the coming months! Thank you again for your continued patience.', 'site-reviews'); ?></p>
2
+    <p><?= __( 'Expect to see these add-ons released in the coming months! Thank you again for your continued patience.', 'site-reviews' ); ?></p>
3 3
 </div>
Please login to merge, or discard this patch.
plugin/Reviews.php 2 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -9,65 +9,65 @@
 block discarded – undo
9 9
 
10 10
 class Reviews extends ArrayObject
11 11
 {
12
-    /**
13
-     * @var array
14
-     */
15
-    public $args;
12
+	/**
13
+	 * @var array
14
+	 */
15
+	public $args;
16 16
 
17
-    /**
18
-     * @var int
19
-     */
20
-    public $max_num_pages;
17
+	/**
18
+	 * @var int
19
+	 */
20
+	public $max_num_pages;
21 21
 
22
-    /**
23
-     * @var array
24
-     */
25
-    public $reviews;
22
+	/**
23
+	 * @var array
24
+	 */
25
+	public $reviews;
26 26
 
27
-    public function __construct(array $reviews, $maxPageCount, array $args)
28
-    {
29
-        $this->args = $args;
30
-        $this->max_num_pages = $maxPageCount;
31
-        $this->reviews = $reviews;
32
-        parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
33
-    }
27
+	public function __construct(array $reviews, $maxPageCount, array $args)
28
+	{
29
+		$this->args = $args;
30
+		$this->max_num_pages = $maxPageCount;
31
+		$this->reviews = $reviews;
32
+		parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
33
+	}
34 34
 
35
-    /**
36
-     * @return string
37
-     */
38
-    public function __toString()
39
-    {
40
-        return (string) $this->build();
41
-    }
35
+	/**
36
+	 * @return string
37
+	 */
38
+	public function __toString()
39
+	{
40
+		return (string) $this->build();
41
+	}
42 42
 
43
-    /**
44
-     * @return ReviewsHtml
45
-     */
46
-    public function build()
47
-    {
48
-        $args = glsr(SiteReviewsDefaults::class)->merge($this->args);
49
-        return glsr(SiteReviewsPartial::class)->build($args, $this);
50
-    }
43
+	/**
44
+	 * @return ReviewsHtml
45
+	 */
46
+	public function build()
47
+	{
48
+		$args = glsr(SiteReviewsDefaults::class)->merge($this->args);
49
+		return glsr(SiteReviewsPartial::class)->build($args, $this);
50
+	}
51 51
 
52
-    /**
53
-     * @param mixed $key
54
-     * @return mixed
55
-     */
56
-    public function offsetGet($key)
57
-    {
58
-        if (property_exists($this, $key)) {
59
-            return $this->$key;
60
-        }
61
-        return array_key_exists($key, $this->reviews)
62
-            ? $this->reviews[$key]
63
-            : null;
64
-    }
52
+	/**
53
+	 * @param mixed $key
54
+	 * @return mixed
55
+	 */
56
+	public function offsetGet($key)
57
+	{
58
+		if (property_exists($this, $key)) {
59
+			return $this->$key;
60
+		}
61
+		return array_key_exists($key, $this->reviews)
62
+			? $this->reviews[$key]
63
+			: null;
64
+	}
65 65
 
66
-    /**
67
-     * @return void
68
-     */
69
-    public function render()
70
-    {
71
-        echo $this->build();
72
-    }
66
+	/**
67
+	 * @return void
68
+	 */
69
+	public function render()
70
+	{
71
+		echo $this->build();
72
+	}
73 73
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,12 +24,12 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public $reviews;
26 26
 
27
-    public function __construct(array $reviews, $maxPageCount, array $args)
27
+    public function __construct( array $reviews, $maxPageCount, array $args )
28 28
     {
29 29
         $this->args = $args;
30 30
         $this->max_num_pages = $maxPageCount;
31 31
         $this->reviews = $reviews;
32
-        parent::__construct($reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS);
32
+        parent::__construct( $reviews, ArrayObject::STD_PROP_LIST | ArrayObject::ARRAY_AS_PROPS );
33 33
     }
34 34
 
35 35
     /**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function __toString()
39 39
     {
40
-        return (string) $this->build();
40
+        return (string)$this->build();
41 41
     }
42 42
 
43 43
     /**
@@ -45,20 +45,20 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function build()
47 47
     {
48
-        $args = glsr(SiteReviewsDefaults::class)->merge($this->args);
49
-        return glsr(SiteReviewsPartial::class)->build($args, $this);
48
+        $args = glsr( SiteReviewsDefaults::class )->merge( $this->args );
49
+        return glsr( SiteReviewsPartial::class )->build( $args, $this );
50 50
     }
51 51
 
52 52
     /**
53 53
      * @param mixed $key
54 54
      * @return mixed
55 55
      */
56
-    public function offsetGet($key)
56
+    public function offsetGet( $key )
57 57
     {
58
-        if (property_exists($this, $key)) {
58
+        if( property_exists( $this, $key ) ) {
59 59
             return $this->$key;
60 60
         }
61
-        return array_key_exists($key, $this->reviews)
61
+        return array_key_exists( $key, $this->reviews )
62 62
             ? $this->reviews[$key]
63 63
             : null;
64 64
     }
Please login to merge, or discard this patch.
plugin/Controllers/ReviewController.php 3 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,8 @@
 block discarded – undo
55 55
         $review = glsr_get_review($post);
56 56
         if ('publish' == $post->post_status) {
57 57
             glsr(CountsManager::class)->increase($review);
58
-        } else {
58
+        }
59
+        else {
59 60
             glsr(CountsManager::class)->decrease($review);
60 61
         }
61 62
     }
Please login to merge, or discard this patch.
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -13,139 +13,139 @@
 block discarded – undo
13 13
 
14 14
 class ReviewController extends Controller
15 15
 {
16
-    /**
17
-     * @param int $postId
18
-     * @param array $terms
19
-     * @param array $newTTIds
20
-     * @param string $taxonomy
21
-     * @param bool $append
22
-     * @param array $oldTTIds
23
-     * @return void
24
-     * @action set_object_terms
25
-     */
26
-    public function onAfterChangeCategory($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds)
27
-    {
28
-        sort($newTTIds);
29
-        sort($oldTTIds);
30
-        if ($newTTIds === $oldTTIds || !$this->isReviewPostId($postId)) {
31
-            return;
32
-        }
33
-        $review = glsr_get_review($postId);
34
-        $ignoredIds = array_intersect($oldTTIds, $newTTIds);
35
-        $decreasedIds = array_diff($oldTTIds, $ignoredIds);
36
-        $increasedIds = array_diff($newTTIds, $ignoredIds);
37
-        if ($review->term_ids = glsr(Database::class)->getTermIds($decreasedIds, 'term_taxonomy_id')) {
38
-            glsr(CountsManager::class)->decreaseTermCounts($review);
39
-        }
40
-        if ($review->term_ids = glsr(Database::class)->getTermIds($increasedIds, 'term_taxonomy_id')) {
41
-            glsr(CountsManager::class)->increaseTermCounts($review);
42
-        }
43
-    }
16
+	/**
17
+	 * @param int $postId
18
+	 * @param array $terms
19
+	 * @param array $newTTIds
20
+	 * @param string $taxonomy
21
+	 * @param bool $append
22
+	 * @param array $oldTTIds
23
+	 * @return void
24
+	 * @action set_object_terms
25
+	 */
26
+	public function onAfterChangeCategory($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds)
27
+	{
28
+		sort($newTTIds);
29
+		sort($oldTTIds);
30
+		if ($newTTIds === $oldTTIds || !$this->isReviewPostId($postId)) {
31
+			return;
32
+		}
33
+		$review = glsr_get_review($postId);
34
+		$ignoredIds = array_intersect($oldTTIds, $newTTIds);
35
+		$decreasedIds = array_diff($oldTTIds, $ignoredIds);
36
+		$increasedIds = array_diff($newTTIds, $ignoredIds);
37
+		if ($review->term_ids = glsr(Database::class)->getTermIds($decreasedIds, 'term_taxonomy_id')) {
38
+			glsr(CountsManager::class)->decreaseTermCounts($review);
39
+		}
40
+		if ($review->term_ids = glsr(Database::class)->getTermIds($increasedIds, 'term_taxonomy_id')) {
41
+			glsr(CountsManager::class)->increaseTermCounts($review);
42
+		}
43
+	}
44 44
 
45
-    /**
46
-     * @param string $oldStatus
47
-     * @param string $newStatus
48
-     * @param WP_Post $post
49
-     * @return void
50
-     * @action transition_post_status
51
-     */
52
-    public function onAfterChangeStatus($newStatus, $oldStatus, $post)
53
-    {
54
-        if (Application::POST_TYPE != Arr::get($post, 'post_type') || in_array($oldStatus, ['new', $newStatus])) {
55
-            return;
56
-        }
57
-        $review = glsr_get_review($post);
58
-        if ('publish' == $post->post_status) {
59
-            glsr(CountsManager::class)->increase($review);
60
-        } else {
61
-            glsr(CountsManager::class)->decrease($review);
62
-        }
63
-    }
45
+	/**
46
+	 * @param string $oldStatus
47
+	 * @param string $newStatus
48
+	 * @param WP_Post $post
49
+	 * @return void
50
+	 * @action transition_post_status
51
+	 */
52
+	public function onAfterChangeStatus($newStatus, $oldStatus, $post)
53
+	{
54
+		if (Application::POST_TYPE != Arr::get($post, 'post_type') || in_array($oldStatus, ['new', $newStatus])) {
55
+			return;
56
+		}
57
+		$review = glsr_get_review($post);
58
+		if ('publish' == $post->post_status) {
59
+			glsr(CountsManager::class)->increase($review);
60
+		} else {
61
+			glsr(CountsManager::class)->decrease($review);
62
+		}
63
+	}
64 64
 
65
-    /**
66
-     * @return void
67
-     * @action site-reviews/review/created
68
-     */
69
-    public function onAfterCreate(Review $review)
70
-    {
71
-        if ('publish' !== $review->status) {
72
-            return;
73
-        }
74
-        glsr(CountsManager::class)->increaseCounts($review);
75
-        glsr(CountsManager::class)->increasePostCounts($review);
76
-    }
65
+	/**
66
+	 * @return void
67
+	 * @action site-reviews/review/created
68
+	 */
69
+	public function onAfterCreate(Review $review)
70
+	{
71
+		if ('publish' !== $review->status) {
72
+			return;
73
+		}
74
+		glsr(CountsManager::class)->increaseCounts($review);
75
+		glsr(CountsManager::class)->increasePostCounts($review);
76
+	}
77 77
 
78
-    /**
79
-     * @param int $postId
80
-     * @return void
81
-     * @action before_delete_post
82
-     */
83
-    public function onBeforeDelete($postId)
84
-    {
85
-        if (!$this->isReviewPostId($postId)) {
86
-            return;
87
-        }
88
-        $review = glsr_get_review($postId);
89
-        if ('trash' !== $review->status) { // do not run for trashed posts
90
-            glsr(CountsManager::class)->decrease($review);
91
-        }
92
-    }
78
+	/**
79
+	 * @param int $postId
80
+	 * @return void
81
+	 * @action before_delete_post
82
+	 */
83
+	public function onBeforeDelete($postId)
84
+	{
85
+		if (!$this->isReviewPostId($postId)) {
86
+			return;
87
+		}
88
+		$review = glsr_get_review($postId);
89
+		if ('trash' !== $review->status) { // do not run for trashed posts
90
+			glsr(CountsManager::class)->decrease($review);
91
+		}
92
+	}
93 93
 
94
-    /**
95
-     * @param int $metaId
96
-     * @param int $postId
97
-     * @param string $metaKey
98
-     * @param mixed $metaValue
99
-     * @return void
100
-     * @action update_postmeta
101
-     */
102
-    public function onBeforeUpdate($metaId, $postId, $metaKey, $metaValue)
103
-    {
104
-        if (!$this->isReviewPostId($postId)) {
105
-            return;
106
-        }
107
-        $metaKey = Str::removePrefix('_', $metaKey);
108
-        if (!in_array($metaKey, ['assigned_to', 'rating', 'review_type'])) {
109
-            return;
110
-        }
111
-        $review = glsr_get_review($postId);
112
-        if ($review->$metaKey == $metaValue) {
113
-            return;
114
-        }
115
-        $method = Helper::buildMethodName($metaKey, 'onBeforeChange');
116
-        call_user_func([$this, $method], $review, $metaValue);
117
-    }
94
+	/**
95
+	 * @param int $metaId
96
+	 * @param int $postId
97
+	 * @param string $metaKey
98
+	 * @param mixed $metaValue
99
+	 * @return void
100
+	 * @action update_postmeta
101
+	 */
102
+	public function onBeforeUpdate($metaId, $postId, $metaKey, $metaValue)
103
+	{
104
+		if (!$this->isReviewPostId($postId)) {
105
+			return;
106
+		}
107
+		$metaKey = Str::removePrefix('_', $metaKey);
108
+		if (!in_array($metaKey, ['assigned_to', 'rating', 'review_type'])) {
109
+			return;
110
+		}
111
+		$review = glsr_get_review($postId);
112
+		if ($review->$metaKey == $metaValue) {
113
+			return;
114
+		}
115
+		$method = Helper::buildMethodName($metaKey, 'onBeforeChange');
116
+		call_user_func([$this, $method], $review, $metaValue);
117
+	}
118 118
 
119
-    /**
120
-     * @param string|int $assignedTo
121
-     * @return void
122
-     */
123
-    public function onBeforeChangeAssignedTo(Review $review, $assignedTo)
124
-    {
125
-        glsr(CountsManager::class)->decreasePostCounts($review);
126
-        $review->assigned_to = $assignedTo;
127
-        glsr(CountsManager::class)->increasePostCounts($review);
128
-    }
119
+	/**
120
+	 * @param string|int $assignedTo
121
+	 * @return void
122
+	 */
123
+	public function onBeforeChangeAssignedTo(Review $review, $assignedTo)
124
+	{
125
+		glsr(CountsManager::class)->decreasePostCounts($review);
126
+		$review->assigned_to = $assignedTo;
127
+		glsr(CountsManager::class)->increasePostCounts($review);
128
+	}
129 129
 
130
-    /**
131
-     * @param string|int $rating
132
-     * @return void
133
-     */
134
-    public function onBeforeChangeRating(Review $review, $rating)
135
-    {
136
-        glsr(CountsManager::class)->decrease($review);
137
-        $review->rating = $rating;
138
-        glsr(CountsManager::class)->increase($review);
139
-    }
130
+	/**
131
+	 * @param string|int $rating
132
+	 * @return void
133
+	 */
134
+	public function onBeforeChangeRating(Review $review, $rating)
135
+	{
136
+		glsr(CountsManager::class)->decrease($review);
137
+		$review->rating = $rating;
138
+		glsr(CountsManager::class)->increase($review);
139
+	}
140 140
 
141
-    /**
142
-     * @param string $reviewType
143
-     * @return void
144
-     */
145
-    public function onBeforeChangeReviewType(Review $review, $reviewType)
146
-    {
147
-        glsr(CountsManager::class)->decrease($review);
148
-        $review->review_type = $reviewType;
149
-        glsr(CountsManager::class)->increase($review);
150
-    }
141
+	/**
142
+	 * @param string $reviewType
143
+	 * @return void
144
+	 */
145
+	public function onBeforeChangeReviewType(Review $review, $reviewType)
146
+	{
147
+		glsr(CountsManager::class)->decrease($review);
148
+		$review->review_type = $reviewType;
149
+		glsr(CountsManager::class)->increase($review);
150
+	}
151 151
 }
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -23,22 +23,22 @@  discard block
 block discarded – undo
23 23
      * @return void
24 24
      * @action set_object_terms
25 25
      */
26
-    public function onAfterChangeCategory($postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds)
26
+    public function onAfterChangeCategory( $postId, $terms, $newTTIds, $taxonomy, $append, $oldTTIds )
27 27
     {
28
-        sort($newTTIds);
29
-        sort($oldTTIds);
30
-        if ($newTTIds === $oldTTIds || !$this->isReviewPostId($postId)) {
28
+        sort( $newTTIds );
29
+        sort( $oldTTIds );
30
+        if( $newTTIds === $oldTTIds || !$this->isReviewPostId( $postId ) ) {
31 31
             return;
32 32
         }
33
-        $review = glsr_get_review($postId);
34
-        $ignoredIds = array_intersect($oldTTIds, $newTTIds);
35
-        $decreasedIds = array_diff($oldTTIds, $ignoredIds);
36
-        $increasedIds = array_diff($newTTIds, $ignoredIds);
37
-        if ($review->term_ids = glsr(Database::class)->getTermIds($decreasedIds, 'term_taxonomy_id')) {
38
-            glsr(CountsManager::class)->decreaseTermCounts($review);
33
+        $review = glsr_get_review( $postId );
34
+        $ignoredIds = array_intersect( $oldTTIds, $newTTIds );
35
+        $decreasedIds = array_diff( $oldTTIds, $ignoredIds );
36
+        $increasedIds = array_diff( $newTTIds, $ignoredIds );
37
+        if( $review->term_ids = glsr( Database::class )->getTermIds( $decreasedIds, 'term_taxonomy_id' ) ) {
38
+            glsr( CountsManager::class )->decreaseTermCounts( $review );
39 39
         }
40
-        if ($review->term_ids = glsr(Database::class)->getTermIds($increasedIds, 'term_taxonomy_id')) {
41
-            glsr(CountsManager::class)->increaseTermCounts($review);
40
+        if( $review->term_ids = glsr( Database::class )->getTermIds( $increasedIds, 'term_taxonomy_id' ) ) {
41
+            glsr( CountsManager::class )->increaseTermCounts( $review );
42 42
         }
43 43
     }
44 44
 
@@ -49,16 +49,16 @@  discard block
 block discarded – undo
49 49
      * @return void
50 50
      * @action transition_post_status
51 51
      */
52
-    public function onAfterChangeStatus($newStatus, $oldStatus, $post)
52
+    public function onAfterChangeStatus( $newStatus, $oldStatus, $post )
53 53
     {
54
-        if (Application::POST_TYPE != Arr::get($post, 'post_type') || in_array($oldStatus, ['new', $newStatus])) {
54
+        if( Application::POST_TYPE != Arr::get( $post, 'post_type' ) || in_array( $oldStatus, ['new', $newStatus] ) ) {
55 55
             return;
56 56
         }
57
-        $review = glsr_get_review($post);
58
-        if ('publish' == $post->post_status) {
59
-            glsr(CountsManager::class)->increase($review);
57
+        $review = glsr_get_review( $post );
58
+        if( 'publish' == $post->post_status ) {
59
+            glsr( CountsManager::class )->increase( $review );
60 60
         } else {
61
-            glsr(CountsManager::class)->decrease($review);
61
+            glsr( CountsManager::class )->decrease( $review );
62 62
         }
63 63
     }
64 64
 
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
      * @return void
67 67
      * @action site-reviews/review/created
68 68
      */
69
-    public function onAfterCreate(Review $review)
69
+    public function onAfterCreate( Review $review )
70 70
     {
71
-        if ('publish' !== $review->status) {
71
+        if( 'publish' !== $review->status ) {
72 72
             return;
73 73
         }
74
-        glsr(CountsManager::class)->increaseCounts($review);
75
-        glsr(CountsManager::class)->increasePostCounts($review);
74
+        glsr( CountsManager::class )->increaseCounts( $review );
75
+        glsr( CountsManager::class )->increasePostCounts( $review );
76 76
     }
77 77
 
78 78
     /**
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
      * @return void
81 81
      * @action before_delete_post
82 82
      */
83
-    public function onBeforeDelete($postId)
83
+    public function onBeforeDelete( $postId )
84 84
     {
85
-        if (!$this->isReviewPostId($postId)) {
85
+        if( !$this->isReviewPostId( $postId ) ) {
86 86
             return;
87 87
         }
88
-        $review = glsr_get_review($postId);
89
-        if ('trash' !== $review->status) { // do not run for trashed posts
90
-            glsr(CountsManager::class)->decrease($review);
88
+        $review = glsr_get_review( $postId );
89
+        if( 'trash' !== $review->status ) { // do not run for trashed posts
90
+            glsr( CountsManager::class )->decrease( $review );
91 91
         }
92 92
     }
93 93
 
@@ -99,53 +99,53 @@  discard block
 block discarded – undo
99 99
      * @return void
100 100
      * @action update_postmeta
101 101
      */
102
-    public function onBeforeUpdate($metaId, $postId, $metaKey, $metaValue)
102
+    public function onBeforeUpdate( $metaId, $postId, $metaKey, $metaValue )
103 103
     {
104
-        if (!$this->isReviewPostId($postId)) {
104
+        if( !$this->isReviewPostId( $postId ) ) {
105 105
             return;
106 106
         }
107
-        $metaKey = Str::removePrefix('_', $metaKey);
108
-        if (!in_array($metaKey, ['assigned_to', 'rating', 'review_type'])) {
107
+        $metaKey = Str::removePrefix( '_', $metaKey );
108
+        if( !in_array( $metaKey, ['assigned_to', 'rating', 'review_type'] ) ) {
109 109
             return;
110 110
         }
111
-        $review = glsr_get_review($postId);
112
-        if ($review->$metaKey == $metaValue) {
111
+        $review = glsr_get_review( $postId );
112
+        if( $review->$metaKey == $metaValue ) {
113 113
             return;
114 114
         }
115
-        $method = Helper::buildMethodName($metaKey, 'onBeforeChange');
116
-        call_user_func([$this, $method], $review, $metaValue);
115
+        $method = Helper::buildMethodName( $metaKey, 'onBeforeChange' );
116
+        call_user_func( [$this, $method], $review, $metaValue );
117 117
     }
118 118
 
119 119
     /**
120 120
      * @param string|int $assignedTo
121 121
      * @return void
122 122
      */
123
-    public function onBeforeChangeAssignedTo(Review $review, $assignedTo)
123
+    public function onBeforeChangeAssignedTo( Review $review, $assignedTo )
124 124
     {
125
-        glsr(CountsManager::class)->decreasePostCounts($review);
125
+        glsr( CountsManager::class )->decreasePostCounts( $review );
126 126
         $review->assigned_to = $assignedTo;
127
-        glsr(CountsManager::class)->increasePostCounts($review);
127
+        glsr( CountsManager::class )->increasePostCounts( $review );
128 128
     }
129 129
 
130 130
     /**
131 131
      * @param string|int $rating
132 132
      * @return void
133 133
      */
134
-    public function onBeforeChangeRating(Review $review, $rating)
134
+    public function onBeforeChangeRating( Review $review, $rating )
135 135
     {
136
-        glsr(CountsManager::class)->decrease($review);
136
+        glsr( CountsManager::class )->decrease( $review );
137 137
         $review->rating = $rating;
138
-        glsr(CountsManager::class)->increase($review);
138
+        glsr( CountsManager::class )->increase( $review );
139 139
     }
140 140
 
141 141
     /**
142 142
      * @param string $reviewType
143 143
      * @return void
144 144
      */
145
-    public function onBeforeChangeReviewType(Review $review, $reviewType)
145
+    public function onBeforeChangeReviewType( Review $review, $reviewType )
146 146
     {
147
-        glsr(CountsManager::class)->decrease($review);
147
+        glsr( CountsManager::class )->decrease( $review );
148 148
         $review->review_type = $reviewType;
149
-        glsr(CountsManager::class)->increase($review);
149
+        glsr( CountsManager::class )->increase( $review );
150 150
     }
151 151
 }
Please login to merge, or discard this patch.
plugin/Widgets/Widget.php 2 patches
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -7,54 +7,54 @@
 block discarded – undo
7 7
 
8 8
 abstract class Widget extends WP_Widget
9 9
 {
10
-    /**
11
-     * @var array
12
-     */
13
-    protected $widgetArgs;
10
+	/**
11
+	 * @var array
12
+	 */
13
+	protected $widgetArgs;
14 14
 
15
-    public function __construct($idBase, $name, $values)
16
-    {
17
-        $controlOptions = $widgetOptions = [];
18
-        if (isset($values['class'])) {
19
-            $widgetOptions['classname'] = $values['class'];
20
-        }
21
-        if (isset($values['description'])) {
22
-            $widgetOptions['description'] = $values['description'];
23
-        }
24
-        if (isset($values['width'])) {
25
-            $controlOptions['width'] = $values['width'];
26
-        }
27
-        parent::__construct($idBase, $name, $widgetOptions, $controlOptions);
28
-    }
15
+	public function __construct($idBase, $name, $values)
16
+	{
17
+		$controlOptions = $widgetOptions = [];
18
+		if (isset($values['class'])) {
19
+			$widgetOptions['classname'] = $values['class'];
20
+		}
21
+		if (isset($values['description'])) {
22
+			$widgetOptions['description'] = $values['description'];
23
+		}
24
+		if (isset($values['width'])) {
25
+			$controlOptions['width'] = $values['width'];
26
+		}
27
+		parent::__construct($idBase, $name, $widgetOptions, $controlOptions);
28
+	}
29 29
 
30
-    /**
31
-     * @param string $tag
32
-     * @return void
33
-     */
34
-    protected function renderField($tag, array $args = [])
35
-    {
36
-        $args = $this->normalizeFieldAttributes($tag, $args);
37
-        $field = glsr(Builder::class)->$tag($args['name'], $args);
38
-        echo glsr(Builder::class)->div($field, [
39
-            'class' => 'glsr-field',
40
-        ]);
41
-    }
30
+	/**
31
+	 * @param string $tag
32
+	 * @return void
33
+	 */
34
+	protected function renderField($tag, array $args = [])
35
+	{
36
+		$args = $this->normalizeFieldAttributes($tag, $args);
37
+		$field = glsr(Builder::class)->$tag($args['name'], $args);
38
+		echo glsr(Builder::class)->div($field, [
39
+			'class' => 'glsr-field',
40
+		]);
41
+	}
42 42
 
43
-    /**
44
-     * @param string $tag
45
-     * @return array
46
-     */
47
-    protected function normalizeFieldAttributes($tag, array $args)
48
-    {
49
-        if (empty($args['value'])) {
50
-            $args['value'] = $this->widgetArgs[$args['name']];
51
-        }
52
-        if (empty($this->widgetArgs['options']) && in_array($tag, ['checkbox', 'radio'])) {
53
-            $args['checked'] = in_array($args['value'], (array) $this->widgetArgs[$args['name']]);
54
-        }
55
-        $args['id'] = $this->get_field_id($args['name']);
56
-        $args['name'] = $this->get_field_name($args['name']);
57
-        $args['is_widget'] = true;
58
-        return $args;
59
-    }
43
+	/**
44
+	 * @param string $tag
45
+	 * @return array
46
+	 */
47
+	protected function normalizeFieldAttributes($tag, array $args)
48
+	{
49
+		if (empty($args['value'])) {
50
+			$args['value'] = $this->widgetArgs[$args['name']];
51
+		}
52
+		if (empty($this->widgetArgs['options']) && in_array($tag, ['checkbox', 'radio'])) {
53
+			$args['checked'] = in_array($args['value'], (array) $this->widgetArgs[$args['name']]);
54
+		}
55
+		$args['id'] = $this->get_field_id($args['name']);
56
+		$args['name'] = $this->get_field_name($args['name']);
57
+		$args['is_widget'] = true;
58
+		return $args;
59
+	}
60 60
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -12,48 +12,48 @@
 block discarded – undo
12 12
      */
13 13
     protected $widgetArgs;
14 14
 
15
-    public function __construct($idBase, $name, $values)
15
+    public function __construct( $idBase, $name, $values )
16 16
     {
17 17
         $controlOptions = $widgetOptions = [];
18
-        if (isset($values['class'])) {
18
+        if( isset($values['class']) ) {
19 19
             $widgetOptions['classname'] = $values['class'];
20 20
         }
21
-        if (isset($values['description'])) {
21
+        if( isset($values['description']) ) {
22 22
             $widgetOptions['description'] = $values['description'];
23 23
         }
24
-        if (isset($values['width'])) {
24
+        if( isset($values['width']) ) {
25 25
             $controlOptions['width'] = $values['width'];
26 26
         }
27
-        parent::__construct($idBase, $name, $widgetOptions, $controlOptions);
27
+        parent::__construct( $idBase, $name, $widgetOptions, $controlOptions );
28 28
     }
29 29
 
30 30
     /**
31 31
      * @param string $tag
32 32
      * @return void
33 33
      */
34
-    protected function renderField($tag, array $args = [])
34
+    protected function renderField( $tag, array $args = [] )
35 35
     {
36
-        $args = $this->normalizeFieldAttributes($tag, $args);
37
-        $field = glsr(Builder::class)->$tag($args['name'], $args);
38
-        echo glsr(Builder::class)->div($field, [
36
+        $args = $this->normalizeFieldAttributes( $tag, $args );
37
+        $field = glsr( Builder::class )->$tag( $args['name'], $args );
38
+        echo glsr( Builder::class )->div( $field, [
39 39
             'class' => 'glsr-field',
40
-        ]);
40
+        ] );
41 41
     }
42 42
 
43 43
     /**
44 44
      * @param string $tag
45 45
      * @return array
46 46
      */
47
-    protected function normalizeFieldAttributes($tag, array $args)
47
+    protected function normalizeFieldAttributes( $tag, array $args )
48 48
     {
49
-        if (empty($args['value'])) {
49
+        if( empty($args['value']) ) {
50 50
             $args['value'] = $this->widgetArgs[$args['name']];
51 51
         }
52
-        if (empty($this->widgetArgs['options']) && in_array($tag, ['checkbox', 'radio'])) {
53
-            $args['checked'] = in_array($args['value'], (array) $this->widgetArgs[$args['name']]);
52
+        if( empty($this->widgetArgs['options']) && in_array( $tag, ['checkbox', 'radio'] ) ) {
53
+            $args['checked'] = in_array( $args['value'], (array)$this->widgetArgs[$args['name']] );
54 54
         }
55
-        $args['id'] = $this->get_field_id($args['name']);
56
-        $args['name'] = $this->get_field_name($args['name']);
55
+        $args['id'] = $this->get_field_id( $args['name'] );
56
+        $args['name'] = $this->get_field_name( $args['name'] );
57 57
         $args['is_widget'] = true;
58 58
         return $args;
59 59
     }
Please login to merge, or discard this patch.