103 lines
3.1 KiB
PHP
103 lines
3.1 KiB
PHP
<?php
|
|
/**
|
|
* Theme Setup - registers supports, menus, patterns, and editor styles.
|
|
*
|
|
* @package OTS_Theme
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
/* ── Theme supports ────────────────────────────────────────── */
|
|
add_action( 'after_setup_theme', function () {
|
|
|
|
// FSE / block essentials
|
|
add_theme_support( 'wp-block-styles' );
|
|
add_theme_support( 'responsive-embeds' );
|
|
add_theme_support( 'editor-styles' );
|
|
|
|
// Classic fallback supports (still respected by block themes)
|
|
add_theme_support( 'automatic-feed-links' );
|
|
add_theme_support( 'title-tag' );
|
|
add_theme_support( 'post-thumbnails' );
|
|
add_theme_support( 'custom-logo', [
|
|
'height' => 40,
|
|
'width' => 180,
|
|
'flex-height' => true,
|
|
'flex-width' => true,
|
|
] );
|
|
add_theme_support( 'html5', [
|
|
'search-form',
|
|
'comment-form',
|
|
'comment-list',
|
|
'gallery',
|
|
'caption',
|
|
'style',
|
|
'script',
|
|
] );
|
|
|
|
// Load main.css inside the block editor so previews match the frontend
|
|
add_editor_style( 'assets/css/main.css' );
|
|
|
|
// Navigation menus (used by oribi/site-header block)
|
|
register_nav_menus( [
|
|
'primary' => __( 'Primary Menu', 'ots-theme' ),
|
|
'footer' => __( 'Footer Menu', 'ots-theme' ),
|
|
] );
|
|
} );
|
|
|
|
/* ── Block pattern categories ──────────────────────────────── */
|
|
add_action( 'init', function () {
|
|
register_block_pattern_category( 'oribi-pages', [
|
|
'label' => __( 'Oribi Tech - Pages', 'ots-theme' ),
|
|
] );
|
|
register_block_pattern_category( 'oribi-sections', [
|
|
'label' => __( 'Oribi Tech - Sections', 'ots-theme' ),
|
|
] );
|
|
} );
|
|
|
|
/* ── Remove core block patterns if desired ─────────────────── */
|
|
add_action( 'after_setup_theme', function () {
|
|
remove_theme_support( 'core-block-patterns' );
|
|
} );
|
|
|
|
/* ── Nav menu filters ──────────────────────────────────────── */
|
|
/**
|
|
* Add button class to Contact menu item for styling as an orange button.
|
|
*/
|
|
add_filter( 'nav_menu_link_attributes', function ( $atts, $item, $args ) {
|
|
// Only apply to the primary menu
|
|
if ( $args->theme_location !== 'primary' ) {
|
|
return $atts;
|
|
}
|
|
|
|
// Check if this is the Contact menu item (by URL or title)
|
|
$contact_url = home_url( '/contact' );
|
|
if ( strpos( $item->url, 'contact' ) !== false || $item->title === 'Contact' ) {
|
|
// Add button classes
|
|
$atts['class'] = isset( $atts['class'] ) ? $atts['class'] . ' btn btn-primary' : 'btn btn-primary';
|
|
}
|
|
|
|
return $atts;
|
|
}, 10, 3 );
|
|
|
|
/**
|
|
* Add nav-contact class to Contact menu item's list element.
|
|
*/
|
|
add_filter( 'nav_menu_li_attributes', function ( $atts, $item, $args, $depth ) {
|
|
// Only apply to the primary menu
|
|
if ( $args->theme_location !== 'primary' ) {
|
|
return $atts;
|
|
}
|
|
|
|
// Check if this is the Contact menu item (by URL or title)
|
|
if ( strpos( $item->url, 'contact' ) !== false || $item->title === 'Contact' ) {
|
|
// Add nav-contact class
|
|
$atts['class'] = isset( $atts['class'] ) ? $atts['class'] . ' nav-contact' : 'nav-contact';
|
|
}
|
|
|
|
return $atts;
|
|
}, 10, 4 );
|
|
|