Passed
Push — develop ( 5e8f92...83d763 )
by Paul
03:00
created
src/MetaBox/Instruction.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @var array
17 17
 	 */
18
-	public $metaboxes = [];
18
+	public $metaboxes = [ ];
19 19
 
20 20
 	/**
21 21
 	 * @return void
@@ -23,19 +23,19 @@  discard block
 block discarded – undo
23 23
 	protected function addInstructions()
24 24
 	{
25 25
 		if( !$this->showInstructions() )return;
26
-		$this->normalize([
26
+		$this->normalize( [
27 27
 			'infodiv' => [
28 28
 				'context' => 'side',
29
-				'fields' => [[
29
+				'fields' => [ [
30 30
 					'slug' => '',
31 31
 					'std' => $this->generateInstructions(),
32 32
 					'type' => 'custom_html',
33
-				]],
33
+				] ],
34 34
 				'post_types' => $this->getPostTypes(),
35 35
 				'priority' => 'low',
36 36
 				'title' => __( 'How to use in your theme', 'pollux' ),
37 37
 			],
38
-		]);
38
+		] );
39 39
 	}
40 40
 
41 41
 	/**
@@ -44,15 +44,15 @@  discard block
 block discarded – undo
44 44
 	protected function generateInstructions()
45 45
 	{
46 46
 		return array_reduce( $this->getInstructions(), function( $html, $metabox ) {
47
-			$fields = array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox ) {
48
-				if( !$this->validate( $field['condition'] )) {
47
+			$fields = array_reduce( $metabox[ 'fields' ], function( $html, $field ) use( $metabox ) {
48
+				if( !$this->validate( $field[ 'condition' ] ) ) {
49 49
 					return $html;
50 50
 				}
51
-				$hook = sprintf( 'pollux/%s/instruction', strtolower(( new Helper )->getClassname( $this )));
52
-				return $html . apply_filters( $hook, "PostMeta::get('{$field['slug']}');", $field['slug'], $metabox['slug'] ) . PHP_EOL;
51
+				$hook = sprintf( 'pollux/%s/instruction', strtolower( ( new Helper )->getClassname( $this ) ) );
52
+				return $html . apply_filters( $hook, "PostMeta::get('{$field[ 'slug' ]}');", $field[ 'slug' ], $metabox[ 'slug' ] ) . PHP_EOL;
53 53
 			});
54 54
 			return $html . sprintf( '<p><strong>%s</strong></p><pre class="my-sites nav-tab-active misc-pub-section">%s</pre>',
55
-				$metabox['title'],
55
+				$metabox[ 'title' ],
56 56
 				$fields
57 57
 			);
58 58
 		});
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	protected function getInstructions()
65 65
 	{
66 66
 		return array_filter( $this->metaboxes, function( $metabox ) {
67
-			return $this->validate( $metabox['condition'] )
67
+			return $this->validate( $metabox[ 'condition' ] )
68 68
 				&& $this->hasPostType( $metabox );
69 69
 		});
70 70
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	{
77 77
 		return count( array_filter( $this->metaboxes, function( $metabox ) {
78 78
 			return $this->show( false, $metabox );
79
-		})) > 0;
79
+		}) ) > 0;
80 80
 	}
81 81
 
82 82
 	/**
@@ -103,5 +103,5 @@  discard block
 block discarded – undo
103 103
 	/**
104 104
 	 * @return void
105 105
 	 */
106
-	abstract protected function normalize( array $metaboxes, array $defaults = [] );
106
+	abstract protected function normalize( array $metaboxes, array $defaults = [ ] );
107 107
 }
Please login to merge, or discard this patch.
src/PostType/Columns.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -10,12 +10,12 @@  discard block
 block discarded – undo
10 10
 	/**
11 11
 	 * @var array
12 12
 	 */
13
-	public $columns = [];
13
+	public $columns = [ ];
14 14
 
15 15
 	/**
16 16
 	 * @var array
17 17
 	 */
18
-	public $types = [];
18
+	public $types = [ ];
19 19
 
