@@ -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 getColumnThumbnail( $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 | $thumbnail = 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 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $defaults = [ |
110 | 110 | 'author' => __( 'Author', 'pollux' ), |
111 | 111 | 'categories' => __( 'Categories', 'pollux' ), |
112 | - 'comments' => sprintf( '<span class="vers comment-grey-bubble" title="%1$s"><span class="screen-reader-text">%1$s</span></span>', __( 'Comments', 'pollux' )), |
|
112 | + 'comments' => sprintf( '<span class="vers comment-grey-bubble" title="%1$s"><span class="screen-reader-text">%1$s</span></span>', __( 'Comments', 'pollux' ) ), |
|
113 | 113 | 'date' => __( 'Date', 'pollux' ), |
114 | 114 | 'media' => __( 'Media', 'pollux' ), |
115 | 115 | 'slug' => __( 'Slug', 'pollux' ), |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | public static $current; |
18 | 18 | |
19 | - public $hooks = []; |
|
19 | + public $hooks = [ ]; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * {@inheritdoc} |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | { |
26 | 26 | parent::init(); |
27 | 27 | |
28 | - add_action( 'wp_ajax_pollux/archives/featured/html', [$this, 'getFeaturedImageHtml'] ); |
|
29 | - add_action( 'pollux/archives/init', [$this, 'registerFeaturedImageMetaBox'] ); |
|
30 | - add_action( 'pollux/archives/editor', [$this, 'renderEditor'], 10, 2 ); |
|
31 | - add_action( 'wp_ajax_pollux/archives/featured', [$this, 'setFeaturedImage'] ); |
|
32 | - add_filter( 'pollux/archives/metabox/submit', [$this, 'filterSubmitMetaBox'] ); |
|
33 | - add_filter( 'pollux/archives/show/instructions', '__return_true' ); |
|
28 | + add_action( 'wp_ajax_pollux/archives/featured/html', [ $this, 'getFeaturedImageHtml' ] ); |
|
29 | + add_action( 'pollux/archives/init', [ $this, 'registerFeaturedImageMetaBox' ] ); |
|
30 | + add_action( 'pollux/archives/editor', [ $this, 'renderEditor' ], 10, 2 ); |
|
31 | + add_action( 'wp_ajax_pollux/archives/featured', [ $this, 'setFeaturedImage' ] ); |
|
32 | + add_filter( 'pollux/archives/metabox/submit', [ $this, 'filterSubmitMetaBox' ] ); |
|
33 | + add_filter( 'pollux/archives/show/instructions', '__return_true' ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | public function canProceed() |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | public function filterBeforeInstructions() |
47 | 47 | { |
48 | 48 | return sprintf( '<pre class="my-sites nav-tab-active misc-pub-section">%s</pre>', |
49 | - array_reduce( ['title', 'content', 'featured'], function( $instructions, $id ) { |
|
50 | - return $instructions . $this->filterInstruction( null, ['slug' => $id], ['slug' => $this->getPostType()] ) . PHP_EOL; |
|
49 | + array_reduce( [ 'title', 'content', 'featured' ], function( $instructions, $id ) { |
|
50 | + return $instructions . $this->filterInstruction( null, [ 'slug' => $id ], [ 'slug' => $this->getPostType() ] ) . PHP_EOL; |
|
51 | 51 | }) |
52 | 52 | ); |
53 | 53 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function filterInstruction( $instruction, array $field, array $metabox ) |
61 | 61 | { |
62 | - return sprintf( "ArchiveMeta::%s('%s');", $metabox['slug'], $field['slug'] ); |
|
62 | + return sprintf( "ArchiveMeta::%s('%s');", $metabox[ 'slug' ], $field[ 'slug' ] ); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function filterSubmitMetaBox( array $args ) |
70 | 70 | { |
71 | - $args[1] = __( 'Save Archive', 'pollux' ); |
|
71 | + $args[ 1 ] = __( 'Save Archive', 'pollux' ); |
|
72 | 72 | return $args; |
73 | 73 | } |
74 | 74 | |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function getFeaturedImageHtml() |
81 | 81 | { |
82 | - check_ajax_referer( sprintf( '%s-options', static::id() )); |
|
82 | + check_ajax_referer( sprintf( '%s-options', static::id() ) ); |
|
83 | 83 | static::$current = filter_input( INPUT_POST, 'post_type' ); |
84 | 84 | ob_start(); |
85 | - $this->renderFeaturedImageMetaBox( intval( filter_input( INPUT_POST, 'thumbnail_id' ))); |
|
85 | + $this->renderFeaturedImageMetaBox( intval( filter_input( INPUT_POST, 'thumbnail_id' ) ) ); |
|
86 | 86 | wp_send_json_success( ob_get_clean() ); |
87 | 87 | } |
88 | 88 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | public function register() |
105 | 105 | { |
106 | 106 | $screenId = ( new Helper )->getCurrentScreen()->id; |
107 | - if( in_array( $screenId, $this->hooks )) { |
|
107 | + if( in_array( $screenId, $this->hooks ) ) { |
|
108 | 108 | $this->hook = $screenId; |
109 | 109 | } |
110 | 110 | parent::register(); |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | */ |
117 | 117 | public function registerFeaturedImageMetaBox() |
118 | 118 | { |
119 | - if( !current_user_can( 'upload_files' ))return; |
|
120 | - add_meta_box( 'postimagediv', __( 'Featured Image', 'pollux' ), [$this, 'renderFeaturedImageMetaBox'], null, 'side', 'low' ); |
|
119 | + if( !current_user_can( 'upload_files' ) )return; |
|
120 | + add_meta_box( 'postimagediv', __( 'Featured Image', 'pollux' ), [ $this, 'renderFeaturedImageMetaBox' ], null, 'side', 'low' ); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -127,15 +127,15 @@ discard block |
||
127 | 127 | public function registerPage() |
128 | 128 | { |
129 | 129 | foreach( $this->getPostTypesWithArchive() as $type => $page ) { |
130 | - $labels = get_post_type_labels( get_post_type_object( $type )); |
|
131 | - $this->hooks[$type] = call_user_func_array( 'add_submenu_page', $this->filter( 'page', [ |
|
130 | + $labels = get_post_type_labels( get_post_type_object( $type ) ); |
|
131 | + $this->hooks[ $type ] = call_user_func_array( 'add_submenu_page', $this->filter( 'page', [ |
|
132 | 132 | $page, |
133 | 133 | sprintf( _x( '%s Archive', 'post archive', 'pollux' ), $labels->singular_name ), |
134 | 134 | sprintf( _x( '%s Archive', 'post archive', 'pollux' ), $labels->singular_name ), |
135 | 135 | static::CAPABILITY, |
136 | 136 | sprintf( '%s_archive', $type ), |
137 | - [$this, 'renderPage'], |
|
138 | - ])); |
|
137 | + [ $this, 'renderPage' ], |
|
138 | + ] ) ); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | 'resize' => false, |
157 | 157 | 'wp_autoresize_on' => true, |
158 | 158 | ], |
159 | - ]); |
|
159 | + ] ); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -165,12 +165,12 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function renderFeaturedImageMetaBox( $imageId = null ) |
167 | 167 | { |
168 | - if( !is_numeric( $imageId )) { |
|
168 | + if( !is_numeric( $imageId ) ) { |
|
169 | 169 | $imageId = ArchiveMeta::get( $this->getPostType(), 'featured', -1 ); |
170 | 170 | } |
171 | - $imageSize = isset( wp_get_additional_image_sizes()['post-thumbnail'] ) |
|
171 | + $imageSize = isset( wp_get_additional_image_sizes()[ 'post-thumbnail' ] ) |
|
172 | 172 | ? 'post-thumbnail' |
173 | - : [266, 266]; |
|
173 | + : [ 266, 266 ]; |
|
174 | 174 | $thumbnail = get_post( $imageId ) |
175 | 175 | ? wp_get_attachment_image( $imageId, $imageSize ) |
176 | 176 | : __( 'Set Featured Image', 'pollux' ); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | 'post_type' => $this->getPostType(), |
183 | 183 | 'remove_image' => __( 'Remove featured image', 'pollux' ), |
184 | 184 | 'thumbnail' => $thumbnail, |
185 | - ]); |
|
185 | + ] ); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | public function renderPage() |
193 | 193 | { |
194 | 194 | $type = $this->getPostType(); |
195 | - if( empty( $type ))return; |
|
196 | - $labels = get_post_type_labels( get_post_type_object( $type )); |
|
195 | + if( empty( $type ) )return; |
|
196 | + $labels = get_post_type_labels( get_post_type_object( $type ) ); |
|
197 | 197 | $this->app->render( 'archive/index', [ |
198 | 198 | 'columns' => get_current_screen()->get_columns(), |
199 | 199 | 'content' => ArchiveMeta::get( $type, 'content', '' ), |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | 'id' => static::id(), |
202 | 202 | 'post_type' => $type, |
203 | 203 | 'title' => ArchiveMeta::get( $type, 'title', '' ), |
204 | - ]); |
|
204 | + ] ); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | protected function getDefaults() |
211 | 211 | { |
212 | - return []; |
|
212 | + return [ ]; |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | protected function getPostType() |
219 | 219 | { |
220 | 220 | $type = array_search( $this->hook, $this->hooks ); |
221 | - if( !empty( $type ) && is_string( $type )) { |
|
221 | + if( !empty( $type ) && is_string( $type ) ) { |
|
222 | 222 | static::$current = $type; |
223 | 223 | } |
224 | 224 | return static::$current; |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | { |
232 | 232 | $types = array_map( function( $value ) { |
233 | 233 | return sprintf( 'edit.php?post_type=%s', $value ); |
234 | - }, get_post_types( ['has_archive' => 1] )); |
|
235 | - return array_merge( $types, ['post' => 'edit.php'] ); |
|
234 | + }, get_post_types( [ 'has_archive' => 1 ] ) ); |
|
235 | + return array_merge( $types, [ 'post' => 'edit.php' ] ); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | |
16 | 16 | const POST_TYPE_DEFAULTS = [ |
17 | 17 | 'capability_type' => 'post', |
18 | - 'columns' => [], |
|
18 | + 'columns' => [ ], |
|
19 | 19 | 'has_archive' => false, |
20 | 20 | 'hierarchical' => false, |
21 | - 'labels' => [], |
|
21 | + 'labels' => [ ], |
|
22 | 22 | 'map_meta_cap' => true, |
23 | 23 | 'menu_icon' => null, |
24 | 24 | 'menu_name' => '', |
@@ -30,27 +30,27 @@ discard block |
||
30 | 30 | 'show_in_menu' => true, |
31 | 31 | 'show_ui' => true, |
32 | 32 | 'single' => '', |
33 | - 'supports' => ['title', 'editor', 'thumbnail'], |
|
34 | - 'taxonomies' => [], |
|
33 | + 'supports' => [ 'title', 'editor', 'thumbnail' ], |
|
34 | + 'taxonomies' => [ ], |
|
35 | 35 | ]; |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @var array |
39 | 39 | */ |
40 | - public $types = []; |
|
40 | + public $types = [ ]; |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * {@inheritdoc} |
44 | 44 | */ |
45 | 45 | public function init() |
46 | 46 | { |
47 | - if( empty( $this->app->config->post_types ))return; |
|
47 | + if( empty( $this->app->config->post_types ) )return; |
|
48 | 48 | |
49 | 49 | $this->setColumns(); |
50 | 50 | $this->normalize(); |
51 | 51 | $this->initColumns(); |
52 | 52 | |
53 | - add_action( 'init', [$this, 'register'] ); |
|
53 | + add_action( 'init', [ $this, 'register' ] ); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | { |
62 | 62 | $types = array_diff_key( |
63 | 63 | $this->types, |
64 | - get_post_types( ['_builtin' => true] ) |
|
64 | + get_post_types( [ '_builtin' => true ] ) |
|
65 | 65 | ); |
66 | 66 | array_walk( $types, function( $args, $type ) { |
67 | - register_post_type( $type, array_diff_key( $args, array_flip( static::CUSTOM_KEYS ))); |
|
67 | + register_post_type( $type, array_diff_key( $args, array_flip( static::CUSTOM_KEYS ) ) ); |
|
68 | 68 | }); |
69 | 69 | } |
70 | 70 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | protected function normalize() |
75 | 75 | { |
76 | 76 | foreach( $this->app->config->post_types as $type => $args ) { |
77 | - $this->types[$type] = apply_filters( 'pollux/post_type/args', |
|
77 | + $this->types[ $type ] = apply_filters( 'pollux/post_type/args', |
|
78 | 78 | $this->normalizeThis( $args, static::POST_TYPE_DEFAULTS, $type ), |
79 | 79 | $type |
80 | 80 | ); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | */ |
88 | 88 | protected function normalizeLabels( $labels, array $args ) |
89 | 89 | { |
90 | - return wp_parse_args( $labels, $this->setLabels( $args )); |
|
90 | + return wp_parse_args( $labels, $this->setLabels( $args ) ); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | protected function normalizeMenuName( $menuname, array $args ) |
98 | 98 | { |
99 | 99 | return empty( $menuname ) |
100 | - ? $args['plural'] |
|
100 | + ? $args[ 'plural' ] |
|
101 | 101 | : $menuname; |
102 | 102 | } |
103 | 103 | |
@@ -108,17 +108,17 @@ discard block |
||
108 | 108 | { |
109 | 109 | return apply_filters( 'pollux/post_type/labels', [ |
110 | 110 | 'add_new' => __( 'Add New', 'pollux' ), |
111 | - 'add_new_item' => sprintf( _x( 'Add New %s', 'Add new post', 'pollux' ), $args['single'] ), |
|
112 | - 'all_items' => sprintf( _x( 'All %s', 'All posts', 'pollux' ), $args['plural'] ), |
|
113 | - 'edit_item' => sprintf( _x( 'Edit %s', 'Edit post', 'pollux' ), $args['single'] ), |
|
114 | - 'menu_name' => $this->normalizeMenuName( $args['menu_name'], $args ), |
|
115 | - 'name' => $args['plural'], |
|
116 | - 'new_item' => sprintf( _x( 'New %s', 'New post', 'pollux' ), $args['single'] ), |
|
117 | - 'not_found' => sprintf( _x( 'No %s found', 'No posts found', 'pollux' ), $args['plural'] ), |
|
118 | - 'not_found_in_trash' => sprintf( _x( 'No %s found in Trash', 'No posts found in trash', 'pollux' ), $args['plural'] ), |
|
119 | - 'search_items' => sprintf( _x( 'Search %s', 'Search posts', 'pollux' ), $args['plural'] ), |
|
120 | - 'singular_name' => $args['single'], |
|
121 | - 'view_item' => sprintf( _x( 'View %s', 'View post', 'pollux' ), $args['single'] ), |
|
111 | + 'add_new_item' => sprintf( _x( 'Add New %s', 'Add new post', 'pollux' ), $args[ 'single' ] ), |
|
112 | + 'all_items' => sprintf( _x( 'All %s', 'All posts', 'pollux' ), $args[ 'plural' ] ), |
|
113 | + 'edit_item' => sprintf( _x( 'Edit %s', 'Edit post', 'pollux' ), $args[ 'single' ] ), |
|
114 | + 'menu_name' => $this->normalizeMenuName( $args[ 'menu_name' ], $args ), |
|
115 | + 'name' => $args[ 'plural' ], |
|
116 | + 'new_item' => sprintf( _x( 'New %s', 'New post', 'pollux' ), $args[ 'single' ] ), |
|
117 | + 'not_found' => sprintf( _x( 'No %s found', 'No posts found', 'pollux' ), $args[ 'plural' ] ), |
|
118 | + 'not_found_in_trash' => sprintf( _x( 'No %s found in Trash', 'No posts found in trash', 'pollux' ), $args[ 'plural' ] ), |
|
119 | + 'search_items' => sprintf( _x( 'Search %s', 'Search posts', 'pollux' ), $args[ 'plural' ] ), |
|
120 | + 'singular_name' => $args[ 'single' ], |
|
121 | + 'view_item' => sprintf( _x( 'View %s', 'View post', 'pollux' ), $args[ 'single' ] ), |
|
122 | 122 | ], $args ); |
123 | 123 | } |
124 | 124 | } |