Passed
Push — master ( 9d21ea...9827a3 )
by Paul
02:49
created
src/MetaBox.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -31,6 +31,7 @@
 block discarded – undo
31 31
 	}
32 32
 
33 33
 	/**
34
+	 * @param boolean $bool
34 35
 	 * @return bool
35 36
 	 * @filter rwmb_show
36 37
 	 */
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	/**
18 18
 	 * @var array
19 19
 	 */
20
-	public $metaboxes = [];
20
+	public $metaboxes = [ ];
21 21
 
22 22
 	/**
23 23
 	 * {@inheritdoc}
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 	{
27 27
 		$this->normalize();
28 28
 
29
-		add_filter( 'rwmb_show',       [$this, 'isVisible'], 10, 2 );
30
-		add_filter( 'rwmb_meta_boxes', [$this, 'register'] );
29
+		add_filter( 'rwmb_show', [ $this, 'isVisible' ], 10, 2 );
30
+		add_filter( 'rwmb_meta_boxes', [ $this, 'register' ] );
31 31
 	}
32 32
 
33 33
 	/**
@@ -37,20 +37,20 @@  discard block
 block discarded – undo
37 37
 	public function isVisible( $bool, array $metabox )
38 38
 	{
39 39
 		if( defined( 'DOING_AJAX' )
40
-			|| !isset( $metabox['condition'] )
41
-			|| !$this->hasPostType( $metabox )) {
40
+			|| !isset( $metabox[ 'condition' ] )
41
+			|| !$this->hasPostType( $metabox ) ) {
42 42
 			return $bool;
43 43
 		}
44
-		return $this->verifyMetaBoxCondition( $metabox['condition'] );
44
+		return $this->verifyMetaBoxCondition( $metabox[ 'condition' ] );
45 45
 	}
46 46
 
47 47
 	/**
48 48
 	 * @return array
49 49
 	 * @filter rwmb_meta_boxes
50 50
 	 */
51
-	public function register( $metaboxes = [] )
51
+	public function register( $metaboxes = [ ] )
52 52
 	{
53
-		if( current_user_can( 'switch_themes' )) {
53
+		if( current_user_can( 'switch_themes' ) ) {
54 54
 			$this->addInstructions();
55 55
 		}
56 56
 		return array_merge( $metaboxes, $this->metaboxes );
@@ -77,18 +77,18 @@  discard block
 block discarded – undo
77 77
 	{
78 78
 		if( !count( array_filter( $this->metaboxes, function( $metabox ) {
79 79
 			return $this->isVisible( false, $metabox );
80
-		})))return;
81
-		$this->metaboxes[] = [
80
+		}) ) )return;
81
+		$this->metaboxes[ ] = [
82 82
 			'id' => 'infodiv',
83 83
 			'post_types' => $this->getPostTypes(),
84 84
 			'title' => __( 'How to use in your theme', 'pollux' ),
85 85
 			'context' => 'side',
86 86
 			'priority' => 'low',
87
-			'fields' => [[
87
+			'fields' => [ [
88 88
 				'slug' => '',
89 89
 				'std' => $this->generateInstructions(),
90 90
 				'type' => 'custom_html',
91
-			]],
91
+			] ],
92 92
 		];
93 93
 	}
94 94
 
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
 	protected function generateInstructions()
