/**
 * Manages the ajax response for setting/getting article export status
 */
function article_status_response()
{
    Core\check_ajax_referer();
    try {
        $export_status = article_status_handler();
        Core\send_json_success(['export_status' => $export_status]);
    } catch (\Exception $e) {
        Core\send_json_error();
    }
}
Example #2
0
 /**
  * Handles an ajax request to update a section's title
  *
  * @todo refactor to use exceptions and one json response vs pepper-style
  */
 public static function update_title_ajax()
 {
     Core\check_elevated_ajax_referer();
     $title = isset($_POST['title']) ? sanitize_text_field($_POST['title']) : false;
     if (!$title) {
         Core\send_json_error(['message' => __('Please enter a section name.', 'eight-day-week')]);
     }
     $post_id = isset($_POST['post_id']) ? sanitize_text_field($_POST['post_id']) : false;
     if (!$post_id) {
         Core\send_json_error(['message' => __('Whoops! This section appears to be invalid.', 'eight-day-week')]);
     }
     try {
         self::update_title($title, $post_id);
     } catch (\Exception $e) {
         Core\send_json_error(['message' => $e->getMessage()]);
     }
     Core\send_json_success();
 }