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:
+110
@@ -0,0 +1,110 @@
|
||||
/* global wpforms_builder_lite, wpforms_builder, Choices, wpf */
|
||||
|
||||
// noinspection ES6ConvertVarToLetConst
|
||||
|
||||
/**
|
||||
* @param wpforms_builder_lite.disable_notifications
|
||||
*/
|
||||
|
||||
var WPFormsBuilderLite = window.WPFormsBuilderLite || ( function( document, window, $ ) { // eslint-disable-line no-var
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const app = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
init() {
|
||||
// Document ready
|
||||
$( app.ready );
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
ready() {
|
||||
app.bindUIActions();
|
||||
},
|
||||
|
||||
/**
|
||||
* Element bindings.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
bindUIActions() {
|
||||
// Warn users if they disable email notifications.
|
||||
$( document ).on( 'change', '#wpforms-panel-field-settings-notification_enable', function() {
|
||||
app.formBuilderNotificationAlert( $( this ).is( ':checked' ) );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Warn users if they disable email notifications.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @param {boolean} value Whether notifications enabled or not. 0 is disabled, 1 is enabled.
|
||||
*/
|
||||
formBuilderNotificationAlert( value ) {
|
||||
if ( value !== false ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.alert( {
|
||||
title: wpforms_builder.heads_up,
|
||||
content: wpforms_builder_lite.disable_notifications,
|
||||
icon: 'fa fa-exclamation-circle',
|
||||
type: 'orange',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: wpforms_builder.ok,
|
||||
btnClass: 'btn-confirm',
|
||||
keys: [ 'enter' ],
|
||||
},
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Initialize Choices.js for the Coupon field.
|
||||
*
|
||||
* @since 1.9.4
|
||||
*/
|
||||
initCouponsChoicesJS() {
|
||||
if ( typeof window.Choices !== 'function' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$( '.wpforms-field-option-row-allowed_coupons select:not(.choices__input)' ).each( function() {
|
||||
const $select = $( this );
|
||||
const choicesInstance = new Choices(
|
||||
$select.get( 0 ),
|
||||
{
|
||||
shouldSort: false,
|
||||
removeItemButton: true,
|
||||
renderChoicesLimit: 5,
|
||||
callbackOnInit() {
|
||||
wpf.showMoreButtonForChoices( this.containerOuter.element );
|
||||
},
|
||||
} );
|
||||
|
||||
// Save Choices.js instance for future access.
|
||||
$select.data( 'choicesjs', choicesInstance );
|
||||
} );
|
||||
},
|
||||
};
|
||||
|
||||
// Provide access to public functions/properties.
|
||||
return app;
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
WPFormsBuilderLite.init();
|
||||
Vendored
Executable
+1
@@ -0,0 +1 @@
|
||||
var WPFormsBuilderLite=window.WPFormsBuilderLite||((e,i,t)=>{let o={init(){t(o.ready)},ready(){o.bindUIActions()},bindUIActions(){t(e).on("change","#wpforms-panel-field-settings-notification_enable",function(){o.formBuilderNotificationAlert(t(this).is(":checked"))})},formBuilderNotificationAlert(e){!1===e&&t.alert({title:wpforms_builder.heads_up,content:wpforms_builder_lite.disable_notifications,icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_builder.ok,btnClass:"btn-confirm",keys:["enter"]}}})},initCouponsChoicesJS(){"function"==typeof i.Choices&&t(".wpforms-field-option-row-allowed_coupons select:not(.choices__input)").each(function(){var e=t(this),i=new Choices(e.get(0),{shouldSort:!1,removeItemButton:!0,renderChoicesLimit:5,callbackOnInit(){wpf.showMoreButtonForChoices(this.containerOuter.element)}});e.data("choicesjs",i)})}};return o})(document,window,jQuery);WPFormsBuilderLite.init();
|
||||
@@ -0,0 +1,181 @@
|
||||
/* global wpforms_admin */
|
||||
/**
|
||||
* Connect functionality.
|
||||
*
|
||||
* @since 1.5.4
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var WPFormsConnect = window.WPFormsConnect || ( function( document, window, $ ) {
|
||||
|
||||
/**
|
||||
* Elements reference.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
var el = {
|
||||
$connectBtn: $( '#wpforms-settings-connect-btn' ),
|
||||
$connectKey: $( '#wpforms-settings-upgrade-license-key' ),
|
||||
};
|
||||
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*
|
||||
* @type {object}
|
||||
*/
|
||||
var app = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*/
|
||||
init: function() {
|
||||
|
||||
$( app.ready );
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*/
|
||||
ready: function() {
|
||||
|
||||
app.events();
|
||||
},
|
||||
|
||||
/**
|
||||
* Register JS events.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*/
|
||||
events: function() {
|
||||
|
||||
app.connectBtnClick();
|
||||
},
|
||||
|
||||
/**
|
||||
* Register connect button event.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*/
|
||||
connectBtnClick: function() {
|
||||
el.$connectBtn.on( 'click', function( event ) {
|
||||
event.preventDefault();
|
||||
app.gotoUpgradeUrl();
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the alert arguments in case of Pro already installed.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*
|
||||
* @param {object} res Ajax query result object.
|
||||
*
|
||||
* @returns {object} Alert arguments.
|
||||
*/
|
||||
proAlreadyInstalled: function( res ) {
|
||||
|
||||
var buttons = {
|
||||
confirm: {
|
||||
text: wpforms_admin.plugin_activate_btn,
|
||||
btnClass: 'btn-confirm',
|
||||
keys: [ 'enter' ],
|
||||
action: function() {
|
||||
window.location.reload();
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
title: wpforms_admin.almost_done,
|
||||
content: res.data.message,
|
||||
icon: 'fa fa-check-circle',
|
||||
type: 'green',
|
||||
buttons: buttons,
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Go to upgrade url.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*/
|
||||
gotoUpgradeUrl: function() {
|
||||
|
||||
var data = {
|
||||
action: 'wpforms_connect_url',
|
||||
key: el.$connectKey.val(),
|
||||
nonce: wpforms_admin.nonce,
|
||||
};
|
||||
|
||||
$.post( wpforms_admin.ajax_url, data )
|
||||
.done( function( res ) {
|
||||
|
||||
if ( res.success ) {
|
||||
if ( res.data.reload ) {
|
||||
$.alert( app.proAlreadyInstalled( res ) );
|
||||
return;
|
||||
}
|
||||
window.location.href = res.data.url;
|
||||
return;
|
||||
}
|
||||
$.alert( {
|
||||
title: wpforms_admin.oops,
|
||||
content: res.data.message,
|
||||
icon: 'fa fa-exclamation-circle',
|
||||
type: 'orange',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: wpforms_admin.ok,
|
||||
btnClass: 'btn-confirm',
|
||||
keys: [ 'enter' ],
|
||||
},
|
||||
},
|
||||
} );
|
||||
} )
|
||||
.fail( function( xhr ) {
|
||||
|
||||
app.failAlert( xhr );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Alert in case of server error.
|
||||
*
|
||||
* @since 1.5.5
|
||||
*
|
||||
* @param {object} xhr XHR object.
|
||||
*/
|
||||
failAlert: function( xhr ) {
|
||||
|
||||
$.alert( {
|
||||
title: wpforms_admin.oops,
|
||||
content: wpforms_admin.server_error + '<br>' + xhr.status + ' ' + xhr.statusText + ' ' + xhr.responseText,
|
||||
icon: 'fa fa-exclamation-circle',
|
||||
type: 'orange',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: wpforms_admin.ok,
|
||||
btnClass: 'btn-confirm',
|
||||
keys: [ 'enter' ],
|
||||
},
|
||||
},
|
||||
} );
|
||||
},
|
||||
};
|
||||
|
||||
// Provide access to public functions/properties.
|
||||
return app;
|
||||
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
// Initialize.
|
||||
WPFormsConnect.init();
|
||||
+1
@@ -0,0 +1 @@
|
||||
var WPFormsConnect=window.WPFormsConnect||((e,t)=>{var o={$connectBtn:t("#wpforms-settings-connect-btn"),$connectKey:t("#wpforms-settings-upgrade-license-key")},r={init:function(){t(r.ready)},ready:function(){r.events()},events:function(){r.connectBtnClick()},connectBtnClick:function(){o.$connectBtn.on("click",function(n){n.preventDefault(),r.gotoUpgradeUrl()})},proAlreadyInstalled:function(n){var t={confirm:{text:wpforms_admin.plugin_activate_btn,btnClass:"btn-confirm",keys:["enter"],action:function(){e.location.reload()}}};return{title:wpforms_admin.almost_done,content:n.data.message,icon:"fa fa-check-circle",type:"green",buttons:t}},gotoUpgradeUrl:function(){var n={action:"wpforms_connect_url",key:o.$connectKey.val(),nonce:wpforms_admin.nonce};t.post(wpforms_admin.ajax_url,n).done(function(n){if(n.success)return n.data.reload?void t.alert(r.proAlreadyInstalled(n)):void(e.location.href=n.data.url);t.alert({title:wpforms_admin.oops,content:n.data.message,icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_admin.ok,btnClass:"btn-confirm",keys:["enter"]}}})}).fail(function(n){r.failAlert(n)})},failAlert:function(n){t.alert({title:wpforms_admin.oops,content:wpforms_admin.server_error+"<br>"+n.status+" "+n.statusText+" "+n.responseText,icon:"fa fa-exclamation-circle",type:"orange",buttons:{confirm:{text:wpforms_admin.ok,btnClass:"btn-confirm",keys:["enter"]}}})}};return r})((document,window),jQuery);WPFormsConnect.init();
|
||||
@@ -0,0 +1,382 @@
|
||||
/* global wpforms_dashboard_widget, moment, Chart, ajaxurl */
|
||||
/**
|
||||
* WPForms Dashboard Widget function.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
|
||||
const WPFormsDashboardWidget = window.WPFormsDashboardWidget || ( function( document, window, $ ) {
|
||||
/**
|
||||
* Elements reference.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const el = {
|
||||
$widget: $( '#wpforms_reports_widget_lite' ),
|
||||
$settingsBtn: $( '#wpforms-dash-widget-settings-button' ),
|
||||
$canvas: $( '#wpforms-dash-widget-chart' ),
|
||||
$chartDismissButton: $( '.wpforms-dash-widget-dismiss-chart-upgrade' ),
|
||||
$dismissButton: $( '.wpforms-dash-widget-dismiss-icon' ),
|
||||
$recommendedBlockDismissButton: $( '#wpforms-dash-widget-dismiss-recommended-plugin-block' ),
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the site is RTL.
|
||||
*
|
||||
* @since 1.9.1
|
||||
*/
|
||||
const isRTL = $( 'body' ).hasClass( 'rtl' );
|
||||
|
||||
/**
|
||||
* Chart.js functions and properties.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
// eslint-disable-next-line no-var
|
||||
var chart = {
|
||||
|
||||
/**
|
||||
* Chart.js instance.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
instance: null,
|
||||
|
||||
/**
|
||||
* Chart.js settings.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
settings: {
|
||||
type : 'line',
|
||||
data : {
|
||||
labels : [],
|
||||
datasets: [ {
|
||||
label : wpforms_dashboard_widget.i18n.entries,
|
||||
data : [],
|
||||
backgroundColor : 'rgba(255, 129, 0, 0.135)',
|
||||
borderColor : 'rgba(211, 126, 71, 1)',
|
||||
borderWidth : 2,
|
||||
pointRadius : 4,
|
||||
pointBorderWidth : 1,
|
||||
pointBackgroundColor: 'rgba(255, 255, 255, 1)',
|
||||
} ],
|
||||
},
|
||||
options: {
|
||||
maintainAspectRatio: false,
|
||||
scales : {
|
||||
x: {
|
||||
type : 'timeseries',
|
||||
reverse: isRTL,
|
||||
ticks : {
|
||||
source : 'labels',
|
||||
padding : 10,
|
||||
minRotation: 25,
|
||||
maxRotation: 25,
|
||||
callback( value, index, values ) {
|
||||
// Distribute the ticks equally starting from a right side of xAxis.
|
||||
const gap = Math.floor( values.length / 7 );
|
||||
|
||||
if ( gap < 1 ) {
|
||||
return moment( value ).format( 'MMM D' );
|
||||
}
|
||||
if ( ( values.length - index - 1 ) % gap === 0 ) {
|
||||
return moment( value ).format( 'MMM D' );
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
y: {
|
||||
beginAtZero : true,
|
||||
ticks: {
|
||||
maxTicksLimit: 6,
|
||||
padding : 20,
|
||||
callback( value ) {
|
||||
// Make sure the tick value has no decimals.
|
||||
if ( Math.floor( value ) === value ) {
|
||||
return value;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
elements: {
|
||||
line: {
|
||||
tension: 0,
|
||||
fill: true,
|
||||
},
|
||||
},
|
||||
animation: false,
|
||||
plugins: {
|
||||
legend: {
|
||||
display: false,
|
||||
},
|
||||
tooltip: {
|
||||
displayColors: false,
|
||||
rtl: isRTL,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Init Chart.js.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
init() {
|
||||
if ( ! el.$canvas.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
chart.injectChartScript();
|
||||
},
|
||||
|
||||
/**
|
||||
* Inject the Chart.js script into the page and trigger initialization.
|
||||
*
|
||||
* @since 1.9.7.3
|
||||
*/
|
||||
injectChartScript() {
|
||||
if ( ! wpforms_dashboard_widget.adapter_path ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const script = document.createElement( 'script' );
|
||||
script.src = wpforms_dashboard_widget.adapter_path;
|
||||
script.onload = chart.initializeChart;
|
||||
script.onerror = function( err ) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log( 'Script injection failed:', err );
|
||||
};
|
||||
document.body.appendChild( script );
|
||||
},
|
||||
|
||||
/**
|
||||
* Initialize Chart.js with the provided settings.
|
||||
*
|
||||
* @since 1.9.7.3
|
||||
*/
|
||||
initializeChart() {
|
||||
const ctx = el.$canvas[ 0 ].getContext( '2d' );
|
||||
|
||||
chart.instance = new Chart( ctx, chart.settings );
|
||||
|
||||
chart.updateUI();
|
||||
},
|
||||
|
||||
/**
|
||||
* Update Chart.js canvas.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
updateUI() {
|
||||
chart.updateWithDummyData();
|
||||
|
||||
chart.instance.data.labels = chart.settings.data.labels;
|
||||
chart.instance.data.datasets[ 0 ].data = chart.settings.data.datasets[ 0 ].data;
|
||||
|
||||
chart.instance.update();
|
||||
},
|
||||
|
||||
/**
|
||||
* Update Chart.js settings with dummy data.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
updateWithDummyData() {
|
||||
const end = moment().endOf( 'day' );
|
||||
let date;
|
||||
|
||||
const minY = 5;
|
||||
const maxY = 20;
|
||||
let i;
|
||||
|
||||
for ( i = 1; i <= 7; i++ ) {
|
||||
date = end.clone().subtract( i, 'days' );
|
||||
|
||||
chart.settings.data.labels.push( date );
|
||||
chart.settings.data.datasets[ 0 ].data.push( {
|
||||
x: date,
|
||||
y: Math.floor( Math.random() * ( maxY - minY + 1 ) ) + minY,
|
||||
} );
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
// eslint-disable-next-line no-var
|
||||
var app = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
init() {
|
||||
$( app.ready );
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
ready() {
|
||||
chart.init();
|
||||
app.events();
|
||||
app.graphSettings();
|
||||
},
|
||||
|
||||
/**
|
||||
* Graph settings related events.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
graphSettings() {
|
||||
el.$settingsBtn.on( 'click', function() {
|
||||
$( this ).siblings( '.wpforms-dash-widget-settings-menu' ).toggle();
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Register JS events.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
events() {
|
||||
app.formsListEvents();
|
||||
app.handleChartClose();
|
||||
app.handleRecommendedPluginsClose();
|
||||
app.handleWidgetBlockClose();
|
||||
},
|
||||
|
||||
/**
|
||||
* Register forms list area JS events.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
formsListEvents() {
|
||||
el.$widget.on( 'click', '#wpforms-dash-widget-forms-more', function() {
|
||||
app.toggleCompleteFormsList();
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle chart close.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
handleChartClose() {
|
||||
el.$chartDismissButton.on( 'click', function( event ) {
|
||||
event.preventDefault();
|
||||
app.saveWidgetMeta( 'hide_graph', 1 );
|
||||
$( '.wpforms-dash-widget.wpforms-lite' ).addClass( 'wpforms-dash-widget-no-graph' );
|
||||
$( this ).closest( '.wpforms-dash-widget-chart-block-container' ).remove();
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle recommended plugins block close.
|
||||
*
|
||||
* @since 1.7.4
|
||||
* @since 1.8.7 Deprecated.
|
||||
*
|
||||
* @deprecated Use WPFormsDashboardWidget.handleWidgetBlockClose() instead.
|
||||
*/
|
||||
handleRecommendedPluginsClose() {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn( 'WARNING! WPFormsDashboardWidget.handleRecommendedPluginsClose() has been deprecated, please use WPFormsDashboardWidget.handleWidgetBlockClose() instead.' );
|
||||
|
||||
el.$recommendedBlockDismissButton.on( 'click', function() {
|
||||
app.dismissRecommendedBlock();
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle widget block close.
|
||||
*
|
||||
* @since 1.8.7
|
||||
*/
|
||||
handleWidgetBlockClose() {
|
||||
el.$dismissButton.on( 'click', function() {
|
||||
app.dismissWidgetBlock( $( this ) );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Save dashboard widget meta on a backend.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @param {string} meta Meta name to save.
|
||||
* @param {number} value Value to save.
|
||||
*/
|
||||
saveWidgetMeta( meta, value ) {
|
||||
const data = {
|
||||
_wpnonce: wpforms_dashboard_widget.nonce,
|
||||
action : 'wpforms_' + wpforms_dashboard_widget.slug + '_save_widget_meta',
|
||||
meta,
|
||||
value,
|
||||
};
|
||||
|
||||
$.post( ajaxurl, data );
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle forms list hidden entries.
|
||||
*
|
||||
* @since 1.5.0.4
|
||||
*/
|
||||
toggleCompleteFormsList() {
|
||||
$( '#wpforms-dash-widget-forms-list-table .wpforms-dash-widget-forms-list-hidden-el' ).toggle();
|
||||
$( '#wpforms-dash-widget-forms-more' ).html( function( i, html ) {
|
||||
return html === wpforms_dashboard_widget.show_less_html ? wpforms_dashboard_widget.show_more_html : wpforms_dashboard_widget.show_less_html;
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Dismiss widget block.
|
||||
*
|
||||
* @since 1.8.7
|
||||
*
|
||||
* @param {Object} $clickedButton jQuery object of the clicked button.
|
||||
*/
|
||||
dismissWidgetBlock( $clickedButton ) {
|
||||
$clickedButton.closest( '.wpforms-dash-widget-block' ).remove();
|
||||
app.saveWidgetMeta( $clickedButton.data( 'field' ), 1 );
|
||||
},
|
||||
|
||||
/**
|
||||
* Dismiss recommended plugin block.
|
||||
*
|
||||
* @since 1.7.4
|
||||
* @since 1.8.7 Deprecated.
|
||||
*
|
||||
* @deprecated Use WPFormsDashboardWidget.dismissWidgetBlock() instead.
|
||||
*/
|
||||
dismissRecommendedBlock() {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn( 'WARNING! WPFormsDashboardWidget.dismissRecommendedBlock() has been deprecated, please use WPFormsDashboardWidget.dismissWidgetBlock() instead.' );
|
||||
|
||||
$( '.wpforms-dash-widget-recommended-plugin-block' ).remove();
|
||||
app.saveWidgetMeta( 'hide_recommended_block', 1 );
|
||||
},
|
||||
};
|
||||
|
||||
// Provide access to public functions/properties.
|
||||
return app;
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
// Initialize.
|
||||
WPFormsDashboardWidget.init();
|
||||
+1
@@ -0,0 +1 @@
|
||||
let WPFormsDashboardWidget=window.WPFormsDashboardWidget||((t,s)=>{let a={$widget:s("#wpforms_reports_widget_lite"),$settingsBtn:s("#wpforms-dash-widget-settings-button"),$canvas:s("#wpforms-dash-widget-chart"),$chartDismissButton:s(".wpforms-dash-widget-dismiss-chart-upgrade"),$dismissButton:s(".wpforms-dash-widget-dismiss-icon"),$recommendedBlockDismissButton:s("#wpforms-dash-widget-dismiss-recommended-plugin-block")};var e=s("body").hasClass("rtl"),i={instance:null,settings:{type:"line",data:{labels:[],datasets:[{label:wpforms_dashboard_widget.i18n.entries,data:[],backgroundColor:"rgba(255, 129, 0, 0.135)",borderColor:"rgba(211, 126, 71, 1)",borderWidth:2,pointRadius:4,pointBorderWidth:1,pointBackgroundColor:"rgba(255, 255, 255, 1)"}]},options:{maintainAspectRatio:!1,scales:{x:{type:"timeseries",reverse:e,ticks:{source:"labels",padding:10,minRotation:25,maxRotation:25,callback(e,t,s){var a=Math.floor(s.length/7);return a<1||(s.length-t-1)%a==0?moment(e).format("MMM D"):void 0}}},y:{beginAtZero:!0,ticks:{maxTicksLimit:6,padding:20,callback(e){if(Math.floor(e)===e)return e}}}},elements:{line:{tension:0,fill:!0}},animation:!1,plugins:{legend:{display:!1},tooltip:{displayColors:!1,rtl:e}}}},init(){a.$canvas.length&&i.injectChartScript()},injectChartScript(){var e;wpforms_dashboard_widget.adapter_path&&((e=t.createElement("script")).src=wpforms_dashboard_widget.adapter_path,e.onload=i.initializeChart,e.onerror=function(e){console.log("Script injection failed:",e)},t.body.appendChild(e))},initializeChart(){var e=a.$canvas[0].getContext("2d");i.instance=new Chart(e,i.settings),i.updateUI()},updateUI(){i.updateWithDummyData(),i.instance.data.labels=i.settings.data.labels,i.instance.data.datasets[0].data=i.settings.data.datasets[0].data,i.instance.update()},updateWithDummyData(){var e,t=moment().endOf("day");let s;for(s=1;s<=7;s++)e=t.clone().subtract(s,"days"),i.settings.data.labels.push(e),i.settings.data.datasets[0].data.push({x:e,y:Math.floor(16*Math.random())+5})}},o={init(){s(o.ready)},ready(){i.init(),o.events(),o.graphSettings()},graphSettings(){a.$settingsBtn.on("click",function(){s(this).siblings(".wpforms-dash-widget-settings-menu").toggle()})},events(){o.formsListEvents(),o.handleChartClose(),o.handleRecommendedPluginsClose(),o.handleWidgetBlockClose()},formsListEvents(){a.$widget.on("click","#wpforms-dash-widget-forms-more",function(){o.toggleCompleteFormsList()})},handleChartClose(){a.$chartDismissButton.on("click",function(e){e.preventDefault(),o.saveWidgetMeta("hide_graph",1),s(".wpforms-dash-widget.wpforms-lite").addClass("wpforms-dash-widget-no-graph"),s(this).closest(".wpforms-dash-widget-chart-block-container").remove()})},handleRecommendedPluginsClose(){console.warn("WARNING! WPFormsDashboardWidget.handleRecommendedPluginsClose() has been deprecated, please use WPFormsDashboardWidget.handleWidgetBlockClose() instead."),a.$recommendedBlockDismissButton.on("click",function(){o.dismissRecommendedBlock()})},handleWidgetBlockClose(){a.$dismissButton.on("click",function(){o.dismissWidgetBlock(s(this))})},saveWidgetMeta(e,t){e={_wpnonce:wpforms_dashboard_widget.nonce,action:"wpforms_"+wpforms_dashboard_widget.slug+"_save_widget_meta",meta:e,value:t};s.post(ajaxurl,e)},toggleCompleteFormsList(){s("#wpforms-dash-widget-forms-list-table .wpforms-dash-widget-forms-list-hidden-el").toggle(),s("#wpforms-dash-widget-forms-more").html(function(e,t){return t===wpforms_dashboard_widget.show_less_html?wpforms_dashboard_widget.show_more_html:wpforms_dashboard_widget.show_less_html})},dismissWidgetBlock(e){e.closest(".wpforms-dash-widget-block").remove(),o.saveWidgetMeta(e.data("field"),1)},dismissRecommendedBlock(){console.warn("WARNING! WPFormsDashboardWidget.dismissRecommendedBlock() has been deprecated, please use WPFormsDashboardWidget.dismissWidgetBlock() instead."),s(".wpforms-dash-widget-recommended-plugin-block").remove(),o.saveWidgetMeta("hide_recommended_block",1)}};return o})(document,(window,jQuery));WPFormsDashboardWidget.init();
|
||||
@@ -0,0 +1,176 @@
|
||||
/* global wpforms_builder, wpforms_education */
|
||||
|
||||
/**
|
||||
* WPForms Education core for Lite.
|
||||
*
|
||||
* @since 1.6.6
|
||||
*/
|
||||
|
||||
// noinspection ES6ConvertVarToLetConst
|
||||
/**
|
||||
* @param wpforms_education.upgrade
|
||||
* @param wpforms_education.upgrade.button
|
||||
* @param wpforms_education.upgrade.doc
|
||||
* @param wpforms_education.upgrade.message
|
||||
* @param wpforms_education.upgrade.title
|
||||
* @param wpforms_education.upgrade.title_plural
|
||||
* @param wpforms_education.upgrade_bonus
|
||||
*/
|
||||
|
||||
var WPFormsEducation = window.WPFormsEducation || {}; // eslint-disable-line no-var
|
||||
|
||||
WPFormsEducation.liteCore = window.WPFormsEducation.liteCore || ( function( document, window, $ ) {
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.6.6
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const app = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.6.6
|
||||
*/
|
||||
init() {
|
||||
$( app.ready );
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.6.6
|
||||
*/
|
||||
ready() {
|
||||
app.events();
|
||||
},
|
||||
|
||||
/**
|
||||
* Register JS events.
|
||||
*
|
||||
* @since 1.6.6
|
||||
*/
|
||||
events() {
|
||||
app.openModalButtonClick();
|
||||
},
|
||||
|
||||
/**
|
||||
* Registers click events that should open upgrade modal.
|
||||
*
|
||||
* @since 1.6.6
|
||||
*/
|
||||
openModalButtonClick() {
|
||||
$( document )
|
||||
.on( 'click', '.education-modal:not(.wpforms-add-fields-button)', app.openModalButtonHandler )
|
||||
.on( 'mousedown', '.education-modal.wpforms-add-fields-button', app.openModalButtonHandler );
|
||||
},
|
||||
|
||||
/**
|
||||
* Open education modal handler.
|
||||
*
|
||||
* @since 1.8.0
|
||||
*
|
||||
* @param {Event} event Event.
|
||||
*/
|
||||
openModalButtonHandler( event ) {
|
||||
const $this = $( this );
|
||||
|
||||
if ( $this.data( 'action' ) && [ 'activate', 'install' ].includes( $this.data( 'action' ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
|
||||
let name = $this.data( 'name' );
|
||||
|
||||
if ( $this.hasClass( 'wpforms-add-fields-button' ) ) {
|
||||
name = $this.text();
|
||||
name += name.indexOf( wpforms_builder.field ) < 0 ? ' ' + wpforms_builder.field : '';
|
||||
}
|
||||
|
||||
const utmContent = WPFormsEducation.core.getUTMContentValue( $this );
|
||||
|
||||
app.upgradeModal( name, utmContent, $this.data( 'license' ), $this.data( 'video' ), $this.data( 'plural' ) );
|
||||
},
|
||||
|
||||
/**
|
||||
* Upgrade modal.
|
||||
*
|
||||
* @since 1.6.6
|
||||
*
|
||||
* @param {string} feature Feature name.
|
||||
* @param {string} utmContent UTM content.
|
||||
* @param {string} type Feature license type: pro or elite.
|
||||
* @param {string} video Feature video URL.
|
||||
* @param {boolean} isPlural Is feature name plural.
|
||||
*/
|
||||
upgradeModal( feature, utmContent, type, video, isPlural ) {
|
||||
// Provide a default value.
|
||||
if ( typeof type === 'undefined' || type.length === 0 ) {
|
||||
type = 'pro';
|
||||
}
|
||||
|
||||
// Make sure we received only a supported type.
|
||||
if ( $.inArray( type, [ 'pro', 'elite' ] ) < 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const message = wpforms_education.upgrade[ type ].message.replace( /%name%/g, feature );
|
||||
const isVideoModal = Boolean( video );
|
||||
const titleMessage = isPlural ? wpforms_education.upgrade[ type ].title_plural : wpforms_education.upgrade[ type ].title;
|
||||
|
||||
let modalWidth = WPFormsEducation.core.getUpgradeModalWidth( isVideoModal );
|
||||
|
||||
const modal = $.alert( {
|
||||
backgroundDismiss: true,
|
||||
title: feature + ' ' + titleMessage,
|
||||
icon: 'fa fa-lock',
|
||||
content: message,
|
||||
boxWidth: modalWidth,
|
||||
theme: 'modern,wpforms-education',
|
||||
closeIcon: true,
|
||||
onOpenBefore() {
|
||||
if ( isVideoModal ) {
|
||||
this.$el.addClass( 'has-video' );
|
||||
}
|
||||
|
||||
const videoHtml = isVideoModal ? '<iframe src="' + video + '" class="feature-video" allowfullscreen="" width="475" height="267"></iframe>' : '';
|
||||
|
||||
this.$btnc.after( '<div class="discount-note">' + wpforms_education.upgrade_bonus + '</div>' );
|
||||
this.$btnc.after( wpforms_education.upgrade[ type ].doc.replace( /%25name%25/g, feature ) );
|
||||
this.$btnc.after( videoHtml );
|
||||
|
||||
this.$body.find( '.jconfirm-content' ).addClass( 'lite-upgrade' );
|
||||
},
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: wpforms_education.upgrade[ type ].button,
|
||||
btnClass: 'btn-confirm',
|
||||
keys: [ 'enter' ],
|
||||
action: () => {
|
||||
window.open( WPFormsEducation.core.getUpgradeURL( utmContent, type ), '_blank' );
|
||||
WPFormsEducation.core.upgradeModalThankYou( type );
|
||||
},
|
||||
},
|
||||
},
|
||||
} );
|
||||
|
||||
$( window ).on( 'resize', function() {
|
||||
modalWidth = WPFormsEducation.core.getUpgradeModalWidth( isVideoModal );
|
||||
|
||||
if ( modal.isOpen() ) {
|
||||
modal.setBoxWidth( modalWidth );
|
||||
}
|
||||
} );
|
||||
},
|
||||
};
|
||||
|
||||
// Provide access to public functions/properties.
|
||||
return app;
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
// Initialize.
|
||||
WPFormsEducation.liteCore.init();
|
||||
+1
@@ -0,0 +1 @@
|
||||
var WPFormsEducation=window.WPFormsEducation||{};WPFormsEducation.liteCore=window.WPFormsEducation.liteCore||((e,l,c)=>{let a={init(){c(a.ready)},ready(){a.events()},events(){a.openModalButtonClick()},openModalButtonClick(){c(e).on("click",".education-modal:not(.wpforms-add-fields-button)",a.openModalButtonHandler).on("mousedown",".education-modal.wpforms-add-fields-button",a.openModalButtonHandler)},openModalButtonHandler(o){var t=c(this);if(!t.data("action")||!["activate","install"].includes(t.data("action"))){o.preventDefault(),o.stopImmediatePropagation();let e=t.data("name");t.hasClass("wpforms-add-fields-button")&&(e=t.text(),e+=e.indexOf(wpforms_builder.field)<0?" "+wpforms_builder.field:"");o=WPFormsEducation.core.getUTMContentValue(t);a.upgradeModal(e,o,t.data("license"),t.data("video"),t.data("plural"))}},upgradeModal(a,n,d,i,r){if(void 0!==d&&0!==d.length||(d="pro"),!(c.inArray(d,["pro","elite"])<0)){var s=wpforms_education.upgrade[d].message.replace(/%name%/g,a);let o=Boolean(i);r=r?wpforms_education.upgrade[d].title_plural:wpforms_education.upgrade[d].title;let e=WPFormsEducation.core.getUpgradeModalWidth(o),t=c.alert({backgroundDismiss:!0,title:a+" "+r,icon:"fa fa-lock",content:s,boxWidth:e,theme:"modern,wpforms-education",closeIcon:!0,onOpenBefore(){o&&this.$el.addClass("has-video");var e=o?'<iframe src="'+i+'" class="feature-video" allowfullscreen="" width="475" height="267"></iframe>':"";this.$btnc.after('<div class="discount-note">'+wpforms_education.upgrade_bonus+"</div>"),this.$btnc.after(wpforms_education.upgrade[d].doc.replace(/%25name%25/g,a)),this.$btnc.after(e),this.$body.find(".jconfirm-content").addClass("lite-upgrade")},buttons:{confirm:{text:wpforms_education.upgrade[d].button,btnClass:"btn-confirm",keys:["enter"],action:()=>{l.open(WPFormsEducation.core.getUpgradeURL(n,d),"_blank"),WPFormsEducation.core.upgradeModalThankYou(d)}}}});c(l).on("resize",function(){e=WPFormsEducation.core.getUpgradeModalWidth(o),t.isOpen()&&t.setBoxWidth(e)})}}};return a})(document,window,jQuery),WPFormsEducation.liteCore.init();
|
||||
+565
@@ -0,0 +1,565 @@
|
||||
/* global wpforms_education_lite_connect, WPFormsChallenge */
|
||||
/**
|
||||
* WPForms Education for Lite.
|
||||
*
|
||||
* Lite Connect feature.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line no-var
|
||||
var WPFormsEducation = window.WPFormsEducation || {};
|
||||
|
||||
WPFormsEducation.liteConnect = window.WPFormsEducation.liteConnect || ( function( document, window, $ ) {
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const app = {
|
||||
|
||||
/**
|
||||
* Start the engine.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
init() {
|
||||
$( app.ready );
|
||||
|
||||
// Page load.
|
||||
$( window ).on( 'load', function() {
|
||||
// In the case of jQuery 3.+, we need to wait for a ready event first.
|
||||
if ( typeof $.ready.then === 'function' ) {
|
||||
$.ready.then( app.load );
|
||||
} else {
|
||||
app.load();
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
ready() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Page load.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
load() {
|
||||
app.events();
|
||||
app.initLiteConnectToggle();
|
||||
app.maybeRevealBuilderTopBar();
|
||||
},
|
||||
|
||||
/**
|
||||
* Register JS events.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
events() {
|
||||
app.enableLiteConnectToggleClick();
|
||||
app.enableLiteConnectButtonClick();
|
||||
app.dismissBuilderTopBarClick();
|
||||
app.autoSaveToggleChange();
|
||||
app.enableLiteConnectAIButtonClick();
|
||||
},
|
||||
|
||||
/**
|
||||
* Init Lite Connect toggle.
|
||||
*
|
||||
* @since 1.7.5
|
||||
*/
|
||||
initLiteConnectToggle() {
|
||||
$( '.wpforms-toggle-control.wpforms-setting-lite-connect-auto-save-toggle input' ).prop( 'disabled', false );
|
||||
},
|
||||
|
||||
/**
|
||||
* Enable Lite Connect toggle mousedown handler.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
enableLiteConnectToggleClick() {
|
||||
$( document ).on(
|
||||
'mousedown touchstart',
|
||||
'#wpforms-setting-row-lite-connect-enabled label, .wpforms-setting-lite-connect-auto-save-toggle label',
|
||||
function( event ) {
|
||||
const isTouchDevice = 'ontouchstart' in document.documentElement;
|
||||
|
||||
if ( ! isTouchDevice ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
const wrapper = $( this ).closest( '#wpforms-setting-row-lite-connect-enabled, .wpforms-setting-lite-connect-auto-save-toggle' );
|
||||
|
||||
const $input = wrapper.find( '#wpforms-setting-lite-connect-enabled' );
|
||||
|
||||
if ( $input.prop( 'disabled' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isEnabled = $input.is( ':checked' );
|
||||
|
||||
app.openSettingsLiteConnectModal( isEnabled, function() {
|
||||
$input
|
||||
.trigger( 'click' )
|
||||
.prop( 'disabled', true );
|
||||
} );
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Enable Lite Connect button click handler.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
enableLiteConnectButtonClick() {
|
||||
$( document ).on(
|
||||
'click',
|
||||
'.wpforms-dyk-lite-connect .button-primary',
|
||||
function( event ) {
|
||||
event.preventDefault();
|
||||
|
||||
const $button = $( this );
|
||||
|
||||
if ( $button.hasClass( 'wpforms-is-enabled' ) ) {
|
||||
window.open( $button.attr( 'href' ) );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
app.openSettingsLiteConnectModal(
|
||||
false,
|
||||
app.enableLiteConnectButtonModalConfirm
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Enable Lite Connect button click handler.
|
||||
*
|
||||
* @since 1.9.1
|
||||
*/
|
||||
enableLiteConnectAIButtonClick() {
|
||||
$( document ).on(
|
||||
'click',
|
||||
'.enable-lite-connect-modal',
|
||||
app.handleLiteConnectModalClick,
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Finalize the Lite Connect keys setup.
|
||||
*
|
||||
* @since 1.9.1
|
||||
*
|
||||
* @return {jQuery} AJAX request deferred object.
|
||||
*/
|
||||
finalizeLiteConnectSetup() {
|
||||
return $.get( wpforms_education_lite_connect.ajax_url, {
|
||||
action: 'wpforms_lite_connect_finalize',
|
||||
nonce: wpforms_education_lite_connect.nonce,
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle Lite Connect modal click.
|
||||
*
|
||||
* @since 1.9.1
|
||||
*
|
||||
* @param {Event} event Event object.
|
||||
*/
|
||||
handleLiteConnectModalClick( event ) {
|
||||
event.preventDefault();
|
||||
|
||||
app.openAILiteConnectEnableModal(
|
||||
function() {
|
||||
app.saveSettingAjaxPost( true, $(), function() {
|
||||
app.switchSettingView( true, $( '#wpforms-builder-lite-connect-top-bar .wpforms-toggle-control' ) );
|
||||
|
||||
// Finalize the Lite Connect keys setup.
|
||||
app.finalizeLiteConnectSetup()
|
||||
.done( () => {
|
||||
app.removeLiteConnectModalOnAIButtons();
|
||||
} );
|
||||
} );
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove Lite Connect modal on AI buttons.
|
||||
*
|
||||
* @since 1.9.1
|
||||
*/
|
||||
removeLiteConnectModalOnAIButtons() {
|
||||
$( '.enable-lite-connect-modal.wpforms-prevent-default' ).each( function() {
|
||||
const $button = $( this );
|
||||
|
||||
// Update button class.
|
||||
$button.removeClass( 'enable-lite-connect-modal wpforms-prevent-default' );
|
||||
|
||||
// Open AI Form Generator.
|
||||
if ( $button.hasClass( 'wpforms-template-generate' ) ) {
|
||||
$button.trigger( 'click' );
|
||||
}
|
||||
|
||||
// Close the top bar in the form builder.
|
||||
if ( $( '#wpforms-builder-lite-connect-top-bar' ).length ) {
|
||||
app.toggleBuilderTopBar( false );
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Enable Lite Connect button modal confirm Callback.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
enableLiteConnectButtonModalConfirm() {
|
||||
const $toggle = $( '.wpforms-dyk-lite-connect .button-primary' );
|
||||
|
||||
app.saveSettingAjaxPost( true, $toggle, function() {
|
||||
app.switchSettingView( true, $toggle );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Form Entry Backups information modal.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @param {boolean} isEnabled Current setting state.
|
||||
* @param {Function} confirmCallback Confirm button action.
|
||||
*/
|
||||
openSettingsLiteConnectModal( isEnabled, confirmCallback ) {
|
||||
if ( isEnabled ) {
|
||||
app.openSettingsLiteConnectDisableModal( confirmCallback );
|
||||
} else {
|
||||
app.openSettingsLiteConnectEnableModal( confirmCallback );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Form Entry Backups enable information modal.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @param {Function} confirmCallback Confirm button action.
|
||||
*/
|
||||
openSettingsLiteConnectEnableModal( confirmCallback ) {
|
||||
const $args = {
|
||||
content: wp.template( 'wpforms-settings-lite-connect-modal-content' )(),
|
||||
confirm: {
|
||||
text: wpforms_education_lite_connect.enable_modal.confirm,
|
||||
callback: confirmCallback,
|
||||
},
|
||||
};
|
||||
|
||||
app.enableModal( $args );
|
||||
},
|
||||
|
||||
/**
|
||||
* AI features enable information modal.
|
||||
*
|
||||
* @since 1.9.1
|
||||
*
|
||||
* @param {Function} confirmCallback Confirm button action.
|
||||
*/
|
||||
openAILiteConnectEnableModal( confirmCallback ) {
|
||||
const $args = {
|
||||
content: wp.template( 'wpforms-builder-ai-lite-connect-modal-content' )(),
|
||||
confirm: {
|
||||
text: wpforms_education_lite_connect.enable_ai.confirm,
|
||||
callback: confirmCallback,
|
||||
},
|
||||
theme: 'modern, ai-modal',
|
||||
};
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
wpforms_education_lite_connect.update_result.enabled_title = wpforms_education_lite_connect.enable_ai.enabled_title;
|
||||
|
||||
app.enableModal( $args );
|
||||
},
|
||||
|
||||
/**
|
||||
* Render Enable modal.
|
||||
*
|
||||
* @param {Object} $args Modal arguments.
|
||||
*/
|
||||
enableModal( $args ) {
|
||||
$.alert( {
|
||||
title: false,
|
||||
content: $args.content,
|
||||
icon: false,
|
||||
type: 'orange',
|
||||
boxWidth: 550,
|
||||
theme: $args.theme || 'modern',
|
||||
useBootstrap: false,
|
||||
scrollToPreviousElement: false,
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: $args.confirm.text,
|
||||
btnClass: 'btn-confirm',
|
||||
keys: [ 'enter' ],
|
||||
action() {
|
||||
if ( typeof $args.confirm.callback === 'function' ) {
|
||||
$args.confirm.callback();
|
||||
}
|
||||
|
||||
// Maybe close Challenge popup.
|
||||
if ( window.WPFormsChallenge ) {
|
||||
// eslint-disable-next-line no-var
|
||||
var completeChallenge = WPFormsChallenge.embed && WPFormsChallenge.embed.completeChallenge;
|
||||
}
|
||||
|
||||
if ( typeof completeChallenge === 'function' ) {
|
||||
completeChallenge();
|
||||
}
|
||||
},
|
||||
},
|
||||
cancel: {
|
||||
text: wpforms_education_lite_connect.enable_modal.cancel,
|
||||
action() {
|
||||
$( '.wpforms-challenge-popup-container' ).removeClass( 'wpforms-invisible' );
|
||||
},
|
||||
},
|
||||
},
|
||||
onOpenBefore() {
|
||||
$( 'body' ).addClass( 'wpforms-setting-lite-connect-modal' );
|
||||
$( '.wpforms-challenge-popup-container' ).addClass( 'wpforms-invisible' );
|
||||
},
|
||||
onDestroy() {
|
||||
$( 'body' ).removeClass( 'wpforms-setting-lite-connect-modal' );
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Form Entry Backups disable information modal.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @param {Function} confirmCallback Confirm button action.
|
||||
*/
|
||||
openSettingsLiteConnectDisableModal( confirmCallback ) {
|
||||
$.alert( {
|
||||
title: wpforms_education_lite_connect.disable_modal.title,
|
||||
content: wpforms_education_lite_connect.disable_modal.content,
|
||||
icon: 'fa fa-exclamation-circle',
|
||||
type: 'red',
|
||||
boxWidth: '400px',
|
||||
theme: 'modern',
|
||||
useBootstrap: false,
|
||||
animateFromElement: false,
|
||||
scrollToPreviousElement: false,
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: wpforms_education_lite_connect.disable_modal.cancel,
|
||||
keys: [ 'enter' ],
|
||||
btnClass: 'btn-confirm',
|
||||
},
|
||||
confirm: {
|
||||
text: wpforms_education_lite_connect.disable_modal.confirm,
|
||||
action() {
|
||||
if ( typeof confirmCallback === 'function' ) {
|
||||
confirmCallback();
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Save Lite Connect Enabled setting AJAX post call.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @param {boolean} isEnabled Lite Connect setting flag.
|
||||
* @param {jQuery|undefined} $toggle Toggle control outer element.
|
||||
* @param {Function} successCallback Success result callback.
|
||||
*/
|
||||
saveSettingAjaxPost( isEnabled, $toggle, successCallback ) {
|
||||
$toggle = $toggle || $();
|
||||
|
||||
const $input = $toggle.find( 'input' );
|
||||
|
||||
// Perform AJAX request.
|
||||
$.post(
|
||||
wpforms_education_lite_connect.ajax_url,
|
||||
{
|
||||
action: 'wpforms_update_lite_connect_enabled_setting',
|
||||
value: isEnabled ? 1 : 0,
|
||||
nonce: wpforms_education_lite_connect.nonce,
|
||||
}
|
||||
).done( function( res ) {
|
||||
if ( ! res.success ) {
|
||||
$input.prop( 'checked', ! isEnabled );
|
||||
app.updateResultModal( 'error' );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
app.updateResultModal( isEnabled ? 'enabled' : 'disabled' );
|
||||
|
||||
if ( typeof successCallback === 'function' ) {
|
||||
successCallback();
|
||||
}
|
||||
} ).fail( function() {
|
||||
$input.prop( 'checked', ! isEnabled );
|
||||
app.updateResultModal( 'error' );
|
||||
} ).always( function() {
|
||||
$input.prop( 'disabled', false );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Lite Connect toggle `change` event handler with "auto save" feature.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
autoSaveToggleChange() {
|
||||
$( document ).on(
|
||||
'change',
|
||||
'.wpforms-toggle-control.wpforms-setting-lite-connect-auto-save-toggle input',
|
||||
function() {
|
||||
const $input = $( this ),
|
||||
$toggle = $input.closest( '.wpforms-toggle-control' ),
|
||||
isEnabled = $input.is( ':checked' );
|
||||
|
||||
app.saveSettingAjaxPost( isEnabled, $toggle, function() {
|
||||
app.switchSettingView( isEnabled, $toggle );
|
||||
app.removeLiteConnectModalOnAIButtons();
|
||||
|
||||
// Finalize the Lite Connect keys setup.
|
||||
app.finalizeLiteConnectSetup();
|
||||
} );
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* After updating setting via AJAX we should hide toggle container and show info container.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @param {boolean} isEnabled Toggle state.
|
||||
* @param {jQuery} $toggle Toggle control.
|
||||
*/
|
||||
switchSettingView( isEnabled, $toggle ) {
|
||||
const $wrapper = $toggle.closest( '.wpforms-education-lite-connect-wrapper' ),
|
||||
$setting = $wrapper.find( '.wpforms-education-lite-connect-setting' ),
|
||||
$enabledInfo = $wrapper.find( '.wpforms-education-lite-connect-enabled-info' );
|
||||
|
||||
$setting.toggleClass( 'wpforms-hidden', isEnabled );
|
||||
$enabledInfo.toggleClass( 'wpforms-hidden', ! isEnabled );
|
||||
},
|
||||
|
||||
/**
|
||||
* Update result message modal.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @param {string} msg Message slug.
|
||||
*/
|
||||
updateResultModal( msg ) {
|
||||
if ( ! wpforms_education_lite_connect.update_result[ msg ] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.alert( {
|
||||
title: wpforms_education_lite_connect.update_result[ msg + '_title' ],
|
||||
content: wpforms_education_lite_connect.update_result[ msg ],
|
||||
icon: 'fa fa-check-circle',
|
||||
type: msg === 'error' ? 'red' : 'green',
|
||||
theme: 'modern',
|
||||
boxWidth: '400px',
|
||||
useBootstrap: false,
|
||||
animation: 'scale',
|
||||
closeAnimation: 'scale',
|
||||
animateFromElement: false,
|
||||
scrollToPreviousElement: false,
|
||||
buttons: {
|
||||
confirm: {
|
||||
text : wpforms_education_lite_connect.update_result.close,
|
||||
btnClass: 'btn-confirm',
|
||||
keys : [ 'enter' ],
|
||||
},
|
||||
},
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Reveal top bar in the Form Builder.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
maybeRevealBuilderTopBar() {
|
||||
// Skip it is not Form Builder or Entry Backups is already enabled or top bar is dismissed.
|
||||
if (
|
||||
! window.wpforms_builder ||
|
||||
wpforms_education_lite_connect.is_enabled === '1' ||
|
||||
$( '#wpforms-builder-lite-connect-top-bar' ).length === 0
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
setTimeout( function() {
|
||||
app.toggleBuilderTopBar( true );
|
||||
}, 3000 );
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle top bar in the Form Builder.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*
|
||||
* @param {boolean} open True for open, false for close.
|
||||
*/
|
||||
toggleBuilderTopBar( open ) {
|
||||
const cssVar = '--wpforms-admin-bar-height';
|
||||
const root = document.documentElement;
|
||||
const topBarHeight = 45;
|
||||
|
||||
let adminBarHeight = parseInt( getComputedStyle( root ).getPropertyValue( cssVar ), 10 );
|
||||
|
||||
adminBarHeight += open ? topBarHeight : -topBarHeight;
|
||||
|
||||
root.setAttribute(
|
||||
'style',
|
||||
cssVar + ': ' + ( adminBarHeight ) + 'px!important;'
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Dismiss top bar in the Form Builder.
|
||||
*
|
||||
* @since 1.7.4
|
||||
*/
|
||||
dismissBuilderTopBarClick() {
|
||||
$( document ).on(
|
||||
'click',
|
||||
'#wpforms-builder-lite-connect-top-bar .wpforms-dismiss-button',
|
||||
function() {
|
||||
app.toggleBuilderTopBar( false );
|
||||
}
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
// Provide access to public functions/properties.
|
||||
return app;
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
// Initialize.
|
||||
WPFormsEducation.liteConnect.init();
|
||||
Vendored
Executable
+1
File diff suppressed because one or more lines are too long
+120
@@ -0,0 +1,120 @@
|
||||
/* global wpCookies */
|
||||
|
||||
/**
|
||||
* Entries list page.
|
||||
*/
|
||||
const WPFormsEntryList = window.WPFormsEntryList || ( function( document, window, $ ) {
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.8.9
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const app = {
|
||||
|
||||
/**
|
||||
* Initialize the engine.
|
||||
*
|
||||
* @since 1.8.9
|
||||
*/
|
||||
init() {
|
||||
$( app.ready );
|
||||
},
|
||||
|
||||
/**
|
||||
* Ready.
|
||||
*
|
||||
* @since 1.8.9
|
||||
*/
|
||||
ready() {
|
||||
app.events();
|
||||
},
|
||||
|
||||
/**
|
||||
* Events.
|
||||
*
|
||||
* @since 1.8.9
|
||||
*/
|
||||
events() {
|
||||
// Show sample data for entries when the Explore Entries is clicked.
|
||||
$( '#wpforms-entries-explore' ).on( 'click', app.showEntries );
|
||||
|
||||
// Hide sample data for entries when the Hide Sample Data is clicked.
|
||||
$( '#wpforms-hide-sample-data' ).on( 'click', app.hideEntries );
|
||||
|
||||
// Toggle the action dropdown.
|
||||
$( '#wpforms-list-table-ext-edit-columns-cog' ).on( 'click', app.toggleActionDropdown );
|
||||
$( '#wpcontent' ).on( 'click', app.hideActionDropdown );
|
||||
},
|
||||
|
||||
/**
|
||||
* Show entries.
|
||||
*
|
||||
* @since 1.8.9
|
||||
*
|
||||
* @param {Object} e Event object.
|
||||
*/
|
||||
showEntries( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
$( '.entries-modal' ).fadeOut( 500, function() {
|
||||
$( '#wpforms-sample-entry-main-notice' ).slideDown( 250 );
|
||||
$( '#wpforms-entries-list' ).addClass( 'wpforms-entires-sample-view' );
|
||||
} );
|
||||
wpCookies.set( 'wpforms_sample_entries', 'true', 2592000 ); // 1 month
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide entries.
|
||||
*
|
||||
* @since 1.8.9
|
||||
*
|
||||
* @param {Object} e Event object.
|
||||
*/
|
||||
hideEntries( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
// Bypass animation as this is causing fade in/out issues.
|
||||
$( '#wpforms-sample-entry-main-notice' ).fadeOut( 250, function() {
|
||||
$( '#wpforms-entries-list' ).removeClass( 'wpforms-entires-sample-view' );
|
||||
$( '.wpforms-sample-entry-notice' ).removeClass( 'wpf-no-animate' );
|
||||
$( '.entries-modal' ).fadeIn( 500 );
|
||||
} );
|
||||
|
||||
wpCookies.remove( 'wpforms_sample_entries' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle the action dropdown.
|
||||
*
|
||||
* @since 1.8.9
|
||||
*
|
||||
* @param {Object} e Event object.
|
||||
*/
|
||||
toggleActionDropdown( e ) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
$( this ).parent().toggleClass( 'is_active' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide the action dropdown.
|
||||
*
|
||||
* @since 1.8.9
|
||||
*/
|
||||
hideActionDropdown() {
|
||||
const actionColumn = $( '#wpforms-list-table-ext-edit-columns-cog' ).parent();
|
||||
|
||||
if ( actionColumn.hasClass( 'is_active' ) ) {
|
||||
actionColumn.removeClass( 'is_active' );
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
return app;
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
// Initialize the engine.
|
||||
WPFormsEntryList.init();
|
||||
+1
@@ -0,0 +1 @@
|
||||
let WPFormsEntryList=window.WPFormsEntryList||(t=>{let e={init(){t(e.ready)},ready(){e.events()},events(){t("#wpforms-entries-explore").on("click",e.showEntries),t("#wpforms-hide-sample-data").on("click",e.hideEntries),t("#wpforms-list-table-ext-edit-columns-cog").on("click",e.toggleActionDropdown),t("#wpcontent").on("click",e.hideActionDropdown)},showEntries(e){e.preventDefault(),t(".entries-modal").fadeOut(500,function(){t("#wpforms-sample-entry-main-notice").slideDown(250),t("#wpforms-entries-list").addClass("wpforms-entires-sample-view")}),wpCookies.set("wpforms_sample_entries","true",2592e3)},hideEntries(e){e.preventDefault(),t("#wpforms-sample-entry-main-notice").fadeOut(250,function(){t("#wpforms-entries-list").removeClass("wpforms-entires-sample-view"),t(".wpforms-sample-entry-notice").removeClass("wpf-no-animate"),t(".entries-modal").fadeIn(500)}),wpCookies.remove("wpforms_sample_entries")},toggleActionDropdown(e){e.preventDefault(),e.stopPropagation(),t(this).parent().toggleClass("is_active")},hideActionDropdown(){var e=t("#wpforms-list-table-ext-edit-columns-cog").parent();e.hasClass("is_active")&&e.removeClass("is_active")}};return e})((document,window,jQuery));WPFormsEntryList.init();
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* View single entry page.
|
||||
*
|
||||
* @since 1.8.9
|
||||
*/
|
||||
const WPFormsViewEntry = window.WPFormsViewEntry || ( function( document, window, $ ) {
|
||||
/**
|
||||
* Elements holder.
|
||||
*
|
||||
* @since 1.8.9
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
let el = {};
|
||||
|
||||
/**
|
||||
* Public functions and properties.
|
||||
*
|
||||
* @since 1.8.9
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const app = {
|
||||
|
||||
/**
|
||||
* Initialize the engine.
|
||||
*
|
||||
* @since 1.8.9
|
||||
*/
|
||||
init() {
|
||||
$( app.ready );
|
||||
},
|
||||
|
||||
/**
|
||||
* Document ready.
|
||||
*
|
||||
* @since 1.8.9
|
||||
*/
|
||||
ready() {
|
||||
app.setup();
|
||||
app.events();
|
||||
},
|
||||
|
||||
/**
|
||||
* Setup. Prepare some variables.
|
||||
*
|
||||
* @since 1.8.9
|
||||
*/
|
||||
setup() {
|
||||
// Cache DOM elements.
|
||||
el = {
|
||||
menuClass: '.wpforms-entries-settings-menu',
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Events.
|
||||
*
|
||||
* @since 1.8.9
|
||||
*/
|
||||
events() {
|
||||
$( '#wpforms-entries-settings-button' ).on( 'click', app.menuToggle );
|
||||
$( '#wpcontent' ).on( 'click', app.menuHide );
|
||||
},
|
||||
|
||||
/**
|
||||
* Handler for the menu toggle behavior.
|
||||
*
|
||||
* @since 1.8.9
|
||||
*
|
||||
* @param {Object} event Event object.
|
||||
*/
|
||||
menuToggle( event ) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
// Toggle the visibility of the matched element.
|
||||
$( el.menuClass ).toggle( 0, function() {
|
||||
const $menu = $( this );
|
||||
|
||||
// When the menu is open, aria-expended="true".
|
||||
$menu.attr( 'aria-expanded', $menu.is( ':visible' ) );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Handler for hiding the menu when a click is outside of it.
|
||||
*
|
||||
* @since 1.8.9
|
||||
*
|
||||
* @param {Object} event Event object.
|
||||
*/
|
||||
menuHide( event ) {
|
||||
// Check if the clicked element is not the menu container or a child of it.
|
||||
if ( ! $( event.target ).closest( `${ el.menuClass }:visible` ).length ) {
|
||||
$( el.menuClass ).attr( 'aria-expanded', 'false' ).hide();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
return app;
|
||||
}( document, window, jQuery ) );
|
||||
|
||||
// Initialize the engine.
|
||||
WPFormsViewEntry.init();
|
||||
+1
@@ -0,0 +1 @@
|
||||
let WPFormsViewEntry=window.WPFormsViewEntry||(t=>{let n={},e={init(){t(e.ready)},ready(){e.setup(),e.events()},setup(){n={menuClass:".wpforms-entries-settings-menu"}},events(){t("#wpforms-entries-settings-button").on("click",e.menuToggle),t("#wpcontent").on("click",e.menuHide)},menuToggle(e){e.preventDefault(),e.stopPropagation(),t(n.menuClass).toggle(0,function(){var e=t(this);e.attr("aria-expanded",e.is(":visible"))})},menuHide(e){t(e.target).closest(n.menuClass+":visible").length||t(n.menuClass).attr("aria-expanded","false").hide()}};return e})((document,window,jQuery));WPFormsViewEntry.init();
|
||||
Reference in New Issue
Block a user