add_section('footer_background_section', array( 'title' => __('Footer Background', 'arcs'), 'priority' => 30, )); // Background Color $wp_customize->add_setting('footer_background_color', array( 'default' => '#3498db', 'sanitize_callback' => 'sanitize_hex_color', )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'footer_background_color', array( 'label' => __('Background Color', 'arcs'), 'section' => 'footer_background_section', ))); // Background Gradient $wp_customize->add_setting('footer_background_gradient', array( 'default' => '', 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control('footer_background_gradient', array( 'label' => __('Background Gradient', 'arcs'), 'section' => 'footer_background_section', )); // Background Image $wp_customize->add_setting('footer_background_image', array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', )); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'footer_background_image', array( 'label' => __('Background Image', 'arcs'), 'section' => 'footer_background_section', ))); // Background Position $wp_customize->add_setting('footer_background_position', array( 'default' => 'center center', 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control('footer_background_position', array( 'label' => __('Background Position', 'arcs'), 'section' => 'footer_background_section', )); // Background Size $wp_customize->add_setting('footer_background_size', array( 'default' => 'cover', 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control('footer_background_size', array( 'label' => __('Background Size', 'arcs'), 'section' => 'footer_background_section', )); // Background Attachment $wp_customize->add_setting('footer_background_attachment', array( 'default' => 'fixed', 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control('footer_background_attachment', array( 'label' => __('Background Attachment', 'arcs'), 'section' => 'footer_background_section', )); // Background Opacity $wp_customize->add_setting('footer_background_opacity', array( 'default' => 1, 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control('footer_background_opacity', array( 'label' => __('Background Opacity', 'arcs'), 'section' => 'footer_background_section', )); } add_action('customize_register', 'customize_footer_background'); // Output dynamic footer styles in the head function arcs_footer_dynamic_styles() { $footer_bg_color = get_theme_mod('footer_background_color', '#3498db'); $footer_bg_gradient = get_theme_mod('footer_background_gradient', ''); $footer_bg_image = get_theme_mod('footer_background_image', ''); $footer_bg_position = get_theme_mod('footer_background_position', 'center center'); $footer_bg_size = get_theme_mod('footer_background_size', 'cover'); $footer_bg_attachment = get_theme_mod('footer_background_attachment', 'fixed'); $footer_bg_opacity = get_theme_mod('footer_background_opacity', 1); $custom_styles = 'background-color: ' . esc_attr($footer_bg_color) . ';'; if (!empty($footer_bg_gradient)) { $custom_styles .= 'background: ' . esc_attr($footer_bg_gradient) . ';'; } if ($footer_bg_image) { $custom_styles .= 'background-image: url(' . esc_url($footer_bg_image) . ');'; $custom_styles .= 'background-position: ' . esc_attr($footer_bg_position) . ';'; $custom_styles .= 'background-size: ' . esc_attr($footer_bg_size) . ';'; $custom_styles .= 'background-attachment: ' . esc_attr($footer_bg_attachment) . ';'; } if ($footer_bg_opacity !== '') { $custom_styles .= 'opacity: ' . esc_attr($footer_bg_opacity) . ';'; } echo ''; } add_action('wp_head', 'arcs_footer_dynamic_styles'); ?>