Passed
Push — master ( ae1954...aab291 )
by Paul
08:17 queued 04:15
created
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.
plugin/HelperTraits/Str.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@  discard block
 block discarded – undo
8 8
      * @param string $string
9 9
      * @return string
10 10
      */
11
-    public function camelCase($string)
11
+    public function camelCase( $string )
12 12
     {
13
-        $string = ucwords(str_replace(['-', '_'], ' ', trim($string)));
14
-        return str_replace(' ', '', $string);
13
+        $string = ucwords( str_replace( ['-', '_'], ' ', trim( $string ) ) );
14
+        return str_replace( ' ', '', $string );
15 15
     }
16 16
 
17 17
     /**
@@ -20,27 +20,27 @@  discard block
 block discarded – undo
20 20
      * @param string $initialType period|period_space|space
21 21
      * @return string
22 22
      */
23
-    public function convertName($name, $nameType = '', $initialType = '')
23
+    public function convertName( $name, $nameType = '', $initialType = '' )
24 24
     {
25
-        $names = preg_split('/\W/', $name, 0, PREG_SPLIT_NO_EMPTY);
26
-        $firstName = array_shift($names);
27
-        $lastName = array_pop($names);
25
+        $names = preg_split( '/\W/', $name, 0, PREG_SPLIT_NO_EMPTY );
26
+        $firstName = array_shift( $names );
27
+        $lastName = array_pop( $names );
28 28
         $initialTypes = [
29 29
             'period' => '.',
30 30
             'period_space' => '. ',
31 31
             'space' => ' ',
32 32
         ];
33
-        $initialPunctuation = glsr_get($initialTypes, $initialType, ' ');
34
-        if ('initials' == $nameType) {
35
-            return $this->convertToInitials($name, $initialPunctuation);
33
+        $initialPunctuation = glsr_get( $initialTypes, $initialType, ' ' );
34
+        if( 'initials' == $nameType ) {
35
+            return $this->convertToInitials( $name, $initialPunctuation );
36 36
         }
37 37
         $nameTypes = [
38 38
             'first' => $firstName,
39
-            'first_initial' => substr($firstName, 0, 1).$initialPunctuation.$lastName,
39
+            'first_initial' => substr( $firstName, 0, 1 ).$initialPunctuation.$lastName,
40 40
             'last' => $lastName,
41
-            'last_initial' => $firstName.' '.substr($lastName, 0, 1).$initialPunctuation,
41
+            'last_initial' => $firstName.' '.substr( $lastName, 0, 1 ).$initialPunctuation,
42 42
         ];
43
-        return trim(glsr_get($nameTypes, $nameType, $name));
43
+        return trim( glsr_get( $nameTypes, $nameType, $name ) );
44 44
     }
45 45
 
46 46
     /**
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
      * @param string $prefix
49 49
      * @return string
50 50
      */
51
-    public function convertPathToId($path, $prefix = '')
51
+    public function convertPathToId( $path, $prefix = '' )
52 52
     {
53
-        return str_replace(['[', ']'], ['-', ''], $this->convertPathToName($path, $prefix));
53
+        return str_replace( ['[', ']'], ['-', ''], $this->convertPathToName( $path, $prefix ) );
54 54
     }
55 55
 
56 56
     /**
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
      * @param string $prefix
59 59
      * @return string
60 60
      */
61
-    public function convertPathToName($path, $prefix = '')
61
+    public function convertPathToName( $path, $prefix = '' )
62 62
     {
63
-        $levels = explode('.', $path);
64
-        return array_reduce($levels, function ($result, $value) {
63
+        $levels = explode( '.', $path );
64
+        return array_reduce( $levels, function( $result, $value ) {
65 65
             return $result .= '['.$value.']';
66
-        }, $prefix);
66
+        }, $prefix );
67 67
     }
68 68
 
69 69
     /**
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
      * @param string $initialPunctuation
72 72
      * @return string
73 73
      */
74
-    public function convertToInitials($name, $initialPunctuation = '')
74
+    public function convertToInitials( $name, $initialPunctuation = '' )
75 75
     {
76
-        preg_match_all('/(?<=\s|\b)\pL/u', $name, $matches);
77
-        return array_reduce($matches[0], function ($carry, $word) use ($initialPunctuation) {
78
-            return $carry.strtoupper(substr($word, 0, 1)).$initialPunctuation;
76
+        preg_match_all( '/(?<=\s|\b)\pL/u', $name, $matches );
77
+        return array_reduce( $matches[0], function( $carry, $word ) use ($initialPunctuation) {
78
+            return $carry.strtoupper( substr( $word, 0, 1 ) ).$initialPunctuation;
79 79
         });
80 80
     }
81 81
 
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
      * @param string $string
84 84
      * @return string
85 85
      */
86
-    public function dashCase($string)
86
+    public function dashCase( $string )
87 87
     {
88
-        return str_replace('_', '-', $this->snakeCase($string));
88
+        return str_replace( '_', '-', $this->snakeCase( $string ) );
89 89
     }
90 90
 
91 91
     /**
@@ -93,11 +93,11 @@  discard block
 block discarded – undo
93 93
      * @param string $haystack
94 94
      * @return bool
95 95
      */
96
-    public function endsWith($needle, $haystack)
96
+    public function endsWith( $needle, $haystack )
97 97
     {
98
-        $length = strlen($needle);
98
+        $length = strlen( $needle );
99 99
         return 0 != $length
100
-            ? substr($haystack, -$length) === $needle
100
+            ? substr( $haystack, -$length ) === $needle
101 101
             : true;
102 102
     }
103 103
 
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
      * @param string|null $trim
108 108
      * @return string
109 109
      */
110
-    public function prefix($prefix, $string, $trim = null)
110
+    public function prefix( $prefix, $string, $trim = null )
111 111
     {
112
-        if (null === $trim) {
112
+        if( null === $trim ) {
113 113
             $trim = $prefix;
114 114
         }
115
-        return $prefix.trim($this->removePrefix($trim, $string));
115
+        return $prefix.trim( $this->removePrefix( $trim, $string ) );
116 116
     }
117 117
 
118 118
     /**
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
      * @param string $string
121 121
      * @return string
122 122
      */
123
-    public function removePrefix($prefix, $string)
123
+    public function removePrefix( $prefix, $string )
124 124
     {
125
-        return $this->startsWith($prefix, $string)
126
-            ? substr($string, strlen($prefix))
125
+        return $this->startsWith( $prefix, $string )
126
+            ? substr( $string, strlen( $prefix ) )
127 127
             : $string;
128 128
     }
129 129
 
@@ -131,16 +131,16 @@  discard block
 block discarded – undo
131 131
      * @param string $string
132 132
      * @return string
133 133
      */
134
-    public function snakeCase($string)
134
+    public function snakeCase( $string )
135 135
     {
136
-        if (!ctype_lower($string)) {
137
-            $string = preg_replace('/\s+/u', '', $string);
138
-            $string = preg_replace('/(.)(?=[A-Z])/u', '$1_', $string);
139
-            $string = function_exists('mb_strtolower')
140
-                ? mb_strtolower($string, 'UTF-8')
141
-                : strtolower($string);
136
+        if( !ctype_lower( $string ) ) {
137
+            $string = preg_replace( '/\s+/u', '', $string );
138
+            $string = preg_replace( '/(.)(?=[A-Z])/u', '$1_', $string );
139
+            $string = function_exists( 'mb_strtolower' )
140
+                ? mb_strtolower( $string, 'UTF-8' )
141
+                : strtolower( $string );
142 142
         }
143
-        return str_replace('-', '_', $string);
143
+        return str_replace( '-', '_', $string );
144 144
     }
145 145
 
146 146
     /**
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
      * @param string $haystack
149 149
      * @return bool
150 150
      */
151
-    public function startsWith($needle, $haystack)
151
+    public function startsWith( $needle, $haystack )
152 152
     {
153
-        return substr($haystack, 0, strlen($needle)) === $needle;
153
+        return substr( $haystack, 0, strlen( $needle ) ) === $needle;
154 154
     }
155 155
 
156 156
     /**
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
      * @param int $length
159 159
      * @return string
160 160
      */
161
-    public function truncate($string, $length)
161
+    public function truncate( $string, $length )
162 162
     {
163
-        return strlen($string) > $length
164
-            ? substr($string, 0, $length)
163
+        return strlen( $string ) > $length
164
+            ? substr( $string, 0, $length )
165 165
             : $string;
166 166
     }
167 167
 }
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 1 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/Commands/CreateReview.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -27,37 +27,37 @@  discard block
 block discarded – undo
27 27
     public $title;
28 28
     public $url;
29 29
 
30
-    public function __construct($input)
30
+    public function __construct( $input )
31 31
     {
32 32
         $this->request = $input;
33 33
         $this->ajax_request = isset($input['_ajax_request']);
34
-        $this->assigned_to = $this->getNumeric('assign_to');
35
-        $this->author = sanitize_text_field($this->getUser('name'));
34
+        $this->assigned_to = $this->getNumeric( 'assign_to' );
35
+        $this->author = sanitize_text_field( $this->getUser( 'name' ) );
36 36
         $this->avatar = $this->getAvatar();
37 37
         $this->blacklisted = isset($input['blacklisted']);
38 38
         $this->category = $this->getCategory();
39
-        $this->content = sanitize_textarea_field($this->get('content'));
39
+        $this->content = sanitize_textarea_field( $this->get( 'content' ) );
40 40
         $this->custom = $this->getCustom();
41
-        $this->date = $this->getDate('date');
42
-        $this->email = sanitize_email($this->getUser('email'));
43
-        $this->form_id = sanitize_key($this->get('form_id'));
44
-        $this->ip_address = $this->get('ip_address');
45
-        $this->post_id = intval($this->get('_post_id'));
46
-        $this->rating = intval($this->get('rating'));
47
-        $this->referer = $this->get('_referer');
48
-        $this->response = sanitize_textarea_field($this->get('response'));
41
+        $this->date = $this->getDate( 'date' );
42
+        $this->email = sanitize_email( $this->getUser( 'email' ) );
43
+        $this->form_id = sanitize_key( $this->get( 'form_id' ) );
44
+        $this->ip_address = $this->get( 'ip_address' );
45
+        $this->post_id = intval( $this->get( '_post_id' ) );
46
+        $this->rating = intval( $this->get( 'rating' ) );
47
+        $this->referer = $this->get( '_referer' );
48
+        $this->response = sanitize_textarea_field( $this->get( 'response' ) );
49 49
         $this->terms = !empty($input['terms']);
50
-        $this->title = sanitize_text_field($this->get('title'));
51
-        $this->url = esc_url_raw($this->get('url'));
50
+        $this->title = sanitize_text_field( $this->get( 'title' ) );
51
+        $this->url = esc_url_raw( $this->get( 'url' ) );
52 52
     }
53 53
 
54 54
     /**
55 55
      * @param string $key
56 56
      * @return string
57 57
      */
58
-    protected function get($key)
58
+    protected function get( $key )
59 59
     {
60
-        return (string) glsr_get($this->request, $key);
60
+        return (string)glsr_get( $this->request, $key );
61 61
     }
62 62
 
63 63
     /**
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
      */
66 66
     protected function getAvatar()
67 67
     {
68
-        $avatar = $this->get('avatar');
69
-        return !filter_var($avatar, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)
70
-            ? (string) get_avatar_url($this->get('email'))
68
+        $avatar = $this->get( 'avatar' );
69
+        return !filter_var( $avatar, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED )
70
+            ? (string)get_avatar_url( $this->get( 'email' ) )
71 71
             : $avatar;
72 72
     }
73 73
 
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
      */
77 77
     protected function getCategory()
78 78
     {
79
-        $categories = glsr(Helper::class)->convertStringToArray($this->get('category'));
80
-        return sanitize_key(glsr_get($categories, 0));
79
+        $categories = glsr( Helper::class )->convertStringToArray( $this->get( 'category' ) );
80
+        return sanitize_key( glsr_get( $categories, 0 ) );
81 81
     }
82 82
 
83 83
     /**
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
             '_referer', 'assign_to', 'category', 'content', 'date', 'email', 'excluded', 'form_id',
91 91
             'gotcha', 'ip_address', 'name', 'rating', 'response', 'terms', 'title', 'url',
92 92
         ];
93
-        $unset = apply_filters('site-reviews/create/unset-keys-from-custom', $unset);
93
+        $unset = apply_filters( 'site-reviews/create/unset-keys-from-custom', $unset );
94 94
         $custom = $this->request;
95
-        foreach ($unset as $value) {
95
+        foreach( $unset as $value ) {
96 96
             unset($custom[$value]);
97 97
         }
98 98
         return $custom;
@@ -102,29 +102,29 @@  discard block
 block discarded – undo
102 102
      * @param string $key
103 103
      * @return string
104 104
      */
105
-    protected function getDate($key)
105
+    protected function getDate( $key )
106 106
     {
107
-        $date = strtotime($this->get($key));
108
-        if (false === $date) {
107
+        $date = strtotime( $this->get( $key ) );
108
+        if( false === $date ) {
109 109
             $date = time();
110 110
         }
111
-        return get_date_from_gmt(gmdate('Y-m-d H:i:s', $date));
111
+        return get_date_from_gmt( gmdate( 'Y-m-d H:i:s', $date ) );
112 112
     }
113 113
 
114 114
     /**
115 115
      * @param string $key
116 116
      * @return string
117 117
      */
118
-    protected function getUser($key)
118
+    protected function getUser( $key )
119 119
     {
120
-        $value = $this->get($key);
121
-        if (empty($value)) {
120
+        $value = $this->get( $key );
121
+        if( empty($value) ) {
122 122
             $user = wp_get_current_user();
123 123
             $userValues = [
124 124
                 'email' => 'user_email',
125 125
                 'name' => 'display_name',
126 126
             ];
127
-            if ($user->exists() && array_key_exists($key, $userValues)) {
127
+            if( $user->exists() && array_key_exists( $key, $userValues ) ) {
128 128
                 return $user->{$userValues[$key]};
129 129
             }
130 130
         }
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
      * @param string $key
136 136
      * @return string
137 137
      */
138
-    protected function getNumeric($key)
138
+    protected function getNumeric( $key )
139 139
     {
140
-        $value = $this->get($key);
141
-        return is_numeric($value)
140
+        $value = $this->get( $key );
141
+        return is_numeric( $value )
142 142
             ? $value
143 143
             : '';
144 144
     }
Please login to merge, or discard this patch.
plugin/Controllers/WelcomeController.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
      * @return array
13 13
      * @filter plugin_action_links_site-reviews/site-reviews.php
14 14
      */
15
-    public function filterActionLinks(array $links)
15
+    public function filterActionLinks( array $links )
16 16
     {
17
-        $links['welcome'] = glsr(Builder::class)->a(__('About', 'site-reviews'), [
18
-            'href' => admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome'),
19
-        ]);
17
+        $links['welcome'] = glsr( Builder::class )->a( __( 'About', 'site-reviews' ), [
18
+            'href' => admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=welcome' ),
19
+        ] );
20 20
         return $links;
21 21
     }
22 22
 
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
      * @return string
25 25
      * @filter admin_title
26 26
      */
27
-    public function filterAdminTitle($title)
27
+    public function filterAdminTitle( $title )
28 28
     {
29 29
         return Application::POST_TYPE.'_page_welcome' == glsr_current_screen()->id
30
-            ? sprintf(__('Welcome to %s &#8212; WordPress', 'site-reviews'), glsr()->name)
30
+            ? sprintf( __( 'Welcome to %s &#8212; WordPress', 'site-reviews' ), glsr()->name )
31 31
             : $title;
32 32
     }
33 33
 
@@ -36,17 +36,17 @@  discard block
 block discarded – undo
36 36
      * @return string
37 37
      * @filter admin_footer_text
38 38
      */
39
-    public function filterFooterText($text)
39
+    public function filterFooterText( $text )
40 40
     {
41
-        if (Application::POST_TYPE.'_page_welcome' != glsr_current_screen()->id) {
41
+        if( Application::POST_TYPE.'_page_welcome' != glsr_current_screen()->id ) {
42 42
             return $text;
43 43
         }
44 44
         $url = 'https://wordpress.org/support/view/plugin-reviews/site-reviews?filter=5#new-post';
45
-        return wp_kses_post(sprintf(
46
-            __('Please rate %s on %s and help us spread the word. Thank you so much!', 'site-reviews'),
45
+        return wp_kses_post( sprintf(
46
+            __( 'Please rate %s on %s and help us spread the word. Thank you so much!', 'site-reviews' ),
47 47
             '<strong>'.glsr()->name.'</strong> <a href="'.$url.'" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>',
48 48
             '<a href="'.$url.'" target="_blank">wordpress.org</a>'
49
-        ));
49
+        ) );
50 50
     }
51 51
 
52 52
     /**
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
      * @return void
56 56
      * @action activated_plugin
57 57
      */
58
-    public function redirectOnActivation($plugin, $isNetworkActivation)
58
+    public function redirectOnActivation( $plugin, $isNetworkActivation )
59 59
     {
60
-        if (!$isNetworkActivation
60
+        if( !$isNetworkActivation
61 61
             && 'cli' !== php_sapi_name()
62
-            && $plugin === plugin_basename(glsr()->file)) {
63
-            wp_safe_redirect(admin_url('edit.php?post_type='.Application::POST_TYPE.'&page=welcome'));
62
+            && $plugin === plugin_basename( glsr()->file ) ) {
63
+            wp_safe_redirect( admin_url( 'edit.php?post_type='.Application::POST_TYPE.'&page=welcome' ) );
64 64
             exit;
65 65
         }
66 66
     }
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function registerPage()
73 73
     {
74
-        add_submenu_page('edit.php?post_type='.Application::POST_TYPE,
75
-            sprintf(__('Welcome to %s', 'site-reviews'), glsr()->name),
74
+        add_submenu_page( 'edit.php?post_type='.Application::POST_TYPE,
75
+            sprintf( __( 'Welcome to %s', 'site-reviews' ), glsr()->name ),
76 76
             glsr()->name,
77
-            glsr()->getPermission('welcome'),
77
+            glsr()->getPermission( 'welcome' ),
78 78
             'welcome',
79 79
             [$this, 'renderPage']
80 80
         );
81
-        remove_submenu_page('edit.php?post_type='.Application::POST_TYPE, 'welcome');
81
+        remove_submenu_page( 'edit.php?post_type='.Application::POST_TYPE, 'welcome' );
82 82
     }
83 83
 
84 84
     /**
@@ -88,19 +88,19 @@  discard block
 block discarded – undo
88 88
      */
89 89
     public function renderPage()
90 90
     {
91
-        $tabs = apply_filters('site-reviews/addon/welcome/tabs', [
92
-            'getting-started' => __('Getting Started', 'site-reviews'),
93
-            'whatsnew' => __('What\'s New', 'site-reviews'),
94
-            'upgrade-guide' => __('Upgrade Guide', 'site-reviews'),
95
-            'support' => __('Support', 'site-reviews'),
96
-        ]);
97
-        glsr()->render('pages/welcome/index', [
91
+        $tabs = apply_filters( 'site-reviews/addon/welcome/tabs', [
92
+            'getting-started' => __( 'Getting Started', 'site-reviews' ),
93
+            'whatsnew' => __( 'What\'s New', 'site-reviews' ),
94
+            'upgrade-guide' => __( 'Upgrade Guide', 'site-reviews' ),
95
+            'support' => __( 'Support', 'site-reviews' ),
96
+        ] );
97
+        glsr()->render( 'pages/welcome/index', [
98 98
             'data' => [
99 99
                 'context' => [],
100 100
             ],
101
-            'http_referer' => (string) wp_get_referer(),
101
+            'http_referer' => (string)wp_get_referer(),
102 102
             'tabs' => $tabs,
103
-            'template' => glsr(Template::class),
104
-        ]);
103
+            'template' => glsr( Template::class ),
104
+        ] );
105 105
     }
106 106
 }
Please login to merge, or discard this patch.
plugin/Controllers/EditorController.php 1 patch
Spacing   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
      */
26 26
     public function customizePostStatusLabels()
27 27
     {
28
-        glsr(Labels::class)->customizePostStatusLabels();
28
+        glsr( Labels::class )->customizePostStatusLabels();
29 29
     }
30 30
 
31 31
     /**
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
      * @return array
34 34
      * @filter wp_editor_settings
35 35
      */
36
-    public function filterEditorSettings($settings)
36
+    public function filterEditorSettings( $settings )
37 37
     {
38
-        return glsr(Customization::class)->filterEditorSettings(
39
-            glsr(Helper::class)->consolidateArray($settings)
38
+        return glsr( Customization::class )->filterEditorSettings(
39
+            glsr( Helper::class )->consolidateArray( $settings )
40 40
         );
41 41
     }
42 42
 
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
      * @return string
47 47
      * @filter the_editor
48 48
      */
49
-    public function filterEditorTextarea($html)
49
+    public function filterEditorTextarea( $html )
50 50
     {
51
-        return glsr(Customization::class)->filterEditorTextarea($html);
51
+        return glsr( Customization::class )->filterEditorTextarea( $html );
52 52
     }
53 53
 
54 54
     /**
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
      * @return bool
59 59
      * @filter is_protected_meta
60 60
      */
61
-    public function filterIsProtectedMeta($protected, $metaKey, $metaType)
61
+    public function filterIsProtectedMeta( $protected, $metaKey, $metaType )
62 62
     {
63
-        if ('post' == $metaType && Application::POST_TYPE == get_post_type()) {
64
-            $values = glsr(CreateReviewDefaults::class)->unguarded();
65
-            $values = glsr(Helper::class)->prefixArrayKeys($values);
66
-            if (array_key_exists($metaKey, $values)) {
63
+        if( 'post' == $metaType && Application::POST_TYPE == get_post_type() ) {
64
+            $values = glsr( CreateReviewDefaults::class )->unguarded();
65
+            $values = glsr( Helper::class )->prefixArrayKeys( $values );
66
+            if( array_key_exists( $metaKey, $values ) ) {
67 67
                 $protected = false;
68 68
             }
69 69
         }
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
      * @return string
78 78
      * @filter gettext
79 79
      */
80
-    public function filterPostStatusLabels($translation, $text, $domain)
80
+    public function filterPostStatusLabels( $translation, $text, $domain )
81 81
     {
82
-        return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain);
82
+        return glsr( Labels::class )->filterPostStatusLabels( $translation, $text, $domain );
83 83
     }
84 84
 
85 85
     /**
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
      * @return string
90 90
      * @filter gettext_with_context
91 91
      */
92
-    public function filterPostStatusLabelsWithContext($translation, $text, $context, $domain)
92
+    public function filterPostStatusLabelsWithContext( $translation, $text, $context, $domain )
93 93
     {
94
-        return glsr(Labels::class)->filterPostStatusLabels($translation, $text, $domain);
94
+        return glsr( Labels::class )->filterPostStatusLabels( $translation, $text, $domain );
95 95
     }
96 96
 
97 97
     /**
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
      * @return array
100 100
      * @filter post_updated_messages
101 101
      */
102
-    public function filterUpdateMessages($messages)
102
+    public function filterUpdateMessages( $messages )
103 103
     {
104
-        return glsr(Labels::class)->filterUpdateMessages(
105
-            glsr(Helper::class)->consolidateArray($messages)
104
+        return glsr( Labels::class )->filterUpdateMessages(
105
+            glsr( Helper::class )->consolidateArray( $messages )
106 106
         );
107 107
     }
108 108
 
@@ -110,14 +110,14 @@  discard block
 block discarded – undo
110 110
      * @return void
111 111
      * @action add_meta_boxes_{Application::POST_TYPE}
112 112
      */
113
-    public function registerMetaBoxes($post)
113
+    public function registerMetaBoxes( $post )
114 114
     {
115
-        add_meta_box(Application::ID.'_assigned_to', __('Assigned To', 'site-reviews'), [$this, 'renderAssignedToMetabox'], null, 'side');
116
-        add_meta_box(Application::ID.'_review', __('Details', 'site-reviews'), [$this, 'renderDetailsMetaBox'], null, 'side');
117
-        if ('local' != glsr(Database::class)->get($post->ID, 'review_type')) {
115
+        add_meta_box( Application::ID.'_assigned_to', __( 'Assigned To', 'site-reviews' ), [$this, 'renderAssignedToMetabox'], null, 'side' );
116
+        add_meta_box( Application::ID.'_review', __( 'Details', 'site-reviews' ), [$this, 'renderDetailsMetaBox'], null, 'side' );
117
+        if( 'local' != glsr( Database::class )->get( $post->ID, 'review_type' ) ) {
118 118
             return;
119 119
         }
120
-        add_meta_box(Application::ID.'_response', __('Respond Publicly', 'site-reviews'), [$this, 'renderResponseMetaBox'], null, 'normal');
120
+        add_meta_box( Application::ID.'_response', __( 'Respond Publicly', 'site-reviews' ), [$this, 'renderResponseMetaBox'], null, 'normal' );
121 121
     }
122 122
 
123 123
     /**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function removeAutosave()
128 128
     {
129
-        glsr(Customization::class)->removeAutosave();
129
+        glsr( Customization::class )->removeAutosave();
130 130
     }
131 131
 
132 132
     /**
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      */
136 136
     public function removeMetaBoxes()
137 137
     {
138
-        glsr(Customization::class)->removeMetaBoxes();
138
+        glsr( Customization::class )->removeMetaBoxes();
139 139
     }
140 140
 
141 141
     /**
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
      */
144 144
     public function removePostTypeSupport()
145 145
     {
146
-        glsr(Customization::class)->removePostTypeSupport();
146
+        glsr( Customization::class )->removePostTypeSupport();
147 147
     }
148 148
 
149 149
     /**
@@ -151,17 +151,17 @@  discard block
 block discarded – undo
151 151
      * @return void
152 152
      * @callback add_meta_box
153 153
      */
154
-    public function renderAssignedToMetabox($post)
154
+    public function renderAssignedToMetabox( $post )
155 155
     {
156
-        if (!$this->isReviewPostType($post)) {
156
+        if( !$this->isReviewPostType( $post ) ) {
157 157
             return;
158 158
         }
159
-        $assignedTo = (string) glsr(Database::class)->get($post->ID, 'assigned_to');
160
-        wp_nonce_field('assigned_to', '_nonce-assigned-to', false);
161
-        glsr()->render('partials/editor/metabox-assigned-to', [
159
+        $assignedTo = (string)glsr( Database::class )->get( $post->ID, 'assigned_to' );
160
+        wp_nonce_field( 'assigned_to', '_nonce-assigned-to', false );
161
+        glsr()->render( 'partials/editor/metabox-assigned-to', [
162 162
             'id' => $assignedTo,
163
-            'template' => $this->buildAssignedToTemplate($assignedTo, $post),
164
-        ]);
163
+            'template' => $this->buildAssignedToTemplate( $assignedTo, $post ),
164
+        ] );
165 165
     }
166 166
 
167 167
     /**
@@ -169,16 +169,16 @@  discard block
 block discarded – undo
169 169
      * @return void
170 170
      * @callback add_meta_box
171 171
      */
172
-    public function renderDetailsMetaBox($post)
172
+    public function renderDetailsMetaBox( $post )
173 173
     {
174
-        if (!$this->isReviewPostType($post)) {
174
+        if( !$this->isReviewPostType( $post ) ) {
175 175
             return;
176 176
         }
177
-        $review = glsr_get_review($post);
178
-        glsr()->render('partials/editor/metabox-details', [
179
-            'button' => $this->buildDetailsMetaBoxRevertButton($review, $post),
180
-            'metabox' => $this->normalizeDetailsMetaBox($review),
181
-        ]);
177
+        $review = glsr_get_review( $post );
178
+        glsr()->render( 'partials/editor/metabox-details', [
179
+            'button' => $this->buildDetailsMetaBoxRevertButton( $review, $post ),
180
+            'metabox' => $this->normalizeDetailsMetaBox( $review ),
181
+        ] );
182 182
     }
183 183
 
184 184
     /**
@@ -187,16 +187,16 @@  discard block
 block discarded – undo
187 187
      */
188 188
     public function renderPinnedInPublishMetaBox()
189 189
     {
190
-        if (!$this->isReviewPostType(get_post())) {
190
+        if( !$this->isReviewPostType( get_post() ) ) {
191 191
             return;
192 192
         }
193
-        glsr(Template::class)->render('partials/editor/pinned', [
193
+        glsr( Template::class )->render( 'partials/editor/pinned', [
194 194
             'context' => [
195
-                'no' => __('No', 'site-reviews'),
196
-                'yes' => __('Yes', 'site-reviews'),
195
+                'no' => __( 'No', 'site-reviews' ),
196
+                'yes' => __( 'Yes', 'site-reviews' ),
197 197
             ],
198
-            'pinned' => wp_validate_boolean(glsr(Database::class)->get(get_the_ID(), 'pinned')),
199
-        ]);
198
+            'pinned' => wp_validate_boolean( glsr( Database::class )->get( get_the_ID(), 'pinned' ) ),
199
+        ] );
200 200
     }
201 201
 
202 202
     /**
@@ -204,15 +204,15 @@  discard block
 block discarded – undo
204 204
      * @return void
205 205
      * @callback add_meta_box
206 206
      */
207
-    public function renderResponseMetaBox($post)
207
+    public function renderResponseMetaBox( $post )
208 208
     {
209
-        if (!$this->isReviewPostType($post)) {
209
+        if( !$this->isReviewPostType( $post ) ) {
210 210
             return;
211 211
         }
212
-        wp_nonce_field('response', '_nonce-response', false);
213
-        glsr()->render('partials/editor/metabox-response', [
214
-            'response' => glsr(Database::class)->get($post->ID, 'response'),
215
-        ]);
212
+        wp_nonce_field( 'response', '_nonce-response', false );
213
+        glsr()->render( 'partials/editor/metabox-response', [
214
+            'response' => glsr( Database::class )->get( $post->ID, 'response' ),
215
+        ] );
216 216
     }
217 217
 
218 218
     /**
@@ -220,15 +220,15 @@  discard block
 block discarded – undo
220 220
      * @return void
221 221
      * @action edit_form_after_title
222 222
      */
223
-    public function renderReviewEditor($post)
223
+    public function renderReviewEditor( $post )
224 224
     {
225
-        if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
225
+        if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) ) {
226 226
             return;
227 227
         }
228
-        glsr()->render('partials/editor/review', [
228
+        glsr()->render( 'partials/editor/review', [
229 229
             'post' => $post,
230
-            'response' => glsr(Database::class)->get($post->ID, 'response'),
231
-        ]);
230
+            'response' => glsr( Database::class )->get( $post->ID, 'response' ),
231
+        ] );
232 232
     }
233 233
 
234 234
     /**
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
     public function renderReviewFields()
239 239
     {
240 240
         $screen = glsr_current_screen();
241
-        if ('post' != $screen->base || Application::POST_TYPE != $screen->post_type) {
241
+        if( 'post' != $screen->base || Application::POST_TYPE != $screen->post_type ) {
242 242
             return;
243 243
         }
244
-        add_action('edit_form_after_title', [$this, 'renderReviewEditor']);
245
-        add_action('edit_form_top', [$this, 'renderReviewNotice']);
244
+        add_action( 'edit_form_after_title', [$this, 'renderReviewEditor'] );
245
+        add_action( 'edit_form_top', [$this, 'renderReviewNotice'] );
246 246
     }
247 247
 
248 248
     /**
@@ -250,20 +250,20 @@  discard block
 block discarded – undo
250 250
      * @return void
251 251
      * @action edit_form_top
252 252
      */
253
-    public function renderReviewNotice($post)
253
+    public function renderReviewNotice( $post )
254 254
     {
255
-        if (!$this->isReviewPostType($post) || $this->isReviewEditable($post)) {
255
+        if( !$this->isReviewPostType( $post ) || $this->isReviewEditable( $post ) ) {
256 256
             return;
257 257
         }
258
-        glsr(Notice::class)->addWarning(sprintf(
259
-            __('%s reviews are read-only.', 'site-reviews'),
260
-            glsr(Columns::class)->buildColumnReviewType($post->ID)
261
-        ));
262
-        glsr(Template::class)->render('partials/editor/notice', [
258
+        glsr( Notice::class )->addWarning( sprintf(
259
+            __( '%s reviews are read-only.', 'site-reviews' ),
260
+            glsr( Columns::class )->buildColumnReviewType( $post->ID )
261
+        ) );
262
+        glsr( Template::class )->render( 'partials/editor/notice', [
263 263
             'context' => [
264
-                'notices' => glsr(Notice::class)->get(),
264
+                'notices' => glsr( Notice::class )->get(),
265 265
             ],
266
-        ]);
266
+        ] );
267 267
     }
268 268
 
269 269
     /**
@@ -272,16 +272,16 @@  discard block
 block discarded – undo
272 272
      * @see glsr_categories_meta_box()
273 273
      * @callback register_taxonomy
274 274
      */
275
-    public function renderTaxonomyMetabox($post)
275
+    public function renderTaxonomyMetabox( $post )
276 276
     {
277
-        if (!$this->isReviewPostType($post)) {
277
+        if( !$this->isReviewPostType( $post ) ) {
278 278
             return;
279 279
         }
280
-        glsr()->render('partials/editor/metabox-categories', [
280
+        glsr()->render( 'partials/editor/metabox-categories', [
281 281
             'post' => $post,
282 282
             'tax_name' => Application::TAXONOMY,
283
-            'taxonomy' => get_taxonomy(Application::TAXONOMY),
284
-        ]);
283
+            'taxonomy' => get_taxonomy( Application::TAXONOMY ),
284
+        ] );
285 285
     }
286 286
 
287 287
     /**
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
      */
292 292
     public function revertReview()
293 293
     {
294
-        if (Application::ID != filter_input(INPUT_GET, 'plugin')) {
294
+        if( Application::ID != filter_input( INPUT_GET, 'plugin' ) ) {
295 295
             return;
296 296
         }
297
-        check_admin_referer('revert-review_'.($postId = $this->getPostId()));
298
-        glsr(ReviewManager::class)->revert($postId);
299
-        $this->redirect($postId, 52);
297
+        check_admin_referer( 'revert-review_'.($postId = $this->getPostId()) );
298
+        glsr( ReviewManager::class )->revert( $postId );
299
+        $this->redirect( $postId, 52 );
300 300
     }
301 301
 
302 302
     /**
@@ -306,12 +306,12 @@  discard block
 block discarded – undo
306 306
      * @return void
307 307
      * @action save_post_.Application::POST_TYPE
308 308
      */
309
-    public function saveMetaboxes($postId, $post, $isUpdating)
309
+    public function saveMetaboxes( $postId, $post, $isUpdating )
310 310
     {
311
-        glsr(Metaboxes::class)->saveAssignedToMetabox($postId);
312
-        glsr(Metaboxes::class)->saveResponseMetabox($postId);
313
-        if ($isUpdating) {
314
-            do_action('site-reviews/review/saved', glsr_get_review($postId));
311
+        glsr( Metaboxes::class )->saveAssignedToMetabox( $postId );
312
+        glsr( Metaboxes::class )->saveResponseMetabox( $postId );
313
+        if( $isUpdating ) {
314
+            do_action( 'site-reviews/review/saved', glsr_get_review( $postId ) );
315 315
         }
316 316
     }
317 317
 
@@ -319,68 +319,68 @@  discard block
 block discarded – undo
319 319
      * @param string $assignedTo
320 320
      * @return string
321 321
      */
322
-    protected function buildAssignedToTemplate($assignedTo, WP_Post $post)
322
+    protected function buildAssignedToTemplate( $assignedTo, WP_Post $post )
323 323
     {
324
-        $assignedPost = glsr(Database::class)->getAssignedToPost($post->ID, $assignedTo);
325
-        if (!($assignedPost instanceof WP_Post)) {
324
+        $assignedPost = glsr( Database::class )->getAssignedToPost( $post->ID, $assignedTo );
325
+        if( !($assignedPost instanceof WP_Post) ) {
326 326
             return;
327 327
         }
328
-        return glsr(Template::class)->build('partials/editor/assigned-post', [
328
+        return glsr( Template::class )->build( 'partials/editor/assigned-post', [
329 329
             'context' => [
330
-                'data.url' => (string) get_permalink($assignedPost),
331
-                'data.title' => get_the_title($assignedPost),
330
+                'data.url' => (string)get_permalink( $assignedPost ),
331
+                'data.title' => get_the_title( $assignedPost ),
332 332
             ],
333
-        ]);
333
+        ] );
334 334
     }
335 335
 
336 336
     /**
337 337
      * @return string
338 338
      */
339
-    protected function buildDetailsMetaBoxRevertButton(Review $review, WP_Post $post)
339
+    protected function buildDetailsMetaBoxRevertButton( Review $review, WP_Post $post )
340 340
     {
341
-        $isModified = !glsr(Helper::class)->compareArrays(
341
+        $isModified = !glsr( Helper::class )->compareArrays(
342 342
             [$review->title, $review->content, $review->date],
343 343
             [
344
-                glsr(Database::class)->get($post->ID, 'title'),
345
-                glsr(Database::class)->get($post->ID, 'content'),
346
-                glsr(Database::class)->get($post->ID, 'date'),
344
+                glsr( Database::class )->get( $post->ID, 'title' ),
345
+                glsr( Database::class )->get( $post->ID, 'content' ),
346
+                glsr( Database::class )->get( $post->ID, 'date' ),
347 347
             ]
348 348
         );
349
-        if ($isModified) {
349
+        if( $isModified ) {
350 350
             $revertUrl = wp_nonce_url(
351
-                admin_url('post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID),
351
+                admin_url( 'post.php?post='.$post->ID.'&action=revert&plugin='.Application::ID ),
352 352
                 'revert-review_'.$post->ID
353 353
             );
354
-            return glsr(Builder::class)->a(__('Revert Changes', 'site-reviews'), [
354
+            return glsr( Builder::class )->a( __( 'Revert Changes', 'site-reviews' ), [
355 355
                 'class' => 'button button-large',
356 356
                 'href' => $revertUrl,
357 357
                 'id' => 'revert',
358
-            ]);
358
+            ] );
359 359
         }
360
-        return glsr(Builder::class)->button(__('Nothing to Revert', 'site-reviews'), [
360
+        return glsr( Builder::class )->button( __( 'Nothing to Revert', 'site-reviews' ), [
361 361
             'class' => 'button-large',
362 362
             'disabled' => true,
363 363
             'id' => 'revert',
364
-        ]);
364
+        ] );
365 365
     }
366 366
 
367 367
     /**
368 368
      * @param object $review
369 369
      * @return string|void
370 370
      */
371
-    protected function getReviewType($review)
371
+    protected function getReviewType( $review )
372 372
     {
373
-        if (count(glsr()->reviewTypes) < 2) {
373
+        if( count( glsr()->reviewTypes ) < 2 ) {
374 374
             return;
375 375
         }
376
-        $reviewType = array_key_exists($review->review_type, glsr()->reviewTypes)
376
+        $reviewType = array_key_exists( $review->review_type, glsr()->reviewTypes )
377 377
             ? glsr()->reviewTypes[$review->review_type]
378
-            : __('Unknown', 'site-reviews');
379
-        if (!empty($review->url)) {
380
-            $reviewType = glsr(Builder::class)->a($reviewType, [
378
+            : __( 'Unknown', 'site-reviews' );
379
+        if( !empty($review->url) ) {
380
+            $reviewType = glsr( Builder::class )->a( $reviewType, [
381 381
                 'href' => $review->url,
382 382
                 'target' => '_blank',
383
-            ]);
383
+            ] );
384 384
         }
385 385
         return $reviewType;
386 386
     }
@@ -388,18 +388,18 @@  discard block
 block discarded – undo
388 388
     /**
389 389
      * @return bool
390 390
      */
391
-    protected function isReviewEditable($post)
391
+    protected function isReviewEditable( $post )
392 392
     {
393
-        return $this->isReviewPostType($post)
394
-            && post_type_supports(Application::POST_TYPE, 'title')
395
-            && 'local' == glsr(Database::class)->get($post->ID, 'review_type');
393
+        return $this->isReviewPostType( $post )
394
+            && post_type_supports( Application::POST_TYPE, 'title' )
395
+            && 'local' == glsr( Database::class )->get( $post->ID, 'review_type' );
396 396
     }
397 397
 
398 398
     /**
399 399
      * @param mixed $post
400 400
      * @return bool
401 401
      */
402
-    protected function isReviewPostType($post)
402
+    protected function isReviewPostType( $post )
403 403
     {
404 404
         return $post instanceof WP_Post && Application::POST_TYPE == $post->post_type;
405 405
     }
@@ -407,29 +407,29 @@  discard block
 block discarded – undo
407 407
     /**
408 408
      * @return array
409 409
      */
410
-    protected function normalizeDetailsMetaBox(Review $review)
410
+    protected function normalizeDetailsMetaBox( Review $review )
411 411
     {
412 412
         $user = empty($review->user_id)
413
-            ? __('Unregistered user', 'site-reviews')
414
-            : glsr(Builder::class)->a(get_the_author_meta('display_name', $review->user_id), [
415
-                'href' => get_author_posts_url($review->user_id),
416
-            ]);
413
+            ? __( 'Unregistered user', 'site-reviews' )
414
+            : glsr( Builder::class )->a( get_the_author_meta( 'display_name', $review->user_id ), [
415
+                'href' => get_author_posts_url( $review->user_id ),
416
+            ] );
417 417
         $email = empty($review->email)
418 418
             ? '&mdash;'
419
-            : glsr(Builder::class)->a($review->email, [
420
-                'href' => 'mailto:'.$review->email.'?subject='.esc_attr(__('RE:', 'site-reviews').' '.$review->title),
421
-            ]);
419
+            : glsr( Builder::class )->a( $review->email, [
420
+                'href' => 'mailto:'.$review->email.'?subject='.esc_attr( __( 'RE:', 'site-reviews' ).' '.$review->title ),
421
+            ] );
422 422
         $metabox = [
423
-            __('Rating', 'site-reviews') => glsr_star_rating($review->rating),
424
-            __('Type', 'site-reviews') => $this->getReviewType($review),
425
-            __('Date', 'site-reviews') => get_date_from_gmt($review->date, 'F j, Y'),
426
-            __('Name', 'site-reviews') => $review->author,
427
-            __('Email', 'site-reviews') => $email,
428
-            __('User', 'site-reviews') => $user,
429
-            __('IP Address', 'site-reviews') => $review->ip_address,
430
-            __('Avatar', 'site-reviews') => sprintf('<img src="%s" width="96">', $review->avatar),
423
+            __( 'Rating', 'site-reviews' ) => glsr_star_rating( $review->rating ),
424
+            __( 'Type', 'site-reviews' ) => $this->getReviewType( $review ),
425
+            __( 'Date', 'site-reviews' ) => get_date_from_gmt( $review->date, 'F j, Y' ),
426
+            __( 'Name', 'site-reviews' ) => $review->author,
427
+            __( 'Email', 'site-reviews' ) => $email,
428
+            __( 'User', 'site-reviews' ) => $user,
429
+            __( 'IP Address', 'site-reviews' ) => $review->ip_address,
430
+            __( 'Avatar', 'site-reviews' ) => sprintf( '<img src="%s" width="96">', $review->avatar ),
431 431
         ];
432
-        return array_filter(apply_filters('site-reviews/metabox/details', $metabox, $review));
432
+        return array_filter( apply_filters( 'site-reviews/metabox/details', $metabox, $review ) );
433 433
     }
434 434
 
435 435
     /**
@@ -437,16 +437,16 @@  discard block
 block discarded – undo
437 437
      * @param int $messageIndex
438 438
      * @return void
439 439
      */
440
-    protected function redirect($postId, $messageIndex)
440
+    protected function redirect( $postId, $messageIndex )
441 441
     {
442 442
         $referer = wp_get_referer();
443 443
         $hasReferer = !$referer
444
-            || false !== strpos($referer, 'post.php')
445
-            || false !== strpos($referer, 'post-new.php');
444
+            || false !== strpos( $referer, 'post.php' )
445
+            || false !== strpos( $referer, 'post-new.php' );
446 446
         $redirectUri = $hasReferer
447
-            ? remove_query_arg(['deleted', 'ids', 'trashed', 'untrashed'], $referer)
448
-            : get_edit_post_link($postId);
449
-        wp_safe_redirect(add_query_arg(['message' => $messageIndex], $redirectUri));
447
+            ? remove_query_arg( ['deleted', 'ids', 'trashed', 'untrashed'], $referer )
448
+            : get_edit_post_link( $postId );
449
+        wp_safe_redirect( add_query_arg( ['message' => $messageIndex], $redirectUri ) );
450 450
         exit;
451 451
     }
452 452
 }
Please login to merge, or discard this patch.
plugin/Controllers/RebusifyController.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -21,16 +21,16 @@  discard block
 block discarded – undo
21 21
      * @return array
22 22
      * @filter site-reviews/settings/callback
23 23
      */
24
-    public function filterSettingsCallback(array $settings)
24
+    public function filterSettingsCallback( array $settings )
25 25
     {
26
-        if ('yes' !== glsr_get($settings, $this->enabledKey)) {
26
+        if( 'yes' !== glsr_get( $settings, $this->enabledKey ) ) {
27 27
             return $settings;
28 28
         }
29
-        $isApiKeyModified = $this->isEmptyOrModified($this->apiKey, $settings);
30
-        $isEmailModified = $this->isEmptyOrModified($this->emailKey, $settings);
31
-        $isAccountVerified = glsr(OptionManager::class)->getWP($this->rebusifyKey, false);
32
-        if (!$isAccountVerified || $isApiKeyModified || $isEmailModified) {
33
-            $settings = $this->sanitizeRebusifySettings($settings);
29
+        $isApiKeyModified = $this->isEmptyOrModified( $this->apiKey, $settings );
30
+        $isEmailModified = $this->isEmptyOrModified( $this->emailKey, $settings );
31
+        $isAccountVerified = glsr( OptionManager::class )->getWP( $this->rebusifyKey, false );
32
+        if( !$isAccountVerified || $isApiKeyModified || $isEmailModified ) {
33
+            $settings = $this->sanitizeRebusifySettings( $settings );
34 34
         }
35 35
         return $settings;
36 36
     }
@@ -40,21 +40,21 @@  discard block
 block discarded – undo
40 40
      * @return array
41 41
      * @filter site-reviews/interpolate/partials/form/table-row-multiple
42 42
      */
43
-    public function filterSettingsTableRow(array $context, $template, array $data)
43
+    public function filterSettingsTableRow( array $context, $template, array $data )
44 44
     {
45
-        if ($this->enabledKey !== glsr_get($data, 'field.path')) {
45
+        if( $this->enabledKey !== glsr_get( $data, 'field.path' ) ) {
46 46
             return $context;
47 47
         }
48
-        $rebusifyProductType = glsr(OptionManager::class)->getWP($this->rebusifyKey);
49
-        if ('P' === $rebusifyProductType) {
48
+        $rebusifyProductType = glsr( OptionManager::class )->getWP( $this->rebusifyKey );
49
+        if( 'P' === $rebusifyProductType ) {
50 50
             return $context;
51 51
         }
52
-        if ('F' === $rebusifyProductType && 'yes' === glsr_get_option('general.rebusify')) {
52
+        if( 'F' === $rebusifyProductType && 'yes' === glsr_get_option( 'general.rebusify' ) ) {
53 53
             $button = $this->buildUpgradeButton();
54 54
         } else {
55 55
             $button = $this->buildCreateButton();
56 56
         }
57
-        $context['field'].= $button;
57
+        $context['field'] .= $button;
58 58
         return $context;
59 59
     }
60 60
 
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
      * @return void
64 64
      * @action site-reviews/review/created
65 65
      */
66
-    public function onCreated(Review $review)
66
+    public function onCreated( Review $review )
67 67
     {
68
-        if (!$this->canPostReview($review)) {
68
+        if( !$this->canPostReview( $review ) ) {
69 69
             return;
70 70
         }
71
-        $rebusify = glsr(Rebusify::class)->sendReview($review);
72
-        if ($rebusify->success) {
73
-            glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id);
71
+        $rebusify = glsr( Rebusify::class )->sendReview( $review );
72
+        if( $rebusify->success ) {
73
+            glsr( Database::class )->set( $review->ID, 'rebusify', $rebusify->review_id );
74 74
         }
75 75
     }
76 76
 
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
      * @return void
80 80
      * @action site-reviews/review/reverted
81 81
      */
82
-    public function onReverted(Review $review)
82
+    public function onReverted( Review $review )
83 83
     {
84
-        if (!$this->canPostReview($review)) {
84
+        if( !$this->canPostReview( $review ) ) {
85 85
             return;
86 86
         }
87
-        $rebusify = glsr(Rebusify::class)->sendReview($review);
88
-        if ($rebusify->success) {
89
-            glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id);
87
+        $rebusify = glsr( Rebusify::class )->sendReview( $review );
88
+        if( $rebusify->success ) {
89
+            glsr( Database::class )->set( $review->ID, 'rebusify', $rebusify->review_id );
90 90
         }
91 91
     }
92 92
 
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
      * @return void
96 96
      * @action site-reviews/review/saved
97 97
      */
98
-    public function onSaved(Review $review)
98
+    public function onSaved( Review $review )
99 99
     {
100
-        if (!$this->canPostReview($review)) {
100
+        if( !$this->canPostReview( $review ) ) {
101 101
             return;
102 102
         }
103
-        $rebusify = glsr(Rebusify::class)->sendReview($review);
104
-        if ($rebusify->success) {
105
-            glsr(Database::class)->set($review->ID, 'rebusify', $rebusify->review_id);
103
+        $rebusify = glsr( Rebusify::class )->sendReview( $review );
104
+        if( $rebusify->success ) {
105
+            glsr( Database::class )->set( $review->ID, 'rebusify', $rebusify->review_id );
106 106
         }
107 107
     }
108 108
 
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
      * @return void
115 115
      * @action updated_postmeta
116 116
      */
117
-    public function onUpdatedMeta($metaId, $postId, $metaKey)
117
+    public function onUpdatedMeta( $metaId, $postId, $metaKey )
118 118
     {
119
-        $review = glsr_get_review($postId);
120
-        if (!$this->canPostResponse($review) || '_response' !== $metaKey) {
119
+        $review = glsr_get_review( $postId );
120
+        if( !$this->canPostResponse( $review ) || '_response' !== $metaKey ) {
121 121
             return;
122 122
         }
123
-        $rebusify = glsr(Rebusify::class)->sendReviewResponse($review);
124
-        if ($rebusify->success) {
125
-            glsr(Database::class)->set($review->ID, 'rebusify_response', true);
123
+        $rebusify = glsr( Rebusify::class )->sendReviewResponse( $review );
124
+        if( $rebusify->success ) {
125
+            glsr( Database::class )->set( $review->ID, 'rebusify_response', true );
126 126
         }
127 127
     }
128 128
 
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
      */
132 132
     protected function buildCreateButton()
133 133
     {
134
-        return glsr(Builder::class)->a(__('Create Your Rebusify Account', 'site-reviews'), [
134
+        return glsr( Builder::class )->a( __( 'Create Your Rebusify Account', 'site-reviews' ), [
135 135
             'class' => 'button',
136 136
             'href' => Rebusify::WEB_URL,
137 137
             'target' => '_blank',
138
-        ]);
138
+        ] );
139 139
     }
140 140
 
141 141
     /**
@@ -143,37 +143,37 @@  discard block
 block discarded – undo
143 143
      */
144 144
     protected function buildUpgradeButton()
145 145
     {
146
-        $build = glsr(Builder::class);
147
-        $notice = $build->p(__('Free Rebusify accounts are limited to 500 blockchain transactions per year.', 'site-reviews'));
148
-        $button = $build->a(__('Upgrade Your Rebusify Plan', 'site-reviews'), [
146
+        $build = glsr( Builder::class );
147
+        $notice = $build->p( __( 'Free Rebusify accounts are limited to 500 blockchain transactions per year.', 'site-reviews' ) );
148
+        $button = $build->a( __( 'Upgrade Your Rebusify Plan', 'site-reviews' ), [
149 149
             'class' => 'button',
150 150
             'href' => Rebusify::WEB_URL,
151 151
             'target' => '_blank',
152
-        ]);
153
-        return $build->div($notice.$button, [
152
+        ] );
153
+        return $build->div( $notice.$button, [
154 154
             'class' => 'glsr-notice-inline',
155
-        ]);
155
+        ] );
156 156
     }
157 157
 
158 158
     /**
159 159
      * @return bool
160 160
      */
161
-    protected function canPostResponse(Review $review)
161
+    protected function canPostResponse( Review $review )
162 162
     {
163 163
         $requiredValues = [
164
-            glsr(Database::class)->get($review->ID, 'rebusify'),
164
+            glsr( Database::class )->get( $review->ID, 'rebusify' ),
165 165
             $review->response,
166 166
             $review->review_id,
167 167
         ];
168
-        return $this->canProceed($review, 'rebusify_response')
168
+        return $this->canProceed( $review, 'rebusify_response' )
169 169
             && 'publish' === $review->status
170
-            && 3 === count(array_filter($requiredValues));
170
+            && 3 === count( array_filter( $requiredValues ) );
171 171
     }
172 172
 
173 173
     /**
174 174
      * @return bool
175 175
      */
176
-    protected function canPostReview(Review $review)
176
+    protected function canPostReview( Review $review )
177 177
     {
178 178
         $requiredValues = [
179 179
             $review->author,
@@ -182,60 +182,60 @@  discard block
 block discarded – undo
182 182
             $review->review_id,
183 183
             $review->title,
184 184
         ];
185
-        return $this->canProceed($review)
185
+        return $this->canProceed( $review )
186 186
             && 'publish' === $review->status
187
-            && 5 === count(array_filter($requiredValues));
187
+            && 5 === count( array_filter( $requiredValues ) );
188 188
     }
189 189
 
190 190
     /**
191 191
      * @param string $metaKey
192 192
      * @return bool
193 193
      */
194
-    protected function canProceed(Review $review, $metaKey = 'rebusify')
194
+    protected function canProceed( Review $review, $metaKey = 'rebusify' )
195 195
     {
196
-        return glsr(OptionManager::class)->getBool($this->enabledKey)
197
-            && $this->isReviewPostId($review->ID)
198
-            && !$this->hasMetaKey($review, $metaKey);
196
+        return glsr( OptionManager::class )->getBool( $this->enabledKey )
197
+            && $this->isReviewPostId( $review->ID )
198
+            && !$this->hasMetaKey( $review, $metaKey );
199 199
     }
200 200
 
201 201
     /**
202 202
      * @param string $metaKey
203 203
      * @return bool
204 204
      */
205
-    protected function hasMetaKey(Review $review, $metaKey = 'rebusify')
205
+    protected function hasMetaKey( Review $review, $metaKey = 'rebusify' )
206 206
     {
207
-        return '' !== glsr(Database::class)->get($review->ID, $metaKey);
207
+        return '' !== glsr( Database::class )->get( $review->ID, $metaKey );
208 208
     }
209 209
 
210 210
     /**
211 211
      * @param string $key
212 212
      * @return bool
213 213
      */
214
-    protected function isEmptyOrModified($key, array $settings)
214
+    protected function isEmptyOrModified( $key, array $settings )
215 215
     {
216
-        $oldValue = glsr_get_option($key);
217
-        $newValue = glsr_get($settings, $key);
216
+        $oldValue = glsr_get_option( $key );
217
+        $newValue = glsr_get( $settings, $key );
218 218
         return empty($newValue) || $newValue !== $oldValue;
219 219
     }
220 220
 
221 221
     /**
222 222
      * @return array
223 223
      */
224
-    protected function sanitizeRebusifySettings(array $settings)
224
+    protected function sanitizeRebusifySettings( array $settings )
225 225
     {
226
-        $rebusify = glsr(Rebusify::class)->activateKey(
227
-            glsr_get($settings, $this->apiKey),
228
-            glsr_get($settings, $this->emailKey)
226
+        $rebusify = glsr( Rebusify::class )->activateKey(
227
+            glsr_get( $settings, $this->apiKey ),
228
+            glsr_get( $settings, $this->emailKey )
229 229
         );
230
-        if ($rebusify->success) {
231
-            update_option($this->rebusifyKey, glsr_get($rebusify->response, 'producttype'));
230
+        if( $rebusify->success ) {
231
+            update_option( $this->rebusifyKey, glsr_get( $rebusify->response, 'producttype' ) );
232 232
         } else {
233
-            delete_option($this->rebusifyKey);
234
-            $settings = glsr(Helper::class)->dataSet($settings, $this->enabledKey, 'no');
235
-            glsr(Notice::class)->addError(sprintf(
236
-                __('Your Rebusify account details could not be verified, please try again. %s', 'site-reviews'),
233
+            delete_option( $this->rebusifyKey );
234
+            $settings = glsr( Helper::class )->dataSet( $settings, $this->enabledKey, 'no' );
235
+            glsr( Notice::class )->addError( sprintf(
236
+                __( 'Your Rebusify account details could not be verified, please try again. %s', 'site-reviews' ),
237 237
                 '('.$rebusify->message.')'
238
-            ));
238
+            ) );
239 239
         }
240 240
         return $settings;
241 241
     }
Please login to merge, or discard this patch.