If you want to alter display based on admin options, you don’t need to deal at all with the shortcode_atts
ar the $attributes
that are passed into your callback. The attributes passed in (and set by shortcode_atts
) are meant to alter the way a shortcode works based on how an end-user uses it.
Take this: [wpse75238 arg1="asdf" arg2="asdf"]
<?php
add_shortcode('wpse75238', 'wpse75238_shortcode_cb');
function wpse75238_shortcode_cb($atts)
{
return var_export($atts);
}
Something like array ( 'arg1' => 'asdf', 'arg2' => 'asdf' )
will come out.
shortcode_atts
just sets defaults for you (and removes “unauthorized” keys) in a similar way to wp_parse_args
.
If you just want to change stuff based on an admin page option, you don’t need to respect the user input.
<?php
add_shortcode('wpse75238', 'wpse75238_shortcode_cb');
function wpse75238_shortcode_cb()
{
if('some_value' = get_option('wpse75238_opts'))
{
// do stuff because some_value was set.
}
}
Calling the shortcode with arguments will not change a thing for the above shortcode.