@@ -10,19 +10,19 @@ discard block |
||
10 | 10 | * @param string $metaKey |
11 | 11 | * @return mixed |
12 | 12 | */ |
13 | - public function get( $metaKey, array $args = [] ) |
|
13 | + public function get( $metaKey, array $args = [ ] ) |
|
14 | 14 | { |
15 | - if( empty( $metaKey ))return; |
|
15 | + if( empty( $metaKey ) )return; |
|
16 | 16 | |
17 | 17 | $args = $this->normalize( $args ); |
18 | - $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |
|
19 | - $metaValue = get_post_meta( $args['id'], $metaKey, $args['single'] ); |
|
18 | + $metaKey = $this->buildMetaKey( $metaKey, $args[ 'prefix' ] ); |
|
19 | + $metaValue = get_post_meta( $args[ 'id' ], $metaKey, $args[ 'single' ] ); |
|
20 | 20 | |
21 | - if( is_string( $metaValue )) { |
|
21 | + if( is_string( $metaValue ) ) { |
|
22 | 22 | $metaValue = trim( $metaValue ); |
23 | 23 | } |
24 | 24 | return empty( $metaValue ) |
25 | - ? $args['fallback'] |
|
25 | + ? $args[ 'fallback' ] |
|
26 | 26 | : $metaValue; |
27 | 27 | } |
28 | 28 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | protected function buildMetaKey( $metaKey, $prefix ) |
35 | 35 | { |
36 | - return ( substr( $metaKey, 0, 1 ) == '_' && !empty( $prefix )) |
|
36 | + return ( substr( $metaKey, 0, 1 ) == '_' && !empty( $prefix ) ) |
|
37 | 37 | ? sprintf( '_%s%s', rtrim( $prefix, '_' ), $metaKey ) |
38 | 38 | : $prefix . $metaKey; |
39 | 39 | } |
@@ -49,6 +49,6 @@ discard block |
||
49 | 49 | 'single' => true, |
50 | 50 | 'prefix' => apply_filters( 'pollux/prefix', Application::PREFIX ), |
51 | 51 | ]; |
52 | - return shortcode_atts( $defaults, array_change_key_case( $args )); |
|
52 | + return shortcode_atts( $defaults, array_change_key_case( $args ) ); |
|
53 | 53 | } |
54 | 54 | } |
@@ -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'] ); |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | */ |
15 | 15 | public function get( $group = null, $key = null, $fallback = null ) |
16 | 16 | { |
17 | - $options = get_option( apply_filters( 'pollux/settings/option', Settings::ID )); |
|
18 | - if( empty( $options )) { |
|
17 | + $options = get_option( apply_filters( 'pollux/settings/option', Settings::ID ) ); |
|
18 | + if( empty( $options ) ) { |
|
19 | 19 | return $fallback; |
20 | 20 | } |
21 | - if( !is_string( $group )) { |
|
21 | + if( !is_string( $group ) ) { |
|
22 | 22 | return $options; |
23 | 23 | } |
24 | 24 | $group = $this->normalize( $options, $group, $fallback ); |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | */ |
35 | 35 | protected function normalize( array $options, $key, $fallback ) |
36 | 36 | { |
37 | - if( !array_key_exists( $key, $options )) { |
|
37 | + if( !array_key_exists( $key, $options ) ) { |
|
38 | 38 | return $fallback; |
39 | 39 | } |
40 | - $option = $options[$key]; |
|
40 | + $option = $options[ $key ]; |
|
41 | 41 | $option = is_array( $option ) |
42 | 42 | ? array_filter( $option ) |
43 | 43 | : trim( $option ); |