Passed
Push — master ( c272a3...f1c4a0 )
by Paul
07:09
created
plugin/Commands/TogglePinned.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 	public function __construct( $input )
11 11
 	{
12 12
 		$this->id = $input['id'];
13
-		$this->pinned = isset( $input['pinned'] )
13
+		$this->pinned = isset($input['pinned'])
14 14
 			? wp_validate_boolean( $input['pinned'] )
15 15
 			: null;
16 16
 	}
Please login to merge, or discard this patch.
plugin/Database/QueryBuilder.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@  discard block
 block discarded – undo
16 16
 	{
17 17
 		$queries = [];
18 18
 		foreach( $keys as $key ) {
19
-			if( !array_key_exists( $key, $values ))continue;
19
+			if( !array_key_exists( $key, $values ) )continue;
20 20
 			$methodName = glsr( Helper::class )->buildMethodName( $key, $prefix = __METHOD__ );
21
-			if( !method_exists( $this, $methodName ))continue;
21
+			if( !method_exists( $this, $methodName ) )continue;
22 22
 			$query = call_user_func( [$this, $methodName], $values[$key] );
23
-			if( is_array( $query )) {
23
+			if( is_array( $query ) ) {
24 24
 				$queries[] = $query;
25 25
 			}
26 26
 		}
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public function buildSqlOr( $values, $sprintfFormat )
37 37
 	{
38
-		if( !is_array( $values )) {
38
+		if( !is_array( $values ) ) {
39 39
 			$values = explode( ',', $values );
40 40
 		}
41
-		$values = array_filter( array_map( 'trim', (array)$values ));
42
-		$values = array_map( function( $value ) use( $sprintfFormat ) {
41
+		$values = array_filter( array_map( 'trim', (array)$values ) );
42
+		$values = array_map( function( $value ) use($sprintfFormat) {
43 43
 			return sprintf( $sprintfFormat, $value );
44 44
 		}, $values );
45 45
 		return implode( ' OR ', $values );
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public function filterSearchByTitle( $search, WP_Query $query )
56 56
 	{
57
-		if( empty( $search ) || empty( $query->get( 'search_terms' ))) {
57
+		if( empty($search) || empty($query->get( 'search_terms' )) ) {
58 58
 			return $search;
59 59
 		}
60 60
 		global $wpdb;
61
-		$n = empty( $query->get( 'exact' ))
61
+		$n = empty($query->get( 'exact' ))
62 62
 			? '%'
63 63
 			: '';
64 64
 		$search = [];
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	public function getPaged( $isEnabled = true )
80 80
 	{
81 81
 		$paged = $isEnabled
82
-			? intval( get_query_var( is_front_page() ? 'page' : Application::PAGED_QUERY_VAR ))
82
+			? intval( get_query_var( is_front_page() ? 'page' : Application::PAGED_QUERY_VAR ) )
83 83
 			: 1;
84 84
 		return max( 1, $paged );
85 85
 	}
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	protected function buildQueryAssignedTo( $value )
92 92
 	{
93
-		if( empty( $value ))return;
93
+		if( empty($value) )return;
94 94
 		return [
95 95
 			'compare' => 'IN',
96 96
 			'key' => 'assigned_to',
97
-			'value' => array_filter( array_map( 'trim', explode( ',', $value )), 'is_numeric' ),
97
+			'value' => array_filter( array_map( 'trim', explode( ',', $value ) ), 'is_numeric' ),
98 98
 		];
99 99
 	}
100 100
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	protected function buildQueryCategory( $value )
106 106
 	{
107
-		if( empty( $value ))return;
107
+		if( empty($value) )return;
108 108
 		return [
109 109
 			'field' => 'term_id',
110 110
 			'taxonomy' => Application::TAXONOMY,
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	protected function buildQueryRating( $value )
120 120
 	{
121
-		if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 )))return;
121
+		if( !is_numeric( $value ) || !in_array( intval( $value ), range( 1, 5 ) ) )return;
122 122
 		return [
123 123
 			'compare' => '>=',
124 124
 			'key' => 'rating',
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 */
133 133
 	protected function buildQueryType( $value )
134 134
 	{
135
-		if( in_array( $value, ['','all'] ))return;
135
+		if( in_array( $value, ['', 'all'] ) )return;
136 136
 		return [
137 137
 			'key' => 'review_type',
138 138
 			'value' => $value,
Please login to merge, or discard this patch.
plugin/Defaults/CreateReviewDefaults.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
 			'author' => '',
17 17
 			'avatar' => '',
18 18
 			'content' => '',
19
-			'date' => get_date_from_gmt( gmdate( 'Y-m-d H:i:s' )),
19
+			'date' => get_date_from_gmt( gmdate( 'Y-m-d H:i:s' ) ),
20 20
 			'email' => '',
21 21
 			'ip_address' => '',
22 22
 			'pinned' => false,
Please login to merge, or discard this patch.
activate.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public static function isPhpValid( $version = '' )
34 34
 	{
35
-		if( !empty( $version )) {
36
-			static::normalize( array( 'php' => $version ));
35
+		if( !empty($version) ) {
36
+			static::normalize( array( 'php' => $version ) );
37 37
 		}
38 38
 		return !version_compare( PHP_VERSION, static::$versions->php, '<' );
39 39
 	}
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public static function isValid( array $args = array() )
45 45
 	{
46
-		if( !empty( $args )) {
46
+		if( !empty($args) ) {
47 47
 			static::normalize( $args );
48 48
 		}
49 49
 		return static::isPhpValid() && static::isWpValid();
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	public static function isWpValid( $version = '' )
57 57
 	{
58 58
 		global $wp_version;
59
-		if( !empty( $version )) {
60
-			static::normalize( array( 'wordpress' => $version ));
59
+		if( !empty($version) ) {
60
+			static::normalize( array( 'wordpress' => $version ) );
61 61
 		}
62 62
 		return !version_compare( $wp_version, static::$versions->wordpress, '<' );
63 63
 	}
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public static function shouldDeactivate( $file, array $args = array() )
70 70
 	{
71
-		if( empty( static::$instance )) {
71
+		if( empty(static::$instance) ) {
72 72
 			static::$file = realpath( $file );
73 73
 			static::$instance = new static;
74 74
 			static::$versions = static::normalize( $args );
75 75
 		}
76 76
 		if( !static::isValid() ) {
77
-			add_action( 'activated_plugin', array( static::$instance, 'deactivate' ));
78
-			add_action( 'admin_notices', array( static::$instance, 'deactivate' ));
77
+			add_action( 'activated_plugin', array( static::$instance, 'deactivate' ) );
78
+			add_action( 'admin_notices', array( static::$instance, 'deactivate' ) );
79 79
 			return true;
80 80
 		}
81 81
 		return false;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		return (object)wp_parse_args( $args, array(
106 106
 			'php' => static::MIN_PHP_VERSION,
107 107
 			'wordpress' => static::MIN_WORDPRESS_VERSION,
108
-		));
108
+		) );
109 109
 	}
110 110
 
111 111
 	/**
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 			filter_input( INPUT_GET, 'plugin_status' ),
118 118
 			filter_input( INPUT_GET, 'paged' ),
119 119
 			filter_input( INPUT_GET, 's' )
120
-		)));
120
+		) ) );
121 121
 		exit;
122 122
 	}
123 123
 
Please login to merge, or discard this patch.
plugin/Shortcodes/ButtonGenerator.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 			'label' => '['.$tag.']',
48 48
 			'required' => $this->required,
49 49
 			'title' => esc_html__( 'Shortcode', 'site-reviews' ),
50
-		]);
50
+		] );
51 51
 		return $this;
52 52
 	}
53 53
 
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 	protected function generateFields( array $fields )
58 58
 	{
59 59
 		$generatedFields = array_map( function( $field ) {
60
-			if( empty( $field ))return;
60
+			if( empty($field) )return;
61 61
 			$field = $this->normalize( $field );
62
-			if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] )))return;
62
+			if( !method_exists( $this, $method = 'normalize'.ucfirst( $field['type'] ) ) )return;
63 63
 			return $this->$method( $field );
64 64
 		}, $fields );
65
-		return array_values( array_filter( $generatedFields ));
65
+		return array_values( array_filter( $generatedFields ) );
66 66
 	}
67 67
 
68 68
 	/**
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
 	protected function getFields()
72 72
 	{
73 73
 		$fields = $this->generateFields( $this->fields() );
74
-		if( !empty( $this->errors )) {
74
+		if( !empty($this->errors) ) {
75 75
 			$errors = [];
76 76
 			foreach( $this->required as $name => $alert ) {
77
-				if( false !== array_search( $name, array_column( $fields, 'name' )))continue;
77
+				if( false !== array_search( $name, array_column( $fields, 'name' ) ) )continue;
78 78
 				$errors[] = $this->errors[$name];
79 79
 			}
80 80
 			$this->errors = $errors;
81 81
 		}
82
-		return empty( $this->errors )
82
+		return empty($this->errors)
83 83
 			? $fields
84 84
 			: $this->errors;
85 85
 	}
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		return wp_parse_args( $field, [
93 93
 			'items' => [],
94 94
 			'type' => '',
95
-		]);
95
+		] );
96 96
 	}
97 97
 
98 98
 	/**
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 			'tooltip' => '',
111 111
 			'type' => '',
112 112
 			'value' => '',
113
-		]);
113
+		] );
114 114
 	}
115 115
 
116 116
 	/**
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	protected function normalizeContainer( array $field )
120 120
 	{
121
-		if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ))return;
121
+		if( !array_key_exists( 'html', $field ) && !array_key_exists( 'items', $field ) )return;
122 122
 		$field['items'] = $this->generateFields( $field['items'] );
123 123
 		return $field;
124 124
 	}
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	protected function normalizeField( array $field, array $defaults )
130 130
 	{
131
-		if( !$this->validate( $field ))return;
131
+		if( !$this->validate( $field ) )return;
132 132
 		return array_filter( shortcode_atts( $defaults, $field ), function( $value ) {
133 133
 			return $value !== '';
134 134
 		});
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
 			'tooltip' => '',
149 149
 			'type' => '',
150 150
 			'value' => '',
151
-		]);
152
-		if( !is_array( $listbox ))return;
153
-		if( !array_key_exists( '', $listbox['options'] )) {
151
+		] );
152
+		if( !is_array( $listbox ) )return;
153
+		if( !array_key_exists( '', $listbox['options'] ) ) {
154 154
 			$listbox['options'] = ['' => $listbox['placeholder']] + $listbox['options'];
155 155
 		}
156 156
 		foreach( $listbox['options'] as $value => $text ) {
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	protected function normalizePost( array $field )
169 169
 	{
170
-		if( !is_array( $field['query_args'] )) {
170
+		if( !is_array( $field['query_args'] ) ) {
171 171
 			$field['query_args'] = [];
172 172
 		}
173 173
 		$posts = get_posts( wp_parse_args( $field['query_args'], [
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 			'orderby' => 'title',
176 176
 			'post_type' => 'post',
177 177
 			'posts_per_page' => 30,
178
-		]));
179
-		if( !empty( $posts )) {
178
+		] ) );
179
+		if( !empty($posts) ) {
180 180
 			$options = [];
181 181
 			foreach( $posts as $post ) {
182 182
 				$options[$post->ID] = esc_html( $post->post_title );
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 			'tooltip' => '',
207 207
 			'type' => '',
208 208
 			'value' => '',
209
-		]);
209
+		] );
210 210
 	}
211 211
 
212 212
 	/**
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	protected function validate( array $field )
216 216
 	{
217
-		$args = shortcode_atts([
217
+		$args = shortcode_atts( [
218 218
 			'label' => '',
219 219
 			'name' => false,
220 220
 			'required' => false,
@@ -230,13 +230,13 @@  discard block
 block discarded – undo
230 230
 	 */
231 231
 	protected function validateErrors( array $args )
232 232
 	{
233
-		if( !isset( $args['required']['error'] )) {
233
+		if( !isset($args['required']['error']) ) {
234 234
 			return true;
235 235
 		}
236
-		$this->errors[$args['name']] = $this->normalizeContainer([
236
+		$this->errors[$args['name']] = $this->normalizeContainer( [
237 237
 			'html' => $args['required']['error'],
238 238
 			'type' => 'container',
239
-		]);
239
+		] );
240 240
 		return false;
241 241
 	}
242 242
 
@@ -249,10 +249,10 @@  discard block
 block discarded – undo
249 249
 			return true;
250 250
 		}
251 251
 		$alert = esc_html__( 'Some of the shortcode options are required.', 'site-reviews' );
252
-		if( isset( $args['required']['alert'] )) {
252
+		if( isset($args['required']['alert']) ) {
253 253
 			$alert = $args['required']['alert'];
254 254
 		}
255
-		else if( !empty( $args['label'] )) {
255
+		else if( !empty($args['label']) ) {
256 256
 			$alert = sprintf(
257 257
 				esc_html_x( 'The "%s" option is required.', 'the option label', 'site-reviews' ),
258 258
 				str_replace( ':', '', $args['label'] )
Please login to merge, or discard this patch.
plugin/Modules/Date.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 		$diff = time() - strtotime( $date );
32 32
 		foreach( static::$TIME_PERIODS as $i => $timePeriod ) {
33 33
 			if( $diff > $timePeriod[0] )continue;
34
-			$unit = intval( floor( $diff / $timePeriod[1] ));
34
+			$unit = intval( floor( $diff / $timePeriod[1] ) );
35 35
 			$relativeDates = [
36 36
 				_n( '%s second ago', '%s seconds ago', $unit, 'site-reviews' ),
37 37
 				_n( '%s minute ago', '%s minutes ago', $unit, 'site-reviews' ),
Please login to merge, or discard this patch.
plugin/Modules/Upgrader.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 		natsort( $routines );
17 17
 		array_walk( $routines, function( $routine ) {
18 18
 			$version = str_replace( strtolower( __CLASS__ ).'_', '', $routine );
19
-			if( version_compare( glsr()->version, $version, '>=' ))return;
19
+			if( version_compare( glsr()->version, $version, '>=' ) )return;
20 20
 			call_user_func( [$this, $routine] );
21 21
 		});
22 22
 		$this->updateVersion();
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	public function updateVersion()
29 29
 	{
30 30
 		$currentVersion = glsr( OptionManager::class )->get( 'version' );
31
-		if( version_compare( $currentVersion, glsr()->version, '<' )) {
31
+		if( version_compare( $currentVersion, glsr()->version, '<' ) ) {
32 32
 			glsr( OptionManager::class )->set( 'version', glsr()->version );
33 33
 		}
34 34
 		if( $currentVersion != glsr()->version ) {
Please login to merge, or discard this patch.
plugin/Modules/Editor/Customization.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
 	 */
58 58
 	protected function isReviewEditable()
59 59
 	{
60
-		$postId = intval( filter_input( INPUT_GET, 'post' ));
60
+		$postId = intval( filter_input( INPUT_GET, 'post' ) );
61 61
 		return $postId > 0
62 62
 			&& get_post_meta( $postId, 'review_type', true ) == 'local'
63 63
 			&& $this->isReviewEditor();
Please login to merge, or discard this patch.
plugin/Modules/Editor/Metaboxes.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 */
23 23
 	public function onCreateReview( $postData, $meta, $postId )
24 24
 	{
25
-		if( !$this->isReviewPostType( $review = get_post( $postId )))return;
25
+		if( !$this->isReviewPostType( $review = get_post( $postId ) ) )return;
26 26
 		$this->updateAssignedToPost( $review );
27 27
 	}
28 28
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 */
33 33
 	public function onDeleteReview( $postId )
34 34
 	{
35
-		if( !$this->isReviewPostType( $review = get_post( $postId )))return;
35
+		if( !$this->isReviewPostType( $review = get_post( $postId ) ) )return;
36 36
 		$review->post_status = 'deleted'; // important to change the post_status here first!
37 37
 		$this->updateAssignedToPost( $review );
38 38
 	}
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function saveAssignedToMetabox( $postId )
54 54
 	{
55
-		if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' ))return;
55
+		if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-assigned-to' ), 'assigned_to' ) )return;
56 56
 		$assignedTo = filter_input( INPUT_POST, 'assigned_to' );
57 57
 		$assignedTo || $assignedTo = '';
58 58
 		if( get_post_meta( $postId, 'assigned_to', true ) != $assignedTo ) {
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	public function saveResponseMetabox( $postId )
69 69
 	{
70
-		if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' ))return;
70
+		if( !wp_verify_nonce( filter_input( INPUT_POST, '_nonce-response' ), 'response' ) )return;
71 71
 		$response = filter_input( INPUT_POST, 'response' );
72 72
 		$response || $response = '';
73 73
 		update_post_meta( $postId, 'response', trim( wp_kses( $response, [
74 74
 			'a' => ['href' => [], 'title' => []],
75 75
 			'em' => [],
76 76
 			'strong' => [],
77
-		])));
77
+		] ) ) );
78 78
 	}
79 79
 
80 80
 	/**
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	protected function getAssignedToPostId( $postId )
85 85
 	{
86
-		$assignedTo = intval( get_post_meta( $postId, 'assigned_to', true ));
87
-		if(( $post = get_post( $assignedTo )) instanceof WP_Post ) {
86
+		$assignedTo = intval( get_post_meta( $postId, 'assigned_to', true ) );
87
+		if( ($post = get_post( $assignedTo )) instanceof WP_Post ) {
88 88
 			return $post->ID;
89 89
 		}
90 90
 		return false;
@@ -120,22 +120,22 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	protected function updateAssignedToPost( WP_Post $review )
122 122
 	{
123
-		if( !( $postId = $this->getAssignedToPostId( $review->ID )))return;
124
-		$reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ));
125
-		if( empty( $reviewIds ))return;
123
+		if( !($postId = $this->getAssignedToPostId( $review->ID )) )return;
124
+		$reviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ) );
125
+		if( empty($reviewIds) )return;
126 126
 		$this->updateReviewIdOfPost( $postId, $review, $reviewIds );
127
-		$updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ));
128
-		if( empty( $updatedReviewIds )) {
127
+		$updatedReviewIds = array_filter( (array)get_post_meta( $postId, static::META_REVIEW_ID ) );
128
+		if( empty($updatedReviewIds) ) {
129 129
 			delete_post_meta( $postId, static::META_RANKING );
130 130
 			delete_post_meta( $postId, static::META_REVIEW_ID );
131 131
 		}
132
-		else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds )) {
133
-			$reviews = glsr( Database::class )->getReviews([
132
+		else if( !glsr( Helper::class )->compareArrays( $reviewIds, $updatedReviewIds ) ) {
133
+			$reviews = glsr( Database::class )->getReviews( [
134 134
 				'count' => -1,
135 135
 				'post__in' => $updatedReviewIds,
136
-			]);
137
-			update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $reviews->results ));
138
-			update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $reviews->results ));
136
+			] );
137
+			update_post_meta( $postId, static::META_AVERAGE, $this->recalculatePostAverage( $reviews->results ) );
138
+			update_post_meta( $postId, static::META_RANKING, $this->recalculatePostRanking( $reviews->results ) );
139 139
 		}
140 140
 	}
141 141
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		if( $review->post_status != 'publish' ) {
149 149
 			delete_post_meta( $postId, static::META_REVIEW_ID, $review->ID );
150 150
 		}
151
-		else if( !in_array( $review->ID, $reviewIds )) {
151
+		else if( !in_array( $review->ID, $reviewIds ) ) {
152 152
 			add_post_meta( $postId, static::META_REVIEW_ID, $review->ID );
153 153
 		}
154 154
 	}
Please login to merge, or discard this patch.