diff --git a/includes/class-hvac-announcements-display.php b/includes/class-hvac-announcements-display.php index 58b7e18f..d632a316 100644 --- a/includes/class-hvac-announcements-display.php +++ b/includes/class-hvac-announcements-display.php @@ -251,7 +251,7 @@ class HVAC_Announcements_Display { } $atts = shortcode_atts(array( - 'url' => 'https://drive.google.com/drive/folders/16uDRkFcaEqKUxfBek9VbfbAIeFV77nZG?usp=drive_link', + 'url' => 'https://drive.google.com/drive/folders/1-SDHGR9Ix6BmUVTHa3wI99K0rwfWL-vs?usp=drive_link', 'height' => '600', 'width' => '100%', ), $atts); diff --git a/includes/class-hvac-dashboard-data.php b/includes/class-hvac-dashboard-data.php index ab6c69ec..0d048087 100644 --- a/includes/class-hvac-dashboard-data.php +++ b/includes/class-hvac-dashboard-data.php @@ -43,18 +43,23 @@ class HVAC_Dashboard_Data { */ public function get_total_events_count() { global $wpdb; - + try { + // Check if TEC is available + if ( ! class_exists( 'Tribe__Events__Main' ) ) { + return 0; + } + // Cache key based on user ID $cache_key = 'hvac_dashboard_total_events_' . $this->user_id; $count = wp_cache_get( $cache_key, 'hvac_dashboard' ); - + if ( false === $count ) { // Use direct database query to avoid TEC query hijacking $count = $wpdb->get_var( $wpdb->prepare( - "SELECT COUNT(*) FROM {$wpdb->posts} - WHERE post_type = %s - AND post_author = %d + "SELECT COUNT(*) FROM {$wpdb->posts} + WHERE post_type = %s + AND post_author = %d AND post_status IN ('publish', 'future', 'draft', 'pending', 'private')", Tribe__Events__Main::POSTTYPE, $this->user_id @@ -84,20 +89,25 @@ class HVAC_Dashboard_Data { */ public function get_upcoming_events_count() { global $wpdb; - + + // Check if TEC is available + if ( ! class_exists( 'Tribe__Events__Main' ) ) { + return 0; + } + // Cache key based on user ID $cache_key = 'hvac_dashboard_upcoming_events_' . $this->user_id; $count = wp_cache_get( $cache_key, 'hvac_dashboard' ); - + if ( false === $count ) { $today = date( 'Y-m-d H:i:s' ); - + // Use direct database query to avoid TEC query hijacking $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->posts} p LEFT JOIN {$wpdb->postmeta} pm ON p.ID = pm.post_id AND pm.meta_key = '_EventStartDate' - WHERE p.post_type = %s - AND p.post_author = %d + WHERE p.post_type = %s + AND p.post_author = %d AND p.post_status IN ('publish', 'future') AND (pm.meta_value >= %s OR pm.meta_value IS NULL)", Tribe__Events__Main::POSTTYPE, @@ -119,20 +129,25 @@ class HVAC_Dashboard_Data { */ public function get_past_events_count() { global $wpdb; - + + // Check if TEC is available + if ( ! class_exists( 'Tribe__Events__Main' ) ) { + return 0; + } + // Cache key based on user ID $cache_key = 'hvac_dashboard_past_events_' . $this->user_id; $count = wp_cache_get( $cache_key, 'hvac_dashboard' ); - + if ( false === $count ) { $today = date( 'Y-m-d H:i:s' ); - + // Use direct database query to avoid TEC query hijacking $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->posts} p LEFT JOIN {$wpdb->postmeta} pm ON p.ID = pm.post_id AND pm.meta_key = '_EventEndDate' - WHERE p.post_type = %s - AND p.post_author = %d + WHERE p.post_type = %s + AND p.post_author = %d AND p.post_status IN ('publish', 'private') AND pm.meta_value < %s", Tribe__Events__Main::POSTTYPE, diff --git a/templates/page-edit-event-custom.php b/templates/page-edit-event-custom.php index ef190c01..3fcdc394 100644 --- a/templates/page-edit-event-custom.php +++ b/templates/page-edit-event-custom.php @@ -113,7 +113,7 @@ get_header();