@@ -6,25 +6,25 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | class PostMeta |
| 8 | 8 | { |
| 9 | - public function get( $metaKey, array $args = [] ) |
|
| 9 | + public function get( $metaKey, array $args = [ ] ) |
|
| 10 | 10 | { |
| 11 | - if( empty( $metaKey ))return; |
|
| 11 | + if( empty( $metaKey ) )return; |
|
| 12 | 12 | |
| 13 | 13 | $args = $this->normalize( $args ); |
| 14 | - $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |
|
| 15 | - $metaValue = get_post_meta( $args['id'], $metaKey, $args['single'] ); |
|
| 14 | + $metaKey = $this->buildMetaKey( $metaKey, $args[ 'prefix' ] ); |
|
| 15 | + $metaValue = get_post_meta( $args[ 'id' ], $metaKey, $args[ 'single' ] ); |
|
| 16 | 16 | |
| 17 | - if( is_string( $metaValue )) { |
|
| 17 | + if( is_string( $metaValue ) ) { |
|
| 18 | 18 | $metaValue = trim( $metaValue ); |
| 19 | 19 | } |
| 20 | 20 | return empty( $metaValue ) |
| 21 | - ? $args['fallback'] |
|
| 21 | + ? $args[ 'fallback' ] |
|
| 22 | 22 | : $metaValue; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | protected function buildMetaKey( $metaKey, $prefix ) |
| 26 | 26 | { |
| 27 | - return ( substr( $metaKey, 0, 1 ) == '_' && !empty( $prefix )) |
|
| 27 | + return ( substr( $metaKey, 0, 1 ) == '_' && !empty( $prefix ) ) |
|
| 28 | 28 | ? sprintf( '_%s%s', rtrim( $prefix, '_' ), $metaKey ) |
| 29 | 29 | : $prefix . $metaKey; |
| 30 | 30 | } |
@@ -37,6 +37,6 @@ discard block |
||
| 37 | 37 | 'single' => true, |
| 38 | 38 | 'prefix' => Application::PREFIX, |
| 39 | 39 | ]; |
| 40 | - return shortcode_atts( $defaults, array_change_key_case( $args )); |
|
| 40 | + return shortcode_atts( $defaults, array_change_key_case( $args ) ); |
|
| 41 | 41 | } |
| 42 | 42 | } |
@@ -8,7 +8,9 @@ |
||
| 8 | 8 | { |
| 9 | 9 | public function get( $metaKey, array $args = [] ) |
| 10 | 10 | { |
| 11 | - if( empty( $metaKey ))return; |
|
| 11 | + if( empty( $metaKey )) { |
|
| 12 | + return; |
|
| 13 | + } |
|
| 12 | 14 | |
| 13 | 15 | $args = $this->normalize( $args ); |
| 14 | 16 | $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |