FWIW, to get this to work as intended, I went ahead with the wp_dropdown_categories function approach, settling for a js on-load hack to facilitate selection of currently excluded categories witin the dropdown.
/* Add Settings Field --"Exclude Categories"-- under options-reading.php page */
class Add_Settings_Field {
public function __construct() {
add_filter( 'admin_init' , array( &$this , 'register_fields' ) );
}
public function register_fields() {
register_setting( 'reading', 'exclude_cats');
add_settings_field('exclude_cats',
'<span title="Exclude Category Posts from Main Blog/Posts Page">Exclude Categories</label>',
array( &$this, 'fields_html' ),
'reading'
);
}
public function fields_html() {
# Requires additional hidden field and js hack to set the current values as selected in the resulting dropdown.
if($selected = get_option( 'exclude_cats')) $selected = implode(",",$selected);
$excluded_cats = "<input type="hidden" id='excluded_cats' value="$selected">"; // to facilitate js selection options onload.
$args = array(
'show_option_none' => ' -- Select -- ',
'hierarchical' => 1,
'depth' => 1,
'hide_empty' => 0,
'orderby' => 'name',
# 'selected'=> $selected, # accepts integer only, so won't work for multiple selections
'name' => 'exclude_cats',
'show_count' => 0,
'use_desc_for_title' => 1,
'echo'=> 0
);
$select_cats = wp_dropdown_categories($args);
$select_cats = str_replace( "name="exclude_cats" id=", "name="exclude_cats[]" multiple="multiple" id=", $select_cats );
echo $select_cats." ".$excluded_cats;
}
}
new Add_Settings_Field();
and for the JS
if(jQuery('#exclude_cats').length)
{ jQuery('#exclude_cats option[value="-1"]').val(''); //'show_options_none' returns value of -1, which just won't do...
var excluded = jQuery('#excluded_cats').val().split(',');
jQuery(excluded).each(function(){
jQuery('#exclude_cats option[value="'+this+'"]').prop('selected','selected');
});
}