diff --git a/wordpress-dev/README.md b/wordpress-dev/README.md index 98d2d190..ea44388f 100644 --- a/wordpress-dev/README.md +++ b/wordpress-dev/README.md @@ -183,6 +183,25 @@ Key findings: - Events created during testing appear in My Events page but not main dashboard - Form submission requires careful handling of TinyMCE editor and field formatting - Tests handle both iframe and textarea fallbacks for description field + +**[UPDATE 2025-05-19]** +Enhanced event creation testing with improved handling of The Events Calendar Community Events: +- ✅ Identified correct form field names and structure for event creation +- ✅ Implemented Breeze cache clearing script to ensure fresh test runs +- ✅ Created multiple test approaches for handling TinyMCE editor +- 🔧 Event creation form validation issue remains for description field + +Test infrastructure improvements: +- Created `bin/clear-breeze-cache.sh` for cache management +- Added form inspection utilities to identify exact field selectors +- Implemented screenshot capture for debugging form submissions +- Multiple test files demonstrating different approaches to form filling + +Current status: +- Event creation tests properly fill all required fields +- TinyMCE description field handling works via iframe and JavaScript injection +- Server-side validation appears to reject description despite content being present +- Further investigation needed into Community Events plugin validation logic ``` **Staging Environment Tests:** diff --git a/wordpress-dev/bin/check-created-events.sh b/wordpress-dev/bin/check-created-events.sh new file mode 100755 index 00000000..94e7a568 --- /dev/null +++ b/wordpress-dev/bin/check-created-events.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +# Get absolute path to this script's directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Navigate to wordpress-dev directory +cd "$(dirname "$SCRIPT_DIR")" || exit 1 + +# Load environment variables +ENV_FILE=".env" +if [ ! -f "$ENV_FILE" ]; then + echo "Error: .env file not found at: $ENV_FILE" + exit 1 +fi + +source "$ENV_FILE" + +# Colors for output +GREEN='\033[0;32m' +RED='\033[0;31m' +YELLOW='\033[1;33m' +NC='\033[0m' + +echo "=== Checking Created Events on Staging Server ===" +echo "Remote host: $UPSKILL_STAGING_IP" +echo "Remote user: $UPSKILL_STAGING_SSH_USER" +echo "===============================" + +# Check the recently created events by ID range +echo -e "\n${YELLOW}Finding events created today (ID range 5482-5486)...${NC}" +sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" \ +"cd ${UPSKILL_STAGING_PATH} && for ID in 5482 5483 5484 5485 5486; do wp post get \$ID --field=post_title,post_author --format=json --allow-root 2>/dev/null && echo; done" + +# Get more details about these events +echo -e "\n${YELLOW}Getting detailed info about these events...${NC}" +sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" \ +"cd ${UPSKILL_STAGING_PATH} && wp post list --post_type=tribe_events --include=5482,5483,5484,5485,5486 --fields=ID,post_title,post_author,post_status --format=table --allow-root" + +# Update these events to be owned by test_trainer +echo -e "\n${YELLOW}Updating events 5482-5486 to be owned by test_trainer...${NC}" +sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" << 'EOF' +cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html + +# Get trainer user ID +TRAINER_ID=$(wp user get test_trainer --field=ID --allow-root) +echo "Trainer ID: $TRAINER_ID" + +# Update events by ID +for EVENT_ID in 5482 5483 5484 5485 5486; do + if wp post get $EVENT_ID --allow-root >/dev/null 2>&1; then + echo "Updating event ID $EVENT_ID..." + wp post update $EVENT_ID --post_author=$TRAINER_ID --allow-root + else + echo "Event ID $EVENT_ID not found" + fi +done + +# Verify the updates +echo -e "\nVerifying updates..." +wp post list --post_type=tribe_events --author=$TRAINER_ID --fields=ID,post_title,post_author --format=table --allow-root +EOF + +echo -e "\n${GREEN}Event check completed!${NC}" \ No newline at end of file diff --git a/wordpress-dev/bin/check-dashboard-data.sh b/wordpress-dev/bin/check-dashboard-data.sh new file mode 100755 index 00000000..29bfe724 --- /dev/null +++ b/wordpress-dev/bin/check-dashboard-data.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +# Exit on error +set -e + +# Source environment variables +source .env + +echo "Checking dashboard data on staging..." + +# Get test trainer user ID +USER_ID=$(sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && wp user get test_trainer --field=ID") +echo "Test trainer user ID: $USER_ID" + +# Check events associated with this user +echo -e "\nEvents by author (post_author = $USER_ID):" +sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && wp db query \"SELECT ID, post_title, post_status, post_author FROM wp_posts WHERE post_type = 'tribe_events' AND post_author = $USER_ID\"" + +echo -e "\nEvents by organizer (meta _EventOrganizerID = $USER_ID):" +sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && wp db query \"SELECT p.ID, p.post_title, p.post_status, p.post_author, pm.meta_value as organizer_id FROM wp_posts p JOIN wp_postmeta pm ON p.ID = pm.post_id WHERE p.post_type = 'tribe_events' AND pm.meta_key = '_EventOrganizerID' AND pm.meta_value = '$USER_ID'\"" + +echo -e "\nAll events with their author and organizer:" +sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && wp db query \"SELECT p.ID, p.post_title, p.post_status, p.post_author, GROUP_CONCAT(CASE WHEN pm.meta_key = '_EventOrganizerID' THEN pm.meta_value END) as organizer_id FROM wp_posts p LEFT JOIN wp_postmeta pm ON p.ID = pm.post_id WHERE p.post_type = 'tribe_events' GROUP BY p.ID\"" + +echo -e "\nUser capabilities for test_trainer:" +sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && wp user meta get $USER_ID wp_capabilities" + +echo -e "\nDebug: Clear cache and test dashboard data class:" +sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && wp cache flush" + +# Create a PHP test script +sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && cat > test-dashboard-data.php << 'EOF' +ID; +echo \"User ID: \$user_id\\n\"; + +// Check if the class exists +if (class_exists('HVAC_Dashboard_Data')) { + echo \"Using original HVAC_Dashboard_Data\\n\"; + \$dashboard_data = new HVAC_Dashboard_Data(\$user_id); +} elseif (class_exists('HVAC_Dashboard_Data_Refactored')) { + echo \"Using refactored HVAC_Dashboard_Data_Refactored\\n\"; + \$dashboard_data = new HVAC_Dashboard_Data_Refactored(\$user_id); +} else { + die(\"Dashboard data class not found\\n\"); +} + +// Get stats +\$total_events = \$dashboard_data->get_total_events_count(); +\$upcoming_events = \$dashboard_data->get_upcoming_events_count(); +\$past_events = \$dashboard_data->get_past_events_count(); +\$total_tickets = \$dashboard_data->get_total_tickets_sold(); +\$total_revenue = \$dashboard_data->get_total_revenue(); + +echo \"Total Events: \$total_events\\n\"; +echo \"Upcoming Events: \$upcoming_events\\n\"; +echo \"Past Events: \$past_events\\n\"; +echo \"Total Tickets: \$total_tickets\\n\"; +echo \"Total Revenue: \$total_revenue\\n\"; + +// Direct query test +echo \"\\nDirect query test:\\n\"; +\$count = \$wpdb->get_var(\$wpdb->prepare( + \"SELECT COUNT(ID) FROM wp_posts WHERE post_type = %s AND post_author = %d AND post_status IN ('publish', 'future', 'draft', 'pending', 'private')\", + 'tribe_events', + \$user_id +)); +echo \"Direct count by author: \$count\\n\"; + +// Check with meta query +\$count2 = \$wpdb->get_var(\$wpdb->prepare( + \"SELECT COUNT(DISTINCT p.ID) FROM wp_posts p JOIN wp_postmeta pm ON p.ID = pm.post_id WHERE p.post_type = %s AND pm.meta_key = '_EventOrganizerID' AND pm.meta_value = %s\", + 'tribe_events', + \$user_id +)); +echo \"Count by organizer ID: \$count2\\n\"; +EOF" + +echo -e "\nRunning PHP test script:" +sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && php test-dashboard-data.php" + +# Clean up +sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && rm test-dashboard-data.php" \ No newline at end of file diff --git a/wordpress-dev/bin/check-test-data.sh b/wordpress-dev/bin/check-test-data.sh new file mode 100755 index 00000000..a8cdb60a --- /dev/null +++ b/wordpress-dev/bin/check-test-data.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# Get absolute path to this script's directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Navigate to wordpress-dev directory +cd "$(dirname "$SCRIPT_DIR")" || exit 1 + +# Load environment variables +ENV_FILE=".env" +if [ ! -f "$ENV_FILE" ]; then + echo "Error: .env file not found at: $ENV_FILE" + exit 1 +fi + +source "$ENV_FILE" + +# Colors for output +GREEN='\033[0;32m' +RED='\033[0;31m' +YELLOW='\033[1;33m' +NC='\033[0m' + +echo "=== Checking Test Data on Staging Server ===" +echo "Remote host: $UPSKILL_STAGING_IP" +echo "Remote user: $UPSKILL_STAGING_SSH_USER" +echo "===============================" + +# Get test_trainer user ID +echo -e "\n${YELLOW}Getting test_trainer user ID...${NC}" +sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" \ +"cd ${UPSKILL_STAGING_PATH} && wp user get test_trainer --field=ID --allow-root" + +# Check events created by test_trainer +echo -e "\n${YELLOW}Events created by test_trainer:${NC}" +sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" \ +"cd ${UPSKILL_STAGING_PATH} && wp post list --post_type=tribe_events --author=\$(wp user get test_trainer --field=ID --allow-root) --fields=ID,post_title,post_status,post_author --format=table --allow-root" + +# Check all events +echo -e "\n${YELLOW}All events in the system:${NC}" +sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" \ +"cd ${UPSKILL_STAGING_PATH} && wp post list --post_type=tribe_events --fields=ID,post_title,post_status,post_author --format=table --number=20 --allow-root" + +# Check event meta data +echo -e "\n${YELLOW}Checking event meta data for a sample event:${NC}" +sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" \ +"cd ${UPSKILL_STAGING_PATH} && wp post meta list \$(wp post list --post_type=tribe_events --field=ID --number=1 --orderby=ID --order=DESC --allow-root) --fields=meta_key,meta_value --format=table --allow-root | grep -E '_Event|Cost'" + +# Check ticket/attendee data +echo -e "\n${YELLOW}Checking for ticket data:${NC}" +sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" \ +"cd ${UPSKILL_STAGING_PATH} && wp post list --post_type=tribe_tpp_attendees --fields=ID,post_title,post_status --format=table --number=10 --allow-root" + +# Check roles and capabilities +echo -e "\n${YELLOW}Checking test_trainer roles and capabilities:${NC}" +sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" \ +"cd ${UPSKILL_STAGING_PATH} && wp user get test_trainer --field=roles --allow-root" + +echo -e "\n${GREEN}Data check completed!${NC}" \ No newline at end of file diff --git a/wordpress-dev/bin/clear-breeze-cache.sh b/wordpress-dev/bin/clear-breeze-cache.sh new file mode 100755 index 00000000..b3027faa --- /dev/null +++ b/wordpress-dev/bin/clear-breeze-cache.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +# Get absolute path to this script's directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Navigate to wordpress-dev directory +cd "$(dirname "$SCRIPT_DIR")" || exit 1 + +# Load environment variables +ENV_FILE=".env" +if [ ! -f "$ENV_FILE" ]; then + echo "Error: .env file not found at: $ENV_FILE" + exit 1 +fi + +source "$ENV_FILE" + +# Colors for output +GREEN='\033[0;32m' +RED='\033[0;31m' +YELLOW='\033[1;33m' +NC='\033[0m' + +echo -e "${YELLOW}=== Clearing Breeze Cache on Staging Server ===${NC}" +echo "Remote host: $UPSKILL_STAGING_IP" +echo "Remote user: $UPSKILL_STAGING_SSH_USER" +echo "WordPress path: $UPSKILL_STAGING_PATH" +echo "===============================" + +# Method 1: Try to clear Breeze cache using direct file system approach +echo -e "\n${YELLOW}Clearing Breeze cache files...${NC}" +sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" \ +"cd ${UPSKILL_STAGING_PATH} && find wp-content/cache/breeze -type f -name '*.php' -delete 2>/dev/null" + +if [ $? -eq 0 ]; then + echo -e "${GREEN}✓ Breeze cache files cleared${NC}" +else + echo -e "${YELLOW}Note: No Breeze cache files found or clearing failed${NC}" +fi + +# Method 2: Clear Breeze minified files +echo -e "\n${YELLOW}Clearing Breeze minified files...${NC}" +sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" \ +"cd ${UPSKILL_STAGING_PATH} && rm -rf wp-content/uploads/breeze/js/* wp-content/uploads/breeze/css/* 2>/dev/null" + +if [ $? -eq 0 ]; then + echo -e "${GREEN}✓ Breeze minified files cleared${NC}" +else + echo -e "${YELLOW}Note: No minified files found${NC}" +fi + +# Method 3: Try using WordPress transient API +echo -e "\n${YELLOW}Clearing Breeze-related transients...${NC}" +sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" \ +"cd ${UPSKILL_STAGING_PATH} && wp transient delete '_breeze_minification' --allow-root 2>/dev/null" + +# Also clear object cache if exists +echo -e "\n${YELLOW}Clearing object cache...${NC}" +sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" \ +"cd ${UPSKILL_STAGING_PATH} && wp cache flush --allow-root" + +if [ $? -eq 0 ]; then + echo -e "${GREEN}✓ Object cache cleared${NC}" +else + echo -e "${YELLOW}Note: Object cache clearing failed (might not be enabled)${NC}" +fi + +# Clear transients +echo -e "\n${YELLOW}Clearing transients...${NC}" +sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" \ +"cd ${UPSKILL_STAGING_PATH} && wp transient delete --all --allow-root" + +if [ $? -eq 0 ]; then + echo -e "${GREEN}✓ Transients cleared${NC}" +else + echo -e "${YELLOW}Note: Transient clearing failed${NC}" +fi + +echo -e "\n${GREEN}Cache clearing completed!${NC}" \ No newline at end of file diff --git a/wordpress-dev/bin/comprehensive-debug.sh b/wordpress-dev/bin/comprehensive-debug.sh new file mode 100755 index 00000000..ed0095d7 --- /dev/null +++ b/wordpress-dev/bin/comprehensive-debug.sh @@ -0,0 +1,155 @@ +#!/bin/bash + +# Comprehensive debug of event queries + +# Get absolute path to this script's directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Navigate to wordpress-dev directory +cd "$(dirname "$SCRIPT_DIR")" || exit 1 + +# Load environment variables +ENV_FILE=".env" +if [ ! -f "$ENV_FILE" ]; then + echo "Error: .env file not found at: $ENV_FILE" + exit 1 +fi + +source "$ENV_FILE" + +echo "=== Comprehensive Event Query Debug ===" +echo "Remote host: $UPSKILL_STAGING_IP" +echo "===============================" + +# Create comprehensive debug script +cat << 'EOF' > /tmp/debug-events.php +ID . "\n"; +echo "User login: " . $user->user_login . "\n"; +echo "User roles: " . implode(', ', $user->roles) . "\n\n"; + +// 2. Direct DB query to see all events +echo "2. All tribe_events in database (direct query):\n"; +global $wpdb; +$all_events = $wpdb->get_results("SELECT ID, post_title, post_author, post_status FROM {$wpdb->posts} WHERE post_type='tribe_events' ORDER BY ID DESC LIMIT 10"); +foreach ($all_events as $event) { + echo "ID: {$event->ID}, Title: {$event->post_title}, Author: {$event->post_author}, Status: {$event->post_status}\n"; +} +echo "\n"; + +// 3. Our specific events +echo "3. Our created events (5482-5486):\n"; +$our_events = $wpdb->get_results("SELECT ID, post_title, post_author, post_status FROM {$wpdb->posts} WHERE ID IN (5482,5483,5484,5485,5486)"); +foreach ($our_events as $event) { + echo "ID: {$event->ID}, Title: {$event->post_title}, Author: {$event->post_author}, Status: {$event->post_status}\n"; +} +echo "\n"; + +// 4. Test WP_Query with various approaches +echo "4. Testing WP_Query approaches:\n"; + +// Test A: Simple author query +echo "Test A - Simple author query:\n"; +$args_a = array( + 'post_type' => 'tribe_events', + 'author' => 17, + 'posts_per_page' => -1, + 'post_status' => 'any' +); +$query_a = new WP_Query($args_a); +echo "Found: " . $query_a->found_posts . "\n"; +echo "SQL: " . $query_a->request . "\n\n"; + +// Test B: With suppress_filters +echo "Test B - With suppress_filters:\n"; +$args_b = $args_a; +$args_b['suppress_filters'] = true; +$query_b = new WP_Query($args_b); +echo "Found: " . $query_b->found_posts . "\n"; +echo "SQL: " . $query_b->request . "\n\n"; + +// Test C: Direct get_posts +echo "Test C - Direct get_posts:\n"; +$posts_c = get_posts(array( + 'post_type' => 'tribe_events', + 'author' => 17, + 'posts_per_page' => -1, + 'post_status' => 'any', + 'suppress_filters' => true +)); +echo "Found: " . count($posts_c) . "\n\n"; + +// 5. Check TEC-specific methods +echo "5. TEC-specific methods:\n"; +if (class_exists('Tribe__Events__Query')) { + echo "Using tribe_get_events:\n"; + $tribe_events = tribe_get_events(array( + 'author' => 17, + 'posts_per_page' => -1, + 'post_status' => 'any' + )); + echo "Found: " . count($tribe_events) . "\n"; +} +echo "\n"; + +// 6. Check active filters +echo "6. Active filters on pre_get_posts:\n"; +global $wp_filter; +if (isset($wp_filter['pre_get_posts'])) { + foreach ($wp_filter['pre_get_posts'] as $priority => $callbacks) { + foreach ($callbacks as $callback) { + if (is_array($callback['function'])) { + $class = is_object($callback['function'][0]) ? get_class($callback['function'][0]) : $callback['function'][0]; + $method = $callback['function'][1]; + echo "Priority $priority: {$class}::{$method}\n"; + } else { + echo "Priority $priority: " . $callback['function'] . "\n"; + } + } + } +} +echo "\n"; + +// 7. Check what happens when we query by ID +echo "7. Query by post ID (should work):\n"; +$args_id = array( + 'post_type' => 'tribe_events', + 'post__in' => array(5482, 5483, 5484, 5485, 5486), + 'posts_per_page' => -1, + 'post_status' => 'any' +); +$query_id = new WP_Query($args_id); +echo "Found: " . $query_id->found_posts . "\n"; +foreach ($query_id->posts as $post) { + echo "ID: {$post->ID}, Author: {$post->post_author}, Title: {$post->post_title}\n"; +} +echo "\n"; + +// 8. Test dashboard data class +echo "8. Testing HVAC Dashboard Data class:\n"; +require_once '/home/974670.cloudwaysapps.com/uberrxmprk/public_html/wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data.php'; +$dashboard = new HVAC_Dashboard_Data(17); +echo "Total events: " . $dashboard->get_total_events_count() . "\n"; +echo "Upcoming events: " . $dashboard->get_upcoming_events_count() . "\n"; +echo "Past events: " . $dashboard->get_past_events_count() . "\n"; + +echo "\n=== END DEBUG ===\n"; +EOF + +# Upload and execute +sshpass -p "${UPSKILL_STAGING_PASS}" scp /tmp/debug-events.php "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}:/home/974670.cloudwaysapps.com/uberrxmprk/" +sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" "cd /home/974670.cloudwaysapps.com/uberrxmprk && php debug-events.php" + +# Clean up +rm /tmp/debug-events.php +sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" "rm /home/974670.cloudwaysapps.com/uberrxmprk/debug-events.php" + +echo "Debug completed!" \ No newline at end of file diff --git a/wordpress-dev/bin/create-test-tickets.sh b/wordpress-dev/bin/create-test-tickets.sh new file mode 100644 index 00000000..2a311b5c --- /dev/null +++ b/wordpress-dev/bin/create-test-tickets.sh @@ -0,0 +1,146 @@ +#!/bin/bash + +# Create tickets and attendees for test events on staging server + +# Variables +SSH_USER="roodev" +SSH_HOST="146.190.76.204" + +echo "=== Creating Test Tickets on Staging Server ===" +echo "Remote host: $SSH_HOST" +echo "Remote user: $SSH_USER" +echo "===============================" + +# Create PHP script to run on server +cat << 'EOF' > create-tickets.php + [ // HVAC System Maintenance Workshop + 'price' => 200, + 'attendees' => 5, + 'capacity' => 50 + ], + 5483 => [ // Advanced Diagnostics Training + 'price' => 350, + 'attendees' => 8, + 'capacity' => 30 + ], + 5484 => [ // Energy Efficiency Certification + 'price' => 500, + 'attendees' => 12, + 'capacity' => 40 + ], + 5485 => [ // Refrigeration Masterclass + 'price' => 300, + 'attendees' => 15, + 'capacity' => 50 + ], + 5486 => [ // HVAC Business Development Summit + 'price' => 1000, + 'attendees' => 7, + 'capacity' => 100 + ] +]; + +foreach ($events as $event_id => $event_data) { + // Check if event exists + $event = get_post($event_id); + if (!$event) { + echo "Event $event_id not found, skipping\n"; + continue; + } + + echo "Processing event: {$event->post_title} (ID: $event_id)\n"; + + // Create ticket for this event + $ticket_args = [ + 'post_type' => 'tribe_tpp_tickets', + 'post_status' => 'publish', + 'post_title' => "{$event->post_title} - General Admission", + 'meta_input' => [ + '_tribe_tpp_enabled' => 'yes', + '_price' => $event_data['price'], + '_stock' => $event_data['capacity'], + '_capacity' => $event_data['capacity'], + '_manage_stock' => 'yes', + '_ticket_start_date' => '2025-01-01 00:00:00', + '_ticket_end_date' => '2025-12-31 23:59:59', + ] + ]; + + $ticket_id = wp_insert_post($ticket_args); + + if (is_wp_error($ticket_id)) { + echo "Failed to create ticket for event $event_id: " . $ticket_id->get_error_message() . "\n"; + continue; + } + + // Associate ticket with event + update_post_meta($ticket_id, '_tribe_tpp_for_event', $event_id); + update_post_meta($event_id, '_tribe_default_ticket_provider', 'Tribe__Tickets_Plus__Commerce__PayPal__Main'); + + echo "Created ticket ID: $ticket_id\n"; + + // Create attendees + for ($i = 1; $i <= $event_data['attendees']; $i++) { + $attendee_args = [ + 'post_type' => 'tribe_tpp_attendees', + 'post_status' => 'publish', + 'post_title' => "Attendee $i for {$event->post_title}", + 'meta_input' => [ + '_tribe_tpp_event' => $event_id, + '_tribe_tpp_product' => $ticket_id, + '_tribe_tpp_ticket' => $ticket_id, + '_tribe_tpp_price_paid' => $event_data['price'], + '_tribe_tpp_order_status' => 'completed', + '_tribe_tpp_security_code' => wp_generate_password(10, false), + '_tribe_tpp_attendee_user_id' => 0, + '_tribe_tpp_attendee_email' => "attendee{$i}_{$event_id}@test.com", + '_tribe_tpp_attendee_full_name' => "Test Attendee $i", + '_tribe_tpp_checked_in' => '', + '_tribe_deleted' => 0, + ] + ]; + + $attendee_id = wp_insert_post($attendee_args); + + if (is_wp_error($attendee_id)) { + echo "Failed to create attendee for event $event_id: " . $attendee_id->get_error_message() . "\n"; + } else { + echo "Created attendee ID: $attendee_id\n"; + + // Update event attendance + $current_count = get_post_meta($event_id, '_tribe_ticket_sold_count', true); + update_post_meta($event_id, '_tribe_ticket_sold_count', intval($current_count) + 1); + } + } + + // Update ticket stock + $remaining_stock = $event_data['capacity'] - $event_data['attendees']; + update_post_meta($ticket_id, '_stock', $remaining_stock); + update_post_meta($ticket_id, '_total_sales', $event_data['attendees']); + + echo "Completed processing event $event_id\n\n"; +} + +echo "All tickets and attendees created successfully\n"; +EOF + +# Copy PHP script to server and execute +sshpass -p "$SSH_PASS" scp create-tickets.php $SSH_USER@$SSH_HOST:$WP_ROOT/ +sshpass -p "$SSH_PASS" ssh $SSH_USER@$SSH_HOST "cd $WP_ROOT && /usr/bin/php create-tickets.php" + +# Clean up +rm create-tickets.php +sshpass -p "$SSH_PASS" ssh $SSH_USER@$SSH_HOST "rm $WP_ROOT/create-tickets.php" + +echo -e "\033[0;32mTicket creation completed!\033[0m" \ No newline at end of file diff --git a/wordpress-dev/bin/debug-dashboard-live.sh b/wordpress-dev/bin/debug-dashboard-live.sh new file mode 100755 index 00000000..de14bd7b --- /dev/null +++ b/wordpress-dev/bin/debug-dashboard-live.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +# Debug dashboard live on server + +# Get absolute path to this script's directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Navigate to wordpress-dev directory +cd "$(dirname "$SCRIPT_DIR")" || exit 1 + +# Load environment variables +ENV_FILE=".env" +if [ ! -f "$ENV_FILE" ]; then + echo "Error: .env file not found at: $ENV_FILE" + exit 1 +fi + +source "$ENV_FILE" + +echo "=== Debugging Dashboard Live ===" +echo "Remote host: $UPSKILL_STAGING_IP" +echo "===============================" + +# Debug dashboard +sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" <<'EOF' +cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html + +# Create debug script +cat > debug-dashboard.php << 'PHP' +get_total_events_count() . "\n"; +echo "Upcoming events: " . $dashboard->get_upcoming_events_count() . "\n"; +echo "Past events: " . $dashboard->get_past_events_count() . "\n\n"; + +// Test a raw query +echo "Raw query test:\n"; +$args = array( + 'post_type' => 'tribe_events', + 'author' => 17, + 'posts_per_page' => -1, + 'post_status' => 'any' +); +$query = new WP_Query($args); +echo "Found: " . $query->found_posts . "\n"; +echo "SQL: " . $query->request . "\n\n"; + +// Check cache +echo "Cache status:\n"; +$cache_group = 'counts'; +$cache_key = 'hvac_events_17'; +$cached = wp_cache_get($cache_key, $cache_group); +echo "Cached value: " . var_export($cached, true) . "\n"; + +// Clear cache and try again +wp_cache_flush(); +echo "\nAfter cache flush:\n"; +echo "Total events: " . $dashboard->get_total_events_count() . "\n"; + +PHP + +php debug-dashboard.php +rm debug-dashboard.php +EOF + +echo "Debug completed!" \ No newline at end of file diff --git a/wordpress-dev/bin/debug-dashboard-template.sh b/wordpress-dev/bin/debug-dashboard-template.sh new file mode 100755 index 00000000..93c07f7b --- /dev/null +++ b/wordpress-dev/bin/debug-dashboard-template.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +# Exit on error +set -e + +# Source environment variables +source .env + +echo "Debugging dashboard template data..." + +# Create a debug version of the dashboard template +sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && cat > wp-content/plugins/hvac-community-events/templates/template-hvac-dashboard-debug.php << 'EOF' +get_total_events_count(); +\$upcoming_events = \$dashboard_data->get_upcoming_events_count(); +\$past_events = \$dashboard_data->get_past_events_count(); +\$total_sold = \$dashboard_data->get_total_tickets_sold(); +\$total_revenue = \$dashboard_data->get_total_revenue(); +\$revenue_target = \$dashboard_data->get_annual_revenue_target(); + +// Debug output +echo '
';
+echo 'User ID: ' . \$user_id . \"\\n\";
+echo 'Total Events: ' . \$total_events . \"\\n\";
+echo 'Upcoming Events: ' . \$upcoming_events . \"\\n\";
+echo 'Past Events: ' . \$past_events . \"\\n\";
+echo 'Total Sold: ' . \$total_sold . \"\\n\";
+echo 'Total Revenue: ' . \$total_revenue . \"\\n\";
+echo 'Revenue Target: ' . \$revenue_target . \"\\n\\n\";
+
+// Direct database query test
+global \$wpdb;
+\$direct_count = \$wpdb->get_var(\$wpdb->prepare(
+ \"SELECT COUNT(ID) FROM wp_posts WHERE post_type = %s AND post_author = %d AND post_status IN ('publish', 'future', 'draft', 'pending', 'private')\",
+ 'tribe_events',
+ \$user_id
+));
+echo 'Direct Count: ' . \$direct_count . \"\\n\\n\";
+
+// Get actual events with details
+\$events_query = new WP_Query(array(
+ 'post_type' => 'tribe_events',
+ 'post_author' => \$user_id,
+ 'post_status' => array('publish', 'future', 'draft', 'pending', 'private'),
+ 'posts_per_page' => -1
+));
+
+echo 'WP_Query found posts: ' . \$events_query->found_posts . \"\\n\";
+echo 'Events:\\n';
+foreach (\$events_query->posts as \$event) {
+ echo ' - ID: ' . \$event->ID . ', Title: ' . \$event->post_title . ', Status: ' . \$event->post_status . \"\\n\";
+}
+
+// Get the SQL query
+echo \"\\nGenerated SQL:\\n\";
+echo \$events_query->request . \"\\n\";
+
+echo '';
+
+// Include the original template
+include HVAC_CE_PLUGIN_DIR . 'templates/template-hvac-dashboard.php';
+EOF"
+
+# Create a page that uses this debug template
+echo -e "\nCreating debug page..."
+sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && wp post create --post_type=page --post_title='Dashboard Debug' --post_name='dashboard-debug' --post_status=publish --post_content='Debug Dashboard Page'"
+
+# Update the template loading to use debug version temporarily
+sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && cat > wp-content/plugins/hvac-community-events/includes/debug-template-loader.php << 'EOF'
+> wp-content/plugins/hvac-community-events/hvac-community-events.php"
+
+echo -e "\nDebug page created. Visit: https://wordpress-974670-5399585.cloudwaysapps.com/dashboard-debug/"
\ No newline at end of file
diff --git a/wordpress-dev/bin/debug-events.sh b/wordpress-dev/bin/debug-events.sh
new file mode 100755
index 00000000..609caf80
--- /dev/null
+++ b/wordpress-dev/bin/debug-events.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+# Debug events on staging server
+
+# Get absolute path to this script's directory
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+# Navigate to wordpress-dev directory
+cd "$(dirname "$SCRIPT_DIR")" || exit 1
+
+# Load environment variables
+ENV_FILE=".env"
+if [ ! -f "$ENV_FILE" ]; then
+ echo "Error: .env file not found at: $ENV_FILE"
+ exit 1
+fi
+
+source "$ENV_FILE"
+
+# Colors for output
+GREEN='\033[0;32m'
+RED='\033[0;31m'
+YELLOW='\033[1;33m'
+NC='\033[0m'
+
+echo "=== Debugging Events on Staging Server ==="
+echo "Remote host: $UPSKILL_STAGING_IP"
+echo "Remote user: $UPSKILL_STAGING_SSH_USER"
+echo "==============================="
+
+# Debug events
+sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" <<'EOF'
+cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html
+
+echo "Test trainer user ID:"
+wp user get test_trainer --field=ID --allow-root
+
+echo -e "\nAll events (showing post author):"
+wp post list --post_type=tribe_events --fields=ID,post_title,post_author --allow-root
+
+echo -e "\nEvents by test_trainer (using author query):"
+wp post list --post_type=tribe_events --author=17 --fields=ID,post_title --allow-root
+
+echo -e "\nDetailed info for event 5482:"
+wp post get 5482 --fields=ID,post_title,post_author,post_status --allow-root
+
+echo -e "\nOrganizer metadata for event 5482:"
+wp post meta get 5482 _EventOrganizerID --allow-root
+
+echo -e "\nAll metadata for event 5482:"
+wp post meta list 5482 --format=table --allow-root | grep -E "_Event|_tribe"
+
+echo -e "\nEvents with any author (testing query):"
+wp post list --post_type=tribe_events --posts_per_page=10 --fields=ID,post_author,post_title --allow-root
+
+echo -e "\nWorking directory events:"
+wp db query "SELECT ID, post_title, post_author FROM wp_posts WHERE post_type='tribe_events' AND ID IN (5482,5483,5484,5485,5486);" --allow-root
+EOF
+
+echo -e "\n${GREEN}Debug completed!${NC}"
\ No newline at end of file
diff --git a/wordpress-dev/bin/debug-filters.sh b/wordpress-dev/bin/debug-filters.sh
new file mode 100755
index 00000000..f5df00e0
--- /dev/null
+++ b/wordpress-dev/bin/debug-filters.sh
@@ -0,0 +1,93 @@
+#!/bin/bash
+
+# Debug WordPress filters affecting queries
+
+# Get absolute path to this script's directory
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+# Navigate to wordpress-dev directory
+cd "$(dirname "$SCRIPT_DIR")" || exit 1
+
+# Load environment variables
+ENV_FILE=".env"
+if [ ! -f "$ENV_FILE" ]; then
+ echo "Error: .env file not found at: $ENV_FILE"
+ exit 1
+fi
+
+source "$ENV_FILE"
+
+echo "=== Debugging Query Filters ==="
+echo "Remote host: $UPSKILL_STAGING_IP"
+echo "==============================="
+
+# Test query filters
+sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" <<'EOF'
+cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html
+
+# Create PHP test script
+cat > debug-filters.php << 'PHP'
+ 'tribe_events',
+ 'author' => 17,
+ 'post_status' => 'any',
+ 'posts_per_page' => 5,
+ 'suppress_filters' => false
+);
+$query = new WP_Query($args);
+echo "Found posts: " . $query->found_posts . "\n";
+echo "SQL: " . $query->request . "\n\n";
+
+// Try with suppress_filters
+echo "Test 2: With suppress_filters = true\n";
+$args['suppress_filters'] = true;
+$query2 = new WP_Query($args);
+echo "Found posts: " . $query2->found_posts . "\n";
+echo "SQL: " . $query2->request . "\n\n";
+
+// Check if Community Events is filtering queries
+echo "Test 3: Check active plugins\n";
+$active_plugins = get_option('active_plugins');
+foreach ($active_plugins as $plugin) {
+ if (strpos($plugin, 'community') !== false || strpos($plugin, 'events') !== false) {
+ echo "Active: " . $plugin . "\n";
+ }
+}
+
+// Check specific event
+echo "\nTest 4: Get specific event\n";
+$event = get_post(5482);
+if ($event) {
+ echo "Event 5482 exists\n";
+ echo "Author: " . $event->post_author . "\n";
+ echo "Type: " . $event->post_type . "\n";
+ echo "Status: " . $event->post_status . "\n";
+}
+
+// Check capabilities
+echo "\nTest 5: User capabilities\n";
+$user = get_user_by('ID', 17);
+if ($user) {
+ echo "User login: " . $user->user_login . "\n";
+ echo "Roles: " . implode(', ', $user->roles) . "\n";
+ echo "Can read private posts: " . ($user->has_cap('read_private_posts') ? 'Yes' : 'No') . "\n";
+ echo "Can edit posts: " . ($user->has_cap('edit_posts') ? 'Yes' : 'No') . "\n";
+}
+PHP
+
+php debug-filters.php
+rm debug-filters.php
+EOF
+
+echo "Debug completed!"
\ No newline at end of file
diff --git a/wordpress-dev/bin/debug-template.sh b/wordpress-dev/bin/debug-template.sh
new file mode 100755
index 00000000..8479e87a
--- /dev/null
+++ b/wordpress-dev/bin/debug-template.sh
@@ -0,0 +1,85 @@
+#!/bin/bash
+
+# Debug template rendering
+
+# Get absolute path to this script's directory
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+# Navigate to wordpress-dev directory
+cd "$(dirname "$SCRIPT_DIR")" || exit 1
+
+# Load environment variables
+ENV_FILE=".env"
+if [ ! -f "$ENV_FILE" ]; then
+ echo "Error: .env file not found at: $ENV_FILE"
+ exit 1
+fi
+
+source "$ENV_FILE"
+
+echo "=== Debugging Template Rendering ==="
+echo "Remote host: $UPSKILL_STAGING_IP"
+echo "==============================="
+
+# Debug template
+sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" <<'EOF'
+cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html
+
+# Create debug script
+cat > debug-template.php << 'PHP'
+ID);
+wp_set_auth_cookie($user->ID);
+
+echo "=== TEMPLATE DEBUG ===\n\n";
+
+// Check current user
+echo "Current user: " . get_current_user_id() . "\n";
+echo "Can view dashboard: " . (current_user_can('view_hvac_dashboard') ? 'Yes' : 'No') . "\n\n";
+
+// Load dashboard data
+require_once '/home/974670.cloudwaysapps.com/uberrxmprk/public_html/wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data.php';
+$dashboard_data = new HVAC_Dashboard_Data(get_current_user_id());
+
+// Get data
+$total_events = $dashboard_data->get_total_events_count();
+$upcoming_events = $dashboard_data->get_upcoming_events_count();
+$past_events = $dashboard_data->get_past_events_count();
+$total_sold = $dashboard_data->get_total_tickets_sold();
+$total_revenue = $dashboard_data->get_total_revenue();
+
+echo "Dashboard data:\n";
+echo "Total events: $total_events\n";
+echo "Upcoming events: $upcoming_events\n";
+echo "Past events: $past_events\n";
+echo "Total sold: $total_sold\n";
+echo "Total revenue: $total_revenue\n\n";
+
+// Check if variables are being overridden
+echo "Checking global scope:\n";
+$GLOBALS['total_events'] = isset($GLOBALS['total_events']) ? $GLOBALS['total_events'] : 'not set';
+echo "Global total_events: " . $GLOBALS['total_events'] . "\n\n";
+
+// Test template directly
+echo "Testing template include:\n";
+global $total_events_test;
+$total_events_test = $total_events;
+echo "Set test variable to: $total_events_test\n";
+
+// Check theme template redirect
+echo "\nChecking template redirect:\n";
+$template = locate_template('template-hvac-dashboard.php');
+echo "Theme template found: " . ($template ? $template : 'No') . "\n";
+
+PHP
+
+php debug-template.php
+rm debug-template.php
+EOF
+
+echo "Debug completed!"
\ No newline at end of file
diff --git a/wordpress-dev/bin/deploy-dashboard-fix-v2.sh b/wordpress-dev/bin/deploy-dashboard-fix-v2.sh
new file mode 100755
index 00000000..e8f151a2
--- /dev/null
+++ b/wordpress-dev/bin/deploy-dashboard-fix-v2.sh
@@ -0,0 +1,301 @@
+#!/bin/bash
+
+# Exit on error
+set -e
+
+# Source environment variables
+source .env
+
+echo "Deploying dashboard fix to staging..."
+
+# Create backup and upload fix directly via SSH
+echo "Creating fix on staging server..."
+sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && cat > wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data-fixed.php << 'EOF'
+user_id = \$user_id;
+ }
+
+ /**
+ * Get the total number of events created by the trainer.
+ *
+ * @return int
+ */
+ public function get_total_events_count() : int {
+ \$args = array(
+ 'post_type' => Tribe__Events__Main::POSTTYPE,
+ 'author' => \$this->user_id,
+ 'post_status' => array( 'publish', 'future', 'draft', 'pending', 'private' ),
+ 'posts_per_page' => -1,
+ 'fields' => 'ids',
+ );
+ \$query = new WP_Query( \$args );
+ return (int) \$query->found_posts;
+ }
+
+ /**
+ * Get the number of upcoming events for the trainer.
+ *
+ * @return int
+ */
+ public function get_upcoming_events_count() : int {
+ \$today = current_time( 'mysql' );
+ \$args = array(
+ 'post_type' => Tribe__Events__Main::POSTTYPE,
+ 'author' => \$this->user_id, // Use author consistently
+ 'post_status' => array( 'publish', 'future' ),
+ 'posts_per_page' => -1,
+ 'fields' => 'ids',
+ 'meta_query' => array(
+ array(
+ 'key' => '_EventStartDate',
+ 'value' => \$today,
+ 'compare' => '>=',
+ 'type' => 'DATETIME',
+ ),
+ ),
+ 'orderby' => 'meta_value',
+ 'meta_key' => '_EventStartDate',
+ 'order' => 'ASC',
+ );
+ \$query = new WP_Query( \$args );
+ return (int) \$query->found_posts;
+ }
+
+ /**
+ * Get the number of past events for the trainer.
+ *
+ * @return int
+ */
+ public function get_past_events_count() : int {
+ \$today = current_time( 'mysql' );
+ \$args = array(
+ 'post_type' => Tribe__Events__Main::POSTTYPE,
+ 'author' => \$this->user_id, // Use author consistently
+ 'post_status' => array( 'publish', 'private' ),
+ 'posts_per_page' => -1,
+ 'fields' => 'ids',
+ 'meta_query' => array(
+ array(
+ 'key' => '_EventEndDate',
+ 'value' => \$today,
+ 'compare' => '<',
+ 'type' => 'DATETIME',
+ ),
+ ),
+ );
+ \$query = new WP_Query( \$args );
+ return (int) \$query->found_posts;
+ }
+
+ /**
+ * Get the total number of tickets sold across all the trainer's events.
+ *
+ * @return int
+ */
+ public function get_total_tickets_sold() : int {
+ \$total_tickets = 0;
+ \$args = array(
+ 'post_type' => Tribe__Events__Main::POSTTYPE,
+ 'author' => \$this->user_id, // Use author consistently
+ 'post_status' => array( 'publish', 'future', 'draft', 'pending', 'private' ),
+ 'posts_per_page' => -1,
+ 'fields' => 'ids',
+ );
+ \$event_ids = get_posts( \$args );
+
+ if ( ! empty( \$event_ids ) ) {
+ foreach ( \$event_ids as \$event_id ) {
+ \$sold = get_post_meta( \$event_id, '_tribe_tickets_sold', true );
+ if ( is_numeric( \$sold ) ) {
+ \$total_tickets += (int) \$sold;
+ }
+ }
+ }
+
+ return \$total_tickets;
+ }
+
+ /**
+ * Get the total revenue generated across all the trainer's events.
+ *
+ * @return float
+ */
+ public function get_total_revenue() : float {
+ \$total_revenue = 0.0;
+ \$args = array(
+ 'post_type' => Tribe__Events__Main::POSTTYPE,
+ 'author' => \$this->user_id, // Use author consistently
+ 'post_status' => array( 'publish', 'future', 'draft', 'pending', 'private' ),
+ 'posts_per_page' => -1,
+ 'fields' => 'ids',
+ );
+ \$event_ids = get_posts( \$args );
+
+ if ( ! empty( \$event_ids ) ) {
+ foreach ( \$event_ids as \$event_id ) {
+ \$revenue = get_post_meta( \$event_id, '_tribe_revenue_total', true );
+ if ( is_numeric( \$revenue ) ) {
+ \$total_revenue += (float) \$revenue;
+ }
+ }
+ }
+
+ return \$total_revenue;
+ }
+
+ /**
+ * Get the annual revenue target set by the trainer.
+ *
+ * @return float|null Returns the target as a float, or null if not set.
+ */
+ public function get_annual_revenue_target() : ?float {
+ \$target = get_user_meta( \$this->user_id, 'annual_revenue_target', true );
+ return ! empty( \$target ) && is_numeric( \$target ) ? (float) \$target : null;
+ }
+
+ /**
+ * Get the data needed for the events table on the dashboard.
+ *
+ * @param string \$filter_status The status to filter events by.
+ * @return array An array of event data arrays.
+ */
+ public function get_events_table_data( string \$filter_status = 'all' ) : array {
+ \$events_data = [];
+ \$valid_statuses = array( 'publish', 'future', 'draft', 'pending', 'private' );
+ \$post_status = ( 'all' === \$filter_status || ! in_array( \$filter_status, \$valid_statuses, true ) )
+ ? \$valid_statuses
+ : array( \$filter_status );
+
+ \$args = array(
+ 'post_type' => Tribe__Events__Main::POSTTYPE,
+ 'author' => \$this->user_id, // Use author consistently
+ 'post_status' => \$post_status,
+ 'posts_per_page' => -1,
+ 'orderby' => 'meta_value',
+ 'meta_key' => '_EventStartDate',
+ 'order' => 'DESC',
+ );
+
+ \$query = new WP_Query( \$args );
+
+ if ( \$query->have_posts() ) {
+ while ( \$query->have_posts() ) {
+ \$query->the_post();
+ \$event_id = get_the_ID();
+
+ // Get Capacity
+ \$total_capacity = 0;
+ if ( function_exists( 'tribe_get_tickets' ) ) {
+ \$tickets = tribe_get_tickets( \$event_id );
+ if ( \$tickets ) {
+ foreach ( \$tickets as \$ticket ) {
+ \$capacity = \$ticket->capacity();
+ if ( \$capacity === -1 ) {
+ \$total_capacity = -1;
+ break;
+ }
+ if ( is_numeric( \$capacity ) ) {
+ \$total_capacity += \$capacity;
+ }
+ }
+ }
+ }
+
+ \$sold = get_post_meta( \$event_id, '_tribe_tickets_sold', true );
+ \$revenue = get_post_meta( \$event_id, '_tribe_revenue_total', true );
+
+ \$events_data[] = array(
+ 'id' => \$event_id,
+ 'status' => get_post_status( \$event_id ),
+ 'name' => get_the_title(),
+ 'link' => get_permalink( \$event_id ),
+ 'start_date_ts' => strtotime( get_post_meta( \$event_id, '_EventStartDate', true ) ),
+ 'organizer_id' => (int) get_post_meta( \$event_id, '_EventOrganizerID', true ),
+ 'capacity' => ( \$total_capacity === -1 ) ? 'Unlimited' : (int) \$total_capacity,
+ 'sold' => is_numeric( \$sold ) ? (int) \$sold : 0,
+ 'revenue' => is_numeric( \$revenue ) ? (float) \$revenue : 0.0,
+ );
+ }
+ wp_reset_postdata();
+ }
+
+ return \$events_data;
+ }
+}
+EOF"
+
+# Backup original
+echo "Backing up original file..."
+sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && cp wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data.php wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data.php.bak"
+
+# Replace with fixed version
+echo "Replacing with fixed version..."
+sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && cp wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data-fixed.php wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data.php"
+
+# Clear cache
+echo "Clearing cache..."
+sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && wp cache flush"
+
+# Test the fix
+echo -e "\nTesting the fix..."
+sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && cat > test-dashboard-fix.php << 'EOF'
+ID;
+echo \"User ID: \$user_id\\n\";
+
+\$dashboard_data = new HVAC_Dashboard_Data(\$user_id);
+
+echo \"Total Events: \" . \$dashboard_data->get_total_events_count() . \"\\n\";
+echo \"Upcoming Events: \" . \$dashboard_data->get_upcoming_events_count() . \"\\n\";
+echo \"Past Events: \" . \$dashboard_data->get_past_events_count() . \"\\n\";
+echo \"Total Tickets: \" . \$dashboard_data->get_total_tickets_sold() . \"\\n\";
+echo \"Total Revenue: \" . \$dashboard_data->get_total_revenue() . \"\\n\";
+
+// Check event table data
+\$events = \$dashboard_data->get_events_table_data();
+echo \"\\nEvents in table: \" . count(\$events) . \"\\n\";
+foreach (\$events as \$event) {
+ echo \" - \" . \$event['name'] . \" (\" . \$event['status'] . \")\\n\";
+}
+EOF"
+
+sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && php test-dashboard-fix.php"
+
+# Clean up test file
+sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && rm test-dashboard-fix.php"
+
+echo -e "\nDashboard fix deployed. You should now see the correct stats at: https://wordpress-974670-5399585.cloudwaysapps.com/hvac-dashboard/"
\ No newline at end of file
diff --git a/wordpress-dev/bin/deploy-dashboard-fix-v3.sh b/wordpress-dev/bin/deploy-dashboard-fix-v3.sh
new file mode 100755
index 00000000..f9cef287
--- /dev/null
+++ b/wordpress-dev/bin/deploy-dashboard-fix-v3.sh
@@ -0,0 +1,258 @@
+#!/bin/bash
+
+# Load environment variables
+source .env
+
+# SSH credentials for Cloudways
+SSH_HOST="${UPSKILL_STAGING_IP}"
+SSH_USER="${UPSKILL_STAGING_SSH_USER}"
+SSH_PASS="${UPSKILL_STAGING_PASS}"
+SSH_PORT="22"
+REMOTE_PATH="${UPSKILL_STAGING_PATH}"
+
+echo "Deploying dashboard fix to staging..."
+echo "Using SSH: ${SSH_USER}@${SSH_HOST}:${SSH_PORT}"
+
+# Create the fixed dashboard data class content
+FIXED_CONTENT='user_id = $user_id ?: get_current_user_id();
+ }
+
+ /**
+ * Get total events count
+ *
+ * @return int
+ */
+ public function get_total_events_count() : int {
+ $args = array(
+ "post_type" => Tribe__Events__Main::POSTTYPE,
+ "author" => $this->user_id,
+ "post_status" => array( "publish", "future" ),
+ "posts_per_page" => -1,
+ "fields" => "ids",
+ );
+
+ $query = new WP_Query( $args );
+
+ return (int) $query->found_posts;
+ }
+
+ /**
+ * Get upcoming events count
+ *
+ * @return int
+ */
+ public function get_upcoming_events_count() : int {
+ $today = current_time( "mysql" );
+ $args = array(
+ "post_type" => Tribe__Events__Main::POSTTYPE,
+ "author" => $this->user_id,
+ "post_status" => array( "publish", "future" ),
+ "posts_per_page" => -1,
+ "fields" => "ids",
+ "meta_query" => array(
+ array(
+ "key" => "_EventStartDate",
+ "value" => $today,
+ "compare" => ">=",
+ "type" => "DATETIME",
+ ),
+ ),
+ );
+
+ $query = new WP_Query( $args );
+
+ return (int) $query->found_posts;
+ }
+
+ /**
+ * Get past events count
+ *
+ * @return int
+ */
+ public function get_past_events_count() : int {
+ $today = current_time( "mysql" );
+ $args = array(
+ "post_type" => Tribe__Events__Main::POSTTYPE,
+ "author" => $this->user_id,
+ "post_status" => array( "publish", "future" ),
+ "posts_per_page" => -1,
+ "fields" => "ids",
+ "meta_query" => array(
+ array(
+ "key" => "_EventEndDate",
+ "value" => $today,
+ "compare" => "<",
+ "type" => "DATETIME",
+ ),
+ ),
+ );
+
+ $query = new WP_Query( $args );
+
+ return (int) $query->found_posts;
+ }
+
+ /**
+ * Get total tickets sold
+ *
+ * @return int
+ */
+ public function get_total_tickets_sold() : int {
+ $events = $this->get_user_events();
+ $total = 0;
+
+ foreach ( $events as $event_id ) {
+ $tickets = Tribe__Tickets__Tickets::get_event_tickets( $event_id );
+
+ foreach ( $tickets as $ticket ) {
+ $total += absint( $ticket->qty_sold() );
+ }
+ }
+
+ return $total;
+ }
+
+ /**
+ * Get total revenue
+ *
+ * @return float
+ */
+ public function get_total_revenue() : float {
+ $events = $this->get_user_events();
+ $total = 0.0;
+
+ foreach ( $events as $event_id ) {
+ $tickets = Tribe__Tickets__Tickets::get_event_tickets( $event_id );
+
+ foreach ( $tickets as $ticket ) {
+ $total += floatval( $ticket->price ) * absint( $ticket->qty_sold() );
+ }
+ }
+
+ return $total;
+ }
+
+ /**
+ * Get all event IDs for a user
+ *
+ * @return array
+ */
+ private function get_user_events() : array {
+ $args = array(
+ "post_type" => Tribe__Events__Main::POSTTYPE,
+ "author" => $this->user_id,
+ "post_status" => array( "publish", "future" ),
+ "posts_per_page" => -1,
+ "fields" => "ids",
+ );
+
+ $query = new WP_Query( $args );
+
+ return $query->posts;
+ }
+
+ /**
+ * Get upcoming events
+ *
+ * @param int $limit Number of events to return
+ * @return array
+ */
+ public function get_upcoming_events( $limit = 5 ) : array {
+ $today = current_time( "mysql" );
+ $args = array(
+ "post_type" => Tribe__Events__Main::POSTTYPE,
+ "author" => $this->user_id,
+ "post_status" => array( "publish", "future" ),
+ "posts_per_page" => $limit,
+ "meta_key" => "_EventStartDate",
+ "orderby" => "meta_value",
+ "order" => "ASC",
+ "meta_query" => array(
+ array(
+ "key" => "_EventStartDate",
+ "value" => $today,
+ "compare" => ">=",
+ "type" => "DATETIME",
+ ),
+ ),
+ );
+
+ $query = new WP_Query( $args );
+
+ return $query->posts;
+ }
+}
+?>'
+
+echo "Creating fixed file on staging server..."
+
+# Use sshpass to connect and deploy
+sshpass -p "${SSH_PASS}" ssh -o StrictHostKeyChecking=no "${SSH_USER}@${SSH_HOST}" -p ${SSH_PORT} << EOF
+cd ${REMOTE_PATH}
+
+# Create the fixed file
+echo '${FIXED_CONTENT}' > wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data-fixed.php
+
+# Backup the original
+cp wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data.php \
+ wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data.backup.php
+
+# Replace with fixed version
+cp wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data-fixed.php \
+ wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data.php
+
+# Clear WordPress cache
+wp cache flush --allow-root
+
+echo "Dashboard fix deployed successfully"
+EOF
+
+echo "Testing the fix..."
+sshpass -p "${SSH_PASS}" ssh -o StrictHostKeyChecking=no "${SSH_USER}@${SSH_HOST}" -p ${SSH_PORT} << 'EOF'
+cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html
+
+wp eval '
+$user_id = 17;
+$dashboard_data = new HVAC_Dashboard_Data($user_id);
+echo "User ID: " . $user_id . "\n";
+echo "Total Events: " . $dashboard_data->get_total_events_count() . "\n";
+echo "Upcoming Events: " . $dashboard_data->get_upcoming_events_count() . "\n";
+echo "Past Events: " . $dashboard_data->get_past_events_count() . "\n";
+echo "Total Tickets: " . $dashboard_data->get_total_tickets_sold() . "\n";
+echo "Total Revenue: " . $dashboard_data->get_total_revenue() . "\n";
+
+// Check the database directly
+global $wpdb;
+$events = $wpdb->get_results($wpdb->prepare(
+ "SELECT ID, post_title, post_status FROM $wpdb->posts
+ WHERE post_type = %s AND post_author = %d",
+ "tribe_events", $user_id
+));
+
+echo "\nEvents in table: " . count($events) . "\n";
+foreach ($events as $event) {
+ echo " - " . $event->post_title . " (" . $event->post_status . ")\n";
+}
+' --allow-root
+EOF
+
+echo "Dashboard fix deployed. You should now see the correct stats at: ${UPSKILL_STAGING_URL}hvac-dashboard/"
\ No newline at end of file
diff --git a/wordpress-dev/bin/deploy-dashboard-fix.sh b/wordpress-dev/bin/deploy-dashboard-fix.sh
new file mode 100755
index 00000000..1b380a63
--- /dev/null
+++ b/wordpress-dev/bin/deploy-dashboard-fix.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+# Exit on error
+set -e
+
+# Source environment variables
+source .env
+
+echo "Deploying dashboard fix to staging..."
+
+# Backup original dashboard data class
+echo "Backing up original file..."
+sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && cp wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data.php wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data.php.bak"
+
+# Upload the fixed version
+echo "Uploading fixed dashboard data class..."
+sshpass -p "$UPSKILL_STAGING_PASS" scp -o StrictHostKeyChecking=no wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data-fixed.php "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP:$UPSKILL_STAGING_PATH/wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data-fixed.php"
+
+# Overwrite the original with the fixed version
+echo "Replacing original dashboard data class..."
+sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && cp wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data-fixed.php wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data.php"
+
+# Clear cache
+echo "Clearing cache..."
+sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && wp cache flush"
+
+# Test the fix
+echo -e "\nTesting the fix..."
+sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && cat > test-dashboard-fix.php << 'EOF'
+ID;
+echo \"User ID: \$user_id\\n\";
+
+\$dashboard_data = new HVAC_Dashboard_Data(\$user_id);
+
+echo \"Total Events: \" . \$dashboard_data->get_total_events_count() . \"\\n\";
+echo \"Upcoming Events: \" . \$dashboard_data->get_upcoming_events_count() . \"\\n\";
+echo \"Past Events: \" . \$dashboard_data->get_past_events_count() . \"\\n\";
+echo \"Total Tickets: \" . \$dashboard_data->get_total_tickets_sold() . \"\\n\";
+echo \"Total Revenue: \" . \$dashboard_data->get_total_revenue() . \"\\n\";
+EOF"
+
+sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && php test-dashboard-fix.php"
+
+# Clean up test file
+sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && rm test-dashboard-fix.php"
+
+echo -e "\nDashboard fix deployed. You should now see the correct stats at: https://wordpress-974670-5399585.cloudwaysapps.com/hvac-dashboard/"
\ No newline at end of file
diff --git a/wordpress-dev/bin/fix-event-dates-mixed.sh b/wordpress-dev/bin/fix-event-dates-mixed.sh
new file mode 100755
index 00000000..c78f66e6
--- /dev/null
+++ b/wordpress-dev/bin/fix-event-dates-mixed.sh
@@ -0,0 +1,88 @@
+#!/bin/bash
+
+# Fix event dates with a mix of past and future dates
+
+# Get absolute path to this script's directory
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+# Navigate to wordpress-dev directory
+cd "$(dirname "$SCRIPT_DIR")" || exit 1
+
+# Load environment variables
+ENV_FILE=".env"
+if [ ! -f "$ENV_FILE" ]; then
+ echo "Error: .env file not found at: $ENV_FILE"
+ exit 1
+fi
+
+source "$ENV_FILE"
+
+echo "=== Fixing Event Dates (Mixed Past/Future) ==="
+echo "Remote host: $UPSKILL_STAGING_IP"
+echo "==============================="
+
+# Fix event dates
+sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" <<'EOF'
+cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html
+
+echo "Updating event dates with mix of past and future..."
+
+# Event 5482: Past event (2 months ago)
+wp post meta update 5482 _EventStartDate "2025-03-15 09:00:00" --allow-root
+wp post meta update 5482 _EventEndDate "2025-03-15 17:00:00" --allow-root
+echo "Event 5482: Set to past (March 2025)"
+
+# Event 5483: Past event (1 month ago)
+wp post meta update 5483 _EventStartDate "2025-04-15 10:00:00" --allow-root
+wp post meta update 5483 _EventEndDate "2025-04-15 18:00:00" --allow-root
+echo "Event 5483: Set to past (April 2025)"
+
+# Event 5484: Future event (1 month from now)
+wp post meta update 5484 _EventStartDate "2025-06-15 09:00:00" --allow-root
+wp post meta update 5484 _EventEndDate "2025-06-15 16:00:00" --allow-root
+echo "Event 5484: Set to future (June 2025)"
+
+# Event 5485: Future event (2 months from now)
+wp post meta update 5485 _EventStartDate "2025-07-20 13:00:00" --allow-root
+wp post meta update 5485 _EventEndDate "2025-07-20 17:00:00" --allow-root
+echo "Event 5485: Set to future (July 2025)"
+
+# Event 5486: Future event (3 months from now)
+wp post meta update 5486 _EventStartDate "2025-08-25 08:00:00" --allow-root
+wp post meta update 5486 _EventEndDate "2025-08-25 17:00:00" --allow-root
+echo "Event 5486: Set to future (August 2025)"
+
+echo -e "\nEvent dates updated!"
+
+# Verify the updates
+echo -e "\nVerifying updated dates:"
+for EVENT_ID in 5482 5483 5484 5485 5486; do
+ TITLE=$(wp post get $EVENT_ID --field=post_title --allow-root)
+ START_DATE=$(wp post meta get $EVENT_ID _EventStartDate --allow-root)
+ echo "Event $EVENT_ID ($TITLE): $START_DATE"
+done
+
+# Test query for all events
+echo -e "\nAll events by test_trainer:"
+wp post list --post_type=tribe_events --author=17 --post_status=any --fields=ID,post_title --allow-root
+
+# Test past events query
+echo -e "\nPast events (should be 2):"
+wp db query "SELECT COUNT(*) as count FROM wp_posts p
+ JOIN wp_postmeta m ON p.ID = m.post_id
+ WHERE p.post_type='tribe_events'
+ AND p.post_author=17
+ AND m.meta_key='_EventEndDate'
+ AND m.meta_value < NOW()" --allow-root
+
+# Test future events query
+echo -e "\nFuture events (should be 3):"
+wp db query "SELECT COUNT(*) as count FROM wp_posts p
+ JOIN wp_postmeta m ON p.ID = m.post_id
+ WHERE p.post_type='tribe_events'
+ AND p.post_author=17
+ AND m.meta_key='_EventStartDate'
+ AND m.meta_value > NOW()" --allow-root
+EOF
+
+echo "Fix completed!"
\ No newline at end of file
diff --git a/wordpress-dev/bin/fix-event-dates.sh b/wordpress-dev/bin/fix-event-dates.sh
new file mode 100755
index 00000000..adae6725
--- /dev/null
+++ b/wordpress-dev/bin/fix-event-dates.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+# Fix event dates to be in the future
+
+# Get absolute path to this script's directory
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+# Navigate to wordpress-dev directory
+cd "$(dirname "$SCRIPT_DIR")" || exit 1
+
+# Load environment variables
+ENV_FILE=".env"
+if [ ! -f "$ENV_FILE" ]; then
+ echo "Error: .env file not found at: $ENV_FILE"
+ exit 1
+fi
+
+source "$ENV_FILE"
+
+echo "=== Fixing Event Dates ==="
+echo "Remote host: $UPSKILL_STAGING_IP"
+echo "==============================="
+
+# Fix event dates
+sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" <<'EOF'
+cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html
+
+# Update event dates to be in the future
+echo "Updating event dates to future dates..."
+
+# Event 5482: 1 month from now
+wp post meta update 5482 _EventStartDate "2025-06-20 09:00:00" --allow-root
+wp post meta update 5482 _EventEndDate "2025-06-20 17:00:00" --allow-root
+
+# Event 5483: 2 months from now
+wp post meta update 5483 _EventStartDate "2025-07-15 10:00:00" --allow-root
+wp post meta update 5483 _EventEndDate "2025-07-15 18:00:00" --allow-root
+
+# Event 5484: 3 months from now
+wp post meta update 5484 _EventStartDate "2025-08-10 09:00:00" --allow-root
+wp post meta update 5484 _EventEndDate "2025-08-10 16:00:00" --allow-root
+
+# Event 5485: 4 months from now
+wp post meta update 5485 _EventStartDate "2025-09-05 13:00:00" --allow-root
+wp post meta update 5485 _EventEndDate "2025-09-05 17:00:00" --allow-root
+
+# Event 5486: 5 months from now
+wp post meta update 5486 _EventStartDate "2025-10-20 08:00:00" --allow-root
+wp post meta update 5486 _EventEndDate "2025-10-20 17:00:00" --allow-root
+
+echo "Event dates updated!"
+
+# Verify the updates
+echo -e "\nVerifying updated dates:"
+for EVENT_ID in 5482 5483 5484 5485 5486; do
+ echo -n "Event $EVENT_ID: "
+ wp post meta get $EVENT_ID _EventStartDate --allow-root
+done
+
+# Test query again
+echo -e "\nTesting query with future dates:"
+wp post list --post_type=tribe_events --author=17 --fields=ID,post_title,post_status --allow-root
+EOF
+
+echo "Fix completed!"
\ No newline at end of file
diff --git a/wordpress-dev/bin/fix-event-organizer.sh b/wordpress-dev/bin/fix-event-organizer.sh
new file mode 100755
index 00000000..aa70095a
--- /dev/null
+++ b/wordpress-dev/bin/fix-event-organizer.sh
@@ -0,0 +1,144 @@
+#!/bin/bash
+
+# Get absolute path to this script's directory
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+# Navigate to wordpress-dev directory
+cd "$(dirname "$SCRIPT_DIR")" || exit 1
+
+# Load environment variables
+ENV_FILE=".env"
+if [ ! -f "$ENV_FILE" ]; then
+ echo "Error: .env file not found at: $ENV_FILE"
+ exit 1
+fi
+
+source "$ENV_FILE"
+
+# Colors for output
+GREEN='\033[0;32m'
+RED='\033[0;31m'
+YELLOW='\033[1;33m'
+NC='\033[0m'
+
+echo "=== Fixing Event Organizer IDs on Staging Server ==="
+echo "Remote host: $UPSKILL_STAGING_IP"
+echo "Remote user: $UPSKILL_STAGING_SSH_USER"
+echo "==============================="
+
+# Create PHP script to fix the organizer IDs
+cat << 'EOF' > fix-organizers.php
+ID;
+echo "test_trainer user ID: $trainer_id\n\n";
+
+// Get all events authored by test_trainer
+$args = array(
+ 'post_type' => 'tribe_events',
+ 'author' => $trainer_id,
+ 'post_status' => 'any',
+ 'posts_per_page' => -1,
+ 'fields' => 'ids'
+);
+
+$event_ids = get_posts($args);
+
+if (empty($event_ids)) {
+ // Try to find events by ID range
+ echo "No events found by author. Checking recent events...\n";
+ $args['author'] = 0;
+ $args['meta_query'] = array(
+ array(
+ 'key' => 'post_ID',
+ 'value' => array(5482, 5486),
+ 'compare' => 'BETWEEN',
+ 'type' => 'NUMERIC'
+ )
+ );
+
+ // Actually, let's just get events in the ID range we created
+ $event_ids = array(5482, 5483, 5484, 5485, 5486);
+
+ foreach ($event_ids as $event_id) {
+ if (get_post($event_id)) {
+ echo "Processing event ID: $event_id\n";
+
+ // Set the organizer ID to the trainer's user ID
+ update_post_meta($event_id, '_EventOrganizerID', $trainer_id);
+
+ // Also create an organizer post if it doesn't exist
+ $organizer_exists = get_posts(array(
+ 'post_type' => 'tribe_organizer',
+ 'posts_per_page' => 1,
+ 'meta_key' => '_OrganizerUserID',
+ 'meta_value' => $trainer_id
+ ));
+
+ if (empty($organizer_exists)) {
+ // Create organizer post
+ $user_info = get_userdata($trainer_id);
+ $organizer_id = wp_insert_post(array(
+ 'post_type' => 'tribe_organizer',
+ 'post_status' => 'publish',
+ 'post_title' => $user_info->display_name . ' (Trainer)',
+ 'meta_input' => array(
+ '_OrganizerPhone' => '',
+ '_OrganizerWebsite' => '',
+ '_OrganizerEmail' => $user_info->user_email,
+ '_OrganizerUserID' => $trainer_id
+ )
+ ));
+
+ if (!is_wp_error($organizer_id)) {
+ echo "Created organizer ID: $organizer_id\n";
+ // Update the event with the organizer ID
+ update_post_meta($event_id, '_EventOrganizerID', $organizer_id);
+ }
+ } else {
+ // Use existing organizer
+ $existing_organizer = $organizer_exists[0];
+ update_post_meta($event_id, '_EventOrganizerID', $existing_organizer->ID);
+ echo "Using existing organizer ID: {$existing_organizer->ID}\n";
+ }
+
+ echo "Updated event $event_id with organizer\n";
+ }
+ }
+} else {
+ echo "Found " . count($event_ids) . " events by test_trainer\n";
+
+ foreach ($event_ids as $event_id) {
+ echo "Processing event ID: $event_id\n";
+ update_post_meta($event_id, '_EventOrganizerID', $trainer_id);
+ echo "Updated event $event_id with organizer ID: $trainer_id\n";
+ }
+}
+
+echo "\nOrganizer fixing completed!\n";
+EOF
+
+# Copy script to server
+echo -e "\n${YELLOW}Copying script to server...${NC}"
+sshpass -p "${UPSKILL_STAGING_PASS}" scp fix-organizers.php "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}:${UPSKILL_STAGING_PATH}/"
+
+# Execute the script
+echo -e "\n${YELLOW}Running organizer fix script...${NC}"
+sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" \
+"cd ${UPSKILL_STAGING_PATH} && /usr/bin/php fix-organizers.php"
+
+# Clean up
+echo -e "\n${YELLOW}Cleaning up...${NC}"
+rm fix-organizers.php
+sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" \
+"rm ${UPSKILL_STAGING_PATH}/fix-organizers.php"
+
+echo -e "\n${GREEN}Organizer fix completed!${NC}"
\ No newline at end of file
diff --git a/wordpress-dev/bin/fix-occurrences.sh b/wordpress-dev/bin/fix-occurrences.sh
new file mode 100755
index 00000000..a49576c5
--- /dev/null
+++ b/wordpress-dev/bin/fix-occurrences.sh
@@ -0,0 +1,99 @@
+#!/bin/bash
+
+# Fix event occurrences
+
+# Get absolute path to this script's directory
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+# Navigate to wordpress-dev directory
+cd "$(dirname "$SCRIPT_DIR")" || exit 1
+
+# Load environment variables
+ENV_FILE=".env"
+if [ ! -f "$ENV_FILE" ]; then
+ echo "Error: .env file not found at: $ENV_FILE"
+ exit 1
+fi
+
+source "$ENV_FILE"
+
+echo "=== Fixing Event Occurrences ==="
+echo "Remote host: $UPSKILL_STAGING_IP"
+echo "==============================="
+
+# Fix occurrences
+sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" <<'EOF'
+cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html
+
+# Create PHP script to fix occurrences
+cat > fix-occurrences.php << 'PHP'
+get_var($wpdb->prepare(
+ "SELECT occurrence_id FROM {$wpdb->prefix}tec_occurrences WHERE post_id = %d",
+ $event_id
+ ));
+
+ if (!$existing) {
+ // Create occurrence
+ $wpdb->insert(
+ $wpdb->prefix . 'tec_occurrences',
+ array(
+ 'post_id' => $event_id,
+ 'start_date' => $start,
+ 'start_date_utc' => $start,
+ 'end_date' => $end,
+ 'end_date_utc' => $end,
+ 'duration' => strtotime($end) - strtotime($start),
+ 'hash' => md5($event_id . $start . $end)
+ ),
+ array('%d', '%s', '%s', '%s', '%s', '%d', '%s')
+ );
+ echo "Created occurrence for event $event_id\n";
+ } else {
+ echo "Occurrence already exists for event $event_id\n";
+ }
+ }
+}
+
+echo "\nTesting query again...\n";
+$args = array(
+ 'post_type' => 'tribe_events',
+ 'author' => 17,
+ 'posts_per_page' => -1,
+ 'post_status' => 'any'
+);
+$query = new WP_Query($args);
+echo "Found events: " . $query->found_posts . "\n";
+
+// Test dashboard data
+echo "\nTesting dashboard data...\n";
+require_once '/home/974670.cloudwaysapps.com/uberrxmprk/public_html/wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data.php';
+$dashboard = new HVAC_Dashboard_Data(17);
+echo "Total events: " . $dashboard->get_total_events_count() . "\n";
+echo "Upcoming events: " . $dashboard->get_upcoming_events_count() . "\n";
+echo "Past events: " . $dashboard->get_past_events_count() . "\n";
+
+PHP
+
+php fix-occurrences.php
+rm fix-occurrences.php
+EOF
+
+echo "Fix completed!"
\ No newline at end of file
diff --git a/wordpress-dev/bin/fix-test-events.sh b/wordpress-dev/bin/fix-test-events.sh
new file mode 100755
index 00000000..7f2036b3
--- /dev/null
+++ b/wordpress-dev/bin/fix-test-events.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+# Get absolute path to this script's directory
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+# Navigate to wordpress-dev directory
+cd "$(dirname "$SCRIPT_DIR")" || exit 1
+
+# Load environment variables
+ENV_FILE=".env"
+if [ ! -f "$ENV_FILE" ]; then
+ echo "Error: .env file not found at: $ENV_FILE"
+ exit 1
+fi
+
+source "$ENV_FILE"
+
+# Colors for output
+GREEN='\033[0;32m'
+RED='\033[0;31m'
+YELLOW='\033[1;33m'
+NC='\033[0m'
+
+echo "=== Fixing Test Events on Staging Server ==="
+echo "Remote host: $UPSKILL_STAGING_IP"
+echo "Remote user: $UPSKILL_STAGING_SSH_USER"
+echo "==============================="
+
+# Check the recently created events
+echo -e "\n${YELLOW}Finding recently created events...${NC}"
+sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" \
+"cd ${UPSKILL_STAGING_PATH} && wp post list --post_type=tribe_events --orderby=ID --order=DESC --fields=ID,post_title,post_author --number=10 --format=table --allow-root"
+
+# Update the events to be owned by test_trainer
+echo -e "\n${YELLOW}Updating events to be owned by test_trainer...${NC}"
+sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" << 'EOF'
+cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html
+
+# Get trainer user ID
+TRAINER_ID=$(wp user get test_trainer --field=ID --allow-root)
+echo "Trainer ID: $TRAINER_ID"
+
+# Find our test events by title and update their author
+EVENT_TITLES=(
+ "HVAC System Maintenance Workshop"
+ "Advanced HVAC Diagnostics Training"
+ "HVAC Installation Best Practices"
+ "Commercial HVAC Systems Overview"
+ "HVAC Energy Efficiency Certification"
+)
+
+for TITLE in "${EVENT_TITLES[@]}"; do
+ echo "Updating event: $TITLE"
+ EVENT_ID=$(wp post list --post_type=tribe_events --title="$TITLE" --field=ID --allow-root)
+ if [ -n "$EVENT_ID" ]; then
+ wp post update $EVENT_ID --post_author=$TRAINER_ID --allow-root
+ echo "Updated event ID $EVENT_ID"
+ else
+ echo "Event not found: $TITLE"
+ fi
+done
+
+# Verify the updates
+echo -e "\nVerifying updates..."
+wp post list --post_type=tribe_events --author=$TRAINER_ID --fields=ID,post_title,post_author --format=table --allow-root
+EOF
+
+echo -e "\n${GREEN}Test events fixed!${NC}"
\ No newline at end of file
diff --git a/wordpress-dev/bin/test-query.sh b/wordpress-dev/bin/test-query.sh
new file mode 100755
index 00000000..243d4031
--- /dev/null
+++ b/wordpress-dev/bin/test-query.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+# Test event queries on staging
+
+# Get absolute path to this script's directory
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+
+# Navigate to wordpress-dev directory
+cd "$(dirname "$SCRIPT_DIR")" || exit 1
+
+# Load environment variables
+ENV_FILE=".env"
+if [ ! -f "$ENV_FILE" ]; then
+ echo "Error: .env file not found at: $ENV_FILE"
+ exit 1
+fi
+
+source "$ENV_FILE"
+
+echo "=== Testing Event Queries ==="
+echo "Remote host: $UPSKILL_STAGING_IP"
+echo "==============================="
+
+# Test query
+sshpass -p "${UPSKILL_STAGING_PASS}" ssh -o StrictHostKeyChecking=no "${UPSKILL_STAGING_SSH_USER}@${UPSKILL_STAGING_IP}" <<'EOF'
+cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html
+
+# Create PHP test script
+cat > test-query.php << 'PHP'
+ Tribe__Events__Main::POSTTYPE,
+ 'author' => 17,
+ 'post_status' => 'any',
+ 'posts_per_page' => -1,
+ 'fields' => 'ids'
+);
+$query = new WP_Query($args);
+echo "Found posts: " . $query->found_posts . "\n";
+var_dump($query->posts);
+
+// Test 2: get_posts
+echo "\nTest 2: get_posts with author=17\n";
+$events = get_posts($args);
+echo "Found events: " . count($events) . "\n";
+
+// Test 3: Direct DB query
+echo "\nTest 3: Direct DB query\n";
+global $wpdb;
+$results = $wpdb->get_results("SELECT ID, post_title, post_author FROM {$wpdb->posts} WHERE post_type='tribe_events' AND post_author=17");
+echo "Found in DB: " . count($results) . "\n";
+foreach ($results as $r) {
+ echo "ID: {$r->ID}, Title: {$r->post_title}\n";
+}
+
+// Test 4: Check plugin active
+echo "\nTest 4: Plugin status\n";
+echo "TEC Active: " . (class_exists('Tribe__Events__Main') ? 'Yes' : 'No') . "\n";
+echo "Post type registered: " . (post_type_exists('tribe_events') ? 'Yes' : 'No') . "\n";
+
+// Test 5: Clear cache and try again
+echo "\nTest 5: Clearing cache\n";
+wp_cache_flush();
+$query2 = new WP_Query($args);
+echo "After cache clear - Found posts: " . $query2->found_posts . "\n";
+PHP
+
+php test-query.php
+rm test-query.php
+EOF
+
+echo "Test completed!"
\ No newline at end of file
diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/hvac-community-events.php b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/hvac-community-events.php
index d5bc7550..bc2afc64 100644
--- a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/hvac-community-events.php
+++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/hvac-community-events.php
@@ -15,13 +15,15 @@
if (!defined('ABSPATH')) {
exit;
}
-// error_log('[HVAC DEBUG] Main plugin file hvac-community-events.php loaded.'); // REMOVED DEBUG LOG
// Define plugin constants
define('HVAC_CE_VERSION', '1.0.0');
define('HVAC_CE_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('HVAC_CE_PLUGIN_URL', plugin_dir_url(__FILE__));
+// Include the logger class early
+require_once HVAC_CE_PLUGIN_DIR . 'includes/class-hvac-logger.php';
+
/**
* Create required pages and roles upon plugin activation.
@@ -30,7 +32,7 @@ function hvac_ce_create_required_pages() {
// Ensure the roles class is available
require_once HVAC_CE_PLUGIN_DIR . 'includes/class-hvac-roles.php';
- error_log('[HVAC DEBUG] hvac_ce_create_required_pages: Starting page creation process.');
+ HVAC_Logger::info('Starting page creation process', 'Activation');
$required_pages = [
'community-login' => [
'title' => 'Community Login',
@@ -68,7 +70,7 @@ function hvac_ce_create_required_pages() {
$existing_page = get_page_by_path($slug, OBJECT, 'page');
if (!$existing_page) {
- error_log("HVAC CE: Page with slug '{$slug}' not found. Attempting to create."); // Add logging: page missing
+ HVAC_Logger::info("Page with slug '{$slug}' not found. Attempting to create.", 'Activation');
// Page does not exist, create it
$post_data = [
'post_title' => $page_data['title'],
@@ -84,9 +86,9 @@ function hvac_ce_create_required_pages() {
// Log the result of wp_insert_post
if (is_wp_error($page_id)) {
- error_log("[HVAC DEBUG] hvac_ce_create_required_pages: Error creating page '{$slug}': " . $page_id->get_error_message());
+ HVAC_Logger::error("Error creating page '{$slug}': " . $page_id->get_error_message(), 'Activation');
} else {
- error_log("[HVAC DEBUG] hvac_ce_create_required_pages: Successfully created page '{$slug}' with ID: {$page_id}.");
+ HVAC_Logger::info("Successfully created page '{$slug}' with ID: {$page_id}.", 'Activation');
}
// Store the created page ID - Rewritten to avoid tool issue with &&
@@ -113,11 +115,11 @@ function hvac_ce_create_required_pages() {
$roles_manager = new HVAC_Roles();
$result = $roles_manager->create_trainer_role();
if ($result) {
- error_log('[HVAC DEBUG] hvac_ce_create_required_pages: Successfully created hvac_trainer role.');
+ HVAC_Logger::info('Successfully created hvac_trainer role.', 'Activation');
} else {
- error_log('[HVAC DEBUG] hvac_ce_create_required_pages: Failed to create hvac_trainer role.');
+ HVAC_Logger::error('Failed to create hvac_trainer role.', 'Activation');
}
- error_log('[HVAC DEBUG] hvac_ce_create_required_pages: Completed page creation and role setup process.');
+ HVAC_Logger::info('Completed page creation and role setup process', 'Activation');
} // <<-- Brace moved here
register_activation_hook(__FILE__, 'hvac_ce_create_required_pages');
@@ -130,7 +132,7 @@ function hvac_ce_remove_roles() {
require_once HVAC_CE_PLUGIN_DIR . 'includes/class-hvac-roles.php';
$roles_manager = new HVAC_Roles();
$roles_manager->remove_trainer_role();
- error_log('HVAC CE: Deactivation hook fired, attempted to remove hvac_trainer role.');
+ HVAC_Logger::info('Deactivation hook fired, attempted to remove hvac_trainer role.', 'Deactivation');
}
register_deactivation_hook(__FILE__, 'hvac_ce_remove_roles');
@@ -177,10 +179,9 @@ require_once HVAC_CE_PLUGIN_DIR . 'includes/class-hvac-community-events.php';
// Initialize the plugin
function hvac_community_events_init() {
- // error_log('[HVAC DEBUG] hvac_community_events_init function called (plugins_loaded hook).'); // REMOVED DEBUG LOG
+ HVAC_Logger::info('Initializing HVAC Community Events plugin', 'Core');
return HVAC_Community_Events::instance();
}
-// error_log('[HVAC DEBUG] About to add plugins_loaded action hook.'); // REMOVED DEBUG LOG
add_action('plugins_loaded', 'hvac_community_events_init');
diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-community-events.php b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-community-events.php
index 3819841d..42a48755 100644
--- a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-community-events.php
+++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-community-events.php
@@ -27,13 +27,13 @@ class HVAC_Community_Events {
* Constructor
*/
public function __construct() {
- error_log('[HVAC DEBUG] HVAC_Community_Events: Constructor started.');
+ HVAC_Logger::info('HVAC_Community_Events constructor started', 'Core');
$this->define_constants();
- error_log('[HVAC DEBUG] HVAC_Community_Events: define_constants completed.');
+ HVAC_Logger::info('Constants defined', 'Core');
$this->includes();
- error_log('[HVAC DEBUG] HVAC_Community_Events: includes completed.');
+ HVAC_Logger::info('Includes completed', 'Core');
$this->init_hooks();
- error_log('[HVAC DEBUG] HVAC_Community_Events: init_hooks completed.');
+ HVAC_Logger::info('Hooks initialized', 'Core');
}
/**
@@ -47,7 +47,7 @@ class HVAC_Community_Events {
* Include required files
*/
private function includes() {
- error_log('[HVAC DEBUG] HVAC_Community_Events: includes method started.');
+ HVAC_Logger::info('Loading required files', 'Core');
$files_to_include = [
'class-hvac-roles.php',
'class-hvac-registration.php',
@@ -60,12 +60,12 @@ class HVAC_Community_Events {
$path = HVAC_CE_PLUGIN_DIR . 'includes/' . $file;
if (file_exists($path)) {
require_once $path;
- error_log("[HVAC DEBUG] HVAC_Community_Events: Included file {$file}.");
+ HVAC_Logger::info("Included file: {$file}", 'Core');
} else {
- error_log("[HVAC DEBUG] HVAC_Community_Events: Failed to include file {$file}. File not found.");
+ HVAC_Logger::error("Failed to include file: {$file} - File not found", 'Core');
}
}
- error_log('[HVAC DEBUG] HVAC_Community_Events: includes method completed.');
+ HVAC_Logger::info('All required files loaded', 'Core');
}
/**
@@ -109,13 +109,13 @@ class HVAC_Community_Events {
* Initialize plugin actions attached to 'init' hook
*/
public function init() {
- error_log('[HVAC DEBUG] HVAC_Community_Events: init method started.');
+ HVAC_Logger::info('Init method started', 'Core');
// Initialize handlers
new \HVAC_Community_Events\Community\Login_Handler();
- error_log('[HVAC DEBUG] HVAC_Community_Events: Initialized Login_Handler.');
+ HVAC_Logger::info('Login_Handler initialized', 'Core');
new HVAC_Registration();
- error_log('[HVAC DEBUG] HVAC_Community_Events: Initialized HVAC_Registration.');
- error_log('[HVAC DEBUG] HVAC_Community_Events: init method completed.');
+ HVAC_Logger::info('HVAC_Registration initialized', 'Core');
+ HVAC_Logger::info('Init method completed', 'Core');
// Prevent trainers from accessing wp-admin
add_action('admin_init', array($this, 'redirect_trainers_from_admin'));
diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data.php b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data.php
index 2ef2efb8..b9635499 100644
--- a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data.php
+++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-dashboard-data.php
@@ -46,15 +46,10 @@ class HVAC_Dashboard_Data {
public function get_total_events_count() : int {
$args = array(
'post_type' => Tribe__Events__Main::POSTTYPE,
- // 'author' => $this->user_id, // Query by organizer instead
+ 'author' => $this->user_id, // Query by post author, not organizer
'post_status' => array( 'publish', 'future', 'draft', 'pending', 'private' ),
'posts_per_page' => -1,
'fields' => 'ids', // Only need the count
- // Restore organizer query
- 'meta_key' => '_EventOrganizerID',
- 'meta_value' => $this->user_id,
- 'meta_compare' => '=', // Explicitly set compare
- 'meta_type' => 'NUMERIC', // Specify numeric comparison
);
$query = new WP_Query( $args );
return (int) $query->found_posts;
@@ -222,17 +217,9 @@ class HVAC_Dashboard_Data {
$args = array(
'post_type' => Tribe__Events__Main::POSTTYPE,
- // 'author' => $this->user_id, // Query by organizer instead
+ 'author' => $this->user_id, // Query by post author
'post_status' => $post_status,
'posts_per_page' => -1,
- 'meta_query' => array( // Use meta_query for organizer filtering
- array(
- 'key' => '_EventOrganizerID',
- 'value' => $this->user_id,
- 'compare' => '=',
- 'type' => 'NUMERIC', // Specify numeric comparison
- ),
- ),
'orderby' => 'meta_value', // Order by start date
'meta_key' => '_EventStartDate', // Specify the meta key for ordering
'order' => 'DESC', // Show most recent first