✏️ 编辑:email-promo.js
路径:
/home/forge/kingkrunch.com/wp/wp-content/plugins/simple-history/js/email-promo.js
大小:1.6 KB · 修改:2026-09-25 00:42:29 · 权限:0644 · 可写
← 返回目录
👁 查看
⬇ 下载
/** * JavaScript for the email promo card dismissal functionality. * * @param {Object} $ jQuery object */ ( function ( $ ) { 'use strict'; $( document ).ready( function () { const $card = $( '#simple-history-email-promo-card' ); if ( ! $card.length ) { return; } // Handle "Subscribe now" button click $card.on( 'click', '.sh-EmailPromoCard-cta', function () { // Don't prevent default - let the link navigate // But dismiss the card in the background via AJAX dismissPromo(); } ); // Handle "No thanks, not interested" button click $card.on( 'click', '.sh-EmailPromoCard-dismiss', function ( e ) { e.preventDefault(); // Fade out the card first for better UX $card.fadeOut( 300, function () { dismissPromo(); } ); } ); /** * Send AJAX request to dismiss the promo card. */ function dismissPromo() { $.ajax( { url: window.simpleHistoryEmailPromo.ajaxUrl, type: 'POST', data: { action: window.simpleHistoryEmailPromo.action, nonce: window.simpleHistoryEmailPromo.nonce, }, success( response ) { if ( response.success ) { // Card successfully dismissed // eslint-disable-next-line no-console // console.log( 'Email promo card dismissed' ); } else { // eslint-disable-next-line no-console console.error( 'Failed to dismiss email promo card:', response.data ); } }, error( xhr, status, error ) { // eslint-disable-next-line no-console console.error( 'AJAX error dismissing email promo card:', error ); }, } ); } } ); } )( jQuery );
💾 保存
取消
保存为 UTF-8,换行统一为 LF