20 20
 	/**
21 21
 	 * @var Application
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
 	public function initColumns()
29 29
 	{
30 30
 		foreach( $this->types as $type => $args ) {
31
-			add_action( "manage_{$type}_posts_custom_column", [$this, 'printColumnValue'], 10, 2 );
31
+			add_action( "manage_{$type}_posts_custom_column", [ $this, 'printColumnValue' ], 10, 2 );
32 32
 			add_filter( "manage_{$type}_posts_columns", function( $columns ) use( $args ) {
33
-				return count( $args['columns'] ) > 1
34
-					? $args['columns']
33
+				return count( $args[ 'columns' ] ) > 1
34
+					? $args[ 'columns' ]
35 35
 					: $columns;
36 36
 			});
37 37
 		}
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 	protected function getColumnImage( $postId )
59 59
 	{
60 60
 		if( has_post_thumbnail( $postId ) ) {
61
-			list( $src, $width, $height ) = wp_get_attachment_image_src( get_post_thumbnail_id( $postId ), [96, 48] );
61
+			list( $src, $width, $height ) = wp_get_attachment_image_src( get_post_thumbnail_id( $postId ), [ 96, 48 ] );
62 62
 			$image = sprintf( '<img src="%s" alt="%s" width="%s" height="%s">',
63
-				esc_url( set_url_scheme( $src )),
64
-				esc_attr( get_the_title( $postId )),
63
+				esc_url( set_url_scheme( $src ) ),
64
+				esc_attr( get_the_title( $postId ) ),
65 65
 				$width,
66 66
 				$height
67 67
 			);
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
 	protected function getColumnMedia()
78 78
 	{
79 79
 		return count( PostMeta::get( 'media', [
80
-			'fallback' => [],
80
+			'fallback' => [ ],
81 81
 			'single' => false,
82
-		]));
82
+		] ) );
83 83
 	}
84 84
 
85 85
 	/**
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 	protected function normalizeColumns( array $columns )
98 98
 	{
99 99
 		$columns = array_flip( $columns );
100
-		$columns = array_merge( $columns, array_intersect_key( $this->columns, $columns ));
101
-		return ['cb' => '<input type="checkbox">'] + $columns;
100
+		$columns = array_merge( $columns, array_intersect_key( $this->columns, $columns ) );
101
+		return [ 'cb' => '<input type="checkbox">' ] + $columns;
102 102
 	}
103 103
 
104 104
 	/**
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 	{
109 109
 		$comments = sprintf(
110 110
 			'<span class="vers comment-grey-bubble" title="%1$s"><span class="screen-reader-text">%1$s</span></span>',
111
-			$this->app->config['columns']['comments']
111
+			$this->app->config[ 'columns' ][ 'comments' ]
112 112
 		);
113
-		$columns = wp_parse_args( $this->app->config['columns'], [
113
+		$columns = wp_parse_args( $this->app->config[ 'columns' ], [
114 114
 			'comments' => $comments,
115
-		]);
115
+		] );
116 116
 		$this->columns = apply_filters( 'pollux/post_type/columns', $columns );
117 117
 	}
118 118
 }
Please login to merge, or discard this patch.
src/MetaBox/MetaBox.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -19,20 +19,20 @@  discard block
 block discarded – undo
19 19
 	/**
20 20
 	 * @var array
21 21
 	 */
22
-	public $metaboxes = [];
22
+	public $metaboxes = [ ];
23 23
 
24 24
 	/**
25 25
 	 * {@inheritdoc}
26 26
 	 */
27 27
 	public function init()
28 28
 	{
29
-		$this->normalize( $this->app->config['meta_boxes'], [
30
-			'post_types' => [],
31
-		]);
29
+		$this->normalize( $this->app->config[ 'meta_boxes' ], [
30
+			'post_types' => [ ],
31
+		] );
32 32
 
33
-		add_filter( 'rwmb_show',       [$this, 'show'], 10, 2 );
34
-		add_filter( 'rwmb_meta_boxes', [$this, 'register'] );
35
-		add_filter( 'rwmb_outer_html', [$this, 'renderField'], 10, 2 );
33
+		add_filter( 'rwmb_show', [ $this, 'show' ], 10, 2 );
34
+		add_filter( 'rwmb_meta_boxes', [ $this, 'register' ] );
35
+		add_filter( 'rwmb_outer_html', [ $this, 'renderField' ], 10, 2 );
36 36
 	}
