Autogenerated_Series::trash_following( int|WP_Post $post_id )
Handles the trashing of any auto-generated Series related to an Event
Contents
Parameters
- $post_id
-
(int|WP_Post) (Required) The ID of the post being trashed or a reference to a post object.
Return
(int) The number of trashed Series.
Source
File: src/Events_Pro/Custom_Tables/V1/Series/Autogenerated_Series.php
public function trash_following( $post_id ) {
$post = $this->check_event_post( $post_id );
if ( false === $post ) {
return false;
}
$relationships = $this->get_event_relationships( $post );
$trashed = 0;
/** @var \TEC\Events_Pro\Custom_Tables\V1\Models\Relationship $relationship */
foreach ( $relationships as $relationship ) {
$series_id = $relationship->series_post_id;
if ( ! (
$this->check_autogenerated( $series_id )
&& $this->should_follow( $series_id, $post_id ) )
) {
continue;
}
$trashed_post = wp_trash_post( $series_id );
if ( ! $trashed_post instanceof WP_Post ) {
continue;
}
$trashed ++;
}
return $trashed;
}
Changelog
| Version | Description |
|---|---|
| 6.0.0 | Introduced. |