- Create Admin Dashboard class with multiple metric categories - Add health checks for plugin dependencies and system status - Implement trainer metrics (total registrations, weekly registrations, login tracking) - Add event statistics (total/past/future/draft/cancelled events, attendee counts) - Implement revenue statistics (total revenue, weekly revenue, purchase counts) - Create maintenance controls for cache clearing, database optimization, role regeneration - Add AJAX-powered metric refresh and CSV export functionality - Include responsive dashboard UI with metric widgets - Integrate dashboard into WordPress admin menu under HVAC Community Events - Add auto-refresh capability (every 5 minutes) - Include error handling and user notifications 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
107 lines
No EOL
3.2 KiB
PHP
107 lines
No EOL
3.2 KiB
PHP
<?php
|
|
/**
|
|
* Handles plugin settings and options
|
|
*/
|
|
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
class HVAC_Settings {
|
|
public function __construct() {
|
|
add_action('admin_menu', array($this, 'add_admin_menu'));
|
|
add_action('admin_init', array($this, 'register_settings'));
|
|
}
|
|
|
|
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',
|
|
array($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',
|
|
array($this, 'options_page')
|
|
);
|
|
|
|
// Add dashboard submenu
|
|
add_submenu_page(
|
|
'hvac-community-events',
|
|
__('Dashboard', 'hvac-ce'),
|
|
__('Dashboard', 'hvac-ce'),
|
|
'manage_options',
|
|
'hvac-ce-dashboard',
|
|
array($this, 'dashboard_page')
|
|
);
|
|
}
|
|
|
|
public function register_settings() {
|
|
register_setting('hvac_ce_options', 'hvac_ce_options');
|
|
|
|
add_settings_section(
|
|
'hvac_ce_main',
|
|
__('HVAC Community Events Settings', 'hvac-ce'),
|
|
array($this, 'settings_section_callback'),
|
|
'hvac-ce'
|
|
);
|
|
|
|
add_settings_field(
|
|
'notification_emails',
|
|
__('Trainer Notification Emails', 'hvac-ce'),
|
|
array($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() {
|
|
?>
|
|
<div class="wrap">
|
|
<h1><?php esc_html_e('HVAC Community Events Settings', 'hvac-ce'); ?></h1>
|
|
<form method="post" action="options.php">
|
|
<?php
|
|
settings_fields('hvac_ce_options');
|
|
do_settings_sections('hvac-ce');
|
|
submit_button();
|
|
?>
|
|
</form>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
/**
|
|
* Dashboard page callback
|
|
*/
|
|
public function dashboard_page() {
|
|
// Load the admin dashboard class
|
|
if (!class_exists('HVAC_Admin_Dashboard')) {
|
|
require_once HVAC_CE_PLUGIN_DIR . 'includes/admin/class-admin-dashboard.php';
|
|
}
|
|
|
|
$dashboard = new HVAC_Admin_Dashboard();
|
|
$dashboard->render_page();
|
|
}
|
|
}
|