Passed
Push — master ( a9e365...6c4de8 )
by Paul
02:25
created
src/MetaBox.php 1 patch
Spacing   +35 added lines, -35 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_action( 'rwmb_meta_boxes', [$this, 'register'] );
29
+		add_filter( 'rwmb_show', [ $this, 'isVisible' ], 10, 2 );
30
+		add_action( 'rwmb_meta_boxes', [ $this, 'register' ] );
31 31
 	}
32 32
 
33 33
 	/**
@@ -36,19 +36,19 @@  discard block
 block discarded – undo
36 36
 	public function isVisible( $bool, array $metabox )
37 37
 	{
38 38
 		if( defined( 'DOING_AJAX' )
39
-			|| !isset( $metabox['condition'] )
40
-			|| !$this->hasPostType( $metabox )) {
39
+			|| !isset( $metabox[ 'condition' ] )
40
+			|| !$this->hasPostType( $metabox ) ) {
41 41
 			return $bool;
42 42
 		}
43
-		return $this->verifyMetaBoxCondition( $metabox['condition'] );
43
+		return $this->verifyMetaBoxCondition( $metabox[ 'condition' ] );
44 44
 	}
45 45
 
46 46
 	/**
47 47
 	 * @return array
48 48
 	 */
49
-	public function register( $metaboxes = [] )
49
+	public function register( $metaboxes = [ ] )
50 50
 	{
51
-		if( current_user_can( 'switch_themes' )) {
51
+		if( current_user_can( 'switch_themes' ) ) {
52 52
 			$this->addInstructions();
53 53
 		}
54 54
 		return array_merge( $metaboxes, $this->metaboxes );
@@ -72,18 +72,18 @@  discard block
 block discarded – undo
72 72
 	{
73 73
 		if( !count( array_filter( $this->metaboxes, function( $metabox ) {
74 74
 			return $this->isVisible( false, $metabox );
75
-		})))return;
76
-		$this->metaboxes[] = [
75
+		}) ) )return;
76
+		$this->metaboxes[ ] = [
77 77
 			'id' => 'infodiv',
78 78
 			'post_types' => $this->getPostTypes(),
79 79
 			'title' => __( 'How to use in your theme', 'pollux' ),
80 80
 			'context' => 'side',
81 81
 			'priority' => 'low',
82
-			'fields' => [[
82
+			'fields' => [ [
83 83
 				'slug' => '',
84 84
 				'std' => $this->generateInstructions(),
85 85
 				'type' => 'custom_html',
86
-			]],
86
+			] ],
87 87
 		];
88 88
 	}
89 89
 
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
 	protected function generateInstructions()
