| Conditions | 5 |
| Paths | 4 |
| Total Lines | 21 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | public function get( $value, array $args = [] ) |
||
| 8 | { |
||
| 9 | $defaults = [ |
||
| 10 | 'ID' => get_the_ID(), |
||
| 11 | 'fallback' => '', |
||
| 12 | 'single' => true, |
||
| 13 | 'prefix' => 'pollux_', |
||
| 14 | ]; |
||
| 15 | |||
| 16 | $args = shortcode_atts( $defaults, $args ); |
||
| 17 | |||
| 18 | if( !empty( $value ) && $value[0] == '_' && !empty( $args['prefix'] )) { |
||
| 19 | $args['prefix'] = sprintf( '_%s', rtrim( $args['prefix'], '_' )); |
||
| 20 | } |
||
| 21 | |||
| 22 | $metaValue = get_post_meta( $args['ID'], $args['prefix'] . $value, $args['single'] ); |
||
| 23 | |||
| 24 | return empty( $metaValue ) |
||
| 25 | ? $args['fallback'] |
||
| 26 | : $metaValue; |
||
| 27 | } |
||
| 28 | } |
||
| 29 |