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

Duplicate job offer feature - issue with Polylang #2291

Open Lens40 opened 2 years ago

Lens40 commented 2 years ago

I run WP Job Manager with Polylang. To display all jobs in all language I duplicate the job offers and sync them with a custom function. This allows the users to modify their job offers in any language and making sure those changes are synced to the other languages as well.

When a job is synced with its translations some taxonomies are create by Polylang to link them together. The duplication of theses taxonomies to the new job offer also creates the issue/conflict with WP Job Manager duplication feature.

When duplicating a job offer WP Job Manager copies all available taxonomies, including the Polylang ones which will link the new job offer to the translations of the old job offer which just was duplicated. This is something that should not happen creating some issues with the translations and linking.

The file where the function is embedded is wp-job-manager-functions.php Line 1527-1535.

$taxonomies = get_object_taxonomies( $post->post_type ); foreach ( $taxonomies as $taxonomy ) { $post_terms = wp_get_object_terms( $post_id, $taxonomy, [ 'fields' => 'slugs' ] ); wp_set_object_terms( $new_post_id, $post_terms, $taxonomy, false ); }

Is there an option to add a filter hook before foreach to remove certain taxonomies? Or limit the copying to only a certain type of taxonomies which are related to WP Job Manager only?

Thanks for your input. Best regards Lens

Lens40 commented 2 years ago

Polylang is proposing the following adjustment:

`/**

Allowing them to filter their translation taxonomies by adding a filter into their plugin:

add_filter( 'wpjm_filter_taxonomy_to_duplicate', 'filter_taxo' ); function filter_taxo( $taxonomies ){ $taxonomy_to_remove = array( 'post_translations' ); return array_diff( $taxonomies, $taxonomy_to_remove); }

Is this something you would consider for the next release?

Gnodesign commented 2 years ago

@dadish @fjorgemota @onubrooks Could we please add a filter to the $taxonomy and include it in 1.37.1? It will allow users to expand the Polylang/WPML (and other multilingual plugins) compatibility from their side as @Lens40 mentioned above.

https://github.com/Automattic/WP-Job-Manager/blob/28f871e3bac1bede01af6186bc4525fe38220c63/wp-job-manager-functions.php#L1530

Lens40 commented 2 years ago

Thanks Gino for supporting that :)