Passed
Push — master ( abfd32...f48539 )
by Paul
04:34
created
plugin/Controllers/ListTableController/Columns.php 2 patches
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -10,184 +10,184 @@
 block discarded – undo
10 10
 
11 11
 class Columns
12 12
 {
13
-    /**
14
-     * @param int $postId
15
-     * @return void|string
16
-     */
17
-    public function buildColumnAssignedTo($postId)
18
-    {
19
-        $assignedPost = glsr(Database::class)->getAssignedToPost($postId);
20
-        if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) {
21
-            return glsr(Builder::class)->a(get_the_title($assignedPost->ID), [
22
-                'href' => (string) get_the_permalink($assignedPost->ID),
23
-            ]);
24
-        }
25
-    }
13
+	/**
14
+	 * @param int $postId
15
+	 * @return void|string
16
+	 */
17
+	public function buildColumnAssignedTo($postId)
18
+	{
19
+		$assignedPost = glsr(Database::class)->getAssignedToPost($postId);
20
+		if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) {
21
+			return glsr(Builder::class)->a(get_the_title($assignedPost->ID), [
22
+				'href' => (string) get_the_permalink($assignedPost->ID),
23
+			]);
24
+		}
25
+	}
26 26
 
27
-    /**
28
-     * @param int $postId
29
-     * @return void|string
30
-     */
31
-    public function buildColumnEmail($postId)
32
-    {
33
-        if ($email = glsr(Database::class)->get($postId, 'email')) {
34
-            return $email;
35
-        }
36
-    }
27
+	/**
28
+	 * @param int $postId
29
+	 * @return void|string
30
+	 */
31
+	public function buildColumnEmail($postId)
32
+	{
33
+		if ($email = glsr(Database::class)->get($postId, 'email')) {
34
+			return $email;
35
+		}
36
+	}
37 37
 
38
-    /**
39
-     * @param int $postId
40
-     * @return void|string
41
-     */
42
-    public function buildColumnIpAddress($postId)
43
-    {
44
-        if ($ipAddress = glsr(Database::class)->get($postId, 'ip_address')) {
45
-            return $ipAddress;
46
-        }
47
-    }
38
+	/**
39
+	 * @param int $postId
40
+	 * @return void|string
41
+	 */
42
+	public function buildColumnIpAddress($postId)
43
+	{
44
+		if ($ipAddress = glsr(Database::class)->get($postId, 'ip_address')) {
45
+			return $ipAddress;
46
+		}
47
+	}
48 48
 
49
-    /**
50
-     * @param int $postId
51
-     * @return string
52
-     */
53
-    public function buildColumnPinned($postId)
54
-    {
55
-        $pinned = glsr(Database::class)->get($postId, 'pinned')
56
-            ? 'pinned '
57
-            : '';
58
-        if (glsr()->can('edit_others_posts')) {
59
-            $pinned.= 'pin-review ';
60
-        }
61
-        return glsr(Builder::class)->i([
62
-            'class' => $pinned.'dashicons dashicons-sticky',
63
-            'data-id' => $postId,
64
-        ]);
65
-    }
49
+	/**
50
+	 * @param int $postId
51
+	 * @return string
52
+	 */
53
+	public function buildColumnPinned($postId)
54
+	{
55
+		$pinned = glsr(Database::class)->get($postId, 'pinned')
56
+			? 'pinned '
57
+			: '';
58
+		if (glsr()->can('edit_others_posts')) {
59
+			$pinned.= 'pin-review ';
60
+		}
61
+		return glsr(Builder::class)->i([
62
+			'class' => $pinned.'dashicons dashicons-sticky',
63
+			'data-id' => $postId,
64
+		]);
65
+	}
66 66
 
67
-    /**
68
-     * @param int $postId
69
-     * @return string
70
-     */
71
-    public function buildColumnResponse($postId)
72
-    {
73
-        return glsr(Database::class)->get($postId, 'response')
74
-            ? __('Yes', 'site-reviews')
75
-            : __('No', 'site-reviews');
76
-    }
67
+	/**
68
+	 * @param int $postId
69
+	 * @return string
70
+	 */
71
+	public function buildColumnResponse($postId)
72
+	{
73
+		return glsr(Database::class)->get($postId, 'response')
74
+			? __('Yes', 'site-reviews')
75
+			: __('No', 'site-reviews');
76
+	}
77 77
 
78
-    /**
79
-     * @param int $postId
80
-     * @return string
81
-     */
82
-    public function buildColumnReviewer($postId)
83
-    {
84
-        $author = strval(glsr(Database::class)->get($postId, 'author'));
85
-        $userId = Helper::castToInt(get_post($postId)->post_author);
86
-        return !empty($userId)
87
-            ? glsr(Builder::class)->a($author, ['href' => get_author_posts_url($userId)])
88
-            : $author;
89
-    }
78
+	/**
79
+	 * @param int $postId
80
+	 * @return string
81
+	 */
82
+	public function buildColumnReviewer($postId)
83
+	{
84
+		$author = strval(glsr(Database::class)->get($postId, 'author'));
85
+		$userId = Helper::castToInt(get_post($postId)->post_author);
86
+		return !empty($userId)
87
+			? glsr(Builder::class)->a($author, ['href' => get_author_posts_url($userId)])
88
+			: $author;
89
+	}
90 90
 
91
-    /**
92
-     * @param int $postId
93
-     * @param int|null $rating
94
-     * @return string
95
-     */
96
-    public function buildColumnRating($postId)
97
-    {
98
-        return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating')));
99
-    }
91
+	/**
92
+	 * @param int $postId
93
+	 * @param int|null $rating
94
+	 * @return string
95
+	 */
96
+	public function buildColumnRating($postId)
97
+	{
98
+		return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating')));
99
+	}
100 100
 
101
-    /**
102
-     * @param int $postId
103
-     * @return string
104
-     */
105
-    public function buildColumnReviewType($postId)
106
-    {
107
-        $type = glsr(Database::class)->get($postId, 'review_type');
108
-        return array_key_exists($type, glsr()->reviewTypes)
109
-            ? glsr()->reviewTypes[$type]
110
-            : __('Unsupported Type', 'site-reviews');
111
-    }
101
+	/**
102
+	 * @param int $postId
103
+	 * @return string
104
+	 */
105
+	public function buildColumnReviewType($postId)
106
+	{
107
+		$type = glsr(Database::class)->get($postId, 'review_type');
108
+		return array_key_exists($type, glsr()->reviewTypes)
109
+			? glsr()->reviewTypes[$type]
110
+			: __('Unsupported Type', 'site-reviews');
111
+	}
112 112
 
113
-    /**
114
-     * @param string $postType
115
-     * @return void
116
-     */
117
-    public function renderFilters($postType)
118
-    {
119
-        if (Application::POST_TYPE !== $postType) {
120
-            return;
121
-        }
122
-        if (!($status = filter_input(INPUT_GET, 'post_status'))) {
123
-            $status = 'publish';
124
-        }
125
-        $ratings = glsr(Database::class)->getReviewsMeta('rating', $status);
126
-        $types = glsr(Database::class)->getReviewsMeta('review_type', $status);
127
-        $this->renderFilterRatings($ratings);
128
-        $this->renderFilterTypes($types);
129
-    }
113
+	/**
114
+	 * @param string $postType
115
+	 * @return void
116
+	 */
117
+	public function renderFilters($postType)
118
+	{
119
+		if (Application::POST_TYPE !== $postType) {
120
+			return;
121
+		}
122
+		if (!($status = filter_input(INPUT_GET, 'post_status'))) {
123
+			$status = 'publish';
124
+		}
125
+		$ratings = glsr(Database::class)->getReviewsMeta('rating', $status);
126
+		$types = glsr(Database::class)->getReviewsMeta('review_type', $status);
127
+		$this->renderFilterRatings($ratings);
128
+		$this->renderFilterTypes($types);
129
+	}
130 130
 
131
-    /**
132
-     * @param string $column
133
-     * @param int $postId
134
-     * @return void
135
-     */
136
-    public function renderValues($column, $postId)
137
-    {
138
-        $method = Helper::buildMethodName($column, 'buildColumn');
139
-        $value = method_exists($this, $method)
140
-            ? call_user_func([$this, $method], $postId)
141
-            : '';
142
-        $value = apply_filters('site-reviews/columns/'.$column, $value, $postId);
143
-        if (0 !== $value && empty($value)) {
144
-            $value = '—';
145
-        }
146
-        echo $value;
147
-    }
131
+	/**
132
+	 * @param string $column
133
+	 * @param int $postId
134
+	 * @return void
135
+	 */
136
+	public function renderValues($column, $postId)
137
+	{
138
+		$method = Helper::buildMethodName($column, 'buildColumn');
139
+		$value = method_exists($this, $method)
140
+			? call_user_func([$this, $method], $postId)
141
+			: '';
142
+		$value = apply_filters('site-reviews/columns/'.$column, $value, $postId);
143
+		if (0 !== $value && empty($value)) {
144
+			$value = '—';
145
+		}
146
+		echo $value;
147
+	}
148 148
 
