Submits article to Instant Articles.
public static submit_article ( string $post_id, Post $post ) | ||
$post_id | string | The identifier of post. |
$post | Post | The WP Post. |
/** * Renderer for the Metabox. */ public static function force_submit() { check_ajax_referer('instant-articles-force-submit', 'security'); $post_id = intval($_POST['post_ID']); $force = sanitize_text_field($_POST['force']) === 'true'; update_post_meta($post_id, Instant_Articles_Publisher::FORCE_SUBMIT_KEY, $force); Instant_Articles_Publisher::submit_article($post_id, get_post($post_id)); }
/** * Submits the select page for review */ public static function submit_for_review() { if (!current_user_can('manage_options')) { wp_die(esc_html('You do not have sufficient permissions to access this page.')); } $current_state = Instant_Articles_Wizard_State::get_current_state(); if ($current_state !== Instant_Articles_Wizard_State::STATE_REVIEW_SUBMISSION) { die; } $fb_app_settings = Instant_Articles_Option_FB_App::get_option_decoded(); $fb_page_settings = Instant_Articles_Option_FB_Page::get_option_decoded(); $client = Client::create($fb_app_settings['app_id'], $fb_app_settings['app_secret'], $fb_page_settings['page_access_token'], $fb_page_settings['page_id']); try { // Bulk upload articles for review $articles_for_review = Instant_Articles_Wizard_Review_Submission::getArticlesForReview(); foreach ($articles_for_review as $post) { Instant_Articles_Publisher::submit_article($post->ID, $post); } // Trigger review submission $client->submitForReview(); } catch (Exception $e) { // If something went wrong, simply render the error + the same state. echo '<div class="error settings-error notice is-dismissible"><p><strong>' . esc_html($e->getMessage()) . '</strong></p></div>'; } self::render(true); die; }