Skip to content

Commit

Permalink
Display error message if meta box can't be loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
timjacobi committed Oct 31, 2017
1 parent b6dd8b1 commit 37cde50
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
45 changes: 25 additions & 20 deletions meta-box/class-instant-articles-meta-box.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,31 @@ public static function render_meta_box() {
$ajax_nonce = wp_create_nonce( "instant-articles-force-submit-" . $post_id );
$post = get_post( $post_id );
$adapter = new Instant_Articles_Post( $post );
$article = $adapter->to_instant_article();
$canonical_url = $adapter->get_canonical_url();
$published = ( 'publish' === $post->post_status );
$dev_mode = false;
$force_submit = get_post_meta( $post_id, IA_PLUGIN_FORCE_SUBMIT_KEY, true );
$instant_articles_should_submit_post_filter = apply_filters( 'instant_articles_should_submit_post', true, $adapter );

Instant_Articles_Wizard::menu_items();
$settings_page_href = Instant_Articles_Wizard::get_url();

$publishing_settings = Instant_Articles_Option_Publishing::get_option_decoded();
$publish_with_warnings = isset( $publishing_settings[ 'publish_with_warnings' ] ) ? $publishing_settings[ 'publish_with_warnings' ] : false;
$fb_page_settings = Instant_Articles_Option_FB_Page::get_option_decoded();
$publishing_settings = Instant_Articles_Option_Publishing::get_option_decoded();

$dev_mode = isset( $publishing_settings['dev_mode'] )
? ( $publishing_settings['dev_mode'] ? true : false )
: false;

include( dirname( __FILE__ ) . '/meta-box-template.php' );

try {
$article = $adapter->to_instant_article();
$canonical_url = $adapter->get_canonical_url();
$published = ( 'publish' === $post->post_status );
$dev_mode = false;
$force_submit = get_post_meta( $post_id, IA_PLUGIN_FORCE_SUBMIT_KEY, true );
$instant_articles_should_submit_post_filter = apply_filters( 'instant_articles_should_submit_post', true, $adapter );

Instant_Articles_Wizard::menu_items();
$settings_page_href = Instant_Articles_Wizard::get_url();

$publishing_settings = Instant_Articles_Option_Publishing::get_option_decoded();
$publish_with_warnings = isset( $publishing_settings[ 'publish_with_warnings' ] ) ? $publishing_settings[ 'publish_with_warnings' ] : false;
$fb_page_settings = Instant_Articles_Option_FB_Page::get_option_decoded();
$publishing_settings = Instant_Articles_Option_Publishing::get_option_decoded();

$dev_mode = isset( $publishing_settings['dev_mode'] )
? ( $publishing_settings['dev_mode'] ? true : false )
: false;

include( dirname( __FILE__ ) . '/meta-box-template.php' );
} catch (Exception $e) {
include( dirname( __FILE__ ) . '/meta-box-error.php' );
}

die();
}
Expand Down
10 changes: 10 additions & 0 deletions meta-box/meta-box-error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
/**
* Facebook Instant Articles for WP.
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*
* @package default
*/
?>
<p>An unkown error occurred while transforming the article. Please verify your rules confgiuration is correct.</p>

0 comments on commit 37cde50

Please sign in to comment.