94 94
 	{
95 95
 		return array_reduce( $this->getInstructions(), function( $html, $metabox ) {
96
-			$fields = array_reduce( array_column( $metabox['fields'], 'slug' ), function( $html, $slug ) use( $metabox ) {
96
+			$fields = array_reduce( array_column( $metabox[ 'fields' ], 'slug' ), function( $html, $slug ) use( $metabox ) {
97 97
 				$hook = sprintf( 'pollux/%s/instruction', $this->getClassname() );
98
-				return $html . apply_filters( $hook, "PostMeta::get('{$slug}');", $slug, $metabox['slug'] ) . PHP_EOL;
98
+				return $html . apply_filters( $hook, "PostMeta::get('{$slug}');", $slug, $metabox[ 'slug' ] ) . PHP_EOL;
99 99
 			});
100 100
 			return $html . sprintf( '<p><strong>%s</strong></p><pre class="my-sites nav-tab-active misc-pub-section">%s</pre>',
101
-				$metabox['title'],
101
+				$metabox[ 'title' ],
102 102
 				$fields
103 103
 			);
104 104
 		});
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	protected function getInstructions()
111 111
 	{
112 112
 		return array_filter( $this->metaboxes, function( $metabox ) {
113
-			return $this->verifyMetaBoxCondition( $metabox['condition'] )
113
+			return $this->verifyMetaBoxCondition( $metabox[ 'condition' ] )
114 114
 				&& $this->hasPostType( $metabox );
115 115
 		});
116 116
 	}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	protected function getPostId()
122 122
 	{
123
-		if( !( $postId = filter_input( INPUT_GET, 'post' ))) {
123
+		if( !( $postId = filter_input( INPUT_GET, 'post' ) ) ) {
124 124
 			$postId = filter_input( INPUT_POST, 'post_ID' );
125 125
 		}
126 126
 		return intval( $postId );
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
 	{
134 134
 		return array_unique( iterator_to_array(
135 135
 			new RecursiveIteratorIterator(
136
-				new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' ))
136
+				new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' ) )
137 137
 			),
138 138
 			false
139
-		));
139
+		) );
140 140
 	}
141 141
 
142 142
 	/**
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 	 */
145 145
 	protected function hasPostType( array $metabox )
146 146
 	{
147
-		if( !isset( $metabox['post_types'] )) {
147
+		if( !isset( $metabox[ 'post_types' ] ) ) {
148 148
 			return true;
149 149
 		}
150
-		return in_array( get_post_type( $this->getPostId() ), $metabox['post_types'] );
150
+		return in_array( get_post_type( $this->getPostId() ), $metabox[ 'post_types' ] );
151 151
 	}
152 152
 
153 153
 	/**
@@ -155,15 +155,15 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	protected function normalize()
157 157
 	{
158
-		foreach( $this->app->config['meta_boxes'] as $id => $metabox ) {
158
+		foreach( $this->app->config[ 'meta_boxes' ] as $id => $metabox ) {
159 159
 			$defaults = [
160
-				'condition' => [],
161
-				'fields' => [],
160
+				'condition' => [ ],
161
+				'fields' => [ ],
162 162
 				'id' => $id,
163
-				'post_types' => [],
163
+				'post_types' => [ ],
164 164
 				'slug' => $id,
165 165
 			];
166
-			$this->metaboxes[] = $this->normalizeThis( $metabox, $defaults, $id );
166
+			$this->metaboxes[ ] = $this->normalizeThis( $metabox, $defaults, $id );
167 167
 		}
168 168
 	}
169 169
 
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
 	protected function normalizeCondition( $conditions )
175 175
 	{
176 176
 		$conditions = $this->toArray( $conditions );
177
-		if( count( array_filter( array_keys( $conditions ), 'is_string' )) == 0 ) {
177
+		if( count( array_filter( array_keys( $conditions ), 'is_string' ) ) == 0 ) {
178 178
 			foreach( $conditions as $key ) {
179
-				$conditions[str_replace( '!', '', $key )] = substr( $key, 0, 1 ) == '!' ? 0 : 1;
179
+				$conditions[ str_replace( '!', '', $key ) ] = substr( $key, 0, 1 ) == '!' ? 0 : 1;
180 180
 			}
181 181
 			$conditions = array_filter( $conditions, function( $key ) {
182 182
 				return !is_numeric( $key );
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 		$hook = sprintf( 'pollux/%s/conditions', $this->getClassname() );
186 186
 		return array_intersect_key(
187 187
 			$conditions,
188
-			array_flip( apply_filters( $hook, static::CONDITIONS ))
188
+			array_flip( apply_filters( $hook, static::CONDITIONS ) )
189 189
 		);
190 190
 	}
191 191
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	protected function normalizeFields( array $fields, array $data, $parentId )
196 196
 	{
197 197
 		return array_map( function( $id, $field ) use( $parentId ) {
198
-			$defaults =  [
198
+			$defaults = [
199 199
 				'id' => $id,
200 200
 				'field_name' => '',
201 201
 				'slug' => $id,
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	 */
241 241
 	protected function validateIsFrontPage( $value )
242 242
 	{
243
-		return $value == ( $this->getPostId() == get_option( 'page_on_front' ));
243
+		return $value == ( $this->getPostId() == get_option( 'page_on_front' ) );
244 244
 	}
245 245
 
246 246
 	/**
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	 */
250 250
 	protected function validateIsHome( $value )
251 251
 	{
252
-		return $value == ( $this->getPostId() == get_option( 'page_for_posts' ));
252
+		return $value == ( $this->getPostId() == get_option( 'page_for_posts' ) );
253 253
 	}
254 254
 
255 255
 	/**
@@ -258,10 +258,10 @@  discard block
 block discarded – undo
258 258
 	 */
259 259
 	protected function validateIsPageTemplate( $value )
260 260
 	{
261
-		error_log( print_r( $value, 1 ));
262
-		error_log( print_r( basename( get_page_template_slug( $this->getPostId() )), 1 ));
261
+		error_log( print_r( $value, 1 ) );
262
+		error_log( print_r( basename( get_page_template_slug( $this->getPostId() ) ), 1 ) );
263 263
 
264
-		return basename( get_page_template_slug( $this->getPostId() )) == $value;
264
+		return basename( get_page_template_slug( $this->getPostId() ) ) == $value;
265 265
 	}
266 266
 
267 267
 	/**
Please login to merge, or discard this patch.
src/Taxonomy.php 1 patch
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_filter( 'parse_query',           [ $this, 'filterBy'] );
40
-		add_action( 'restrict_manage_posts', [ $this, 'printFilters'] );
41
-		add_action( 'init',                  [ $this, 'register'] );
39
+		add_filter( 'parse_query', [ $this, 'filterBy' ] );
40
+		add_action( 'restrict_manage_posts', [ $this, 'printFilters' ] );
41
+		add_action( 'init', [ $this, 'register' ] );
42 42
 	}
43 43
 
44 44
 	/**
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 		if( !is_admin() || get_current_screen()->base != 'edit' )return;
50 50
 		$vars = &$query->query_vars;
51 51
 		foreach( array_keys( $this->taxonomies ) as $taxonomy ) {
52
-			if( !isset( $vars[$taxonomy] ))return;
53
-			if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy )) {
54
-				$vars[$taxonomy] = $term->slug;
52
+			if( !isset( $vars[ $taxonomy ] ) )return;
53
+			if( $term = get_term_by( 'id', $vars[ $taxonomy ], $taxonomy ) ) {
54
+				$vars[ $taxonomy ] = $term->slug;
55 55
 			}
56 56
 		}
57 57
 		return $query;
@@ -64,18 +64,18 @@  discard block
 block discarded – undo
64 64
 	{
65 65
 		global $wp_query;
66 66
 		foreach( $this->taxonomies as $taxonomy => $args ) {
67
-			if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue;
68
-			$selected = isset( $wp_query->query[$taxonomy] )
69
-				? $wp_query->query[$taxonomy]
67
+			if( !in_array( get_current_screen()->post_type, $args[ 'post_types' ] ) )continue;
68
+			$selected = isset( $wp_query->query[ $taxonomy ] )
69
+				? $wp_query->query[ $taxonomy ]
70 70
 				: false;
71
-			wp_dropdown_categories([
71
+			wp_dropdown_categories( [
72 72
 				'hide_if_empty' => true,
73 73
 				'name' => $taxonomy,
74 74
 				'orderby' => 'name',
75 75
 				'selected' => $selected,
76
-				'show_option_all' => $args['labels']['all_items'],
76
+				'show_option_all' => $args[ 'labels' ][ 'all_items' ],
77 77
 				'taxonomy' => $taxonomy,
78
-			]);
78
+			] );
79 79
 		}
80 80
 	}
81 81
 
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 	public function register()
86 86
 	{
87 87
 		array_walk( $this->taxonomies, function( $args, $taxonomy ) {
88
-			register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( static::CUSTOM_KEYS )));
89
-			foreach( $args['post_types'] as $type ) {
88
+			register_taxonomy( $taxonomy, $args[ 'post_types' ], array_diff_key( $args, array_flip( static::CUSTOM_KEYS ) ) );
89
+			foreach( $args[ 'post_types' ] as $type ) {
90 90
 				register_taxonomy_for_object_type( $taxonomy, $type );
91 91
 			}
92 92
 		});
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	protected function normalize()
99 99
 	{
100
-		foreach( $this->app->config['taxonomies'] as $taxonomy => $args ) {
101
-			$this->taxonomies[$taxonomy] = apply_filters( 'pollux/taxonomy/args',
100
+		foreach( $this->app->config[ 'taxonomies' ] as $taxonomy => $args ) {
101
+			$this->taxonomies[ $taxonomy ] = apply_filters( 'pollux/taxonomy/args',
102 102
 				$this->normalizeThis( $args, static::TAXONOMY_DEFAULTS, $taxonomy )
103 103
 			);
104 104
 		}
105 105
 		$this->taxonomies = array_diff_key(
106 106
 			$this->taxonomies,
107
-			get_taxonomies( ['_builtin' => true] )
107
+			get_taxonomies( [ '_builtin' => true ] )
108 108
 		);
109 109
 	}
110 110
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	protected function normalizeLabels( $labels, array $args )
116 116
 	{
117
-		return wp_parse_args( $labels, $this->setLabels( $args ));
117
+		return wp_parse_args( $labels, $this->setLabels( $args ) );
118 118
 	}
119 119
 
120 120
 	/**
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	protected function normalizeMenuName( $menuname, array $args )
125 125
 	{
126 126
 		return empty( $menuname )
127
-			? $args['plural']
127
+			? $args[ 'plural' ]
128 128
 			: $menuname;
129 129
 	}
130 130
 
@@ -143,17 +143,17 @@  discard block
 block discarded – undo
143 143
 	protected function setLabels( array $args )
144 144
 	{
145 145
 		return apply_filters( 'pollux/taxonomy/labels', [
146
-			'add_new_item' => sprintf( _x( 'Add New %s', 'Add new taxonomy', 'pollux' ), $args['single'] ),
147
-			'all_items' => sprintf( _x( 'All %s', 'All taxonomies', 'pollux' ), $args['plural'] ),
148
-			'edit_item' => sprintf( _x( 'Edit %s', 'Edit taxonomy', 'pollux' ), $args['single'] ),
149
-			'menu_name' => $this->normalizeMenuName( $args['menu_name'], $args ),
150
-			'name' => $args['plural'],
151
-			'new_item_name' => sprintf( _x( 'New %s Name', 'New taxonomy name', 'pollux' ), $args['single'] ),
152
-			'not_found' => sprintf( _x( 'No %s found', 'No taxonomies found', 'pollux' ), $args['plural'] ),
153
-			'search_items' => sprintf( _x( 'Search %s', 'Search taxonomies', 'pollux' ), $args['plural'] ),
154
-			'singular_name' => $args['single'],
155
-			'update_item' => sprintf( _x( 'Update %s', 'Update taxonomy', 'pollux' ), $args['single'] ),
156
-			'view_item' => sprintf( _x( 'View %s', 'View taxonomy', 'pollux' ), $args['single'] ),
146
+			'add_new_item' => sprintf( _x( 'Add New %s', 'Add new taxonomy', 'pollux' ), $args[ 'single' ] ),
147
+			'all_items' => sprintf( _x( 'All %s', 'All taxonomies', 'pollux' ), $args[ 'plural' ] ),
148
+			'edit_item' => sprintf( _x( 'Edit %s', 'Edit taxonomy', 'pollux' ), $args[ 'single' ] ),
149
+			'menu_name' => $this->normalizeMenuName( $args[ 'menu_name' ], $args ),
150
+			'name' => $args[ 'plural' ],
151
+			'new_item_name' => sprintf( _x( 'New %s Name', 'New taxonomy name', 'pollux' ), $args[ 'single' ] ),
152
+			'not_found' => sprintf( _x( 'No %s found', 'No taxonomies found', 'pollux' ), $args[ 'plural' ] ),
153
+			'search_items' => sprintf( _x( 'Search %s', 'Search taxonomies', 'pollux' ), $args[ 'plural' ] ),
154
+			'singular_name' => $args[ 'single' ],
155
+			'update_item' => sprintf( _x( 'Update %s', 'Update taxonomy', 'pollux' ), $args[ 'single' ] ),
156
+			'view_item' => sprintf( _x( 'View %s', 'View taxonomy', 'pollux' ), $args[ 'single' ] ),
157 157
 		], $args );
158 158
 	}
159 159
 }
Please login to merge, or discard this patch.
src/PostType.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 
14 14
 	const POST_TYPE_DEFAULTS = [
15 15
 		'capability_type' => 'post',
16
-		'columns' => [],
16
+		'columns' => [ ],
17 17
 		'has_archive' => false,
18 18
 		'hierarchical' => false,
19
-		'labels' => [],
19
+		'labels' => [ ],
20 20
 		'map_meta_cap' => true,
21 21
 		'menu_icon' => null,
22 22
 		'menu_name' => '',
@@ -29,19 +29,19 @@  discard block
 block discarded – undo
29 29
 		'show_ui' => true,
30 30
 		'single' => '',
31 31
 		'slug' => '',
32
-		'supports' => ['title', 'editor', 'thumbnail'],
33
-		'taxonomies' => [],
32
+		'supports' => [ 'title', 'editor', 'thumbnail' ],
33
+		'taxonomies' => [ ],
34 34
 	];
35 35
 
36 36
 	/**
37 37
 	 * @var array
38 38
 	 */
39
-	public $columns = [];
39
+	public $columns = [ ];
40 40
 
41 41
 	/**
42 42
 	 * @var array
43 43
 	 */
44
-	public $types = [];
44
+	public $types = [ ];
45 45
 
46 46
 	/**
47 47
 	 * {@inheritdoc}
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
 	{
51 51
 		$this->normalize();
52 52
 
53
-		add_action( 'init', [$this, 'register'] );
53
+		add_action( 'init', [ $this, 'register' ] );
54 54
 
55 55
 		foreach( $this->types as $type => $args ) {
56
-			add_action( "manage_{$type}_posts_custom_column", [$this, 'printColumnValue'], 10, 2 );
56
+			add_action( "manage_{$type}_posts_custom_column", [ $this, 'printColumnValue' ], 10, 2 );
57 57
 			add_filter( "manage_{$type}_posts_columns", function( $columns ) use( $args ) {
58
-				return count( $args['columns'] ) > 1
59
-					? $args['columns']
58
+				return count( $args[ 'columns' ] ) > 1
59
+					? $args[ 'columns' ]
60 60
 					: $columns;
61 61
 			});
62 62
 		}
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 	{
70 70
 		$types = array_diff_key(
71 71
 			$this->types,
72
-			get_post_types( ['_builtin' => true] )
72
+			get_post_types( [ '_builtin' => true ] )
73 73
 		);
74 74
 		array_walk( $types, function( $args, $type ) {
75
-			register_post_type( $type, array_diff_key( $args, array_flip( static::CUSTOM_KEYS )));
75
+			register_post_type( $type, array_diff_key( $args, array_flip( static::CUSTOM_KEYS ) ) );
76 76
 		});
77 77
 	}
78 78
 
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 	protected function normalize()
96 96
 	{
97 97
 		$this->setColumns();
98
-		foreach( $this->app->config['post_types'] as $type => $args ) {
99
-			$this->types[$type] = apply_filters( 'pollux/post_type/args',
98
+		foreach( $this->app->config[ 'post_types' ] as $type => $args ) {
99
+			$this->types[ $type ] = apply_filters( 'pollux/post_type/args',
100 100
 				$this->normalizeThis( $args, static::POST_TYPE_DEFAULTS, $type ),
101 101
 				$type
102 102
 			);
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	protected function normalizeColumns( array $columns )
110 110
 	{
111 111
 		$columns = array_flip( $columns );
112
-		$columns = array_merge( $columns, array_intersect_key( $this->columns, $columns ));
113
-		return ['cb' => '<input type="checkbox">'] + $columns;
112
+		$columns = array_merge( $columns, array_intersect_key( $this->columns, $columns ) );
113
+		return [ 'cb' => '<input type="checkbox">' ] + $columns;
114 114
 	}
115 115
 
116 116
 	/**
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	protected function normalizeLabels( $labels, array $args )
121 121
 	{
122
-		return wp_parse_args( $labels, $this->setLabels( $args ));
122
+		return wp_parse_args( $labels, $this->setLabels( $args ) );
123 123
 	}
124 124
 
125 125
 	/**
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	protected function normalizeMenuName( $menuname, array $args )
130 130
 	{
131 131
 		return empty( $menuname )
132
-			? $args['plural']
132
+			? $args[ 'plural' ]
133 133
 			: $menuname;
134 134
 	}
135 135
 
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
 	protected function normalizeRewrite( $rewrite, array $args )
141 141
 	{
142 142
 		if( $rewrite === true ) {
143
-			$slug = empty( $args['slug'] )
144
-				? sanitize_title( $args['plural'] )
145
-				: $args['slug'];
146
-			$rewrite = ['slug' => $slug, 'with_front' => false];
143
+			$slug = empty( $args[ 'slug' ] )
144
+				? sanitize_title( $args[ 'plural' ] )
145
+				: $args[ 'slug' ];
146
+			$rewrite = [ 'slug' => $slug, 'with_front' => false ];
147 147
 		}
148 148
 		return $rewrite;
149 149
 	}
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
 	protected function getColumnImage( $postId )
156 156
 	{
157 157
 		if( has_post_thumbnail( $postId ) ) {
158
-			list( $src, $width, $height ) = wp_get_attachment_image_src( get_post_thumbnail_id( $postId ), [96, 48] );
158
+			list( $src, $width, $height ) = wp_get_attachment_image_src( get_post_thumbnail_id( $postId ), [ 96, 48 ] );
159 159
 			$image = sprintf( '<img src="%s" alt="%s" width="%s" height="%s">',
160
-				esc_url( set_url_scheme( $src )),
161
-				esc_attr( get_the_title( $postId )),
160
+				esc_url( set_url_scheme( $src ) ),
161
+				esc_attr( get_the_title( $postId ) ),
162 162
 				$width,
163 163
 				$height
164 164
 			);
@@ -173,10 +173,10 @@  discard block
 block discarded – undo
173 173
 	 */
174 174
 	protected function getColumnMedia()
175 175
 	{
176
-		return count( (new PostMeta)->get( 'media', [
177
-			'fallback' => [],
176
+		return count( ( new PostMeta )->get( 'media', [
177
+			'fallback' => [ ],
178 178
 			'single' => false,
179
-		]));
179
+		] ) );
180 180
 	}
181 181
 
182 182
 	/**
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 	{
196 196
 		$comments = sprintf(
197 197
 			'<span class="vers comment-grey-bubble" title="%1$s"><span class="screen-reader-text">%1$s</span></span>',
198
-			$this->app->config['columns']['comments']
198
+			$this->app->config[ 'columns' ][ 'comments' ]
199 199
 		);
200
-		$columns = wp_parse_args( $this->app->config['columns'], [
200
+		$columns = wp_parse_args( $this->app->config[ 'columns' ], [
201 201
 			'comments' => $comments,
202
-		]);
202
+		] );
203 203
 		$this->columns = apply_filters( 'pollux/post_type/columns', $columns );
204 204
 	}
205 205
 
@@ -210,17 +210,17 @@  discard block
 block discarded – undo
210 210
 	{
211 211
 		return apply_filters( 'pollux/post_type/labels', [
212 212
 			'add_new' => __( 'Add New', 'pollux' ),
213
-			'add_new_item' => sprintf( _x( 'Add New %s', 'Add new post', 'pollux' ), $args['single'] ),
214
-			'all_items' => sprintf( _x( 'All %s', 'All posts', 'pollux' ), $args['plural'] ),
215
-			'edit_item' => sprintf( _x( 'Edit %s', 'Edit post', 'pollux' ), $args['single'] ),
216
-			'menu_name' => $this->normalizeMenuName( $args['menu_name'], $args ),
217
-			'name' => $args['plural'],
218
-			'new_item' => sprintf( _x( 'New %s', 'New post', 'pollux' ), $args['single'] ),
219
-			'not_found' => sprintf( _x( 'No %s found', 'No posts found', 'pollux' ), $args['plural'] ),
220
-			'not_found_in_trash' => sprintf( _x( 'No %s found in Trash', 'No posts found in trash', 'pollux' ), $args['plural'] ),
221
-			'search_items' => sprintf( _x( 'Search %s', 'Search posts', 'pollux' ), $args['plural'] ),
222
-			'singular_name' => $args['single'],
223
-			'view_item' => sprintf( _x( 'View %s', 'View post', 'pollux' ), $args['single'] ),
213
+			'add_new_item' => sprintf( _x( 'Add New %s', 'Add new post', 'pollux' ), $args[ 'single' ] ),
214
+			'all_items' => sprintf( _x( 'All %s', 'All posts', 'pollux' ), $args[ 'plural' ] ),
215
+			'edit_item' => sprintf( _x( 'Edit %s', 'Edit post', 'pollux' ), $args[ 'single' ] ),
216
+			'menu_name' => $this->normalizeMenuName( $args[ 'menu_name' ], $args ),
217
+			'name' => $args[ 'plural' ],
218
+			'new_item' => sprintf( _x( 'New %s', 'New post', 'pollux' ), $args[ 'single' ] ),
219
+			'not_found' => sprintf( _x( 'No %s found', 'No posts found', 'pollux' ), $args[ 'plural' ] ),
220
+			'not_found_in_trash' => sprintf( _x( 'No %s found in Trash', 'No posts found in trash', 'pollux' ), $args[ 'plural' ] ),
221
+			'search_items' => sprintf( _x( 'Search %s', 'Search posts', 'pollux' ), $args[ 'plural' ] ),
222
+			'singular_name' => $args[ 'single' ],
223
+			'view_item' => sprintf( _x( 'View %s', 'View post', 'pollux' ), $args[ 'single' ] ),
224 224
 		], $args );
225 225
 	}
226 226
 }
Please login to merge, or discard this patch.
src/Settings.php 2 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 
33 33
 		$this->normalize();
34 34
 
35
-		add_action( 'admin_menu',                               [$this, 'addPage'] );
36
-		add_action( 'pollux/settings/init',                     [$this, 'addSubmitMetaBox'] );
37
-		add_filter( 'pollux/settings/instruction',              [$this, 'filterInstruction'], 10, 3 );
38
-		add_filter( 'wp_redirect',                              [$this, 'filterRedirectOnSave'] );
39
-		add_action( 'current_screen',                           [$this, 'register'] );
40
-		add_action( 'admin_menu',                               [$this, 'registerSetting'] );
41
-		add_action( 'pollux/settings/init',                     [$this, 'reset'] );
42
-		add_action( 'admin_footer-toplevel_page_' . static::ID, [$this, 'renderFooterScript'] );
35
+		add_action( 'admin_menu', [ $this, 'addPage' ] );
36
+		add_action( 'pollux/settings/init', [ $this, 'addSubmitMetaBox' ] );
37
+		add_filter( 'pollux/settings/instruction', [ $this, 'filterInstruction' ], 10, 3 );
38
+		add_filter( 'wp_redirect', [ $this, 'filterRedirectOnSave' ] );
39
+		add_action( 'current_screen', [ $this, 'register' ] );
40
+		add_action( 'admin_menu', [ $this, 'registerSetting' ] );
41
+		add_action( 'pollux/settings/init', [ $this, 'reset' ] );
42
+		add_action( 'admin_footer-toplevel_page_' . static::ID, [ $this, 'renderFooterScript' ] );
43 43
 	}
44 44
 
45 45
 	/**
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 			__( 'Site Settings', 'pollux' ),
53 53
 			'edit_theme_options',
54 54
 			static::ID,
55
-			[$this, 'renderPage'],
55
+			[ $this, 'renderPage' ],
56 56
 			'dashicons-screenoptions',
57 57
 			1313
58
-		]));
58
+		] ) );
59 59
 	}
60 60
 
61 61
 	/**
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
 		call_user_func_array( 'add_meta_box', apply_filters( 'pollux/settings/metabox/submit', [
67 67
 			'submitdiv',
68 68
 			__( 'Save Settings', 'pollux' ),
69
-			[ $this, 'renderSubmitMetaBox'],
69
+			[ $this, 'renderSubmitMetaBox' ],
70 70
 			$this->hook,
71 71
 			'side',
72 72
 			'high',
73
-		]));
73
+		] ) );
74 74
 	}
75 75
 
76 76
 	/**
@@ -91,19 +91,19 @@  discard block
 block discarded – undo
91 91
 	public function filterRedirectOnSave( $location )
92 92
 	{
93 93
 		if( strpos( $location, 'settings-updated=true' ) === false
94
-			|| strpos( $location, sprintf( 'page=%s', static::ID )) === false ) {
94
+			|| strpos( $location, sprintf( 'page=%s', static::ID ) ) === false ) {
95 95
 			return $location;
96 96
 		}
97
-		return add_query_arg([
97
+		return add_query_arg( [
98 98
 			'page' => static::ID,
99 99
 			'settings-updated' => 'true',
100
-		], admin_url( 'admin.php' ));
100
+		], admin_url( 'admin.php' ) );
101 101
 	}
102 102
 
103 103
 	/**
104 104
 	 * @return void
105 105
 	 */
106
-	public function register( $metaboxes = [] )
106
+	public function register( $metaboxes = [ ] )
107 107
 	{
108 108
 		if( get_current_screen()->id != $this->hook )return;
109 109
 		foreach( parent::register() as $metabox ) {
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		add_screen_option( 'layout_columns', [
113 113
 			'max' => 2,
114 114
 			'default' => 2,
115
-		]);
115
+		] );
116 116
 		do_action( 'pollux/settings/init' );
117 117
 	}
118 118
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 			'confirm' => __( 'Are you sure want to do this?', 'pollux' ),
134 134
 			'hook' => $this->hook,
135 135
 			'id' => static::ID,
136
-		]);
136
+		] );
137 137
 	}
