init_hooks(); } /** * Initialize hooks */ private function init_hooks() { // Register shortcodes add_shortcode('hvac_announcements_timeline', array($this, 'render_timeline_shortcode')); add_shortcode('hvac_announcements_list', array($this, 'render_list_shortcode')); add_shortcode('hvac_google_drive_embed', array($this, 'render_google_drive_shortcode')); // Filter for UAGB post timeline to include our post type add_filter('uagb_post_timeline_query_args', array($this, 'modify_uagb_query'), 10, 2); // Enqueue scripts when shortcode is used add_action('wp_enqueue_scripts', array($this, 'maybe_enqueue_scripts')); } /** * Render announcements timeline shortcode * * @param array $atts Shortcode attributes * @return string */ public function render_timeline_shortcode($atts) { // Check permissions if (!HVAC_Announcements_Permissions::current_user_can_read()) { return '
' . __('You do not have permission to view announcements.', 'hvac') . '
'; } $atts = shortcode_atts(array( 'posts_per_page' => 10, 'orderby' => 'date', 'order' => 'DESC', ), $atts); // Query announcements $args = array( 'post_type' => HVAC_Announcements_CPT::get_post_type(), 'posts_per_page' => intval($atts['posts_per_page']), 'orderby' => sanitize_text_field($atts['orderby']), 'order' => sanitize_text_field($atts['order']), 'post_status' => 'publish', ); $query = new WP_Query($args); ob_start(); ?> ' . __('You do not have permission to view announcements.', 'hvac') . ''; } $atts = shortcode_atts(array( 'posts_per_page' => 5, 'show_excerpt' => 'yes', 'show_date' => 'yes', 'show_author' => 'no', ), $atts); // Query announcements $args = array( 'post_type' => HVAC_Announcements_CPT::get_post_type(), 'posts_per_page' => intval($atts['posts_per_page']), 'orderby' => 'date', 'order' => 'DESC', 'post_status' => 'publish', ); $query = new WP_Query($args); ob_start(); ?> ' . __('You do not have permission to view training resources.', 'hvac') . ''; } $atts = shortcode_atts(array( 'url' => 'https://drive.google.com/drive/folders/16uDRkFcaEqKUxfBek9VbfbAIeFV77nZG?usp=drive_link', 'height' => '600', 'width' => '100%', ), $atts); // Convert sharing URL to embed URL $embed_url = $this->convert_drive_url_to_embed($atts['url']); ob_start(); ?> post_type !== HVAC_Announcements_CPT::get_post_type()) { return ''; } // Check permissions if (!HVAC_Announcements_Permissions::current_user_can_read()) { return ''; } // Only allow viewing of published posts unless user is a master trainer if ($post->post_status !== 'publish' && !HVAC_Announcements_Permissions::is_master_trainer()) { return ''; } ob_start(); ?>