- 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 全面更新为门店多页面架构文档
67 lines
2.5 KiB
PHP
67 lines
2.5 KiB
PHP
<?php
|
|
/** Reusable store theme helpers. @package Fragrance_Trade */
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
function fragrance_trade_get_default( $key, $fallback = '' ) {
|
|
$defaults = fragrance_trade_defaults();
|
|
return array_key_exists( $key, $defaults ) ? $defaults[ $key ] : $fallback;
|
|
}
|
|
|
|
function fragrance_trade_get_mod( $key, $fallback = null ) {
|
|
$default = null === $fallback ? fragrance_trade_get_default( $key ) : $fallback;
|
|
return get_theme_mod( $key, $default );
|
|
}
|
|
|
|
function fragrance_trade_asset_uri( $relative_path ) {
|
|
return trailingslashit( get_template_directory_uri() ) . 'assets/' . ltrim( $relative_path, '/' );
|
|
}
|
|
|
|
function fragrance_trade_image_uri( $setting, $fallback_filename ) {
|
|
$image = fragrance_trade_get_mod( $setting, '' );
|
|
return $image ? $image : fragrance_trade_asset_uri( 'images/' . $fallback_filename );
|
|
}
|
|
|
|
function fragrance_trade_show_section( $setting ) {
|
|
return (bool) fragrance_trade_get_mod( $setting, true );
|
|
}
|
|
|
|
function fragrance_trade_whatsapp_number() {
|
|
return preg_replace( '/[^0-9]/', '', (string) fragrance_trade_get_mod( 'whatsapp', '' ) );
|
|
}
|
|
|
|
function fragrance_trade_inquiry_email() {
|
|
$email = sanitize_email( fragrance_trade_get_mod( 'inquiry_email', '' ) );
|
|
return is_email( $email ) ? $email : sanitize_email( get_option( 'admin_email' ) );
|
|
}
|
|
|
|
function fragrance_trade_get_inquiry_url( $project = '' ) {
|
|
$message = $project
|
|
? sprintf( __( '您好,我想咨询 %s 的贴膜服务。', 'fragrance-trade' ), $project )
|
|
: __( '您好,我想咨询汽车贴膜服务。', 'fragrance-trade' );
|
|
$number = fragrance_trade_whatsapp_number();
|
|
if ( $number ) {
|
|
return add_query_arg( 'text', $message, 'https://wa.me/' . $number );
|
|
}
|
|
return 'mailto:' . antispambot( fragrance_trade_inquiry_email() ) . '?subject=' . rawurlencode( __( '汽车贴膜预约咨询', 'fragrance-trade' ) ) . '&body=' . rawurlencode( $message );
|
|
}
|
|
|
|
function fragrance_trade_get_notice() {
|
|
if ( empty( $_GET['fragrance_notice'] ) ) {
|
|
return '';
|
|
}
|
|
return sanitize_key( wp_unslash( $_GET['fragrance_notice'] ) );
|
|
}
|
|
|
|
function fragrance_trade_notice_message( $code ) {
|
|
$messages = array(
|
|
'success' => __( '感谢您的提交,预约需求已发送。', 'fragrance-trade' ),
|
|
'invalid' => __( '请检查必填项后重新提交。', 'fragrance-trade' ),
|
|
'rate_limited' => __( '请稍候片刻再重新提交。', 'fragrance-trade' ),
|
|
'mail_failed' => __( '发送失败,请通过邮件或 WhatsApp 联系我们。', 'fragrance-trade' ),
|
|
);
|
|
return isset( $messages[ $code ] ) ? $messages[ $code ] : '';
|
|
}
|