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_head', function() {
$bg = esc_url( get_theme_mod('airtheme_bg_image') );
$opacity = floatval( get_theme_mod('airtheme_overlay_opacity', 0.3) );
if ( $bg ) {
?>
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', ]); }); // === Analytics & Tracking Scripts === add_action('customize_register', function($wp_customize) { $wp_customize->add_section('airtheme_analytics', [ 'title' => __('Analytics & Tracking', 'airtheme'), 'priority' => 50, ]); $wp_customize->add_setting('airtheme_analytics_code', [ 'default' => '', 'sanitize_callback' => function( $input ) { // Allow only safe tags for analytics scripts return wp_kses( $input, [ 'script' => [ 'type' => true, 'src' => true, 'async' => true, 'defer' => true, ], 'noscript' => [], 'img' => [ 'src' => true, 'style' => true, 'alt' => true, ], ]); }, ]); $wp_customize->add_control('airtheme_analytics_code', [ 'label' => __('Analytics Code (Google, Meta, etc.)', 'airtheme'), 'section' => 'airtheme_analytics', 'type' => 'textarea', 'description' => __('Insert your analytics HTML code here. It will be added before the closing