138 138
 
139 139
 	/**
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 			'columns' => get_current_screen()->get_columns(),
146 146
 			'id' => static::ID,
147 147
 			'title' => __( 'Site Settings', 'pollux' ),
148
-		]);
148
+		] );
149 149
 	}
150 150
 
151 151
 	/**
@@ -160,9 +160,9 @@  discard block
 block discarded – undo
160 160
 		];
161 161
 		$this->render( 'settings/submit', [
162 162
 			'reset' => __( 'Reset Settings', 'pollux' ),
163
-			'reset_url' => esc_url( add_query_arg( $query, admin_url( 'admin.php' ))),
163
+			'reset_url' => esc_url( add_query_arg( $query, admin_url( 'admin.php' ) ) ),
164 164
 			'submit' => get_submit_button( __( 'Save', 'pollux' ), 'primary', 'submit', false ),
165
-		]);
165
+		] );
166 166
 	}
167 167
 
168 168
 	/**
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 		if( filter_input( INPUT_GET, 'page' ) !== static::ID
174 174
 			|| filter_input( INPUT_GET, 'action' ) !== 'reset'
175 175
 		)return;
176
-		if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) {
176
+		if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook ) ) {
177 177
 			update_option( static::ID, $this->getDefaults() );
178 178
 			return add_settings_error( static::ID, 'reset', __( 'Settings reset to defaults.', 'pollux' ), 'updated' );
179 179
 		}
180
-		add_settings_error( static::ID, 'reset', __( 'Failed to reset settings. Please refresh the page and try again.', 'pollux' ));
180
+		add_settings_error( static::ID, 'reset', __( 'Failed to reset settings. Please refresh the page and try again.', 'pollux' ) );
181 181
 	}
182 182
 
183 183
 	/**
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	protected function filterArrayByKey( array $array, $key )
188 188
 	{
189 189
 		return array_filter( $array, function( $value ) use( $key ) {
190
-			return !empty( $value[$key] );
190
+			return !empty( $value[ $key ] );
191 191
 		});
192 192
 	}
193 193
 
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
 
201 201
 		array_walk( $metaboxes, function( &$metabox ) {
202 202
 			$fields = array_map( function( $field ) {
203
-				$field = wp_parse_args( $field, ['std' => ''] );
204
-				return [$field['slug'] => $field['std']];
205
-			}, $this->filterArrayByKey( $metabox['fields'], 'slug' ));
203
+				$field = wp_parse_args( $field, [ 'std' => '' ] );
204
+				return [ $field[ 'slug' ] => $field[ 'std' ] ];
205
+			}, $this->filterArrayByKey( $metabox[ 'fields' ], 'slug' ) );
206 206
 			$metabox = [
207
-				$metabox['slug'] => call_user_func_array( 'array_merge', $fields ),
207
+				$metabox[ 'slug' ] => call_user_func_array( 'array_merge', $fields ),
208 208
 			];
209 209
 		});
210 210
 		return call_user_func_array( 'array_merge', $metaboxes );
@@ -215,14 +215,14 @@  discard block
 block discarded – undo
215 215
 	 */
