Snapshot: MLS sync fixes, image refresh, plugin/theme updates
MLS plugin fixes from this session: - Fix silent insert failures: location column NOT NULL was rejecting wpdb->insert calls, causing ~18k new properties since Dec 2025 to be lost. Inserts now build raw SQL with ST_PointFromText so the spatial column is populated atomically. - Auto-refresh expired media URLs in MLS_Media_Handler::fetch_and_cache(), guarded by a property-level GET_LOCK so concurrent fetches share one API refresh. - Normalize WP_Error to null in mls_get_property_image() so callers can rely on the documented string|null contract. - Support comma-separated property_type filters in MLS_Query and MLS_Cluster so the homepage "View All Commercial" link (?property_type=Commercial+Sale,Land,Farm) actually filters correctly. - Incremental sync now looks back 10 minutes past the latest modification timestamp as a safety margin against missed records. - Smart sync exits silently (info-level, not warning) when a full sync is in progress. Operational: - New cron: weekly full sync Sundays at 3 AM (/usr/local/bin/mls-full-sync). - New cron: hourly 2GB cap on mls-thumbnails/ and cache/transformed-images/ (/usr/local/bin/mls-image-cache-cap). - Logrotate config for wp-content/debug.log (2-day retention, daily rotation, delaycompress). Repo policy: - CLAUDE.md updated with explicit "commit everything except build artifacts" policy. - .gitignore: untrack runtime image caches and debug.log rotations. Other modifications in this snapshot are pre-existing in-flight theme/plugin/db_content_updates work. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,276 @@
|
||||
/* global wpforms_pluginlanding, wpforms_admin */
|
||||
|
||||
/**
|
||||
* @param wpforms_pluginlanding.activated
|
||||
* @param wpforms_pluginlanding.activated_pro
|
||||
* @param wpforms_pluginlanding.download_now
|
||||
* @param wpforms_pluginlanding.error_could_not_activate
|
||||
* @param wpforms_pluginlanding.error_could_not_install
|
||||
* @param wpforms_pluginlanding.is_activated
|
||||
* @param wpforms_pluginlanding.license_level
|
||||
* @param wpforms_pluginlanding.result_status
|
||||
* @param wpforms_pluginlanding.plugins_page
|
||||
* @param wpforms_pluginlanding.setup_status
|
||||
* @param wpforms_pluginlanding.step3_button_url
|
||||
* @param wpforms_pluginlanding.manual_activate_url
|
||||
* @param wpforms_pluginlanding.manual_install_url
|
||||
*/
|
||||
|
||||
/**
|
||||
* Landing Pages Common.
|
||||
*
|
||||
* @since 1.9.8.6
|
||||
*/
|
||||
const WPFormsPagesCommon = window.WPFormsPagesCommon || ( function( document, window, $ ) {
|
||||
/**
|
||||
* Elements.
|
||||
*
|
||||
* @since 1.9.8.6
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
let el = {};
|
||||
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.9.8.6
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const app = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.9.8.6
|
||||
*/
|
||||
init: () => {
|
||||
$( app.ready );
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.9.8.6
|
||||
*/
|
||||
ready: () => {
|
||||
app.initVars();
|
||||
app.events();
|
||||
},
|
||||
|
||||
/**
|
||||
* Init variables.
|
||||
*
|
||||
* @since 1.9.8.6
|
||||
*/
|
||||
initVars: () => {
|
||||
el = {
|
||||
$stepInstall: $( 'section.step-install' ),
|
||||
$stepInstallNum: $( 'section.step-install .num img' ),
|
||||
$stepSetup: $( 'section.step-setup' ),
|
||||
$stepSetupNum: $( 'section.step-setup .num img' ),
|
||||
$stepResult: $( 'section.step-result' ),
|
||||
$stepResultNum: $( 'section.step-result .num img' ),
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Register JS events.
|
||||
*
|
||||
* @since 1.9.8.6
|
||||
*/
|
||||
events: () => {
|
||||
// Step the 'Install' button click.
|
||||
el.$stepInstall.on( 'click', 'button', app.stepInstallClick );
|
||||
|
||||
// Step 'Setup' button click.
|
||||
el.$stepSetup.on( 'click', 'button', app.gotoURL );
|
||||
|
||||
// Step the 'Addon' button click.
|
||||
el.$stepResult.on( 'click', 'button', app.gotoURL );
|
||||
},
|
||||
|
||||
/**
|
||||
* Step the 'Install' button click.
|
||||
*
|
||||
* @since 1.9.8.6
|
||||
*
|
||||
* @param {Event} e Event object.
|
||||
*/
|
||||
stepInstallClick: ( e ) => {
|
||||
const $btn = $( e.currentTarget );
|
||||
|
||||
if ( $btn.hasClass( 'disabled' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const action = $btn.attr( 'data-action' );
|
||||
|
||||
let ajaxAction = '';
|
||||
|
||||
switch ( action ) {
|
||||
case 'activate':
|
||||
ajaxAction = 'wpforms_activate_addon';
|
||||
$btn.text( wpforms_pluginlanding.activating );
|
||||
break;
|
||||
|
||||
case 'install':
|
||||
ajaxAction = 'wpforms_install_addon';
|
||||
$btn.text( wpforms_pluginlanding.installing );
|
||||
break;
|
||||
|
||||
case 'goto-url':
|
||||
window.location.href = $btn.attr( 'data-url' );
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
$btn.addClass( 'disabled' );
|
||||
app.showSpinner( el.$stepInstallNum );
|
||||
|
||||
const plugin = $btn.attr( 'data-plugin' );
|
||||
|
||||
const data = {
|
||||
action: ajaxAction,
|
||||
nonce : wpforms_admin.nonce,
|
||||
plugin,
|
||||
type : 'plugin',
|
||||
};
|
||||
$.post( wpforms_admin.ajax_url, data )
|
||||
.done( function( res ) {
|
||||
app.stepInstallDone( res, $btn, action );
|
||||
} )
|
||||
.always( function() {
|
||||
app.hideSpinner( el.$stepInstallNum );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Done part of the step 'Install'.
|
||||
*
|
||||
* @since 1.9.8.6
|
||||
*
|
||||
* @param {Object} res Result of $.post() query.
|
||||
* @param {jQuery} $btn Button.
|
||||
* @param {string} action Action (for more info look at the app.stepInstallClick() function).
|
||||
*/
|
||||
stepInstallDone: ( res, $btn, action ) => { // eslint-disable-line complexity
|
||||
const success = 'install' === action ? res.success && res.data.is_activated : res.success,
|
||||
provider = $btn.data( 'provider' );
|
||||
|
||||
if ( success ) {
|
||||
el.$stepInstallNum.attr( 'src', el.$stepInstallNum.attr( 'src' ).replace( 'step-1.', 'step-complete.' ) );
|
||||
$btn.addClass( 'grey' ).removeClass( 'button-primary' ).text( wpforms_pluginlanding.activated );
|
||||
app.stepInstallPluginStatus( provider );
|
||||
} else {
|
||||
const activationFail = ( 'install' === action && res.success && ! res.data.is_activated ) || 'activate' === action,
|
||||
installUrl = wpforms_pluginlanding[ provider + '_manual_install_url' ] || '',
|
||||
activateUrl = wpforms_pluginlanding[ provider + '_manual_activate_url' ] || '',
|
||||
url = ! activationFail ? installUrl : activateUrl,
|
||||
msg = ! activationFail ? wpforms_pluginlanding.error_could_not_install : wpforms_pluginlanding.error_could_not_activate,
|
||||
btn = ! activationFail ? wpforms_pluginlanding.download_now : wpforms_pluginlanding.plugins_page;
|
||||
|
||||
$btn.removeClass( 'grey disabled' ).text( btn ).attr( 'data-action', 'goto-url' ).attr( 'data-url', url );
|
||||
$btn.after( '<p class="error">' + msg + '</p>' );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback for step 'Install' completion.
|
||||
*
|
||||
* @since 1.9.8.6
|
||||
*
|
||||
* @param {string} plugin Plugin name.
|
||||
*/
|
||||
stepInstallPluginStatus: ( plugin ) => {
|
||||
const data = {
|
||||
action: 'wpforms_page_check_' + plugin + '_status',
|
||||
nonce: wpforms_admin.nonce,
|
||||
provider: plugin,
|
||||
};
|
||||
$.post( wpforms_admin.ajax_url, data ).done( app.stepInstallPluginStatusDone );
|
||||
},
|
||||
|
||||
/**
|
||||
* Done part of the callback for step 'Install' completion.
|
||||
*
|
||||
* @since 1.9.8.6
|
||||
*
|
||||
* @param {Object} res Result of $.post() query.
|
||||
*/
|
||||
stepInstallPluginStatusDone: ( res ) => {
|
||||
if ( ! res.success ) {
|
||||
return;
|
||||
}
|
||||
|
||||
el.$stepSetup.removeClass( 'grey' );
|
||||
el.$stepSetupBtn = el.$stepSetup.find( 'button' );
|
||||
|
||||
if ( res.data.setup_status > 0 ) {
|
||||
el.$stepSetupNum.attr( 'src', el.$stepSetupNum.attr( 'src' ).replace( 'step-2.svg', 'step-complete.svg' ) );
|
||||
el.$stepResult.removeClass( 'grey' );
|
||||
el.$stepResultBtn = el.$stepResult.find( 'button' );
|
||||
|
||||
if ( res.data.license_level === 'pro' && res.data.result_status === true ) {
|
||||
el.$stepResultBtn.text( wpforms_pluginlanding.activated_pro );
|
||||
el.$stepResultNum.attr( 'src', el.$stepResultNum.attr( 'src' ).replace( 'step-3.svg', 'step-complete.svg' ) );
|
||||
} else {
|
||||
el.$stepResultBtn.attr( 'data-url', res.data.step3_button_url );
|
||||
el.$stepResultBtn.removeClass( 'grey disabled' ).addClass( 'button-primary' );
|
||||
}
|
||||
} else {
|
||||
el.$stepSetupBtn.removeClass( 'grey disabled' ).addClass( 'button-primary' );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Go to URL.
|
||||
*
|
||||
* @since 1.9.8.6
|
||||
*
|
||||
* @param {Event} e Event object.
|
||||
*/
|
||||
gotoURL: ( e ) => { // eslint-disable-line no-unused-vars
|
||||
const $btn = $( e.currentTarget ),
|
||||
url = $btn.attr( 'data-url' );
|
||||
|
||||
if ( $btn.hasClass( 'disabled' ) || ! url ) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.open( url, '_blank' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Show spinner.
|
||||
*
|
||||
* @since 1.9.8.6
|
||||
*
|
||||
* @param {jQuery} $el Element.
|
||||
*/
|
||||
showSpinner: ( $el ) => {
|
||||
$el.siblings( 'i.loader' ).removeClass( 'hidden' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide spinner.
|
||||
*
|
||||
* @since 1.9.8.6
|
||||
*
|
||||
* @param {jQuery} $el Element.
|
||||
*/
|
||||
hideSpinner: ( $el ) => {
|
||||
$el.show();
|
||||
$el.siblings( 'i.loader' ).addClass( 'hidden' );
|
||||
},
|
||||
};
|
||||
|
||||
// Provide public access to functions and properties.
|
||||
return app;
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
// Initialize.
|
||||
WPFormsPagesCommon.init();
|
||||
+1
@@ -0,0 +1 @@
|
||||
let WPFormsPagesCommon=window.WPFormsPagesCommon||((n,l)=>{let r={},i={init:()=>{l(i.ready)},ready:()=>{i.initVars(),i.events()},initVars:()=>{r={$stepInstall:l("section.step-install"),$stepInstallNum:l("section.step-install .num img"),$stepSetup:l("section.step-setup"),$stepSetupNum:l("section.step-setup .num img"),$stepResult:l("section.step-result"),$stepResultNum:l("section.step-result .num img")}},events:()=>{r.$stepInstall.on("click","button",i.stepInstallClick),r.$stepSetup.on("click","button",i.gotoURL),r.$stepResult.on("click","button",i.gotoURL)},stepInstallClick:e=>{let a=l(e.currentTarget);if(!a.hasClass("disabled")){let s=a.attr("data-action"),t="";switch(s){case"activate":t="wpforms_activate_addon",a.text(wpforms_pluginlanding.activating);break;case"install":t="wpforms_install_addon",a.text(wpforms_pluginlanding.installing);break;case"goto-url":return void(n.location.href=a.attr("data-url"));default:return}a.addClass("disabled"),i.showSpinner(r.$stepInstallNum);e=a.attr("data-plugin"),e={action:t,nonce:wpforms_admin.nonce,plugin:e,type:"plugin"};l.post(wpforms_admin.ajax_url,e).done(function(t){i.stepInstallDone(t,a,s)}).always(function(){i.hideSpinner(r.$stepInstallNum)})}},stepInstallDone:(t,s,e)=>{var a="install"===e?t.success&&t.data.is_activated:t.success,n=s.data("provider");a?(r.$stepInstallNum.attr("src",r.$stepInstallNum.attr("src").replace("step-1.","step-complete.")),s.addClass("grey").removeClass("button-primary").text(wpforms_pluginlanding.activated),i.stepInstallPluginStatus(n)):(a="install"===e&&t.success&&!t.data.is_activated||"activate"===e,t=wpforms_pluginlanding[n+"_manual_install_url"]||"",e=a?wpforms_pluginlanding[n+"_manual_activate_url"]||"":t,n=a?wpforms_pluginlanding.error_could_not_activate:wpforms_pluginlanding.error_could_not_install,t=a?wpforms_pluginlanding.plugins_page:wpforms_pluginlanding.download_now,s.removeClass("grey disabled").text(t).attr("data-action","goto-url").attr("data-url",e),s.after('<p class="error">'+n+"</p>"))},stepInstallPluginStatus:t=>{t={action:"wpforms_page_check_"+t+"_status",nonce:wpforms_admin.nonce,provider:t};l.post(wpforms_admin.ajax_url,t).done(i.stepInstallPluginStatusDone)},stepInstallPluginStatusDone:t=>{t.success&&(r.$stepSetup.removeClass("grey"),r.$stepSetupBtn=r.$stepSetup.find("button"),0<t.data.setup_status?(r.$stepSetupNum.attr("src",r.$stepSetupNum.attr("src").replace("step-2.svg","step-complete.svg")),r.$stepResult.removeClass("grey"),r.$stepResultBtn=r.$stepResult.find("button"),"pro"===t.data.license_level&&!0===t.data.result_status?(r.$stepResultBtn.text(wpforms_pluginlanding.activated_pro),r.$stepResultNum.attr("src",r.$stepResultNum.attr("src").replace("step-3.svg","step-complete.svg"))):(r.$stepResultBtn.attr("data-url",t.data.step3_button_url),r.$stepResultBtn.removeClass("grey disabled").addClass("button-primary"))):r.$stepSetupBtn.removeClass("grey disabled").addClass("button-primary"))},gotoURL:t=>{var t=l(t.currentTarget),s=t.attr("data-url");!t.hasClass("disabled")&&s&&n.open(s,"_blank")},showSpinner:t=>{t.siblings("i.loader").removeClass("hidden")},hideSpinner:t=>{t.show(),t.siblings("i.loader").addClass("hidden")}};return i})((document,window),jQuery);WPFormsPagesCommon.init();
|
||||
@@ -0,0 +1,247 @@
|
||||
/* global wpforms_admin, WPFormsFormTemplates, wpforms_admin_form_templates, wpf */
|
||||
|
||||
// noinspection ES6ConvertVarToLetConst
|
||||
|
||||
/**
|
||||
* @param wpforms_admin_form_templates.openAIFormUrl
|
||||
*/
|
||||
/**
|
||||
* Admin Subpage Form Templates function.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line no-var
|
||||
var WPFormsAdminFormTemplates = window.WPFormsAdminFormTemplates || ( function( document, window, $ ) {
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const app = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*/
|
||||
init() {
|
||||
$( app.ready );
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*/
|
||||
ready() {
|
||||
WPFormsFormTemplates.setup();
|
||||
app.events();
|
||||
wpf.initTooltips();
|
||||
},
|
||||
|
||||
/**
|
||||
* Bind events.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*/
|
||||
events() {
|
||||
$( '.wpforms-form-setup-content' )
|
||||
.on( 'keyup', '#wpforms-setup-template-search', _.debounce( WPFormsFormTemplates.searchTemplate, 200 ) )
|
||||
.on( 'click', '.wpforms-setup-templates-categories li div', WPFormsFormTemplates.selectCategory )
|
||||
.on( 'click', '.wpforms-setup-templates-categories li .chevron', WPFormsFormTemplates.toggleSubcategoriesList )
|
||||
.on( 'click', '.wpforms-setup-templates-subcategories li', WPFormsFormTemplates.selectSubCategory )
|
||||
.on( 'click', '.wpforms-template-select', app.selectTemplate )
|
||||
.on( 'click', '.wpforms-trigger-blank', app.selectBlankTemplate )
|
||||
.on( 'click', '.wpforms-template-generate', app.openAIFormGenerator );
|
||||
},
|
||||
|
||||
/**
|
||||
* Open the AI Form Generator.
|
||||
*
|
||||
* @since 1.9.4
|
||||
*
|
||||
* @param {Object} e Event object.
|
||||
*/
|
||||
openAIFormGenerator( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
const $button = $( this );
|
||||
|
||||
// Don't do anything for inactive button.
|
||||
if ( $button.hasClass( 'wpforms-inactive wpforms-help-tooltip' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.location = wpforms_admin_form_templates.openAIFormUrl;
|
||||
},
|
||||
|
||||
/**
|
||||
* Select template.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*
|
||||
* @param {Object} event Event object.
|
||||
*/
|
||||
selectTemplate( event ) {
|
||||
event.preventDefault();
|
||||
|
||||
const $button = $( this );
|
||||
const spinner = '<i class="wpforms-loading-spinner wpforms-loading-white wpforms-loading-inline"></i>';
|
||||
|
||||
// Don't do anything for templates that trigger education modal OR addons-modal.
|
||||
if ( $button.hasClass( 'education-modal' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// User templates are applied differently for new forms.
|
||||
if ( $button.data( 'template' ).match( /wpforms-user-template-(\d+)/ ) && $button.data( 'create-url' ) ) {
|
||||
window.location.href = $button.data( 'create-url' );
|
||||
return;
|
||||
}
|
||||
|
||||
$( '.wpforms-form-setup-content' ).find( '.wpforms-template' ).removeClass( 'active' );
|
||||
$button.closest( '.wpforms-template' ).addClass( 'active' );
|
||||
|
||||
// Save the original label.
|
||||
$button.data( 'labelOriginal', $button.html() );
|
||||
|
||||
// Display loading indicator.
|
||||
$button.html( spinner + wpforms_admin.loading );
|
||||
|
||||
WPFormsFormTemplates.selectTemplateProcess( $button.data( 'template-name-raw' ), $button.data( 'template' ), $button, app.selectTemplateProcessAjax );
|
||||
},
|
||||
|
||||
/**
|
||||
* Select Blank template.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*
|
||||
* @param {Object} e Event object.
|
||||
*/
|
||||
selectBlankTemplate( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
app.selectTemplateProcessAjax( 'Blank Form', 'blank' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Select template. Create or update form AJAX call.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*
|
||||
* @param {string} formName Name of the form.
|
||||
* @param {string} template Template slug.
|
||||
*/
|
||||
selectTemplateProcessAjax( formName, template ) {
|
||||
const data = {
|
||||
title: formName,
|
||||
action: 'wpforms_new_form',
|
||||
template,
|
||||
// eslint-disable-next-line camelcase
|
||||
form_id: 0,
|
||||
nonce: wpforms_admin_form_templates.nonce,
|
||||
};
|
||||
|
||||
const category = $( '.wpforms-setup-templates-categories li.active' ).data( 'category' );
|
||||
|
||||
if ( category && category !== 'all' ) {
|
||||
data.category = category;
|
||||
}
|
||||
|
||||
const subcategory = $( '.wpforms-setup-templates-subcategories li.active' ).data( 'subcategory' );
|
||||
|
||||
if ( subcategory ) {
|
||||
data.subcategory = subcategory;
|
||||
}
|
||||
|
||||
$.post( wpforms_admin.ajax_url, data )
|
||||
.done( function( res ) {
|
||||
if ( res.success ) {
|
||||
window.location.href = res.data.redirect;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( res.data.error_type === 'invalid_template' ) {
|
||||
app.selectTemplateProcessInvalidTemplateError( res.data.message, formName );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
app.selectTemplateProcessError( res.data.message );
|
||||
} )
|
||||
.fail( function() {
|
||||
app.selectTemplateProcessError( '' );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Select template AJAX call error modal for invalid template using.
|
||||
*
|
||||
* @since 1.7.7
|
||||
*
|
||||
* @param {string} errorMessage Error message.
|
||||
* @param {string} formName Name of the form.
|
||||
*/
|
||||
selectTemplateProcessInvalidTemplateError( errorMessage, formName ) {
|
||||
$.alert( {
|
||||
title: wpforms_admin.heads_up,
|
||||
content: errorMessage,
|
||||
icon: 'fa fa-exclamation-circle',
|
||||
type: 'orange',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: wpforms_admin.use_default_template,
|
||||
btnClass: 'btn-confirm',
|
||||
keys: [ 'enter' ],
|
||||
action() {
|
||||
app.selectTemplateProcessAjax( formName, 'simple-contact-form-template' );
|
||||
},
|
||||
},
|
||||
cancel: {
|
||||
text: wpforms_admin.cancel,
|
||||
action() {
|
||||
WPFormsFormTemplates.selectTemplateCancel();
|
||||
},
|
||||
},
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Select template AJAX call error modal.
|
||||
*
|
||||
* @since 1.7.7
|
||||
* @since 1.8.8 Replaced error message with error title.
|
||||
*
|
||||
* @param {string} errorTitle Error title.
|
||||
*/
|
||||
selectTemplateProcessError( errorTitle ) {
|
||||
$.alert( {
|
||||
title: errorTitle,
|
||||
content: wpforms_admin.error_select_template,
|
||||
icon: 'fa fa-exclamation-circle',
|
||||
type: 'orange',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: wpforms_admin.ok,
|
||||
btnClass: 'btn-confirm',
|
||||
keys: [ 'enter' ],
|
||||
action() {
|
||||
WPFormsFormTemplates.selectTemplateCancel();
|
||||
},
|
||||
},
|
||||
},
|
||||
} );
|
||||
},
|
||||
};
|
||||
|
||||
// Provide access to public functions/properties.
|
||||
return app;
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
// Initialize.
|
||||
WPFormsAdminFormTemplates.init();
|
||||
+1
@@ -0,0 +1 @@
|
||||
var WPFormsAdminFormTemplates=window.WPFormsAdminFormTemplates||((s,o)=>{let r={init(){o(r.ready)},ready(){WPFormsFormTemplates.setup(),r.events(),wpf.initTooltips()},events(){o(".wpforms-form-setup-content").on("keyup","#wpforms-setup-template-search",_.debounce(WPFormsFormTemplates.searchTemplate,200)).on("click",".wpforms-setup-templates-categories li div",WPFormsFormTemplates.selectCategory).on("click",".wpforms-setup-templates-categories li .chevron",WPFormsFormTemplates.toggleSubcategoriesList).on("click",".wpforms-setup-templates-subcategories li",WPFormsFormTemplates.selectSubCategory).on("click",".wpforms-template-select",r.selectTemplate).on("click",".wpforms-trigger-blank",r.selectBlankTemplate).on("click",".wpforms-template-generate",r.openAIFormGenerator)},openAIFormGenerator(e){e.preventDefault(),o(this).hasClass("wpforms-inactive wpforms-help-tooltip")||(s.location=wpforms_admin_form_templates.openAIFormUrl)},selectTemplate(e){e.preventDefault();e=o(this);e.hasClass("education-modal")||(e.data("template").match(/wpforms-user-template-(\d+)/)&&e.data("create-url")?s.location.href=e.data("create-url"):(o(".wpforms-form-setup-content").find(".wpforms-template").removeClass("active"),e.closest(".wpforms-template").addClass("active"),e.data("labelOriginal",e.html()),e.html('<i class="wpforms-loading-spinner wpforms-loading-white wpforms-loading-inline"></i>'+wpforms_admin.loading),WPFormsFormTemplates.selectTemplateProcess(e.data("template-name-raw"),e.data("template"),e,r.selectTemplateProcessAjax)))},selectBlankTemplate(e){e.preventDefault(),r.selectTemplateProcessAjax("Blank Form","blank")},selectTemplateProcessAjax(t,e){var e={title:t,action:"wpforms_new_form",template:e,form_id:0,nonce:wpforms_admin_form_templates.nonce},a=o(".wpforms-setup-templates-categories li.active").data("category"),a=(a&&"all"!==a&&(e.category=a),o(".wpforms-setup-templates-subcategories li.active").data("subcategory"));a&&(e.subcategory=a),o.post(wpforms_admin.ajax_url,e).done(function(e){e.success?s.location.href=e.data.redirect:"invalid_template"===e.data.error_type?r.selectTemplateProcessInvalidTemplateError(e.data.message,t):r.selectTemplateProcessError(e.data.message)}).fail(function(){r.selectTemplateProcessError("")})},selectTemplateProcessInvalidTemplateError(e,t){o.alert({title:wpforms_admin.heads_up,content:e,icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_admin.use_default_template,btnClass:"btn-confirm",keys:["enter"],action(){r.selectTemplateProcessAjax(t,"simple-contact-form-template")}},cancel:{text:wpforms_admin.cancel,action(){WPFormsFormTemplates.selectTemplateCancel()}}}})},selectTemplateProcessError(e){o.alert({title:e,content:wpforms_admin.error_select_template,icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_admin.ok,btnClass:"btn-confirm",keys:["enter"],action(){WPFormsFormTemplates.selectTemplateCancel()}}}})}};return r})((document,window),jQuery);WPFormsAdminFormTemplates.init();
|
||||
+318
@@ -0,0 +1,318 @@
|
||||
/* global wpforms_pluginlanding, wpforms_admin */
|
||||
|
||||
/**
|
||||
* @param wpforms_pluginlanding.activated
|
||||
* @param wpforms_pluginlanding.activated_pro
|
||||
* @param wpforms_pluginlanding.download_now
|
||||
* @param wpforms_pluginlanding.error_could_not_activate
|
||||
* @param wpforms_pluginlanding.error_could_not_install
|
||||
* @param wpforms_pluginlanding.is_activated
|
||||
* @param wpforms_pluginlanding.license_level
|
||||
* @param wpforms_pluginlanding.plugins_page
|
||||
* @param wpforms_pluginlanding.setup_status
|
||||
* @param wpforms_pluginlanding.step3_button_url
|
||||
* @param wpforms_pluginlanding.wpconsent_manual_activate_url
|
||||
* @param wpforms_pluginlanding.wpconsent_manual_install_url
|
||||
*/
|
||||
|
||||
/**
|
||||
* Privacy Compliance Subpage.
|
||||
*
|
||||
* @since 1.9.7.3
|
||||
* @deprecated 1.9.8.6 Use WPFormsPagesCommon instead.
|
||||
*/
|
||||
const WPFormsPagesPrivacyCompliance = window.WPFormsPagesPrivacyCompliance || ( function( document, window, $ ) {
|
||||
/**
|
||||
* Elements.
|
||||
*
|
||||
* @since 1.9.7.3
|
||||
*
|
||||
* @deprecated 1.9.8.6 Use WPFormsPagesCommon instead.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
let el = {};
|
||||
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.9.7.3
|
||||
*
|
||||
* @deprecated 1.9.8.6 Use WPFormsPagesCommon instead.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const app = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.9.7.3
|
||||
*
|
||||
* @deprecated 1.9.8.6 Use WPFormsPagesCommon.init() instead.
|
||||
*/
|
||||
init: () => {
|
||||
console.warn( 'WARNING! Function "WPFormsPagesPrivacyCompliance.init()" has been deprecated, please use the new "WPFormsPagesCommon.init()" function instead!' ); // eslint-disable-line no-console
|
||||
|
||||
$( app.ready );
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.9.7.3
|
||||
*
|
||||
* @deprecated 1.9.8.6 Use WPFormsPagesCommon.ready() instead.
|
||||
*/
|
||||
ready: () => {
|
||||
console.warn( 'WARNING! Function "WPFormsPagesPrivacyCompliance.ready()" has been deprecated, please use the new "WPFormsPagesCommon.ready()" function instead!' ); // eslint-disable-line no-console
|
||||
|
||||
app.initVars();
|
||||
app.events();
|
||||
},
|
||||
|
||||
/**
|
||||
* Init variables.
|
||||
*
|
||||
* @since 1.9.7.3
|
||||
*
|
||||
* @deprecated 1.9.8.6 Use WPFormsPagesCommon.initVars() instead.
|
||||
*/
|
||||
initVars: () => {
|
||||
console.warn( 'WARNING! Function "WPFormsPagesPrivacyCompliance.initVars()" has been deprecated, please use the new "WPFormsPagesCommon.initVars()" function instead!' ); // eslint-disable-line no-console
|
||||
|
||||
el = {
|
||||
$stepInstall: $( 'section.step-install' ),
|
||||
$stepInstallNum: $( 'section.step-install .num img' ),
|
||||
$stepSetup: $( 'section.step-setup' ),
|
||||
$stepSetupNum: $( 'section.step-setup .num img' ),
|
||||
$stepAddon: $( 'section.step-addon' ),
|
||||
$stepAddonNum: $( 'section.step-addon .num img' ),
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Register JS events.
|
||||
*
|
||||
* @since 1.9.7.3
|
||||
*
|
||||
* @deprecated 1.9.8.6 Use WPFormsPagesCommon.events() instead.
|
||||
*/
|
||||
events: () => {
|
||||
console.warn( 'WARNING! Function "WPFormsPagesPrivacyCompliance.events()" has been deprecated, please use the new "WPFormsPagesCommon.events()" function instead!' ); // eslint-disable-line no-console
|
||||
|
||||
// Step the 'Install' button click.
|
||||
el.$stepInstall.on( 'click', 'button', app.stepInstallClick );
|
||||
|
||||
// Step 'Setup' button click.
|
||||
el.$stepSetup.on( 'click', 'button', app.gotoURL );
|
||||
|
||||
// Step the 'Addon' button click.
|
||||
el.$stepAddon.on( 'click', 'button', app.gotoURL );
|
||||
},
|
||||
|
||||
/**
|
||||
* Step the 'Install' button click.
|
||||
*
|
||||
* @since 1.9.7.3
|
||||
*
|
||||
* @deprecated 1.9.8.6 Use WPFormsPagesCommon.stepInstallClick() instead.
|
||||
*
|
||||
* @param {Event} e Event object.
|
||||
*/
|
||||
stepInstallClick: ( e ) => {
|
||||
console.warn( 'WARNING! Function "WPFormsPagesPrivacyCompliance.stepInstallClick()" has been deprecated, please use the new "WPFormsPagesCommon.stepInstallClick()" function instead!' ); // eslint-disable-line no-console
|
||||
|
||||
const $btn = $( e.currentTarget );
|
||||
|
||||
if ( $btn.hasClass( 'disabled' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const action = $btn.attr( 'data-action' );
|
||||
|
||||
let ajaxAction = '';
|
||||
|
||||
switch ( action ) {
|
||||
case 'activate':
|
||||
ajaxAction = 'wpforms_activate_addon';
|
||||
$btn.text( wpforms_pluginlanding.activating );
|
||||
break;
|
||||
|
||||
case 'install':
|
||||
ajaxAction = 'wpforms_install_addon';
|
||||
$btn.text( wpforms_pluginlanding.installing );
|
||||
break;
|
||||
|
||||
case 'goto-url':
|
||||
window.location.href = $btn.attr( 'data-url' );
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
$btn.addClass( 'disabled' );
|
||||
app.showSpinner( el.$stepInstallNum );
|
||||
|
||||
const plugin = $btn.attr( 'data-plugin' );
|
||||
|
||||
const data = {
|
||||
action: ajaxAction,
|
||||
nonce : wpforms_admin.nonce,
|
||||
plugin,
|
||||
type : 'plugin',
|
||||
};
|
||||
$.post( wpforms_admin.ajax_url, data )
|
||||
.done( function( res ) {
|
||||
app.stepInstallDone( res, $btn, action );
|
||||
} )
|
||||
.always( function() {
|
||||
app.hideSpinner( el.$stepInstallNum );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Done part of the step 'Install'.
|
||||
*
|
||||
* @since 1.9.7.3
|
||||
*
|
||||
* @deprecated 1.9.8.6 Use WPFormsPagesCommon.stepInstallDone() instead.
|
||||
*
|
||||
* @param {Object} res Result of $.post() query.
|
||||
* @param {jQuery} $btn Button.
|
||||
* @param {string} action Action (for more info look at the app.stepInstallClick() function).
|
||||
*/
|
||||
stepInstallDone: ( res, $btn, action ) => {
|
||||
console.warn( 'WARNING! Function "WPFormsPagesPrivacyCompliance.stepInstallDone()" has been deprecated, please use the new "WPFormsPagesCommon.stepInstallDone()" function instead!' ); // eslint-disable-line no-console
|
||||
|
||||
const success = 'install' === action ? res.success && res.data.is_activated : res.success;
|
||||
|
||||
if ( success ) {
|
||||
el.$stepInstallNum.attr( 'src', el.$stepInstallNum.attr( 'src' ).replace( 'step-1.', 'step-complete.' ) );
|
||||
$btn.addClass( 'grey' ).removeClass( 'button-primary' ).text( wpforms_pluginlanding.activated );
|
||||
app.stepInstallPluginStatus();
|
||||
} else {
|
||||
const activationFail = ( 'install' === action && res.success && ! res.data.is_activated ) || 'activate' === action,
|
||||
url = ! activationFail ? wpforms_pluginlanding.wpconsent_manual_install_url : wpforms_pluginlanding.wpconsent_manual_activate_url,
|
||||
msg = ! activationFail ? wpforms_pluginlanding.error_could_not_install : wpforms_pluginlanding.error_could_not_activate,
|
||||
btn = ! activationFail ? wpforms_pluginlanding.download_now : wpforms_pluginlanding.plugins_page;
|
||||
|
||||
$btn.removeClass( 'grey disabled' ).text( btn ).attr( 'data-action', 'goto-url' ).attr( 'data-url', url );
|
||||
$btn.after( '<p class="error">' + msg + '</p>' );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback for step 'Install' completion.
|
||||
*
|
||||
* @since 1.9.7.3
|
||||
*
|
||||
* @deprecated 1.9.8.6 Use WPFormsPagesCommon.stepInstallPluginStatus() instead.
|
||||
*/
|
||||
stepInstallPluginStatus: () => {
|
||||
console.warn( 'WARNING! Function "WPFormsPagesPrivacyCompliance.stepInstallPluginStatus()" has been deprecated, please use the new "WPFormsPagesCommon.stepInstallPluginStatus()" function instead!' ); // eslint-disable-line no-console
|
||||
|
||||
const data = {
|
||||
action: 'wpforms_privacy_compliance_page_check_plugin_status',
|
||||
nonce : wpforms_admin.nonce,
|
||||
};
|
||||
$.post( wpforms_admin.ajax_url, data ).done( app.stepInstallPluginStatusDone );
|
||||
},
|
||||
|
||||
/**
|
||||
* Done part of the callback for step 'Install' completion.
|
||||
*
|
||||
* @since 1.9.7.3
|
||||
*
|
||||
* @deprecated 1.9.8.6 Use WPFormsPagesCommon.stepInstallPluginStatusDone() instead.
|
||||
*
|
||||
* @param {Object} res Result of $.post() query.
|
||||
*/
|
||||
stepInstallPluginStatusDone: ( res ) => {
|
||||
console.warn( 'WARNING! Function "WPFormsPagesPrivacyCompliance.stepInstallPluginStatusDone()" has been deprecated, please use the new "WPFormsPagesCommon.stepInstallPluginStatusDone()" function instead!' ); // eslint-disable-line no-console
|
||||
|
||||
if ( ! res.success ) {
|
||||
return;
|
||||
}
|
||||
|
||||
el.$stepSetup.removeClass( 'grey' );
|
||||
el.$stepSetupBtn = el.$stepSetup.find( 'button' );
|
||||
|
||||
if ( res.data.setup_status > 0 ) {
|
||||
el.$stepSetupNum.attr( 'src', el.$stepSetupNum.attr( 'src' ).replace( 'step-2.svg', 'step-complete.svg' ) );
|
||||
el.$stepAddon.removeClass( 'grey' );
|
||||
el.$stepAddonBtn = el.$stepAddon.find( 'button' );
|
||||
|
||||
if ( res.data.license_level === 'pro' ) {
|
||||
el.$stepAddonBtn.text( wpforms_pluginlanding.activated_pro );
|
||||
el.$stepAddonNum.attr( 'src', el.$stepAddonNum.attr( 'src' ).replace( 'step-3.svg', 'step-complete.svg' ) );
|
||||
} else {
|
||||
el.$stepAddonBtn.attr( 'data-url', res.data.step3_button_url );
|
||||
el.$stepAddonBtn.removeClass( 'grey disabled' ).addClass( 'button-primary' );
|
||||
}
|
||||
} else {
|
||||
el.$stepSetupBtn.removeClass( 'grey disabled' ).addClass( 'button-primary' );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Go to URL.
|
||||
*
|
||||
* @since 1.9.7.3
|
||||
*
|
||||
* @deprecated 1.9.8.6 Use WPFormsPagesCommon.gotoURL() instead.
|
||||
*
|
||||
* @param {Event} e Event object.
|
||||
*/
|
||||
gotoURL: ( e ) => { // eslint-disable-line no-unused-vars
|
||||
console.warn( 'WARNING! Function "WPFormsPagesPrivacyCompliance.gotoURL()" has been deprecated, please use the new "WPFormsPagesCommon.gotoURL()" function instead!' ); // eslint-disable-line no-console
|
||||
|
||||
const $btn = $( e.currentTarget ),
|
||||
url = $btn.attr( 'data-url' );
|
||||
|
||||
if ( $btn.hasClass( 'disabled' ) || ! url ) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.location.href = url;
|
||||
},
|
||||
|
||||
/**
|
||||
* Show spinner.
|
||||
*
|
||||
* @since 1.9.7.3
|
||||
*
|
||||
* @deprecated 1.9.8.6 Use WPFormsPagesCommon.showSpinner() instead.
|
||||
*
|
||||
* @param {jQuery} $el Element.
|
||||
*/
|
||||
showSpinner: ( $el ) => {
|
||||
console.warn( 'WARNING! Function "WPFormsPagesPrivacyCompliance.showSpinner()" has been deprecated, please use the new "WPFormsPagesCommon.showSpinner()" function instead!' ); // eslint-disable-line no-console
|
||||
|
||||
$el.siblings( 'i.loader' ).removeClass( 'hidden' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide spinner.
|
||||
*
|
||||
* @since 1.9.7.3
|
||||
*
|
||||
* @deprecated 1.9.8.6 Use WPFormsPagesCommon.hideSpinner() instead.
|
||||
*
|
||||
* @param {jQuery} $el Element.
|
||||
*/
|
||||
hideSpinner: ( $el ) => {
|
||||
console.warn( 'WARNING! Function "WPFormsPagesPrivacyCompliance.hideSpinner()" has been deprecated, please use the new "WPFormsPagesCommon.hideSpinner()" function instead!' ); // eslint-disable-line no-console
|
||||
|
||||
$el.show();
|
||||
$el.siblings( 'i.loader' ).addClass( 'hidden' );
|
||||
},
|
||||
};
|
||||
|
||||
// Provide public access to functions and properties.
|
||||
return app;
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
// Initialize.
|
||||
WPFormsPagesPrivacyCompliance.init();
|
||||
+1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,259 @@
|
||||
/* global wpforms_pluginlanding, wpforms_admin */
|
||||
|
||||
/**
|
||||
* SMTP Sub-page.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var WPFormsPagesSMTP = window.WPFormsPagesSMTP || ( function( document, window, $ ) {
|
||||
|
||||
/**
|
||||
* Elements.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
var el = {};
|
||||
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
var app = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
init: function() {
|
||||
|
||||
$( app.ready );
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
ready: function() {
|
||||
|
||||
app.initVars();
|
||||
app.events();
|
||||
},
|
||||
|
||||
/**
|
||||
* Init variables.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
initVars: function() {
|
||||
|
||||
el = {
|
||||
$stepInstall: $( 'section.step-install' ),
|
||||
$stepInstallNum: $( 'section.step-install .num img' ),
|
||||
$stepSetup: $( 'section.step-setup' ),
|
||||
$stepSetupNum: $( 'section.step-setup .num img' ),
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Register JS events.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
events: function() {
|
||||
|
||||
// Step 'Install' button click.
|
||||
el.$stepInstall.on( 'click', 'button', app.stepInstallClick );
|
||||
|
||||
// Step 'Setup' button click.
|
||||
el.$stepSetup.on( 'click', 'button', app.gotoURL );
|
||||
},
|
||||
|
||||
/**
|
||||
* Step 'Install' button click.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
stepInstallClick: function() {
|
||||
|
||||
const $btn = $( this );
|
||||
|
||||
if ( $btn.hasClass( 'disabled' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const action = $btn.attr( 'data-action' );
|
||||
let ajaxAction = '';
|
||||
|
||||
switch ( action ) {
|
||||
case 'activate':
|
||||
ajaxAction = 'wpforms_activate_addon';
|
||||
$btn.text( wpforms_pluginlanding.activating );
|
||||
break;
|
||||
|
||||
case 'install':
|
||||
ajaxAction = 'wpforms_install_addon';
|
||||
$btn.text( wpforms_pluginlanding.installing );
|
||||
break;
|
||||
|
||||
case 'goto-url':
|
||||
window.location.href = $btn.attr( 'data-url' );
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
$btn.addClass( 'disabled' );
|
||||
app.showSpinner( el.$stepInstallNum );
|
||||
|
||||
const plugin = $btn.attr( 'data-plugin' ),
|
||||
source = $btn.attr( 'data-source' );
|
||||
|
||||
const data = {
|
||||
action: ajaxAction,
|
||||
nonce: wpforms_admin.nonce,
|
||||
plugin,
|
||||
type: 'plugin',
|
||||
source,
|
||||
};
|
||||
|
||||
$.post( wpforms_admin.ajax_url, data )
|
||||
.done( function( res ) {
|
||||
app.stepInstallDone( res, $btn, action );
|
||||
} )
|
||||
.always( function() {
|
||||
app.hideSpinner( el.$stepInstallNum );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Done part of the 'Install' step.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @param {object} res Result of $.post() query.
|
||||
* @param {jQuery} $btn Button.
|
||||
* @param {string} action Action (for more info look at the app.stepInstallClick() function).
|
||||
*/
|
||||
stepInstallDone: function( res, $btn, action ) {
|
||||
|
||||
var success = 'install' === action ? res.success && res.data.is_activated : res.success;
|
||||
|
||||
if ( success ) {
|
||||
el.$stepInstallNum.attr( 'src', el.$stepInstallNum.attr( 'src' ).replace( 'step-1.', 'step-complete.' ) );
|
||||
$btn.addClass( 'grey' ).removeClass( 'button-primary' ).text( wpforms_pluginlanding.activated );
|
||||
app.stepInstallPluginStatus();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var activationFail = ( 'install' === action && res.success && ! res.data.is_activated ) || 'activate' === action,
|
||||
url = ! activationFail ? wpforms_pluginlanding.manual_install_url : wpforms_pluginlanding.manual_activate_url,
|
||||
msg = ! activationFail ? wpforms_pluginlanding.error_could_not_install : wpforms_pluginlanding.error_could_not_activate,
|
||||
btn = ! activationFail ? wpforms_pluginlanding.download_now : wpforms_pluginlanding.plugins_page;
|
||||
|
||||
$btn.removeClass( 'grey disabled' ).text( btn ).attr( 'data-action', 'goto-url' ).attr( 'data-url', url );
|
||||
$btn.after( '<p class="error">' + msg + '</p>' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback for step 'Install' completion.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
stepInstallPluginStatus: function() {
|
||||
|
||||
var data = {
|
||||
action: 'wpforms_smtp_page_check_plugin_status',
|
||||
nonce : wpforms_admin.nonce,
|
||||
};
|
||||
|
||||
$.post( wpforms_admin.ajax_url, data )
|
||||
.done( app.stepInstallPluginStatusDone );
|
||||
},
|
||||
|
||||
/**
|
||||
* Done part of the callback for step 'Install' completion.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @param {object} res Result of $.post() query.
|
||||
*/
|
||||
stepInstallPluginStatusDone: function( res ) {
|
||||
|
||||
if ( ! res.success ) {
|
||||
return;
|
||||
}
|
||||
|
||||
el.$stepSetup.removeClass( 'grey' );
|
||||
el.$stepSetupBtn = el.$stepSetup.find( 'button' );
|
||||
el.$stepSetupBtn.removeClass( 'grey disabled' ).addClass( 'button-primary' );
|
||||
|
||||
if ( res.data.setup_status > 0 ) {
|
||||
el.$stepSetupNum.attr( 'src', el.$stepSetupNum.attr( 'src' ).replace( 'step-2.svg', 'step-complete.svg' ) );
|
||||
el.$stepSetupBtn.attr( 'data-url', wpforms_pluginlanding.smtp_settings_url ).text( wpforms_pluginlanding.smtp_settings );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
el.$stepSetupBtn.attr( 'data-url', wpforms_pluginlanding.smtp_wizard_url ).text( wpforms_pluginlanding.smtp_wizard );
|
||||
},
|
||||
|
||||
/**
|
||||
* Go to URL by click on the button.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*/
|
||||
gotoURL: function() {
|
||||
|
||||
var $btn = $( this );
|
||||
|
||||
if ( $btn.hasClass( 'disabled' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.location.href = $btn.attr( 'data-url' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Display spinner.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @param {jQuery} $el Section number image jQuery object.
|
||||
*/
|
||||
showSpinner: function( $el ) {
|
||||
|
||||
$el.siblings( '.loader' ).removeClass( 'hidden' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide spinner.
|
||||
*
|
||||
* @since 1.5.7
|
||||
*
|
||||
* @param {jQuery} $el Section number image jQuery object.
|
||||
*/
|
||||
hideSpinner: function( $el ) {
|
||||
|
||||
$el.siblings( '.loader' ).addClass( 'hidden' );
|
||||
},
|
||||
};
|
||||
|
||||
// Provide access to public functions/properties.
|
||||
return app;
|
||||
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
// Initialize.
|
||||
WPFormsPagesSMTP.init();
|
||||
+1
@@ -0,0 +1 @@
|
||||
var WPFormsPagesSMTP=window.WPFormsPagesSMTP||((l,i)=>{var r={},p={init:function(){i(p.ready)},ready:function(){p.initVars(),p.events()},initVars:function(){r={$stepInstall:i("section.step-install"),$stepInstallNum:i("section.step-install .num img"),$stepSetup:i("section.step-setup"),$stepSetupNum:i("section.step-setup .num img")}},events:function(){r.$stepInstall.on("click","button",p.stepInstallClick),r.$stepSetup.on("click","button",p.gotoURL)},stepInstallClick:function(){let n=i(this);if(!n.hasClass("disabled")){let s=n.attr("data-action"),t="";switch(s){case"activate":t="wpforms_activate_addon",n.text(wpforms_pluginlanding.activating);break;case"install":t="wpforms_install_addon",n.text(wpforms_pluginlanding.installing);break;case"goto-url":return void(l.location.href=n.attr("data-url"));default:return}n.addClass("disabled"),p.showSpinner(r.$stepInstallNum);var a=n.attr("data-plugin"),e=n.attr("data-source"),a={action:t,nonce:wpforms_admin.nonce,plugin:a,type:"plugin",source:e};i.post(wpforms_admin.ajax_url,a).done(function(t){p.stepInstallDone(t,n,s)}).always(function(){p.hideSpinner(r.$stepInstallNum)})}},stepInstallDone:function(t,s,n){var a;("install"===n?t.success&&t.data.is_activated:t.success)?(r.$stepInstallNum.attr("src",r.$stepInstallNum.attr("src").replace("step-1.","step-complete.")),s.addClass("grey").removeClass("button-primary").text(wpforms_pluginlanding.activated),p.stepInstallPluginStatus()):(n=(t="install"===n&&t.success&&!t.data.is_activated||"activate"===n)?wpforms_pluginlanding.manual_activate_url:wpforms_pluginlanding.manual_install_url,a=t?wpforms_pluginlanding.error_could_not_activate:wpforms_pluginlanding.error_could_not_install,t=t?wpforms_pluginlanding.plugins_page:wpforms_pluginlanding.download_now,s.removeClass("grey disabled").text(t).attr("data-action","goto-url").attr("data-url",n),s.after('<p class="error">'+a+"</p>"))},stepInstallPluginStatus:function(){var t={action:"wpforms_smtp_page_check_plugin_status",nonce:wpforms_admin.nonce};i.post(wpforms_admin.ajax_url,t).done(p.stepInstallPluginStatusDone)},stepInstallPluginStatusDone:function(t){t.success&&(r.$stepSetup.removeClass("grey"),r.$stepSetupBtn=r.$stepSetup.find("button"),r.$stepSetupBtn.removeClass("grey disabled").addClass("button-primary"),0<t.data.setup_status?(r.$stepSetupNum.attr("src",r.$stepSetupNum.attr("src").replace("step-2.svg","step-complete.svg")),r.$stepSetupBtn.attr("data-url",wpforms_pluginlanding.smtp_settings_url).text(wpforms_pluginlanding.smtp_settings)):r.$stepSetupBtn.attr("data-url",wpforms_pluginlanding.smtp_wizard_url).text(wpforms_pluginlanding.smtp_wizard))},gotoURL:function(){var t=i(this);t.hasClass("disabled")||(l.location.href=t.attr("data-url"))},showSpinner:function(t){t.siblings(".loader").removeClass("hidden")},hideSpinner:function(t){t.siblings(".loader").addClass("hidden")}};return p})((document,window),jQuery);WPFormsPagesSMTP.init();
|
||||
Reference in New Issue
Block a user