Skip to content

Commit

Permalink
Resolve error with Yoast SEO when deleting an aircraft
Browse files Browse the repository at this point in the history
  • Loading branch information
clubdeuce committed Jun 16, 2022
1 parent 320e95e commit 20e5047
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions includes/hooks/actions/trash-post.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

add_action( 'wp_trash_post', 'wpfnps_trash_post', 9999999 );

function wpfnps_trash_post( $post_id ) {

if ( in_array( get_post_type( $post_id ), wpfnps_post_types() ) ) {
$shared_with = wpfnps_get_shares( $post_id );

if ( is_array( $shared_with ) ) {
foreach ( $shared_with as $site_id ) {
$remote_id = get_post_meta( $post_id, "_remote_share_id_{$site_id}", 'single' );

if ( $remote_id ) {
remove_action( 'wp_trash_post', 'wpfnps_trash_post' );
switch_to_blog( $site_id );
wp_delete_post( $remote_id, "force delete" );
restore_current_blog();
add_action( 'wp_trash_post', 'wpfnps_trash_post' );
}
}
}
}

}

0 comments on commit 20e5047

Please sign in to comment.