Passed
Push — develop ( 37b65a...9b346b )
by Paul
03:39
created
src/PostType/Archive.php 3 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	 */
15 15
 	CONST ID = 'archives';
16 16
 
17
-	public $hooks = [];
17
+	public $hooks = [ ];
18 18
 
19 19
 	/**
20 20
 	 * {@inheritdoc}
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 	{
24 24
 		parent::init();
25 25
 
26
-		add_action( 'pollux/archives/init',              [$this, 'registerFeaturedImageMetaBox'] );
27
-		add_action( 'pollux/archives/editor',            [$this, 'renderEditor'], 10, 2 );
28
-		add_filter( 'pollux/archives/metabox/submit',    [$this, 'filterSubmitMetaBox'] );
26
+		add_action( 'pollux/archives/init', [ $this, 'registerFeaturedImageMetaBox' ] );
27
+		add_action( 'pollux/archives/editor', [ $this, 'renderEditor' ], 10, 2 );
28
+		add_filter( 'pollux/archives/metabox/submit', [ $this, 'filterSubmitMetaBox' ] );
29 29
 		add_filter( 'pollux/archives/show/instructions', '__return_true' );
30 30
 	}
31 31
 
@@ -36,15 +36,15 @@  discard block
 block discarded – undo
36 36
 	public function addPage()
37 37
 	{
38 38
 		foreach( $this->getPostTypesWithArchive() as $type => $page ) {
39
-			$labels = get_post_type_labels( get_post_type_object( $type ));
40
-			$this->hooks[$type] = call_user_func_array( 'add_submenu_page', $this->filter( 'page', [
39
+			$labels = get_post_type_labels( get_post_type_object( $type ) );
40
+			$this->hooks[ $type ] = call_user_func_array( 'add_submenu_page', $this->filter( 'page', [
41 41
 				$page,
42 42
 				sprintf( _x( '%s Archive', 'post archive', 'pollux' ), $labels->singular_name ),
43 43
 				__( 'Archive', 'pollux' ),
44 44
 				'edit_theme_options',
45 45
 				sprintf( '%s_archive', $type ),
46
-				[$this, 'renderPage'],
47
-			]));
46
+				[ $this, 'renderPage' ],
47
+			] ) );
48 48
 		}
49 49
 	}
50 50
 
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 	public function filterBeforeInstructions()
56 56
 	{
57 57
 		return sprintf( '<pre class="my-sites nav-tab-active misc-pub-section">%s</pre>',
58
-			array_reduce( ['title', 'content', 'featured'], function( $instructions, $id ) {
59
-				return $instructions . $this->filterInstruction( null, ['slug' => $id], ['slug' => $this->getPostType()] ) . PHP_EOL;
58
+			array_reduce( [ 'title', 'content', 'featured' ], function( $instructions, $id ) {
59
+				return $instructions . $this->filterInstruction( null, [ 'slug' => $id ], [ 'slug' => $this->getPostType() ] ) . PHP_EOL;
60 60
 			})
61 61
 		);
62 62
 	}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function filterInstruction( $instruction, array $field, array $metabox )
70 70
 	{
71
-		return sprintf( "ArchiveMeta::%s('%s');", $metabox['slug'], $field['slug'] );
71
+		return sprintf( "ArchiveMeta::%s('%s');", $metabox[ 'slug' ], $field[ 'slug' ] );
72 72
 	}
73 73
 
74 74
 	/**
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 */
78 78
 	public function filterSubmitMetaBox( array $args )
79 79
 	{
80
-		$args[1] = __( 'Save Archive', 'pollux' );
80
+		$args[ 1 ] = __( 'Save Archive', 'pollux' );
81 81
 		return $args;
82 82
 	}
