Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving compatibility with WPML #2863

Open
nicolasviallet opened this issue Dec 24, 2024 · 0 comments
Open

Improving compatibility with WPML #2863

nicolasviallet opened this issue Dec 24, 2024 · 0 comments

Comments

@nicolasviallet
Copy link

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 );
					}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant