@@ -14,18 +14,18 @@ discard block |
||
14 | 14 | * @param string $metaKey |
15 | 15 | * @return mixed |
16 | 16 | */ |
17 | - public function get( $metaKey, array $args = [] ) |
|
17 | + public function get($metaKey, array $args = []) |
|
18 | 18 | { |
19 | - if( empty( $metaKey ))return; |
|
19 | + if (empty($metaKey))return; |
|
20 | 20 | |
21 | - $args = $this->normalize( $args ); |
|
22 | - $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |
|
23 | - $metaValue = get_post_meta( $args['id'], $metaKey, $args['single'] ); |
|
21 | + $args = $this->normalize($args); |
|
22 | + $metaKey = $this->buildMetaKey($metaKey, $args['prefix']); |
|
23 | + $metaValue = get_post_meta($args['id'], $metaKey, $args['single']); |
|
24 | 24 | |
25 | - if( is_string( $metaValue )) { |
|
26 | - $metaValue = trim( $metaValue ); |
|
25 | + if (is_string($metaValue)) { |
|
26 | + $metaValue = trim($metaValue); |
|
27 | 27 | } |
28 | - return empty( $metaValue ) |
|
28 | + return empty($metaValue) |
|
29 | 29 | ? $args['fallback'] |
30 | 30 | : $metaValue; |
31 | 31 | } |
@@ -35,24 +35,24 @@ discard block |
||
35 | 35 | * @param string $prefix |
36 | 36 | * @return string |
37 | 37 | */ |
38 | - protected function buildMetaKey( $metaKey, $prefix ) |
|
38 | + protected function buildMetaKey($metaKey, $prefix) |
|
39 | 39 | { |
40 | - return ( substr( $metaKey, 0, 1 ) == '_' && !empty( $prefix )) |
|
41 | - ? sprintf( '_%s%s', rtrim( $prefix, '_' ), $metaKey ) |
|
40 | + return (substr($metaKey, 0, 1) == '_' && !empty($prefix)) |
|
41 | + ? sprintf('_%s%s', rtrim($prefix, '_'), $metaKey) |
|
42 | 42 | : $prefix . $metaKey; |
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * @return array |
47 | 47 | */ |
48 | - protected function normalize( array $args ) |
|
48 | + protected function normalize(array $args) |
|
49 | 49 | { |
50 | 50 | $defaults = [ |
51 | 51 | 'id' => get_the_ID(), |
52 | 52 | 'fallback' => '', |
53 | 53 | 'single' => true, |
54 | - 'prefix' => apply_filters( 'pollux/prefix', 'pollux_' ), |
|
54 | + 'prefix' => apply_filters('pollux/prefix', 'pollux_'), |
|
55 | 55 | ]; |
56 | - return shortcode_atts( $defaults, array_change_key_case( $args )); |
|
56 | + return shortcode_atts($defaults, array_change_key_case($args)); |
|
57 | 57 | } |
58 | 58 | } |
@@ -16,7 +16,9 @@ |
||
16 | 16 | */ |
17 | 17 | public function get( $metaKey, array $args = [] ) |
18 | 18 | { |
19 | - if( empty( $metaKey ))return; |
|
19 | + if( empty( $metaKey )) { |
|
20 | + return; |
|
21 | + } |
|
20 | 22 | |
21 | 23 | $args = $this->normalize( $args ); |
22 | 24 | $metaKey = $this->buildMetaKey( $metaKey, $args['prefix'] ); |
@@ -1,27 +1,27 @@ |
||
1 | -<?php defined( 'WPINC' ) || die; |
|
1 | +<?php defined('WPINC') || die; |
|
2 | 2 | |
3 | 3 | global $wp_version; |
4 | 4 | |
5 | -if( version_compare( '5.6', phpversion(), '>' )) { |
|
5 | +if (version_compare('5.6', phpversion(), '>')) { |
|
6 | 6 | wp_die( |
7 | - __( 'You must be using PHP 5.6.0 or greater.', 'castor' ), |
|
8 | - __( 'Unsupported PHP version', 'castor' ) |
|
7 | + __('You must be using PHP 5.6.0 or greater.', 'castor'), |
|
8 | + __('Unsupported PHP version', 'castor') |
|
9 | 9 | ); |
10 | 10 | } |
11 | 11 | |
12 | -if( version_compare( '4.7', $wp_version, '>' )) { |
|
12 | +if (version_compare('4.7', $wp_version, '>')) { |
|
13 | 13 | wp_die( |
14 | - __( 'You must be using WordPress 4.7.0 or greater.', 'castor' ), |
|
15 | - __( 'Unsupported WordPress version', 'castor' ) |
|
14 | + __('You must be using WordPress 4.7.0 or greater.', 'castor'), |
|
15 | + __('Unsupported WordPress version', 'castor') |
|
16 | 16 | ); |
17 | 17 | } |
18 | 18 | |
19 | -if( is_customize_preview() && filter_input( INPUT_GET, 'theme' )) { |
|
19 | +if (is_customize_preview() && filter_input(INPUT_GET, 'theme')) { |
|
20 | 20 | wp_die( |
21 | - __( 'Theme must be activated prior to using the customizer.', 'castor' ) |
|
21 | + __('Theme must be activated prior to using the customizer.', 'castor') |
|
22 | 22 | ); |
23 | 23 | } |
24 | 24 | |
25 | -require_once( ABSPATH . '/' . WPINC . '/class-oembed.php' ); |
|
25 | +require_once(ABSPATH . '/' . WPINC . '/class-oembed.php'); |
|
26 | 26 | |
27 | 27 | \GeminiLabs\Castor\Application::getInstance()->init(); |