<?php
// Exit if accessed directly
defined( 'ABSPATH' ) or die( 'Cheatin&#8217; uh?' );

function AMVG_toggle_feed_auto_import(){
    if ( ! wp_verify_nonce( $_POST['nonce'], 'ajax-nonce' ) )
        wp_die ( 'Busted!');

    if( ! isset( $_POST['feed_id'], $_POST['new_value'] ) )
        wp_die ( 'Some parameters are missing!');
    
    $_POST['new_value'] = $_POST['new_value'] == 'true' ? true: false;

    $output = AMVG()->update_feed( $_POST['feed_id'], array( 'auto_import' => $_POST['new_value'] ) );

    wp_send_json( $output );
    
    wp_die();
}
add_action('wp_ajax_AMVG_toggle_feed_auto_import', 'AMVG_toggle_feed_auto_import');