PluginProbe ʕ •ᴥ•ʔ
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin / 4.9.0
WP Mail SMTP by WPForms – The Most Popular SMTP and Email Log Plugin v4.9.0
4.9.0 0.9.6 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.6.0 1.6.2 1.7.0 1.7.1 1.8.0 1.8.1 1.9.0 2.0.0 2.0.1 2.1.1 2.2.1 2.3.1 2.4.0 2.5.0 2.5.1 2.6.0 2.7.0 2.8.0 2.9.0 3.0.1 3.0.2 3.0.3 3.1.0 3.10.0 3.11.0 3.11.1 3.2.0 3.2.1 3.3.0 3.4.0 3.5.0 3.5.1 3.5.2 3.6.1 3.7.0 3.8.0 3.8.2 3.9.0 4.0.1 4.1.0 4.1.1 4.2.0 4.3.0 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.8.0 trunk 0.10.0 0.10.1 0.11.1 0.11.2 0.3.1 0.3.2 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.5.2 0.6 0.7 0.8 0.8.2 0.8.3 0.8.4 0.8.5 0.8.6 0.8.7 0.9.0 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5
wp-mail-smtp / assets / js / smtp-code-snippets.js
wp-mail-smtp / assets / js Last commit date
vendor 5 days ago connect.js 5 days ago connect.min.js 5 days ago smtp-about.js 5 days ago smtp-about.min.js 5 days ago smtp-activelayer-wc.js 5 days ago smtp-activelayer-wc.min.js 5 days ago smtp-admin-notices.js 5 days ago smtp-admin-notices.min.js 5 days ago smtp-admin.js 5 days ago smtp-admin.min.js 5 days ago smtp-ai-mcp.js 5 days ago smtp-ai-mcp.min.js 5 days ago smtp-code-snippets.js 5 days ago smtp-code-snippets.min.js 5 days ago smtp-dashboard-widget.js 5 days ago smtp-dashboard-widget.min.js 5 days ago smtp-notifications.js 5 days ago smtp-notifications.min.js 5 days ago smtp-recommendations.js 5 days ago smtp-recommendations.min.js 5 days ago smtp-tools-debug-events.js 5 days ago smtp-tools-debug-events.min.js 5 days ago
smtp-code-snippets.js
693 lines
1 /* global List */
2 'use strict';
3
4 var WPMailSMTP = window.WPMailSMTP || {};
5 WPMailSMTP.Admin = WPMailSMTP.Admin || {};
6
7 /**
8 * WP Mail SMTP Admin area Code Snippets module.
9 *
10 * @since 4.9.0
11 */
12 WPMailSMTP.Admin.CodeSnippets = WPMailSMTP.Admin.CodeSnippets || ( function( document, window, $ ) {
13
14 /**
15 * Public functions and properties.
16 *
17 * @since 4.9.0
18 *
19 * @type {object}
20 */
21 var app = {
22
23 /**
24 * List.js instance for the snippet grid.
25 *
26 * @since 4.9.0
27 *
28 * @type {object}
29 */
30 snippetSearch: null,
31
32 /**
33 * Start the engine. DOM is not ready yet, use only to init something.
34 *
35 * @since 4.9.0
36 */
37 init: function() {
38
39 $( app.ready );
40 },
41
42 /**
43 * DOM is fully loaded.
44 *
45 * @since 4.9.0
46 */
47 ready: function() {
48
49 app.snippetSearch = new List(
50 'wp-mail-smtp-wpcode-snippets-list',
51 {
52 valueNames: [ 'wp-mail-smtp-wpcode-snippet-title' ],
53 }
54 );
55
56 app.events();
57 },
58
59 /**
60 * Bind events.
61 *
62 * @since 4.9.0
63 */
64 events: function() {
65
66 // Fallback overlay button installs WPCode directly.
67 $( '.wp-mail-smtp-wpcode-fallback-install-plugin' ).on( 'click', app.onFallbackInstallClick );
68
69 // Card "Install Snippet" (WPCode absent) opens the install-plugin popup.
70 $( '.wp-mail-smtp-wpcode-install-plugin' ).on( 'click', app.openInstallPluginPopup );
71
72 // Card "Install Snippet" (WPCode installed but inactive) activates WPCode, then installs.
73 $( '.wp-mail-smtp-wpcode-activate-plugin' ).on( 'click', app.onActivatePluginClick );
74
75 // "View" opens the code-preview modal.
76 $( '.wp-mail-smtp-wpcode-view-snippet' ).on( 'click', app.openViewSnippetModal );
77
78 // Active-state "Install Snippet" shows an installing state before navigating to WPCode.
79 $( '.wp-mail-smtp-wpcode-install-snippet' ).on( 'click', app.installSnippet );
80
81 $( '#wp-mail-smtp-wpcode-snippet-search' ).on( 'keyup search', function() {
82
83 app.searchSnippet( this );
84 } );
85 },
86
87 /**
88 * POST to an admin-ajax action with the nonce attached.
89 *
90 * @since 4.9.0
91 *
92 * @param {string} action admin-ajax action name.
93 * @param {object} extra Action-specific fields merged into the request.
94 *
95 * @returns {object} The jQuery jqXHR promise.
96 */
97 post: function( action, extra ) {
98
99 var data = $.extend( {
100 action: action,
101 nonce: window.wp_mail_smtp.nonce,
102 }, extra || {} );
103
104 return $.post( window.wp_mail_smtp.ajax_url, data );
105 },
106
107 /**
108 * Enter the installing state: hide the badge/label and overlay a spinner
109 * on the button (CSS keeps the button width).
110 *
111 * @since 4.9.0
112 *
113 * @param {object} $label Badge or "installing" label element.
114 * @param {object} $button Action button element.
115 */
116 setInstalling: function( $label, $button ) {
117
118 $label.addClass( 'wp-mail-smtp-wpcode-installing-in-progress' ).text( window.wp_mail_smtp_code_snippets.installing_text );
119 $button.addClass( 'wp-mail-smtp-btn-loading' );
120 },
121
122 /**
123 * Leave the installing state (used when a flow fails and the UI stays put).
124 *
125 * @since 4.9.0
126 *
127 * @param {object} $label Badge or "installing" label element.
128 * @param {object} $button Action button element.
129 */
130 clearInstalling: function( $label, $button ) {
131
132 $label.removeClass( 'wp-mail-smtp-wpcode-installing-in-progress' ).text( '' );
133 $button.removeClass( 'wp-mail-smtp-btn-loading' );
134 },
135
136 /**
137 * Filter the snippet grid against the search field value.
138 *
139 * @since 4.9.0
140 *
141 * @param {object} searchField The search field HTML element.
142 */
143 searchSnippet: function( searchField ) {
144
145 var searchTerm = $( searchField ).val();
146 var searchResults = app.snippetSearch.search( searchTerm );
147 var $noResults = $( '#wp-mail-smtp-wpcode-no-results' );
148
149 if ( searchResults.length === 0 ) {
150 $noResults.show();
151 } else {
152 $noResults.hide();
153 }
154 },
155
156 /**
157 * Active-state "Install Snippet": show an installing state, then let the
158 * link navigate to WPCode's install screen (perceived-load only, no AJAX).
159 *
160 * @since 4.9.0
161 */
162 installSnippet: function() {
163
164 var $button = $( this );
165
166 // Edit is a plain navigation to the WPCode edit screen; no JS needed.
167 if ( $button.data( 'action' ) === 'edit' ) {
168 return;
169 }
170
171 app.setInstalling(
172 $button.closest( '.wp-mail-smtp-wpcode-snippet' ).find( '.wp-mail-smtp-wpcode-snippet-badge' ),
173 $button
174 );
175 },
176
177 /**
178 * Card "Install Snippet" when WPCode is installed but inactive: activate
179 * WPCode, then navigate to the snippet's install URL. On activation
180 * failure, show the activation popup.
181 *
182 * @since 4.9.0
183 *
184 * @param {object} event The click event.
185 */
186 onActivatePluginClick: function( event ) {
187
188 event.preventDefault();
189
190 var $button = $( this );
191 var $badge = $button.closest( '.wp-mail-smtp-wpcode-snippet' ).find( '.wp-mail-smtp-wpcode-snippet-badge' );
192
193 app.setInstalling( $badge, $button );
194
195 app.activatePluginThenInstallSnippet( $button.data( 'library-id' ), $button.data( 'plugin' ), function() {
196
197 app.clearInstalling( $badge, $button );
198 app.showManualActivationPluginPopup();
199 } );
200 },
201
202 /**
203 * Activate WPCode via AJAX, then resolve the snippet's install URL via a
204 * second AJAX request and navigate there. If activation fails, run the
205 * provided callback; if only the URL lookup fails, reload so the tab
206 * re-renders in its active state.
207 *
208 * @since 4.9.0
209 *
210 * @param {number} libraryId The snippet library id.
211 * @param {string} plugin WPCode plugin path.
212 * @param {Function} onActivateFail Called when activation fails.
213 */
214 activatePluginThenInstallSnippet: function( libraryId, plugin, onActivateFail ) {
215
216 app.post( 'wp_mail_smtp_ajax', { task: 'about_plugin_activate', plugin: plugin } )
217 .done( function( response ) {
218
219 if ( ! response || ! response.success ) {
220 onActivateFail();
221 return;
222 }
223
224 app.navigateToSnippetInstall( libraryId );
225 } )
226 .fail( function() {
227
228 onActivateFail();
229 } );
230 },
231
232 /**
233 * Resolve a snippet's WPCode install URL (now that WPCode is active) via
234 * AJAX and navigate to it. Falls back to a reload if the URL can't be
235 * resolved, so the tab still re-renders in its active state.
236 *
237 * @since 4.9.0
238 *
239 * @param {number} libraryId The snippet library id.
240 */
241 navigateToSnippetInstall: function( libraryId ) {
242
243 var extra = {};
244 extra['library_id'] = libraryId; // eslint-disable-line dot-notation
245
246 app.post( 'wp_mail_smtp_get_wpcode_snippet_install_url', extra )
247 .done( function( response ) {
248
249 if ( response && response.success && response.data && response.data.install_url ) {
250 window.location.href = response.data.install_url;
251 return;
252 }
253
254 window.location.reload();
255 } )
256 .fail( function() {
257
258 window.location.reload();
259 } );
260 },
261
262 /**
263 * Install and activate WPCode via AJAX. Runs onDone on full success, or
264 * onError('install') if the install failed / errored, or onError('activate')
265 * if WPCode installed but silent activation failed.
266 *
267 * WP returns logical failures with HTTP 200 + success:false, so a failed
268 * install lands in .done (not .fail) and must be checked explicitly.
269 *
270 * @since 4.9.0
271 *
272 * @param {string} plugin WPCode download URL.
273 * @param {Function} onDone Called after a successful install + activation.
274 * @param {Function} onError Called with 'install' or 'activate' on failure.
275 */
276 installAndActivatePlugin: function( plugin, onDone, onError ) {
277
278 app.post( 'wp_mail_smtp_ajax', { task: 'about_plugin_install', plugin: plugin } )
279 .done( function( response ) {
280
281 if ( ! response || ! response.success ) {
282 onError( 'install' );
283 return;
284 }
285
286 if ( response.data && response.data.is_activated === false ) {
287 onError( 'activate' );
288 return;
289 }
290
291 onDone();
292 } )
293 .fail( function() {
294
295 onError( 'install' );
296 } );
297 },
298
299 /**
300 * Show the activate-WPCode popup. Its button forwards to the Plugins page
301 * activation action for the installed WPCode plugin.
302 *
303 * @since 4.9.0
304 */
305 showManualActivationPluginPopup: function() {
306
307 var l10n = window.wp_mail_smtp_code_snippets;
308
309 $.confirm( {
310 title: l10n.activate_popup_title,
311 container: '#wp-mail-smtp',
312 boxWidth: '600px',
313 useBootstrap: false,
314 closeIcon: true,
315 draggable: false,
316 content: '<p class="wpms:text-secondary">' + l10n.activate_popup_desc + '</p>',
317 buttons: {
318 activate: {
319 text: l10n.activate_popup_btn,
320 btnClass: 'btn btn-confirm',
321 action: function( button ) {
322
323 button.addClass( 'wp-mail-smtp-btn-loading' );
324 window.location.href = l10n.activate_url;
325
326 // Keep the popup open so the loader stays visible during navigation.
327 return false;
328 },
329 },
330 },
331 } );
332 },
333
334 /**
335 * Map a snippet code_type to a CodeMirror mode.
336 *
337 * @since 4.9.0
338 *
339 * @param {string} codeType Snippet code type.
340 *
341 * @returns {string} CodeMirror mode.
342 */
343 mapMode: function( codeType ) {
344
345 switch ( codeType ) {
346 case 'js':
347 case 'javascript':
348 return 'javascript';
349 case 'css':
350 return 'css';
351 case 'html':
352 return 'htmlmixed';
353 default:
354 return 'text/x-php';
355 }
356 },
357
358 /**
359 * Open the read-only code-preview modal for a snippet.
360 *
361 * @since 4.9.0
362 *
363 * @param {object} event The click event.
364 */
365 openViewSnippetModal: function( event ) {
366
367 event.preventDefault();
368
369 var $btn = $( this );
370 var libraryId = $btn.data( 'library-id' );
371 var installUrl = $btn.data( 'install-url' );
372 var plugin = $btn.data( 'plugin' );
373 var l10n = window.wp_mail_smtp_code_snippets;
374
375 // $.dialog has no jconfirm button row (whose styles can't be overridden
376 // cleanly) — the action button is rendered inside our own content.
377 $.dialog( {
378 title: l10n.loading_text,
379 container: '#wp-mail-smtp',
380 boxWidth: '720px',
381 useBootstrap: false,
382 closeIcon: true,
383 draggable: false,
384 content: '<div class="wpms:p-md wpms:text-secondary">' + l10n.loading_text + '</div>',
385 onContentReady: function() {
386
387 this.$el.addClass( 'wp-mail-smtp-wpcode-dialog' );
388 app.loadSnippetCode( this, libraryId, installUrl, plugin );
389 },
390 } );
391 },
392
393 /**
394 * Fetch a snippet's code and render it into an open dialog.
395 *
396 * @since 4.9.0
397 *
398 * @param {object} dialog The jconfirm dialog instance.
399 * @param {number} libraryId The snippet library id.
400 * @param {string} installUrl WPCode install URL (active state).
401 * @param {string} plugin WPCode download URL (inactive state).
402 */
403 loadSnippetCode: function( dialog, libraryId, installUrl, plugin ) {
404
405 var l10n = window.wp_mail_smtp_code_snippets;
406 var error = '<div class="wpms:p-md wpms:text-error">' + l10n.error_text + '</div>';
407 var extra = {};
408
409 extra['library_id'] = libraryId; // eslint-disable-line dot-notation
410
411 app.post( 'wp_mail_smtp_get_wpcode_snippet_code', extra )
412 .done( function( response ) {
413
414 if ( ! response || ! response.success || ! response.data ) {
415 dialog.setContent( error );
416 return;
417 }
418
419 dialog.setTitle( response.data.title );
420
421 var $content = $( '<div class="wp-mail-smtp-wpcode-modal"></div>' );
422 var $codeWrap = $( '<div class="wp-mail-smtp-wpcode-modal-code"></div>' );
423 var $textarea = $( '<textarea></textarea>' ).val( response.data.code );
424 var $footer = $( '<div class="wp-mail-smtp-wpcode-modal-footer"></div>' );
425 var $installing = $( '<span class="wp-mail-smtp-wpcode-modal-installing"></span>' );
426 var $action = $( '<a href="#" class="wp-mail-smtp-btn wp-mail-smtp-btn-md wp-mail-smtp-btn-secondary"></a>' ).text( l10n.install_text );
427
428 $codeWrap.append( $textarea );
429 $footer.append( $installing ).append( $action );
430 $content.append( $codeWrap ).append( $footer );
431
432 if ( response.data.note ) {
433 $content.prepend( $( '<div class="wp-mail-smtp-wpcode-modal-note"></div>' ).text( response.data.note ) );
434 }
435
436 dialog.setContent( $content );
437 app.initEditor( $textarea[ 0 ], response.data.code_type );
438 app.bindModalInstall( dialog, libraryId, installUrl, plugin, $action, $installing );
439 } )
440 .fail( function() {
441
442 dialog.setContent( error );
443 } );
444 },
445
446 /**
447 * Wire the preview modal's "Install Snippet" button to the right action for
448 * the current WPCode state (active, installed-inactive, or absent).
449 *
450 * @since 4.9.0
451 *
452 * @param {object} dialog The jconfirm dialog instance.
453 * @param {number} libraryId The snippet library id.
454 * @param {string} installUrl WPCode install URL (active state).
455 * @param {string} plugin WPCode download URL (WPCode-absent branch).
456 * @param {object} $action The modal action button.
457 * @param {object} $installing The modal "installing" text element.
458 */
459 bindModalInstall: function( dialog, libraryId, installUrl, plugin, $action, $installing ) {
460
461 var l10n = window.wp_mail_smtp_code_snippets;
462
463 $action.on( 'click', function( clickEvent ) {
464
465 clickEvent.preventDefault();
466
467 if ( l10n.wpcode_active ) {
468 if ( installUrl ) {
469 app.setInstalling( $installing, $action );
470 window.location.href = installUrl;
471 }
472 return;
473 }
474
475 // WPCode installed but inactive: activate, then install (mirrors the card button).
476 if ( l10n.wpcode_path ) {
477 app.setInstalling( $installing, $action );
478 app.activatePluginThenInstallSnippet( libraryId, l10n.wpcode_path, function() {
479
480 app.clearInstalling( $installing, $action );
481 dialog.close();
482 app.showManualActivationPluginPopup();
483 } );
484 return;
485 }
486
487 dialog.close();
488 app.showInstallPluginPopup( plugin, libraryId );
489 } );
490 },
491
492 /**
493 * Initialize CodeMirror on a textarea, with a plain-text fallback.
494 *
495 * @since 4.9.0
496 *
497 * @param {HTMLElement} textarea The textarea element.
498 * @param {string} codeType Snippet code type.
499 */
500 initEditor: function( textarea, codeType ) {
501
502 var l10n = window.wp_mail_smtp_code_snippets;
503
504 if ( ! window.wp || ! window.wp.codeEditor || ! l10n.code_editor ) {
505
506 // Syntax highlighting unavailable (user profile setting): leave the
507 // textarea as a plain read-only code box.
508 $( textarea ).prop( 'readonly', true );
509 return;
510 }
511
512 var settings = $.extend( true, {}, l10n.code_editor );
513
514 settings.codemirror = $.extend( {}, settings.codemirror, {
515 mode: app.mapMode( codeType ),
516 readOnly: true,
517 lineNumbers: true,
518 } );
519
520 window.wp.codeEditor.initialize( textarea, settings );
521 },
522
523 /**
524 * Card "Install Snippet" (WPCode absent): open the install-plugin popup.
525 *
526 * @since 4.9.0
527 *
528 * @param {object} event The click event.
529 */
530 openInstallPluginPopup: function( event ) {
531
532 event.preventDefault();
533 app.showInstallPluginPopup( $( this ).data( 'plugin' ), $( this ).data( 'library-id' ) );
534 },
535
536 /**
537 * Show the install-plugin popup. Its button installs + activates WPCode,
538 * then navigates to the chosen snippet's install URL.
539 *
540 * @since 4.9.0
541 *
542 * @param {string} plugin WPCode download URL.
543 * @param {number} libraryId The snippet library id.
544 */
545 showInstallPluginPopup: function( plugin, libraryId ) {
546
547 var l10n = window.wp_mail_smtp_code_snippets;
548
549 // $.dialog (no jconfirm button row) so the icon row, title, description,
550 // CTA, and link render as one centered content block per the design.
551 $.dialog( {
552 title: '',
553 container: '#wp-mail-smtp',
554 boxWidth: '550px',
555 useBootstrap: false,
556 closeIcon: true,
557 draggable: false,
558 content: app.installPopupHtml( l10n ),
559
560 // The scoped modal styles key off these classes. jQuery-Confirm v3.3.4
561 // has no containerClass option, so add them in onOpenBefore: it is the
562 // earliest hook where $el exists and it fires before the open animation
563 // reveals the box, so the modal paints styled on first render.
564 onOpenBefore: function() {
565
566 this.$el.addClass( 'wp-mail-smtp-wpcode-dialog wp-mail-smtp-wpcode-install-dialog' );
567 },
568 onContentReady: function() {
569
570 var dialog = this;
571
572 dialog.$content.find( '.wp-mail-smtp-wpcode-install-modal-btn' ).on( 'click', function( event ) {
573
574 event.preventDefault();
575
576 var $btn = $( this );
577
578 if ( $btn.hasClass( 'wp-mail-smtp-btn-loading' ) ) {
579 return;
580 }
581
582 $btn.addClass( 'wp-mail-smtp-btn-loading' );
583 dialog.$content.find( '.wp-mail-smtp-wpcode-modal-error' ).remove();
584
585 app.installAndActivatePlugin(
586 plugin,
587 function() {
588
589 app.navigateToSnippetInstall( libraryId );
590 },
591 function( reason ) {
592
593 $btn.removeClass( 'wp-mail-smtp-btn-loading' );
594 dialog.$content.append( app.modalErrorHtml( reason ) );
595 }
596 );
597 } );
598 },
599 } );
600 },
601
602 /**
603 * Build the install-WPCode popup body: an icon row, a two-line title and
604 * description, the install CTA, and a "learn more" link.
605 *
606 * @since 4.9.0
607 *
608 * @param {object} l10n Localized strings and URLs.
609 *
610 * @returns {string} The popup body markup.
611 */
612 installPopupHtml: function( l10n ) {
613
614 return '<div class="wp-mail-smtp-wpcode-install-modal">' +
615 '<img class="wp-mail-smtp-wpcode-install-modal-icons" src="' + l10n.install_popup_icon + '" alt="">' +
616 '<div class="wp-mail-smtp-wpcode-install-modal-title">' + l10n.install_popup_title + '</div>' +
617 '<div class="wp-mail-smtp-wpcode-install-modal-description">' + l10n.install_popup_desc + '</div>' +
618 '<button type="button" class="wp-mail-smtp-btn wp-mail-smtp-btn-lg wp-mail-smtp-btn-orange wp-mail-smtp-wpcode-install-modal-btn">' + l10n.install_popup_btn + '</button>' +
619 '<a href="' + l10n.learn_more_url + '" target="_blank" rel="noopener noreferrer" class="wp-mail-smtp-wpcode-install-modal-link">' + l10n.learn_more_text + '</a>' +
620 '</div>';
621 },
622
623 /**
624 * Build the inline error shown in the install/activate confirm dialog on
625 * failure: a message plus a manual-fallback link (activation URL for
626 * activation failures).
627 *
628 * @since 4.9.0
629 *
630 * @param {string} reason 'install' or 'activate'.
631 *
632 * @returns {object} jQuery element for the error paragraph.
633 */
634 modalErrorHtml: function( reason ) {
635
636 var l10n = window.wp_mail_smtp_code_snippets;
637 var $error = $( '<p class="wp-mail-smtp-wpcode-modal-error"></p>' );
638
639 // Install failure: message only. A plugin-directory search link is
640 // fragile (it can surface the wrong plugin), so we don't offer one.
641 if ( reason !== 'activate' ) {
642 return $error.text( l10n.install_error_text );
643 }
644
645 // Activation failure: WPCode is installed, so link to its exact
646 // activation URL.
647 return $error
648 .text( l10n.activate_error_text + ' ' )
649 .append(
650 $( '<a></a>' )
651 .attr( 'href', l10n.lite_activate_url )
652 .text( l10n.activate_manual_link )
653 );
654 },
655
656 /**
657 * Fallback overlay button: install (or activate) WPCode directly, then
658 * reload so the tab re-renders with live snippet data.
659 *
660 * @since 4.9.0
661 *
662 * @param {object} event The click event.
663 */
664 onFallbackInstallClick: function( event ) {
665
666 if ( event && typeof event.preventDefault === 'function' ) {
667 event.preventDefault();
668 }
669
670 var $btn = $( this );
671
672 if ( $btn.hasClass( 'disabled' ) ) {
673 return;
674 }
675
676 // Lock the width, hide the label, and disable while the request runs.
677 $btn.width( $btn.width() ).text( '' ).addClass( 'disabled' );
678
679 var task = $btn.data( 'action' ) === 'activate' ? 'about_plugin_activate' : 'about_plugin_install';
680
681 app.post( 'wp_mail_smtp_ajax', { task: task, plugin: $btn.data( 'plugin' ) } )
682 .done( function() {
683
684 window.location.reload();
685 } );
686 },
687 };
688
689 return app;
690 }( document, window, jQuery ) );
691
692 WPMailSMTP.Admin.CodeSnippets.init();
693