83 83
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	public function register()
89 89
 	{
90 90
 		$screenId = ( new Helper )->getCurrentScreen()->id;
91
-		if( in_array( $screenId, $this->hooks )) {
91
+		if( in_array( $screenId, $this->hooks ) ) {
92 92
 			$this->hook = $screenId;
93 93
 		}
94 94
 		parent::register();
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	public function registerFeaturedImageMetaBox()
102 102
 	{
103
-		if( !current_user_can( 'upload_files' ))return;
104
-		add_meta_box( 'postimagediv', __( 'Featured Image', 'pollux' ), [$this, 'renderFeaturedImageMetaBox'], null, 'side', 'low' );
103
+		if( !current_user_can( 'upload_files' ) )return;
104
+		add_meta_box( 'postimagediv', __( 'Featured Image', 'pollux' ), [ $this, 'renderFeaturedImageMetaBox' ], null, 'side', 'low' );
105 105
 	}
106 106
 
107 107
 	/**
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 				'resize' => false,
122 122
 				'wp_autoresize_on' => true,
123 123
 			],
124
-		]);
124
+		] );
125 125
 	}
126 126
 
127 127
 	/**
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 	public function renderFeaturedImageMetaBox()
132 132
 	{
133 133
 		$imageId = ArchiveMeta::get( 'featured', -1, $this->getPostType() );
134
-		$imageSize = isset( wp_get_additional_image_sizes()['post-thumbnail'] )
134
+		$imageSize = isset( wp_get_additional_image_sizes()[ 'post-thumbnail' ] )
135 135
 			? 'post-thumbnail'
136
-			: [266, 266];
136
+			: [ 266, 266 ];
137 137
 		$thumbnail = get_post( $imageId )
138 138
 			? wp_get_attachment_image( $imageId, $imageSize )
139 139
 			: __( 'Set Featured Image', 'pollux' );
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 			'remove_image' => __( 'Remove featured image', 'pollux' ),
147 147
 			'thickbox_url' => '',
148 148
 			'thumbnail' => $thumbnail,
149
-		]);
149
+		] );
150 150
 	}
151 151
 
152 152
 	/**
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 	public function renderPage()
157 157
 	{
158 158
 		$type = $this->getPostType();
159
-		if( empty( $type ))return;
160
-		$labels = get_post_type_labels( get_post_type_object( $type ));
159
+		if( empty( $type ) )return;
160
+		$labels = get_post_type_labels( get_post_type_object( $type ) );
161 161
 		$this->render( 'archive/index', [
162 162
 			'columns' => get_current_screen()->get_columns(),
163 163
 			'content' => ArchiveMeta::get( 'content', '', $type ),
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 			'id' => static::id(),
166 166
 			'post_type' => $type,
167 167
 			'title' => ArchiveMeta::get( 'title', '', $type ),
168
-		]);
168
+		] );
169 169
 	}
170 170
 
171 171
 	/**
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	 */
174 174
 	protected function getDefaults()
175 175
 	{
176
-		return [];
176
+		return [ ];
177 177
 	}
178 178
 
179 179
 	/**
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
 	{
195 195
 		$types = array_map( function( $value ) {
196 196
 			return sprintf( 'edit.php?post_type=%s', $value );
197
-		}, get_post_types( ['has_archive' => 1] ));
198
-		return array_merge( $types, ['post' => 'edit.php'] );
197
+		}, get_post_types( [ 'has_archive' => 1 ] ) );
198
+		return array_merge( $types, [ 'post' => 'edit.php' ] );
199 199
 	}
200 200
 
201 201
 	/**
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -55,7 +55,8 @@  discard block
 block discarded – undo
55 55
 	public function filterBeforeInstructions()
56 56
 	{
57 57
 		return sprintf( '<pre class="my-sites nav-tab-active misc-pub-section">%s</pre>',
58
-			array_reduce( ['title', 'content', 'featured'], function( $instructions, $id ) {
58
+			array_reduce( ['title', 'content', 'featured'], function( $instructions, $id )
59
+			{
59 60
 				return $instructions . $this->filterInstruction( null, ['slug' => $id], ['slug' => $this->getPostType()] ) . PHP_EOL;
60 61
 			})
61 62
 		);
@@ -100,7 +101,9 @@  discard block
 block discarded – undo
100 101
 	 */
101 102
 	public function registerFeaturedImageMetaBox()
102 103
 	{
103
-		if( !current_user_can( 'upload_files' ))return;
104
+		if( !current_user_can( 'upload_files' )) {
105
+			return;
106
+		}
104 107
 		add_meta_box( 'postimagediv', __( 'Featured Image', 'pollux' ), [$this, 'renderFeaturedImageMetaBox'], null, 'side', 'low' );
105 108
 	}
106 109
 
@@ -156,7 +159,9 @@  discard block
 block discarded – undo
156 159
 	public function renderPage()
157 160
 	{
158 161
 		$type = $this->getPostType();
159
-		if( empty( $type ))return;
162
+		if( empty( $type )) {
163
+			return;
164
+		}
160 165
 		$labels = get_post_type_labels( get_post_type_object( $type ));
161 166
 		$this->render( 'archive/index', [
162 167
 			'columns' => get_current_screen()->get_columns(),
@@ -192,7 +197,8 @@  discard block
 block discarded – undo
192 197
 	 */
193 198
 	protected function getPostTypesWithArchive()
194 199
 	{
195
-		$types = array_map( function( $value ) {
200
+		$types = array_map( function( $value )
201
+		{
196 202
 			return sprintf( 'edit.php?post_type=%s', $value );
197 203
 		}, get_post_types( ['has_archive' => 1] ));
198 204
 		return array_merge( $types, ['post' => 'edit.php'] );
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
 	/**
13 13
 	 * @var string
14 14
 	 */
15
-	CONST ID = 'archives';
15
+	const ID = 'archives';
16 16
 
17 17
 	public $hooks = [];
18 18
 
Please login to merge, or discard this patch.
src/Settings/Settings.php 2 patches
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
 		// @todo: run GateKeeper to check dependencies and capability (make sure it it run on the correct hook!)
45 45
 		// if( !is_plugin_active( 'meta-box/meta-box.php' ))return;
46 46
 
47
-		$this->normalize( $this->app->config[static::ID] );
47
+		$this->normalize( $this->app->config[ static::ID ] );
48 48
 
49
-		add_action( 'admin_menu',                                [$this, 'addPage'] );
50
-		add_action( 'pollux/'.static::ID.'/init',                [$this, 'addSubmitMetaBox'] );
51
-		add_action( 'current_screen',                            [$this, 'register'] );
52
-		add_action( 'admin_menu',                                [$this, 'registerSetting'] );
53
-		add_action( 'pollux/'.static::ID.'/init',                [$this, 'reset'] );
54
-		add_action( 'admin_print_footer_scripts',                [$this, 'renderFooterScript'] );
55
-		add_filter( 'pollux/'.static::ID.'/instruction',         [$this, 'filterInstruction'], 10, 3 );
56
-		add_filter( 'pollux/'.static::ID.'/before/instructions', [$this, 'filterBeforeInstructions'] );
49
+		add_action( 'admin_menu', [ $this, 'addPage' ] );
50
+		add_action( 'pollux/' . static::ID . '/init', [ $this, 'addSubmitMetaBox' ] );
51
+		add_action( 'current_screen', [ $this, 'register' ] );
52
+		add_action( 'admin_menu', [ $this, 'registerSetting' ] );
53
+		add_action( 'pollux/' . static::ID . '/init', [ $this, 'reset' ] );
54
+		add_action( 'admin_print_footer_scripts', [ $this, 'renderFooterScript' ] );
55
+		add_filter( 'pollux/' . static::ID . '/instruction', [ $this, 'filterInstruction' ], 10, 3 );
56
+		add_filter( 'pollux/' . static::ID . '/before/instructions', [ $this, 'filterBeforeInstructions' ] );
57 57
 	}
58 58
 
59 59
 	/**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	public function action()
63 63
 	{
64 64
 		$args = func_get_args();
65
-		$hook = sprintf( 'pollux/%s/%s', static::ID, array_shift( $args ));
65
+		$hook = sprintf( 'pollux/%s/%s', static::ID, array_shift( $args ) );
66 66
 		return do_action_ref_array( $hook, $args );
67 67
 	}
68 68
 
@@ -77,10 +77,10 @@  discard block
 block discarded – undo
77 77
 			__( 'Site Settings', 'pollux' ),
78 78
 			'edit_theme_options',
79 79
 			static::id(),
80
-			[$this, 'renderPage'],
80
+			[ $this, 'renderPage' ],
81 81
 			'dashicons-screenoptions',
82 82
 			1313
83
-		]));
83
+		] ) );
84 84
 	}
85 85
 
86 86
 	/**
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 		call_user_func_array( 'add_meta_box', $this->filter( 'metabox/submit', [
93 93
 			'submitdiv',
94 94
 			__( 'Save Settings', 'pollux' ),
95
-			[$this, 'renderSubmitMetaBox'],
95
+			[ $this, 'renderSubmitMetaBox' ],
96 96
 			$this->hook,
97 97
 			'side',
98 98
 			'high',
99
-		]));
99
+		] ) );
100 100
 	}
101 101
 
102 102
 	/**
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	public function filter()
106 106
 	{
107 107
 		$args = func_get_args();
108
-		$hook = sprintf( 'pollux/%s/%s', static::ID, array_shift( $args ));
108
+		$hook = sprintf( 'pollux/%s/%s', static::ID, array_shift( $args ) );
109 109
 		return apply_filters_ref_array( $hook, $args );
110 110
 	}
111 111
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function filterInstruction( $instruction, array $field, array $metabox )
127 127
 	{
128
-		return sprintf( "SiteMeta::%s('%s');", $metabox['slug'], $field['slug'] );
128
+		return sprintf( "SiteMeta::%s('%s');", $metabox[ 'slug' ], $field[ 'slug' ] );
129 129
 	}
130 130
 
131 131
 	/**
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	public function filterSavedSettings( $settings )
137 137
 	{
138
-		if( is_null( $settings )) {
139
-			$settings = [];
138
+		if( is_null( $settings ) ) {
139
+			$settings = [ ];
140 140
 		}
141
-		return $this->filter( 'save', array_merge( $settings, $this->getSettings() ));
141
+		return $this->filter( 'save', array_merge( $settings, $this->getSettings() ) );
142 142
 	}
143 143
 
144 144
 	/**
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function register()
149 149
 	{
150
-		if(( new Helper )->getCurrentScreen()->id != $this->hook )return;
150
+		if( ( new Helper )->getCurrentScreen()->id != $this->hook )return;
151 151
 		foreach( parent::register() as $metabox ) {
152 152
 			new RWMetaBox( $metabox, static::ID, $this->hook );
153 153
 		}
154 154
 		add_screen_option( 'layout_columns', [
155 155
 			'max' => 2,
156 156
 			'default' => 2,
157
-		]);
157
+		] );
158 158
 		$this->action( 'init' );
159 159
 	}
160 160
 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	public function registerSetting()
166 166
 	{
167
-		register_setting( static::id(), static::id(), [$this, 'filterSavedSettings'] );
167
+		register_setting( static::id(), static::id(), [ $this, 'filterSavedSettings' ] );
168 168
 	}
169 169
 
170 170
 	/**
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
 	 */
174 174
 	public function renderFooterScript()
175 175
 	{
176
-		if(( new Helper )->getCurrentScreen()->id != $this->hook )return;
176
+		if( ( new Helper )->getCurrentScreen()->id != $this->hook )return;
177 177
 		$this->render( 'settings/script', [
178 178
 			'confirm' => __( 'Are you sure want to do this?', 'pollux' ),
179 179
 			'hook' => $this->hook,
180 180
 			'id' => static::id(),
181
-		]);
181
+		] );
182 182
 	}
183 183
 
184 184
 	/**
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 			'columns' => get_current_screen()->get_columns(),
192 192
 			'heading' => __( 'Site Settings', 'pollux' ),
193 193
 			'id' => static::id(),
194
-		]);
194
+		] );
195 195
 	}
196 196
 
197 197
 	/**
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
 		];
209 209
 		$this->render( 'settings/submit', [
210 210
 			'reset' => __( 'Reset all', 'pollux' ),
211
-			'reset_url' => esc_url( add_query_arg( $query, admin_url( $pagenow ))),
211
+			'reset_url' => esc_url( add_query_arg( $query, admin_url( $pagenow ) ) ),
212 212
 			'submit' => get_submit_button( __( 'Save', 'pollux' ), 'primary', 'submit', false ),
213
-		]);
213
+		] );
214 214
 	}
215 215
 
216 216
 	/**
@@ -222,15 +222,15 @@  discard block
 block discarded – undo
222 222
 		if( filter_input( INPUT_GET, 'page' ) !== static::id()
223 223
 			|| filter_input( INPUT_GET, 'action' ) !== 'reset'
224 224
 		)return;
225
-		if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) {
225
+		if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook ) ) {
226 226
 			update_option( static::id(), $this->getDefaults() );
227 227
 			add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' );
228 228
 		}
229 229
 		else {
230
-			add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' ));
230
+			add_settings_error( static::id(), 'failed', __( 'Failed to reset. Please try again.', 'pollux' ) );
231 231
 		}
232 232
 		set_transient( 'settings_errors', get_settings_errors(), 30 );
233
-		wp_safe_redirect( add_query_arg( 'settings-updated', 'true',  wp_get_referer() ));
233
+		wp_safe_redirect( add_query_arg( 'settings-updated', 'true', wp_get_referer() ) );
234 234
 		exit;
235 235
 	}
236 236
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	protected function filterArrayByKey( array $array, $key )
242 242
 	{
243 243
 		return array_filter( $array, function( $value ) use( $key ) {
244
-			return !empty( $value[$key] );
244
+			return !empty( $value[ $key ] );
245 245
 		});
246 246
 	}
247 247
 
@@ -254,11 +254,11 @@  discard block
 block discarded – undo
254 254
 
255 255
 		array_walk( $metaboxes, function( &$metabox ) {
256 256
 			$fields = array_map( function( $field ) {
257
-				$field = wp_parse_args( $field, ['std' => ''] );
258
-				return [$field['slug'] => $field['std']];
259
-			}, $this->filterArrayByKey( $metabox['fields'], 'slug' ));
257
+				$field = wp_parse_args( $field, [ 'std' => '' ] );
258
+				return [ $field[ 'slug' ] => $field[ 'std' ] ];
259
+			}, $this->filterArrayByKey( $metabox[ 'fields' ], 'slug' ) );
260 260
 			$metabox = [
261
-				$metabox['slug'] => call_user_func_array( 'array_merge', $fields ),
261
+				$metabox[ 'slug' ] => call_user_func_array( 'array_merge', $fields ),
262 262
 			];
263 263
 		});
264 264
 		return call_user_func_array( 'array_merge', $metaboxes );
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 */
285 285
 	protected function normalizeFieldName( $name, array $data, $parentId )
286 286
 	{
287
-		return sprintf( '%s[%s][%s]', static::id(), $parentId, $data['slug'] );
287
+		return sprintf( '%s[%s][%s]', static::id(), $parentId, $data[ 'slug' ] );
288 288
 	}
289 289
 
290 290
 	/**
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -147,7 +147,9 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function register()
149 149
 	{
150
-		if(( new Helper )->getCurrentScreen()->id != $this->hook )return;
150
+		if(( new Helper )->getCurrentScreen()->id != $this->hook ) {
151
+			return;
152
+		}
151 153
 		foreach( parent::register() as $metabox ) {
152 154
 			new RWMetaBox( $metabox, static::ID, $this->hook );
153 155
 		}
@@ -173,7 +175,9 @@  discard block
 block discarded – undo
173 175
 	 */
174 176
 	public function renderFooterScript()
175 177
 	{
176
-		if(( new Helper )->getCurrentScreen()->id != $this->hook )return;
178
+		if(( new Helper )->getCurrentScreen()->id != $this->hook ) {
179
+			return;
180
+		}
177 181
 		$this->render( 'settings/script', [
178 182
 			'confirm' => __( 'Are you sure want to do this?', 'pollux' ),
179 183
 			'hook' => $this->hook,
@@ -221,7 +225,9 @@  discard block
 block discarded – undo
221 225
 	{
222 226
 		if( filter_input( INPUT_GET, 'page' ) !== static::id()
223 227
 			|| filter_input( INPUT_GET, 'action' ) !== 'reset'
224
-		)return;
228
+		) {
229
+			return;
230
+		}
225 231
 		if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) {
226 232
 			update_option( static::id(), $this->getDefaults() );
227 233
 			add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' );
@@ -240,7 +246,8 @@  discard block
 block discarded – undo
240 246
 	 */
241 247
 	protected function filterArrayByKey( array $array, $key )
242 248
 	{
243
-		return array_filter( $array, function( $value ) use( $key ) {
249
+		return array_filter( $array, function( $value ) use( $key )
250
+		{
244 251
 			return !empty( $value[$key] );
245 252
 		});
246 253
 	}
@@ -252,8 +259,10 @@  discard block
 block discarded – undo
252 259
 	{
253 260
 		$metaboxes = $this->filterArrayByKey( $this->metaboxes, 'slug' );
254 261
 
255
-		array_walk( $metaboxes, function( &$metabox ) {
256
-			$fields = array_map( function( $field ) {
262
+		array_walk( $metaboxes, function( &$metabox )
263
+		{
264
+			$fields = array_map( function( $field )
265
+			{
257 266
 				$field = wp_parse_args( $field, ['std' => ''] );
258 267
 				return [$field['slug'] => $field['std']];
259 268
 			}, $this->filterArrayByKey( $metabox['fields'], 'slug' ));
Please login to merge, or discard this patch.
src/MetaBox/MetaBox.php 2 patches
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -24,20 +24,20 @@  discard block
 block discarded – undo
24 24
 	/**
25 25
 	 * @var array
26 26
 	 */
27
-	public $metaboxes = [];
27
+	public $metaboxes = [ ];
28 28
 
29 29
 	/**
30 30
 	 * {@inheritdoc}
31 31
 	 */
32 32
 	public function init()
33 33
 	{
34
-		$this->normalize( $this->app->config[static::ID], [
35
-			'post_types' => [],
36
-		]);
34
+		$this->normalize( $this->app->config[ static::ID ], [
35
+			'post_types' => [ ],
36
+		] );
37 37
 
38
-		add_filter( 'rwmb_show',       [$this, 'show'], 10, 2 );
39
-		add_filter( 'rwmb_meta_boxes', [$this, 'register'] );
40
-		add_filter( 'rwmb_outer_html', [$this, 'renderField'], 10, 2 );
38
+		add_filter( 'rwmb_show', [ $this, 'show' ], 10, 2 );
39
+		add_filter( 'rwmb_meta_boxes', [ $this, 'register' ] );
40
+		add_filter( 'rwmb_outer_html', [ $this, 'renderField' ], 10, 2 );
41 41
 	}
42 42
 
43 43
 	/**
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	public function filter()
47 47
 	{
48 48
 		$args = func_get_args();
49
-		$hook = sprintf( 'pollux/%s/%s', strtolower(( new Helper )->getClassname( $this )), array_shift( $args ));
49
+		$hook = sprintf( 'pollux/%s/%s', strtolower( ( new Helper )->getClassname( $this ) ), array_shift( $args ) );
50 50
 		return apply_filters_ref_array( $hook, $args );
51 51
 	}
52 52
 
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function register()
58 58
 	{
59
-		if( current_user_can( 'switch_themes' )) {
59
+		if( current_user_can( 'switch_themes' ) ) {
60 60
 			$this->addInstructions();
61 61
 		}
62 62
 		$metaboxes = func_num_args()
63
-			? ( new Helper )->toArray( func_get_arg(0) )
64
-			: [];
63
+			? ( new Helper )->toArray( func_get_arg( 0 ) )
64
+			: [ ];
65 65
 		return array_merge( $metaboxes, $this->metaboxes );
66 66
 	}
67 67
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	public function renderField( $html, $field )
73 73
 	{
74
-		return $this->validate( $field['condition'] )
74
+		return $this->validate( $field[ 'condition' ] )
75 75
 			? $html
76 76
 			: '';
77 77
 	}
@@ -83,11 +83,11 @@  discard block
 block discarded – undo
83 83
 	public function show( $bool, array $metabox )
84 84
 	{
85 85
 		if( defined( 'DOING_AJAX' )
86
-			|| !isset( $metabox['condition'] )
87
-			|| !$this->hasPostType( $metabox )) {
86
+			|| !isset( $metabox[ 'condition' ] )
87
+			|| !$this->hasPostType( $metabox ) ) {
88 88
 			return $bool;
89 89
 		}
90
-		return $this->validate( $metabox['condition'] );
90
+		return $this->validate( $metabox[ 'condition' ] );
91 91
 	}
92 92
 
93 93
 	/**
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	protected function getPostId()
97 97
 	{
98
-		if( !( $postId = filter_input( INPUT_GET, 'post' ))) {
98
+		if( !( $postId = filter_input( INPUT_GET, 'post' ) ) ) {
99 99
 			$postId = filter_input( INPUT_POST, 'post_ID' );
100 100
 		}
101 101
 		return intval( $postId );
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 	{
109 109
 		return array_unique( iterator_to_array(
110 110
 			new RecursiveIteratorIterator(
111
-				new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' ))
111
+				new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' ) )
112 112
 			),
113 113
 			false
114
-		));
114
+		) );
115 115
 	}
116 116
 
117 117
 	/**
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	{
122 122
 		return PostMeta::get( $key, [
123 123
 			'id' => $this->getPostId(),
124
-		]);
124
+		] );
125 125
 	}
126 126
 
127 127
 	/**
@@ -129,26 +129,26 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	protected function hasPostType( array $metabox )
131 131
 	{
132
-		if( !isset( $metabox['post_types'] )) {
132
+		if( !isset( $metabox[ 'post_types' ] ) ) {
133 133
 			return true;
134 134
 		}
135
-		return in_array( get_post_type( $this->getPostId() ), $metabox['post_types'] );
135
+		return in_array( get_post_type( $this->getPostId() ), $metabox[ 'post_types' ] );
136 136
 	}
137 137
 
138 138
 	/**
139 139
 	 * @return void
140 140
 	 */
141
-	protected function normalize( array $metaboxes, array $defaults = [] )
141
+	protected function normalize( array $metaboxes, array $defaults = [ ] )
142 142
 	{
143 143
 		foreach( $metaboxes as $id => $metabox ) {
144 144
 			$data = wp_parse_args( $defaults, [
145
-				'condition' => [],
146
-				'fields' => [],
145
+				'condition' => [ ],
146
+				'fields' => [ ],
147 147
 				'id' => $id,
148 148
 				'slug' => $id,
149
-				'validation' => [],
150
-			]);
151
-			$this->metaboxes[] = $this->setDependencies(
149
+				'validation' => [ ],
150
+			] );
151
+			$this->metaboxes[ ] = $this->setDependencies(
152 152
 				$this->normalizeThis( $metabox, $data, $id )
153 153
 			);
154 154
 		}
@@ -182,10 +182,10 @@  discard block
 block discarded – undo
182 182
 	protected function normalizeFields( array $fields, array $data, $parentId )
183 183
 	{
184 184
 		return array_map( function( $id, $field ) use( $parentId ) {
185
-			$defaults =  [
186
-				'attributes' => [],
185
+			$defaults = [
186
+				'attributes' => [ ],
187 187
 				'class' => '',
188
-				'condition' => [],
188
+				'condition' => [ ],
189 189
 				'depends' => '',
190 190
 				'field_name' => $id,
191 191
 				'id' => $id,
@@ -219,11 +219,11 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	protected function normalizeValidation( array $validation, array $data, $parentId )
221 221
 	{
222
-		foreach( ['messages', 'rules'] as $key ) {
223
-			if( empty( $validation[$key] ))continue;
224
-			foreach( $validation[$key] as $id => $value ) {
225
-				$validation[$key][$this->normalizeFieldName( $id, ['slug' => $id], $parentId )] = $value;
226
-				unset( $validation[$key][$id] );
222
+		foreach( [ 'messages', 'rules' ] as $key ) {
223
+			if( empty( $validation[ $key ] ) )continue;
224
+			foreach( $validation[ $key ] as $id => $value ) {
225
+				$validation[ $key ][ $this->normalizeFieldName( $id, [ 'slug' => $id ], $parentId ) ] = $value;
226
+				unset( $validation[ $key ][ $id ] );
227 227
 			}
228 228
 		}
229 229
 		return $validation;
@@ -234,14 +234,14 @@  discard block
 block discarded – undo
234 234
 	 */
235 235
 	protected function setDependencies( array $metabox )
236 236
 	{
237
-		$fields = &$metabox['fields'];
237
+		$fields = &$metabox[ 'fields' ];
238 238
 		$depends = array_column( $fields, 'depends' );
239 239
 		array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) {
240
-			if( empty( $value ))return;
241
-			$dependency = array_search( $value, array_column( $fields, 'id' ));
242
-			$fields[$index]['attributes']['data-depends'] = $value;
243
-			if( !$this->getValue( $fields[$dependency]['slug'], $metabox['slug'] )) {
244
-				$fields[$index]['class'] = trim( 'hidden ' . $fields[$index]['class'] );
240
+			if( empty( $value ) )return;
241
+			$dependency = array_search( $value, array_column( $fields, 'id' ) );
242
+			$fields[ $index ][ 'attributes' ][ 'data-depends' ] = $value;
243
+			if( !$this->getValue( $fields[ $dependency ][ 'slug' ], $metabox[ 'slug' ] ) ) {
244
+				$fields[ $index ][ 'class' ] = trim( 'hidden ' . $fields[ $index ][ 'class' ] );
245 245
 			}
246 246
 		});
247 247
 		return $metabox;
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -181,7 +181,8 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	protected function normalizeFields( array $fields, array $data, $parentId )
183 183
 	{
184
-		return array_map( function( $id, $field ) use( $parentId ) {
184
+		return array_map( function( $id, $field ) use( $parentId )
185
+		{
185 186
 			$defaults =  [
186 187
 				'attributes' => [],
187 188
 				'class' => '',
@@ -220,7 +221,9 @@  discard block
 block discarded – undo
220 221
 	protected function normalizeValidation( array $validation, array $data, $parentId )
221 222
 	{
222 223
 		foreach( ['messages', 'rules'] as $key ) {
223
-			if( empty( $validation[$key] ))continue;
224
+			if( empty( $validation[$key] )) {
225
+				continue;
226
+			}
224 227
 			foreach( $validation[$key] as $id => $value ) {
225 228
 				$validation[$key][$this->normalizeFieldName( $id, ['slug' => $id], $parentId )] = $value;
226 229
 				unset( $validation[$key][$id] );
@@ -236,8 +239,11 @@  discard block
 block discarded – undo
236 239
 	{
237 240
 		$fields = &$metabox['fields'];
238 241
 		$depends = array_column( $fields, 'depends' );
239
-		array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) {
240
-			if( empty( $value ))return;
242
+		array_walk( $depends, function( $value, $index ) use( &$fields, $metabox )
243
+		{
244
+			if( empty( $value )) {
245
+				return;
246
+			}
241 247
 			$dependency = array_search( $value, array_column( $fields, 'id' ));
242 248
 			$fields[$index]['attributes']['data-depends'] = $value;
243 249
 			if( !$this->getValue( $fields[$dependency]['slug'], $metabox['slug'] )) {
Please login to merge, or discard this patch.
src/MetaBox/SiteMetaManager.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
 	public function __construct()
19 19
 	{
20
-		$this->options = get_option( Settings::id(), [] );
20
+		$this->options = get_option( Settings::id(), [ ] );
21 21
 	}
22 22
 
23 23
 	/**
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
 	{
29 29
 		$args = array_pad( $args, 2, null );
30 30
 		$group = $this->$group;
31
-		if( is_object( $group )) {
31
+		if( is_object( $group ) ) {
32 32
 			return $group;
33 33
 		}
34
-		return $this->get( $group, $args[0], $args[1] );
34
+		return $this->get( $group, $args[ 0 ], $args[ 1 ] );
35 35
 	}
36 36
 
37 37
 	/**
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
 		if( $group == 'all' ) {
44 44
 			return (object) $this->options;
45 45
 		}
46
-		if( empty( $group )) {
46
+		if( empty( $group ) ) {
47 47
 			$group = $this->getDefaultGroup();
48 48
 		}
49
-		return isset( $this->options[$group] )
50
-			? $this->options[$group]
49
+		return isset( $this->options[ $group ] )
50
+			? $this->options[ $group ]
51 51
 			: null;
52 52
 	}
53 53
 
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 		if( func_num_args() < 1 ) {
63 63
 			return $this->all;
64 64
 		}
65
-		if( is_string( $group )) {
65
+		if( is_string( $group ) ) {
66 66
 			$group = $this->$group;
67 67
 		}
68
-		if( !is_array( $group )) {
68
+		if( !is_array( $group ) ) {
69 69
 			return $fallback;
70 70
 		}
71
-		if( is_null( $key )) {
71
+		if( is_null( $key ) ) {
72 72
 			return $group;
73 73
 		}
74 74
 		return $this->getValue( $group, $key, $fallback );
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	protected function getValue( array $group, $key, $fallback )
91 91
 	{
92
-		if( !array_key_exists( $key, $group )) {
92
+		if( !array_key_exists( $key, $group ) ) {
93 93
 			return $fallback;
94 94
 		}
95
-		return empty( $group[$key] ) && !is_null( $fallback )
95
+		return empty( $group[ $key ] ) && !is_null( $fallback )
96 96
 			? $fallback
97
-			: $group[$key];
97
+			: $group[ $key ];
98 98
 	}
99 99
 }
Please login to merge, or discard this patch.
views/archive/featured.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@
 block discarded – undo
4 4
 	<a href="<?= $thickbox_url; ?>" id="set-post-thumbnail" class="thickbox"><?= $thumbnail; ?></a>
5 5
 </p>
6 6
 
7
-<?php if( get_post( $image_id )) : ?>
7
+<?php if( get_post( $image_id ) ) : ?>
8 8
 
9 9
 <p class="hide-if-no-js howto" id="set-post-thumbnail-desc"><?= $edit_image; ?></p>
10 10
 <p class="hide-if-no-js">
Please login to merge, or discard this patch.