/** * Relist a closed product at ML * * @ajax( action: "relist_ml_product" , only_logged: true ) */ public function relist_product() { check_ajax_referer('ml-relist-product-action', 'security'); if (!isset($_GET['post_id'])) { die; } try { $ml_product = new ML_Product(intval($_GET['post_id'])); $ml_product->relist(); ML()->add_notice(__('The product was successfully relisted on MercadoLivre', ML()->textdomain), 'success'); } catch (ML_Exception $e) { ML()->add_notice(sprintf('%s: %s', __('The product could not be relisted on MercadoLivre', ML()->textdomain), $e->getMessage()), 'error'); } wp_safe_redirect(wp_get_referer() ? wp_get_referer() : admin_url('edit.php?post_type=product')); die; }