/** * Update a product at ML * * @ajax( action: "change_status_ml_product" , only_logged: true ) */ public function change_product_status() { check_ajax_referer('ml-change-status-action', 'security'); if (!isset($_GET['post_id'], $_GET['status'])) { die; } try { $ml_product = new ML_Product(intval($_GET['post_id'])); $ml_product->update_status($_GET['status']); } catch (ML_Exception $e) { ML()->add_notice(sprintf('%s: %s', __('Error while trying to update product status on MercadoLivre', ML()->textdomain), $e->getMessage()), 'error'); } wp_safe_redirect(wp_get_referer() ? wp_get_referer() : admin_url('edit.php?post_type=product')); die; }