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

Not update on multisite Wordpress #43

Open dpotuznik opened 6 years ago

dpotuznik commented 6 years ago

Hi, thank's for your plugin is really nice, but i need to change wordpress to a multisite installation,

and now the site1 work, but all the other doesn't save the modification. if i deactivate your plugin i can update with the plugin activated don't.

thank for your help. In the meantime a wish you a beautiful day. Best Regards Daniel

helgatheviking commented 6 years ago

Hi Daniel. Thanks for the report. Unfortunately, I don't have any availability at the moment to look in to this right now. If you want to make an attempt, I am open to a pull request.

kellenmace commented 4 years ago

@dpotuznik (and anyone else who comes across this issue) –

If you have a WP multisite and want to display some taxonomies as radio buttons, but don't want to go through every site in the network and manually configure the settings on their options pages, you can do something like this:

function use_radio_buttons_for_taxonomies( string $taxonomy ) : void {
    if ( ! class_exists( 'WordPress_Radio_Taxonomy' ) ) {
        return;
    }

    // Add the taxonomies you would like displayed as radio buttons here.
    $taxonomies_to_convert = [ 'project_status', 'employee_status' ];

    $should_convert_this_taxonomy = in_array( $taxonomy, $taxonomies_to_convert, true );

    if ( ! $should_convert_this_taxonomy ) {
        return;
    }

    $rbft_instance = radio_buttons_for_taxonomies();
    $rbft_instance->taxonomies[ $taxonomy ] = new WordPress_Radio_Taxonomy( $taxonomy );
}
add_action( 'registered_taxonomy', 'use_radio_buttons_for_taxonomies' );

With that code in place, you don't have to set anything on any of your sites' options pages. Radio buttons will be displayed for the taxonomies you specify in the $taxonomies_to_convert array across the whole network.