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>
104 lines
2.5 KiB
PHP
Executable File
104 lines
2.5 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Helper functions related to privacy, geolocation and user data.
|
|
*
|
|
* @since 1.8.0
|
|
*/
|
|
|
|
/**
|
|
* Get the user IP address.
|
|
*
|
|
* @since 1.2.5
|
|
* @since 1.7.3 Improve the IP detection quality by taking care of proxies (e.g. when the site is behind Cloudflare).
|
|
*
|
|
* Code based on the:
|
|
* - WordPress method \WP_Community_Events::get_unsafe_client_ip
|
|
* - Cloudflare documentation https://support.cloudflare.com/hc/en-us/articles/206776727
|
|
*
|
|
* @return string
|
|
*/
|
|
function wpforms_get_ip(): string {
|
|
|
|
$ip = '127.0.0.1';
|
|
|
|
$address_headers = [
|
|
'HTTP_TRUE_CLIENT_IP',
|
|
'HTTP_CF_CONNECTING_IP',
|
|
'HTTP_X_REAL_IP',
|
|
'HTTP_CLIENT_IP',
|
|
'HTTP_X_FORWARDED_FOR',
|
|
'HTTP_X_FORWARDED',
|
|
'HTTP_X_CLUSTER_CLIENT_IP',
|
|
'HTTP_FORWARDED_FOR',
|
|
'HTTP_FORWARDED',
|
|
'REMOTE_ADDR',
|
|
];
|
|
|
|
foreach ( $address_headers as $header ) {
|
|
if ( empty( $_SERVER[ $header ] ) ) {
|
|
continue;
|
|
}
|
|
|
|
/*
|
|
* HTTP_X_FORWARDED_FOR can contain a chain of comma-separated addresses, with or without spaces.
|
|
* The first address is the original client. It can't be trusted for authenticity,
|
|
* but we don't need to for this purpose.
|
|
*/
|
|
|
|
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
|
$address_chain = explode( ',', wp_unslash( $_SERVER[ $header ] ) );
|
|
$ip = filter_var( trim( $address_chain[0] ), FILTER_VALIDATE_IP );
|
|
|
|
break;
|
|
}
|
|
|
|
/**
|
|
* Filter detected IP address.
|
|
*
|
|
* @since 1.2.5
|
|
*
|
|
* @param string $ip IP address.
|
|
*/
|
|
return (string) filter_var( apply_filters( 'wpforms_get_ip', $ip ), FILTER_VALIDATE_IP );
|
|
}
|
|
|
|
/**
|
|
* Determine if collecting user's IP is allowed by GDPR setting (globally or per form).
|
|
* Majority of our users have GDPR disabled.
|
|
* So we remove this data from the request only when it's not needed:
|
|
* 1) when GDPR is enabled AND globally disabled user details storage;
|
|
* 2) when GDPR is enabled AND IP address processing is disabled on per form basis.
|
|
*
|
|
* @since 1.6.6
|
|
*
|
|
* @param array $form_data Form settings.
|
|
*
|
|
* @return bool
|
|
*/
|
|
function wpforms_is_collecting_ip_allowed( $form_data = [] ) {
|
|
|
|
if (
|
|
wpforms_setting( 'gdpr', false ) &&
|
|
(
|
|
wpforms_setting( 'gdpr-disable-details', false ) ||
|
|
( ! empty( $form_data ) && ! empty( $form_data['settings']['disable_ip'] ) )
|
|
)
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Determine if collecting cookies is allowed by GDPR setting.
|
|
*
|
|
* @since 1.7.5
|
|
*
|
|
* @return bool
|
|
*/
|
|
function wpforms_is_collecting_cookies_allowed() {
|
|
|
|
return ! ( wpforms_setting( 'gdpr', false ) && wpforms_setting( 'gdpr-disable-uuid', false ) );
|
|
}
|