@@ -12,7 +12,9 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | public function get( $metaKey, array $args = [] ) |
| 14 | 14 | { |
| 15 | - if( empty( $metaKey ))return; |
|
| 15 | + if( empty( $metaKey )) { |
|
| 16 | + return; |
|
| 17 | + } |
|
| 16 | 18 | |
| 17 | 19 | $args = $this->normalize( $args ); |
| 18 | 20 | $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |
@@ -130,7 +130,8 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | protected function normalizeFields( array $fields, array $data, $parentId ) |
| 132 | 132 | { |
| 133 | - return array_map( function( $id, $field ) use( $parentId ) { |
|
| 133 | + return array_map( function( $id, $field ) use( $parentId ) |
|
| 134 | + { |
|
| 134 | 135 | $defaults = [ |
| 135 | 136 | 'attributes' => [], |
| 136 | 137 | // 'condition' => [], |
@@ -169,8 +170,11 @@ discard block |
||
| 169 | 170 | { |
| 170 | 171 | $fields = &$metabox['fields']; |
| 171 | 172 | $depends = array_column( $fields, 'depends' ); |
| 172 | - array_walk( $depends, function( $value, $index ) use( &$fields ) { |
|
| 173 | - if( empty( $value ))return; |
|
| 173 | + array_walk( $depends, function( $value, $index ) use( &$fields ) |
|
| 174 | + { |
|
| 175 | + if( empty( $value )) { |
|
| 176 | + return; |
|
| 177 | + } |
|
| 174 | 178 | $fields[$index]['attributes']['data-depends'] = $value; |
| 175 | 179 | }); |
| 176 | 180 | return $metabox; |
@@ -16,9 +16,12 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | protected function addInstructions() |
| 18 | 18 | { |
| 19 | - if( !count( array_filter( $this->metaboxes, function( $metabox ) { |
|
| 19 | + if( !count( array_filter( $this->metaboxes, function( $metabox ) |
|
| 20 | + { |
|
| 20 | 21 | return $this->show( false, $metabox ); |
| 21 | - })))return; |
|
| 22 | + }))) { |
|
| 23 | + return; |
|
| 24 | + } |
|
| 22 | 25 | $this->metaboxes[] = [ |
| 23 | 26 | 'id' => 'infodiv', |
| 24 | 27 | 'post_types' => $this->getPostTypes(), |
@@ -38,8 +41,10 @@ discard block |
||
| 38 | 41 | */ |
| 39 | 42 | protected function generateInstructions() |
| 40 | 43 | { |
| 41 | - return array_reduce( $this->getInstructions(), function( $html, $metabox ) { |
|
| 42 | - $fields = array_reduce( array_column( $metabox['fields'], 'slug' ), function( $html, $slug ) use( $metabox ) { |
|
| 44 | + return array_reduce( $this->getInstructions(), function( $html, $metabox ) |
|
| 45 | + { |
|
| 46 | + $fields = array_reduce( array_column( $metabox['fields'], 'slug' ), function( $html, $slug ) use( $metabox ) |
|
| 47 | + { |
|
| 43 | 48 | $hook = sprintf( 'pollux/%s/instruction', $this->getClassname() ); |
| 44 | 49 | return $html . apply_filters( $hook, "PostMeta::get('{$slug}');", $slug, $metabox['slug'] ) . PHP_EOL; |
| 45 | 50 | }); |
@@ -55,7 +60,8 @@ discard block |
||
| 55 | 60 | */ |
| 56 | 61 | protected function getInstructions() |
| 57 | 62 | { |
| 58 | - return array_filter( $this->metaboxes, function( $metabox ) { |
|
| 63 | + return array_filter( $this->metaboxes, function( $metabox ) |
|
| 64 | + { |
|
| 59 | 65 | return $this->validate( $metabox['condition'] ) |
| 60 | 66 | && $this->hasPostType( $metabox ); |
| 61 | 67 | }); |
@@ -18,7 +18,8 @@ |
||
| 18 | 18 | { |
| 19 | 19 | foreach( $this->types as $type => $args ) { |
| 20 | 20 | add_action( "manage_{$type}_posts_custom_column", [$this, 'printColumnValue'], 10, 2 ); |
| 21 | - add_filter( "manage_{$type}_posts_columns", function( $columns ) use( $args ) { |
|
| 21 | + add_filter( "manage_{$type}_posts_columns", function( $columns ) use( $args ) |
|
| 22 | + { |
|
| 22 | 23 | return count( $args['columns'] ) > 1 |
| 23 | 24 | ? $args['columns'] |
| 24 | 25 | : $columns; |
@@ -62,7 +62,8 @@ |
||
| 62 | 62 | $this->types, |
| 63 | 63 | get_post_types( ['_builtin' => true] ) |
| 64 | 64 | ); |
| 65 | - array_walk( $types, function( $args, $type ) { |
|
| 65 | + array_walk( $types, function( $args, $type ) |
|
| 66 | + { |
|
| 66 | 67 | register_post_type( $type, array_diff_key( $args, array_flip( static::CUSTOM_KEYS ))); |
| 67 | 68 | }); |
| 68 | 69 | } |