Accumulated changes from previous sessions (Feb 9-20): - Staging email filter to prevent test emails reaching real users - Version bump to 2.2.0 in plugin header - Venue geocoding enhancements and batch processing - Find Training page improvements (tab content, map data) - MapGeo integration hardening for Find a Trainer - Master trainers overview table improvements - AJAX handler additions for venue categories - SVG marker icon tweaks (trainer, venue) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
77 lines
No EOL
2.2 KiB
PHP
77 lines
No EOL
2.2 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: HVAC Community Events
|
|
* Plugin URI: https://upskillhvac.com
|
|
* Description: Custom plugin for HVAC trainer event management system
|
|
* Version: 2.2.0
|
|
* Author: Upskill HVAC
|
|
* Author URI: https://upskillhvac.com
|
|
* License: GPL-2.0+
|
|
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
|
* Text Domain: hvac-community-events
|
|
* Domain Path: /languages
|
|
*/
|
|
|
|
// Exit if accessed directly
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Staging Email Filter
|
|
* Prevents emails from being sent to anyone except allowed addresses on staging.
|
|
* This protects real users from receiving test emails during development.
|
|
*/
|
|
function hvac_is_staging_environment() {
|
|
$host = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '';
|
|
$staging_indicators = array( 'staging', 'upskill-staging', 'localhost', '127.0.0.1' );
|
|
|
|
foreach ( $staging_indicators as $indicator ) {
|
|
if ( stripos( $host, $indicator ) !== false ) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function hvac_staging_email_filter( $args ) {
|
|
if ( ! hvac_is_staging_environment() ) {
|
|
return $args;
|
|
}
|
|
|
|
$allowed_emails = array( 'ben@tealmaker.com', 'ben@measurequick.com' );
|
|
$to = $args['to'];
|
|
|
|
// Extract email address
|
|
$email_address = is_array( $to ) ? ( isset( $to[0] ) ? $to[0] : '' ) : $to;
|
|
if ( preg_match( '/<([^>]+)>/', $email_address, $matches ) ) {
|
|
$email_address = $matches[1];
|
|
}
|
|
$email_address = trim( strtolower( $email_address ) );
|
|
|
|
if ( ! in_array( $email_address, $allowed_emails, true ) ) {
|
|
error_log( sprintf( '[HVAC Staging] Blocked email to: %s | Subject: %s',
|
|
is_array( $to ) ? implode( ', ', $to ) : $to, $args['subject'] ) );
|
|
$args['to'] = '';
|
|
return $args;
|
|
}
|
|
|
|
$args['subject'] = '[STAGING] ' . $args['subject'];
|
|
return $args;
|
|
}
|
|
add_filter( 'wp_mail', 'hvac_staging_email_filter', 1 );
|
|
|
|
// Load the main plugin class
|
|
require_once plugin_dir_path(__FILE__) . 'includes/class-hvac-plugin.php';
|
|
|
|
/**
|
|
* Initialize the plugin
|
|
*
|
|
* @return HVAC_Plugin
|
|
*/
|
|
function hvac_community_events() {
|
|
return HVAC_Plugin::instance();
|
|
}
|
|
|
|
// Initialize the plugin
|
|
hvac_community_events(); |