@@ -133,7 +133,9 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public function register() |
| 135 | 135 | { |
| 136 | - if( $this->app->screen()->id != $this->hook )return; |
|
| 136 | + if( $this->app->screen()->id != $this->hook ) { |
|
| 137 | + return; |
|
| 138 | + } |
|
| 137 | 139 | foreach( parent::register() as $metabox ) { |
| 138 | 140 | new RWMetaBox( $metabox ); |
| 139 | 141 | } |
@@ -205,7 +207,9 @@ discard block |
||
| 205 | 207 | { |
| 206 | 208 | if( filter_input( INPUT_GET, 'page' ) !== $this->id |
| 207 | 209 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
| 208 | - )return; |
|
| 210 | + ) { |
|
| 211 | + return; |
|
| 212 | + } |
|
| 209 | 213 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
| 210 | 214 | update_option( $this->id, $this->getDefaults() ); |
| 211 | 215 | return add_settings_error( $this->id, 'reset', __( 'Settings reset to defaults.', 'pollux' ), 'updated' ); |
@@ -219,7 +223,8 @@ discard block |
||
| 219 | 223 | */ |
| 220 | 224 | protected function filterArrayByKey( array $array, $key ) |
| 221 | 225 | { |
| 222 | - return array_filter( $array, function( $value ) use( $key ) { |
|
| 226 | + return array_filter( $array, function( $value ) use( $key ) |
|
| 227 | + { |
|
| 223 | 228 | return !empty( $value[$key] ); |
| 224 | 229 | }); |
| 225 | 230 | } |
@@ -231,8 +236,10 @@ discard block |
||
| 231 | 236 | { |
| 232 | 237 | $metaboxes = $this->filterArrayByKey( $this->metaboxes, 'slug' ); |
| 233 | 238 | |
| 234 | - array_walk( $metaboxes, function( &$metabox ) { |
|
| 235 | - $fields = array_map( function( $field ) { |
|
| 239 | + array_walk( $metaboxes, function( &$metabox ) |
|
| 240 | + { |
|
| 241 | + $fields = array_map( function( $field ) |
|
| 242 | + { |
|
| 236 | 243 | $field = wp_parse_args( $field, ['std' => ''] ); |
| 237 | 244 | return [$field['slug'] => $field['std']]; |
| 238 | 245 | }, $this->filterArrayByKey( $metabox['fields'], 'slug' )); |
@@ -14,7 +14,8 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | public function validate( array $conditions ) |
| 16 | 16 | { |
| 17 | - array_walk( $conditions, function( &$value, $key ) { |
|
| 17 | + array_walk( $conditions, function( &$value, $key ) |
|
| 18 | + { |
|
| 18 | 19 | $method = $this->app->buildMethodName( $key, 'validate' ); |
| 19 | 20 | $value = method_exists( $this, $method ) |
| 20 | 21 | ? $this->$method( $value ) |
@@ -34,7 +35,8 @@ discard block |
||
| 34 | 35 | foreach( $conditions as $key ) { |
| 35 | 36 | $conditions[str_replace( '!', '', $key )] = substr( $key, 0, 1 ) == '!' ? 0 : 1; |
| 36 | 37 | } |
| 37 | - $conditions = array_filter( $conditions, function( $key ) { |
|
| 38 | + $conditions = array_filter( $conditions, function( $key ) |
|
| 39 | + { |
|
| 38 | 40 | return !is_numeric( $key ); |
| 39 | 41 | }, ARRAY_FILTER_USE_KEY ); |
| 40 | 42 | } |
@@ -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 | } |