add_section( 'airtheme_support_section', [
'title' => __( 'AirTheme Support', 'airtheme' ),
'priority' => 1,
'description' => __( 'Access tutorials, community chat, showcase and documentation.', 'airtheme' )
] );
// === Fake Setting (required to render control) ===
$wp_customize->add_setting( 'airtheme_support_dummy', [
'sanitize_callback' => 'sanitize_text_field',
] );
// === Simple Button Control (HTML output) ===
$wp_customize->add_control(
new WP_Customize_Control(
$wp_customize,
'airtheme_support_button',
[
'section' => 'airtheme_support_section',
'settings' => 'airtheme_support_dummy',
'type' => 'hidden', // prevents text input
'description' => '
Join AirTheme Community 🚀
'
]
)
);
}
add_action( 'customize_register', 'airtheme_customize_register_support' );
add_action('customize_register', function($wp_customize) {
// === Section: Site Background ===
$wp_customize->add_section('airtheme_background', [
'title' => __('Site Background', 'airtheme'),
'priority' => 30,
]);
// === Background Image ===
$wp_customize->add_setting('airtheme_bg_image', [
'default' => '',
'sanitize_callback' => 'esc_url_raw',
]);
$wp_customize->add_control(new WP_Customize_Image_Control(
$wp_customize,
'airtheme_bg_image',
[
'label' => __('Background Image', 'airtheme'),
'section' => 'airtheme_background',
'settings' => 'airtheme_bg_image',
]
));
// === Background Color ===
$wp_customize->add_setting('airtheme_bg_color', [
'default' => '#ffffff',
'transport' => 'refresh',
'sanitize_callback' => 'sanitize_hex_color',
]);
$wp_customize->add_control(new WP_Customize_Color_Control(
$wp_customize,
'airtheme_bg_color',
[
'label' => __('Background Color', 'airtheme'),
'section' => 'airtheme_background',
'settings' => 'airtheme_bg_color',
]
));
// === White Overlay Opacity ===
$wp_customize->add_setting('airtheme_overlay_opacity', [
'default' => 0.3,
'sanitize_callback' => 'airtheme_sanitize_opacity',
]);
$wp_customize->add_control('airtheme_overlay_opacity', [
'label' => __('White Overlay Opacity (0–1)', 'airtheme'),
'section' => 'airtheme_background',
'type' => 'number',
'input_attrs' => [
'step' => '0.05',
'min' => '0',
'max' => '1',
],
]);
});
/**
* Sanitizes opacity value (0–1).
*/
function airtheme_sanitize_opacity( $value, $setting = null ) {
$value = floatval( $value );
// enforce strict range: 0–1
if ( $value < 0 ) {
$value = 0;
}
if ( $value > 1 ) {
$value = 1;
}
return $value;
}
/**
* Outputs background image and white overlay layer.
*/
add_action( 'wp_enqueue_scripts', 'airtheme_output_background_styles' );
function airtheme_output_background_styles() {
$bg = get_theme_mod( 'airtheme_bg_image' );
$opacity = get_theme_mod( 'airtheme_overlay_opacity', 0.3 );
if ( ! $bg ) {
return;
}
// Санитизация
$bg = esc_url_raw( $bg );
$opacity = min( 1, max( 0, floatval( $opacity ) ) );
$css = "
body {
background: url('{$bg}') center/cover no-repeat fixed;
}
body::before {
content: '';
position: fixed;
inset: 0;
background: rgba(255, 255, 255, {$opacity});
z-index: 1;
}
main, header, footer {
position: relative;
z-index: 2;
}
";
wp_add_inline_style( 'airtheme-style', $css );
}
/**
* === Single Post: Related Posts ===
*/
add_action('customize_register', function($wp_customize) {
$wp_customize->add_section('airtheme_single_related', [
'title' => __('Single Post: Related Posts', 'airtheme'),
'priority' => 45,
]);
$wp_customize->add_setting('airtheme_related_posts_enable', [
'default' => true,
'sanitize_callback' => 'wp_validate_boolean',
]);
$wp_customize->add_control('airtheme_related_posts_enable', [
'label' => __('Show related posts block', 'airtheme'),
'section' => 'airtheme_single_related',
'type' => 'checkbox',
]);
});
// === Footer Section (single unified block) ===
add_action('customize_register', function($wp_customize) {
// Create section
$wp_customize->add_section('airtheme_footer', [
'title' => __('Footer Area', 'airtheme'),
'priority' => 40,
]);
// Footer background color
$wp_customize->add_setting('footer_bg_color', [
'default' => '#000000',
'sanitize_callback' => 'sanitize_hex_color',
]);
$wp_customize->add_control(new WP_Customize_Color_Control(
$wp_customize,
'footer_bg_color',
[
'label' => __('Footer Background Color', 'airtheme'),
'section' => 'airtheme_footer',
'settings' => 'footer_bg_color',
]
));
// === Three footer content blocks ===
for ( $i = 1; $i <= 3; $i++ ) {
// Footer block title
$wp_customize->add_setting("footer_title_$i", [
'default' => '',
'sanitize_callback' => 'sanitize_text_field',
]);
$wp_customize->add_control("footer_title_$i", [
'label' => sprintf( __('Footer Block Title %d', 'airtheme'), $i ),
'section' => 'airtheme_footer',
'type' => 'text',
'description' => __('Leave empty to hide the title.', 'airtheme'),
]);
// Footer block content (HTML allowed)
$wp_customize->add_setting("footer_block_$i", [
'default' => '',
'sanitize_callback' => 'wp_kses_post',
]);
$wp_customize->add_control("footer_block_$i", [
'label' => sprintf( __('Footer Block Content %d (HTML)', 'airtheme'), $i ),
'section' => 'airtheme_footer',
'type' => 'textarea',
'description' => __(
'You may use basic HTML, for example:
Company Name
Address or contact info
Privacy Policy', 'airtheme' ), ]); } // === Footer block title color === $wp_customize->add_setting('footer_title_color', [ 'default' => '#7db7ff', 'sanitize_callback' => 'sanitize_hex_color', ]); $wp_customize->add_control(new WP_Customize_Color_Control( $wp_customize, 'footer_title_color', [ 'label' => __('Footer Block Title Color', 'airtheme'), 'section' => 'airtheme_footer', 'settings' => 'footer_title_color', ] )); // === Copyright text === $default_domain = isset($_SERVER['HTTP_HOST']) ? preg_replace('#^www\.#', '', sanitize_text_field($_SERVER['HTTP_HOST'])) : sanitize_text_field( get_bloginfo('name') ); $default_text = sprintf( '© %1$s %2$s. %3$s', date('Y'), $default_domain, __('All rights reserved.', 'airtheme') ); $wp_customize->add_setting('footer_copyright', [ 'default' => '', 'sanitize_callback' => 'wp_kses_post', ]); $wp_customize->add_control('footer_copyright', [ 'label' => __('Copyright Text', 'airtheme'), 'section' => 'airtheme_footer', 'type' => 'text', 'description' => __('Leave empty to automatically use the site domain.', 'airtheme'), ]); /** * === AirTheme Badge (Footer) === */ $wp_customize->add_section('airtheme_footer_brand', [ 'title' => __('AirTheme', 'airtheme'), 'priority' => 99, 'description' => __('Subtle AirTheme branding in the footer.', 'airtheme'), ]); $wp_customize->add_setting('airtheme_footer_badge_enable', [ 'default' => true, 'sanitize_callback' => 'wp_validate_boolean', ]); $wp_customize->add_control('airtheme_footer_badge_enable', [ 'label' => __('Show AirTheme badge', 'airtheme'), 'section' => 'airtheme_footer_brand', 'type' => 'checkbox', ]); }); // === Header & Hero Section === add_action('customize_register', function($wp_customize) { // Create section $wp_customize->add_section('airtheme_header_hero', [ 'title' => __('Header & Hero', 'airtheme'), 'priority' => 20, ]); // === Tagline text and visibility toggle === $wp_customize->add_setting('airtheme_tagline', [ 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_control('airtheme_tagline', [ 'label' => __('Tagline under the logo', 'airtheme'), 'section' => 'airtheme_header_hero', 'type' => 'text', ]); $wp_customize->add_setting('airtheme_tagline_toggle', [ 'default' => true, 'sanitize_callback' => 'rest_sanitize_boolean', ]); $wp_customize->add_control('airtheme_tagline_toggle', [ 'label' => __('Show tagline', 'airtheme'), 'section' => 'airtheme_header_hero', 'type' => 'checkbox', ]); // === Hero image === $wp_customize->add_setting('airtheme_hero_image', [ 'default' => '', 'sanitize_callback' => 'esc_url_raw', ]); $wp_customize->add_control(new WP_Customize_Image_Control( $wp_customize, 'airtheme_hero_image', [ 'label' => __('Hero Image', 'airtheme'), 'section' => 'airtheme_header_hero', 'settings' => 'airtheme_hero_image', ] )); // === Hero subtitle text & toggle === $wp_customize->add_setting('airtheme_hero_subtitle_text', [ 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_control('airtheme_hero_subtitle_text', [ 'label' => __('Hero Hashtag Line', 'airtheme'), 'section' => 'airtheme_header_hero', 'type' => 'text', ]); $wp_customize->add_setting('airtheme_hero_subtitle_toggle', [ 'default' => true, 'sanitize_callback' => 'rest_sanitize_boolean', ]); $wp_customize->add_control('airtheme_hero_subtitle_toggle', [ 'label' => __('Show Subtitle', 'airtheme'), 'section' => 'airtheme_header_hero', 'type' => 'checkbox', ]); // === Hero border radius (in px) === $wp_customize->add_setting('airtheme_hero_border_radius', [ 'default' => 12, 'sanitize_callback' => 'absint', ]); $wp_customize->add_control('airtheme_hero_border_radius', [ 'label' => __('Hero Border Radius (px)', 'airtheme'), 'section' => 'airtheme_header_hero', 'type' => 'number', 'input_attrs' => [ 'min' => 0, 'max' => 30, 'step' => 1, ], ]); // === Accent color (primary accent) === $wp_customize->add_setting('airtheme_accent_color', [ 'default' => '#ff7a00', 'sanitize_callback' => 'sanitize_hex_color', ]); $wp_customize->add_control(new WP_Customize_Color_Control( $wp_customize, 'airtheme_accent_color', [ 'label' => __('Accent Color', 'airtheme'), 'section' => 'airtheme_header_hero', 'settings' => 'airtheme_accent_color', ] )); }); /** * AirTheme — Customizer Settings * (minimal version: accent color, background, sidebar) */ if ( ! defined('ABSPATH') ) { exit; } /** * === Sidebar Settings === */ function airtheme_sidebar_customizer( $wp_customize ) { // Sidebar section $wp_customize->add_section('airtheme_sidebar', [ 'title' => __('Sidebar', 'airtheme'), 'description' => __('Sidebar display settings for different templates.', 'airtheme'), 'priority' => 35, ]); // Enable sidebar toggle $wp_customize->add_setting('airtheme_sidebar_enabled', [ 'default' => false, 'sanitize_callback' => 'wp_validate_boolean', ]); $wp_customize->add_control('airtheme_sidebar_enabled', [ 'label' => __('Enable Sidebar', 'airtheme'), 'section' => 'airtheme_sidebar', 'type' => 'checkbox', ]); // Sidebar position (left / right) $wp_customize->add_setting('airtheme_sidebar_position', [ 'default' => 'right', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_control('airtheme_sidebar_position', [ 'label' => __('Sidebar Position', 'airtheme'), 'section' => 'airtheme_sidebar', 'type' => 'radio', 'choices' => [ 'left' => __('Left', 'airtheme'), 'right' => __('Right', 'airtheme'), ], ]); // === Where to display the sidebar === $templates = [ 'single' => __('Show on Posts (single.php)', 'airtheme'), 'page' => __('Show on Pages (page.php)', 'airtheme'), ]; foreach ( $templates as $key => $label ) { $wp_customize->add_setting("airtheme_sidebar_show_{$key}", [ 'default' => false, 'sanitize_callback' => 'wp_validate_boolean', ]); $wp_customize->add_control("airtheme_sidebar_show_{$key}", [ 'label' => $label, 'section' => 'airtheme_sidebar', 'type' => 'checkbox', ]); } } add_action('customize_register', 'airtheme_sidebar_customizer'); /** * === Color Settings === */ function airtheme_color_customizer( $wp_customize ) { // Theme color section $wp_customize->add_section('airtheme_colors', [ 'title' => __('Theme Colors', 'airtheme'), 'priority' => 20, ]); // Accent color $wp_customize->add_setting('airtheme_accent_color', [ 'default' => '#ff7a00', 'sanitize_callback' => 'sanitize_hex_color', ]); $wp_customize->add_control(new WP_Customize_Color_Control( $wp_customize, 'airtheme_accent_color', [ 'label' => __('Accent Color', 'airtheme'), 'section' => 'airtheme_colors', ] )); // Background color $wp_customize->add_setting('airtheme_bg_color', [ 'default' => '#ffffff', 'sanitize_callback' => 'sanitize_hex_color', ]); $wp_customize->add_control(new WP_Customize_Color_Control( $wp_customize, 'airtheme_bg_color', [ 'label' => __('Site Background Color', 'airtheme'), 'section' => 'airtheme_colors', ] )); } add_action('customize_register', 'airtheme_color_customizer');