diff --git a/.claude/settings.local.json b/.claude/settings.local.json index f5e55065..cbd1d1d0 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -103,7 +103,10 @@ "Bash(export XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.90WDB3)", "Bash(UPSKILL_STAGING_URL=\"https://upskill-staging.measurequick.com\" wp --url=$UPSKILL_STAGING_URL --ssh=root@upskill-staging.measurequick.com post get 6177 --field=post_name,post_parent,post_type)", "Bash(DISPLAY=:0 XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.90WDB3 node test-direct-access.js)", - "Bash(DISPLAY=:0 XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.90WDB3 node test-create-and-edit-event.js)" + "Bash(DISPLAY=:0 XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.90WDB3 node test-create-and-edit-event.js)", + "Bash(bin/pre-deployment-check.sh:*)", + "Bash(UPSKILL_PROD_URL=\"https://upskillhvac.com\" wp-cli.phar --url=$UPSKILL_PROD_URL --ssh=benr@146.190.76.204 post list --post_type=page --search=\"Edit Event\" --fields=ID,post_title,post_status)", + "Bash(scripts/fix-production-issues.sh:*)" ], "deny": [] }, diff --git a/assets/js/community-login.js b/assets/js/community-login.js index 650e82e8..ac8742cc 100644 --- a/assets/js/community-login.js +++ b/assets/js/community-login.js @@ -1,13 +1,12 @@ /** * HVAC Community Events: Login Form JavaScript * - * Enhanced login form functionality including password show/hide toggle, - * form validation, and loading states. + * Enhanced login form functionality following WordPress best practices. * - * @version 1.0.0 + * @version 2.0.0 */ -(function($) { +jQuery(document).ready(function($) { 'use strict'; /** @@ -208,16 +207,10 @@ } }; - /** - * Initialize all components when document is ready - */ - $(document).ready(function() { - // Only initialize if we're on a page with the login form - if ($('#hvac_community_loginform').length) { - HVACPasswordToggle.init(); - HVACLoginValidation.init(); - HVACLoginUX.init(); - } - }); - -})(jQuery); \ No newline at end of file + // Initialize all components + if ($('#hvac_community_loginform').length) { + HVACPasswordToggle.init(); + HVACLoginValidation.init(); + HVACLoginUX.init(); + } +}); \ No newline at end of file diff --git a/assets/js/hvac-jquery-compatibility-fix.js b/assets/js/hvac-jquery-compatibility-fix.js deleted file mode 100644 index 34beb399..00000000 --- a/assets/js/hvac-jquery-compatibility-fix.js +++ /dev/null @@ -1,201 +0,0 @@ -/** - * HVAC jQuery Compatibility Fix - * - * Resolves jQuery no-conflict mode issues in WordPress environments - * where $ is not available globally but window.jQuery is. - * - * This fix ensures all HVAC JavaScript files can access jQuery - * methods like removeClass, addClass, etc. without errors. - * - * @version 1.0.0 - * @date August 12, 2025 - */ - -(function() { - 'use strict'; - - console.log('๐Ÿ”ง HVAC jQuery Compatibility Fix Loading...'); - - // Ensure jQuery is available - if (typeof window.jQuery === 'undefined') { - console.error('โŒ HVAC Compatibility Fix: jQuery not found!'); - return; - } - - // Store jQuery version for debugging - const jqueryVersion = window.jQuery.fn.jquery; - console.log(`โœ… jQuery ${jqueryVersion} detected`); - - // Create global $ alias if not available - if (typeof window.$ === 'undefined') { - window.$ = window.jQuery; - console.log('๐Ÿ”— Global $ alias created from window.jQuery'); - } - - // Extend jQuery with HVAC-specific compatibility methods - window.jQuery.extend({ - hvacSafeFind: function(selector) { - try { - return window.jQuery(selector); - } catch (error) { - console.warn('โš ๏ธ HVAC Safe Find Error:', error.message, 'for selector:', selector); - return window.jQuery(); - } - } - }); - - // Add HVAC-specific jQuery methods to prototype for enhanced compatibility - window.jQuery.fn.extend({ - hvacSafeRemoveClass: function(className) { - try { - if (this.length > 0) { - return this.removeClass(className); - } - return this; - } catch (error) { - console.warn('โš ๏ธ HVAC Safe Remove Class Error:', error.message); - // Fallback to vanilla JavaScript - this.each(function() { - if (this.classList && className) { - this.classList.remove(className); - } - }); - return this; - } - }, - - hvacSafeAddClass: function(className) { - try { - if (this.length > 0) { - return this.addClass(className); - } - return this; - } catch (error) { - console.warn('โš ๏ธ HVAC Safe Add Class Error:', error.message); - // Fallback to vanilla JavaScript - this.each(function() { - if (this.classList && className) { - this.classList.add(className); - } - }); - return this; - } - }, - - hvacSafeVal: function(value) { - try { - if (typeof value !== 'undefined') { - return this.val(value); - } - return this.val(); - } catch (error) { - console.warn('โš ๏ธ HVAC Safe Val Error:', error.message); - if (this.length > 0) { - return this[0].value || ''; - } - return ''; - } - } - }); - - // Global error handler for jQuery-related errors - window.addEventListener('error', function(event) { - if (event.error && event.error.message) { - const message = event.error.message; - if (message.includes('removeClass') || - message.includes('addClass') || - message.includes('$ is not defined') || - message.includes('jQuery')) { - - console.warn('๐Ÿšจ HVAC jQuery Compatibility Issue Detected:', message); - console.warn('๐Ÿ’ก Suggestion: Use window.jQuery instead of $ or wrap code in jQuery(document).ready()'); - - // Attempt to fix common issues - if (typeof window.$ === 'undefined' && typeof window.jQuery !== 'undefined') { - window.$ = window.jQuery; - console.log('๐Ÿ”ง Auto-fixed: Created global $ alias'); - } - } - } - }); - - // Enhanced Field Population System Integration - function initializeEnhancedFieldPopulation() { - // Wait for enhanced field population system to load - const checkInterval = setInterval(function() { - if (typeof window.HVACEnhancedFieldPopulation !== 'undefined') { - console.log('โœ… Enhanced Field Population System detected'); - clearInterval(checkInterval); - - // Test the system - try { - if (typeof window.HVACEnhancedFieldPopulation.testFieldAccess === 'function') { - const testResult = window.HVACEnhancedFieldPopulation.testFieldAccess(); - console.log('๐Ÿงช Field Access Test Result:', testResult); - } - } catch (error) { - console.error('โŒ Enhanced Field Population Test Error:', error.message); - } - } - }, 500); - - // Stop checking after 10 seconds - setTimeout(function() { - clearInterval(checkInterval); - }, 10000); - } - - // Safe document ready function - function safeDocumentReady(callback) { - if (typeof window.jQuery !== 'undefined') { - window.jQuery(document).ready(callback); - } else { - if (document.readyState === 'loading') { - document.addEventListener('DOMContentLoaded', callback); - } else { - callback(); - } - } - } - - // Initialize when DOM is ready - safeDocumentReady(function() { - console.log('๐ŸŽฏ HVAC jQuery Compatibility Fix Active'); - - // Test jQuery operations - try { - const testElement = window.jQuery('
').addClass('hvac-test'); - if (testElement.hasClass('hvac-test')) { - console.log('โœ… jQuery operations working correctly'); - } - } catch (error) { - console.error('โŒ jQuery operations test failed:', error.message); - } - - // Initialize enhanced field population integration - initializeEnhancedFieldPopulation(); - - // Export compatibility functions to global scope for other scripts - window.HVACjQuery = { - safeFind: function(selector) { - return window.jQuery.hvacSafeFind(selector); - }, - safeRemoveClass: function(element, className) { - return window.jQuery(element).hvacSafeRemoveClass(className); - }, - safeAddClass: function(element, className) { - return window.jQuery(element).hvacSafeAddClass(className); - }, - safeVal: function(element, value) { - return window.jQuery(element).hvacSafeVal(value); - }, - version: jqueryVersion, - isReady: true - }; - - console.log('๐Ÿš€ HVAC jQuery Compatibility Fix Ready'); - }); - - console.log('๐Ÿ“„ HVAC jQuery Compatibility Fix Loaded'); - -})(); \ No newline at end of file diff --git a/includes/class-hvac-jquery-compatibility.php b/includes/class-hvac-jquery-compatibility.php deleted file mode 100644 index c6ec4e4c..00000000 --- a/includes/class-hvac-jquery-compatibility.php +++ /dev/null @@ -1,225 +0,0 @@ - - - post_content, 'hvac_trainer_dashboard')) { - return true; - } - - return false; - } - - /** - * Check if current page is a trainer page - */ - private static function is_trainer_page() { - $current_url = $_SERVER['REQUEST_URI'] ?? ''; - - $trainer_patterns = [ - '/trainer/', - '/master-trainer/', - '/training-login/', - '/trainer-registration/' - ]; - - foreach ($trainer_patterns as $pattern) { - if (strpos($current_url, $pattern) !== false) { - return true; - } - } - - return false; - } - - /** - * Check if current page is a TEC Community Events page - */ - private static function is_tec_community_page() { - $current_url = $_SERVER['REQUEST_URI'] ?? ''; - - $tec_patterns = [ - '/events/community/', - '/events/network/', - '/community/events/', - 'event_id=', - 'tribe-community-events' - ]; - - foreach ($tec_patterns as $pattern) { - if (strpos($current_url, $pattern) !== false) { - return true; - } - } - - // Check if TEC Community Events is active on this page - if (function_exists('tribe_is_community_edit_event_page') && tribe_is_community_edit_event_page()) { - return true; - } - - return false; - } - - /** - * Check if current page is a registration page - */ - private static function is_registration_page() { - global $post; - - if ($post) { - // Check if page uses registration template - $template = get_page_template_slug($post->ID); - if (strpos($template, 'registration') !== false) { - return true; - } - - // Check page content for registration forms - if (has_shortcode($post->post_content, 'hvac_registration_form')) { - return true; - } - } - - return false; - } - - /** - * Get compatibility status for debugging - */ - public static function get_compatibility_status() { - return [ - 'jquery_loaded' => wp_script_is('jquery', 'done'), - 'compatibility_fix_loaded' => wp_script_is('hvac-jquery-compatibility-fix', 'done'), - 'should_load' => self::should_load_compatibility_scripts(), - 'is_trainer_page' => self::is_trainer_page(), - 'is_tec_page' => self::is_tec_community_page(), - 'is_registration_page' => self::is_registration_page(), - 'current_url' => $_SERVER['REQUEST_URI'] ?? '' - ]; - } -} - -// Initialize the compatibility system -HVAC_jQuery_Compatibility::init(); \ No newline at end of file diff --git a/includes/class-hvac-plugin.php b/includes/class-hvac-plugin.php index 08fbe657..99af0512 100644 --- a/includes/class-hvac-plugin.php +++ b/includes/class-hvac-plugin.php @@ -109,8 +109,6 @@ class HVAC_Plugin { require_once HVAC_PLUGIN_DIR . 'includes/class-hvac-browser-detection.php'; require_once HVAC_PLUGIN_DIR . 'includes/class-hvac-find-trainer-assets.php'; - // jQuery compatibility system (load early to prevent JavaScript errors) - require_once HVAC_PLUGIN_DIR . 'includes/class-hvac-jquery-compatibility.php'; require_once HVAC_PLUGIN_DIR . 'includes/class-hvac-safari-debugger.php'; require_once HVAC_PLUGIN_DIR . 'includes/class-hvac-shortcodes.php'; // DISABLED - Using TEC Community Events 5.x instead diff --git a/scripts/fix-production-issues.sh b/scripts/fix-production-issues.sh new file mode 100755 index 00000000..26fa585b --- /dev/null +++ b/scripts/fix-production-issues.sh @@ -0,0 +1,102 @@ +#!/bin/bash +set -e + +# Fix Production Issues Script +# Addresses: Missing edit event page, jQuery compatibility errors + +# Colors for output +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +RED='\033[0;31m' +NC='\033[0m' # No Color + +echo -e "${YELLOW}=== Fixing Production Issues ===${NC}" +echo "Date: $(date)" +echo "" + +# Load environment variables +if [ -f .env ]; then + export $(cat .env | sed 's/#.*//g' | xargs) +fi + +# Set production variables +SERVER_IP=$UPSKILL_PROD_IP +SSH_USER=$UPSKILL_PROD_SSH_USER +SSH_PASS=$UPSKILL_PROD_PASS +SERVER_PATH=$UPSKILL_PROD_PATH +SITE_URL=$UPSKILL_PROD_URL + +echo -e "${YELLOW}Target:${NC} $SITE_URL" +echo -e "${YELLOW}Server:${NC} $SERVER_IP" +echo "" + +# Function to run WordPress CLI commands +run_wp_cli() { + local cmd="$1" + echo -e "${GREEN}Running WP-CLI:${NC} $cmd" + sshpass -p "$SSH_PASS" ssh -o StrictHostKeyChecking=no "$SSH_USER@$SERVER_IP" \ + "cd $SERVER_PATH && wp $cmd" +} + +echo -e "${YELLOW}Step 1: Creating missing Edit Event page...${NC}" + +# Check if edit event page exists +PAGE_EXISTS=$(run_wp_cli "post list --post_type=page --name='edit-event' --format=count" 2>/dev/null || echo "0") + +if [ "$PAGE_EXISTS" = "0" ]; then + echo "Creating Edit Event page..." + + # Create the edit event page + PAGE_ID=$(run_wp_cli "post create --post_type=page --post_title='Edit Event' --post_name='edit-event' --post_status=publish --post_parent=6177 --porcelain") + + if [ ! -z "$PAGE_ID" ]; then + echo -e "${GREEN}โœ… Edit Event page created with ID: $PAGE_ID${NC}" + + # Set the page template + run_wp_cli "post meta update $PAGE_ID _wp_page_template 'templates/page-edit-event-custom.php'" + echo -e "${GREEN}โœ… Page template assigned${NC}" + + # Update page content if needed + run_wp_cli "post update $PAGE_ID --post_content='[hvac_edit_event_form]'" + echo -e "${GREEN}โœ… Page content updated with shortcode${NC}" + else + echo -e "${RED}โŒ Failed to create Edit Event page${NC}" + fi +else + echo -e "${GREEN}โœ… Edit Event page already exists${NC}" +fi + +echo "" +echo -e "${YELLOW}Step 2: Updating jQuery compatibility...${NC}" + +# Clear all caches to ensure jQuery fixes are loaded +echo "Clearing caches..." +run_wp_cli "cache flush" +echo -e "${GREEN}โœ… WordPress cache cleared${NC}" + +# Clear OPcache if available +run_wp_cli "eval 'if (function_exists(\"opcache_reset\")) { opcache_reset(); echo \"OPcache cleared\"; } else { echo \"OPcache not available\"; }'" + +# Clear any object cache +run_wp_cli "eval 'if (function_exists(\"wp_cache_flush\")) { wp_cache_flush(); echo \"Object cache cleared\"; }'" + +echo "" +echo -e "${YELLOW}Step 3: Flushing rewrite rules...${NC}" +run_wp_cli "rewrite flush --hard" +echo -e "${GREEN}โœ… Rewrite rules flushed${NC}" + +echo "" +echo -e "${YELLOW}Step 4: Re-activating plugin to ensure all hooks are registered...${NC}" +run_wp_cli "plugin deactivate hvac-community-events" +run_wp_cli "plugin activate hvac-community-events" +echo -e "${GREEN}โœ… Plugin re-activated${NC}" + +echo "" +echo -e "${GREEN}=== Production fixes completed! ===${NC}" +echo "" +echo -e "${YELLOW}Verification URLs:${NC}" +echo "1. Login: $SITE_URL/training-login/" +echo "2. Dashboard: $SITE_URL/trainer/dashboard/" +echo "3. Edit Event: $SITE_URL/trainer/event/edit/" +echo "" +echo -e "${YELLOW}Please test the site functionality after these fixes.${NC}" \ No newline at end of file