Autogenerated_Series::untrash_following( int $post_id )

Untrashes a Series post if the Event being untrashed is the one that triggered the Series auto-generation.


Parameters

$post_id

(int) (Required) The Event post ID.


Top ↑

Return

(int) The number of untrashed Series.


Top ↑

Source

File: src/Events_Pro/Custom_Tables/V1/Series/Autogenerated_Series.php

	public function untrash_following( $post_id ) {
		$post = $this->check_event_post( $post_id );

		if ( ! $post instanceof WP_Post ) {
			return false;
		}

		$relationships = $this->get_event_relationships( $post );
		$untrashed     = 0;

		/** @var \TEC\Events_Pro\Custom_Tables\V1\Models\Relationship $relationship */
		foreach ( $relationships as $relationship ) {
			$series_id = $relationship->series_post_id;

			if ( ! $this->should_follow( $series_id, $post_id ) ) {
				continue;
			}

			$untrashed_post = wp_untrash_post( $series_id );

			if ( ! $untrashed_post instanceof WP_Post ) {
				continue;
			}

			$untrashed ++;
		}

		return $untrashed;
	}

Top ↑

Changelog

Changelog
Version Description
6.0.0 Introduced.