pdf_instance = new AIOHM_Simple_PDF(); return true; } /** * Get PDF instance */ public function get_pdf() { return $this->pdf_instance; } } /** * Simple PDF generator class */ class AIOHM_Simple_PDF { private $content = ''; private $title = ''; /** * Initialize PDF generation with proper WordPress hooks */ public function __construct() { // Enqueue assets using proper WordPress hooks add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) ); add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_assets' ) ); } /** * Enqueue admin assets using WordPress standards */ public function enqueue_admin_assets( $hook ) { // Only load on relevant admin pages if ( strpos( $hook, 'aiohm' ) === false ) { return; } wp_enqueue_style( 'aiohm-pdf-generation', AIOHM_KB_PLUGIN_URL . 'assets/css/aiohm-pdf-generation.css', array(), AIOHM_KB_VERSION, 'all' ); wp_enqueue_script( 'aiohm-pdf-generation', AIOHM_KB_PLUGIN_URL . 'assets/js/aiohm-pdf-generation.js', array(), AIOHM_KB_VERSION, true ); } /** * Enqueue frontend assets using WordPress standards */ public function enqueue_frontend_assets() { // Only enqueue when needed (not globally) if ( ! $this->should_load_pdf_assets() ) { return; } wp_enqueue_style( 'aiohm-pdf-generation', AIOHM_KB_PLUGIN_URL . 'assets/css/aiohm-pdf-generation.css', array(), AIOHM_KB_VERSION, 'all' ); wp_enqueue_script( 'aiohm-pdf-generation', AIOHM_KB_PLUGIN_URL . 'assets/js/aiohm-pdf-generation.js', array(), AIOHM_KB_VERSION, true ); } /** * Check if PDF assets should be loaded */ private function should_load_pdf_assets() { // Load only when PDF functionality is needed return is_admin() || has_shortcode( get_post()->post_content ?? '', 'aiohm_chat' ); } /** * Add a page (in our case, just initialize) */ public function AddPage() { // Initialize the HTML content with proper structure $this->content = '
'; $this->content .= ''; } /** * Add a chapter title */ public function ChapterTitle( $title ) { $this->content .= '