@@ -10,12 +10,12 @@ discard block |
||
10 | 10 | /** |
11 | 11 | * @var array |
12 | 12 | */ |
13 | - public $columns = []; |
|
13 | + public $columns = [ ]; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * @var array |
17 | 17 | */ |
18 | - public $types = []; |
|
18 | + public $types = [ ]; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @var Application |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | public function initColumns() |
29 | 29 | { |
30 | 30 | foreach( $this->types as $type => $args ) { |
31 | - add_action( "manage_{$type}_posts_custom_column", [$this, 'printColumnValue'], 10, 2 ); |
|
31 | + add_action( "manage_{$type}_posts_custom_column", [ $this, 'printColumnValue' ], 10, 2 ); |
|
32 | 32 | add_filter( "manage_{$type}_posts_columns", function( $columns ) use( $args ) { |
33 | - return count( $args['columns'] ) > 1 |
|
34 | - ? $args['columns'] |
|
33 | + return count( $args[ 'columns' ] ) > 1 |
|
34 | + ? $args[ 'columns' ] |
|
35 | 35 | : $columns; |
36 | 36 | }); |
37 | 37 | } |
@@ -58,10 +58,10 @@ discard block |
||
58 | 58 | protected function getColumnImage( $postId ) |
59 | 59 | { |
60 | 60 | if( has_post_thumbnail( $postId ) ) { |
61 | - list( $src, $width, $height ) = wp_get_attachment_image_src( get_post_thumbnail_id( $postId ), [96, 48] ); |
|
61 | + list( $src, $width, $height ) = wp_get_attachment_image_src( get_post_thumbnail_id( $postId ), [ 96, 48 ] ); |
|
62 | 62 | $image = sprintf( '<img src="%s" alt="%s" width="%s" height="%s">', |
63 | - esc_url( set_url_scheme( $src )), |
|
64 | - esc_attr( get_the_title( $postId )), |
|
63 | + esc_url( set_url_scheme( $src ) ), |
|
64 | + esc_attr( get_the_title( $postId ) ), |
|
65 | 65 | $width, |
66 | 66 | $height |
67 | 67 | ); |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | protected function getColumnMedia() |
78 | 78 | { |
79 | 79 | return count( PostMeta::get( 'media', [ |
80 | - 'fallback' => [], |
|
80 | + 'fallback' => [ ], |
|
81 | 81 | 'single' => false, |
82 | - ])); |
|
82 | + ] ) ); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | protected function normalizeColumns( array $columns ) |
98 | 98 | { |
99 | 99 | $columns = array_flip( $columns ); |
100 | - $columns = array_merge( $columns, array_intersect_key( $this->columns, $columns )); |
|
101 | - return ['cb' => '<input type="checkbox">'] + $columns; |
|
100 | + $columns = array_merge( $columns, array_intersect_key( $this->columns, $columns ) ); |
|
101 | + return [ 'cb' => '<input type="checkbox">' ] + $columns; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | { |
109 | 109 | $comments = sprintf( |
110 | 110 | '<span class="vers comment-grey-bubble" title="%1$s"><span class="screen-reader-text">%1$s</span></span>', |
111 | - $this->app->config['columns']['comments'] |
|
111 | + $this->app->config[ 'columns' ][ 'comments' ] |
|
112 | 112 | ); |
113 | - $columns = wp_parse_args( $this->app->config['columns'], [ |
|
113 | + $columns = wp_parse_args( $this->app->config[ 'columns' ], [ |
|
114 | 114 | 'comments' => $comments, |
115 | - ]); |
|
115 | + ] ); |
|
116 | 116 | $this->columns = apply_filters( 'pollux/post_type/columns', $columns ); |
117 | 117 | } |
118 | 118 | } |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | parent::__construct( $metabox ); |
16 | 16 | $this->meta_box = static::normalize( $this->meta_box ); |
17 | 17 | |
18 | - remove_action( 'add_meta_boxes', [$this, 'add_meta_boxes'] ); |
|
19 | - remove_action( 'save_post_post', [$this, 'save_post'] ); |
|
18 | + remove_action( 'add_meta_boxes', [ $this, 'add_meta_boxes' ] ); |
|
19 | + remove_action( 'save_post_post', [ $this, 'save_post' ] ); |
|
20 | 20 | |
21 | - add_action( 'pollux/settings/init', [$this, 'add_meta_boxes'] ); |
|
22 | - add_filter( 'rwmb_field_meta', [$this, '_get_field_meta'], 10, 3 ); |
|
21 | + add_action( 'pollux/settings/init', [ $this, 'add_meta_boxes' ] ); |
|
22 | + add_filter( 'rwmb_field_meta', [ $this, '_get_field_meta' ], 10, 3 ); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | /** |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function _get_field_meta( $meta, array $field, $saved ) |
32 | 32 | { |
33 | - if( !$this->is_edit_screen() || !empty(( new Helper )->toArray( $meta )) || empty( $field['slug'] )) { |
|
33 | + if( !$this->is_edit_screen() || !empty( ( new Helper )->toArray( $meta ) ) || empty( $field[ 'slug' ] ) ) { |
|
34 | 34 | return $meta; |
35 | 35 | } |
36 | - $meta = call_user_func( [RWMB_Field::get_class_name( $field ), 'esc_meta'], ( $saved |
|
37 | - ? SiteMeta::get( $this->meta_box['slug'], $field['slug'], $meta ) |
|
38 | - : $field['std'] |
|
39 | - )); |
|
36 | + $meta = call_user_func( [ RWMB_Field::get_class_name( $field ), 'esc_meta' ], ( $saved |
|
37 | + ? SiteMeta::get( $this->meta_box[ 'slug' ], $field[ 'slug' ], $meta ) |
|
38 | + : $field[ 'std' ] |
|
39 | + ) ); |
|
40 | 40 | return $this->_normalize_field_meta( $meta, $field ); |
41 | 41 | } |
42 | 42 | |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function _normalize_field_meta( $meta, array $field ) |
48 | 48 | { |
49 | - if( !empty( $meta ) && is_array( $meta )) { |
|
49 | + if( !empty( $meta ) && is_array( $meta ) ) { |
|
50 | 50 | return $meta; |
51 | 51 | } |
52 | - if( $field['clone'] ) { |
|
53 | - return ['']; |
|
52 | + if( $field[ 'clone' ] ) { |
|
53 | + return [ '' ]; |
|
54 | 54 | } |
55 | - if( $field['multiple'] ) { |
|
56 | - return []; |
|
55 | + if( $field[ 'multiple' ] ) { |
|
56 | + return [ ]; |
|
57 | 57 | } |
58 | 58 | return $meta; |
59 | 59 | } |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | public function add_meta_boxes() |
66 | 66 | { |
67 | 67 | add_meta_box( |
68 | - $this->meta_box['id'], |
|
69 | - $this->meta_box['title'], |
|
70 | - [$this, 'show'], |
|
68 | + $this->meta_box[ 'id' ], |
|
69 | + $this->meta_box[ 'title' ], |
|
70 | + [ $this, 'show' ], |
|
71 | 71 | null, |
72 | - $this->meta_box['context'], |
|
73 | - $this->meta_box['priority'] |
|
72 | + $this->meta_box[ 'context' ], |
|
73 | + $this->meta_box[ 'priority' ] |
|
74 | 74 | ); |
75 | 75 | } |
76 | 76 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function is_edit_screen( $screen = null ) |
81 | 81 | { |
82 | - return get_current_screen()->id == sprintf( 'toplevel_page_%s', apply_filters( 'pollux/settings/option', Settings::ID )); |
|
82 | + return get_current_screen()->id == sprintf( 'toplevel_page_%s', apply_filters( 'pollux/settings/option', Settings::ID ) ); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | public function is_saved() |
89 | 89 | { |
90 | 90 | foreach( array_column( $this->fields, 'slug' ) as $field ) { |
91 | - if( !is_null( SiteMeta::get( $this->meta_box['slug'], $field, null ))) { |
|
91 | + if( !is_null( SiteMeta::get( $this->meta_box[ 'slug' ], $field, null ) ) ) { |
|
92 | 92 | return true; |
93 | 93 | } |
94 | 94 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public static function normalize( $metabox ) |
103 | 103 | { |
104 | - unset( $metabox['post_types'] ); |
|
105 | - return wp_parse_args( $metabox, ['slug' => ''] ); |
|
104 | + unset( $metabox[ 'post_types' ] ); |
|
105 | + return wp_parse_args( $metabox, [ 'slug' => '' ] ); |
|
106 | 106 | } |
107 | 107 | } |
@@ -22,8 +22,8 @@ discard block |
||
22 | 22 | |
23 | 23 | public function __construct() |
24 | 24 | { |
25 | - $this->file = realpath( dirname( dirname( __FILE__ )) . '/pollux.php' ); |
|
26 | - $this->gatekeeper = new GateKeeper( plugin_basename( $this->file )); |
|
25 | + $this->file = realpath( dirname( dirname( __FILE__ ) ) . '/pollux.php' ); |
|
26 | + $this->gatekeeper = new GateKeeper( plugin_basename( $this->file ) ); |
|
27 | 27 | |
28 | 28 | $data = get_file_data( $this->file, array( |
29 | 29 | 'id' => 'Text Domain', |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | |
47 | 47 | $controller = $this->make( 'Controller' ); |
48 | 48 | |
49 | - add_action( 'admin_enqueue_scripts', array( $controller, 'registerAssets' )); |
|
50 | - add_action( 'admin_init', array( $controller, 'removeDashboardWidgets' )); |
|
51 | - add_action( 'wp_before_admin_bar_render', array( $controller, 'removeWordPressMenu' )); |
|
52 | - add_filter( 'admin_footer_text', array( $controller, 'filterWordPressFooter' )); |
|
49 | + add_action( 'admin_enqueue_scripts', array( $controller, 'registerAssets' ) ); |
|
50 | + add_action( 'admin_init', array( $controller, 'removeDashboardWidgets' ) ); |
|
51 | + add_action( 'wp_before_admin_bar_render', array( $controller, 'removeWordPressMenu' ) ); |
|
52 | + add_filter( 'admin_footer_text', array( $controller, 'filterWordPressFooter' ) ); |
|
53 | 53 | |
54 | 54 | // Disallow indexing of the site on non-production environments |
55 | 55 | if( !$this->environment( 'production' ) && !is_admin() ) { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | { |
65 | 65 | Facade::clearResolvedInstances(); |
66 | 66 | Facade::setFacadeApplication( $this ); |
67 | - $this->config = ( new Config( $this ))->get(); |
|
67 | + $this->config = ( new Config( $this ) )->get(); |
|
68 | 68 | $this->registerAliases(); |
69 | 69 | $classNames = array( |
70 | 70 | 'MetaBox\MetaBox', |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | public function environment( $checkFor = '' ) |
85 | 85 | { |
86 | 86 | $environment = defined( 'WP_ENV' ) ? WP_ENV : 'production'; |
87 | - if( !empty( $checkFor )) { |
|
87 | + if( !empty( $checkFor ) ) { |
|
88 | 88 | return $environment == $checkFor; |
89 | 89 | } |
90 | 90 | return $environment; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $option = apply_filters( 'pollux/settings/option', Settings::ID ); |
99 | 99 | $settings = get_option( $option ); |
100 | 100 | if( !$settings ) { |
101 | - update_option( $option, [] ); |
|
101 | + update_option( $option, [ ] ); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
@@ -150,6 +150,6 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function url( $path = '' ) |
152 | 152 | { |
153 | - return esc_url( plugin_dir_url( $this->file ) . ltrim( trim( $path ), '/' )); |
|
153 | + return esc_url( plugin_dir_url( $this->file ) . ltrim( trim( $path ), '/' ) ); |
|
154 | 154 | } |
155 | 155 | } |
@@ -19,20 +19,20 @@ discard block |
||
19 | 19 | /** |
20 | 20 | * @var array |
21 | 21 | */ |
22 | - public $metaboxes = []; |
|
22 | + public $metaboxes = [ ]; |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * {@inheritdoc} |
26 | 26 | */ |
27 | 27 | public function init() |
28 | 28 | { |
29 | - $this->normalize( $this->app->config['meta_boxes'], [ |
|
30 | - 'post_types' => [], |
|
31 | - ]); |
|
29 | + $this->normalize( $this->app->config[ 'meta_boxes' ], [ |
|
30 | + 'post_types' => [ ], |
|
31 | + ] ); |
|
32 | 32 | |
33 | - add_filter( 'rwmb_show', [$this, 'show'], 10, 2 ); |
|
34 | - add_filter( 'rwmb_meta_boxes', [$this, 'register'] ); |
|
35 | - add_filter( 'rwmb_outer_html', [$this, 'renderField'], 10, 2 ); |
|
33 | + add_filter( 'rwmb_show', [ $this, 'show' ], 10, 2 ); |
|
34 | + add_filter( 'rwmb_meta_boxes', [ $this, 'register' ] ); |
|
35 | + add_filter( 'rwmb_outer_html', [ $this, 'renderField' ], 10, 2 ); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function register() |
43 | 43 | { |
44 | - if( current_user_can( 'switch_themes' )) { |
|
44 | + if( current_user_can( 'switch_themes' ) ) { |
|
45 | 45 | $this->addInstructions(); |
46 | 46 | } |
47 | 47 | $metaboxes = func_num_args() |
48 | - ? ( new Helper )->toArray( func_get_arg(0) ) |
|
49 | - : []; |
|
48 | + ? ( new Helper )->toArray( func_get_arg( 0 ) ) |
|
49 | + : [ ]; |
|
50 | 50 | return array_merge( $metaboxes, $this->metaboxes ); |
51 | 51 | } |
52 | 52 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function renderField( $html, $field ) |
58 | 58 | { |
59 | - return $this->validate( $field['condition'] ) |
|
59 | + return $this->validate( $field[ 'condition' ] ) |
|
60 | 60 | ? $html |
61 | 61 | : ''; |
62 | 62 | } |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | public function show( $bool, array $metabox ) |
69 | 69 | { |
70 | 70 | if( defined( 'DOING_AJAX' ) |
71 | - || !isset( $metabox['condition'] ) |
|
72 | - || !$this->hasPostType( $metabox )) { |
|
71 | + || !isset( $metabox[ 'condition' ] ) |
|
72 | + || !$this->hasPostType( $metabox ) ) { |
|
73 | 73 | return $bool; |
74 | 74 | } |
75 | - return $this->validate( $metabox['condition'] ); |
|
75 | + return $this->validate( $metabox[ 'condition' ] ); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | protected function getPostId() |
82 | 82 | { |
83 | - if( !( $postId = filter_input( INPUT_GET, 'post' ))) { |
|
83 | + if( !( $postId = filter_input( INPUT_GET, 'post' ) ) ) { |
|
84 | 84 | $postId = filter_input( INPUT_POST, 'post_ID' ); |
85 | 85 | } |
86 | 86 | return intval( $postId ); |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | { |
94 | 94 | return array_unique( iterator_to_array( |
95 | 95 | new RecursiveIteratorIterator( |
96 | - new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' )) |
|
96 | + new RecursiveArrayIterator( array_column( $this->metaboxes, 'post_types' ) ) |
|
97 | 97 | ), |
98 | 98 | false |
99 | - )); |
|
99 | + ) ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | return PostMeta::get( $key, [ |
108 | 108 | 'id' => $this->getPostId(), |
109 | - ]); |
|
109 | + ] ); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -114,25 +114,25 @@ discard block |
||
114 | 114 | */ |
115 | 115 | protected function hasPostType( array $metabox ) |
116 | 116 | { |
117 | - if( !isset( $metabox['post_types'] )) { |
|
117 | + if( !isset( $metabox[ 'post_types' ] ) ) { |
|
118 | 118 | return true; |
119 | 119 | } |
120 | - return in_array( get_post_type( $this->getPostId() ), $metabox['post_types'] ); |
|
120 | + return in_array( get_post_type( $this->getPostId() ), $metabox[ 'post_types' ] ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
124 | 124 | * @return void |
125 | 125 | */ |
126 | - protected function normalize( array $metaboxes, array $defaults = [] ) |
|
126 | + protected function normalize( array $metaboxes, array $defaults = [ ] ) |
|
127 | 127 | { |
128 | 128 | foreach( $metaboxes as $id => $metabox ) { |
129 | 129 | $data = wp_parse_args( $defaults, [ |
130 | - 'condition' => [], |
|
131 | - 'fields' => [], |
|
130 | + 'condition' => [ ], |
|
131 | + 'fields' => [ ], |
|
132 | 132 | 'id' => $id, |
133 | 133 | 'slug' => $id, |
134 | - ]); |
|
135 | - $this->metaboxes[] = $this->setDependencies( |
|
134 | + ] ); |
|
135 | + $this->metaboxes[ ] = $this->setDependencies( |
|
136 | 136 | $this->normalizeThis( $metabox, $data, $id ) |
137 | 137 | ); |
138 | 138 | } |
@@ -156,10 +156,10 @@ discard block |
||
156 | 156 | protected function normalizeFields( array $fields, array $data, $parentId ) |
157 | 157 | { |
158 | 158 | return array_map( function( $id, $field ) use( $parentId ) { |
159 | - $defaults = [ |
|
160 | - 'attributes' => [], |
|
159 | + $defaults = [ |
|
160 | + 'attributes' => [ ], |
|
161 | 161 | 'class' => '', |
162 | - 'condition' => [], |
|
162 | + 'condition' => [ ], |
|
163 | 163 | 'depends' => '', |
164 | 164 | 'id' => $id, |
165 | 165 | 'field_name' => '', |
@@ -193,14 +193,14 @@ discard block |
||
193 | 193 | */ |
194 | 194 | protected function setDependencies( array $metabox ) |
195 | 195 | { |
196 | - $fields = &$metabox['fields']; |
|
196 | + $fields = &$metabox[ 'fields' ]; |
|
197 | 197 | $depends = array_column( $fields, 'depends' ); |
198 | 198 | array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) { |
199 | - if( empty( $value ))return; |
|
200 | - $dependency = array_search( $value, array_column( $fields, 'id' )); |
|
201 | - $fields[$index]['attributes']['data-depends'] = $value; |
|
202 | - if( !$this->getValue( $fields[$dependency]['slug'], $metabox['slug'] )) { |
|
203 | - $fields[$index]['class'] = trim( 'hidden ' . $fields[$index]['class'] ); |
|
199 | + if( empty( $value ) )return; |
|
200 | + $dependency = array_search( $value, array_column( $fields, 'id' ) ); |
|
201 | + $fields[ $index ][ 'attributes' ][ 'data-depends' ] = $value; |
|
202 | + if( !$this->getValue( $fields[ $dependency ][ 'slug' ], $metabox[ 'slug' ] ) ) { |
|
203 | + $fields[ $index ][ 'class' ] = trim( 'hidden ' . $fields[ $index ][ 'class' ] ); |
|
204 | 204 | } |
205 | 205 | }); |
206 | 206 | return $metabox; |