Navigation Menu

Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Add is_transforming_instant_article() conditional #568

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions class-instant-articles-post.php
Expand Up @@ -595,6 +595,8 @@ public function to_instant_article() {
*/
do_action( 'instant_articles_before_transform_post', $this );

is_transforming_instant_article( true );

// Get time zone configured in WordPress. Default to UTC if no time zone configured.
$date_time_zone = get_option( 'timezone_string' ) ? new DateTimeZone( get_option( 'timezone_string' ) ) : new DateTimeZone( 'UTC' );

Expand Down Expand Up @@ -690,6 +692,8 @@ public function to_instant_article() {

$this->instant_article = apply_filters( 'instant_articles_transformed_element', $this->instant_article );

is_transforming_instant_article( false );

/**
* Fires after the instant article is rendered.
*
Expand Down
15 changes: 15 additions & 0 deletions facebook-instant-articles.php
Expand Up @@ -157,6 +157,21 @@ function instant_articles_feed() {

}

/**
* Whether currently processing an instant article.
*
* @param bool Set the status
* @return bool
*/
function is_transforming_instant_article( $set_status = null ) {
static $is_instant_article = false;

if ( isset( $set_status ) ) {
$is_instant_article = (bool) $set_status;
}

return $is_instant_article;
}

/**
* Modify the main query for our feed.
Expand Down