@@ -59,7 +59,8 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function verifyMetaBoxCondition( array $conditions ) |
| 61 | 61 | { |
| 62 | - array_walk( $conditions, function( &$value, $key ) { |
|
| 62 | + array_walk( $conditions, function( &$value, $key ) |
|
| 63 | + { |
|
| 63 | 64 | $method = $this->app->buildMethodName( $key, 'validate' ); |
| 64 | 65 | $value = method_exists( $this, $method ) |
| 65 | 66 | ? $this->$method( $value ) |
@@ -70,9 +71,12 @@ discard block |
||
| 70 | 71 | |
| 71 | 72 | protected function addInstructions() |
| 72 | 73 | { |
| 73 | - if( !count( array_filter( $this->metaboxes, function( $metabox ) { |
|
| 74 | + if( !count( array_filter( $this->metaboxes, function( $metabox ) |
|
| 75 | + { |
|
| 74 | 76 | return $this->isVisible( false, $metabox ); |
| 75 | - })))return; |
|
| 77 | + }))) { |
|
| 78 | + return; |
|
| 79 | + } |
|
| 76 | 80 | $this->metaboxes[] = [ |
| 77 | 81 | 'id' => 'infodiv', |
| 78 | 82 | 'post_types' => $this->getPostTypes(), |
@@ -91,8 +95,10 @@ discard block |
||
| 91 | 95 | */ |
| 92 | 96 | protected function generateInstructions() |
| 93 | 97 | { |
| 94 | - return array_reduce( $this->getInstructions(), function( $html, $metabox ) { |
|
| 95 | - $fields = array_reduce( array_column( $metabox['fields'], 'slug' ), function( $html, $slug ) use( $metabox ) { |
|
| 98 | + return array_reduce( $this->getInstructions(), function( $html, $metabox ) |
|
| 99 | + { |
|
| 100 | + $fields = array_reduce( array_column( $metabox['fields'], 'slug' ), function( $html, $slug ) use( $metabox ) |
|
| 101 | + { |
|
| 96 | 102 | $hook = sprintf( 'pollux/%s/instruction', $this->getClassname() ); |
| 97 | 103 | return $html . apply_filters( $hook, "PostMeta::get('{$slug}');", $slug, $metabox['slug'] ) . PHP_EOL; |
| 98 | 104 | }); |
@@ -108,7 +114,8 @@ discard block |
||
| 108 | 114 | */ |
| 109 | 115 | protected function getInstructions() |
| 110 | 116 | { |
| 111 | - return array_filter( $this->metaboxes, function( $metabox ) { |
|
| 117 | + return array_filter( $this->metaboxes, function( $metabox ) |
|
| 118 | + { |
|
| 112 | 119 | return $this->verifyMetaBoxCondition( $metabox['condition'] ) |
| 113 | 120 | && $this->hasPostType( $metabox ); |
| 114 | 121 | }); |
@@ -178,7 +185,8 @@ discard block |
||
| 178 | 185 | foreach( $conditions as $key ) { |
| 179 | 186 | $conditions[str_replace( '!', '', $key )] = substr( $key, 0, 1 ) == '!' ? 0 : 1; |
| 180 | 187 | } |
| 181 | - $conditions = array_filter( $conditions, function( $key ) { |
|
| 188 | + $conditions = array_filter( $conditions, function( $key ) |
|
| 189 | + { |
|
| 182 | 190 | return !is_numeric( $key ); |
| 183 | 191 | }, ARRAY_FILTER_USE_KEY ); |
| 184 | 192 | } |
@@ -194,7 +202,8 @@ discard block |
||
| 194 | 202 | */ |
| 195 | 203 | protected function normalizeFields( array $fields, array $data, $parentId ) |
| 196 | 204 | { |
| 197 | - return array_map( function( $id, $field ) use( $parentId ) { |
|
| 205 | + return array_map( function( $id, $field ) use( $parentId ) |
|
| 206 | + { |
|
| 198 | 207 | $defaults = [ |
| 199 | 208 | 'id' => $id, |
| 200 | 209 | 'field_name' => '', |