@@ -26,7 +26,9 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function filterWordPressFooter( $text ) |
| 28 | 28 | { |
| 29 | - if( $this->app->config['remove_wordpress_footer'] )return; |
|
| 29 | + if( $this->app->config['remove_wordpress_footer'] ) { |
|
| 30 | + return; |
|
| 31 | + } |
|
| 30 | 32 | return $text; |
| 31 | 33 | } |
| 32 | 34 | |
@@ -63,7 +65,9 @@ discard block |
||
| 63 | 65 | */ |
| 64 | 66 | public function removeDashboardWidgets() |
| 65 | 67 | { |
| 66 | - if( !$this->app->config['remove_dashboard_widgets'] )return; |
|
| 68 | + if( !$this->app->config['remove_dashboard_widgets'] ) { |
|
| 69 | + return; |
|
| 70 | + } |
|
| 67 | 71 | $widgets = apply_filters( 'pollux/dashoard/widgets', [ |
| 68 | 72 | 'dashboard_quick_press', |
| 69 | 73 | ]); |
@@ -78,7 +82,9 @@ discard block |
||
| 78 | 82 | */ |
| 79 | 83 | public function removeWordPressMenu() |
| 80 | 84 | { |
| 81 | - if( !$this->app->config['remove_wordpress_menu'] )return; |
|
| 85 | + if( !$this->app->config['remove_wordpress_menu'] ) { |
|
| 86 | + return; |
|
| 87 | + } |
|
| 82 | 88 | global $wp_admin_bar; |
| 83 | 89 | $wp_admin_bar->remove_menu( 'wp-logo' ); |
| 84 | 90 | } |
@@ -31,7 +31,9 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | public function init() |
| 33 | 33 | { |
| 34 | - if( empty( $this->app->config[static::ID] ))return; |
|
| 34 | + if( empty( $this->app->config[static::ID] )) { |
|
| 35 | + return; |
|
| 36 | + } |
|
| 35 | 37 | |
| 36 | 38 | $this->normalize( $this->app->config[static::ID], [ |
| 37 | 39 | 'post_types' => [], |
@@ -199,7 +201,8 @@ discard block |
||
| 199 | 201 | */ |
| 200 | 202 | protected function normalizeFields( array $fields, array $data, $parentId ) |
| 201 | 203 | { |
| 202 | - return array_map( function( $id, $field ) use( $parentId ) { |
|
| 204 | + return array_map( function( $id, $field ) use( $parentId ) |
|
| 205 | + { |
|
| 203 | 206 | $defaults = [ |
| 204 | 207 | 'attributes' => [], |
| 205 | 208 | 'class' => '', |
@@ -238,7 +241,9 @@ discard block |
||
| 238 | 241 | protected function normalizeValidation( array $validation, array $data, $parentId ) |
| 239 | 242 | { |
| 240 | 243 | foreach( ['messages', 'rules'] as $key ) { |
| 241 | - if( empty( $validation[$key] ))continue; |
|
| 244 | + if( empty( $validation[$key] )) { |
|
| 245 | + continue; |
|
| 246 | + } |
|
| 242 | 247 | foreach( $validation[$key] as $id => $value ) { |
| 243 | 248 | $validation[$key][$this->normalizeFieldName( $id, ['slug' => $id], $parentId )] = $value; |
| 244 | 249 | unset( $validation[$key][$id] ); |
@@ -254,8 +259,11 @@ discard block |
||
| 254 | 259 | { |
| 255 | 260 | $fields = &$metabox['fields']; |
| 256 | 261 | $depends = array_column( $fields, 'depends' ); |
| 257 | - array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) { |
|
| 258 | - if( empty( $value ))return; |
|
| 262 | + array_walk( $depends, function( $value, $index ) use( &$fields, $metabox ) |
|
| 263 | + { |
|
| 264 | + if( empty( $value )) { |
|
| 265 | + return; |
|
| 266 | + } |
|
| 259 | 267 | $dependency = array_search( $value, array_column( $fields, 'id' )); |
| 260 | 268 | $fields[$index]['attributes']['data-depends'] = $value; |
| 261 | 269 | if( !$this->getMetaValue( $fields[$dependency]['slug'], '', $metabox['slug'] )) { |
@@ -45,7 +45,9 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function init() |
| 47 | 47 | { |
| 48 | - if( empty( $this->app->config['post_types'] ))return; |
|
| 48 | + if( empty( $this->app->config['post_types'] )) { |
|
| 49 | + return; |
|
| 50 | + } |
|
| 49 | 51 | |
| 50 | 52 | $this->setColumns(); |
| 51 | 53 | $this->normalize(); |
@@ -64,7 +66,8 @@ discard block |
||
| 64 | 66 | $this->types, |
| 65 | 67 | get_post_types( ['_builtin' => true] ) |
| 66 | 68 | ); |
| 67 | - array_walk( $types, function( $args, $type ) { |
|
| 69 | + array_walk( $types, function( $args, $type ) |
|
| 70 | + { |
|
| 68 | 71 | register_post_type( $type, array_diff_key( $args, array_flip( static::CUSTOM_KEYS ))); |
| 69 | 72 | }); |
| 70 | 73 | } |
@@ -35,7 +35,9 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | public function init() |
| 37 | 37 | { |
| 38 | - if( empty( $this->app->config['taxonomies'] ))return; |
|
| 38 | + if( empty( $this->app->config['taxonomies'] )) { |
|
| 39 | + return; |
|
| 40 | + } |
|
| 39 | 41 | |
| 40 | 42 | $this->normalize(); |
| 41 | 43 | |
@@ -50,10 +52,14 @@ discard block |
||
| 50 | 52 | */ |
| 51 | 53 | public function filterByTaxonomy( WP_Query $query ) |
| 52 | 54 | { |
| 53 | - if( !is_admin() || ( new Helper )->getCurrentScreen()->base != 'edit' )return; |
|
| 55 | + if( !is_admin() || ( new Helper )->getCurrentScreen()->base != 'edit' ) { |
|
| 56 | + return; |
|
| 57 | + } |
|
| 54 | 58 | $vars = &$query->query_vars; |
| 55 | 59 | foreach( array_keys( $this->taxonomies ) as $taxonomy ) { |
| 56 | - if( !isset( $vars[$taxonomy] ))return; |
|
| 60 | + if( !isset( $vars[$taxonomy] )) { |
|
| 61 | + return; |
|
| 62 | + } |
|
| 57 | 63 | if( $term = get_term_by( 'id', $vars[$taxonomy], $taxonomy )) { |
| 58 | 64 | $vars[$taxonomy] = $term->slug; |
| 59 | 65 | } |
@@ -69,7 +75,9 @@ discard block |
||
| 69 | 75 | { |
| 70 | 76 | global $wp_query; |
| 71 | 77 | foreach( $this->taxonomies as $taxonomy => $args ) { |
| 72 | - if( !in_array( get_current_screen()->post_type, $args['post_types'] ))continue; |
|
| 78 | + if( !in_array( get_current_screen()->post_type, $args['post_types'] )) { |
|
| 79 | + continue; |
|
| 80 | + } |
|
| 73 | 81 | $selected = isset( $wp_query->query[$taxonomy] ) |
| 74 | 82 | ? $wp_query->query[$taxonomy] |
| 75 | 83 | : false; |
@@ -90,7 +98,8 @@ discard block |
||
| 90 | 98 | */ |
| 91 | 99 | public function register() |
| 92 | 100 | { |
| 93 | - array_walk( $this->taxonomies, function( $args, $taxonomy ) { |
|
| 101 | + array_walk( $this->taxonomies, function( $args, $taxonomy ) |
|
| 102 | + { |
|
| 94 | 103 | register_taxonomy( $taxonomy, $args['post_types'], array_diff_key( $args, array_flip( static::CUSTOM_KEYS ))); |
| 95 | 104 | foreach( $args['post_types'] as $type ) { |
| 96 | 105 | register_taxonomy_for_object_type( $taxonomy, $type ); |
@@ -40,7 +40,8 @@ discard block |
||
| 40 | 40 | public function filterBeforeInstructions() |
| 41 | 41 | { |
| 42 | 42 | return sprintf( '<pre class="my-sites nav-tab-active misc-pub-section">%s</pre>', |
| 43 | - array_reduce( ['title', 'content', 'featured'], function( $instructions, $id ) { |
|
| 43 | + array_reduce( ['title', 'content', 'featured'], function( $instructions, $id ) |
|
| 44 | + { |
|
| 44 | 45 | return $instructions . $this->filterInstruction( null, ['slug' => $id], ['slug' => $this->getPostType()] ) . PHP_EOL; |
| 45 | 46 | }) |
| 46 | 47 | ); |
@@ -110,7 +111,9 @@ discard block |
||
| 110 | 111 | */ |
| 111 | 112 | public function registerFeaturedImageMetaBox() |
| 112 | 113 | { |
| 113 | - if( !current_user_can( 'upload_files' ))return; |
|
| 114 | + if( !current_user_can( 'upload_files' )) { |
|
| 115 | + return; |
|
| 116 | + } |
|
| 114 | 117 | add_meta_box( 'postimagediv', __( 'Featured Image', 'pollux' ), [$this, 'renderFeaturedImageMetaBox'], null, 'side', 'low' ); |
| 115 | 118 | } |
| 116 | 119 | |
@@ -186,7 +189,9 @@ discard block |
||
| 186 | 189 | public function renderPage() |
| 187 | 190 | { |
| 188 | 191 | $type = $this->getPostType(); |
| 189 | - if( empty( $type ))return; |
|
| 192 | + if( empty( $type )) { |
|
| 193 | + return; |
|
| 194 | + } |
|
| 190 | 195 | $labels = get_post_type_labels( get_post_type_object( $type )); |
| 191 | 196 | $this->app->render( 'archive/index', [ |
| 192 | 197 | 'columns' => get_current_screen()->get_columns(), |
@@ -223,7 +228,8 @@ discard block |
||
| 223 | 228 | */ |
| 224 | 229 | protected function getPostTypesWithArchive() |
| 225 | 230 | { |
| 226 | - $types = array_map( function( $value ) { |
|
| 231 | + $types = array_map( function( $value ) |
|
| 232 | + { |
|
| 227 | 233 | return sprintf( 'edit.php?post_type=%s', $value ); |
| 228 | 234 | }, get_post_types( ['has_archive' => 1] )); |
| 229 | 235 | return array_merge( $types, ['post' => 'edit.php'] ); |
@@ -41,7 +41,9 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public function init() |
| 43 | 43 | { |
| 44 | - if( empty( $this->app->config[static::ID] ))return; |
|
| 44 | + if( empty( $this->app->config[static::ID] )) { |
|
| 45 | + return; |
|
| 46 | + } |
|
| 45 | 47 | if( is_bool( $this->app->config[static::ID] )) { |
| 46 | 48 | $this->app->config[static::ID] = []; |
| 47 | 49 | } |
@@ -126,7 +128,9 @@ discard block |
||
| 126 | 128 | */ |
| 127 | 129 | public function register() |
| 128 | 130 | { |
| 129 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
| 131 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
| 132 | + return; |
|
| 133 | + } |
|
| 130 | 134 | foreach( parent::register() as $metabox ) { |
| 131 | 135 | new RWMetaBox( $metabox, static::ID, $this ); |
| 132 | 136 | } |
@@ -169,7 +173,9 @@ discard block |
||
| 169 | 173 | */ |
| 170 | 174 | public function renderFooterScript() |
| 171 | 175 | { |
| 172 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
| 176 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
| 177 | + return; |
|
| 178 | + } |
|
| 173 | 179 | $this->app->render( 'settings/script', [ |
| 174 | 180 | 'confirm' => __( 'Are you sure want to do this?', 'pollux' ), |
| 175 | 181 | 'hook' => $this->hook, |
@@ -217,7 +223,9 @@ discard block |
||
| 217 | 223 | { |
| 218 | 224 | if( filter_input( INPUT_GET, 'page' ) !== static::id() |
| 219 | 225 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
| 220 | - )return; |
|
| 226 | + ) { |
|
| 227 | + return; |
|
| 228 | + } |
|
| 221 | 229 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
| 222 | 230 | update_option( static::id(), $this->getDefaults() ); |
| 223 | 231 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); |
@@ -236,7 +244,8 @@ discard block |
||
| 236 | 244 | */ |
| 237 | 245 | protected function filterArrayByKey( array $array, $key ) |
| 238 | 246 | { |
| 239 | - return array_filter( $array, function( $value ) use( $key ) { |
|
| 247 | + return array_filter( $array, function( $value ) use( $key ) |
|
| 248 | + { |
|
| 240 | 249 | return !empty( $value[$key] ); |
| 241 | 250 | }); |
| 242 | 251 | } |
@@ -248,8 +257,10 @@ discard block |
||
| 248 | 257 | { |
| 249 | 258 | $metaboxes = $this->filterArrayByKey( $this->metaboxes, 'slug' ); |
| 250 | 259 | |
| 251 | - array_walk( $metaboxes, function( &$metabox ) { |
|
| 252 | - $fields = array_map( function( $field ) { |
|
| 260 | + array_walk( $metaboxes, function( &$metabox ) |
|
| 261 | + { |
|
| 262 | + $fields = array_map( function( $field ) |
|
| 263 | + { |
|
| 253 | 264 | $field = wp_parse_args( $field, ['std' => ''] ); |
| 254 | 265 | return [$field['slug'] => $field['std']]; |
| 255 | 266 | }, $this->filterArrayByKey( $metabox['fields'], 'slug' )); |