template_loader = TemplateLoader::get_instance(); $this->enqueue = Enqueue::get_instance(); add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); } public function enqueue_scripts() { $post_type = PostType::get_instance(); $is_custom_template = is_page() && get_post_meta( get_the_ID(), '_wp_page_template', true ) === 'acumenon-kb-template.php'; if ( is_singular( $post_type->post_type ) || is_post_type_archive( $post_type->post_type ) || is_tax( $post_type->knowledge_base ) || is_tax( $post_type->category ) || is_tax( $post_type->tag ) || $is_custom_template ) { // Try to load frontend styles if they exist $css_file = ACUMENON_PLUGIN_DIR . 'assets/css/frontend.css'; if ( file_exists( $css_file ) ) { $this->enqueue->enqueue( 'acumenon-frontend-css', 'css/frontend.css' ); } // Load frontend JS $js_file = ACUMENON_PLUGIN_DIR . 'assets/js/frontend.js'; if ( file_exists( $js_file ) ) { $this->enqueue->enqueue( 'acumenon-frontend-js', 'js/frontend.js', [] ); wp_localize_script( 'acumenon-frontend-js', 'acumenonFrontendData', [ 'restUrl' => esc_url_raw( rest_url( 'acumenon/v1/' ) ), ] ); } } } }