Since: 0.9.0
Inheritance: extends Apple_News
 public function testSaveWithAutoSync()
 {
     // Set API settings to not auto sync and to enable the meta box
     $this->settings->set('api_autosync', 'yes');
     $this->settings->set('show_metabox', 'yes');
     // Create post
     $post_id = $this->factory->post->create();
     // Create post data
     $_POST['post_ID'] = $post_id;
     $_POST['apple_news_sections'] = array('https://u48r14.digitalhub.com/sections/1234567890');
     $_POST['apple_news_is_preview'] = 0;
     $_POST['apple_news_pullquote'] = 'test pullquote';
     $_POST['apple_news_pullquote_position'] = 'middle';
     $_POST['apple_news_nonce'] = wp_create_nonce('apple_news_publish');
     $_POST['apple_news_publish_action'] = 'apple_news_publish';
     // Create the meta box class and simulate a save
     $meta_box = new Admin_Apple_Meta_Boxes($this->settings);
     if ('yes' == $this->settings->get('show_metabox')) {
         $meta_box->do_publish($post_id, get_post($post_id));
     }
     // Check the meta values
     $this->assertEquals(array('https://u48r14.digitalhub.com/sections/1234567890'), get_post_meta($post_id, 'apple_news_sections', true));
     $this->assertEquals(false, get_post_meta($post_id, 'apple_news_is_preview', true));
     $this->assertEquals('test pullquote', get_post_meta($post_id, 'apple_news_pullquote', true));
     $this->assertEquals('middle', get_post_meta($post_id, 'apple_news_pullquote_position', true));
 }
?>
		<?php 
do_action('apple_news_before_single_settings');
?>
		<table class="form-table">
			<?php 
if (!empty($sections)) {
    ?>
			<tr>
				<th scope="row"><?php 
    esc_html_e('Sections', 'apple-news');
    ?>
</th>
				<td>
					<?php 
    \Admin_Apple_Meta_Boxes::build_sections_field($sections, $post->ID);
    ?>
					<p class="description"><?php 
    esc_html_e('Select the sections in which to publish this article. Uncheck them all for a standalone article.', 'apple-news');
    ?>
</p>
				</td>
			</tr>
			<?php 
}
?>
			<tr>
				<th scope="row"><?php 
esc_html_e('Preview?', 'apple-news');
?>
</th>
 /**
  * Handles a push to Apple News action.
  *
  * @param int $id
  * @access private
  */
 private function push_action($id)
 {
     // Ensure the post is published
     if ('publish' != get_post_status($id)) {
         $this->notice_error(sprintf(__('Article %s is not published and cannot be pushed to Apple News.', 'apple-news'), $id));
         return;
     }
     // Check the nonce.
     // If it isn't set, this isn't a form submission so we need to just display the form.
     if (!isset($_POST['apple_news_nonce'])) {
         return;
     }
     // If invalid, we need to display an error.
     if (!wp_verify_nonce($_POST['apple_news_nonce'], 'publish')) {
         $this->notice_error(__('Invalid nonce.', 'apple-news'));
     }
     // Save fields
     \Admin_Apple_Meta_Boxes::save_post_meta($id);
     $message = __('Settings saved.', 'apple-news');
     // Push the post
     $action = new Apple_Actions\Index\Push($this->settings, $id);
     try {
         $action->perform();
         // In async mode, success or failure will be displayed later
         if ('yes' !== $this->settings->get('api_async')) {
             $this->notice_success(__('Your article has been pushed successfully!', 'apple-news'));
         } else {
             $this->notice_success(__('Your article will be pushed shortly.', 'apple-news'));
         }
     } catch (Apple_Actions\Action_Exception $e) {
         $this->notice_error($e->getMessage());
     }
 }