@@ -19,13 +19,13 @@ discard block |
||
19 | 19 | $this->pollux_caller = $caller; |
20 | 20 | $this->pollux_id = $id; |
21 | 21 | |
22 | - remove_action( 'add_meta_boxes', [$this, 'add_meta_boxes'] ); |
|
23 | - remove_action( 'save_post_post', [$this, 'save_post'] ); |
|
22 | + remove_action( 'add_meta_boxes', [ $this, 'add_meta_boxes' ] ); |
|
23 | + remove_action( 'save_post_post', [ $this, 'save_post' ] ); |
|
24 | 24 | |
25 | - add_action( 'pollux/archives/init', [$this, 'add_meta_boxes'] ); |
|
26 | - add_action( 'pollux/settings/init', [$this, 'add_meta_boxes'] ); |
|
27 | - add_filter( 'rwmb_field_meta', [$this, '_get_field_meta'], 10, 3 ); |
|
28 | - add_filter( 'rwmb_normalize_field', [$this, '_normalize_field'] ); |
|
25 | + add_action( 'pollux/archives/init', [ $this, 'add_meta_boxes' ] ); |
|
26 | + add_action( 'pollux/settings/init', [ $this, 'add_meta_boxes' ] ); |
|
27 | + add_filter( 'rwmb_field_meta', [ $this, '_get_field_meta' ], 10, 3 ); |
|
28 | + add_filter( 'rwmb_normalize_field', [ $this, '_normalize_field' ] ); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function _get_field_meta( $meta, array $field, $saved ) |
38 | 38 | { |
39 | - if( !$this->is_edit_screen() || !empty(( new Helper )->toArray( $meta )) || empty( $field['slug'] )) { |
|
39 | + if( !$this->is_edit_screen() || !empty( ( new Helper )->toArray( $meta ) ) || empty( $field[ 'slug' ] ) ) { |
|
40 | 40 | return $meta; |
41 | 41 | } |
42 | - $meta = call_user_func( [RWMB_Field::get_class_name( $field ), 'esc_meta'], ( $saved |
|
43 | - ? $this->pollux_caller->getMetaValue( $field['slug'], $meta, $this->meta_box['slug'] ) |
|
44 | - : $field['std'] |
|
45 | - )); |
|
42 | + $meta = call_user_func( [ RWMB_Field::get_class_name( $field ), 'esc_meta' ], ( $saved |
|
43 | + ? $this->pollux_caller->getMetaValue( $field[ 'slug' ], $meta, $this->meta_box[ 'slug' ] ) |
|
44 | + : $field[ 'std' ] |
|
45 | + ) ); |
|
46 | 46 | return $this->_normalize_field_meta( $meta, $field ); |
47 | 47 | } |
48 | 48 | |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function _normalize_field( $field ) |
54 | 54 | { |
55 | - if( !empty( $field['multiple'] ) && $field['id'] == substr( $field['field_name'], 0, -2 )) { |
|
56 | - $parts = array_filter( explode( '-', $field['id'] )); |
|
55 | + if( !empty( $field[ 'multiple' ] ) && $field[ 'id' ] == substr( $field[ 'field_name' ], 0, -2 ) ) { |
|
56 | + $parts = array_filter( explode( '-', $field[ 'id' ] ) ); |
|
57 | 57 | $first = array_shift( $parts ); |
58 | - $field['field_name'] = array_reduce( $parts, function( $carry, $part ) { |
|
58 | + $field[ 'field_name' ] = array_reduce( $parts, function( $carry, $part ) { |
|
59 | 59 | return sprintf( '%s[%s]', $carry, $part ); |
60 | 60 | }, $first ) . '[]'; |
61 | 61 | } |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function _normalize_field_meta( $meta, array $field ) |
70 | 70 | { |
71 | - if( !empty( $meta ) && is_array( $meta )) { |
|
71 | + if( !empty( $meta ) && is_array( $meta ) ) { |
|
72 | 72 | return $meta; |
73 | 73 | } |
74 | - if( $field['clone'] ) { |
|
75 | - return ['']; |
|
74 | + if( $field[ 'clone' ] ) { |
|
75 | + return [ '' ]; |
|
76 | 76 | } |
77 | - if( $field['multiple'] ) { |
|
78 | - return []; |
|
77 | + if( $field[ 'multiple' ] ) { |
|
78 | + return [ ]; |
|
79 | 79 | } |
80 | 80 | return $meta; |
81 | 81 | } |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | public function add_meta_boxes() |
89 | 89 | { |
90 | 90 | add_meta_box( |
91 | - $this->meta_box['id'], |
|
92 | - $this->meta_box['title'], |
|
93 | - [$this, 'show'], |
|
91 | + $this->meta_box[ 'id' ], |
|
92 | + $this->meta_box[ 'title' ], |
|
93 | + [ $this, 'show' ], |
|
94 | 94 | null, |
95 | - $this->meta_box['context'], |
|
96 | - $this->meta_box['priority'] |
|
95 | + $this->meta_box[ 'context' ], |
|
96 | + $this->meta_box[ 'priority' ] |
|
97 | 97 | ); |
98 | 98 | } |
99 | 99 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | public function is_saved() |
112 | 112 | { |
113 | 113 | foreach( array_column( $this->fields, 'slug' ) as $field ) { |
114 | - if( !is_null( $this->pollux_caller->getMetaValue( $field, null, $this->meta_box['slug'] ))) { |
|
114 | + if( !is_null( $this->pollux_caller->getMetaValue( $field, null, $this->meta_box[ 'slug' ] ) ) ) { |
|
115 | 115 | return true; |
116 | 116 | } |
117 | 117 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public static function normalize( $metabox ) |
126 | 126 | { |
127 | - unset( $metabox['post_types'] ); |
|
128 | - return wp_parse_args( $metabox, ['slug' => ''] ); |
|
127 | + unset( $metabox[ 'post_types' ] ); |
|
128 | + return wp_parse_args( $metabox, [ 'slug' => '' ] ); |
|
129 | 129 | } |
130 | 130 | } |
@@ -55,7 +55,8 @@ |
||
55 | 55 | if( !empty( $field['multiple'] ) && $field['id'] == substr( $field['field_name'], 0, -2 )) { |
56 | 56 | $parts = array_filter( explode( '-', $field['id'] )); |
57 | 57 | $first = array_shift( $parts ); |
58 | - $field['field_name'] = array_reduce( $parts, function( $carry, $part ) { |
|
58 | + $field['field_name'] = array_reduce( $parts, function( $carry, $part ) |
|
59 | + { |
|
59 | 60 | return sprintf( '%s[%s]', $carry, $part ); |
60 | 61 | }, $first ) . '[]'; |
61 | 62 | } |