/*
Theme Name: GeneratePress Child
Theme URI: https://generatepress.com
Template: generatepress
Author: Tom Usborne
Author URI: https://generatepress.com/about
Description: GeneratePress is a lightweight WordPress theme built with a focus on speed and usability. Performance is important to us, which is why a fresh GeneratePress install adds less than 10kb (gzipped) to your page size. We take full advantage of the block editor (Gutenberg), which gives you more control over creating your content. If you use page builders, GeneratePress is the right theme for you. It is completely compatible with all major page builders, including Beaver Builder and Elementor. Thanks to our emphasis on WordPress coding standards, we can boast full compatibility with all well-coded plugins, including WooCommerce. GeneratePress is fully responsive, uses valid HTML/CSS, and is translated into over 25 languages by our amazing community of users. A few of our many features include 60+ color controls, powerful dynamic typography, 5 navigation locations, 5 sidebar layouts, dropdown menus (click or hover), and 9 widget areas. Learn more and check out our powerful premium version at https://generatepress.com
Tags: two-columns,three-columns,one-column,right-sidebar,left-sidebar,footer-widgets,blog,e-commerce,flexible-header,full-width-template,buddypress,custom-header,custom-background,custom-menu,custom-colors,sticky-post,threaded-comments,translation-ready,rtl-language-support,featured-images,theme-options
Version: 3.6.1.1783137278
Updated: 2026-07-04 03:54:38
*/

<?php
// Display ACF fields on single Calibre entries
add_action( 'generate_after_entry_title', function() {
    if ( ! is_singular( 'calibre' ) ) return;
    if ( ! function_exists( 'get_field' ) ) return;

    $earliest   = get_field('earliest_example');
    $latest     = get_field('latest_example');
    $notes      = get_field('notes');

    $specs = [
        'lignes'             => 'Lignes',
        'mounting_diameter'  => 'Mounting Diameter',
        'thickness'          => 'Thickness',
        'frequency'          => 'Frequency (vph)',
        'jewels'             => 'Jewels',
        'power_reserve'      => 'Power Reserve',
        'hand_sizes'         => 'Hand Sizes',
        'complication'       => 'Complication',
        'power'              => 'Power',
        'shape'              => 'Shape',
        'size'               => 'Size',
    ];

    echo '<div class="calibre-body">';

    // Production years
    if ( $earliest || $latest ) {
        echo '<p class="calibre-years">';
        echo esc_html($earliest);
        if ( $earliest && $latest ) echo ' – ';
        echo esc_html($latest);
        echo '</p>';
    }

    // Specs table
    $has_specs = false;
    foreach ( $specs as $key => $label ) {
        if ( get_field($key) ) { $has_specs = true; break; }
    }

    if ( $has_specs ) {
        echo '<h2 class="calibre-section-heading">Specifications</h2>';
        echo '<table class="calibre-spec-table"><tbody>';
        foreach ( $specs as $key => $label ) {
            $value = get_field($key);
            if ( $value ) {
                echo '<tr>';
                echo '<th>' . esc_html($label) . '</th>';
                echo '<td>' . esc_html($value) . '</td>';
                echo '</tr>';
            }
        }
        echo '</tbody></table>';
    }

    // Notes
    if ( $notes ) {
        echo '<div class="calibre-notes">';
        echo '<h2 class="calibre-section-heading">Notes</h2>';
        echo '<p>' . nl2br( esc_html($notes) ) . '</p>';
        echo '</div>';
    }

    echo '</div><!-- .calibre-body -->';
});