for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace GeminiLabs\Castor\Helpers;
class PostMeta
{
public function get( $value, array $args = [] )
if( empty( $value ))return;
$args = $this->normalize( $args );
if( substr( $value, 0, 1 ) == '_' && !empty( $args['prefix'] )) {
$args['prefix'] = sprintf( '_%s', rtrim( $args['prefix'], '_' ));
}
$metaValue = get_post_meta( $args['ID'], $args['prefix'] . $value, $args['single'] );
return empty( $metaValue )
? $args['fallback']
: $metaValue;
protected function normalize( array $args )
$defaults = [
'ID' => get_the_ID(),
'fallback' => '',
'single' => true,
'prefix' => 'pollux_',
];
return shortcode_atts( $defaults, $args );