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-activelayer-wc.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-activelayer-wc.js
175 lines
1 /* global wp_mail_smtp_activelayer_wc */
2
3 'use strict';
4
5 ( function( $ ) {
6
7 const l10n = wp_mail_smtp_activelayer_wc;
8
9 const WPMailSMTPActiveLayerWC = {
10
11 /**
12 * Bind the section controls.
13 *
14 * @since 4.9.0
15 */
16 init: function() {
17
18 $( document )
19 .on( 'click', '.wp-mail-smtp-activelayer-button', WPMailSMTPActiveLayerWC.onClick )
20 .on( 'click', '.wp-mail-smtp-activelayer-wc-dismiss', WPMailSMTPActiveLayerWC.onDismiss );
21 },
22
23 /**
24 * Handle a click on the section button based on its data-action.
25 *
26 * @since 4.9.0
27 *
28 * @param {Event} e Click event.
29 */
30 onClick: function( e ) {
31
32 e.preventDefault();
33
34 const $btn = $( this ),
35 action = $btn.attr( 'data-action' );
36
37 if ( $btn.hasClass( 'disabled' ) ) {
38 return;
39 }
40
41 if ( action === 'goto-url' ) {
42 window.open( $btn.attr( 'data-url' ), '_blank', 'noopener' );
43 return;
44 }
45
46 if ( action === 'goto-settings' ) {
47 window.location.href = $btn.attr( 'data-url' );
48 return;
49 }
50
51 if ( action === 'install' ) {
52 WPMailSMTPActiveLayerWC.run( $btn, 'about_plugin_install', l10n.download_url, l10n.installing );
53 } else if ( action === 'activate' ) {
54 WPMailSMTPActiveLayerWC.run( $btn, 'about_plugin_activate', l10n.plugin, l10n.activating );
55 }
56 },
57
58 /**
59 * Run an install or activate task through the shared plugin dispatcher.
60 *
61 * @since 4.9.0
62 *
63 * @param {jQuery} $btn The section button.
64 * @param {string} task The dispatcher task name.
65 * @param {string} plugin The download URL (install) or basename (activate).
66 * @param {string} processingText Button text while the request runs.
67 */
68 run: function( $btn, task, plugin, processingText ) {
69
70 $btn.addClass( 'disabled' ).text( processingText );
71
72 $.post(
73 l10n.ajax_url,
74 {
75 action: 'wp_mail_smtp_ajax',
76 task: task,
77 plugin: plugin,
78 nonce: l10n.nonce
79 }
80 )
81 .done( function( res ) {
82
83 if ( task === 'about_plugin_install' ) {
84
85 if ( res && res.success && res.data && res.data.is_activated ) {
86 WPMailSMTPActiveLayerWC.toSettings( $btn );
87 return;
88 }
89
90 // Installed but not auto-activated: try activating.
91 if ( res && res.success ) {
92 WPMailSMTPActiveLayerWC.run( $btn, 'about_plugin_activate', l10n.plugin, l10n.activating );
93 return;
94 }
95
96 WPMailSMTPActiveLayerWC.fail( $btn, task );
97 return;
98 }
99
100 if ( res && res.success ) {
101 WPMailSMTPActiveLayerWC.toSettings( $btn );
102 return;
103 }
104
105 WPMailSMTPActiveLayerWC.fail( $btn, task );
106 } )
107 .fail( function() {
108
109 WPMailSMTPActiveLayerWC.fail( $btn, task );
110 } );
111 },
112
113 /**
114 * Turn the button into the "Connect Your Free Account" CTA.
115 *
116 * @since 4.9.0
117 *
118 * @param {jQuery} $btn The section button.
119 */
120 toSettings: function( $btn ) {
121
122 $btn
123 .removeClass( 'disabled' )
124 .attr( 'data-action', 'goto-settings' )
125 .attr( 'data-url', l10n.settings_url )
126 .text( l10n.goto_settings );
127 },
128
129 /**
130 * Show an inline error and fall back to the WordPress.org link.
131 *
132 * @since 4.9.0
133 *
134 * @param {jQuery} $btn The section button.
135 * @param {string} task The dispatcher task that failed.
136 */
137 fail: function( $btn, task ) {
138
139 const msg = task === 'about_plugin_install' ? l10n.error_install : l10n.error_activate;
140
141 $btn
142 .removeClass( 'disabled' )
143 .attr( 'data-action', 'goto-url' )
144 .attr( 'data-url', l10n.wporg_url )
145 .text( l10n.get_activelayer );
146
147 if ( ! $btn.siblings( '.wp-mail-smtp-activelayer-error' ).length ) {
148 $btn.after( '<p class="wp-mail-smtp-activelayer-error">' + msg + '</p>' );
149 }
150 },
151
152 /**
153 * Dismiss the section for the current user.
154 *
155 * @since 4.9.0
156 */
157 onDismiss: function() {
158
159 $.post(
160 l10n.ajax_url,
161 {
162 action: 'wp_mail_smtp_activelayer_wc_dismiss',
163 nonce: l10n.nonce
164 }
165 );
166
167 // Remove optimistically; persistence failures only resurface the section on reload.
168 $( this ).closest( '.wpms-activelayer-wc' ).remove();
169 }
170 };
171
172 $( WPMailSMTPActiveLayerWC.init );
173
174 }( jQuery ) );
175