From f81998e639641fa82a71fe2a7dd30b7013fcfa54 Mon Sep 17 00:00:00 2001 From: Nathaniel Taintor Date: Thu, 22 Dec 2016 13:23:16 -0800 Subject: [PATCH] Set the status on the existing action hooks Rather than tracking down every place that might call Instant_Articles_Post::to_instant_article and wrapping it call to set the is_instant_article conditional, it's much simpler to just hook those settings on the existing actions `instant_articles_before_transform_post` and `instant_articles_after_transform_post`. --- class-instant-articles-publisher.php | 4 ---- facebook-instant-articles.php | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/class-instant-articles-publisher.php b/class-instant-articles-publisher.php index da81ab6a..03cae6ac 100644 --- a/class-instant-articles-publisher.php +++ b/class-instant-articles-publisher.php @@ -62,12 +62,8 @@ public static function submit_article( $post_id, $post ) { return; } - is_instant_article( true ); - $article = $adapter->to_instant_article(); - is_instant_article( false ); - // Skip empty articles or articles missing title. // This is important because the save_post action is also triggered by bulk updates, but in this case // WordPress does not load the content field from DB for performance reasons. In this case, articles diff --git a/facebook-instant-articles.php b/facebook-instant-articles.php index 09fcd3b2..5d09cc93 100644 --- a/facebook-instant-articles.php +++ b/facebook-instant-articles.php @@ -151,12 +151,10 @@ function instant_articles_init() { * @since 0.1 */ function instant_articles_feed() { - is_instant_article( true ); // Load the feed template. include( dirname( __FILE__ ) . '/feed-template.php' ); - is_instant_article( false ); } /** @@ -174,6 +172,8 @@ function is_instant_article( $set_status = null ) { return $is_instant_article; } + add_action( 'instant_articles_before_transform_post', function() { is_instant_article( true ); } ); + add_action( 'instant_articles_after_transform_post', function() { is_instant_article( false ); } ); /** * Modify the main query for our feed.