- CPT: service(服务项目) + case(案例作品集) + case_type 分类 - 页面: 关于门店/常见问题/预约联系 + archive/single 模板 - 首页精简为 hero+trust+service-teaser+case-teaser+cta - 主题激活自动迁移 Customizer 产品数据为 service 文章 - 预约表单: nonce+honeypot+rate-limit, URL 参数预填服务 - 联系页: 门店地址/电话/营业时间/百度地图导航 - Customizer 面板改为门店语境(13 板块) - header CTA 改为预约, helpers 更新为门店口径 - README.md 全面更新为门店多页面架构文档
66 lines
3.3 KiB
PHP
66 lines
3.3 KiB
PHP
<?php
|
|
/**
|
|
* Theme setup and frontend assets.
|
|
*
|
|
* @package Fragrance_Trade
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
/** Register theme features and menus. */
|
|
function fragrance_trade_setup() {
|
|
load_theme_textdomain( 'fragrance-trade', get_template_directory() . '/languages' );
|
|
add_theme_support( 'title-tag' );
|
|
add_theme_support( 'custom-logo', array( 'height' => 96, 'width' => 260, 'flex-height' => true, 'flex-width' => true ) );
|
|
add_theme_support( 'post-thumbnails' );
|
|
add_theme_support( 'automatic-feed-links' );
|
|
add_theme_support( 'responsive-embeds' );
|
|
add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption', 'style', 'script' ) );
|
|
add_image_size( 'fragrance-capability', 760, 720, true );
|
|
|
|
register_nav_menus(
|
|
array(
|
|
'primary' => __( '主导航', 'fragrance-trade' ),
|
|
)
|
|
);
|
|
}
|
|
add_action( 'after_setup_theme', 'fragrance_trade_setup' );
|
|
|
|
/**
|
|
* Return a cache-busting version for a local theme asset.
|
|
*
|
|
* @param string $relative_path Path relative to the theme root.
|
|
* @param string $fallback Version used when the file cannot be read.
|
|
* @return string
|
|
*/
|
|
function fragrance_trade_asset_version( $relative_path, $fallback ) {
|
|
$file = get_theme_file_path( '/' . ltrim( $relative_path, '/' ) );
|
|
return file_exists( $file ) ? (string) filemtime( $file ) : $fallback;
|
|
}
|
|
|
|
/** Load theme styles and scripts through the WordPress dependency system. */
|
|
function fragrance_trade_enqueue_assets() {
|
|
$version = wp_get_theme()->get( 'Version' );
|
|
|
|
wp_enqueue_style( 'fragrance-bootstrap', 'https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0-alpha3/css/bootstrap.min.css', array(), '5.3.0-alpha3' );
|
|
wp_enqueue_style( 'fragrance-fonts', 'https://fonts.loli.net/css2?family=Josefin+Sans:wght@200;300;400;500;600;700&family=Jost:wght@200;300;400;500&family=Noto+Sans+SC:wght@300;400;500;700&display=swap', array(), null );
|
|
wp_enqueue_style( 'fragrance-normalize', get_template_directory_uri() . '/assets/css/normalize.css', array(), fragrance_trade_asset_version( 'assets/css/normalize.css', $version ) );
|
|
wp_enqueue_style( 'fragrance-vendor', get_template_directory_uri() . '/assets/css/vendor.css', array(), fragrance_trade_asset_version( 'assets/css/vendor.css', $version ) );
|
|
wp_enqueue_style( 'fragrance-base', get_stylesheet_uri(), array( 'fragrance-bootstrap', 'fragrance-vendor' ), fragrance_trade_asset_version( 'style.css', $version ) );
|
|
wp_enqueue_style( 'fragrance-theme', get_template_directory_uri() . '/assets/css/theme.css', array( 'fragrance-base' ), fragrance_trade_asset_version( 'assets/css/theme.css', $version ) );
|
|
|
|
wp_enqueue_script( 'fragrance-bootstrap', 'https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0-alpha3/js/bootstrap.bundle.min.js', array(), '5.3.0-alpha3', true );
|
|
wp_enqueue_script( 'fragrance-plugins', get_template_directory_uri() . '/assets/js/plugins.js', array( 'jquery' ), fragrance_trade_asset_version( 'assets/js/plugins.js', $version ), true );
|
|
wp_enqueue_script( 'fragrance-theme', get_template_directory_uri() . '/assets/js/theme.js', array( 'jquery', 'fragrance-bootstrap', 'fragrance-plugins' ), fragrance_trade_asset_version( 'assets/js/theme.js', $version ), true );
|
|
wp_localize_script(
|
|
'fragrance-theme',
|
|
'fragranceTrade',
|
|
array(
|
|
'motionQuery' => '(prefers-reduced-motion: reduce)',
|
|
)
|
|
);
|
|
}
|
|
add_action( 'wp_enqueue_scripts', 'fragrance_trade_enqueue_assets' );
|