Implements automatic creation of required plugin pages (Community Login, Trainer Registration, Trainer Dashboard) upon plugin activation. This addresses E2E test failures caused by missing pages in the test environment. - Adds activation hook in `hvac-community-events.php` to call `hvac_ce_create_required_pages`. - The callback function checks for existing pages by slug and creates them using `wp_insert_post` if missing. Includes debug logging. Also fixes issues identified during E2E test debugging: - Corrects fatal error in `includes/community/class-login-handler.php` by replacing undefined constant `HVAC_COMMUNITY_EVENTS_PATH` with `HVAC_CE_PLUGIN_DIR`. - Updates `tests/e2e/tests/login.spec.ts` to use the correct selector `#wp-submit` for the login form submit button instead of `button[type="submit"]`. Documentation updates: - Adds `docs/automatic-page-creation-plan.md`. - Updates `README.md` regarding automatic page creation. - Updates Memory Bank files (`decisionLog.md`, `progress.md`, `activeContext.md`). Note: Activation hook logging did not appear during WP-CLI activation, requiring further investigation if page creation issues persist. E2E test confirmation pending.
		
			
				
	
	
		
			71 lines
		
	
	
		
			No EOL
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			71 lines
		
	
	
		
			No EOL
		
	
	
		
			2.1 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_options_page(
 | |
|             __('HVAC Community Events', 'hvac-ce'),
 | |
|             __('HVAC Community', 'hvac-ce'),
 | |
|             'manage_options',
 | |
|             'hvac-ce',
 | |
|             array($this, 'options_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
 | |
|     }
 | |
| }
 |