Some checks failed
Security Monitoring & Compliance / Static Code Security Analysis (push) Has been cancelled
Security Monitoring & Compliance / Security Compliance Validation (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Security Analysis (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Code Quality & Standards (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Unit Tests (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Integration Tests (push) Has been cancelled
Security Monitoring & Compliance / Dependency Vulnerability Scan (push) Has been cancelled
Security Monitoring & Compliance / Secrets & Credential Scan (push) Has been cancelled
Security Monitoring & Compliance / WordPress Security Analysis (push) Has been cancelled
Security Monitoring & Compliance / Security Summary Report (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Deploy to Production (push) Has been cancelled
HVAC Plugin CI/CD Pipeline / Notification (push) Has been cancelled
Security Monitoring & Compliance / Security Team Notification (push) Has been cancelled
Major modernization of HVAC plugin for PHP 8+ with full backward compatibility: CORE MODERNIZATION: - Implement strict type declarations throughout codebase - Modernize main plugin class with PHP 8+ features - Convert array syntax to modern PHP format - Add constructor property promotion where applicable - Enhance security helpers with modern PHP patterns COMPATIBILITY FIXES: - Fix PHP 8.1+ enum compatibility (convert to class constants) - Fix union type compatibility (true|WP_Error → bool|WP_Error) - Remove mixed type declarations for PHP 8.0 compatibility - Add default arms to match expressions preventing UnhandledMatchError - Fix method naming inconsistency (ensureRegistrationAccess callback) - Add null coalescing in TEC integration for strict type compliance DEPLOYMENT STATUS: ✅ Successfully deployed and tested on staging ✅ Site functional at https://upskill-staging.measurequick.com ✅ Expert code review completed with GPT-5 validation ✅ MCP Playwright testing confirms functionality Ready for production deployment when requested. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
161 lines
No EOL
5.2 KiB
PHP
161 lines
No EOL
5.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Handles plugin settings and options
|
|
*/
|
|
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
class HVAC_Settings {
|
|
public function __construct() {
|
|
add_action('admin_menu', [$this, 'add_admin_menu']);
|
|
add_action('admin_init', [$this, 'register_settings']);
|
|
add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts']);
|
|
}
|
|
|
|
public function add_admin_menu() {
|
|
// Add main menu page
|
|
add_menu_page(
|
|
__('HVAC Community Events', 'hvac-ce'),
|
|
__('HVAC Community Events', 'hvac-ce'),
|
|
'manage_options',
|
|
'hvac-community-events',
|
|
[$this, 'options_page'],
|
|
'dashicons-calendar-alt',
|
|
30
|
|
);
|
|
|
|
// Add settings submenu
|
|
add_submenu_page(
|
|
'hvac-community-events',
|
|
__('Settings', 'hvac-ce'),
|
|
__('Settings', 'hvac-ce'),
|
|
'manage_options',
|
|
'hvac-community-events',
|
|
[$this, 'options_page']
|
|
);
|
|
|
|
// Add dashboard submenu
|
|
add_submenu_page(
|
|
'hvac-community-events',
|
|
__('Dashboard', 'hvac-ce'),
|
|
__('Dashboard', 'hvac-ce'),
|
|
'manage_options',
|
|
'hvac-ce-dashboard',
|
|
[$this, 'dashboard_page']
|
|
);
|
|
|
|
// Add trainer login link submenu
|
|
$training_login_url = home_url('training-login');
|
|
add_submenu_page(
|
|
'hvac-community-events',
|
|
__('Trainer Login', 'hvac-ce'),
|
|
__('Trainer Login', 'hvac-ce'),
|
|
'manage_options',
|
|
$training_login_url,
|
|
null
|
|
);
|
|
}
|
|
|
|
public function register_settings() {
|
|
register_setting('hvac_ce_options', 'hvac_ce_options');
|
|
|
|
add_settings_section(
|
|
'hvac_ce_main',
|
|
__('HVAC Community Events Settings', 'hvac-ce'),
|
|
[$this, 'settings_section_callback'],
|
|
'hvac-ce'
|
|
);
|
|
|
|
add_settings_field(
|
|
'notification_emails',
|
|
__('Trainer Notification Emails', 'hvac-ce'),
|
|
[$this, 'notification_emails_callback'],
|
|
'hvac-ce',
|
|
'hvac_ce_main'
|
|
);
|
|
}
|
|
|
|
public function settings_section_callback() {
|
|
echo '<p>' . __('Configure settings for HVAC Community Events', 'hvac-ce') . '</p>';
|
|
}
|
|
|
|
public function notification_emails_callback() {
|
|
$options = get_option('hvac_ce_options');
|
|
echo '<input type="text" name="hvac_ce_options[notification_emails]" value="' .
|
|
esc_attr($options['notification_emails'] ?? '') . '" class="regular-text">';
|
|
echo '<p class="description">' .
|
|
__('Comma-separated list of emails to notify when new trainers register', 'hvac-ce') . '</p>';
|
|
}
|
|
|
|
public function options_page() {
|
|
$active_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
|
|
|
|
$tabs = [
|
|
'general' => __( 'General Settings', 'hvac-ce' ),
|
|
];
|
|
|
|
// Allow other classes to add tabs
|
|
$tabs = apply_filters( 'hvac_ce_settings_tabs', $tabs );
|
|
?>
|
|
<div class="wrap">
|
|
<h1><?php esc_html_e('HVAC Community Events Settings', 'hvac-ce'); ?></h1>
|
|
|
|
<h2 class="nav-tab-wrapper">
|
|
<?php foreach ( $tabs as $tab_key => $tab_label ): ?>
|
|
<a href="?page=hvac-community-events&tab=<?php echo esc_attr( $tab_key ); ?>"
|
|
class="nav-tab <?php echo $active_tab === $tab_key ? 'nav-tab-active' : ''; ?>">
|
|
<?php echo esc_html( $tab_label ); ?>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</h2>
|
|
|
|
<?php if ( $active_tab === 'general' ): ?>
|
|
<form method="post" action="options.php">
|
|
<?php
|
|
settings_fields('hvac_ce_options');
|
|
do_settings_sections('hvac-ce');
|
|
submit_button();
|
|
?>
|
|
</form>
|
|
<?php else: ?>
|
|
<?php do_action( 'hvac_ce_settings_content', $active_tab ); ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
/**
|
|
* Dashboard page callback
|
|
*/
|
|
public function dashboard_page() {
|
|
// Load the admin dashboard class
|
|
if (!class_exists('HVAC_Admin_Dashboard')) {
|
|
require_once HVAC_PLUGIN_DIR . 'includes/admin/class-admin-dashboard.php';
|
|
}
|
|
|
|
$dashboard = new HVAC_Admin_Dashboard();
|
|
$dashboard->render_page();
|
|
}
|
|
|
|
/**
|
|
* Enqueue admin scripts and styles
|
|
*/
|
|
public function enqueue_admin_scripts($hook) {
|
|
// Only load on HVAC admin pages
|
|
if (strpos($hook, 'hvac-community-events') !== false) {
|
|
// Add inline script to make trainer login link open in new tab
|
|
$script = "
|
|
jQuery(document).ready(function($) {
|
|
// Find the trainer login menu link and make it open in new tab
|
|
$('a[href*=\"training-login\"]').attr('target', '_blank');
|
|
});
|
|
";
|
|
wp_add_inline_script('jquery', $script);
|
|
}
|
|
}
|
|
}
|