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>
159 lines
4.0 KiB
JavaScript
Executable File
159 lines
4.0 KiB
JavaScript
Executable File
/* global wpforms_builder */
|
|
|
|
// eslint-disable-next-line no-var
|
|
var WPForms = window.WPForms || {};
|
|
WPForms.Admin = WPForms.Admin || {};
|
|
WPForms.Admin.Builder = WPForms.Admin.Builder || {};
|
|
|
|
WPForms.Admin.Builder.Templates = WPForms.Admin.Builder.Templates || ( function( document, window, $ ) {
|
|
/**
|
|
* Private functions and properties.
|
|
*
|
|
* @since 1.4.8
|
|
*
|
|
* @type {Object}
|
|
*/
|
|
const __private = {
|
|
|
|
/**
|
|
* All templating functions for providers are stored here in a Map.
|
|
* Key is a template name, value - Underscore.js templating function.
|
|
*
|
|
* @since 1.4.8
|
|
*
|
|
* @type {Map}
|
|
*/
|
|
previews: new Map(),
|
|
|
|
/**
|
|
* Function to handle subfields for a given template's properties and extend
|
|
* the fields list if applicable. The function processes fields for specific
|
|
* types and formats, especially for "name" type fields, transforming them into
|
|
* an extended format with additional subfields (Full, First, Middle, Last).
|
|
*
|
|
* If the `isSupportSubfields` property is not enabled in the provided template's
|
|
* properties, the original `basePreview` function is executed without modification.
|
|
*
|
|
* @since 1.9.6
|
|
*
|
|
* @param {Function} basePreview The base preview function to execute the final output.
|
|
*
|
|
* @return {Function} A function that accepts `templateProps` and processes its fields.
|
|
*/
|
|
handleSubFields: ( basePreview ) => ( templateProps ) => {
|
|
if ( ! templateProps?.isSupportSubfields ) {
|
|
return basePreview( templateProps );
|
|
}
|
|
|
|
const extendedFieldsList = {};
|
|
let counter = 0;
|
|
|
|
_.each( templateProps.fields, function( field, key ) {
|
|
if ( _.isEmpty( field ) || ! _.has( field, 'id' ) || ! _.has( field, 'type' ) ) {
|
|
return;
|
|
}
|
|
|
|
if ( 'name' !== field.type || ! _.has( field, 'format' ) ) {
|
|
extendedFieldsList[ counter++ ] = field;
|
|
|
|
return;
|
|
}
|
|
|
|
field.id = field.id.toString();
|
|
|
|
const fieldLabel = ! _.isUndefined( field.label ) && field.label.toString().trim() !== ''
|
|
? field.label.toString().trim()
|
|
: wpforms_builder.field + ' #' + key;
|
|
|
|
// Add data for Name field in "extended" format (Full, First, Middle and Last).
|
|
_.each( wpforms_builder.name_field_formats, function( formatLabel, valueSlug ) {
|
|
if ( -1 !== field.format.indexOf( valueSlug ) || valueSlug === 'full' ) {
|
|
extendedFieldsList[ counter++ ] = {
|
|
id: field.id + '.' + valueSlug,
|
|
label: fieldLabel + ' (' + formatLabel + ')',
|
|
format: field.format,
|
|
};
|
|
}
|
|
} );
|
|
} );
|
|
|
|
templateProps.fields = extendedFieldsList;
|
|
|
|
return basePreview( templateProps );
|
|
},
|
|
};
|
|
|
|
/**
|
|
* Public functions and properties.
|
|
*
|
|
* @since 1.4.8
|
|
*
|
|
* @type {Object}
|
|
*/
|
|
const app = {
|
|
|
|
/**
|
|
* Start the engine. DOM is not ready yet, use only to init something.
|
|
*
|
|
* @since 1.4.8
|
|
*/
|
|
init() {
|
|
// Do that when DOM is ready.
|
|
$( app.ready );
|
|
},
|
|
|
|
/**
|
|
* DOM is fully loaded.
|
|
*
|
|
* @since 1.4.8
|
|
*/
|
|
ready() {
|
|
$( '#wpforms-panel-providers' ).trigger( 'WPForms.Admin.Builder.Templates.ready' );
|
|
},
|
|
|
|
/**
|
|
* Register and compile all templates.
|
|
* All data is saved in a Map.
|
|
*
|
|
* @since 1.4.8
|
|
*
|
|
* @param {string[]} templates Array of template names.
|
|
*/
|
|
add( templates ) {
|
|
templates.forEach( function( template ) {
|
|
if ( typeof template === 'string' ) {
|
|
__private.previews.set( template, wp.template( template ) );
|
|
}
|
|
} );
|
|
},
|
|
|
|
/**
|
|
* Get a templating function (to compile later with data).
|
|
*
|
|
* @since 1.4.8
|
|
*
|
|
* @param {string} template ID of a template to retrieve from a cache.
|
|
*
|
|
* @return {*} A callable that after compiling will always return a string.
|
|
*/
|
|
get( template ) {
|
|
const preview = __private.previews.get( template );
|
|
|
|
if ( typeof preview !== 'undefined' ) {
|
|
return __private.handleSubFields( preview );
|
|
}
|
|
|
|
return function() {
|
|
return '';
|
|
};
|
|
},
|
|
|
|
};
|
|
|
|
// Provide access to public functions/properties.
|
|
return app;
|
|
}( document, window, jQuery ) );
|
|
|
|
// Initialize.
|
|
WPForms.Admin.Builder.Templates.init();
|