Passed
Branch master (3d135a)
by Paul
02:50
created
src/Settings/RWMetaBox.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.