149
-    /**
150
-     * @param array $ratings
151
-     * @return void
152
-     */
153
-    protected function renderFilterRatings($ratings)
154
-    {
155
-        if (empty($ratings)) {
156
-            return;
157
-        }
158
-        $ratings = array_flip(array_reverse($ratings));
159
-        array_walk($ratings, function (&$value, $key) {
160
-            $label = _n('%s star', '%s stars', $key, 'site-reviews');
161
-            $value = sprintf($label, $key);
162
-        });
163
-        echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [
164
-            'class' => 'screen-reader-text',
165
-            'for' => 'rating',
166
-        ]);
167
-        echo glsr(Builder::class)->select([
168
-            'name' => 'rating',
169
-            'options' => ['' => __('All ratings', 'site-reviews')] + $ratings,
170
-            'value' => filter_input(INPUT_GET, 'rating'),
171
-        ]);
172
-    }
149
+	/**
150
+	 * @param array $ratings
151
+	 * @return void
152
+	 */
153
+	protected function renderFilterRatings($ratings)
154
+	{
155
+		if (empty($ratings)) {
156
+			return;
157
+		}
158
+		$ratings = array_flip(array_reverse($ratings));
159
+		array_walk($ratings, function (&$value, $key) {
160
+			$label = _n('%s star', '%s stars', $key, 'site-reviews');
161
+			$value = sprintf($label, $key);
162
+		});
163
+		echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [
164
+			'class' => 'screen-reader-text',
165
+			'for' => 'rating',
166
+		]);
167
+		echo glsr(Builder::class)->select([
168
+			'name' => 'rating',
169
+			'options' => ['' => __('All ratings', 'site-reviews')] + $ratings,
170
+			'value' => filter_input(INPUT_GET, 'rating'),
171
+		]);
172
+	}
173 173
 
174
-    /**
175
-     * @param array $types
176
-     * @return void
177
-     */
178
-    protected function renderFilterTypes($types)
179
-    {
180
-        if (count(glsr()->reviewTypes) < 2) {
181
-            return;
182
-        }
183
-        echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [
184
-            'class' => 'screen-reader-text',
185
-            'for' => 'review_type',
186
-        ]);
187
-        echo glsr(Builder::class)->select([
188
-            'name' => 'review_type',
189
-            'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes,
190
-            'value' => filter_input(INPUT_GET, 'review_type'),
191
-        ]);
192
-    }
174
+	/**
175
+	 * @param array $types
176
+	 * @return void
177
+	 */
178
+	protected function renderFilterTypes($types)
179
+	{
180
+		if (count(glsr()->reviewTypes) < 2) {
181
+			return;
182
+		}
183
+		echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [
184
+			'class' => 'screen-reader-text',
185
+			'for' => 'review_type',
186
+		]);
187
+		echo glsr(Builder::class)->select([
188
+			'name' => 'review_type',
189
+			'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes,
190
+			'value' => filter_input(INPUT_GET, 'review_type'),
191
+		]);
192
+	}
193 193
 }
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
      * @param int $postId
15 15
      * @return void|string
16 16
      */
17
-    public function buildColumnAssignedTo($postId)
17
+    public function buildColumnAssignedTo( $postId )
18 18
     {
19
-        $assignedPost = glsr(Database::class)->getAssignedToPost($postId);
20
-        if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) {
21
-            return glsr(Builder::class)->a(get_the_title($assignedPost->ID), [
22
-                'href' => (string) get_the_permalink($assignedPost->ID),
23
-            ]);
19
+        $assignedPost = glsr( Database::class )->getAssignedToPost( $postId );
20
+        if( $assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status ) {
21
+            return glsr( Builder::class )->a( get_the_title( $assignedPost->ID ), [
22
+                'href' => (string)get_the_permalink( $assignedPost->ID ),
23
+            ] );
24 24
         }
25 25
     }
26 26
 
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
      * @param int $postId
29 29
      * @return void|string
30 30
      */
