@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | parent::__construct( $metabox ); |
15 | 15 | $this->meta_box = static::normalize( $this->meta_box ); |
16 | 16 | |
17 | - remove_action( 'add_meta_boxes', [$this, 'add_meta_boxes'] ); |
|
18 | - remove_action( 'save_post_post', [$this, 'save_post'] ); |
|
17 | + remove_action( 'add_meta_boxes', [ $this, 'add_meta_boxes' ] ); |
|
18 | + remove_action( 'save_post_post', [ $this, 'save_post' ] ); |
|
19 | 19 | |
20 | - add_action( 'pollux/settings/init', [$this, 'add_meta_boxes'] ); |
|
21 | - add_filter( 'rwmb_field_meta', [$this, '_get_field_meta'], 10, 3 ); |
|
20 | + add_action( 'pollux/settings/init', [ $this, 'add_meta_boxes' ] ); |
|
21 | + add_filter( 'rwmb_field_meta', [ $this, '_get_field_meta' ], 10, 3 ); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -29,13 +29,13 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function _get_field_meta( $meta, array $field, $saved ) |
31 | 31 | { |
32 | - if( !$this->is_edit_screen() || !empty( $meta ) || empty( $field['slug'] )) { |
|
32 | + if( !$this->is_edit_screen() || !empty( $meta ) || empty( $field[ 'slug' ] ) ) { |
|
33 | 33 | return $meta; |
34 | 34 | } |
35 | - $meta = call_user_func( [RWMB_Field::get_class_name( $field ), 'esc_meta'], ( $saved |
|
36 | - ? (new SiteMeta)->get( $this->meta_box['slug'], $field['slug'], $meta ) |
|
37 | - : $field['std'] |
|
38 | - )); |
|
35 | + $meta = call_user_func( [ RWMB_Field::get_class_name( $field ), 'esc_meta' ], ( $saved |
|
36 | + ? ( new SiteMeta )->get( $this->meta_box[ 'slug' ], $field[ 'slug' ], $meta ) |
|
37 | + : $field[ 'std' ] |
|
38 | + ) ); |
|
39 | 39 | return $this->_normalize_field_meta( $meta, $field ); |
40 | 40 | } |
41 | 41 | |
@@ -45,14 +45,14 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function _normalize_field_meta( $meta, array $field ) |
47 | 47 | { |
48 | - if( !empty( $meta ) && is_array( $meta )) { |
|
48 | + if( !empty( $meta ) && is_array( $meta ) ) { |
|
49 | 49 | return $meta; |
50 | 50 | } |
51 | - if( $field['clone'] ) { |
|
52 | - return ['']; |
|
51 | + if( $field[ 'clone' ] ) { |
|
52 | + return [ '' ]; |
|
53 | 53 | } |
54 | - if( $field['multiple'] ) { |
|
55 | - return []; |
|
54 | + if( $field[ 'multiple' ] ) { |
|
55 | + return [ ]; |
|
56 | 56 | } |
57 | 57 | return $meta; |
58 | 58 | } |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | public function add_meta_boxes() |
65 | 65 | { |
66 | 66 | add_meta_box( |
67 | - $this->meta_box['id'], |
|
68 | - $this->meta_box['title'], |
|
69 | - [$this, 'show'], |
|
67 | + $this->meta_box[ 'id' ], |
|
68 | + $this->meta_box[ 'title' ], |
|
69 | + [ $this, 'show' ], |
|
70 | 70 | null, |
71 | - $this->meta_box['context'], |
|
72 | - $this->meta_box['priority'] |
|
71 | + $this->meta_box[ 'context' ], |
|
72 | + $this->meta_box[ 'priority' ] |
|
73 | 73 | ); |
74 | 74 | } |
75 | 75 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function is_edit_screen( $screen = null ) |
80 | 80 | { |
81 | - return get_current_screen()->id == sprintf( 'toplevel_page_%s', apply_filters( 'pollux/settings/option', Settings::ID )); |
|
81 | + return get_current_screen()->id == sprintf( 'toplevel_page_%s', apply_filters( 'pollux/settings/option', Settings::ID ) ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | public function is_saved() |
88 | 88 | { |
89 | 89 | foreach( array_column( $this->fields, 'slug' ) as $field ) { |
90 | - if( !is_null( (new SiteMeta)->get( $this->meta_box['slug'], $field, null ))) { |
|
90 | + if( !is_null( ( new SiteMeta )->get( $this->meta_box[ 'slug' ], $field, null ) ) ) { |
|
91 | 91 | return true; |
92 | 92 | } |
93 | 93 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public static function normalize( $metabox ) |
102 | 102 | { |
103 | - unset( $metabox['post_types'] ); |
|
104 | - return wp_parse_args( $metabox, ['slug' => ''] ); |
|
103 | + unset( $metabox[ 'post_types' ] ); |
|
104 | + return wp_parse_args( $metabox, [ 'slug' => '' ] ); |
|
105 | 105 | } |
106 | 106 | } |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | /** |
10 | 10 | * @var array |
11 | 11 | */ |
12 | - public $columns = []; |
|
12 | + public $columns = [ ]; |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * @var array |
16 | 16 | */ |
17 | - public $types = []; |
|
17 | + public $types = [ ]; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @var Application |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | public function initColumns() |
28 | 28 | { |
29 | 29 | foreach( $this->types as $type => $args ) { |
30 | - add_action( "manage_{$type}_posts_custom_column", [$this, 'printColumnValue'], 10, 2 ); |
|
30 | + add_action( "manage_{$type}_posts_custom_column", [ $this, 'printColumnValue' ], 10, 2 ); |
|
31 | 31 | add_filter( "manage_{$type}_posts_columns", function( $columns ) use( $args ) { |
32 | - return count( $args['columns'] ) > 1 |
|
33 | - ? $args['columns'] |
|
32 | + return count( $args[ 'columns' ] ) > 1 |
|
33 | + ? $args[ 'columns' ] |
|
34 | 34 | : $columns; |
35 | 35 | }); |
36 | 36 | } |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | protected function getColumnImage( $postId ) |
58 | 58 | { |
59 | 59 | if( has_post_thumbnail( $postId ) ) { |
60 | - list( $src, $width, $height ) = wp_get_attachment_image_src( get_post_thumbnail_id( $postId ), [96, 48] ); |
|
60 | + list( $src, $width, $height ) = wp_get_attachment_image_src( get_post_thumbnail_id( $postId ), [ 96, 48 ] ); |
|
61 | 61 | $image = sprintf( '<img src="%s" alt="%s" width="%s" height="%s">', |
62 | - esc_url( set_url_scheme( $src )), |
|
63 | - esc_attr( get_the_title( $postId )), |
|
62 | + esc_url( set_url_scheme( $src ) ), |
|
63 | + esc_attr( get_the_title( $postId ) ), |
|
64 | 64 | $width, |
65 | 65 | $height |
66 | 66 | ); |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | */ |
76 | 76 | protected function getColumnMedia() |
77 | 77 | { |
78 | - return count( (new PostMeta)->get( 'media', [ |
|
79 | - 'fallback' => [], |
|
78 | + return count( ( new PostMeta )->get( 'media', [ |
|
79 | + 'fallback' => [ ], |
|
80 | 80 | 'single' => false, |
81 | - ])); |
|
81 | + ] ) ); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | protected function normalizeColumns( array $columns ) |
97 | 97 | { |
98 | 98 | $columns = array_flip( $columns ); |
99 | - $columns = array_merge( $columns, array_intersect_key( $this->columns, $columns )); |
|
100 | - return ['cb' => '<input type="checkbox">'] + $columns; |
|
99 | + $columns = array_merge( $columns, array_intersect_key( $this->columns, $columns ) ); |
|
100 | + return [ 'cb' => '<input type="checkbox">' ] + $columns; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | { |
108 | 108 | $comments = sprintf( |
109 | 109 | '<span class="vers comment-grey-bubble" title="%1$s"><span class="screen-reader-text">%1$s</span></span>', |
110 | - $this->app->config['columns']['comments'] |
|
110 | + $this->app->config[ 'columns' ][ 'comments' ] |
|
111 | 111 | ); |
112 | - $columns = wp_parse_args( $this->app->config['columns'], [ |
|
112 | + $columns = wp_parse_args( $this->app->config[ 'columns' ], [ |
|
113 | 113 | 'comments' => $comments, |
114 | - ]); |
|
114 | + ] ); |
|
115 | 115 | $this->columns = apply_filters( 'pollux/post_type/columns', $columns ); |
116 | 116 | } |
117 | 117 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @var array |
16 | 16 | */ |
17 | - public $metaboxes = []; |
|
17 | + public $metaboxes = [ ]; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @return void |
@@ -23,18 +23,18 @@ discard block |
||
23 | 23 | { |
24 | 24 | if( !count( array_filter( $this->metaboxes, function( $metabox ) { |
25 | 25 | return $this->show( false, $metabox ); |
26 | - })))return; |
|
27 | - $this->metaboxes[] = [ |
|
26 | + }) ) )return; |
|
27 | + $this->metaboxes[ ] = [ |
|
28 | 28 | 'id' => 'infodiv', |
29 | 29 | 'post_types' => $this->getPostTypes(), |
30 | 30 | 'title' => __( 'How to use in your theme', 'pollux' ), |
31 | 31 | 'context' => 'side', |
32 | 32 | 'priority' => 'low', |
33 | - 'fields' => [[ |
|
33 | + 'fields' => [ [ |
|
34 | 34 | 'slug' => '', |
35 | 35 | 'std' => $this->generateInstructions(), |
36 | 36 | 'type' => 'custom_html', |
37 | - ]], |
|
37 | + ] ], |
|
38 | 38 | ]; |
39 | 39 | } |
40 | 40 | |
@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | protected function generateInstructions() |
45 | 45 | { |
46 | 46 | return array_reduce( $this->getInstructions(), function( $html, $metabox ) { |
47 | - $fields = array_reduce( array_column( $metabox['fields'], 'slug' ), function( $html, $slug ) use( $metabox ) { |
|
47 | + $fields = array_reduce( array_column( $metabox[ 'fields' ], 'slug' ), function( $html, $slug ) use( $metabox ) { |
|
48 | 48 | $hook = sprintf( 'pollux/%s/instruction', $this->getClassname() ); |
49 | - return $html . apply_filters( $hook, "PostMeta::get('{$slug}');", $slug, $metabox['slug'] ) . PHP_EOL; |
|
49 | + return $html . apply_filters( $hook, "PostMeta::get('{$slug}');", $slug, $metabox[ 'slug' ] ) . PHP_EOL; |
|
50 | 50 | }); |
51 | 51 | return $html . sprintf( '<p><strong>%s</strong></p><pre class="my-sites nav-tab-active misc-pub-section">%s</pre>', |
52 | - $metabox['title'], |
|
52 | + $metabox[ 'title' ], |
|
53 | 53 | $fields |
54 | 54 | ); |
55 | 55 | }); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | protected function getInstructions() |
62 | 62 | { |
63 | 63 | return array_filter( $this->metaboxes, function( $metabox ) { |
64 | - return $this->validate( $metabox['condition'] ) |
|
64 | + return $this->validate( $metabox[ 'condition' ] ) |
|
65 | 65 | && $this->hasPostType( $metabox ); |
66 | 66 | }); |
67 | 67 | } |