@@ -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' => '', |
@@ -46,10 +46,14 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function filterBy( WP_Query $query ) |
| 48 | 48 | { |
| 49 | - if( !is_admin() || get_current_screen()->base != 'edit' )return; |
|
| 49 | + if( !is_admin() || get_current_screen()->base != 'edit' ) { |
|
| 50 | + return; |
|
| 51 | + } |
|
| 50 | 52 | $vars = &$query->query_vars; |
| 51 | 53 | foreach( array_keys( $this->taxonomies ) as $taxonomy ) { |
| 52 | - if( !is_numeric( $vars[$taxonomy] ))continue; |
|
| 54 | + if( !is_numeric( $vars[$taxonomy] )) { |
|
| 55 | + continue; |
|
| 56 | + } |
|
| 53 | 57 | $vars[$taxonomy] = get_term_by( 'id', $vars[$taxonomy], $taxonomy )->slug; |
| 54 | 58 | } |
| 55 | 59 | return $query; |
@@ -62,7 +66,9 @@ discard block |
||
| 62 | 66 | { |
| 63 | 67 | global $wp_query; |
| 64 | 68 | foreach( $this->taxonomies as $taxonomy => $args ) { |
| 65 | - if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue; |
|
| 69 | + if( !in_array( get_current_screen()->post_type, $args['post_types'] )) { |
|
| 70 | + continue; |
|
| 71 | + } |
|
| 66 | 72 | $selected = isset( $wp_query->query[$taxonomy] ) |
| 67 | 73 | ? $wp_query->query[$taxonomy] |
| 68 | 74 | : false; |
@@ -82,7 +88,8 @@ discard block |
||
| 82 | 88 | */ |
| 83 | 89 | public function register() |
| 84 | 90 | { |
| 85 | - array_walk( $this->taxonomies, function( $args, $taxonomy ) { |
|
| 91 | + array_walk( $this->taxonomies, function( $args, $taxonomy ) |
|
| 92 | + { |
|
| 86 | 93 | register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( self::CUSTOM_KEYS ))); |
| 87 | 94 | foreach( $args['post_types'] as $type ) { |
| 88 | 95 | register_taxonomy_for_object_type( $taxonomy, $type ); |