Automattic / Automattic/WP-Job-Manager

Improving compatibility with WPML

Open
#2,863 3 comments 0 reactions 0 assignees View on GitHub
Enhancement
Dominant language
PHP
Stars
899
Forks
369
Avg merge
11h 37m
Merged PRs (30d)
12

Description

### Is your feature request related to a problem? Please describe
When deleting a Job post or Resume post from the frontend (Job Dashboard), their translations are not automatically deleted. This occurs because WPML restricts the `delete_post` action to REST requests.

### Describe the solution you'd like
**For jobs**
- Open /wp-content/plugins/wp-job-manager/includes/class-job-dashboard-shortcode.php
- Look for line 466
- Replace:
```
case 'delete':
// Trash it.
wp_trash_post( $job_id );
```
- With:
```
case 'delete':
// Trash it.
// WPML workaround for compsupp-7729
if ( class_exists('Sitepress') ) {
$trid = apply_filters( 'wpml_element_trid', NULL, $job_id , 'post_job_listing' );
$translations = apply_filters( 'wpml_get_element_translations', NULL, $trid, 'job_listing' );
if ( !empty( $translations ) ) {
foreach ( $translations as $lang => $translation ) {
$translation_id = absint( $translation->element_id );
wp_trash_post( $translation_id );
}
}
} else {
wp_trash_post( $job_id );
}
```
**Same thing for Resumes**
- Open /wp-content/plugins/wp-job-manager-resumes/includes/class-wp-resume-manager-shortcodes.php
- Look for line 125
- Replace:
```
case 'delete':
// Trash it.
wp_trash_post( $resume_id );
```
- With:
```
case 'delete':
// Trash it.
// WPML workaround for compsupp-7757
if ( class_exists('Sitepress') ) {
$trid = apply_filters( 'wpml_element_trid', NULL, $resume_id , 'post_resume' );
$translations = apply_filters( 'wpml_get_element_translations', NULL, $trid, 'resume' );
if ( !empty( $translations ) ) {
foreach ( $translations as $lang => $translation ) {
$translation_id = absint( $translation->element_id );
wp_trash_post( $translation_id );
}
}
} else {
wp_trash_post( $resume_id );
}
```

Contributor guide

Open the contributing guide

Research direction

Start at the delete cases in includes/class-job-dashboard-shortcode.php around line 466 and wp-job-manager-resumes/includes/class-wp-resume-manager-shortcodes.php around line 125. Review the existing frontend deletion flow and WPML hooks shown in the issue; done means deleting a job or resume also trashes its translations when WPML is present, while preserving deletion without it.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.