Automattic / WP-Job-Manager

Manage job listings from the WordPress admin panel, and allow users to post jobs directly to your site.
https://wpjobmanager.com
GNU General Public License v3.0
901 stars 368 forks source link

Bulk editing Job Type does not update Types column on All Listings page #1896

Closed richardmtl closed 1 year ago

richardmtl commented 5 years ago

Reported here: https://wordpress.org/support/topic/bulk-change-job-type-issue/

To reproduce:

1 – Open Jobs Listing Admin 2 – Select 2 or more job posts 3 – From Bulk Actions, choose Edit and Apply 4 – Tick a job type from Job Types 5 – Click Update

Expected result:

The Types column will reflect the new selected Type.

Actual result:

The Types column does not show the new Type. You need to go into each listing and Save them again for the new Type to show on the All Jobs page.

Dubaidogfish commented 5 years ago

I have inconsistent issues when publishing imported jobs from draft in bulk in that many will expire themselves within a few hours despite future expiry dates being shown. I don't get this issue if I do them one at a time. It might be related.

JuanchoPestana commented 4 years ago

Hey @richardmtl ! Here's a possible solution for this issue... Could you please let me know your thoughts on this approach? (I just focused on the functionality part, so i18n and graphics are still not covered, and even some nonce validations are missing; I just wanted to make sure this works before I finish all the details...)

While working on this, I found out that the issue was not that the 'Bulk edit' wasn't updating the 'job type'. The issue was that the 'Bulk edit' action was ADDING the 'term' or 'job type' to the listing (in the wp_term_relationships table, you would end with multiple terms per listing); so, after "Bulk editing" you would end with multiple job types for the same job listing. What the issue description said about "You need to go into each listing and Save them again for the new Type to show on the All Jobs page." was an illusion... I realized this after a lot of playing around. When you went inside each listing, the option that was pre-selected in the radio buttons was simply the last of the multiple job types that this post already had. (This was tricky!)

The way to see this issue is to set the parameter "show_admin_column" to true, in the register_taxonomy function calling. (When we register the job type taxonomy). If you do this, the job type will appear in the table and you can easily see how the job types are added, instead of updated.

What I did in this solution is to prevent the "default" bulk edit functionality for the taxonomy and create a new one. (Btw, the default one, or the current bulk edit functionality, used a checklist input for the job types. In this solution I use a radio input, since, if I'm not mistaken, you should only be able to select ONE job type per listing, not multiple ones)

I got the idea from this tutorial, so there's some copy paste from here: https://github.com/bamadesigner/manage-wordpress-posts-using-bulk-edit-and-quick-edit

If this approach is not a good idea, let me know and I'll gladly try to work on a different one! Thanks!

JuanchoPestana commented 4 years ago

Hey Richard! I just realized that there's a setting for allowing job listings to have multiple job types; which means that we should only apply the solution I propose (in case it's a good one) to the case where multiple job types per listing is not enabled. That being said; the issue I mentioned in the comment above still occurs when having the multiple types enabled per listing (bulk editing is adding terms instead of replacing them with the newly selected ones)... I'll work on a solution that encompasses both cases (single job type per listing and multiple job types per listing); but basically my question is the same as before: What are your thoughts on this approach of creating a custom functionality for the bulk editing?

Also, if I'm not following the correct protocol for contributing here, by commenting multiple times on the same thread or by creating a PR before knowing if it's the right approach, or even if I'm not suppose to ask for guidance in the approach to solve an issue, please let me know so that I can learn how to contribute in a bit more elegant or professional way!

JuanchoPestana commented 4 years ago

Hey Richard! I made some changes... This PR should now fix the bulk editing issue for single job types and for multiple job types...

Hey @jom! While working on this issue, I found out that bulk editing has the same problem when dealing with categories (both single and multiple). I was thinking of opening a new issue and fixing it, but I wanted to first make sure that this approach is approved or in case it's not, get your feedback so that I can help you with another solution... In case this one works, let me know please and I'll fix the categories issue ASAP! Thanks a lot!

mikeyarce commented 1 year ago

Tested this out today and it no longer seems to be an issue. Closing this out now! :)