LLMS_Post_Relationships::maybe_update_relationships( int $post_id )
Check relationships and delete / update related posts when a post is deleted.
Description Description
Called on delete_post hook (before a post is deleted).
Parameters Parameters
- $post_id
-
(int) (Required) WP Post ID of the deleted post.
Return Return
(void)
Source Source
File: includes/class.llms.post.relationships.php
public function maybe_update_relationships( $post_id ) {
$post = get_post( $post_id );
if ( ! in_array( $post->post_type, $this->get_post_types(), true ) ) {
return;
}
foreach ( $this->get_relationships() as $post_type => $relationships ) {
if ( $post->post_type !== $post_type ) {
continue;
}
foreach ( $relationships as $data ) {
if ( in_array( $data['action'], array( 'delete', 'trash' ), true ) ) {
$this->delete_relationships( $post, $data );
} elseif ( 'unset' === $data['action'] ) {
$this->unset_relationships( $post, $data );
}
}
}
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.24.0 | Unknown. |
| 3.16.12 | Introduced. |