@@ -126,7 +126,9 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function register() |
128 | 128 | { |
129 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
129 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
130 | + return; |
|
131 | + } |
|
130 | 132 | foreach( parent::register() as $metabox ) { |
131 | 133 | new RWMetaBox( $metabox, static::ID, $this ); |
132 | 134 | } |
@@ -169,7 +171,9 @@ discard block |
||
169 | 171 | */ |
170 | 172 | public function renderFooterScript() |
171 | 173 | { |
172 | - if(( new Helper )->getCurrentScreen()->id != $this->hook )return; |
|
174 | + if(( new Helper )->getCurrentScreen()->id != $this->hook ) { |
|
175 | + return; |
|
176 | + } |
|
173 | 177 | $this->app->render( 'settings/script', [ |
174 | 178 | 'confirm' => __( 'Are you sure want to do this?', 'pollux' ), |
175 | 179 | 'hook' => $this->hook, |
@@ -217,7 +221,9 @@ discard block |
||
217 | 221 | { |
218 | 222 | if( filter_input( INPUT_GET, 'page' ) !== static::id() |
219 | 223 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
220 | - )return; |
|
224 | + ) { |
|
225 | + return; |
|
226 | + } |
|
221 | 227 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), $this->hook )) { |
222 | 228 | update_option( static::id(), $this->getDefaults() ); |
223 | 229 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); |
@@ -236,7 +242,8 @@ discard block |
||
236 | 242 | */ |
237 | 243 | protected function filterArrayByKey( array $array, $key ) |
238 | 244 | { |
239 | - return array_filter( $array, function( $value ) use( $key ) { |
|
245 | + return array_filter( $array, function( $value ) use( $key ) |
|
246 | + { |
|
240 | 247 | return !empty( $value[$key] ); |
241 | 248 | }); |
242 | 249 | } |
@@ -248,8 +255,10 @@ discard block |
||
248 | 255 | { |
249 | 256 | $metaboxes = $this->filterArrayByKey( $this->metaboxes, 'slug' ); |
250 | 257 | |
251 | - array_walk( $metaboxes, function( &$metabox ) { |
|
252 | - $fields = array_map( function( $field ) { |
|
258 | + array_walk( $metaboxes, function( &$metabox ) |
|
259 | + { |
|
260 | + $fields = array_map( function( $field ) |
|
261 | + { |
|
253 | 262 | $field = wp_parse_args( $field, ['std' => ''] ); |
254 | 263 | return [$field['slug'] => $field['std']]; |
255 | 264 | }, $this->filterArrayByKey( $metabox['fields'], 'slug' )); |
@@ -40,7 +40,9 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function filterWordPressFooter( $text ) |
42 | 42 | { |
43 | - if( $this->app->config->remove_wordpress_footer )return; |
|
43 | + if( $this->app->config->remove_wordpress_footer ) { |
|
44 | + return; |
|
45 | + } |
|
44 | 46 | return $text; |
45 | 47 | } |
46 | 48 | |
@@ -78,7 +80,9 @@ discard block |
||
78 | 80 | */ |
79 | 81 | public function removeDashboardWidgets() |
80 | 82 | { |
81 | - if( !$this->app->config->remove_dashboard_widgets )return; |
|
83 | + if( !$this->app->config->remove_dashboard_widgets ) { |
|
84 | + return; |
|
85 | + } |
|
82 | 86 | $widgets = apply_filters( 'pollux/dashoard/widgets', [ |
83 | 87 | 'dashboard_quick_press', |
84 | 88 | ]); |
@@ -93,7 +97,9 @@ discard block |
||
93 | 97 | */ |
94 | 98 | public function removeWordPressMenu() |
95 | 99 | { |
96 | - if( !$this->app->config->remove_wordpress_menu )return; |
|
100 | + if( !$this->app->config->remove_wordpress_menu ) { |
|
101 | + return; |
|
102 | + } |
|
97 | 103 | global $wp_admin_bar; |
98 | 104 | $wp_admin_bar->remove_menu( 'wp-logo' ); |
99 | 105 | } |
@@ -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 ); |
@@ -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 | } |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function init() |
25 | 25 | { |
26 | - if( !$this->app->config->disable_posts )return; |
|
26 | + if( !$this->app->config->disable_posts ) { |
|
27 | + return; |
|
28 | + } |
|
27 | 29 | |
28 | 30 | add_action( 'init', [$this, 'disable'] ); |
29 | 31 | add_action( 'wp_dashboard_setup', [$this, 'modifyDashboardWidgets'] ); |
@@ -43,7 +45,9 @@ discard block |
||
43 | 45 | { |
44 | 46 | if( !in_array(( new Helper )->getCurrentScreen()->pagenow, [ |
45 | 47 | 'edit.php', 'edit-tags.php', 'post-new.php', |
46 | - ]))return; |
|
48 | + ])) { |
|
49 | + return; |
|
50 | + } |
|
47 | 51 | |
48 | 52 | if( !filter_input_array( INPUT_GET, [ |
49 | 53 | 'post_type' => FILTER_DEFAULT, |
@@ -95,12 +99,17 @@ discard block |
||
95 | 99 | */ |
96 | 100 | public function modifyDashboardWidgets() |
97 | 101 | { |
98 | - if( !is_blog_admin() || !current_user_can( 'edit_posts' ))return; |
|
102 | + if( !is_blog_admin() || !current_user_can( 'edit_posts' )) { |
|
103 | + return; |
|
104 | + } |
|
99 | 105 | |
100 | 106 | global $wp_meta_boxes; |
101 | 107 | $widgets = &$wp_meta_boxes['dashboard']['normal']['core']; |
102 | - if( !isset( $widgets['dashboard_right_now']['callback'] ))return; |
|
103 | - $widgets['dashboard_right_now']['callback'] = function() { |
|
108 | + if( !isset( $widgets['dashboard_right_now']['callback'] )) { |
|
109 | + return; |
|
110 | + } |
|
111 | + $widgets['dashboard_right_now']['callback'] = function() |
|
112 | + { |
|
104 | 113 | ob_start(); |
105 | 114 | wp_dashboard_right_now(); |
106 | 115 | echo preg_replace( '/<li class="post-count">(.*?)<\/li>/', '', ob_get_clean() ); |
@@ -23,7 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function init() |
25 | 25 | { |
26 | - if( !$this->app->config->enable_archive_meta )return; |
|
26 | + if( !$this->app->config->enable_archive_meta ) { |
|
27 | + return; |
|
28 | + } |
|
27 | 29 | |
28 | 30 | parent::init(); |
29 | 31 | |
@@ -42,7 +44,8 @@ discard block |
||
42 | 44 | public function filterBeforeInstructions() |
43 | 45 | { |
44 | 46 | return sprintf( '<pre class="my-sites nav-tab-active misc-pub-section">%s</pre>', |
45 | - array_reduce( ['title', 'content', 'featured'], function( $instructions, $id ) { |
|
47 | + array_reduce( ['title', 'content', 'featured'], function( $instructions, $id ) |
|
48 | + { |
|
46 | 49 | return $instructions . $this->filterInstruction( null, ['slug' => $id], ['slug' => $this->getPostType()] ) . PHP_EOL; |
47 | 50 | }) |
48 | 51 | ); |
@@ -112,7 +115,9 @@ discard block |
||
112 | 115 | */ |
113 | 116 | public function registerFeaturedImageMetaBox() |
114 | 117 | { |
115 | - if( !current_user_can( 'upload_files' ))return; |
|
118 | + if( !current_user_can( 'upload_files' )) { |
|
119 | + return; |
|
120 | + } |
|
116 | 121 | add_meta_box( 'postimagediv', __( 'Featured Image', 'pollux' ), [$this, 'renderFeaturedImageMetaBox'], null, 'side', 'low' ); |
117 | 122 | } |
118 | 123 | |
@@ -188,7 +193,9 @@ discard block |
||
188 | 193 | public function renderPage() |
189 | 194 | { |
190 | 195 | $type = $this->getPostType(); |
191 | - if( empty( $type ))return; |
|
196 | + if( empty( $type )) { |
|
197 | + return; |
|
198 | + } |
|
192 | 199 | $labels = get_post_type_labels( get_post_type_object( $type )); |
193 | 200 | $this->app->render( 'archive/index', [ |
194 | 201 | 'columns' => get_current_screen()->get_columns(), |
@@ -225,7 +232,8 @@ discard block |
||
225 | 232 | */ |
226 | 233 | protected function getPostTypesWithArchive() |
227 | 234 | { |
228 | - $types = array_map( function( $value ) { |
|
235 | + $types = array_map( function( $value ) |
|
236 | + { |
|
229 | 237 | return sprintf( 'edit.php?post_type=%s', $value ); |
230 | 238 | }, get_post_types( ['has_archive' => 1] )); |
231 | 239 | return array_merge( $types, ['post' => 'edit.php'] ); |
@@ -37,7 +37,9 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function init() |
39 | 39 | { |
40 | - if( $this->app->config->disable_config )return; |
|
40 | + if( $this->app->config->disable_config ) { |
|
41 | + return; |
|
42 | + } |
|
41 | 43 | |
42 | 44 | add_action( 'admin_menu', [$this, 'registerPage'] ); |
43 | 45 | add_action( 'admin_menu', [$this, 'registerSetting'] ); |
@@ -106,7 +108,9 @@ discard block |
||
106 | 108 | { |
107 | 109 | if( filter_input( INPUT_GET, 'page' ) !== $this->app->id |
108 | 110 | || filter_input( INPUT_GET, 'action' ) !== 'reset' |
109 | - )return; |
|
111 | + ) { |
|
112 | + return; |
|
113 | + } |
|
110 | 114 | if( wp_verify_nonce( filter_input( INPUT_GET, '_wpnonce' ), static::id() )) { |
111 | 115 | delete_option( static::id() ); |
112 | 116 | add_settings_error( static::id(), 'reset', __( 'Reset successful.', 'pollux' ), 'updated' ); |
@@ -107,7 +107,9 @@ discard block |
||
107 | 107 | trailingslashit( dirname( dirname( ABSPATH ))), |
108 | 108 | ]); |
109 | 109 | foreach( (array) $configLocations as $location ) { |
110 | - if( !file_exists( $location . $configYaml ))continue; |
|
110 | + if( !file_exists( $location . $configYaml )) { |
|
111 | + continue; |
|
112 | + } |
|
111 | 113 | return $location . $configYaml; |
112 | 114 | } |
113 | 115 | return $this->app->path( 'defaults.yml' ); |
@@ -118,7 +120,8 @@ discard block |
||
118 | 120 | */ |
119 | 121 | public function normalizeArray( array $array ) |
120 | 122 | { |
121 | - return array_map( function( $value ) { |
|
123 | + return array_map( function( $value ) |
|
124 | + { |
|
122 | 125 | return !is_numeric( $value ) && is_string( $value ) |
123 | 126 | ? $this->parseYaml( $value ) |
124 | 127 | : $value; |
@@ -130,7 +133,8 @@ discard block |
||
130 | 133 | */ |
131 | 134 | public function normalizeYamlValues( array $array ) |
132 | 135 | { |
133 | - return array_map( function( $value ) { |
|
136 | + return array_map( function( $value ) |
|
137 | + { |
|
134 | 138 | return is_array( $value ) |
135 | 139 | ? $this->convertArrayToYaml( $value ) |
136 | 140 | : $value; |
@@ -188,7 +192,8 @@ discard block |
||
188 | 192 | $strings = apply_filters( 'pollux/config/raw_strings', static::RAW_STRINGS ); |
189 | 193 | $pattern = '/(\')((' . implode( '|', $strings ) . ')\(?.+\))(\')/'; |
190 | 194 | return stripslashes( |
191 | - preg_replace_callback( $pattern, function( $matches ) { |
|
195 | + preg_replace_callback( $pattern, function( $matches ) |
|
196 | + { |
|
192 | 197 | return str_replace( "''", "'", $matches[2] ); |
193 | 198 | }, $configString ) |
194 | 199 | ); |
@@ -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'] )) { |