add_panel( 'homepage_settings_panel', array( 'title' => 'Homepage Settings', 'description' => 'Configure Homepage Sections', 'priority' => 999, 'active_callback' => 'is_front_page', ) ); // create Hero section $wp_customize->add_section( 'hero_section', array( 'title' => 'Hero Section', 'priority' => 10, 'panel' => 'homepage_settings_panel', )); // create Partners section $wp_customize->add_section( 'partners_section', array( 'title' => 'Partners Section', 'priority' => 10, 'panel' => 'homepage_settings_panel', )); // create About section $wp_customize->add_section( 'about_section', array( 'title' => 'About Section', 'priority' => 10, 'panel' => 'homepage_settings_panel', )); // create Latest Articles section $wp_customize->add_section( 'latest_articles_section', array( 'title' => 'Latest Articles Section', 'priority' => 10, 'panel' => 'homepage_settings_panel', )); // create Latest Articles section $wp_customize->add_section( 'portfolio_section', array( 'title' => 'Portfolio Section', 'priority' => 10, 'panel' => 'homepage_settings_panel', )); // HERO SECTION CONTENT $wp_customize->add_setting( 'jumbotron_section', array( 'default' => '', 'sanitize_callback' => 'ab_sanitize_checkbox' ) ); $wp_customize->add_control('jumbotron_section', array( 'type' => 'checkbox', 'label' => 'Show Hero section on Homepage', 'section' => 'hero_section', 'settings' => 'jumbotron_section' ) ); $wp_customize->add_setting( 'jumbotron_bg_image', array( 'default' => '', 'sanitize_callback' => 'ab_sanitize_input' ) ); $wp_customize->add_control('jumbotron_bg_image', array( 'label' => 'Hero Section Background Image', 'section' => 'hero_section', 'type' => 'text', 'settings' => 'jumbotron_bg_image' ) ); $wp_customize->add_setting( 'jumbotron_title', array( 'default' => 'WordPress Expert & Professional Keyboard Typer :)', 'sanitize_callback' => 'ab_sanitize_input' ) ); $wp_customize->add_control('jumbotron_title', array( 'label' => 'Hero Section Title', 'section' => 'hero_section', 'type' => 'text', 'settings' => 'jumbotron_title' ) ); $wp_customize->add_setting( 'jumbotron_subtitle', array( 'default' => 'The blog and portfolio of Arber Braja', 'sanitize_callback' => 'ab_sanitize_input' ) ); $wp_customize->add_control('jumbotron_subtitle', array( 'label' => 'Hero Section Sub-Title', 'section' => 'hero_section', 'type' => 'text', 'settings' => 'jumbotron_subtitle' ) ); $wp_customize->add_setting('jumbotron_link', array( 'default' => '#', 'sanitize_callback' => 'ab_sanitize_input' ) ); $wp_customize->add_control('jumbotron_link', array( 'label' => 'Hero Section Link', 'section' => 'hero_section', 'type' => 'text', 'settings' => 'jumbotron_link' ) ); // PARTNERS SECTION CONTENT $wp_customize->add_setting('partners_section', array( 'default' => '', 'sanitize_callback' => 'ab_sanitize_checkbox' ) ); $wp_customize->add_control('partners_section', array( 'type' => 'checkbox', 'label' => 'Show Partners on Homepage', 'section' => 'partners_section', 'settings' => 'partners_section' ) ); $wp_customize->add_setting('partners_shown', array( 'default' => '6', 'sanitize_callback' => 'ab_sanitize_input' ) ); $wp_customize->add_control('partners_shown', array( 'type' => 'select', 'label' => 'Number of partners shown:', 'section' => 'partners_section', 'choices' => array( '3' => '3', '4' => '4', '6' => '6', ), ) ); // ABOUT ME SECTION CONTENT $wp_customize->add_setting('aboutme_section', array( 'default' => '', 'sanitize_callback' => 'ab_sanitize_checkbox' ) ); $wp_customize->add_control('aboutme_section', array( 'type' => 'checkbox', 'label' => 'Show About me on Homepage', 'section' => 'about_section', 'settings' => 'aboutme_section' ) ); $wp_customize->add_setting('aboutme_image', array( 'default' => '', 'sanitize_callback' => 'ab_sanitize_input' ) ); $wp_customize->add_control( new WP_Customize_Upload_Control( $wp_customize, 'aboutme_image', array( 'label' => 'About me Image', 'section' => 'about_section', 'settings' => 'aboutme_image' ) ) ); $wp_customize->add_setting('aboutme_content', array( 'default' => '', 'sanitize_callback' => 'ab_sanitize_input' ) ); $wp_customize->add_control('aboutme_content', array( 'label' => 'About me content', 'section' => 'about_section', 'type' => 'textarea', 'settings' => 'aboutme_content' ) ); // LATEST ARTICLES SECTION $wp_customize->add_setting('latest_section', array( 'default' => '', 'sanitize_callback' => 'ab_sanitize_checkbox' ) ); $wp_customize->add_control('latest_section', array( 'type' => 'checkbox', 'label' => 'Show latest blog articles on Homepage', 'section' => 'latest_articles_section', 'settings' => 'latest_section' ) ); // PORTFOLIO SECTION $wp_customize->add_setting('portfolio_section', array( 'default' => '', 'sanitize_callback' => 'ab_sanitize_checkbox' ) ); $wp_customize->add_control('portfolio_section', array( 'type' => 'checkbox', 'label' => 'Show Portfolio items on Homepage', 'section' => 'portfolio_section', 'settings' => 'portfolio_section' ) ); } add_action('customize_register', 'ab_homepage_costumizer'); // might need a better sanitizing function function ab_sanitize_input( $value ) { return $value; } function ab_sanitize_checkbox( $value ) { if ( $value == 1 ) { return 1; } else { return ''; } }