37 37
 
38 38
 	/**
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public function register()
43 43
 	{
44
-		if( current_user_can( 'switch_themes' )) {
44
+		if( current_user_can( 'switch_themes' ) ) {
45 45
 			$this->addInstructions();
46 46
 		}
47 47
 		$metaboxes = func_num_args()
48
-			? ( new Helper )->toArray( func_get_arg(0) )
49
-			: [];
48
+			? ( new Helper )->toArray( func_get_arg( 0 ) )
49
+			: [ ];
50 50
 		return array_merge( $metaboxes, $this->metaboxes );
51 51
 	}
52 52
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	public function renderField( $html, $field )
58 58
 	{
59
-		return $this->validate( $field['condition'] )
59
+		return $this->validate( $field[ 'condition' ] )
60 60
 			? $html
61 61
 			: '';
62 62
 	}
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 	public function show( $bool, array $metabox )
69 69
 	{
70 70
 		if( defined( 'DOING_AJAX' )
71
-			|| !isset( $metabox['condition'] )
72
-			|| !$this->hasPostType( $metabox )) {
71
+			|| !isset( $metabox[ 'condition' ] )
72
+			|| !$this->hasPostType( $metabox ) ) {
73 73
 			return $bool;
74 74
 		}
75
-		return $this->validate( $metabox['condition'] );
75
+		return $this->validate( $metabox[ 'condition' ] );
76 76
 	}
77 77
 
78 78
 	/**
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	protected function getPostId()
82 82
 	{
83
-		if( !( $postId = filter_input( INPUT_GET, 'post' ))) {
83
+		if( !( $postId = filter_input( INPUT_GET, 'post' ) ) ) {
84 84
 			$postId = filter_input( INPUT_POST, 'post_ID' );
85 85
 		}
86 86
 		return intval( $postId );
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
 	{
94 94
 		return array_unique( iterator_to_array(
95 95
 			new RecursiveIteratorIterator(
96
-				new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' ))
96
+				new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' ) )
97 97
 			),
98 98
 			false
99
-		));
99
+		) );
100 100
 	}
101 101
 
102 102
 	/**
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	{
107 107
 		return PostMeta::get( $key, [
108 108
 			'id' => $this->getPostId(),
109
-		]);
109
+		] );
110 110
 	}
111 111
 
112 112
 	/**
@@ -114,25 +114,25 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	protected function hasPostType( array $metabox )
116 116
 	{
117
-		if( !isset( $metabox['post_types'] )) {
117
+		if( !isset( $metabox[ 'post_types' ] ) ) {
118 118
 			return true;
119 119
 		}
120
-		return in_array( get_post_type( $this->getPostId() ), $metabox['post_types'] );
120
+		return in_array( get_post_type( $this->getPostId() ), $metabox[ 'post_types' ] );
121 121
 	}
122 122
 
123 123
 	/**
124 124
 	 * @return void
125 125
 	 */
126
-	protected function normalize( array $metaboxes, array $defaults = [] )
126
+	protected function normalize( array $metaboxes, array $defaults = [ ] )
127 127
 	{
128 128
 		foreach( $metaboxes as $id => $metabox ) {
129 129
 			$data = wp_parse_args( $defaults, [
130
-				'condition' => [],
131
-				'fields' => [],
130
+				'condition' => [ ],
131
+				'fields' => [ ],
132 132
 				'id' => $id,
133 133
 				'slug' => $id,
134
-			]);
135
-			$this->metaboxes[] = $this->setDependencies(
134
+			] );
135
+			$this->metaboxes[ ] = $this->setDependencies(
136 136
 				$this->normalizeThis( $metabox, $data, $id )
137 137
 			);
138 138
 		}
@@ -166,10 +166,10 @@  discard block
 block discarded – undo
166 166
 	protected function normalizeFields( array $fields, array $data, $parentId )
