|
|
<?php
|
|
|
/**
|
|
|
* 主题自定义函数
|
|
|
*/
|
|
|
|
|
|
// 添加视频横幅自定义选项
|
|
|
function nenghui_video_banner_customizer($wp_customize) {
|
|
|
// 添加视频横幅面板
|
|
|
$wp_customize->add_panel('video_banner_panel', array(
|
|
|
'title' => '视频横幅设置',
|
|
|
'description' => '配置首页视频横幅的背景图片和视频链接',
|
|
|
'priority' => 30,
|
|
|
));
|
|
|
|
|
|
// 添加视频横幅设置部分
|
|
|
$wp_customize->add_section('video_banner_section', array(
|
|
|
'title' => '视频设置',
|
|
|
'panel' => 'video_banner_panel',
|
|
|
'priority' => 10,
|
|
|
));
|
|
|
|
|
|
// 背景图片设置
|
|
|
$wp_customize->add_setting('video_banner_bg_image', array(
|
|
|
'default' => get_template_directory_uri() . '/assets/images/video.webp',
|
|
|
'sanitize_callback' => 'esc_url_raw',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'video_banner_bg_image', array(
|
|
|
'label' => '背景图片',
|
|
|
'section' => 'video_banner_section',
|
|
|
'settings' => 'video_banner_bg_image',
|
|
|
'description' => '选择视频横幅的背景图片',
|
|
|
)));
|
|
|
|
|
|
// 容器高度设置
|
|
|
$wp_customize->add_setting('video_banner_height', array(
|
|
|
'default' => '600',
|
|
|
'sanitize_callback' => 'absint',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('video_banner_height', array(
|
|
|
'label' => '容器高度',
|
|
|
'section' => 'video_banner_section',
|
|
|
'type' => 'number',
|
|
|
'description' => '视频横幅容器的高度(像素)',
|
|
|
'input_attrs' => array(
|
|
|
'min' => 300,
|
|
|
'max' => 1000,
|
|
|
'step' => 10,
|
|
|
),
|
|
|
));
|
|
|
|
|
|
// 添加视频背景设置部分
|
|
|
$wp_customize->add_section('video_banner_background_section', array(
|
|
|
'title' => '视频背景设置',
|
|
|
'panel' => 'video_banner_panel',
|
|
|
'priority' => 20,
|
|
|
));
|
|
|
|
|
|
// 启用视频背景
|
|
|
$wp_customize->add_setting('video_banner_enable_background', array(
|
|
|
'default' => false,
|
|
|
'sanitize_callback' => 'wp_validate_boolean',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('video_banner_enable_background', array(
|
|
|
'label' => '启用视频背景',
|
|
|
'section' => 'video_banner_background_section',
|
|
|
'type' => 'checkbox',
|
|
|
'description' => '启用自动播放的视频背景功能',
|
|
|
));
|
|
|
|
|
|
// 视频背景链接设置
|
|
|
$wp_customize->add_setting('video_banner_background_url', array(
|
|
|
'default' => '',
|
|
|
'sanitize_callback' => 'esc_url_raw',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('video_banner_background_url', array(
|
|
|
'label' => '视频背景链接',
|
|
|
'section' => 'video_banner_background_section',
|
|
|
'type' => 'url',
|
|
|
'description' => '输入用作背景的视频文件URL地址(建议使用MP4格式)',
|
|
|
));
|
|
|
|
|
|
// 视频背景透明度
|
|
|
$wp_customize->add_setting('video_banner_background_opacity', array(
|
|
|
'default' => '100',
|
|
|
'sanitize_callback' => 'absint',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('video_banner_background_opacity', array(
|
|
|
'label' => '视频背景透明度',
|
|
|
'section' => 'video_banner_background_section',
|
|
|
'type' => 'range',
|
|
|
'description' => '调整视频背景的透明度(0-100)',
|
|
|
'input_attrs' => array(
|
|
|
'min' => 0,
|
|
|
'max' => 100,
|
|
|
'step' => 5,
|
|
|
),
|
|
|
));
|
|
|
|
|
|
// 启用懒加载
|
|
|
$wp_customize->add_setting('video_banner_enable_lazy_load', array(
|
|
|
'default' => true,
|
|
|
'sanitize_callback' => 'wp_validate_boolean',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('video_banner_enable_lazy_load', array(
|
|
|
'label' => '启用懒加载',
|
|
|
'section' => 'video_banner_background_section',
|
|
|
'type' => 'checkbox',
|
|
|
'description' => '启用视频懒加载以提升页面加载性能',
|
|
|
));
|
|
|
|
|
|
// 添加内容设置部分
|
|
|
$wp_customize->add_section('video_banner_content_section', array(
|
|
|
'title' => '内容设置',
|
|
|
'panel' => 'video_banner_panel',
|
|
|
'priority' => 30,
|
|
|
));
|
|
|
|
|
|
// 横幅标题
|
|
|
$wp_customize->add_setting('video_banner_content_title', array(
|
|
|
'default' => '',
|
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('video_banner_content_title', array(
|
|
|
'label' => '横幅标题',
|
|
|
'section' => 'video_banner_content_section',
|
|
|
'type' => 'text',
|
|
|
'description' => '显示在视频横幅上的主标题',
|
|
|
));
|
|
|
|
|
|
// 横幅副标题
|
|
|
$wp_customize->add_setting('video_banner_content_subtitle', array(
|
|
|
'default' => '',
|
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('video_banner_content_subtitle', array(
|
|
|
'label' => '横幅副标题',
|
|
|
'section' => 'video_banner_content_section',
|
|
|
'type' => 'text',
|
|
|
'description' => '显示在视频横幅上的副标题',
|
|
|
));
|
|
|
|
|
|
// 横幅描述
|
|
|
$wp_customize->add_setting('video_banner_content_description', array(
|
|
|
'default' => '',
|
|
|
'sanitize_callback' => 'sanitize_textarea_field',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('video_banner_content_description', array(
|
|
|
'label' => '横幅描述',
|
|
|
'section' => 'video_banner_content_section',
|
|
|
'type' => 'textarea',
|
|
|
'description' => '显示在视频横幅上的描述文字',
|
|
|
));
|
|
|
}
|
|
|
add_action('customize_register', 'nenghui_video_banner_customizer');
|
|
|
|
|
|
// 添加归档页模板自定义选项
|
|
|
function nenghui_archive_template_customizer($wp_customize) {
|
|
|
// 添加归档页模板面板
|
|
|
$wp_customize->add_panel('archive_template_panel', array(
|
|
|
'title' => '归档页模板设置',
|
|
|
'description' => '配置归档页面的显示模板',
|
|
|
'priority' => 40,
|
|
|
));
|
|
|
|
|
|
// 添加归档页模板设置部分
|
|
|
$wp_customize->add_section('archive_template_section', array(
|
|
|
'title' => '模板选择',
|
|
|
'panel' => 'archive_template_panel',
|
|
|
'priority' => 10,
|
|
|
));
|
|
|
|
|
|
// 获取所有已发布的页面
|
|
|
$pages = get_pages(array(
|
|
|
'post_status' => 'publish',
|
|
|
'number' => 100,
|
|
|
));
|
|
|
|
|
|
$page_choices = array(
|
|
|
'' => '使用默认归档模板',
|
|
|
);
|
|
|
|
|
|
foreach ($pages as $page) {
|
|
|
$page_choices[$page->ID] = $page->post_title;
|
|
|
}
|
|
|
|
|
|
// 归档页模板选择设置
|
|
|
$wp_customize->add_setting('archive_template_page', array(
|
|
|
'default' => '',
|
|
|
'sanitize_callback' => 'absint',
|
|
|
'transport' => 'refresh',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('archive_template_page', array(
|
|
|
'label' => '选择归档页模板',
|
|
|
'section' => 'archive_template_section',
|
|
|
'type' => 'select',
|
|
|
'choices' => $page_choices,
|
|
|
'description' => '选择一个页面作为归档页面的模板,留空则使用默认归档模板',
|
|
|
));
|
|
|
|
|
|
// 是否显示归档标题
|
|
|
$wp_customize->add_setting('archive_show_title', array(
|
|
|
'default' => true,
|
|
|
'sanitize_callback' => 'wp_validate_boolean',
|
|
|
'transport' => 'refresh',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('archive_show_title', array(
|
|
|
'label' => '显示归档标题',
|
|
|
'section' => 'archive_template_section',
|
|
|
'type' => 'checkbox',
|
|
|
'description' => '是否在归档页面显示归档标题',
|
|
|
));
|
|
|
|
|
|
// 是否显示归档描述
|
|
|
$wp_customize->add_setting('archive_show_description', array(
|
|
|
'default' => true,
|
|
|
'sanitize_callback' => 'wp_validate_boolean',
|
|
|
'transport' => 'refresh',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('archive_show_description', array(
|
|
|
'label' => '显示归档描述',
|
|
|
'section' => 'archive_template_section',
|
|
|
'type' => 'checkbox',
|
|
|
'description' => '是否在归档页面显示归档描述',
|
|
|
));
|
|
|
}
|
|
|
add_action('customize_register', 'nenghui_archive_template_customizer');
|
|
|
|
|
|
|
|
|
|
|
|
// 添加证书轮播自定义选项
|
|
|
function nenghui_certificates_carousel_customizer($wp_customize) {
|
|
|
// 添加证书轮播面板
|
|
|
$wp_customize->add_panel('certificates_carousel_panel', array(
|
|
|
'title' => '证书轮播设置',
|
|
|
'description' => '配置证书轮播图的显示选项',
|
|
|
'priority' => 60,
|
|
|
));
|
|
|
|
|
|
// 添加基础设置部分
|
|
|
$wp_customize->add_section('certificates_carousel_basic_section', array(
|
|
|
'title' => '基础设置',
|
|
|
'panel' => 'certificates_carousel_panel',
|
|
|
'priority' => 10,
|
|
|
));
|
|
|
|
|
|
// 是否显示证书轮播
|
|
|
$wp_customize->add_setting('certificates_carousel_show', array(
|
|
|
'default' => true,
|
|
|
'sanitize_callback' => 'wp_validate_boolean',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('certificates_carousel_show', array(
|
|
|
'label' => '显示证书轮播',
|
|
|
'section' => 'certificates_carousel_basic_section',
|
|
|
'type' => 'checkbox',
|
|
|
'description' => '是否在页面中显示证书轮播区块',
|
|
|
));
|
|
|
|
|
|
// 轮播标题设置
|
|
|
$wp_customize->add_setting('certificates_carousel_title', array(
|
|
|
'default' => '国际奖项证书',
|
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('certificates_carousel_title', array(
|
|
|
'label' => '轮播标题',
|
|
|
'section' => 'certificates_carousel_basic_section',
|
|
|
'type' => 'text',
|
|
|
'description' => '证书轮播区块的主标题',
|
|
|
));
|
|
|
|
|
|
// 轮播副标题设置
|
|
|
$wp_customize->add_setting('certificates_carousel_subtitle', array(
|
|
|
'default' => '我们获得的荣誉与认证',
|
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('certificates_carousel_subtitle', array(
|
|
|
'label' => '轮播副标题',
|
|
|
'section' => 'certificates_carousel_basic_section',
|
|
|
'type' => 'text',
|
|
|
'description' => '证书轮播区块的副标题',
|
|
|
));
|
|
|
|
|
|
// 自动轮播设置
|
|
|
$wp_customize->add_setting('certificates_carousel_autoplay', array(
|
|
|
'default' => true,
|
|
|
'sanitize_callback' => 'wp_validate_boolean',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('certificates_carousel_autoplay', array(
|
|
|
'label' => '自动轮播',
|
|
|
'section' => 'certificates_carousel_basic_section',
|
|
|
'type' => 'checkbox',
|
|
|
'description' => '是否启用自动轮播功能',
|
|
|
));
|
|
|
|
|
|
// 轮播间隔设置
|
|
|
$wp_customize->add_setting('certificates_carousel_delay', array(
|
|
|
'default' => 5000,
|
|
|
'sanitize_callback' => 'absint',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('certificates_carousel_delay', array(
|
|
|
'label' => '轮播间隔(毫秒)',
|
|
|
'section' => 'certificates_carousel_basic_section',
|
|
|
'type' => 'number',
|
|
|
'description' => '自动轮播的时间间隔',
|
|
|
'input_attrs' => array(
|
|
|
'min' => 2000,
|
|
|
'max' => 10000,
|
|
|
'step' => 500,
|
|
|
),
|
|
|
));
|
|
|
|
|
|
// 添加图片设置部分
|
|
|
$wp_customize->add_section('certificates_carousel_images_section', array(
|
|
|
'title' => '图片设置',
|
|
|
'panel' => 'certificates_carousel_panel',
|
|
|
'priority' => 20,
|
|
|
));
|
|
|
|
|
|
// 图片来源选择
|
|
|
$wp_customize->add_setting('certificates_carousel_source', array(
|
|
|
'default' => 'folder',
|
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
|
'transport' => 'refresh',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('certificates_carousel_source', array(
|
|
|
'label' => '图片来源',
|
|
|
'section' => 'certificates_carousel_images_section',
|
|
|
'type' => 'select',
|
|
|
'choices' => array(
|
|
|
'folder' => '使用文件夹中的图片',
|
|
|
'gallery' => '使用自定义图片库',
|
|
|
),
|
|
|
'description' => '选择证书图片的来源方式',
|
|
|
));
|
|
|
|
|
|
// 自定义图片库设置(多图上传)
|
|
|
$wp_customize->add_setting('certificates_carousel_gallery', array(
|
|
|
'default' => '',
|
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
|
'transport' => 'refresh',
|
|
|
));
|
|
|
|
|
|
// 使用自定义控件来支持多图上传
|
|
|
$wp_customize->add_control(new WP_Customize_Media_Control($wp_customize, 'certificates_carousel_gallery', array(
|
|
|
'label' => '自定义证书图片',
|
|
|
'section' => 'certificates_carousel_images_section',
|
|
|
'mime_type' => 'image',
|
|
|
'description' => '上传自定义的证书图片(支持多选)',
|
|
|
)));
|
|
|
}
|
|
|
add_action('customize_register', 'nenghui_certificates_carousel_customizer');
|
|
|
|
|
|
// 获取视频横幅配置的辅助函数
|
|
|
function get_video_banner_bg_image() {
|
|
|
return get_theme_mod('video_banner_bg_image', get_template_directory_uri() . '/assets/images/video.webp');
|
|
|
}
|
|
|
|
|
|
function get_video_banner_height() {
|
|
|
return get_theme_mod('video_banner_height', 600);
|
|
|
}
|
|
|
|
|
|
function get_video_banner_enable_background() {
|
|
|
return get_theme_mod('video_banner_enable_background', false);
|
|
|
}
|
|
|
|
|
|
function get_video_banner_background_url() {
|
|
|
return get_theme_mod('video_banner_background_url', '');
|
|
|
}
|
|
|
|
|
|
function get_video_banner_background_opacity() {
|
|
|
return get_theme_mod('video_banner_background_opacity', 100);
|
|
|
}
|
|
|
|
|
|
function get_video_banner_enable_lazy_load() {
|
|
|
return get_theme_mod('video_banner_enable_lazy_load', true);
|
|
|
}
|
|
|
|
|
|
function get_video_banner_content_title() {
|
|
|
return get_theme_mod('video_banner_content_title', '');
|
|
|
}
|
|
|
|
|
|
function get_video_banner_content_subtitle() {
|
|
|
return get_theme_mod('video_banner_content_subtitle', '');
|
|
|
}
|
|
|
|
|
|
function get_video_banner_content_description() {
|
|
|
return get_theme_mod('video_banner_content_description', '');
|
|
|
}
|
|
|
|
|
|
// 获取归档页模板配置的辅助函数
|
|
|
function get_archive_template_page() {
|
|
|
return get_theme_mod('archive_template_page', '');
|
|
|
}
|
|
|
|
|
|
function get_archive_show_title() {
|
|
|
return get_theme_mod('archive_show_title', true);
|
|
|
}
|
|
|
|
|
|
function get_archive_show_description() {
|
|
|
return get_theme_mod('archive_show_description', true);
|
|
|
}
|
|
|
|
|
|
// 检查是否使用自定义归档页模板
|
|
|
function is_using_custom_archive_template() {
|
|
|
$template_page_id = get_archive_template_page();
|
|
|
return !empty($template_page_id) && get_post_status($template_page_id) === 'publish';
|
|
|
}
|
|
|
|
|
|
// 获取自定义归档页模板内容
|
|
|
function get_custom_archive_template_content() {
|
|
|
$template_page_id = get_archive_template_page();
|
|
|
if (empty($template_page_id)) {
|
|
|
return '';
|
|
|
}
|
|
|
|
|
|
$page = get_post($template_page_id);
|
|
|
if (!$page || $page->post_status !== 'publish') {
|
|
|
return '';
|
|
|
}
|
|
|
|
|
|
return apply_filters('the_content', $page->post_content);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取证书轮播配置的辅助函数
|
|
|
function get_certificates_carousel_show() {
|
|
|
return get_theme_mod('certificates_carousel_show', true);
|
|
|
}
|
|
|
|
|
|
function get_certificates_carousel_title() {
|
|
|
return get_theme_mod('certificates_carousel_title', '国际奖项证书');
|
|
|
}
|
|
|
|
|
|
function get_certificates_carousel_subtitle() {
|
|
|
return get_theme_mod('certificates_carousel_subtitle', '我们获得的荣誉与认证');
|
|
|
}
|
|
|
|
|
|
function get_certificates_carousel_autoplay() {
|
|
|
return get_theme_mod('certificates_carousel_autoplay', true);
|
|
|
}
|
|
|
|
|
|
function get_certificates_carousel_delay() {
|
|
|
return get_theme_mod('certificates_carousel_delay', 5000);
|
|
|
}
|
|
|
|
|
|
function get_certificates_carousel_source() {
|
|
|
return get_theme_mod('certificates_carousel_source', 'folder');
|
|
|
}
|
|
|
|
|
|
function get_certificates_carousel_gallery() {
|
|
|
return get_theme_mod('certificates_carousel_gallery', '');
|
|
|
}
|
|
|
|
|
|
// 获取证书图片数据
|
|
|
function get_certificates_carousel_images() {
|
|
|
$source = get_certificates_carousel_source();
|
|
|
$images = [];
|
|
|
|
|
|
if ($source === 'gallery') {
|
|
|
// 从自定义图片库获取
|
|
|
$gallery_ids = get_certificates_carousel_gallery();
|
|
|
if (!empty($gallery_ids)) {
|
|
|
$ids = explode(',', $gallery_ids);
|
|
|
foreach ($ids as $id) {
|
|
|
$id = intval(trim($id));
|
|
|
if ($id > 0) {
|
|
|
$image_url = wp_get_attachment_image_url($id, 'large');
|
|
|
$image_title = get_the_title($id);
|
|
|
$image_alt = get_post_meta($id, '_wp_attachment_image_alt', true);
|
|
|
|
|
|
if ($image_url) {
|
|
|
$images[] = [
|
|
|
'url' => $image_url,
|
|
|
'title' => $image_title ?: '证书',
|
|
|
'alt' => $image_alt ?: '证书图片',
|
|
|
'description' => get_post_field('post_content', $id) ?: '公司获得的重要认证证书'
|
|
|
];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
// 从文件夹获取图片
|
|
|
$certificates_dir = get_template_directory() . '/assets/images/certificates/';
|
|
|
$certificates_url = get_template_directory_uri() . '/assets/images/certificates/';
|
|
|
|
|
|
if (is_dir($certificates_dir)) {
|
|
|
$files = scandir($certificates_dir);
|
|
|
$image_extensions = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
|
|
|
|
|
|
foreach ($files as $file) {
|
|
|
if ($file === '.' || $file === '..') continue;
|
|
|
|
|
|
$file_extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
|
|
|
if (in_array($file_extension, $image_extensions)) {
|
|
|
$file_name = pathinfo($file, PATHINFO_FILENAME);
|
|
|
$images[] = [
|
|
|
'url' => $certificates_url . $file,
|
|
|
'title' => str_replace(['Certificate-', '-', '_'], ['证书 ', ' ', ' '], $file_name),
|
|
|
'alt' => '证书图片 - ' . $file_name,
|
|
|
'description' => '公司获得的重要认证证书'
|
|
|
];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 按文件名排序
|
|
|
usort($images, function($a, $b) {
|
|
|
return strnatcmp($a['url'], $b['url']);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return $images;
|
|
|
}
|
|
|
|
|
|
// 添加业务流程设计区块自定义选项
|
|
|
function nenghui_business_process_customizer($wp_customize) {
|
|
|
// 添加业务流程面板
|
|
|
$wp_customize->add_panel('business_process_panel', array(
|
|
|
'title' => '业务流程设计',
|
|
|
'description' => '配置业务流程设计区块的显示选项和内容',
|
|
|
'priority' => 70,
|
|
|
));
|
|
|
|
|
|
// 添加基础设置部分
|
|
|
$wp_customize->add_section('business_process_basic_section', array(
|
|
|
'title' => '基础设置',
|
|
|
'panel' => 'business_process_panel',
|
|
|
'priority' => 10,
|
|
|
));
|
|
|
|
|
|
// 是否显示业务流程区块
|
|
|
$wp_customize->add_setting('business_process_show', array(
|
|
|
'default' => true,
|
|
|
'sanitize_callback' => 'wp_validate_boolean',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('business_process_show', array(
|
|
|
'label' => '显示业务流程区块',
|
|
|
'section' => 'business_process_basic_section',
|
|
|
'type' => 'checkbox',
|
|
|
'description' => '是否在页面中显示业务流程设计区块',
|
|
|
));
|
|
|
|
|
|
// 区块标题设置
|
|
|
$wp_customize->add_setting('business_process_title', array(
|
|
|
'default' => '设计业务流程',
|
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('business_process_title', array(
|
|
|
'label' => '区块标题',
|
|
|
'section' => 'business_process_basic_section',
|
|
|
'type' => 'text',
|
|
|
'description' => '业务流程设计区块的主标题',
|
|
|
));
|
|
|
|
|
|
// 区块副标题设置
|
|
|
$wp_customize->add_setting('business_process_subtitle', array(
|
|
|
'default' => '专业的设计流程,确保项目高质量完成',
|
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('business_process_subtitle', array(
|
|
|
'label' => '区块副标题',
|
|
|
'section' => 'business_process_basic_section',
|
|
|
'type' => 'text',
|
|
|
'description' => '业务流程设计区块的副标题',
|
|
|
));
|
|
|
|
|
|
// Tab 01 设置部分
|
|
|
$wp_customize->add_section('business_process_tab1_section', array(
|
|
|
'title' => 'Tab 01 - 可行性研究',
|
|
|
'panel' => 'business_process_panel',
|
|
|
'priority' => 20,
|
|
|
));
|
|
|
|
|
|
// Tab 01 标题
|
|
|
$wp_customize->add_setting('business_process_tab1_title', array(
|
|
|
'default' => '可行性研究',
|
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('business_process_tab1_title', array(
|
|
|
'label' => 'Tab 01 标题',
|
|
|
'section' => 'business_process_tab1_section',
|
|
|
'type' => 'text',
|
|
|
));
|
|
|
|
|
|
// Tab 01 描述
|
|
|
$wp_customize->add_setting('business_process_tab1_description', array(
|
|
|
'default' => '前期调研并综合考虑"可行性、经济性、安全性"三个方面,多方案比较,确定最优设计方案和实施策略。',
|
|
|
'sanitize_callback' => 'sanitize_textarea_field',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('business_process_tab1_description', array(
|
|
|
'label' => 'Tab 01 描述',
|
|
|
'section' => 'business_process_tab1_section',
|
|
|
'type' => 'textarea',
|
|
|
));
|
|
|
|
|
|
// Tab 01 图片
|
|
|
$wp_customize->add_setting('business_process_tab1_image', array(
|
|
|
'default' => get_template_directory_uri() . '/assets/images/FWas.jpg',
|
|
|
'sanitize_callback' => 'esc_url_raw',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'business_process_tab1_image', array(
|
|
|
'label' => 'Tab 01 图片',
|
|
|
'section' => 'business_process_tab1_section',
|
|
|
'settings' => 'business_process_tab1_image',
|
|
|
'description' => '选择Tab 01对应的图片',
|
|
|
)));
|
|
|
|
|
|
// Tab 02 设置部分
|
|
|
$wp_customize->add_section('business_process_tab2_section', array(
|
|
|
'title' => 'Tab 02 - 初步设计',
|
|
|
'panel' => 'business_process_panel',
|
|
|
'priority' => 30,
|
|
|
));
|
|
|
|
|
|
// Tab 02 标题
|
|
|
$wp_customize->add_setting('business_process_tab2_title', array(
|
|
|
'default' => '初步设计',
|
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('business_process_tab2_title', array(
|
|
|
'label' => 'Tab 02 标题',
|
|
|
'section' => 'business_process_tab2_section',
|
|
|
'type' => 'text',
|
|
|
));
|
|
|
|
|
|
// Tab 02 描述
|
|
|
$wp_customize->add_setting('business_process_tab2_description', array(
|
|
|
'default' => '在基本方案确定的基础上,进行"精细设计",确定主要设备的选型和布置,形成初步设计方案。',
|
|
|
'sanitize_callback' => 'sanitize_textarea_field',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('business_process_tab2_description', array(
|
|
|
'label' => 'Tab 02 描述',
|
|
|
'section' => 'business_process_tab2_section',
|
|
|
'type' => 'textarea',
|
|
|
));
|
|
|
|
|
|
// Tab 02 图片
|
|
|
$wp_customize->add_setting('business_process_tab2_image', array(
|
|
|
'default' => get_template_directory_uri() . '/assets/images/FWas.jpg',
|
|
|
'sanitize_callback' => 'esc_url_raw',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'business_process_tab2_image', array(
|
|
|
'label' => 'Tab 02 图片',
|
|
|
'section' => 'business_process_tab2_section',
|
|
|
'settings' => 'business_process_tab2_image',
|
|
|
'description' => '选择Tab 02对应的图片',
|
|
|
)));
|
|
|
|
|
|
// Tab 03 设置部分
|
|
|
$wp_customize->add_section('business_process_tab3_section', array(
|
|
|
'title' => 'Tab 03 - 施工图设计',
|
|
|
'panel' => 'business_process_panel',
|
|
|
'priority' => 40,
|
|
|
));
|
|
|
|
|
|
// Tab 03 标题
|
|
|
$wp_customize->add_setting('business_process_tab3_title', array(
|
|
|
'default' => '施工图设计',
|
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('business_process_tab3_title', array(
|
|
|
'label' => 'Tab 03 标题',
|
|
|
'section' => 'business_process_tab3_section',
|
|
|
'type' => 'text',
|
|
|
));
|
|
|
|
|
|
// Tab 03 描述
|
|
|
$wp_customize->add_setting('business_process_tab3_description', array(
|
|
|
'default' => '基于初步设计方案,进行详细的施工图设计,确保设计方案的可实施性和工程质量。',
|
|
|
'sanitize_callback' => 'sanitize_textarea_field',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('business_process_tab3_description', array(
|
|
|
'label' => 'Tab 03 描述',
|
|
|
'section' => 'business_process_tab3_section',
|
|
|
'type' => 'textarea',
|
|
|
));
|
|
|
|
|
|
// Tab 03 图片
|
|
|
$wp_customize->add_setting('business_process_tab3_image', array(
|
|
|
'default' => get_template_directory_uri() . '/assets/images/FWas.jpg',
|
|
|
'sanitize_callback' => 'esc_url_raw',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'business_process_tab3_image', array(
|
|
|
'label' => 'Tab 03 图片',
|
|
|
'section' => 'business_process_tab3_section',
|
|
|
'settings' => 'business_process_tab3_image',
|
|
|
'description' => '选择Tab 03对应的图片',
|
|
|
)));
|
|
|
|
|
|
// Tab 04 设置部分
|
|
|
$wp_customize->add_section('business_process_tab4_section', array(
|
|
|
'title' => 'Tab 04 - 竣工图设计',
|
|
|
'panel' => 'business_process_panel',
|
|
|
'priority' => 50,
|
|
|
));
|
|
|
|
|
|
// Tab 04 标题
|
|
|
$wp_customize->add_setting('business_process_tab4_title', array(
|
|
|
'default' => '竣工图设计',
|
|
|
'sanitize_callback' => 'sanitize_text_field',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('business_process_tab4_title', array(
|
|
|
'label' => 'Tab 04 标题',
|
|
|
'section' => 'business_process_tab4_section',
|
|
|
'type' => 'text',
|
|
|
));
|
|
|
|
|
|
// Tab 04 描述
|
|
|
$wp_customize->add_setting('business_process_tab4_description', array(
|
|
|
'default' => '项目完工后的竣工图设计,真实反映工程实际建设情况,为后续运维提供准确的技术资料。',
|
|
|
'sanitize_callback' => 'sanitize_textarea_field',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control('business_process_tab4_description', array(
|
|
|
'label' => 'Tab 04 描述',
|
|
|
'section' => 'business_process_tab4_section',
|
|
|
'type' => 'textarea',
|
|
|
));
|
|
|
|
|
|
// Tab 04 图片
|
|
|
$wp_customize->add_setting('business_process_tab4_image', array(
|
|
|
'default' => get_template_directory_uri() . '/assets/images/FWas.jpg',
|
|
|
'sanitize_callback' => 'esc_url_raw',
|
|
|
'transport' => 'postMessage',
|
|
|
));
|
|
|
|
|
|
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'business_process_tab4_image', array(
|
|
|
'label' => 'Tab 04 图片',
|
|
|
'section' => 'business_process_tab4_section',
|
|
|
'settings' => 'business_process_tab4_image',
|
|
|
'description' => '选择Tab 04对应的图片',
|
|
|
)));
|
|
|
}
|
|
|
|
|
|
// 获取业务流程配置的辅助函数
|
|
|
function get_business_process_show() {
|
|
|
return get_theme_mod('business_process_show', true);
|
|
|
}
|
|
|
|
|
|
function get_business_process_title() {
|
|
|
return get_theme_mod('business_process_title', '设计业务流程');
|
|
|
}
|
|
|
|
|
|
function get_business_process_subtitle() {
|
|
|
return get_theme_mod('business_process_subtitle', '专业的设计流程,确保项目高质量完成');
|
|
|
}
|
|
|
|
|
|
function get_business_process_tab_data($tab_number) {
|
|
|
$defaults = array(
|
|
|
1 => array(
|
|
|
'title' => '可行性研究',
|
|
|
'description' => '前期调研并综合考虑"可行性、经济性、安全性"三个方面,多方案比较,确定最优设计方案和实施策略。',
|
|
|
'image' => get_template_directory_uri() . '/assets/images/FWas.jpg'
|
|
|
),
|
|
|
2 => array(
|
|
|
'title' => '初步设计',
|
|
|
'description' => '在基本方案确定的基础上,进行"精细设计",确定主要设备的选型和布置,形成初步设计方案。',
|
|
|
'image' => get_template_directory_uri() . '/assets/images/FWas.jpg'
|
|
|
),
|
|
|
3 => array(
|
|
|
'title' => '施工图设计',
|
|
|
'description' => '基于初步设计方案,进行详细的施工图设计,确保设计方案的可实施性和工程质量。',
|
|
|
'image' => get_template_directory_uri() . '/assets/images/FWas.jpg'
|
|
|
),
|
|
|
4 => array(
|
|
|
'title' => '竣工图设计',
|
|
|
'description' => '项目完工后的竣工图设计,真实反映工程实际建设情况,为后续运维提供准确的技术资料。',
|
|
|
'image' => get_template_directory_uri() . '/assets/images/FWas.jpg'
|
|
|
)
|
|
|
);
|
|
|
|
|
|
if (!isset($defaults[$tab_number])) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
return array(
|
|
|
'title' => get_theme_mod("business_process_tab{$tab_number}_title", $defaults[$tab_number]['title']),
|
|
|
'description' => get_theme_mod("business_process_tab{$tab_number}_description", $defaults[$tab_number]['description']),
|
|
|
'image' => get_theme_mod("business_process_tab{$tab_number}_image", $defaults[$tab_number]['image'])
|
|
|
);
|
|
|
}
|
|
|
|
|
|
// 注册自定义器钩子
|
|
|
add_action('customize_register', 'nenghui_video_banner_customizer');
|
|
|
add_action('customize_register', 'nenghui_certificates_carousel_customizer');
|
|
|
add_action('customize_register', 'nenghui_business_process_customizer');
|
|
|
|
|
|
|
|
|
?>
|