So I want to have defaults set up for each of my plugins settings, and I’m using wp_parse_args to do so which I believe is the correct way, but I’m hitting a roadblock.
Here’s my code at the moment:
function eddslider_options_each( $edd_slider_options ) {
$edd_slider_options = get_option( 'eddslider_options' );
/**
* Define the array of defaults
*/
$defaults = array(
'slider_insert' => 0,
'slider_arrows' => 0,
'slider_bullets' => 0,
'slider_effect' => 'fade',
'slider_theme' => 'default'
);
/**
* Parse incomming $args into an array and merge it with $defaults
*/
$edd_slider_options = wp_parse_args( $edd_slider_options, $defaults );
/**
* OPTIONAL: Declare each item in $args as its own variable i.e. $type, $before.
*/
extract( $edd_slider_options, EXTR_SKIP );
}
Now if I add something like:
$output = $slider_insert;
return $output;
I’m able to use <?php echo eddslider_options_each('slider_insert'); ?>
and it will have the defined default set and work well. How do I do this for every option though? Thank you.
Try: