esc_html__( 'Primary Menu', 'peptide-starter' ), 'footer' => esc_html__( 'Footer Menu', 'peptide-starter' ), ) ); // Add support for wide blocks add_theme_support( 'align-wide' ); // Load text domain load_theme_textdomain( 'peptide-starter', PEPTIDE_STARTER_DIR . '/languages' ); } add_action( 'after_setup_theme', 'peptide_starter_setup' ); /** * Register and enqueue stylesheets and scripts */ function peptide_starter_scripts() { // Register and enqueue main stylesheet wp_enqueue_style( 'peptide-starter-style', PEPTIDE_STARTER_URI . '/style.css', array(), PEPTIDE_STARTER_VERSION ); // Add conditional scripts wp_enqueue_script( 'peptide-starter-navigation', PEPTIDE_STARTER_URI . '/assets/js/navigation.js', array(), PEPTIDE_STARTER_VERSION, true ); wp_enqueue_script( 'peptide-starter-theme', PEPTIDE_STARTER_URI . '/assets/js/theme.js', array(), PEPTIDE_STARTER_VERSION, true ); // Pass PHP data to JavaScript wp_localize_script( 'peptide-starter-theme', 'peptideStarterData', array( 'siteUrl' => home_url( '/' ), 'isDarkMode' => get_theme_mod( 'dark_mode_default', false ), ) ); // Dequeue comment reply script if comments are not open if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'peptide_starter_scripts' ); /** * Enqueue plugin override styles at a late priority so they load AFTER plugin stylesheets. * This ensures theme overrides (e.g. removing line-clamp on article excerpts) beat plugin CSS. */ function peptide_starter_plugin_overrides() { wp_add_inline_style( 'peptide-starter-style', ' /* Override Peptide News plugin line-clamp — show full summaries */ p.pn-article-excerpt, .pn-article-card p.pn-article-excerpt, body .pn-article-excerpt { -webkit-line-clamp: unset !important; -webkit-box-orient: unset !important; display: block !important; overflow: visible !important; } ' ); } add_action( 'wp_enqueue_scripts', 'peptide_starter_plugin_overrides', 99 ); /** * Register widget areas */ function peptide_starter_widgets_init() { register_sidebar( array( 'name' => esc_html__( 'Footer - Column 1', 'peptide-starter' ), 'id' => 'footer-1', 'description' => esc_html__( 'Footer widget area 1', 'peptide-starter' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => esc_html__( 'Footer - Column 2', 'peptide-starter' ), 'id' => 'footer-2', 'description' => esc_html__( 'Footer widget area 2', 'peptide-starter' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => esc_html__( 'Footer - Column 3', 'peptide-starter' ), 'id' => 'footer-3', 'description' => esc_html__( 'Footer widget area 3', 'peptide-starter' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => esc_html__( 'Footer - Column 4', 'peptide-starter' ), 'id' => 'footer-4', 'description' => esc_html__( 'Footer widget area 4', 'peptide-starter' ), 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'peptide_starter_widgets_init' ); /** * Register theme customizer options */ function peptide_starter_customize_register( $wp_customize ) { // Logo section $wp_customize->add_section( 'peptide_starter_branding', array( 'title' => esc_html__( 'Branding', 'peptide-starter' ), 'priority' => 30, ) ); // Hero settings section $wp_customize->add_section( 'peptide_starter_hero', array( 'title' => esc_html__( 'Hero Section', 'peptide-starter' ), 'priority' => 40, ) ); // Hero Title $wp_customize->add_setting( 'hero_title', array( 'default' => get_bloginfo( 'name' ), 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'hero_title', array( 'label' => esc_html__( 'Hero Title', 'peptide-starter' ), 'section' => 'peptide_starter_hero', 'type' => 'text', ) ); // Hero Subtitle $wp_customize->add_setting( 'hero_subtitle', array( 'default' => esc_html__( 'A scientific peptide reference database', 'peptide-starter' ), 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'hero_subtitle', array( 'label' => esc_html__( 'Hero Subtitle', 'peptide-starter' ), 'section' => 'peptide_starter_hero', 'type' => 'textarea', ) ); // Hero Search Placeholder $wp_customize->add_setting( 'hero_search_placeholder', array( 'default' => esc_html__( 'Search peptides, sequences, or research...', 'peptide-starter' ), 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'hero_search_placeholder', array( 'label' => esc_html__( 'Search Placeholder', 'peptide-starter' ), 'section' => 'peptide_starter_hero', 'type' => 'text', ) ); // Footer section $wp_customize->add_section( 'peptide_starter_footer', array( 'title' => esc_html__( 'Footer', 'peptide-starter' ), 'priority' => 50, ) ); // Footer Copyright Text $wp_customize->add_setting( 'footer_copyright', array( 'default' => esc_html__( 'Copyright © 2026 Peptide Repo. All rights reserved.', 'peptide-starter' ), 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'footer_copyright', array( 'label' => esc_html__( 'Copyright Text', 'peptide-starter' ), 'section' => 'peptide_starter_footer', 'type' => 'textarea', ) ); // Dark mode section $wp_customize->add_section( 'peptide_starter_theme_mode', array( 'title' => esc_html__( 'Theme Mode', 'peptide-starter' ), 'priority' => 60, ) ); // Dark mode default $wp_customize->add_setting( 'dark_mode_default', array( 'default' => false, 'transport' => 'refresh', ) ); $wp_customize->add_control( 'dark_mode_default', array( 'label' => esc_html__( 'Enable Dark Mode by Default', 'peptide-starter' ), 'section' => 'peptide_starter_theme_mode', 'type' => 'checkbox', ) ); } add_action( 'customize_register', 'peptide_starter_customize_register' ); /** * Add custom logo support */ function peptide_starter_get_custom_logo() { if ( function_exists( 'get_custom_logo' ) ) { return get_custom_logo(); } return ''; } /** * Navigation Menu Walker for handling active states */ class Peptide_Starter_Nav_Walker extends Walker_Nav_Menu { public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) { if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { $t = ''; $n = ''; } else { $t = "\t"; $n = "\n"; } $indent = ( $depth ) ? str_repeat( $t, $depth ) : ''; $classes = empty( $item->classes ) ? array() : (array) $item->classes; $classes[] = 'menu-item-' . $item->ID; if ( in_array( 'current-menu-item', $classes, true ) || in_array( 'current-menu-parent', $classes, true ) ) { $classes[] = 'active'; } $args = apply_filters( 'nav_menu_item_args', $args, $item, $depth ); $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) ); $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; $id = apply_filters( 'nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args, $depth ); $id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; $output .= $indent . ''; $atts = array(); $atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : ''; $atts['target'] = ! empty( $item->target ) ? $item->target : ''; $atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : ''; $atts['href'] = ! empty( $item->url ) ? $item->url : ''; $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ); $attributes = ''; foreach ( $atts as $attr => $value ) { if ( ! empty( $value ) ) { $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); $attributes .= ' ' . $attr . '="' . $value . '"'; } } $title = apply_filters( 'nav_menu_item_title', $item->title, $item, $args, $depth ); $title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth ); $link = $args->before; $link .= ''; $link .= $args->link_before . $title . $args->link_after; $link .= ''; $link .= $args->after; $output .= apply_filters( 'nav_menu_item_title', $link, $item, $args, $depth ); $output .= '' . $n; } } /** * Display custom logo */ function peptide_starter_the_custom_logo() { if ( function_exists( 'the_custom_logo' ) ) { the_custom_logo(); } else { $site_name = get_bloginfo( 'name' ); echo ''; } } /** * Get hero title */ function peptide_starter_get_hero_title() { return get_theme_mod( 'hero_title', get_bloginfo( 'name' ) ); } /** * Get hero subtitle */ function peptide_starter_get_hero_subtitle() { return get_theme_mod( 'hero_subtitle', esc_html__( 'A scientific peptide reference database', 'peptide-starter' ) ); } /** * Get search placeholder */ function peptide_starter_get_search_placeholder() { return get_theme_mod( 'hero_search_placeholder', esc_html__( 'Search peptides, sequences, or research...', 'peptide-starter' ) ); } /** * Get footer copyright text */ function peptide_starter_get_footer_copyright() { return get_theme_mod( 'footer_copyright', esc_html__( 'Copyright © 2026 Peptide Repo. All rights reserved.', 'peptide-starter' ) ); } /** * Apply dark mode class to body if enabled */ function peptide_starter_dark_mode_body_class( $classes ) { if ( get_theme_mod( 'dark_mode_default', false ) ) { $classes[] = 'dark-mode-default'; } return $classes; } add_filter( 'body_class', 'peptide_starter_dark_mode_body_class' ); /** * Register pagination function */ function peptide_starter_pagination() { global $wp_query; if ( $wp_query->max_num_pages <= 1 ) { return; } $current_page = max( 1, get_query_var( 'paged' ) ); $total_pages = $wp_query->max_num_pages; echo ''; } /** * Get the excerpt */ function peptide_starter_get_excerpt( $post_id = 0, $length = 20 ) { if ( ! $post_id ) { $post_id = get_the_ID(); } $excerpt = get_the_excerpt( $post_id ); if ( ! $excerpt ) { $excerpt = wp_trim_words( get_the_content( $post_id ), $length ); } return $excerpt; } /** * Check if we should show footer newsletter signup */ function peptide_starter_show_newsletter_form() { return apply_filters( 'peptide_starter_show_newsletter', true ); } /** * Enqueue inline script for dark mode toggle (output in footer) */ function peptide_starter_inline_dark_mode_script() { $default_dark = get_theme_mod( 'dark_mode_default', false ) ? 'dark' : 'light'; ?>