| 1 |
( function ( $ ) { |
| 2 |
const ignore_gb_notice = function () { |
| 3 |
$( '.wcf_notice_gutenberg_plugin button.notice-dismiss' ).on( |
| 4 |
'click', |
| 5 |
function ( e ) { |
| 6 |
e.preventDefault(); |
| 7 |
|
| 8 |
const data = { |
| 9 |
action: 'cartflows_ignore_gutenberg_notice', |
| 10 |
security: cartflows_notices.ignore_gb_notice, |
| 11 |
}; |
| 12 |
|
| 13 |
$.ajax( { |
| 14 |
type: 'POST', |
| 15 |
url: ajaxurl, |
| 16 |
data, |
| 17 |
|
| 18 |
success( response ) { |
| 19 |
if ( response.success ) { |
| 20 |
console.log( 'Gutenberg Notice Ignored.' ); |
| 21 |
} |
| 22 |
}, |
| 23 |
} ); |
| 24 |
} |
| 25 |
); |
| 26 |
}; |
| 27 |
|
| 28 |
const dismiss_weekly_report_email_notice = function () { |
| 29 |
$( |
| 30 |
'.weekly-report-email-notice.wcf-dismissible-notice button.notice-dismiss' |
| 31 |
).on( 'click', function ( e ) { |
| 32 |
e.preventDefault(); |
| 33 |
|
| 34 |
const data = { |
| 35 |
action: 'cartflows_disable_weekly_report_email_notice', |
| 36 |
security: cartflows_notices.dismiss_weekly_report_email_notice, |
| 37 |
}; |
| 38 |
|
| 39 |
$.ajax( { |
| 40 |
type: 'POST', |
| 41 |
url: ajaxurl, |
| 42 |
data, |
| 43 |
|
| 44 |
success( response ) { |
| 45 |
if ( response.success ) { |
| 46 |
console.log( 'Weekly Report Email Notice Ignored.' ); |
| 47 |
} |
| 48 |
}, |
| 49 |
} ); |
| 50 |
} ); |
| 51 |
}; |
| 52 |
|
| 53 |
const migrate_custom_scripts = function () { |
| 54 |
$( '.wcf-migrate-scripts-btn' ).on( 'click', function ( e ) { |
| 55 |
e.preventDefault(); |
| 56 |
|
| 57 |
const $btn = $( this ); |
| 58 |
const $notice = $btn.closest( '.script-migration-notice' ); |
| 59 |
|
| 60 |
$btn.prop( 'disabled', true ).text( $btn.text() + '...' ); |
| 61 |
|
| 62 |
const data = { |
| 63 |
action: 'cartflows_migrate_custom_scripts', |
| 64 |
security: cartflows_notices.migrate_custom_scripts, |
| 65 |
}; |
| 66 |
|
| 67 |
$.ajax( { |
| 68 |
type: 'POST', |
| 69 |
url: ajaxurl, |
| 70 |
data, |
| 71 |
|
| 72 |
success( response ) { |
| 73 |
if ( response.success ) { |
| 74 |
$notice.fadeOut( 'fast', function () { |
| 75 |
$( this ).remove(); |
| 76 |
} ); |
| 77 |
} else { |
| 78 |
$btn.prop( 'disabled', false ).text( |
| 79 |
$btn.text().replace( '...', '' ) |
| 80 |
); |
| 81 |
} |
| 82 |
}, |
| 83 |
|
| 84 |
error() { |
| 85 |
$btn.prop( 'disabled', false ).text( |
| 86 |
$btn.text().replace( '...', '' ) |
| 87 |
); |
| 88 |
}, |
| 89 |
} ); |
| 90 |
} ); |
| 91 |
}; |
| 92 |
|
| 93 |
const snooze_script_migration_notice = function () { |
| 94 |
$( '.wcf-snooze-migration-btn' ).on( 'click', function ( e ) { |
| 95 |
e.preventDefault(); |
| 96 |
|
| 97 |
const $btn = $( this ); |
| 98 |
const $notice = $btn.closest( '.script-migration-notice' ); |
| 99 |
|
| 100 |
$btn.prop( 'disabled', true ); |
| 101 |
|
| 102 |
const data = { |
| 103 |
action: 'cartflows_snooze_script_migration', |
| 104 |
security: cartflows_notices.snooze_script_migration, |
| 105 |
}; |
| 106 |
|
| 107 |
$.ajax( { |
| 108 |
type: 'POST', |
| 109 |
url: ajaxurl, |
| 110 |
data, |
| 111 |
|
| 112 |
success( response ) { |
| 113 |
if ( response.success ) { |
| 114 |
$notice.fadeOut( 'fast', function () { |
| 115 |
$( this ).remove(); |
| 116 |
} ); |
| 117 |
} else { |
| 118 |
$btn.prop( 'disabled', false ); |
| 119 |
} |
| 120 |
}, |
| 121 |
|
| 122 |
error() { |
| 123 |
$btn.prop( 'disabled', false ); |
| 124 |
}, |
| 125 |
} ); |
| 126 |
} ); |
| 127 |
}; |
| 128 |
|
| 129 |
const dismiss_script_migration_complete_notice = function () { |
| 130 |
$( |
| 131 |
'.script-migration-complete-notice.wcf-dismissible-notice button.notice-dismiss' |
| 132 |
).on( 'click', function ( e ) { |
| 133 |
e.preventDefault(); |
| 134 |
|
| 135 |
const data = { |
| 136 |
action: 'cartflows_dismiss_script_migration_complete_notice', |
| 137 |
security: cartflows_notices.dismiss_migration_complete_notice, |
| 138 |
}; |
| 139 |
|
| 140 |
$.ajax( { |
| 141 |
type: 'POST', |
| 142 |
url: ajaxurl, |
| 143 |
data, |
| 144 |
|
| 145 |
success( response ) { |
| 146 |
if ( response.success ) { |
| 147 |
console.log( |
| 148 |
'Script Migration Complete Notice Dismissed.' |
| 149 |
); |
| 150 |
} |
| 151 |
}, |
| 152 |
} ); |
| 153 |
} ); |
| 154 |
}; |
| 155 |
|
| 156 |
$( function () { |
| 157 |
ignore_gb_notice(); |
| 158 |
dismiss_weekly_report_email_notice(); |
| 159 |
migrate_custom_scripts(); |
| 160 |
snooze_script_migration_notice(); |
| 161 |
dismiss_script_migration_complete_notice(); |
| 162 |
} ); |
| 163 |
} )( jQuery ); |
| 164 |
|