Advertisement
Beee

sd_before_delete_post()

Oct 27th, 2020
1,384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. public function sd_before_delete_post( $post_id ) {
  2.     // check if profile
  3.     if ( in_array( get_post_type( $post_id ), [ PostTypes::PROFILE, PostTypes::COMPANY ] ) ) {
  4.         $media = get_children( array(
  5.             'post_parent' => $post_id,
  6.             'post_type'   => 'any',
  7.             'numberposts' => -1,
  8.             'post_status' => 'any',
  9.         ) );
  10.         if ( ! empty( $media ) ) {
  11.             foreach ( $media as $file ) {
  12.                 wp_delete_attachment( $file->ID, true );
  13.             }
  14.         }
  15.         do_action( 'delete_sd8_transients', PostTypes::PROFILE );
  16.         do_action( 'delete_sd8_transients', PostTypes::COMPANY );
  17.     }
  18.     // @TODO: delete_row from sd8_icl_translations where element_id == $post_id
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement