Tribe__Events__Aggregator__Record__Abstract::load( WP_Post|int $post = null )
Loads the WP_Post associated with this record.
Contents
Parameters
- $post
-
(WP_Post|int) (Optional) The post object or post ID to load.
Default value: null
Source
File: src/Tribe/Aggregator/Record/Abstract.php
public function load( $post = null ) {
if ( is_numeric( $post ) ) {
$post = get_post( $post );
}
if ( ! $post instanceof WP_Post ) {
return tribe_error( 'core:aggregator:invalid-record-object', array(), array( $post ) );
}
if ( $post->post_type !== Tribe__Events__Aggregator__Records::$post_type ) {
return tribe_error( 'core:aggregator:invalid-record-post_type', array(), array( $post ) );
}
$this->id = $post->ID;
// Get WP_Post object
$this->post = $post;
// Map `ping_status` as the `type`
$this->type = $this->post->ping_status;
if ( 'schedule' === $this->type ) {
// Fetches the Frequency Object
$this->frequency = Tribe__Events__Aggregator__Cron::instance()->get_frequency( array( 'id' => $this->post->post_content ) );
// Boolean Flag for Scheduled records
$this->is_schedule = true;
} else {
// Everything that is not a Scheduled Record is set as Manual
$this->is_manual = true;
}
$this->setup_meta( get_post_meta( $this->id ) );
return $this;
}