diff --git a/wp-content/themes/twentytwentyfour/assets/css/test1-shared-shell.css b/wp-content/themes/twentytwentyfour/assets/css/test1-shared-shell.css index 75ed9b9d..ba6cecfd 100644 --- a/wp-content/themes/twentytwentyfour/assets/css/test1-shared-shell.css +++ b/wp-content/themes/twentytwentyfour/assets/css/test1-shared-shell.css @@ -17,14 +17,29 @@ flex-direction: column; } +.test1-shared-faq-page { + min-height: 100vh; + display: flex; + flex-direction: column; +} + .test1-shared-cart-page .site-main { flex: 1 0 auto; } +.test1-shared-faq-page .site-main { + flex: 1 0 auto; + padding-bottom: 26px; +} + .test1-shared-cart-page .classic-footer { margin-top: auto; } +.test1-shared-faq-page .classic-footer { + margin-top: auto; +} + .test1-shared-shell .site-header { position: sticky; top: 0; diff --git a/wp-content/themes/twentytwentyfour/assets/js/test1-faq.js b/wp-content/themes/twentytwentyfour/assets/js/test1-faq.js new file mode 100644 index 00000000..2c3c5c87 --- /dev/null +++ b/wp-content/themes/twentytwentyfour/assets/js/test1-faq.js @@ -0,0 +1,38 @@ +(() => { + const faqItems = document.querySelectorAll('.faq-item') + + if (!faqItems.length) { + return + } + + faqItems.forEach(item => { + const trigger = item.querySelector('.faq-question') + const answer = item.querySelector('.faq-answer') + + if (!trigger || !answer) { + return + } + + trigger.addEventListener('click', () => { + const isOpen = item.classList.contains('open') + + faqItems.forEach(entry => { + const entryTrigger = entry.querySelector('.faq-question') + const entryAnswer = entry.querySelector('.faq-answer') + + entry.classList.remove('open') + entryTrigger?.setAttribute('aria-expanded', 'false') + + if (entryAnswer) { + entryAnswer.hidden = true + } + }) + + if (!isOpen) { + item.classList.add('open') + trigger.setAttribute('aria-expanded', 'true') + answer.hidden = false + } + }) + }) +})() diff --git a/wp-content/themes/twentytwentyfour/functions.php b/wp-content/themes/twentytwentyfour/functions.php index d05f8bbd..b896b511 100644 --- a/wp-content/themes/twentytwentyfour/functions.php +++ b/wp-content/themes/twentytwentyfour/functions.php @@ -228,6 +228,29 @@ function twentytwentyfour_test1_template( $template ) { } add_filter( 'template_include', 'twentytwentyfour_test1_template' ); +/** + * Use a standalone PHP template for the page slug "faq". + * + * @since Twenty Twenty-Four 1.0 + * + * @param string $template Resolved template path. + * @return string + */ +function twentytwentyfour_faq_template( $template ) { + if ( ! is_page( 'faq' ) ) { + return $template; + } + + $custom_template = get_theme_file_path( 'page-faq.php' ); + + if ( file_exists( $custom_template ) ) { + return $custom_template; + } + + return $template; +} +add_filter( 'template_include', 'twentytwentyfour_faq_template' ); + /** * Use a lightweight custom template for the WooCommerce checkout page. * @@ -281,7 +304,7 @@ add_filter( 'template_include', 'twentytwentyfour_cart_template', 20 ); * @return void */ function twentytwentyfour_test1_assets() { - $use_test1_assets = is_page( 'test1' ); + $use_test1_assets = is_page( array( 'test1', 'faq' ) ); if ( ! $use_test1_assets ) { return; @@ -290,7 +313,7 @@ function twentytwentyfour_test1_assets() { $css_file = ABSPATH . 'index3.css'; $js_file = ABSPATH . 'index3.js'; - if ( is_page( 'test1' ) ) { + if ( $use_test1_assets ) { wp_dequeue_style( 'global-styles' ); wp_dequeue_style( 'wp-block-library' ); wp_dequeue_style( 'wp-block-library-theme' ); @@ -335,6 +358,20 @@ function twentytwentyfour_test1_assets() { } } + if ( is_page( 'faq' ) ) { + $faq_js_file = get_theme_file_path( 'assets/js/test1-faq.js' ); + + if ( file_exists( $faq_js_file ) ) { + wp_enqueue_script( + 'twentytwentyfour-test1-faq-script', + get_theme_file_uri( 'assets/js/test1-faq.js' ), + array(), + (string) filemtime( $faq_js_file ), + true + ); + } + } + } add_action( 'wp_enqueue_scripts', 'twentytwentyfour_test1_assets', 100 ); @@ -345,7 +382,7 @@ add_action( 'wp_enqueue_scripts', 'twentytwentyfour_test1_assets', 100 ); * @return void */ function twentytwentyfour_test1_shared_shell_assets() { - if ( ! ( ( function_exists( 'is_checkout' ) && is_checkout() && ! is_order_received_page() ) || ( function_exists( 'is_cart' ) && is_cart() ) ) ) { + if ( ! ( ( function_exists( 'is_checkout' ) && is_checkout() && ! is_order_received_page() ) || ( function_exists( 'is_cart' ) && is_cart() ) || is_page( 'faq' ) ) ) { return; } diff --git a/wp-content/themes/twentytwentyfour/page-faq.php b/wp-content/themes/twentytwentyfour/page-faq.php new file mode 100644 index 00000000..703c7fb9 --- /dev/null +++ b/wp-content/themes/twentytwentyfour/page-faq.php @@ -0,0 +1,107 @@ + +> +
+ + + + +> + + + +