@@ -13,9 +13,13 @@ |
||
13 | 13 | ]; |
14 | 14 | foreach( $namespaces as $prefix => $base_dir ) { |
15 | 15 | $len = strlen( $prefix ); |
16 | - if( strncmp( $prefix, $class, $len ) !== 0 )continue; |
|
16 | + if( strncmp( $prefix, $class, $len ) !== 0 ) { |
|
17 | + continue; |
|
18 | + } |
|
17 | 19 | $file = $base_dir . str_replace( '\\', '/', substr( $class, $len ) ) . '.php'; |
18 | - if( !file_exists( $file ) )continue; |
|
20 | + if( !file_exists( $file ) ) { |
|
21 | + continue; |
|
22 | + } |
|
19 | 23 | require $file; |
20 | 24 | break; |
21 | 25 | } |
@@ -31,7 +31,8 @@ |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | private function __clone() |
34 | - {} |
|
34 | + { |
|
35 | +} |
|
35 | 36 | |
36 | 37 | /** |
37 | 38 | * Get or create the singleton alias loader instance. |
@@ -31,7 +31,8 @@ |
||
31 | 31 | 'name' => 'Plugin Name', |
32 | 32 | 'version' => 'Version', |
33 | 33 | ), 'plugin' ); |
34 | - array_walk( $data, function( $value, $key ) { |
|
34 | + array_walk( $data, function( $value, $key ) |
|
35 | + { |
|
35 | 36 | $this->$key = $value; |
36 | 37 | }); |
37 | 38 | } |
@@ -14,7 +14,9 @@ |
||
14 | 14 | |
15 | 15 | public function __construct( $plugin ) |
16 | 16 | { |
17 | - if( $this->proceed() )return; |
|
17 | + if( $this->proceed() ) { |
|
18 | + return; |
|
19 | + } |
|
18 | 20 | |
19 | 21 | $this->plugin = $plugin; |
20 | 22 |
@@ -18,7 +18,8 @@ |
||
18 | 18 | { |
19 | 19 | foreach( $this->types as $type => $args ) { |
20 | 20 | add_action( "manage_{$type}_posts_custom_column", [$this, 'printColumnValue'], 10, 2 ); |
21 | - add_filter( "manage_{$type}_posts_columns", function( $columns ) use( $args ) { |
|
21 | + add_filter( "manage_{$type}_posts_columns", function( $columns ) use( $args ) |
|
22 | + { |
|
22 | 23 | return count( $args['columns'] ) > 1 |
23 | 24 | ? $args['columns'] |
24 | 25 | : $columns; |
@@ -21,7 +21,8 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function validate( array $conditions ) |
23 | 23 | { |
24 | - array_walk( $conditions, function( &$value, $key ) { |
|
24 | + array_walk( $conditions, function( &$value, $key ) |
|
25 | + { |
|
25 | 26 | $method = ( new Helper )->buildMethodName( $key, 'validate' ); |
26 | 27 | $value = method_exists( $this, $method ) |
27 | 28 | ? $this->$method( $value ) |
@@ -41,7 +42,8 @@ discard block |
||
41 | 42 | foreach( $conditions as $key ) { |
42 | 43 | $conditions[str_replace( '!', '', $key )] = substr( $key, 0, 1 ) == '!' ? 0 : 1; |
43 | 44 | } |
44 | - $conditions = array_filter( $conditions, function( $key ) { |
|
45 | + $conditions = array_filter( $conditions, function( $key ) |
|
46 | + { |
|
45 | 47 | return !is_numeric( $key ); |
46 | 48 | }, ARRAY_FILTER_USE_KEY ); |
47 | 49 | } |
@@ -12,7 +12,9 @@ |
||
12 | 12 | */ |
13 | 13 | public function get( $metaKey, array $args = [] ) |
14 | 14 | { |
15 | - if( empty( $metaKey ))return; |
|
15 | + if( empty( $metaKey )) { |
|
16 | + return; |
|
17 | + } |
|
16 | 18 | |
17 | 19 | $args = $this->normalize( $args ); |
18 | 20 | $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |
@@ -22,8 +22,10 @@ discard block |
||
22 | 22 | */ |
23 | 23 | protected function generateInstructions() |
24 | 24 | { |
25 | - $instructions = array_reduce( $this->getInstructions(), function( $html, $metabox ) { |
|
26 | - $fields = array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox ) { |
|
25 | + $instructions = array_reduce( $this->getInstructions(), function( $html, $metabox ) |
|
26 | + { |
|
27 | + $fields = array_reduce( $metabox['fields'], function( $html, $field ) use( $metabox ) |
|
28 | + { |
|
27 | 29 | return $this->validate( $field['condition'] ) |
28 | 30 | ? $html . $this->filter( 'instruction', "PostMeta::get('{$field['slug']}');", $field, $metabox ) . PHP_EOL |
29 | 31 | : $html; |
@@ -41,7 +43,8 @@ discard block |
||
41 | 43 | */ |
42 | 44 | protected function getInstructions() |
43 | 45 | { |
44 | - return array_filter( $this->metaboxes, function( $metabox ) { |
|
46 | + return array_filter( $this->metaboxes, function( $metabox ) |
|
47 | + { |
|
45 | 48 | return $this->validate( $metabox['condition'] ) |
46 | 49 | && $this->hasPostType( $metabox ); |
47 | 50 | }); |
@@ -52,7 +55,9 @@ discard block |
||
52 | 55 | */ |
53 | 56 | protected function initInstructions() |
54 | 57 | { |
55 | - if( !$this->showInstructions() )return; |
|
58 | + if( !$this->showInstructions() ) { |
|
59 | + return; |
|
60 | + } |
|
56 | 61 | return [ |
57 | 62 | 'infodiv' => [ |
58 | 63 | 'context' => 'side', |
@@ -73,7 +78,8 @@ discard block |
||
73 | 78 | */ |
74 | 79 | protected function showInstructions() |
75 | 80 | { |
76 | - return $this->filter( 'show/instructions', count( array_filter( $this->metaboxes, function( $metabox ) { |
|
81 | + return $this->filter( 'show/instructions', count( array_filter( $this->metaboxes, function( $metabox ) |
|
82 | + { |
|
77 | 83 | return $this->show( false, $metabox ); |
78 | 84 | })) > 0 ); |
79 | 85 | } |
@@ -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' )); |