99 99
 	{
100 100
 		return array_reduce( $this->getInstructions(), function( $html, $metabox ) {
101
-			$fields = array_reduce( array_column( $metabox['fields'], 'slug' ), function( $html, $slug ) use( $metabox ) {
101
+			$fields = array_reduce( array_column( $metabox[ 'fields' ], 'slug' ), function( $html, $slug ) use( $metabox ) {
102 102
 				$hook = sprintf( 'pollux/%s/instruction', $this->getClassname() );
103
-				return $html . apply_filters( $hook, "PostMeta::get('{$slug}');", $slug, $metabox['slug'] ) . PHP_EOL;
103
+				return $html . apply_filters( $hook, "PostMeta::get('{$slug}');", $slug, $metabox[ 'slug' ] ) . PHP_EOL;
104 104
 			});
105 105
 			return $html . sprintf( '<p><strong>%s</strong></p><pre class="my-sites nav-tab-active misc-pub-section">%s</pre>',
106
-				$metabox['title'],
106
+				$metabox[ 'title' ],
107 107
 				$fields
108 108
 			);
109 109
 		});
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	protected function getInstructions()
116 116
 	{
117 117
 		return array_filter( $this->metaboxes, function( $metabox ) {
118
-			return $this->verifyMetaBoxCondition( $metabox['condition'] )
118
+			return $this->verifyMetaBoxCondition( $metabox[ 'condition' ] )
119 119
 				&& $this->hasPostType( $metabox );
120 120
 		});
121 121
 	}
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	protected function getPostId()
127 127
 	{
128
-		if( !( $postId = filter_input( INPUT_GET, 'post' ))) {
128
+		if( !( $postId = filter_input( INPUT_GET, 'post' ) ) ) {
129 129
 			$postId = filter_input( INPUT_POST, 'post_ID' );
130 130
 		}
131 131
 		return intval( $postId );
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
 	{
139 139
 		return array_unique( iterator_to_array(
140 140
 			new RecursiveIteratorIterator(
141
-				new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' ))
141
+				new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' ) )
142 142
 			),
143 143
 			false
144
-		));
144
+		) );
145 145
 	}
146 146
 
147 147
 	/**
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	protected function hasPostType( array $metabox )
151 151
 	{
152
-		if( !isset( $metabox['post_types'] )) {
152
+		if( !isset( $metabox[ 'post_types' ] ) ) {
153 153
 			return true;
154 154
 		}
155
-		return in_array( get_post_type( $this->getPostId() ), $metabox['post_types'] );
155
+		return in_array( get_post_type( $this->getPostId() ), $metabox[ 'post_types' ] );
156 156
 	}
157 157
 
158 158
 	/**
@@ -160,15 +160,15 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	protected function normalize()
162 162
 	{
163
-		foreach( $this->app->config['meta_boxes'] as $id => $metabox ) {
163
+		foreach( $this->app->config[ 'meta_boxes' ] as $id => $metabox ) {
164 164
 			$defaults = [
165
-				'condition' => [],
166
-				'fields' => [],
165
+				'condition' => [ ],
166
+				'fields' => [ ],
167 167
 				'id' => $id,
168
-				'post_types' => [],
168
+				'post_types' => [ ],
169 169
 				'slug' => $id,
170 170
 			];
171
-			$this->metaboxes[] = $this->normalizeThis( $metabox, $defaults, $id );
171
+			$this->metaboxes[ ] = $this->normalizeThis( $metabox, $defaults, $id );
172 172
 		}
173 173
 	}
174 174
 
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
 	protected function normalizeCondition( $conditions )
180 180
 	{
181 181
 		$conditions = $this->toArray( $conditions );
182
-		if( count( array_filter( array_keys( $conditions ), 'is_string' )) == 0 ) {
182
+		if( count( array_filter( array_keys( $conditions ), 'is_string' ) ) == 0 ) {
183 183
 			foreach( $conditions as $key ) {
184
-				$conditions[str_replace( '!', '', $key )] = substr( $key, 0, 1 ) == '!' ? 0 : 1;
184
+				$conditions[ str_replace( '!', '', $key ) ] = substr( $key, 0, 1 ) == '!' ? 0 : 1;
185 185
 			}
186 186
 			$conditions = array_filter( $conditions, function( $key ) {
187 187
 				return !is_numeric( $key );
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 		$hook = sprintf( 'pollux/%s/conditions', $this->getClassname() );
191 191
 		return array_intersect_key(
192 192
 			$conditions,
193
-			array_flip( apply_filters( $hook, static::CONDITIONS ))
193
+			array_flip( apply_filters( $hook, static::CONDITIONS ) )
194 194
 		);
195 195
 	}
196 196
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	protected function normalizeFields( array $fields, array $data, $parentId )
201 201
 	{
202 202
 		return array_map( function( $id, $field ) use( $parentId ) {
203
-			$defaults =  [
203
+			$defaults = [
204 204
 				'id' => $id,
205 205
 				'field_name' => '',
206 206
 				'slug' => $id,
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 */
246 246
 	protected function validateIsFrontPage( $value )
247 247
 	{
248
-		return $value == ( $this->getPostId() == get_option( 'page_on_front' ));
248
+		return $value == ( $this->getPostId() == get_option( 'page_on_front' ) );
249 249
 	}
250 250
 
251 251
 	/**
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	 */
255 255
 	protected function validateIsHome( $value )
256 256
 	{
257
-		return $value == ( $this->getPostId() == get_option( 'page_for_posts' ));
257
+		return $value == ( $this->getPostId() == get_option( 'page_for_posts' ) );
258 258
 	}
259 259
 
260 260
 	/**
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	 */
264 264
 	protected function validateIsPageTemplate( $value )
265 265
 	{
266
-		return basename( get_page_template_slug( $this->getPostId() )) == $value;
266
+		return basename( get_page_template_slug( $this->getPostId() ) ) == $value;
267 267
 	}
268 268
 
269 269
 	/**
Please login to merge, or discard this patch.
Braces   +17 added lines, -8 removed lines patch added patch discarded remove patch
@@ -61,7 +61,8 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public function verifyMetaBoxCondition( array $conditions )
63 63
 	{
64
-		array_walk( $conditions, function( &$value, $key ) {
64
+		array_walk( $conditions, function( &$value, $key )
65
+		{
65 66
 			$method = $this->app->buildMethodName( $key, 'validate' );
66 67
 			$value = method_exists( $this, $method )
67 68
 				? $this->$method( $value )
@@ -75,9 +76,12 @@  discard block
 block discarded – undo
75 76
 	 */
76 77
 	protected function addInstructions()
77 78
 	{
78
-		if( !count( array_filter( $this->metaboxes, function( $metabox ) {
79
+		if( !count( array_filter( $this->metaboxes, function( $metabox )
80
+		{
79 81
 			return $this->isVisible( false, $metabox );
80
-		})))return;
82
+		}))) {
83
+			return;
84
+		}
81 85
 		$this->metaboxes[] = [
82 86
 			'id' => 'infodiv',
83 87
 			'post_types' => $this->getPostTypes(),
@@ -97,8 +101,10 @@  discard block
 block discarded – undo
97 101
 	 */
98 102
 	protected function generateInstructions()
99 103
 	{
100
-		return array_reduce( $this->getInstructions(), function( $html, $metabox ) {
101
-			$fields = array_reduce( array_column( $metabox['fields'], 'slug' ), function( $html, $slug ) use( $metabox ) {
104
+		return array_reduce( $this->getInstructions(), function( $html, $metabox )
105
+		{
106
+			$fields = array_reduce( array_column( $metabox['fields'], 'slug' ), function( $html, $slug ) use( $metabox )
107
+			{
102 108
 				$hook = sprintf( 'pollux/%s/instruction', $this->getClassname() );
103 109
 				return $html . apply_filters( $hook, "PostMeta::get('{$slug}');", $slug, $metabox['slug'] ) . PHP_EOL;
104 110
 			});
@@ -114,7 +120,8 @@  discard block
 block discarded – undo
114 120
 	 */
115 121
 	protected function getInstructions()
116 122
 	{
117
-		return array_filter( $this->metaboxes, function( $metabox ) {
123
+		return array_filter( $this->metaboxes, function( $metabox )
124
+		{
118 125
 			return $this->verifyMetaBoxCondition( $metabox['condition'] )
119 126
 				&& $this->hasPostType( $metabox );
120 127
 		});
@@ -183,7 +190,8 @@  discard block
 block discarded – undo
183 190
 			foreach( $conditions as $key ) {
184 191
 				$conditions[str_replace( '!', '', $key )] = substr( $key, 0, 1 ) == '!' ? 0 : 1;
185 192
 			}
186
-			$conditions = array_filter( $conditions, function( $key ) {
193
+			$conditions = array_filter( $conditions, function( $key )
194
+			{
187 195
 				return !is_numeric( $key );
188 196
 			}, ARRAY_FILTER_USE_KEY );
189 197
 		}
@@ -199,7 +207,8 @@  discard block
 block discarded – undo
199 207
 	 */
200 208
 	protected function normalizeFields( array $fields, array $data, $parentId )
201 209
 	{
202
-		return array_map( function( $id, $field ) use( $parentId ) {
210
+		return array_map( function( $id, $field ) use( $parentId )
211
+		{
203 212
 			$defaults =  [
204 213
 				'id' => $id,
205 214
 				'field_name' => '',
Please login to merge, or discard this patch.
src/PostMeta.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -10,19 +10,19 @@  discard block
 block discarded – undo
10 10
 	 * @param string $metaKey
11 11
 	 * @return mixed
12 12
 	 */
13
-	public function get( $metaKey, array $args = [] )
13
+	public function get( $metaKey, array $args = [ ] )
14 14
 	{
15
-		if( empty( $metaKey ))return;
15
+		if( empty( $metaKey ) )return;
16 16
 
17 17
 		$args = $this->normalize( $args );
18
-		$metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] );
19
-		$metaValue = get_post_meta( $args['id'], $metaKey, $args['single'] );
18
+		$metaKey = $this->buildMetaKey( $metaKey, $args[ 'prefix' ] );
19
+		$metaValue = get_post_meta( $args[ 'id' ], $metaKey, $args[ 'single' ] );
20 20
 
21
-		if( is_string( $metaValue )) {
21
+		if( is_string( $metaValue ) ) {
22 22
 			$metaValue = trim( $metaValue );
23 23
 		}
24 24
 		return empty( $metaValue )
25
-			? $args['fallback']
25
+			? $args[ 'fallback' ]
26 26
 			: $metaValue;
27 27
 	}
28 28
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 */
34 34
 	protected function buildMetaKey( $metaKey, $prefix )
35 35
 	{
36
-		return ( substr( $metaKey, 0, 1 ) == '_' && !empty( $prefix ))
36
+		return ( substr( $metaKey, 0, 1 ) == '_' && !empty( $prefix ) )
37 37
 			? sprintf( '_%s%s', rtrim( $prefix, '_' ), $metaKey )
38 38
 			: $prefix . $metaKey;
39 39
 	}
@@ -49,6 +49,6 @@  discard block
 block discarded – undo
49 49
 			'single'   => true,
50 50
 			'prefix'   => apply_filters( 'pollux/prefix', Application::PREFIX ),
51 51
 		];
52
-		return shortcode_atts( $defaults, array_change_key_case( $args ));
52
+		return shortcode_atts( $defaults, array_change_key_case( $args ) );
53 53
 	}
54 54
 }
Please login to merge, or discard this patch.
src/SettingsMetaBox.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
 		parent::__construct( $metabox );
15 15
 		$this->meta_box = static::normalize( $this->meta_box );
16 16
 
17
-		remove_action( 'add_meta_boxes', [$this, 'add_meta_boxes'] );
18
-		remove_action( 'save_post_post', [$this, 'save_post'] );
17
+		remove_action( 'add_meta_boxes', [ $this, 'add_meta_boxes' ] );
18
+		remove_action( 'save_post_post', [ $this, 'save_post' ] );
19 19
 
20
-		add_action( 'pollux/settings/init', [$this, 'add_meta_boxes'] );
21
-		add_filter( 'rwmb_field_meta',      [$this, '_get_field_meta'], 10, 3 );
20
+		add_action( 'pollux/settings/init', [ $this, 'add_meta_boxes' ] );
21
+		add_filter( 'rwmb_field_meta', [ $this, '_get_field_meta' ], 10, 3 );
22 22
 	}
23 23
 
24 24
 	/**
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function _get_field_meta( $meta, array $field, $saved )
31 31
 	{
32
-		if( !$this->is_edit_screen() || !empty( $meta ) || empty( $field['slug'] )) {
32
+		if( !$this->is_edit_screen() || !empty( $meta ) || empty( $field[ 'slug' ] ) ) {
33 33
 			return $meta;
34 34
 		}
35
-		$meta = call_user_func( [RWMB_Field::get_class_name( $field ), 'esc_meta'], ( $saved
36
-			? (new SiteMeta)->get( $this->meta_box['slug'], $field['slug'], $meta )
37
-			: $field['std']
38
-		));
35
+		$meta = call_user_func( [ RWMB_Field::get_class_name( $field ), 'esc_meta' ], ( $saved
36
+			? ( new SiteMeta )->get( $this->meta_box[ 'slug' ], $field[ 'slug' ], $meta )
37
+			: $field[ 'std' ]
38
+		) );
39 39
 		return $this->_normalize_field_meta( $meta, $field );
40 40
 	}
41 41
 
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
 	 */
46 46
 	public function _normalize_field_meta( $meta, array $field )
47 47
 	{
48
-		if( !empty( $meta ) && is_array( $meta )) {
48
+		if( !empty( $meta ) && is_array( $meta ) ) {
49 49
 			return $meta;
50 50
 		}
51
-		if( $field['clone'] ) {
52
-			return [''];
51
+		if( $field[ 'clone' ] ) {
52
+			return [ '' ];
53 53
 		}
54
-		if( $field['multiple'] ) {
55
-			return [];
54
+		if( $field[ 'multiple' ] ) {
55
+			return [ ];
56 56
 		}
57 57
 		return $meta;
58 58
 	}
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
 	public function add_meta_boxes()
65 65
 	{
66 66
 		add_meta_box(
67
-			$this->meta_box['id'],
68
-			$this->meta_box['title'],
69
-			[$this, 'show'],
67
+			$this->meta_box[ 'id' ],
68
+			$this->meta_box[ 'title' ],
69
+			[ $this, 'show' ],
70 70
 			null,
71
-			$this->meta_box['context'],
72
-			$this->meta_box['priority']
71
+			$this->meta_box[ 'context' ],
72
+			$this->meta_box[ 'priority' ]
73 73
 		);
74 74
 	}
75 75
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public function is_edit_screen( $screen = null )
80 80
 	{
81
-		return get_current_screen()->id == sprintf( 'toplevel_page_%s', apply_filters( 'pollux/settings/option', Settings::ID ));
81
+		return get_current_screen()->id == sprintf( 'toplevel_page_%s', apply_filters( 'pollux/settings/option', Settings::ID ) );
82 82
 	}
83 83
 
84 84
 	/**
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	public function is_saved()
88 88
 	{
89 89
 		foreach( array_column( $this->fields, 'slug' ) as $field ) {
90
-			if( !is_null( (new SiteMeta)->get( $this->meta_box['slug'], $field, null ))) {
90
+			if( !is_null( ( new SiteMeta )->get( $this->meta_box[ 'slug' ], $field, null ) ) ) {
91 91
 				return true;
92 92
 			}
93 93
 		}
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	public static function normalize( $metabox )
102 102
 	{
103
-		unset( $metabox['post_types'] );
104
-		return wp_parse_args( $metabox, ['slug' => ''] );
103
+		unset( $metabox[ 'post_types' ] );
104
+		return wp_parse_args( $metabox, [ 'slug' => '' ] );
105 105
 	}
106 106
 }
Please login to merge, or discard this patch.
src/Controller.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	public function filterWordPressFooter( $text )
25 25
 	{
26
-		if( $this->app->config['remove_wordpress_footer'] )return;
26
+		if( $this->app->config[ 'remove_wordpress_footer' ] )return;
27 27
 		return $text;
28 28
 	}
29 29
 
@@ -33,24 +33,24 @@  discard block
 block discarded – undo
33 33
 	 */
34 34
 	public function registerAssets()
35 35
 	{
36
-		if( $this->app->screen()->id == sprintf( 'toplevel_page_%s', apply_filters( 'pollux/settings/option', Settings::ID ))) {
36
+		if( $this->app->screen()->id == sprintf( 'toplevel_page_%s', apply_filters( 'pollux/settings/option', Settings::ID ) ) ) {
37 37
 			wp_enqueue_script( 'common' );
38 38
 			wp_enqueue_script( 'wp-lists' );
39 39
 			wp_enqueue_script( 'postbox' );
40 40
 		}
41 41
 		wp_enqueue_style( 'pollux/main.css',
42 42
 			$this->app->path( 'assets/main.css' ),
43
-			apply_filters( 'pollux/enqueue/css/deps', [] ),
43
+			apply_filters( 'pollux/enqueue/css/deps', [ ] ),
44 44
 			$this->app->version
45 45
 		);
46 46
 		wp_enqueue_script( 'pollux/main.js',
47 47
 			$this->app->path( 'assets/main.js' ),
48
-			apply_filters( 'pollux/enqueue/js/deps', [] ),
48
+			apply_filters( 'pollux/enqueue/js/deps', [ ] ),
49 49
 			$this->app->version
50 50
 		);
51 51
 		wp_localize_script( 'pollux/main.js',
52 52
 			apply_filters( 'pollux/enqueue/js/localize/name', $this->app->id ),
53
-			apply_filters( 'pollux/enqueue/js/localize/variables', [] )
53
+			apply_filters( 'pollux/enqueue/js/localize/variables', [ ] )
54 54
 		);
55 55
 	}
56 56
 
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 	 */
61 61
 	public function removeDashboardWidgets()
62 62
 	{
63
-		if( !$this->app->config['remove_dashboard_widgets'] )return;
63
+		if( !$this->app->config[ 'remove_dashboard_widgets' ] )return;
64 64
 		$widgets = apply_filters( 'pollux/dashoard/widgets', [
65 65
 			'dashboard_primary',
66 66
 			'dashboard_quick_press',
67
-		]);
67
+		] );
68 68
 		foreach( $widgets as $widget ) {
69 69
 			remove_meta_box( $widget, 'dashboard', 'normal' );
70 70
 		}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function removeWordPressMenu()
78 78
 	{
79
-		if( !$this->app->config['remove_wordpress_menu'] )return;
79
+		if( !$this->app->config[ 'remove_wordpress_menu' ] )return;
80 80
 		global $wp_admin_bar;
81 81
 		$wp_admin_bar->remove_menu( 'wp-logo' );
82 82
 	}
Please login to merge, or discard this patch.
src/Taxonomy.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 
14 14
 	const TAXONOMY_DEFAULTS = [
15 15
 		'hierarchical'      => true,
16
-		'labels'            => [],
16
+		'labels'            => [ ],
17 17
 		'menu_name'         => '',
18 18
 		'plural'            => '',
19
-		'post_types'        => [],
19
+		'post_types'        => [ ],
20 20
 		'public'            => true,
21 21
 		'rewrite'           => true,
22 22
 		'show_admin_column' => true,
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @var array
29 29
 	 */
30
-	public $taxonomies = [];
30
+	public $taxonomies = [ ];
31 31
 
32 32
 	/**
33 33
 	 * {@inheritdoc}
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	{
37 37
 		$this->normalize();
38 38
 
39
-		add_action( 'restrict_manage_posts', [ $this, 'printFilters'] );
40
-		add_action( 'init',                  [ $this, 'register'] );
41
-		add_filter( 'parse_query',           [ $this, 'filterByTaxonomy'] );
39
+		add_action( 'restrict_manage_posts', [ $this, 'printFilters' ] );
40
+		add_action( 'init', [ $this, 'register' ] );
41
+		add_filter( 'parse_query', [ $this, 'filterByTaxonomy' ] );
42 42
 	}
43 43
 
44 44
 	/**
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 		if( !is_admin() || $this->app->screen()->base != 'edit' )return;
51 51
 		$vars = &$query->query_vars;
52 52
 		foreach( array_keys( $this->taxonomies ) as $taxonomy ) {
53
-			if( !isset( $vars[$taxonomy] ))return;
54
-			if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy )) {
55
-				$vars[$taxonomy] = $term->slug;
53
+			if( !isset( $vars[ $taxonomy ] ) )return;
54
+			if( $term = get_term_by( 'id', $vars[ $taxonomy ], $taxonomy ) ) {
55
+				$vars[ $taxonomy ] = $term->slug;
56 56
 			}
57 57
 		}
58 58
 		return $query;
@@ -66,18 +66,18 @@  discard block
 block discarded – undo
66 66
 	{
67 67
 		global $wp_query;
68 68
 		foreach( $this->taxonomies as $taxonomy => $args ) {
69
-			if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue;
70
-			$selected = isset( $wp_query->query[$taxonomy] )
71
-				? $wp_query->query[$taxonomy]
69
+			if( !in_array( get_current_screen()->post_type, $args[ 'post_types' ] ) )continue;
70
+			$selected = isset( $wp_query->query[ $taxonomy ] )
71
+				? $wp_query->query[ $taxonomy ]
72 72
 				: false;
73
-			wp_dropdown_categories([
73
+			wp_dropdown_categories( [
74 74
 				'hide_if_empty' => true,
75 75
 				'name' => $taxonomy,
76 76
 				'orderby' => 'name',
77 77
 				'selected' => $selected,
78
-				'show_option_all' => $args['labels']['all_items'],
78
+				'show_option_all' => $args[ 'labels' ][ 'all_items' ],
79 79
 				'taxonomy' => $taxonomy,
80
-			]);
80
+			] );
81 81
 		}
82 82
 	}
83 83
 
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 	public function register()
89 89
 	{
90 90
 		array_walk( $this->taxonomies, function( $args, $taxonomy ) {
91
-			register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( static::CUSTOM_KEYS )));
92
-			foreach( $args['post_types'] as $type ) {
91
+			register_taxonomy( $taxonomy, $args[ 'post_types' ], array_diff_key( $args, array_flip( static::CUSTOM_KEYS ) ) );
92
+			foreach( $args[ 'post_types' ] as $type ) {
93 93
 				register_taxonomy_for_object_type( $taxonomy, $type );
94 94
 			}
95 95
 		});
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	protected function normalize()
102 102
 	{
103
-		foreach( $this->app->config['taxonomies'] as $taxonomy => $args ) {
104
-			$this->taxonomies[$taxonomy] = apply_filters( 'pollux/taxonomy/args',
103
+		foreach( $this->app->config[ 'taxonomies' ] as $taxonomy => $args ) {
104
+			$this->taxonomies[ $taxonomy ] = apply_filters( 'pollux/taxonomy/args',
105 105
 				$this->normalizeThis( $args, static::TAXONOMY_DEFAULTS, $taxonomy )
106 106
 			);
107 107
 		}
108 108
 		$this->taxonomies = array_diff_key(
109 109
 			$this->taxonomies,
110
-			get_taxonomies( ['_builtin' => true] )
110
+			get_taxonomies( [ '_builtin' => true ] )
111 111
 		);
112 112
 	}
113 113
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	protected function normalizeLabels( $labels, array $args )
119 119
 	{
120
-		return wp_parse_args( $labels, $this->setLabels( $args ));
120
+		return wp_parse_args( $labels, $this->setLabels( $args ) );
121 121
 	}
122 122
 
123 123
 	/**
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	protected function normalizeMenuName( $menuname, array $args )
128 128
 	{
129 129
 		return empty( $menuname )
130
-			? $args['plural']
130
+			? $args[ 'plural' ]
131 131
 			: $menuname;
132 132
 	}
133 133
 
@@ -146,17 +146,17 @@  discard block
 block discarded – undo
146 146
 	protected function setLabels( array $args )
147 147
 	{
148 148
 		return apply_filters( 'pollux/taxonomy/labels', [
149
-			'add_new_item' => sprintf( _x( 'Add New %s', 'Add new taxonomy', 'pollux' ), $args['single'] ),
150
-			'all_items' => sprintf( _x( 'All %s', 'All taxonomies', 'pollux' ), $args['plural'] ),
151
-			'edit_item' => sprintf( _x( 'Edit %s', 'Edit taxonomy', 'pollux' ), $args['single'] ),
152
-			'menu_name' => $this->normalizeMenuName( $args['menu_name'], $args ),
153
-			'name' => $args['plural'],
154
-			'new_item_name' => sprintf( _x( 'New %s Name', 'New taxonomy name', 'pollux' ), $args['single'] ),
155
-			'not_found' => sprintf( _x( 'No %s found', 'No taxonomies found', 'pollux' ), $args['plural'] ),
156
-			'search_items' => sprintf( _x( 'Search %s', 'Search taxonomies', 'pollux' ), $args['plural'] ),
157
-			'singular_name' => $args['single'],
158
-			'update_item' => sprintf( _x( 'Update %s', 'Update taxonomy', 'pollux' ), $args['single'] ),
159
-			'view_item' => sprintf( _x( 'View %s', 'View taxonomy', 'pollux' ), $args['single'] ),
149
+			'add_new_item' => sprintf( _x( 'Add New %s', 'Add new taxonomy', 'pollux' ), $args[ 'single' ] ),
150
+			'all_items' => sprintf( _x( 'All %s', 'All taxonomies', 'pollux' ), $args[ 'plural' ] ),
151
+			'edit_item' => sprintf( _x( 'Edit %s', 'Edit taxonomy', 'pollux' ), $args[ 'single' ] ),
152
+			'menu_name' => $this->normalizeMenuName( $args[ 'menu_name' ], $args ),
153
+			'name' => $args[ 'plural' ],
154
+			'new_item_name' => sprintf( _x( 'New %s Name', 'New taxonomy name', 'pollux' ), $args[ 'single' ] ),
155
+			'not_found' => sprintf( _x( 'No %s found', 'No taxonomies found', 'pollux' ), $args[ 'plural' ] ),
156
+			'search_items' => sprintf( _x( 'Search %s', 'Search taxonomies', 'pollux' ), $args[ 'plural' ] ),
157
+			'singular_name' => $args[ 'single' ],
158
+			'update_item' => sprintf( _x( 'Update %s', 'Update taxonomy', 'pollux' ), $args[ 'single' ] ),
159
+			'view_item' => sprintf( _x( 'View %s', 'View taxonomy', 'pollux' ), $args[ 'single' ] ),
160 160
 		], $args );
161 161
 	}
162 162
 }
Please login to merge, or discard this patch.
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,10 +47,14 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function filterByTaxonomy( WP_Query $query )
49 49
 	{
50
-		if( !is_admin() || $this->app->screen()->base != 'edit' )return;
50
+		if( !is_admin() || $this->app->screen()->base != 'edit' ) {
51
+			return;
52
+		}
51 53
 		$vars = &$query->query_vars;
52 54
 		foreach( array_keys( $this->taxonomies ) as $taxonomy ) {
53
-			if( !isset( $vars[$taxonomy] ))return;
55
+			if( !isset( $vars[$taxonomy] )) {
56
+				return;
57
+			}
54 58
 			if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy )) {
55 59
 				$vars[$taxonomy] = $term->slug;
56 60
 			}
@@ -66,7 +70,9 @@  discard block
 block discarded – undo
66 70
 	{
67 71
 		global $wp_query;
68 72
 		foreach( $this->taxonomies as $taxonomy => $args ) {
69
-			if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue;
73
+			if( !in_array( get_current_screen()->post_type, $args['post_types'] )) {
74
+				continue;
75
+			}
70 76
 			$selected = isset( $wp_query->query[$taxonomy] )
71 77
 				? $wp_query->query[$taxonomy]
72 78
 				: false;
@@ -87,7 +93,8 @@  discard block
 block discarded – undo
87 93
 	 */
88 94
 	public function register()
89 95
 	{
90
-		array_walk( $this->taxonomies, function( $args, $taxonomy ) {
96
+		array_walk( $this->taxonomies, function( $args, $taxonomy )
97
+		{
91 98
 			register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( static::CUSTOM_KEYS )));
92 99
 			foreach( $args['post_types'] as $type ) {
93 100
 				register_taxonomy_for_object_type( $taxonomy, $type );
Please login to merge, or discard this patch.
src/Application.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 
24 24
 	public function __construct()
25 25
 	{
26
-		$this->file = realpath( dirname( dirname( __FILE__ )) . '/pollux.php' );
27
-		$this->gatekeeper = new GateKeeper( plugin_basename( $this->file ));
26
+		$this->file = realpath( dirname( dirname( __FILE__ ) ) . '/pollux.php' );
27
+		$this->gatekeeper = new GateKeeper( plugin_basename( $this->file ) );
28 28
 
29 29
 		$data = get_file_data( $this->file, array(
30 30
 			'id' => 'Text Domain',
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
 
48 48
 		$controller = $this->make( 'Controller' );
49 49
 
50
-		add_action( 'admin_enqueue_scripts',      array( $controller, 'registerAssets' ));
51
-		add_action( 'admin_init',                 array( $controller, 'removeDashboardWidgets' ));
52
-		add_action( 'wp_before_admin_bar_render', array( $controller, 'removeWordPressMenu' ));
53
-		add_filter( 'admin_footer_text',          array( $controller, 'filterWordPressFooter' ));
50
+		add_action( 'admin_enqueue_scripts', array( $controller, 'registerAssets' ) );
51
+		add_action( 'admin_init', array( $controller, 'removeDashboardWidgets' ) );
52
+		add_action( 'wp_before_admin_bar_render', array( $controller, 'removeWordPressMenu' ) );
53
+		add_filter( 'admin_footer_text', array( $controller, 'filterWordPressFooter' ) );
54 54
 
55 55
 		// Disallow indexing of the site on non-production environments
56 56
 		if( !$this->environment( 'production' ) && !is_admin() ) {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	{
66 66
 		Facade::clearResolvedInstances();
67 67
 		Facade::setFacadeApplication( $this );
68
-		$this->config = (new Config( $this ))->get();
68
+		$this->config = ( new Config( $this ) )->get();
69 69
 		$this->registerAliases();
70 70
 		$classNames = array(
71 71
 			'MetaBox', 'PostType', 'Settings', 'Taxonomy',
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	public function buildClassName( $name, $path = '' )
84 84
 	{
85
-		$className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name )));
85
+		$className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name ) ) );
86 86
 		$className = implode( '', $className );
87 87
 		return !empty( $path )
88
-			? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className ))
88
+			? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className ) )
89 89
 			: $className;
90 90
 	}
91 91
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function buildMethodName( $name, $prefix = 'get' )
98 98
 	{
99
-		return lcfirst( $this->buildClassName( $prefix . '-' . $name ));
99
+		return lcfirst( $this->buildClassName( $prefix . '-' . $name ) );
100 100
 	}
101 101
 
102 102
 	/**
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	public function environment( $checkFor = '' )
107 107
 	{
108 108
 		$environment = defined( 'WP_ENV' ) ? WP_ENV : 'production';
109
-		if( !empty( $checkFor )) {
109
+		if( !empty( $checkFor ) ) {
110 110
 			return $environment == $checkFor;
111 111
 		}
112 112
 		return $environment;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		$option = apply_filters( 'pollux/settings/option', Settings::ID );
121 121
 		$settings = get_option( $option );
122 122
 		if( !$settings ) {
123
-			update_option( $option, [] );
123
+			update_option( $option, [ ] );
124 124
 		}
125 125
 	}
126 126
 
@@ -171,6 +171,6 @@  discard block
 block discarded – undo
171 171
 	 */
172 172
 	public function url( $path = '' )
173 173
 	{
174
-		return esc_url( plugin_dir_url( $this->file ) . ltrim( trim( $path ), '/' ));
174
+		return esc_url( plugin_dir_url( $this->file ) . ltrim( trim( $path ), '/' ) );
175 175
 	}
176 176
 }
Please login to merge, or discard this patch.
src/Settings.php 2 patches
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
 
40 40
 		$this->id = apply_filters( 'pollux/settings/option', static::ID );
41 41
 
42
-		add_action( 'admin_menu',                             [$this, 'addPage'] );
43
-		add_action( 'pollux/settings/init',                   [$this, 'addSubmitMetaBox'] );
44
-		add_action( 'current_screen',                         [$this, 'register'] );
45
-		add_action( 'admin_menu',                             [$this, 'registerSetting'] );
46
-		add_action( 'pollux/settings/init',                   [$this, 'reset'] );
47
-		add_action( "admin_footer-toplevel_page_{$this->id}", [$this, 'renderFooterScript'] );
48
-		add_filter( 'pollux/settings/instruction',            [$this, 'filterInstruction'], 10, 3 );
49
-		add_filter( 'wp_redirect',                            [$this, 'filterRedirectOnSave'] );
42
+		add_action( 'admin_menu', [ $this, 'addPage' ] );
43
+		add_action( 'pollux/settings/init', [ $this, 'addSubmitMetaBox' ] );
44
+		add_action( 'current_screen', [ $this, 'register' ] );
45
+		add_action( 'admin_menu', [ $this, 'registerSetting' ] );
46
+		add_action( 'pollux/settings/init', [ $this, 'reset' ] );
47
+		add_action( "admin_footer-toplevel_page_{$this->id}", [ $this, 'renderFooterScript' ] );
48
+		add_filter( 'pollux/settings/instruction', [ $this, 'filterInstruction' ], 10, 3 );
49
+		add_filter( 'wp_redirect', [ $this, 'filterRedirectOnSave' ] );
50 50
 	}
51 51
 
52 52
 	/**
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
 			__( 'Site Settings', 'pollux' ),
61 61
 			'edit_theme_options',
62 62
 			$this->id,
63
-			[$this, 'renderPage'],
63
+			[ $this, 'renderPage' ],
64 64
 			'dashicons-screenoptions',
65 65
 			1313
66
-		]));
66
+		] ) );
67 67
 	}
68 68
 
69 69
 	/**
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
 		call_user_func_array( 'add_meta_box', apply_filters( 'pollux/settings/metabox/submit', [
76 76
 			'submitdiv',
77 77
 			__( 'Save Settings', 'pollux' ),
78
-			[ $this, 'renderSubmitMetaBox'],
78
+			[ $this, 'renderSubmitMetaBox' ],
79 79
 			$this->hook,
80 80
 			'side',
81 81
 			'high',
82
-		]));
82
+		] ) );
83 83
 	}
84 84
 
85 85
 	/**
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
 	public function filterRedirectOnSave( $location )
103 103
 	{
104 104
 		if( strpos( $location, 'settings-updated=true' ) === false
105
-			|| strpos( $location, sprintf( 'page=%s', $this->id )) === false ) {
105
+			|| strpos( $location, sprintf( 'page=%s', $this->id ) ) === false ) {
106 106
 			return $location;
107 107
 		}
108
-		return add_query_arg([
108
+		return add_query_arg( [
109 109
 			'page' => $this->id,
110 110
 			'settings-updated' => 'true',
111
-		], admin_url( 'admin.php' ));
111
+		], admin_url( 'admin.php' ) );
112 112
 	}
113 113
 
114 114
 	/**
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function filterSavedSettings( $settings )
120 120
 	{
121
-		if( is_null( $settings )) {
122
-			$settings = [];
121
+		if( is_null( $settings ) ) {
122
+			$settings = [ ];
123 123
 		}
124 124
 		return apply_filters( 'pollux/settings/save', $settings );
125 125
 	}
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @return void
129 129
 	 * @action current_screen
130 130
 	 */
131
-	public function register( $metaboxes = [] )
131
+	public function register( $metaboxes = [ ] )
132 132
 	{
133 133
 		if( $this->app->screen()->id != $this->hook )return;
134 134
 		foreach( parent::register() as $metabox ) {
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 		add_screen_option( 'layout_columns', [
138 138
 			'max' => 2,
139 139
 			'default' => 2,
140
-		]);
140
+		] );
141 141
 		do_action( 'pollux/settings/init' );
142 142
 	}
143 143
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function registerSetting()
149 149
 	{
150
-		register_setting( $this->id, $this->id, [$this, 'filterSavedSettings'] );
150
+		register_setting( $this->id, $this->id, [ $this, 'filterSavedSettings' ] );
151 151
 	}
152 152
 
153 153
 	/**
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			'confirm' => __( 'Are you sure want to do this?', 'pollux' ),
161 161
 			'hook' => $this->hook,
162 162
 			'id' => $this->id,
163
-		]);
163
+		] );
164 164
 	}
165 165
 
166 166
 	/**
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 			'columns' => get_current_screen()->get_columns(),
174 174
 			'id' => $this->id,
175 175
 			'title' => __( 'Site Settings', 'pollux' ),
176
-		]);
176
+		] );
177 177
 	}
178 178
 
179 179
 	/**
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
 		];
190 190
 		$this->render( 'settings/submit', [
191 191
 			'reset' => __( 'Reset Settings', 'pollux' ),
192
-			'reset_url' => esc_url( add_query_arg( $query, admin_url( 'admin.php' ))),
192
+			'reset_url' => esc_url( add_query_arg( $query, admin_url( 'admin.php' ) ) ),
193 193
 			'submit' => get_submit_button( __( 'Save', 'pollux' ), 'primary', 'submit', false ),
194
-		]);
194
+		] );
195 195
 	}
196 196
 
197 197
 	/**
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
 		if( filter_input( INPUT_GET, 'page' ) !== $this->id
204 204
 			|| filter_input( INPUT_GET, 'action' ) !== 'reset'
205 205
 		)return;
206
-		if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) {
206
+		if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook ) ) {
207 207
 			update_option( $this->id, $this->getDefaults() );
208 208
 			return add_settings_error( $this->id, 'reset', __( 'Settings reset to defaults.', 'pollux' ), 'updated' );
209 209
 		}
210
-		add_settings_error( $this->id, 'reset', __( 'Failed to reset settings. Please refresh the page and try again.', 'pollux' ));
210
+		add_settings_error( $this->id, 'reset', __( 'Failed to reset settings. Please refresh the page and try again.', 'pollux' ) );
211 211
 	}
212 212
 
213 213
 	/**
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	protected function filterArrayByKey( array $array, $key )
218 218
 	{
219 219
 		return array_filter( $array, function( $value ) use( $key ) {
220
-			return !empty( $value[$key] );
220
+			return !empty( $value[ $key ] );
221 221
 		});
222 222
 	}
223 223
 
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
 
231 231
 		array_walk( $metaboxes, function( &$metabox ) {
232 232
 			$fields = array_map( function( $field ) {
233
-				$field = wp_parse_args( $field, ['std' => ''] );
234
-				return [$field['slug'] => $field['std']];
235
-			}, $this->filterArrayByKey( $metabox['fields'], 'slug' ));
233
+				$field = wp_parse_args( $field, [ 'std' => '' ] );
234
+				return [ $field[ 'slug' ] => $field[ 'std' ] ];
235
+			}, $this->filterArrayByKey( $metabox[ 'fields' ], 'slug' ) );
236 236
 			$metabox = [
237
-				$metabox['slug'] => call_user_func_array( 'array_merge', $fields ),
237
+				$metabox[ 'slug' ] => call_user_func_array( 'array_merge', $fields ),
238 238
 			];
239 239
 		});
240 240
 		return call_user_func_array( 'array_merge', $metaboxes );
@@ -245,14 +245,14 @@  discard block
 block discarded – undo
245 245
 	 */
246 246
 	protected function normalize()
247 247
 	{
248
-		foreach( $this->app->config['settings'] as $id => $metabox ) {
248
+		foreach( $this->app->config[ 'settings' ] as $id => $metabox ) {
249 249
 			$defaults = [
250
-				'condition' => [],
251
-				'fields' => [],
250
+				'condition' => [ ],
251
+				'fields' => [ ],
252 252
 				'id' => $id,
253 253
 				'slug' => $id,
254 254
 			];
255
-			$this->metaboxes[] = $this->normalizeThis( $metabox, $defaults, $id );
255
+			$this->metaboxes[ ] = $this->normalizeThis( $metabox, $defaults, $id );
256 256
 		}
257 257
 	}
258 258
 
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
 	 */
264 264
 	protected function normalizeFieldName( $name, array $data, $parentId )
265 265
 	{
266
-		if( !empty( $name )) {
266
+		if( !empty( $name ) ) {
267 267
 			return $name;
268 268
 		}
269
-		$name = str_replace( sprintf( '%s-%s-', $this->id, $parentId ), '', $data['id'] );
269
+		$name = str_replace( sprintf( '%s-%s-', $this->id, $parentId ), '', $data[ 'id' ] );
270 270
 		return sprintf( '%s[%s][%s]', $this->id, $parentId, $name );
271 271
 	}
272 272
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -130,7 +130,9 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	public function register( $metaboxes = [] )
132 132
 	{
133
-		if( $this->app->screen()->id != $this->hook )return;
133
+		if( $this->app->screen()->id != $this->hook ) {
134
+			return;
135
+		}
134 136
 		foreach( parent::register() as $metabox ) {
135 137
 			new SettingsMetaBox( $metabox );
136 138
 		}
@@ -202,7 +204,9 @@  discard block
 block discarded – undo
202 204
 	{
203 205
 		if( filter_input( INPUT_GET, 'page' ) !== $this->id
204 206
 			|| filter_input( INPUT_GET, 'action' ) !== 'reset'
205
-		)return;
207
+		) {
208
+			return;
209
+		}
206 210
 		if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) {
207 211
 			update_option( $this->id, $this->getDefaults() );
208 212
 			return add_settings_error( $this->id, 'reset', __( 'Settings reset to defaults.', 'pollux' ), 'updated' );
@@ -216,7 +220,8 @@  discard block
 block discarded – undo
216 220
 	 */
217 221
 	protected function filterArrayByKey( array $array, $key )
218 222
 	{
219
-		return array_filter( $array, function( $value ) use( $key ) {
223
+		return array_filter( $array, function( $value ) use( $key )
224
+		{
220 225
 			return !empty( $value[$key] );
221 226
 		});
222 227
 	}
@@ -228,8 +233,10 @@  discard block
 block discarded – undo
228 233
 	{
229 234
 		$metaboxes = $this->filterArrayByKey( $this->metaboxes, 'slug' );
230 235
 
231
-		array_walk( $metaboxes, function( &$metabox ) {
232
-			$fields = array_map( function( $field ) {
236
+		array_walk( $metaboxes, function( &$metabox )
237
+		{
238
+			$fields = array_map( function( $field )
239
+			{
233 240
 				$field = wp_parse_args( $field, ['std' => ''] );
234 241
 				return [$field['slug'] => $field['std']];
235 242
 			}, $this->filterArrayByKey( $metabox['fields'], 'slug' ));
Please login to merge, or discard this patch.
src/SiteMeta.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
 	 */
15 15
 	public function get( $group = null, $key = null, $fallback = null )
16 16
 	{
17
-		$options = get_option( apply_filters( 'pollux/settings/option', Settings::ID ));
18
-		if( empty( $options )) {
17
+		$options = get_option( apply_filters( 'pollux/settings/option', Settings::ID ) );
18
+		if( empty( $options ) ) {
19 19
 			return $fallback;
20 20
 		}
21
-		if( !is_string( $group )) {
21
+		if( !is_string( $group ) ) {
22 22
 			return $options;
23 23
 		}
24 24
 		$group = $this->normalize( $options, $group, $fallback );
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
 	 */
35 35
 	protected function normalize( array $options, $key, $fallback )
36 36
 	{
37
-		if( !array_key_exists( $key, $options )) {
37
+		if( !array_key_exists( $key, $options ) ) {
38 38
 			return $fallback;
39 39
 		}
40
-		$option = $options[$key];
40
+		$option = $options[ $key ];
41 41
 		$option = is_array( $option )
42 42
 			? array_filter( $option )
43 43
 			: trim( $option );
Please login to merge, or discard this patch.