add_section('allurewp_layout', [ 'title' => __('Layout Settings', 'allurewp'), 'priority' => 30, ]); $wp_customize->add_setting('allurewp_container_type', [ 'default' => 'container', 'sanitize_callback' => function($value) { return in_array($value, ['container', 'container-fluid']) ? $value : 'container'; } ]); $wp_customize->add_control('allurewp_container_type', [ 'label' => __('Container Type', 'allurewp'), 'section' => 'allurewp_layout', 'type' => 'select', 'choices' => [ 'container' => __('Fixed Container', 'allurewp'), 'container-fluid' => __('Full Width Container', 'allurewp') ] ]); } add_action('customize_register', 'allurewp_customize_register'); // helper fuction to get the class dynamically for layout function allurewp_get_container_class() { return get_theme_mod('allurewp_container_type', 'container'); } // Footer Customizer function allurewp_customize_footer_widgets( $wp_customize ) { $wp_customize->add_section( 'allurewp_footer_widgets_section', [ 'title' => __( 'Footer Widgets', 'allurewp' ), 'priority' => 35, ] ); $wp_customize->add_setting( 'allurewp_footer_widget_columns', [ 'default' => 1, 'sanitize_callback' => 'absint', ] ); $wp_customize->add_control( 'allurewp_footer_widget_columns', [ 'label' => __( 'Number of Footer Widget Areas (1 to 4)', 'allurewp' ), 'section' => 'allurewp_footer_widgets_section', 'type' => 'range', 'input_attrs' => [ 'min' => 1, 'max' => 4, ], ] ); } add_action( 'customize_register', 'allurewp_customize_footer_widgets' ); function allurewp_register_footer_widgets() { $columns = get_theme_mod( 'allurewp_footer_widget_columns', 1 ); $columns = max( 1, min( 4, $columns ) ); // Clamp between 1 and 4 for ( $i = 1; $i <= $columns; $i++ ) { register_sidebar( [ 'name' => sprintf( __( 'Footer Column %d', 'allurewp' ), $i ), 'id' => 'footer-' . $i, 'description' => sprintf( __( 'Widgets in column %d of the footer.', 'allurewp' ), $i ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ] ); } } add_action( 'widgets_init', 'allurewp_register_footer_widgets' ); // color customizer function allurewp_customize_colors( $wp_customize ) { $wp_customize->add_section( 'allurewp_color_section', [ 'title' => __( 'Theme Colors', 'allurewp' ), 'priority' => 31, ] ); $color_settings = [ 'primary' => 'Primary Color', 'secondary' => 'Secondary Color', 'body_text' => 'Body Font Color', 'heading' => 'Heading Color', 'subheading' => 'Subheading Color', 'button_bg' => 'Button Background Color', 'button_text' => 'Button Text Color', 'link' => 'Anchor Link Color', ]; foreach ( $color_settings as $slug => $label ) { $wp_customize->add_setting( "allurewp_color_{$slug}", [ 'default' => '#000000', 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_hex_color', ] ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, "allurewp_color_{$slug}", [ 'label' => sprintf( __( '%s', 'allurewp' ), $label ), 'section' => 'allurewp_color_section', 'settings' => "allurewp_color_{$slug}", ] ) ); } } add_action( 'customize_register', 'allurewp_customize_colors' ); function allurewp_output_color_styles() { ?> add_section( 'allurewp_typography_section', [ 'title' => __( 'Typography Settings', 'allurewp' ), 'priority' => 30, ] ); $google_fonts = [ 'Roboto' => 'Roboto', 'Open Sans' => 'Open Sans', 'Lato' => 'Lato', 'Montserrat' => 'Montserrat', 'Poppins' => 'Poppins', 'Raleway' => 'Raleway', 'Merriweather' => 'Merriweather', 'Oswald' => 'Oswald', 'Source Sans Pro' => 'Source Sans Pro', 'Playfair Display' => 'Playfair Display' ]; $font_controls = [ 'heading' => 'Main Heading Font', 'subheading' => 'Subheading Font', 'body' => 'Body Font', 'button' => 'Button Font', ]; foreach ( $font_controls as $key => $label ) { $wp_customize->add_setting( "allurewp_font_{$key}", [ 'default' => 'Roboto', 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_text_field', ] ); $wp_customize->add_control( "allurewp_font_{$key}", [ 'label' => __( $label, 'allurewp' ), 'section' => 'allurewp_typography_section', 'type' => 'select', 'choices' => $google_fonts, 'sanitize_callback' => 'sanitize_text_field', ] ); } } add_action( 'customize_register', 'allurewp_customize_typography' ); function allurewp_enqueue_google_fonts() { $fonts = []; $font_keys = [ get_theme_mod( 'allurewp_font_heading', 'Roboto' ), get_theme_mod( 'allurewp_font_subheading', 'Roboto' ), get_theme_mod( 'allurewp_font_body', 'Roboto' ), get_theme_mod( 'allurewp_font_button', 'Roboto' ), ]; $unique_fonts = array_unique( array_filter( $font_keys ) ); foreach ( $unique_fonts as $font ) { $fonts[] = str_replace( ' ', '+', $font ) . ':400,500,600,700'; } if ( ! empty( $fonts ) ) { $query_args = [ 'family' => implode( '|', $fonts ), 'display' => 'swap' ]; $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' ); wp_enqueue_style( 'allurewp-google-fonts', $fonts_url, false ); } } add_action( 'wp_enqueue_scripts', 'allurewp_enqueue_google_fonts' ); function allurewp_typography_styles() { ?>