@@ -6,13 +6,13 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ArchiveMeta extends Facade |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Get the fully qualified class name of the component. |
|
| 11 | - * |
|
| 12 | - * @return string |
|
| 13 | - */ |
|
| 14 | - protected static function getFacadeAccessor() |
|
| 15 | - { |
|
| 16 | - return \GeminiLabs\Castor\Helpers\ArchiveMeta::class; |
|
| 17 | - } |
|
| 9 | + /** |
|
| 10 | + * Get the fully qualified class name of the component. |
|
| 11 | + * |
|
| 12 | + * @return string |
|
| 13 | + */ |
|
| 14 | + protected static function getFacadeAccessor() |
|
| 15 | + { |
|
| 16 | + return \GeminiLabs\Castor\Helpers\ArchiveMeta::class; |
|
| 17 | + } |
|
| 18 | 18 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public function __construct() |
| 21 | 21 | { |
| 22 | - $this->options = get_option( apply_filters( 'pollux/archives/id', 'pollux_archives' ), [] ); |
|
| 22 | + $this->options = get_option(apply_filters('pollux/archives/id', 'pollux_archives'), []); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -28,9 +28,9 @@ discard block |
||
| 28 | 28 | * @param string $group |
| 29 | 29 | * @return mixed |
| 30 | 30 | */ |
| 31 | - public function get( $key = '', $fallback = null, $group = '' ) |
|
| 31 | + public function get($key = '', $fallback = null, $group = '') |
|
| 32 | 32 | { |
| 33 | - return parent::get( $group, $key, $fallback ); |
|
| 33 | + return parent::get($group, $key, $fallback); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -17,36 +17,36 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | public function __construct() |
| 19 | 19 | { |
| 20 | - $this->options = get_option( apply_filters( 'pollux/settings/id', 'pollux_settings' ), [] ); |
|
| 20 | + $this->options = get_option(apply_filters('pollux/settings/id', 'pollux_settings'), []); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * @param string $group |
| 25 | 25 | * @return object|array|null |
| 26 | 26 | */ |
| 27 | - public function __call( $group, $args ) |
|
| 27 | + public function __call($group, $args) |
|
| 28 | 28 | { |
| 29 | - $args = array_pad( $args, 2, null ); |
|
| 29 | + $args = array_pad($args, 2, null); |
|
| 30 | 30 | $group = $this->$group; |
| 31 | - if( is_object( $group )) { |
|
| 31 | + if (is_object($group)) { |
|
| 32 | 32 | return $group; |
| 33 | 33 | } |
| 34 | - return $this->get( $group, $args[0], $args[1] ); |
|
| 34 | + return $this->get($group, $args[0], $args[1]); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @param string $group |
| 39 | 39 | * @return object|array|null |
| 40 | 40 | */ |
| 41 | - public function __get( $group ) |
|
| 41 | + public function __get($group) |
|
| 42 | 42 | { |
| 43 | - if( $group == 'all' ) { |
|
| 43 | + if ($group == 'all') { |
|
| 44 | 44 | return (object) $this->options; |
| 45 | 45 | } |
| 46 | - if( empty( $group )) { |
|
| 46 | + if (empty($group)) { |
|
| 47 | 47 | $group = $this->getDefaultGroup(); |
| 48 | 48 | } |
| 49 | - return isset( $this->options[$group] ) |
|
| 49 | + return isset($this->options[$group]) |
|
| 50 | 50 | ? $this->options[$group] |
| 51 | 51 | : null; |
| 52 | 52 | } |
@@ -57,21 +57,21 @@ discard block |
||
| 57 | 57 | * @param mixed $fallback |
| 58 | 58 | * @return mixed |
| 59 | 59 | */ |
| 60 | - public function get( $group = '', $key = '', $fallback = null ) |
|
| 60 | + public function get($group = '', $key = '', $fallback = null) |
|
| 61 | 61 | { |
| 62 | - if( func_num_args() < 1 ) { |
|
| 62 | + if (func_num_args() < 1) { |
|
| 63 | 63 | return $this->all; |
| 64 | 64 | } |
| 65 | - if( is_string( $group )) { |
|
| 65 | + if (is_string($group)) { |
|
| 66 | 66 | $group = $this->$group; |
| 67 | 67 | } |
| 68 | - if( !is_array( $group )) { |
|
| 68 | + if (!is_array($group)) { |
|
| 69 | 69 | return $fallback; |
| 70 | 70 | } |
| 71 | - if( is_null( $key )) { |
|
| 71 | + if (is_null($key)) { |
|
| 72 | 72 | return $group; |
| 73 | 73 | } |
| 74 | - return $this->getValue( $group, $key, $fallback ); |
|
| 74 | + return $this->getValue($group, $key, $fallback); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | * @param mixed $fallback |
| 88 | 88 | * @return mixed |
| 89 | 89 | */ |
| 90 | - protected function getValue( array $group, $key, $fallback ) |
|
| 90 | + protected function getValue(array $group, $key, $fallback) |
|
| 91 | 91 | { |
| 92 | - if( !array_key_exists( $key, $group )) { |
|
| 92 | + if (!array_key_exists($key, $group)) { |
|
| 93 | 93 | return $fallback; |
| 94 | 94 | } |
| 95 | - return empty( $group[$key] ) && !is_null( $fallback ) |
|
| 95 | + return empty($group[$key]) && !is_null($fallback) |
|
| 96 | 96 | ? $fallback |
| 97 | 97 | : $group[$key]; |
| 98 | 98 | } |
@@ -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'] ); |