diff --git a/CLAUDE.md b/CLAUDE.md index ea556d7e..4ddb8f41 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -290,4 +290,5 @@ The following systems are commented out in `/includes/class-hvac-plugin.php` lin - **Trainer Dashboard Template Refactoring (2025-08-11)**: Fixed critical dashboard and navigation issues. Root cause: hardcoded template override in `class-hvac-community-events.php` lines 804-806 forcing old shortcode-based template. Solution: removed hardcoded override, updated to use refactored `page-trainer-dashboard.php` template with proper WordPress integration. Fixed navigation menu rendering by removing conflicting `HVAC_NAV_RENDERED` constant checks in `class-hvac-menu-system.php` and page templates. Added missing `hvac-menu-system.css` file via git pull. Dashboard now displays correctly with working navigation across all trainer pages. Deployment script updated to automatically assign correct page template during deployment. - **Documentation Page Double Navigation Fix (2025-08-11)**: Resolved duplicate navigation bar issue on documentation page. Root cause: HVAC_Help_System class was rendering its own navigation (lines 223-231) via `[hvac_documentation]` shortcode while page template also rendered navigation. Solution: commented out duplicate navigation in `class-hvac-help-system.php`. Documentation page now uses comprehensive template (`page-trainer-documentation.php`) with table of contents sidebar, WordPress/Gutenberg integration, and single navigation instance. Help content provided via `HVAC_Documentation_Content` class with fallback to shortcode for empty pages. - **Custom Event Edit Implementation (2025-08-18)**: Implemented secure custom event editing without JavaScript dependencies. Created HVAC_Custom_Event_Edit class with proper authorization checks using role verification instead of capability checks. Fixed permission bug where `current_user_can('hvac_trainer')` was incorrectly used - custom roles are not capabilities. Solution: use `in_array('hvac_trainer', $user->roles)` for proper role checking. Added professional CSS styling matching registration page design with 1200px container width, card-based layout, and proper z-index layering to prevent navigation overlap. Successfully deployed to production with full functionality verified. -- **JavaScript Simplification (2025-08-18)**: Removed 200+ lines of unnecessary jQuery compatibility code following WordPress best practices. Eliminated hvac-jquery-compatibility-fix.js and class-hvac-jquery-compatibility.php. Updated community-login.js to use standard `jQuery(document).ready()` pattern. WordPress handles jQuery in no-conflict mode automatically - complex compatibility layers violate best practices and add unnecessary complexity. Production deployment successful with all functionality working correctly. \ No newline at end of file +- **JavaScript Simplification (2025-08-18)**: Removed 200+ lines of unnecessary jQuery compatibility code following WordPress best practices. Eliminated hvac-jquery-compatibility-fix.js and class-hvac-jquery-compatibility.php. Updated community-login.js to use standard `jQuery(document).ready()` pattern. WordPress handles jQuery in no-conflict mode automatically - complex compatibility layers violate best practices and add unnecessary complexity. Production deployment successful with all functionality working correctly. +- **Event Management Page UI Enhancement (2025-08-19)**: Improved trainer/event/manage/ page UX by removing redundant buttons and adding helpful event creation guide. Changes: Removed "Add New Event" and "View My Events" buttons to reduce clutter, added breadcrumb navigation to harmonize with other trainer pages, introduced "Quick Guide to Creating Events" section with 8 essential bullet points covering event types, requirements, registration options, and approval process. Guide styled with light gray background for improved readability. Maintains The Events Calendar shortcode integration. \ No newline at end of file diff --git a/scripts/create-announcements-pages.sh b/scripts/create-announcements-pages.sh new file mode 100755 index 00000000..eee2b8d0 --- /dev/null +++ b/scripts/create-announcements-pages.sh @@ -0,0 +1,142 @@ +#!/bin/bash + +# Create HVAC Announcements pages on staging server + +echo "šŸš€ Creating HVAC Announcements pages on staging..." + +# Create the PHP script content +cat > /tmp/create-pages.php << 'EOF' +ID})\n"; +echo " - Trainer (ID: {$trainer_parent->ID})\n\n"; + +// Check if pages already exist +$existing_manage = get_page_by_path('master-trainer/manage-announcements'); +$existing_view = get_page_by_path('trainer/announcements'); +$existing_resources = get_page_by_path('trainer/training-resources'); + +if ($existing_manage) { + echo "āš ļø Manage Announcements page already exists (ID: {$existing_manage->ID})\n"; +} else { + // Create Manage Announcements page + $manage_page = wp_insert_post(array( + 'post_title' => 'Manage Announcements', + 'post_name' => 'manage-announcements', + 'post_content' => '[hvac_announcements_manager]', + 'post_status' => 'publish', + 'post_type' => 'page', + 'post_parent' => $master_parent->ID, + )); + + if ($manage_page && !is_wp_error($manage_page)) { + update_post_meta($manage_page, '_wp_page_template', 'templates/page-master-manage-announcements.php'); + echo "āœ… Created: /master-trainer/manage-announcements/ (ID: $manage_page)\n"; + } else { + echo "āŒ Failed to create manage announcements page\n"; + if (is_wp_error($manage_page)) { + echo " Error: " . $manage_page->get_error_message() . "\n"; + } + } +} + +if ($existing_view) { + echo "āš ļø Announcements page already exists (ID: {$existing_view->ID})\n"; +} else { + // Create Announcements view page + $view_page = wp_insert_post(array( + 'post_title' => 'Announcements', + 'post_name' => 'announcements', + 'post_content' => '[hvac_announcements_timeline]', + 'post_status' => 'publish', + 'post_type' => 'page', + 'post_parent' => $trainer_parent->ID, + )); + + if ($view_page && !is_wp_error($view_page)) { + update_post_meta($view_page, '_wp_page_template', 'templates/page-trainer-announcements.php'); + echo "āœ… Created: /trainer/announcements/ (ID: $view_page)\n"; + } else { + echo "āŒ Failed to create announcements page\n"; + if (is_wp_error($view_page)) { + echo " Error: " . $view_page->get_error_message() . "\n"; + } + } +} + +if ($existing_resources) { + echo "āš ļø Training Resources page already exists (ID: {$existing_resources->ID})\n"; +} else { + // Create Training Resources page + $resources_page = wp_insert_post(array( + 'post_title' => 'Training Resources', + 'post_name' => 'training-resources', + 'post_content' => '[hvac_google_drive_embed url="https://drive.google.com/drive/folders/1-G8gICMsih5E9YJ2FqaC5OqG0o4rwuSP"]', + 'post_status' => 'publish', + 'post_type' => 'page', + 'post_parent' => $trainer_parent->ID, + )); + + if ($resources_page && !is_wp_error($resources_page)) { + update_post_meta($resources_page, '_wp_page_template', 'templates/page-trainer-resources.php'); + echo "āœ… Created: /trainer/training-resources/ (ID: $resources_page)\n"; + } else { + echo "āŒ Failed to create training resources page\n"; + if (is_wp_error($resources_page)) { + echo " Error: " . $resources_page->get_error_message() . "\n"; + } + } +} + +// Flush rewrite rules and clear cache +flush_rewrite_rules(); +if (function_exists('wp_cache_flush')) { + wp_cache_flush(); +} + +echo "\nšŸŽ‰ HVAC Announcements pages setup complete!\n"; +echo "\nPages should be available at:\n"; +echo "- https://upskill-staging.measurequick.com/master-trainer/manage-announcements/\n"; +echo "- https://upskill-staging.measurequick.com/trainer/announcements/\n"; +echo "- https://upskill-staging.measurequick.com/trainer/training-resources/\n"; +?> +EOF + +# Get server details from existing deployment +SERVER_IP="146.190.76.204" +SERVER_USER="roodev" +SERVER_PATH="/home/974670.cloudwaysapps.com/uberrxmprk/public_html" + +# Check if we can access the server (using the same method as deploy.sh) +echo "šŸ“” Connecting to staging server..." + +# Try to execute the PHP script +ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no ${SERVER_USER}@${SERVER_IP} " + echo 'šŸ”§ Executing page creation script on server...' + cd ${SERVER_PATH} + php /tmp/create-pages.php +" 2>/dev/null || { + echo "āŒ SSH connection failed. You may need to run this manually on the staging server." + echo "šŸ“‹ To run manually, copy this script to the staging server and execute:" + echo " php /path/to/create-pages.php" + exit 1 +} + +echo "āœ… HVAC Announcements pages creation completed!" \ No newline at end of file diff --git a/templates/page-master-manage-announcements.php b/templates/page-master-manage-announcements.php new file mode 100644 index 00000000..5cd2d580 --- /dev/null +++ b/templates/page-master-manage-announcements.php @@ -0,0 +1,124 @@ + + +
+
+ + +
+
+

