1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
<?php
function papi_delete_option( $slug ) {
return papi_delete_field( 0, $slug, 'option' );
}
function papi_get_option( $slug, $default = null ) {
return papi_get_field( 0, $slug, $default, 'option' );
}
function papi_option_shortcode( $atts ) {
$default = isset( $atts['default'] ) ? $atts['default'] : '';
if ( empty( $atts['slug'] ) ) {
$value = $default;
} else {
$value = papi_get_option( $atts['slug'], $default );
}
if ( is_array( $value ) ) {
$value = implode( ', ', $value );
}
return $value;
}
add_shortcode( 'papi_option', 'papi_option_shortcode' );
function papi_update_option( $slug, $value = null ) {
return papi_update_field( 0, $slug, $value, 'option' );
}
function the_papi_option( $slug = null, $default = null ) {
$value = papi_get_option( $slug, $default );
if ( is_array( $value ) ) {
$value = implode( ', ', $value );
}
if ( is_object( $value ) ) {
$value = print_r( $value, true );
}
echo $value;
}