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

[dev] All terms get saved instead of just selected terms #53

Closed leymannx closed 5 years ago

leymannx commented 5 years ago

I checked out the dev branch for WP5 compatibility and radios appear nicely for the chosen taxonomies.

Unfortunately the term saving doesn't seem to work properly. After I selected a term, saved the post and watched it in the frontend, all terms appear.

I'd expect only the chosen term to be applied.

That's what I selected

Screenshot 2019-04-10 10 56 20

That's what has been saved

Screenshot 2019-04-10 10 56 35

helgatheviking commented 5 years ago

Great, I was going to open this based on your WP.org reply. And just noticed it myself. I think I have to dig into the API as everything in Gutenberg is saved via the API.

helgatheviking commented 5 years ago

Either need to find a way to modify the results of WP_REST_Posts_Controller ~or perhaps extend the class and replace the controller for all radio taxonomies via the register_taxonomy_args filter.~

helgatheviking commented 5 years ago

I actually think this may be more oriented towards the JS side of things. Specifically, may need to mimic how the Radio controls set state. https://github.com/WordPress/gutenberg/tree/master/packages/components/src/radio-control

helgatheviking commented 5 years ago

@leymannx Hi Norman. I just pushed a few changes. I think it solves the saving issue. I'd appreciate it if you could take a look when you have a chance.

leymannx commented 5 years ago

It works super smooth now. Select and updates precisely. Well done!

Only one minor thing with the styles of the focused radio that underlaps the meta box wrapper. It's not bad thing, but it may look broken to the enduser. I'll drop a new issue for that.

helgatheviking commented 5 years ago

I've seen the style thing too. Not sure what to do about it.

Glad it's working! Gotta give credit to @5ally and her work at https://github.com/5ally/my-term-selector/ she's been amazingly helpful on this.

I am a little nervous about just how many changes were made to the term selector script. I fear it coud be hard to maintain, but we'll cross that bridge when we get to it.

I'll give a quick thought to the style issue and try to get this packaged up for release!

leymannx commented 5 years ago

I'm a little bit concerned regarding backwards compatibility. But you didn't remove any of the old code? So the plugin should still work on older WordPress versions you think?

helgatheviking commented 5 years ago

For back compat, the old scripts should still load when not using Gutenberg.... So anywhere tractional metaboxs are leading. But I only tested quickly with product post type.

On Wed, Apr 24, 2019, 7:57 PM Norman Kämper-Leymann < notifications@github.com> wrote:

I'm a little bit concerned regarding backwards compatibility. But you didn't remove any of the old code? So the plugin should still work on older WordPress versions you think?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/helgatheviking/Radio-Buttons-for-Taxonomies/issues/53#issuecomment-486175054, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD3ZEJTH62X2VYG6CT2CILPSA4LHANCNFSM4HEZ37CQ .