*/ private static $toggle_icons = [ 'chevron' => "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E\")", ]; /** * Get toggle icon SVG data URIs. * * Shared by FAQShortcode for inline CSS output. * * @return array */ public static function get_toggle_icons(): array { /** * Filter the toggle icons, keyed by setting value. The Premium build * adds its plus, arrow and caret icons. * * @since 2.8.0 * @param array $icons SVG data URIs. */ $icons = apply_filters( 'aipt_faq_display_toggle_icons', self::$toggle_icons ); return is_array( $icons ) ? array_filter( $icons, 'is_string' ) + self::$toggle_icons : self::$toggle_icons; } /** * Extra CSS for the FAQ display, after the custom-property block. * * @param string[] $parts CSS parts so far. * @param array $settings Display settings. * @return string[] */ public static function extra_css( array $parts, array $settings ): array { /** * Filter the FAQ display's inline CSS parts. The Premium build adds * the merchant's custom CSS. * * @since 2.8.0 * @param string[] $parts CSS parts. * @param array $settings Display settings. */ $filtered = apply_filters( 'aipt_faq_display_css', $parts, $settings ); return is_array( $filtered ) ? array_values( array_filter( $filtered, 'is_string' ) ) : $parts; } /** * Tell extensions the FAQ display stylesheet was just enqueued, so the * Premium build can add its theme presets right after it. * * @return void */ public static function styles_enqueued(): void { /** * Fires right after the `aipt-faq-display` stylesheet is enqueued. * * @since 2.8.0 */ do_action( 'aipt_faq_display_styles_enqueued' ); } /** * Sanitize a settings value for inclusion inside a CSS custom-property * declaration in an inline ' . "\n"; } /** * Build the container CSS classes for the accordion. * * @param array $settings Display settings. * @return string Space-separated class string. */ public static function build_container_classes( array $settings ): string { $classes = []; $settings = FAQDisplaySettings::projectThemePresetForEntitlement( $settings ); $theme_preset = ! empty( $settings['theme_preset'] ) ? $settings['theme_preset'] : 'default'; $classes[] = 'aipt-faq-accordion--' . sanitize_html_class( $theme_preset ); if ( isset( $settings['animation'] ) && 'smooth' === $settings['animation'] ) { $classes[] = 'aipt-faq-accordion--smooth'; } /** * Filter the accordion container classes. The Premium build adds the * merchant's custom container class and its other animations. * * @since 2.8.0 * @param string[] $classes Classes. * @param array $settings Display settings (theme preset projected). */ $filtered = apply_filters( 'aipt_faq_display_container_classes', $classes, $settings ); if ( is_array( $filtered ) ) { $classes = array_values( array_filter( array_map( 'sanitize_html_class', array_filter( $filtered, 'is_string' ) ) ) ); } return implode( ' ', $classes ); } /** * Render FAQ content after single product summary. * Hooked to woocommerce_after_single_product_summary. * * Chooses between accordion and flat list output based on settings. * Skips rendering when display_mode is 'shortcode' (user places manually). * * @return void */ public static function render_accordion_content(): void { if ( ! self::should_render() ) { return; } $settings_obj = new FAQDisplaySettings(); $settings = $settings_obj->getAll(); if ( ! empty( $settings['display_mode'] ) && 'shortcode' === $settings['display_mode'] ) { return; } $product_id = get_the_ID(); $faq_data = get_post_meta( $product_id, '_aipt_faq_data', true ); $faqs = is_string( $faq_data ) ? json_decode( $faq_data, true ) : null; if ( ! is_array( $faqs ) || empty( $faqs ) ) { return; } if ( ! empty( $settings['accordion_enabled'] ) ) { $render_settings = [ 'container_class_name' => self::build_container_classes( $settings ), ]; echo FAQTemplateRenderer::renderAccordion( $faqs, $render_settings ); } else { echo FAQTemplateRenderer::renderFlat( $faqs, 'html', $settings ); } } }