167 167
 	{
168 168
 		return array_map( function( $id, $field ) use( $parentId ) {
169
-			$defaults =  [
170
-				'attributes' => [],
169
+			$defaults = [
170
+				'attributes' => [ ],
171 171
 				'class' => '',
172
-				'condition' => [],
172
+				'condition' => [ ],
173 173
 				'depends' => '',
174 174
 				'field_name' => $id,
175 175
 				'id' => $id,
@@ -203,14 +203,14 @@  discard block
 block discarded – undo
203 203
 	 */
204 204
 	protected function setDependencies( array $metabox )
205 205
 	{
206
-		$fields = &$metabox['fields'];
206
+		$fields = &$metabox[ 'fields' ];
207 207
 		$depends = array_column( $fields, 'depends' );
208 208
 		array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) {
209
-			if( empty( $value ))return;
210
-			$dependency = array_search( $value, array_column( $fields, 'id' ));
211
-			$fields[$index]['attributes']['data-depends'] = $value;
212
-			if( !$this->getValue( $fields[$dependency]['slug'], $metabox['slug'] )) {
213
-				$fields[$index]['class'] = trim( 'hidden ' . $fields[$index]['class'] );
209
+			if( empty( $value ) )return;
210
+			$dependency = array_search( $value, array_column( $fields, 'id' ) );
211
+			$fields[ $index ][ 'attributes' ][ 'data-depends' ] = $value;
212
+			if( !$this->getValue( $fields[ $dependency ][ 'slug' ], $metabox[ 'slug' ] ) ) {
213
+				$fields[ $index ][ 'class' ] = trim( 'hidden ' . $fields[ $index ][ 'class' ] );
214 214
 			}
215 215
 		});
216 216
 		return $metabox;
Please login to merge, or discard this patch.
src/Helper.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 	 */
14 14
 	public function buildClassName( $name, $path = '' )
15 15
 	{
16
-		$className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name )));
16
+		$className = array_map( 'ucfirst', array_map( 'strtolower', preg_split( '/[-_]/', $name ) ) );
17 17
 		$className = implode( '', $className );
18 18
 		return !empty( $path )
19
-			? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className ))
19
+			? str_replace( '\\\\', '\\', sprintf( '%s\%s', $path, $className ) )
20 20
 			: $className;
21 21
 	}
22 22
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public function buildMethodName( $name, $prefix = 'get' )
29 29
 	{
30
-		return lcfirst( $this->buildClassName( $prefix . '-' . $name ));
30
+		return lcfirst( $this->buildClassName( $prefix . '-' . $name ) );
31 31
 	}
32 32
 
33 33
 	/**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function startsWith( $needle, $haystack )
78 78
 	{
79
-		return substr( $haystack, 0, strlen( $needle )) === $needle;
79
+		return substr( $haystack, 0, strlen( $needle ) ) === $needle;
80 80
 	}
81 81
 
82 82
 	/**
Please login to merge, or discard this patch.
src/Settings/RWMetaBox.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 		parent::__construct( $metabox );
16 16
 		$this->meta_box = static::normalize( $this->meta_box );
17 17
 
18
-		remove_action( 'add_meta_boxes', [$this, 'add_meta_boxes'] );
19
-		remove_action( 'save_post_post', [$this, 'save_post'] );
18
+		remove_action( 'add_meta_boxes', [ $this, 'add_meta_boxes' ] );
19
+		remove_action( 'save_post_post', [ $this, 'save_post' ] );
20 20
 
21
-		add_action( 'pollux/settings/init', [$this, 'add_meta_boxes'] );
22
-		add_filter( 'rwmb_field_meta',      [$this, '_get_field_meta'], 10, 3 );
21
+		add_action( 'pollux/settings/init', [ $this, 'add_meta_boxes' ] );
22
+		add_filter( 'rwmb_field_meta', [ $this, '_get_field_meta' ], 10, 3 );
23 23
 	}
24 24
 
25 25
 	/**
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 	 */
31 31
 	public function _get_field_meta( $meta, array $field, $saved )
