Dashboard
PHP:
8.1.33
OS:
Linux
User:
lawtemple
/
/
home
/
www
/
lawtemplefirm.com
/
wp-content
/
themes
/
law-temple-theme
/
inc
📤 Upload
📝 New File
📁 New Folder
Close
Editing: presentation-builders.php
<?php if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Presentation builders and mega-menu support. * All functions are prefixed and filterable for child-theme/developer overrides. */ function lt_theme_archive_columns_style( $post_type = '' ) { $desktop = max( 1, min( 4, (int) lt_theme_archive_columns( $post_type ?: 'archive' ) ) ); $tablet = max( 1, min( 3, absint( lt_theme_option( 'archive_columns_tablet', 2 ) ) ) ); $mobile = max( 1, min( 2, absint( lt_theme_option( 'archive_columns_mobile', 1 ) ) ) ); return sprintf( '--lt-archive-columns:%d;--lt-archive-columns-tablet:%d;--lt-archive-columns-mobile:%d;', $desktop, $tablet, $mobile ); } function lt_theme_archive_hero_class() { return 'lt-archive-hero--' . sanitize_html_class( lt_theme_option( 'archive_hero_style', 'surface' ) ); } function lt_theme_content_width_class( $context = 'profile' ) { $key = 'practice' === $context ? 'practice_content_width' : 'profile_content_width'; return 'lt-content-width--' . sanitize_html_class( lt_theme_option( $key, 'standard' ) ); } function lt_theme_archive_builder_preview() { $layout = sanitize_html_class( lt_theme_option( 'lawyer_archive_layout', 'portrait' ) ); $hero = sanitize_html_class( lt_theme_option( 'archive_hero_style', 'surface' ) ); echo '<div class="lt-builder-preview lt-builder-preview--archive" data-archive-layout="' . esc_attr( $layout ) . '" data-hero-style="' . esc_attr( $hero ) . '">'; echo '<div class="lt-builder-preview__hero"><span class="lt-preview-eyebrow">' . esc_html__( 'Our People', 'law-temple-theme' ) . '</span><strong>' . esc_html__( 'Professionals with experience across the firm', 'law-temple-theme' ) . '</strong><small>' . esc_html__( 'Archive hero, filters and responsive columns preview', 'law-temple-theme' ) . '</small></div>'; if ( lt_theme_option( 'archive_show_filters' ) ) { echo '<div class="lt-builder-preview__filters"><span></span><span></span><span></span></div>'; } echo '<div class="lt-builder-preview__cards"><i></i><i></i><i></i></div></div>'; } function lt_theme_profile_builder_preview() { $layout = sanitize_html_class( lt_theme_option( 'profile_layout', 'split' ) ); echo '<div class="lt-builder-preview lt-builder-preview--profile" data-profile-layout="' . esc_attr( $layout ) . '"><div class="lt-builder-preview__portrait"></div><div class="lt-builder-preview__profile-copy"><span>' . esc_html__( 'Partner', 'law-temple-theme' ) . '</span><strong>' . esc_html__( 'Professional Name', 'law-temple-theme' ) . '</strong><p></p><p></p><div class="lt-builder-preview__tabs"><i></i><i></i><i></i></div></div></div>'; } function lt_theme_practice_builder_preview() { $layout = sanitize_html_class( lt_theme_option( 'practice_single_layout', 'editorial' ) ); echo '<div class="lt-builder-preview lt-builder-preview--practice" data-practice-layout="' . esc_attr( $layout ) . '"><div><span>' . esc_html__( 'Practice Area', 'law-temple-theme' ) . '</span><strong>' . esc_html__( 'Corporate & Commercial', 'law-temple-theme' ) . '</strong><p></p><p></p></div><aside><i></i><i></i><i></i></aside></div>'; } /** * Desktop-only professional mega menu using the existing Primary Navigation. * The configured top-level menu item remains a normal link and gets a generated * practice/sector panel. Mobile navigation deliberately uses WordPress' normal * menu walker so the panel never duplicates the mobile menu. */ function lt_theme_mega_menu_css_class( $classes, $item, $args, $depth ) { if ( ! lt_theme_option( 'mega_menu' ) || 0 !== (int) $depth || empty( $args->theme_location ) || 'primary' !== $args->theme_location ) { return $classes; } $target = strtolower( trim( (string) lt_theme_option( 'mega_menu_target', 'expertise' ) ) ); if ( $target && strtolower( trim( wp_strip_all_tags( $item->title ) ) ) === $target ) { $classes[] = 'lt-has-mega'; } return $classes; } add_filter( 'nav_menu_css_class', 'lt_theme_mega_menu_css_class', 10, 4 ); class LT_Theme_Mega_Menu_Walker extends Walker_Nav_Menu { public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) { parent::start_el( $output, $item, $depth, $args, $id ); if ( 0 !== (int) $depth || ! lt_theme_option( 'mega_menu' ) ) { return; } $target = strtolower( trim( (string) lt_theme_option( 'mega_menu_target', 'expertise' ) ) ); if ( '' === $target || strtolower( trim( wp_strip_all_tags( $item->title ) ) ) !== $target ) { return; } $practices = array(); $sectors = array(); if ( lt_theme_option( 'mega_menu_show_practices' ) && post_type_exists( 'practice' ) ) { $practices = get_posts( array( 'post_type' => 'practice', 'post_status' => 'publish', 'posts_per_page' => max( 1, min( 16, absint( lt_theme_option( 'mega_menu_practice_count', 8 ) ) ) ), 'orderby' => 'menu_order title', 'order' => 'ASC', ) ); } if ( lt_theme_option( 'mega_menu_show_sectors' ) && taxonomy_exists( 'sector' ) ) { $sectors = get_terms( array( 'taxonomy' => 'sector', 'hide_empty' => true, 'number' => max( 1, min( 16, absint( lt_theme_option( 'mega_menu_sector_count', 8 ) ) ) ), 'orderby' => 'name', 'order' => 'ASC', ) ); if ( is_wp_error( $sectors ) ) { $sectors = array(); } } if ( ! $practices && ! $sectors ) { return; } $output .= '<div class="lt-mega-panel" role="group" aria-label="' . esc_attr__( 'Expertise navigation', 'law-temple-theme' ) . '"><div class="lt-mega-panel__inner">'; if ( $practices ) { $output .= '<section><div class="lt-mega-panel__heading">' . esc_html( lt_theme_option( 'mega_menu_practice_heading', __( 'Practice Areas', 'law-temple-theme' ) ) ) . '</div><ul class="lt-mega-panel__links">'; foreach ( $practices as $practice ) { $output .= '<li><a href="' . esc_url( get_permalink( $practice ) ) . '">' . esc_html( $practice->post_title ) . '</a></li>'; } $output .= '</ul></section>'; } if ( $sectors ) { $output .= '<section><div class="lt-mega-panel__heading">' . esc_html( lt_theme_option( 'mega_menu_sector_heading', __( 'Sectors', 'law-temple-theme' ) ) ) . '</div><ul class="lt-mega-panel__links">'; foreach ( $sectors as $sector ) { $output .= '<li><a href="' . esc_url( get_term_link( $sector ) ) . '">' . esc_html( $sector->name ) . '</a></li>'; } $output .= '</ul></section>'; } $cta_label = trim( (string) lt_theme_option( 'mega_menu_cta_label' ) ); $cta_url = esc_url( lt_theme_option( 'mega_menu_cta_url' ) ); if ( ! $cta_url && post_type_exists( 'practice' ) ) { $cta_url = get_post_type_archive_link( 'practice' ); } if ( $cta_label && $cta_url ) { $output .= '<aside class="lt-mega-panel__cta"><span>' . esc_html__( 'Legal services', 'law-temple-theme' ) . '</span><a href="' . esc_url( $cta_url ) . '">' . esc_html( $cta_label ) . ' <span aria-hidden="true">→</span></a></aside>'; } $output .= '</div></div>'; } } function lt_theme_primary_menu_args() { $args = array( 'theme_location'=>'primary', 'container'=>false, 'fallback_cb'=>false, 'depth'=>3 ); if ( lt_theme_option( 'mega_menu' ) ) { $args['walker'] = new LT_Theme_Mega_Menu_Walker(); } return apply_filters( 'lt_theme_primary_menu_args', $args ); } function lt_theme_archive_body_classes( $classes ) { if ( is_post_type_archive() ) { $classes[] = lt_theme_archive_hero_class(); if ( ! lt_theme_option( 'archive_show_images' ) ) { $classes[] = 'lt-archive-hide-images'; } if ( ! lt_theme_option( 'archive_show_excerpts' ) ) { $classes[] = 'lt-archive-hide-excerpts'; } if ( ! lt_theme_option( 'archive_show_filters' ) ) { $classes[] = 'lt-archive-hide-filters'; } } if ( is_singular( 'lawyer' ) ) { $classes[] = 'lt-profile-layout-' . sanitize_html_class( lt_theme_option( 'profile_layout', 'split' ) ); if ( ! lt_theme_option( 'profile_nav_sticky' ) ) { $classes[] = 'lt-profile-nav-static'; } if ( ! lt_theme_option( 'profile_show_photo' ) ) { $classes[] = 'lt-profile-no-photo'; } if ( lt_theme_option( 'profile_contact_rail' ) ) { $classes[] = 'lt-profile-has-contact-rail'; } } if ( is_singular( 'practice' ) ) { $classes[] = 'lt-practice-layout-' . sanitize_html_class( lt_theme_option( 'practice_single_layout', 'editorial' ) ); if ( ! lt_theme_option( 'practice_show_image' ) ) { $classes[] = 'lt-practice-no-image'; } if ( lt_theme_option( 'practice_sticky_summary' ) ) { $classes[] = 'lt-practice-sticky-summary'; } } return $classes; } add_filter( 'body_class', 'lt_theme_archive_body_classes' );
Save
Cancel