b6df4dbb92
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>
243 lines
6.3 KiB
JavaScript
Executable File
243 lines
6.3 KiB
JavaScript
Executable File
/* global wpforms_builder, wpforms_builder_stripe */
|
|
|
|
// noinspection ES6ConvertVarToLetConst
|
|
/**
|
|
* Stripe builder function.
|
|
*
|
|
* @since 1.8.2
|
|
*/
|
|
// eslint-disable-next-line no-var
|
|
var WPFormsStripe = window.WPFormsStripe || ( function( document, window, $ ) {
|
|
/**
|
|
* Public functions and properties.
|
|
*
|
|
* @since 1.8.2
|
|
*
|
|
* @type {Object}
|
|
*/
|
|
const app = {
|
|
|
|
/**
|
|
* Start the engine.
|
|
*
|
|
* @since 1.8.2
|
|
*/
|
|
init() {
|
|
$( app.ready );
|
|
},
|
|
|
|
/**
|
|
* Initialized once the DOM is fully loaded.
|
|
*
|
|
* @since 1.8.2
|
|
*/
|
|
ready() {
|
|
if ( ! app.isLegacySettings() ) {
|
|
return;
|
|
}
|
|
|
|
app.settingsDisplay();
|
|
app.settingsConditions();
|
|
|
|
app.bindUIActions();
|
|
},
|
|
|
|
/**
|
|
* Process various events as a response to UI interactions.
|
|
*
|
|
* @since 1.8.2
|
|
*/
|
|
bindUIActions() {
|
|
$( document )
|
|
.on( 'wpformsFieldDelete', app.disableNotifications )
|
|
.on( 'wpformsSaved', app.requiredFieldsCheck )
|
|
.on( 'wpformsFieldUpdate', app.settingsDisplay )
|
|
.on( 'wpformsFieldUpdate', app.settingsConditions );
|
|
|
|
$( '#wpforms-panel-field-stripe-recurring-email' ).on( 'change', app.resetEmailAlertErrorClass );
|
|
},
|
|
|
|
/**
|
|
* Toggles visibility of the Stripe settings.
|
|
*
|
|
* If a credit card field has been added, then reveal the settings.
|
|
* Otherwise, hide them.
|
|
*
|
|
* @since 1.8.2
|
|
*/
|
|
settingsDisplay() {
|
|
const $alert = $( '#wpforms-stripe-credit-card-alert' );
|
|
const $content = $( '#stripe-provider' );
|
|
|
|
// Check if any Credit Card fields were added to the form.
|
|
const ccFieldsAdded = wpforms_builder_stripe.field_slugs.filter( function( fieldSlug ) {
|
|
const $el = $( '.wpforms-field-option-' + fieldSlug );
|
|
|
|
return $el.length ? $el : null;
|
|
} );
|
|
|
|
if ( ccFieldsAdded.length ) {
|
|
$alert.hide();
|
|
$content.find( '#wpforms-stripe-new-interface-alert, .wpforms-stripe-notice-info, .wpforms-panel-field, .wpforms-conditional-block-panel, h2' ).show();
|
|
} else {
|
|
$alert.show();
|
|
$content.find( '#wpforms-stripe-new-interface-alert, .wpforms-stripe-notice-info, .wpforms-panel-field, .wpforms-conditional-block-panel, h2' ).hide();
|
|
$content.find( '#wpforms-panel-field-stripe-enable' ).prop( 'checked', false ).trigger( 'change' );
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Toggles the visibility of the related settings.
|
|
*
|
|
* @since 1.8.2
|
|
*/
|
|
settingsConditions() {
|
|
$( '#wpforms-panel-field-stripe-enable' ).conditions( {
|
|
conditions: {
|
|
element: '#wpforms-panel-field-stripe-enable',
|
|
type: 'checked',
|
|
operator: 'is',
|
|
},
|
|
actions: {
|
|
if: {
|
|
element: '.wpforms-panel-content-section-stripe-body',
|
|
action: 'show',
|
|
},
|
|
else: {
|
|
element: '.wpforms-panel-content-section-stripe-body',
|
|
action: 'hide',
|
|
},
|
|
},
|
|
effect: 'appear',
|
|
} );
|
|
|
|
$( '#wpforms-panel-field-stripe-recurring-enable' ).conditions( {
|
|
conditions: {
|
|
element: '#wpforms-panel-field-stripe-recurring-enable',
|
|
type: 'checked',
|
|
operator: 'is',
|
|
},
|
|
actions: {
|
|
if: {
|
|
element: '#wpforms-panel-field-stripe-recurring-period-wrap,#wpforms-panel-field-stripe-recurring-conditional_logic-wrap,#wpforms-conditional-groups-payments-stripe-recurring,#wpforms-panel-field-stripe-recurring-email-wrap,#wpforms-panel-field-stripe-recurring-name-wrap',
|
|
action: 'show',
|
|
},
|
|
else: {
|
|
element: '#wpforms-panel-field-stripe-recurring-period-wrap,#wpforms-panel-field-stripe-recurring-conditional_logic-wrap,#wpforms-conditional-groups-payments-stripe-recurring,#wpforms-panel-field-stripe-recurring-email-wrap,#wpforms-panel-field-stripe-recurring-name-wrap',
|
|
action: 'hide',
|
|
},
|
|
},
|
|
effect: 'appear',
|
|
} );
|
|
},
|
|
|
|
/**
|
|
* On form save notify users about required fields.
|
|
*
|
|
* @since 1.8.2
|
|
*/
|
|
requiredFieldsCheck() {
|
|
if (
|
|
! $( '#wpforms-panel-field-stripe-enable' ).is( ':checked' ) ||
|
|
! $( '#wpforms-panel-field-stripe-recurring-enable' ).is( ':checked' )
|
|
) {
|
|
return;
|
|
}
|
|
|
|
const $emailField = $( '#wpforms-panel-field-stripe-recurring-email' );
|
|
|
|
if ( $emailField.val() ) {
|
|
return;
|
|
}
|
|
|
|
$emailField.addClass( 'wpforms-required-field-error' );
|
|
|
|
let alertMessage = wpforms_builder.stripe_recurring_email;
|
|
|
|
if ( ! $( '.wpforms-panel-content-section-stripe' ).is( ':visible' ) ) {
|
|
alertMessage += ' ' + wpforms_builder.stripe_recurring_settings;
|
|
}
|
|
|
|
$.alert( {
|
|
title: wpforms_builder.stripe_recurring_heading,
|
|
content: alertMessage,
|
|
icon: 'fa fa-exclamation-circle',
|
|
type: 'red',
|
|
buttons: {
|
|
confirm: {
|
|
text: wpforms_builder.ok,
|
|
btnClass: 'btn-confirm',
|
|
keys: [ 'enter' ],
|
|
},
|
|
},
|
|
onOpen() {
|
|
$( '.wpforms-stripe-settings-redirect' ).on( 'click', app.settingsRedirect );
|
|
},
|
|
} );
|
|
},
|
|
|
|
/**
|
|
* Redirect to the settings tab.
|
|
*
|
|
* @since 1.9.5
|
|
*/
|
|
settingsRedirect() {
|
|
// Open the Stripe settings tab.
|
|
$( '.wpforms-panel-payments-button' ).trigger( 'click' );
|
|
$( '.wpforms-panel-sidebar-section-stripe' ).trigger( 'click' );
|
|
|
|
// Scroll to the Stripe settings.
|
|
window.location.href = window.location.pathname + window.location.search + '#wpforms-panel-field-stripe-enable_recurring-wrap';
|
|
|
|
// Close the alert.
|
|
$( this ).closest( '.jconfirm-box' ).find( '.btn-confirm' ).trigger( 'click' );
|
|
},
|
|
|
|
/**
|
|
* Maybe reset required email field error class.
|
|
*
|
|
* @since 1.9.5
|
|
*/
|
|
resetEmailAlertErrorClass() {
|
|
$( this ).toggleClass( 'wpforms-required-field-error', ! $( this ).val() );
|
|
},
|
|
|
|
/**
|
|
* Disable notifications.
|
|
*
|
|
* @since 1.8.2
|
|
*
|
|
* @param {Object} e Event object.
|
|
* @param {number} id Field ID.
|
|
* @param {string} type Field type.
|
|
*/
|
|
disableNotifications( e, id, type ) {
|
|
if ( ! wpforms_builder_stripe.field_slugs.includes( type ) ) {
|
|
return;
|
|
}
|
|
|
|
const $notificationWrap = $( '.wpforms-panel-content-section-notifications [id*="-stripe-wrap"]' );
|
|
|
|
$notificationWrap.find( 'input[id*="-stripe"]' ).prop( 'checked', false );
|
|
$notificationWrap.addClass( 'wpforms-hidden' );
|
|
},
|
|
|
|
/**
|
|
* Determine is legacy settings is loaded.
|
|
*
|
|
* @since 1.8.4
|
|
*
|
|
* @return {boolean} True is legacy settings loaded.
|
|
*/
|
|
isLegacySettings() {
|
|
return $( '#wpforms-panel-field-stripe-enable' ).length;
|
|
},
|
|
};
|
|
|
|
// Provide access to public functions/properties.
|
|
return app;
|
|
}( document, window, jQuery ) );
|
|
|
|
// Initialize.
|
|
WPFormsStripe.init();
|