示例#1
0
/**
 * Handles a request to edit articles' status
 * @todo refactor into pattern so that json functions are higher up, and the handler throws exceptions insteads
 */
function bulk_edit_article_statuses_ajax()
{
    Core\check_elevated_ajax_referer();
    $term_id = absint($_POST['status']);
    $article_ids = $_POST['checked_articles'];
    //sanitize - only allow comma delimited integers
    if (!ctype_digit(str_replace(',', '', $article_ids))) {
        \Eight_Day_Week\Core\send_json_error(['message' => __('Invalid article IDs specified in the request.', 'eight-day-week')]);
    }
    $article_ids = explode(',', $article_ids);
    try {
        bulk_edit_article_statuses($term_id, $article_ids);
    } catch (\Exception $e) {
        \Eight_Day_Week\Core\send_json_error(['message' => $e->getMessage()]);
    }
    \Eight_Day_Week\Core\send_json_success();
}
示例#2
0
/**
 * Handles a request for the HTML of a new, post-specific AL_Table row
 */
function get_article_row_ajax()
{
    \Eight_Day_Week\Core\check_ajax_referer();
    $article_id = absint($_GET['article_id']);
    $article_table = new AL_Table([$article_id]);
    $article_table->prepare_items();
    $article_data = new \stdClass();
    $article_data->data = $article_table->get_data($article_table->items[0]);
    $article_data->html = $article_table->get_single_row($article_table->items[0]);
    \Eight_Day_Week\Core\send_json_success($article_data);
}