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

Commit

Permalink
Merge pull request #151 from Automattic/stop-submitting-drafts
Browse files Browse the repository at this point in the history
Stop publishing drafts
  • Loading branch information
diegoquinteiro committed Apr 14, 2016
2 parents 6dd0008 + b0d976a commit e06bd0a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
7 changes: 6 additions & 1 deletion class-instant-articles-publisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public static function submit_article( $post_id, $post ) {
return;
}

// Don't process if this post is not published
if ('publish' !== $post->post_status) {
return;
}

// Transform the post to an Instant Article.
$adapter = new Instant_Articles_Post( $post );
$article = $adapter->to_instant_article();
Expand Down Expand Up @@ -68,7 +73,7 @@ public static function submit_article( $post_id, $post ) {
$take_live = false;
} else {
// Any publish status other than 'publish' means draft for the Instant Article.
$take_live = 'publish' === $post->post_status;
$take_live = true;
}

try {
Expand Down
1 change: 1 addition & 0 deletions meta-box/class-instant-articles-meta-box.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public static function render_meta_box() {
$article = $adapter->to_instant_article();
$canonical_url = $adapter->get_canonical_url();
$submission_status = null;
$published = 'publish' === $post->post_status;

Instant_Articles_Settings::menu_items();
$settings_page_href = Instant_Articles_Settings::get_href_to_settings_page();
Expand Down
11 changes: 9 additions & 2 deletions meta-box/meta-box-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@
use Facebook\InstantArticles\Client\ServerMessage;
?>

<!-- Submission status -->
<?php if ( $submission_status ) : ?>
<?php if ( ! $published ) : ?>
<p>
<b>
<span class="dashicons dashicons-media-document"></span>
Your post will be submitted to Instant Articles once you publish it.
</b>
</p>

<?php elseif ( $submission_status ) : ?>

<!-- Display the last submission status -->
<?php switch ( $submission_status->getStatus() ) :
Expand Down

0 comments on commit e06bd0a

Please sign in to comment.