+ + Manage Announcements +

+

Create and manage announcements for HVAC trainers

+
+ +
+ +
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/templates/page-trainer-announcements.php b/templates/page-trainer-announcements.php new file mode 100644 index 00000000..0978efd0 --- /dev/null +++ b/templates/page-trainer-announcements.php @@ -0,0 +1,221 @@ + + +
+
+ + +
+
+

+ + Announcements +

+

Stay updated with the latest news and updates

+
+ +
+ +
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/templates/page-trainer-training-resources.php b/templates/page-trainer-training-resources.php new file mode 100644 index 00000000..ebbb1cc9 --- /dev/null +++ b/templates/page-trainer-training-resources.php @@ -0,0 +1,137 @@ + + +
+
+ + +
+
+

+ + Training Resources +

+

Access training materials, documents, and resources

+
+ +
+ +
+ +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/test-announcements-staging.js b/test-announcements-staging.js new file mode 100644 index 00000000..1ed2f0e8 --- /dev/null +++ b/test-announcements-staging.js @@ -0,0 +1,65 @@ +const { chromium } = require('@playwright/test'); + +(async () => { + const browser = await chromium.launch({ headless: true }); + const context = await browser.newContext(); + const page = await context.newPage(); + + console.log('Testing HVAC Announcements on Staging...\n'); + + try { + // Test 1: Check if login page works + console.log('1. Testing login page...'); + await page.goto('https://upskill-staging.measurequick.com/training-login/'); + await page.waitForLoadState('networkidle', { timeout: 30000 }); + const loginTitle = await page.title(); + console.log(` āœ… Login page loaded: ${loginTitle}`); + + // Test 2: Try logging in as master trainer + console.log('\n2. Logging in as master trainer...'); + await page.fill('#user_login', 'test_master'); + await page.fill('#user_pass', 'TestMaster123!'); + await page.click('#wp-submit'); + await page.waitForNavigation({ timeout: 30000 }); + console.log(` āœ… Logged in successfully`); + + // Test 3: Check if manage announcements page exists + console.log('\n3. Checking manage announcements page...'); + await page.goto('https://upskill-staging.measurequick.com/master-trainer/manage-announcements/'); + await page.waitForLoadState('networkidle', { timeout: 30000 }); + + // Check if the page has announcements content + const hasAnnouncementsContent = await page.locator('.hvac-announcements-manager').count() > 0 || + await page.locator('#hvac-announcements-app').count() > 0 || + await page.locator('.announcement').count() > 0 || + await page.textContent('body').then(text => text.includes('Announcements')); + + if (hasAnnouncementsContent) { + console.log(' āœ… Manage announcements page is accessible'); + } else { + console.log(' āš ļø Manage announcements page might not be fully configured'); + } + + // Test 4: Check trainer view announcements + console.log('\n4. Checking trainer announcements view...'); + await page.goto('https://upskill-staging.measurequick.com/trainer/announcements/'); + await page.waitForLoadState('networkidle', { timeout: 30000 }); + + const hasTrainerView = await page.locator('.hvac-announcements-timeline').count() > 0 || + await page.locator('.hvac-announcements-list').count() > 0 || + await page.textContent('body').then(text => text.includes('announcement')); + + if (hasTrainerView) { + console.log(' āœ… Trainer announcements view is accessible'); + } else { + console.log(' āš ļø Trainer announcements view might not be configured'); + } + + console.log('\nāœ… Basic announcements testing complete!'); + + } catch (error) { + console.error('āŒ Test failed:', error.message); + } finally { + await browser.close(); + } +})(); \ No newline at end of file