216 216
 	protected function normalize()
217 217
 	{
218
-		foreach( $this->app->config['settings'] as $id => $metabox ) {
218
+		foreach( $this->app->config[ 'settings' ] as $id => $metabox ) {
219 219
 			$defaults = [
220
-				'condition' => [],
221
-				'fields' => [],
220
+				'condition' => [ ],
221
+				'fields' => [ ],
222 222
 				'id' => $id,
223 223
 				'slug' => $id,
224 224
 			];
225
-			$this->metaboxes[] = $this->normalizeThis( $metabox, $defaults, $id );
225
+			$this->metaboxes[ ] = $this->normalizeThis( $metabox, $defaults, $id );
226 226
 		}
227 227
 	}
228 228
 
@@ -233,10 +233,10 @@  discard block
 block discarded – undo
233 233
 	 */
234 234
 	protected function normalizeFieldName( $name, array $data, $parentId )
235 235
 	{
236
-		if( !empty( $name )) {
236
+		if( !empty( $name ) ) {
237 237
 			return $name;
238 238
 		}
239
-		$name = str_replace( sprintf( '%s-%s-', static::ID, $parentId ), '', $data['id'] );
239
+		$name = str_replace( sprintf( '%s-%s-', static::ID, $parentId ), '', $data[ 'id' ] );
240 240
 		return sprintf( '%s[%s][%s]', static::ID, $parentId, $name );
241 241
 	}
242 242
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -105,7 +105,9 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	public function register( $metaboxes = [] )
107 107
 	{
108
-		if( get_current_screen()->id != $this->hook )return;
108
+		if( get_current_screen()->id != $this->hook ) {
109
+			return;
110
+		}
109 111
 		foreach( parent::register() as $metabox ) {
110 112
 			new SettingsMetaBox( $metabox );
111 113
 		}
@@ -172,7 +174,9 @@  discard block
 block discarded – undo
172 174
 	{
173 175
 		if( filter_input( INPUT_GET, 'page' ) !== static::ID
174 176
 			|| filter_input( INPUT_GET, 'action' ) !== 'reset'
175
-		)return;
177
+		) {
178
+			return;
179
+		}
176 180
 		if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) {
177 181
 			update_option( static::ID, $this->getDefaults() );
178 182
 			return add_settings_error( static::ID, 'reset', __( 'Settings reset to defaults.', 'pollux' ), 'updated' );
@@ -186,7 +190,8 @@  discard block
 block discarded – undo
186 190
 	 */
187 191
 	protected function filterArrayByKey( array $array, $key )
188 192
 	{
189
-		return array_filter( $array, function( $value ) use( $key ) {
193
+		return array_filter( $array, function( $value ) use( $key )
194
+		{
190 195
 			return !empty( $value[$key] );
191 196
 		});
192 197
 	}
@@ -198,8 +203,10 @@  discard block
 block discarded – undo
198 203
 	{
199 204
 		$metaboxes = $this->filterArrayByKey( $this->metaboxes, 'slug' );
200 205
 
201
-		array_walk( $metaboxes, function( &$metabox ) {
202
-			$fields = array_map( function( $field ) {
206
+		array_walk( $metaboxes, function( &$metabox )
207
+		{
208
+			$fields = array_map( function( $field )
209
+			{
203 210
 				$field = wp_parse_args( $field, ['std' => ''] );
204 211
 				return [$field['slug'] => $field['std']];
205 212
 			}, $this->filterArrayByKey( $metabox['fields'], 'slug' ));
Please login to merge, or discard this patch.