32 32
 	{
33
-		if( !$this->is_edit_screen() || !empty(( new Helper )->toArray( $meta )) || empty( $field['slug'] )) {
33
+		if( !$this->is_edit_screen() || !empty( ( new Helper )->toArray( $meta ) ) || empty( $field[ 'slug' ] ) ) {
34 34
 			return $meta;
35 35
 		}
36
-		$meta = call_user_func( [RWMB_Field::get_class_name( $field ), 'esc_meta'], ( $saved
37
-			? SiteMeta::get( $this->meta_box['slug'], $field['slug'], $meta )
38
-			: $field['std']
39
-		));
36
+		$meta = call_user_func( [ RWMB_Field::get_class_name( $field ), 'esc_meta' ], ( $saved
37
+			? SiteMeta::get( $this->meta_box[ 'slug' ], $field[ 'slug' ], $meta )
38
+			: $field[ 'std' ]
39
+		) );
40 40
 		return $this->_normalize_field_meta( $meta, $field );
41 41
 	}
42 42
 
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 	 */
47 47
 	public function _normalize_field_meta( $meta, array $field )
48 48
 	{
49
-		if( !empty( $meta ) && is_array( $meta )) {
49
+		if( !empty( $meta ) && is_array( $meta ) ) {
50 50
 			return $meta;
51 51
 		}
52
-		if( $field['clone'] ) {
53
-			return [''];
52
+		if( $field[ 'clone' ] ) {
53
+			return [ '' ];
54 54
 		}
55
-		if( $field['multiple'] ) {
56
-			return [];
55
+		if( $field[ 'multiple' ] ) {
56
+			return [ ];
57 57
 		}
58 58
 		return $meta;
59 59
 	}
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
 	public function add_meta_boxes()
66 66
 	{
67 67
 		add_meta_box(
68
-			$this->meta_box['id'],
69
-			$this->meta_box['title'],
70
-			[$this, 'show'],
68
+			$this->meta_box[ 'id' ],
69
+			$this->meta_box[ 'title' ],
70
+			[ $this, 'show' ],
71 71
 			null,
72
-			$this->meta_box['context'],
73
-			$this->meta_box['priority']
72
+			$this->meta_box[ 'context' ],
73
+			$this->meta_box[ 'priority' ]
74 74
 		);
75 75
 	}
76 76
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	public function is_saved()
89 89
 	{
90 90
 		foreach( array_column( $this->fields, 'slug' ) as $field ) {
91
-			if( !is_null( SiteMeta::get( $this->meta_box['slug'], $field, null ))) {
91
+			if( !is_null( SiteMeta::get( $this->meta_box[ 'slug' ], $field, null ) ) ) {
92 92
 				return true;
93 93
 			}
94 94
 		}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public static function normalize( $metabox )
103 103
 	{
104
-		unset( $metabox['post_types'] );
105
-		return wp_parse_args( $metabox, ['slug' => ''] );
104
+		unset( $metabox[ 'post_types' ] );
105
+		return wp_parse_args( $metabox, [ 'slug' => '' ] );
106 106
 	}
107 107
 }
Please login to merge, or discard this patch.
src/Settings/Settings.php 1 patch
Spacing   +39 added lines, -39 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( 'wp_redirect',                       [$this, 'filterRedirectOnSave'] );
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( 'wp_redirect', [ $this, 'filterRedirectOnSave' ] );
57 57
 	}
58 58
 
59 59
 	/**
@@ -62,8 +62,8 @@  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 ));
66
-		return do_action_ref_array( $hook, array_filter( $args ));
65
+		$hook = sprintf( 'pollux/%s/%s', static::ID, array_shift( $args ) );
66
+		return do_action_ref_array( $hook, array_filter( $args ) );
67 67
 	}
68 68
 
69 69
 	/**
@@ -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,8 +105,8 @@  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 ));
109
-		return apply_filters_ref_array( $hook, array_filter( $args ));
108
+		$hook = sprintf( 'pollux/%s/%s', static::ID, array_shift( $args ) );
109
+		return apply_filters_ref_array( $hook, array_filter( $args ) );
110 110
 	}
111 111
 
112 112
 	/**
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 	public function filterRedirectOnSave( $location )
130 130
 	{
131 131
 		if( strpos( $location, 'settings-updated=true' ) === false
132
-			|| strpos( $location, sprintf( 'page=%s', static::id() )) === false ) {
132
+			|| strpos( $location, sprintf( 'page=%s', static::id() ) ) === false ) {
133 133
 			return $location;
134 134
 		}
135
-		return add_query_arg([
135
+		return add_query_arg( [
136 136
 			'page' => static::id(),
137 137
 			'settings-updated' => 'true',
138
-		], admin_url( 'admin.php' ));
138
+		], admin_url( 'admin.php' ) );
139 139
 	}
140 140
 
141 141
 	/**
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 	 */
146 146
 	public function filterSavedSettings( $settings )
147 147
 	{
148
-		if( is_null( $settings )) {
149
-			$settings = [];
148
+		if( is_null( $settings ) ) {
149
+			$settings = [ ];
150 150
 		}
151 151
 		$this->action( 'saved' );
152 152
 		return $this->filter( 'save', $settings );
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
 	 */
159 159
 	public function register()
160 160
 	{
161
-		if(( new Helper )->getCurrentScreen()->id != $this->hook )return;
161
+		if( ( new Helper )->getCurrentScreen()->id != $this->hook )return;
162 162
 		foreach( parent::register() as $metabox ) {
163 163
 			new RWMetaBox( $metabox );
164 164
 		}
165 165
 		add_screen_option( 'layout_columns', [
166 166
 			'max' => 2,
167 167
 			'default' => 2,
168
-		]);
168
+		] );
169 169
 		$this->action( 'init' );
170 170
 	}
171 171
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	public function registerSetting()
177 177
 	{
178
-		register_setting( static::id(), static::id(), [$this, 'filterSavedSettings'] );
178
+		register_setting( static::id(), static::id(), [ $this, 'filterSavedSettings' ] );
179 179
 	}
180 180
 
181 181
 	/**
@@ -184,12 +184,12 @@  discard block
 block discarded – undo
184 184
 	 */
185 185
 	public function renderFooterScript()
186 186
 	{
187
-		if(( new Helper )->getCurrentScreen()->id != $this->hook )return;
187
+		if( ( new Helper )->getCurrentScreen()->id != $this->hook )return;
188 188
 		$this->render( 'settings/script', [
189 189
 			'confirm' => __( 'Are you sure want to do this?', 'pollux' ),
190 190
 			'hook' => $this->hook,
191 191
 			'id' => static::id(),
192
-		]);
192
+		] );
193 193
 	}
194 194
 
195 195
 	/**
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 			'columns' => get_current_screen()->get_columns(),
203 203
 			'heading' => __( 'Site Settings', 'pollux' ),
204 204
 			'id' => static::id(),
205
-		]);
205
+		] );
206 206
 	}
207 207
 
208 208
 	/**
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 		];
219 219
 		$this->render( 'settings/submit', [
220 220
 			'reset' => __( 'Reset', 'pollux' ),
221
-			'reset_url' => esc_url( add_query_arg( $query, admin_url( 'admin.php' ))),
221
+			'reset_url' => esc_url( add_query_arg( $query, admin_url( 'admin.php' ) ) ),
222 222
 			'submit' => get_submit_button( __( 'Save', 'pollux' ), 'primary', 'submit', false ),
223
-		]);
223
+		] );
224 224
 	}
225 225
 
226 226
 	/**
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
 		if( filter_input( INPUT_GET, 'page' ) !== static::id()
233 233
 			|| filter_input( INPUT_GET, 'action' ) !== 'reset'
234 234
 		)return;
235
-		if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) {
235
+		if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook ) ) {
236 236
 			update_option( static::id(), $this->getDefaults() );
237 237
 			return add_settings_error( static::id(), 'reset', __( 'All values have been reset to defaults.', 'pollux' ), 'updated' );
238 238
 		}
239
-		add_settings_error( static::id(), 'reset', __( 'Failed to reset values. Please refresh the page and try again.', 'pollux' ));
239
+		add_settings_error( static::id(), 'reset', __( 'Failed to reset values. Please refresh the page and try again.', 'pollux' ) );
240 240
 	}
241 241
 
242 242
 	/**
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	protected function filterArrayByKey( array $array, $key )
247 247
 	{
248 248
 		return array_filter( $array, function( $value ) use( $key ) {
249
-			return !empty( $value[$key] );
249
+			return !empty( $value[ $key ] );
250 250
 		});
251 251
 	}
252 252
 
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
 
260 260
 		array_walk( $metaboxes, function( &$metabox ) {
261 261
 			$fields = array_map( function( $field ) {
262
-				$field = wp_parse_args( $field, ['std' => ''] );
263
-				return [$field['slug'] => $field['std']];
264
-			}, $this->filterArrayByKey( $metabox['fields'], 'slug' ));
262
+				$field = wp_parse_args( $field, [ 'std' => '' ] );
263
+				return [ $field[ 'slug' ] => $field[ 'std' ] ];
264
+			}, $this->filterArrayByKey( $metabox[ 'fields' ], 'slug' ) );
265 265
 			$metabox = [
266
-				$metabox['slug'] => call_user_func_array( 'array_merge', $fields ),
266
+				$metabox[ 'slug' ] => call_user_func_array( 'array_merge', $fields ),
267 267
 			];
268 268
 		});
269 269
 		return call_user_func_array( 'array_merge', $metaboxes );
@@ -284,10 +284,10 @@  discard block
 block discarded – undo
284 284
 	 */
285 285
 	protected function normalizeFieldName( $name, array $data, $parentId )
286 286
 	{
287
-		if( !empty( $name )) {
287
+		if( !empty( $name ) ) {
288 288
 			return $name;
289 289
 		}
290
-		$name = str_replace( sprintf( '%s-%s-', static::id(), $parentId ), '', $data['id'] );
290
+		$name = str_replace( sprintf( '%s-%s-', static::id(), $parentId ), '', $data[ 'id' ] );
291 291
 		return sprintf( '%s[%s][%s]', static::id(), $parentId, $name );
292 292
 	}
293 293
 
Please login to merge, or discard this patch.
src/Controller.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 */
26 26
 	public function filterWordPressFooter( $text )
27 27
 	{
28
-		if( $this->app->config['remove_wordpress_footer'] )return;
28
+		if( $this->app->config[ 'remove_wordpress_footer' ] )return;
29 29
 		return $text;
30 30
 	}
31 31
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	{
38 38
 		$screenId = ( new Helper )->getCurrentScreen()->id;
39 39
 
40
-		if(( new Helper )->endsWith( sprintf( '_page_%s', Archive::id() ), $screenId )) {
40
+		if( ( new Helper )->endsWith( sprintf( '_page_%s', Archive::id() ), $screenId ) ) {
41 41
 			wp_enqueue_script( 'editor-expand' );
42 42
 			wp_enqueue_script( 'common' );
43 43
 			wp_enqueue_script( 'wp-lists' );
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
 				wp_enqueue_script( 'jquery-touch-punch' );
47 47
 			}
48 48
 		}
49
-		if( $screenId == sprintf( 'toplevel_page_%s', Settings::id() )) {
49
+		if( $screenId == sprintf( 'toplevel_page_%s', Settings::id() ) ) {
50 50
 			wp_enqueue_script( 'common' );
51 51
 			wp_enqueue_script( 'wp-lists' );
52 52
 			wp_enqueue_script( 'postbox' );
53 53
 		}
54 54
 		wp_enqueue_style( 'pollux/main.css',
55 55
 			$this->app->url( 'assets/main.css' ),
56
-			apply_filters( 'pollux/enqueue/css/deps', [] ),
56
+			apply_filters( 'pollux/enqueue/css/deps', [ ] ),
57 57
 			$this->app->version
58 58
 		);
59 59
 		wp_enqueue_script( 'pollux/main.js',
60 60
 			$this->app->url( 'assets/main.js' ),
61
-			apply_filters( 'pollux/enqueue/js/deps', [] ),
61
+			apply_filters( 'pollux/enqueue/js/deps', [ ] ),
62 62
 			$this->app->version
63 63
 		);
64 64
 		wp_localize_script( 'pollux/main.js',
65 65
 			apply_filters( 'pollux/enqueue/js/localize/name', $this->app->id ),
66
-			apply_filters( 'pollux/enqueue/js/localize/variables', [] )
66
+			apply_filters( 'pollux/enqueue/js/localize/variables', [ ] )
67 67
 		);
68 68
 	}
69 69
 
@@ -73,11 +73,11 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	public function removeDashboardWidgets()
75 75
 	{
76
-		if( !$this->app->config['remove_dashboard_widgets'] )return;
76
+		if( !$this->app->config[ 'remove_dashboard_widgets' ] )return;
77 77
 		$widgets = apply_filters( 'pollux/dashoard/widgets', [
78 78
 			'dashboard_primary',
79 79
 			'dashboard_quick_press',
80
-		]);
80
+		] );
81 81
 		foreach( $widgets as $widget ) {
82 82
 			remove_meta_box( $widget, 'dashboard', 'normal' );
83 83
 		}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	public function removeWordPressMenu()
91 91
 	{
92
-		if( !$this->app->config['remove_wordpress_menu'] )return;
92
+		if( !$this->app->config[ 'remove_wordpress_menu' ] )return;
93 93
 		global $wp_admin_bar;
94 94
 		$wp_admin_bar->remove_menu( 'wp-logo' );
95 95
 	}
Please login to merge, or discard this patch.
src/MetaBox/Condition.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	public static function conditions()
23 23
 	{
24
-		return apply_filters( 'pollux/conditions', static::$conditions, strtolower(( new Helper )->getClassname( static::class )));
24
+		return apply_filters( 'pollux/conditions', static::$conditions, strtolower( ( new Helper )->getClassname( static::class ) ) );
25 25
 	}
26 26
 
27 27
 	/**
@@ -45,18 +45,18 @@  discard block
 block discarded – undo
45 45
 	protected function normalizeCondition( $conditions )
46 46
 	{
47 47
 		$conditions = ( new Helper )->toArray( $conditions );
48
-		if( count( array_filter( array_keys( $conditions ), 'is_string' )) == 0 ) {
48
+		if( count( array_filter( array_keys( $conditions ), 'is_string' ) ) == 0 ) {
49 49
 			foreach( $conditions as $key ) {
50
-				$conditions[str_replace( '!', '', $key )] = substr( $key, 0, 1 ) == '!' ? 0 : 1;
50
+				$conditions[ str_replace( '!', '', $key ) ] = substr( $key, 0, 1 ) == '!' ? 0 : 1;
51 51
 			}
52 52
 			$conditions = array_filter( $conditions, function( $key ) {
53 53
 				return !is_numeric( $key );
54 54
 			}, ARRAY_FILTER_USE_KEY );
55 55
 		}
56
-		$hook = sprintf( 'pollux/%s/conditions', strtolower(( new Helper )->getClassname( $this )));
56
+		$hook = sprintf( 'pollux/%s/conditions', strtolower( ( new Helper )->getClassname( $this ) ) );
57 57
 		return array_intersect_key(
58 58
 			$conditions,
59
-			array_flip( apply_filters( $hook, static::conditions() ))
59
+			array_flip( apply_filters( $hook, static::conditions() ) )
60 60
 		);
61 61
 	}
62 62
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 */
103 103
 	protected function validateIsFrontPage( $value )
104 104
 	{
105
-		return $value == ( $this->getPostId() == get_option( 'page_on_front' ));
105
+		return $value == ( $this->getPostId() == get_option( 'page_on_front' ) );
106 106
 	}
107 107
 
108 108
 	/**
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	protected function validateIsHome( $value )
113 113
 	{
114
-		return $value == ( $this->getPostId() == get_option( 'page_for_posts' ));
114
+		return $value == ( $this->getPostId() == get_option( 'page_for_posts' ) );
115 115
 	}
116 116
 
117 117
 	/**
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 */
121 121
 	protected function validateIsPageTemplate( $value )
122 122
 	{
123
-		return basename( get_page_template_slug( $this->getPostId() )) == $value;
123
+		return basename( get_page_template_slug( $this->getPostId() ) ) == $value;
124 124
 	}
125 125
 
126 126
 	/**
Please login to merge, or discard this patch.
src/MetaBox/PostMetaManager.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'   => 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.