helgatheviking / Radio-Buttons-for-Taxonomies

Turn any WordPress taxonomy into a list of radio buttons, which forces users to select only 1 term!
53 stars 28 forks source link

Private Taxonomies #34

Closed HowdyMcGee closed 9 years ago

HowdyMcGee commented 9 years ago

On the "Taxonomies to Convert" page, can you also add "private" taxonomies? I currently have a taxonomy that I use for mostly display purposes on the front end but the user should still be restricted to only check 1 of the terms.

helgatheviking commented 9 years ago

I only wanted to get public taxonomies. However, there is a filter

$taxonomies = apply_filters( 'radio_buttons_for_taxonomies_taxonomies', array_merge( $defaults, $custom ) );

So you can add new taxonomy objects to the array. Totally untested:

function kia_add_private_taxonomies($taxonomies){

     $args = array (
            'public'   => false,
        );

    $private_taxonomies = get_taxonomies( $args, 'objects' );
    return array_merge( $taxonomies, $private_taxonomies );
}
add_filter( 'radio_buttons_for_taxonomies_taxonomies', 'kia_add_private_taxonomies' );

I would also not be opposed to adding a filter for the $args for the original get_taxonomies().

helgatheviking commented 9 years ago

closed by 9894f08c68d69d4e3e3fcfc9003079a159d039bb