31
-    public function buildColumnEmail($postId)
31
+    public function buildColumnEmail( $postId )
32 32
     {
33
-        if ($email = glsr(Database::class)->get($postId, 'email')) {
33
+        if( $email = glsr( Database::class )->get( $postId, 'email' ) ) {
34 34
             return $email;
35 35
         }
36 36
     }
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
      * @param int $postId
40 40
      * @return void|string
41 41
      */
42
-    public function buildColumnIpAddress($postId)
42
+    public function buildColumnIpAddress( $postId )
43 43
     {
44
-        if ($ipAddress = glsr(Database::class)->get($postId, 'ip_address')) {
44
+        if( $ipAddress = glsr( Database::class )->get( $postId, 'ip_address' ) ) {
45 45
             return $ipAddress;
46 46
         }
47 47
     }
@@ -50,41 +50,41 @@  discard block
 block discarded – undo
50 50
      * @param int $postId
51 51
      * @return string
52 52
      */
53
-    public function buildColumnPinned($postId)
53
+    public function buildColumnPinned( $postId )
54 54
     {
55
-        $pinned = glsr(Database::class)->get($postId, 'pinned')
55
+        $pinned = glsr( Database::class )->get( $postId, 'pinned' )
56 56
             ? 'pinned '
57 57
             : '';
58
-        if (glsr()->can('edit_others_posts')) {
59
-            $pinned.= 'pin-review ';
58
+        if( glsr()->can( 'edit_others_posts' ) ) {
59
+            $pinned .= 'pin-review ';
60 60
         }
61
-        return glsr(Builder::class)->i([
61
+        return glsr( Builder::class )->i( [
62 62
             'class' => $pinned.'dashicons dashicons-sticky',
63 63
             'data-id' => $postId,
64
-        ]);
64
+        ] );
65 65
     }
66 66
 
67 67
     /**
68 68
      * @param int $postId
69 69
      * @return string
70 70
      */
71
-    public function buildColumnResponse($postId)
71
+    public function buildColumnResponse( $postId )
72 72
     {
73
-        return glsr(Database::class)->get($postId, 'response')
74
-            ? __('Yes', 'site-reviews')
75
-            : __('No', 'site-reviews');
73
+        return glsr( Database::class )->get( $postId, 'response' )
74
+            ? __( 'Yes', 'site-reviews' )
75
+            : __( 'No', 'site-reviews' );
76 76
     }
77 77
 
78 78
     /**
79 79
      * @param int $postId
80 80
      * @return string
81 81
      */
82
-    public function buildColumnReviewer($postId)
82
+    public function buildColumnReviewer( $postId )
83 83
     {
84
-        $author = strval(glsr(Database::class)->get($postId, 'author'));
85
-        $userId = Helper::castToInt(get_post($postId)->post_author);
84
+        $author = strval( glsr( Database::class )->get( $postId, 'author' ) );
85
+        $userId = Helper::castToInt( get_post( $postId )->post_author );
86 86
         return !empty($userId)
87
-            ? glsr(Builder::class)->a($author, ['href' => get_author_posts_url($userId)])
87
+            ? glsr( Builder::class )->a( $author, ['href' => get_author_posts_url( $userId )] )
88 88
             : $author;
89 89
     }
90 90
 
@@ -93,39 +93,39 @@  discard block
 block discarded – undo
93 93
      * @param int|null $rating
94 94
      * @return string
95 95
      */
96
-    public function buildColumnRating($postId)
96
+    public function buildColumnRating( $postId )
97 97
     {
98
-        return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating')));
98
+        return glsr_star_rating( intval( glsr( Database::class )->get( $postId, 'rating' ) ) );
99 99
     }
100 100
 
101 101
     /**
102 102
      * @param int $postId
103 103
      * @return string
104 104
      */
105
-    public function buildColumnReviewType($postId)
105
+    public function buildColumnReviewType( $postId )
106 106
     {
107
-        $type = glsr(Database::class)->get($postId, 'review_type');
108
-        return array_key_exists($type, glsr()->reviewTypes)
107
+        $type = glsr( Database::class )->get( $postId, 'review_type' );
108
+        return array_key_exists( $type, glsr()->reviewTypes )
109 109
             ? glsr()->reviewTypes[$type]
110
-            : __('Unsupported Type', 'site-reviews');
110
+            : __( 'Unsupported Type', 'site-reviews' );
111 111
     }
112 112
 
113 113
     /**
114 114
      * @param string $postType
115 115
      * @return void
116 116
      */
117
-    public function renderFilters($postType)
117
+    public function renderFilters( $postType )
118 118
     {
119
-        if (Application::POST_TYPE !== $postType) {
119
+        if( Application::POST_TYPE !== $postType ) {
120 120
             return;
121 121
         }
122
-        if (!($status = filter_input(INPUT_GET, 'post_status'))) {
122
+        if( !($status = filter_input( INPUT_GET, 'post_status' )) ) {
123 123
             $status = 'publish';
124 124
         }
125
-        $ratings = glsr(Database::class)->getReviewsMeta('rating', $status);
126
-        $types = glsr(Database::class)->getReviewsMeta('review_type', $status);
127
-        $this->renderFilterRatings($ratings);
128
-        $this->renderFilterTypes($types);
125
+        $ratings = glsr( Database::class )->getReviewsMeta( 'rating', $status );
126
+        $types = glsr( Database::class )->getReviewsMeta( 'review_type', $status );
127
+        $this->renderFilterRatings( $ratings );
128
+        $this->renderFilterTypes( $types );
129 129
     }
130 130
 
131 131
     /**
@@ -133,14 +133,14 @@  discard block
 block discarded – undo
133 133
      * @param int $postId
134 134
      * @return void
135 135
      */
136
-    public function renderValues($column, $postId)
136
+    public function renderValues( $column, $postId )
137 137
     {
138
-        $method = Helper::buildMethodName($column, 'buildColumn');
139
-        $value = method_exists($this, $method)
140
-            ? call_user_func([$this, $method], $postId)
138
+        $method = Helper::buildMethodName( $column, 'buildColumn' );
139
+        $value = method_exists( $this, $method )
140
+            ? call_user_func( [$this, $method], $postId )
141 141
             : '';
142
-        $value = apply_filters('site-reviews/columns/'.$column, $value, $postId);
143
-        if (0 !== $value && empty($value)) {
142
+        $value = apply_filters( 'site-reviews/columns/'.$column, $value, $postId );
143
+        if( 0 !== $value && empty($value) ) {
144 144
             $value = '&mdash;';
145 145
         }
146 146
         echo $value;
@@ -150,44 +150,44 @@  discard block
 block discarded – undo
150 150
      * @param array $ratings
151 151
      * @return void
152 152
      */
153
-    protected function renderFilterRatings($ratings)
153
+    protected function renderFilterRatings( $ratings )
154 154
     {
155
-        if (empty($ratings)) {
155
+        if( empty($ratings) ) {
156 156
             return;
157 157
         }
158
-        $ratings = array_flip(array_reverse($ratings));
159
-        array_walk($ratings, function (&$value, $key) {
160
-            $label = _n('%s star', '%s stars', $key, 'site-reviews');
161
-            $value = sprintf($label, $key);
158
+        $ratings = array_flip( array_reverse( $ratings ) );
159
+        array_walk( $ratings, function( &$value, $key ) {
160
+            $label = _n( '%s star', '%s stars', $key, 'site-reviews' );
161
+            $value = sprintf( $label, $key );
162 162
         });
163
-        echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [
163
+        echo glsr( Builder::class )->label( __( 'Filter by rating', 'site-reviews' ), [
164 164
             'class' => 'screen-reader-text',
165 165
             'for' => 'rating',
166
-        ]);
167
-        echo glsr(Builder::class)->select([
166
+        ] );
167
+        echo glsr( Builder::class )->select( [
168 168
             'name' => 'rating',
169
-            'options' => ['' => __('All ratings', 'site-reviews')] + $ratings,
170
-            'value' => filter_input(INPUT_GET, 'rating'),
171
-        ]);
169
+            'options' => ['' => __( 'All ratings', 'site-reviews' )] + $ratings,
170
+            'value' => filter_input( INPUT_GET, 'rating' ),
171
+        ] );
172 172
     }
173 173
 
174 174
     /**
175 175
      * @param array $types
176 176
      * @return void
177 177
      */
178
-    protected function renderFilterTypes($types)
178
+    protected function renderFilterTypes( $types )
179 179
     {
180
-        if (count(glsr()->reviewTypes) < 2) {
180
+        if( count( glsr()->reviewTypes ) < 2 ) {
181 181
             return;
182 182
         }
183
-        echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [
183
+        echo glsr( Builder::class )->label( __( 'Filter by type', 'site-reviews' ), [
184 184
             'class' => 'screen-reader-text',
185 185
             'for' => 'review_type',
186
-        ]);
187
-        echo glsr(Builder::class)->select([
186
+        ] );
187
+        echo glsr( Builder::class )->select( [
188 188
             'name' => 'review_type',
189
-            'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes,
190
-            'value' => filter_input(INPUT_GET, 'review_type'),
191
-        ]);
189
+            'options' => ['' => __( 'All types', 'site-reviews' )] + glsr()->reviewTypes,
190
+            'value' => filter_input( INPUT_GET, 'review_type' ),
191
+        ] );
192 192
     }
193 193
 }
Please login to merge, or discard this patch.