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

Bulk Edit removes terms #105

Closed nate-allen closed 2 years ago

nate-allen commented 2 years ago

If you Bulk Edit custom post types, it deletes any terms that were saved for each post.

To reproduce:

  1. Select multiple posts in the post list screen
  2. In the Bulk Actions select box choose Edit
  3. Change something like the author or status
  4. Click Submit

It will remove whatever terms those posts had assigned.

This can be fixed by adding this:

// If posts are being bulk edited, we don't want to do anything.
if ( ! empty( $_GET['bulk_edit'] ) ) {
    return $post_id;
}

In the first line of the save_single_term function in the class-wordpress-radio-taxonomy.php file.

helgatheviking commented 2 years ago

Hi Nate! Thanks for reporting this. I can't quite reproduce this. I went to Products, bulk edit 3 products and changed their status. the terms for product_cat were not wiped out. Anything else you can tell me about how to reproduce? I am not sure we want to entire disable bulk edit saving... though I am just now realizing that the radio input isn't displaying for me on the bulk edit. Was it for you?

nate-allen commented 2 years ago

Hi @helgatheviking! I can get it to happen with products on a clean install with just WooCommerce and Radio Buttons for Taxonomies installed. I just made sure I enabled "Product Categories" under Settings > Radio Buttons for Taxonomies. I can see the radio buttons.

It happens when I go to the "Bulk Actions" at the top. Here's a screen capture.

Kapture 2022-06-16 at 13 19 16

You can see the product category is "Cool Stuff" at the start, but "Uncategorized" at the end.

nate-allen commented 2 years ago

@helgatheviking, have you had any luck reproducing this issue on your end? You mentioned "radio input isn't displaying" so I'm wondering if maybe you didn't have "Product Categories" enabled in the plugin Settings when you tested?

helgatheviking commented 2 years ago

been on vacation this week so not gotten to look at this yet

nate-allen commented 2 years ago

Okay, no worries! Enjoy your vacation. 🙂

helgatheviking commented 2 years ago

Hi Nate... I was able to reproduce this so I will try to give it some energy this week. I think going a step beyond what you've proposed... I should only save in the bulk edit mode if there's an actual value. If you don't enter a field, I see the terms being removed which I agree is not default bulk edit behavior.

helgatheviking commented 2 years ago

Hi @nate-allen could you test out https://github.com/helgatheviking/Radio-Buttons-for-Taxonomies/pull/107 ?

nate-allen commented 2 years ago

Hi @helgatheviking, I tested it out and it works!

Kapture 2022-06-28 at 10 37 04