@@ -4,35 +4,35 @@ |
||
4 | 4 | |
5 | 5 | class PostMeta |
6 | 6 | { |
7 | - public function get( $metaKey, array $args = [] ) |
|
7 | + public function get($metaKey, array $args = []) |
|
8 | 8 | { |
9 | - if( empty( $metaKey ))return; |
|
9 | + if (empty($metaKey))return; |
|
10 | 10 | |
11 | - $args = $this->normalize( $args ); |
|
12 | - $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |
|
13 | - $metaValue = get_post_meta( $args['ID'], $metaKey, $args['single'] ); |
|
11 | + $args = $this->normalize($args); |
|
12 | + $metaKey = $this->buildMetaKey($metaKey, $args['prefix']); |
|
13 | + $metaValue = get_post_meta($args['ID'], $metaKey, $args['single']); |
|
14 | 14 | |
15 | - return empty( $metaValue ) |
|
15 | + return empty($metaValue) |
|
16 | 16 | ? $args['fallback'] |
17 | 17 | : $metaValue; |
18 | 18 | } |
19 | 19 | |
20 | - protected function buildMetaKey( $metaKey, $prefix ) |
|
20 | + protected function buildMetaKey($metaKey, $prefix) |
|
21 | 21 | { |
22 | - return ( substr( $metaKey, 0, 1 ) == '_' && !empty( $prefix )) |
|
23 | - ? sprintf( '_%s%s', rtrim( $prefix, '_' ), $metaKey ) |
|
22 | + return (substr($metaKey, 0, 1) == '_' && !empty($prefix)) |
|
23 | + ? sprintf('_%s%s', rtrim($prefix, '_'), $metaKey) |
|
24 | 24 | : $prefix . $metaKey; |
25 | 25 | } |
26 | 26 | } |
27 | 27 | |
28 | - protected function normalize( array $args ) |
|
28 | + protected function normalize(array $args) |
|
29 | 29 | { |
30 | 30 | $defaults = [ |
31 | 31 | 'ID' => get_the_ID(), |
32 | 32 | 'fallback' => '', |
33 | 33 | 'single' => true, |
34 | - 'prefix' => apply_filters( 'castor/postmeta/prefix', 'pollux_' ), |
|
34 | + 'prefix' => apply_filters('castor/postmeta/prefix', 'pollux_'), |
|
35 | 35 | ]; |
36 | - return shortcode_atts( $defaults, $args ); |
|
36 | + return shortcode_atts($defaults, $args); |
|
37 | 37 | } |
38 | 38 | } |
@@ -6,7 +6,9 @@ |
||
6 | 6 | { |
7 | 7 | public function get( $metaKey, array $args = [] ) |
8 | 8 | { |
9 | - if( empty( $metaKey ))return; |
|
9 | + if( empty( $metaKey )) { |
|
10 | + return; |
|
11 | + } |
|
10 | 12 | |
11 | 13 | $args = $this->normalize( $args ); |
12 | 14 | $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |