ID ] = $page->post_title; } return $choices; } /** * List of posts for post choices. * @return Array Array of post ids and name. */ function business_cube_post_choices() { $posts = get_posts( array( 'numberposts' => -1 ) ); $choices = array(); $choices[0] = esc_html__( '--Select--', 'business-cube' ); foreach ( $posts as $post ) { $choices[ $post->ID ] = $post->post_title; } return $choices; } /** * List of category for category choices. * @return Array Array of post ids and name. */ function business_cube_category_choices() { $tax_args = array( 'hierarchical' => 0, 'taxonomy' => 'category', ); $taxonomies = get_categories( $tax_args ); $choices = array(); $choices[0] = esc_html__( '--Select--', 'business-cube' ); foreach ( $taxonomies as $tax ) { $choices[ $tax->term_id ] = $tax->name; } return $choices; } /* Options Ends */ /* * Active Callback */ /** * Check if featured section is enabled. * * @since Business Cube 1.0 * @param WP_Customize_Control $control WP_Customize_Control instance. * @return bool Whether the control is active to the current preview. */ function business_cube_featured_section_enable( $control ) { return ( $control->manager->get_setting( 'theme_options[featured_section_enable]' )->value() ); } /** * Check if featured section content type is page. * * @since Business Cube 1.0 * @param WP_Customize_Control $control WP_Customize_Control instance. * @return bool Whether the control is active to the current preview. */ function business_cube_featured_section_content_page_enable( $control ) { $content_type = $control->manager->get_setting( 'theme_options[featured_content_type]' )->value(); return business_cube_featured_section_enable( $control ) && ( 'page' == $content_type ); } /** * Check if about section is enabled. * * @since Business Cube 1.0 * @param WP_Customize_Control $control WP_Customize_Control instance. * @return bool Whether the control is active to the current preview. */ function business_cube_about_section_enable( $control ) { return ( $control->manager->get_setting( 'theme_options[about_section_enable]' )->value() ); } /** * Check if about section content type is page. * * @since Business Cube 1.0 * @param WP_Customize_Control $control WP_Customize_Control instance. * @return bool Whether the control is active to the current preview. */ function business_cube_about_section_content_page_enable( $control ) { $content_type = $control->manager->get_setting( 'theme_options[about_content_type]' )->value(); return business_cube_about_section_enable( $control ) && ( 'page' == $content_type ); } /** * Check if Services section is enabled. * * @since Business Cube 1.0 * @param WP_Customize_Control $control WP_Customize_Control instance. * @return bool Whether the control is active to the current preview. */ function business_cube_services_section_enable( $control ) { return ( $control->manager->get_setting( 'theme_options[services_section_enable]' )->value() ); } /** * Check if services section content type is page. * * @since Business Cube 1.0 * @param WP_Customize_Control $control WP_Customize_Control instance. * @return bool Whether the control is active to the current preview. */ function business_cube_services_section_content_page_enable( $control ) { $content_type = $control->manager->get_setting( 'theme_options[services_content_type]' )->value(); return business_cube_services_section_enable( $control ) && ( 'page' == $content_type ); } /** * Check if Cta section is enabled. * * @since Business Cube 1.0 * @param WP_Customize_Control $control WP_Customize_Control instance. * @return bool Whether the control is active to the current preview. */ function business_cube_cta_section_enable( $control ) { return ( $control->manager->get_setting( 'theme_options[cta_section_enable]' )->value() ); } /** * Check if Cta section content type is page. * * @since Business Cube 1.0 * @param WP_Customize_Control $control WP_Customize_Control instance. * @return bool Whether the control is active to the current preview. */ function business_cube_cta_section_content_page_enable( $control ) { $content_type = $control->manager->get_setting( 'theme_options[cta_content_type]' )->value(); return business_cube_cta_section_enable( $control ) && ( 'page' == $content_type ); } /** * Check if blog section is enabled. * * @since Business Cube 1.0 * @param WP_Customize_Control $control WP_Customize_Control instance. * @return bool Whether the control is active to the current preview. */ function business_cube_blog_section_enable( $control ) { return ( $control->manager->get_setting( 'theme_options[blog_section_enable]' )->value() ); } /** * Check if blog section content type is post. * * @since Business Cube 1.0 * @param WP_Customize_Control $control WP_Customize_Control instance. * @return bool Whether the control is active to the current preview. */ function business_cube_blog_section_content_post_enable( $control ) { $content_type = $control->manager->get_setting( 'theme_options[blog_content_type]' )->value(); return business_cube_blog_section_enable( $control ) && ( 'post' == $content_type ); } /** * Check if blog section content type is page. * * @since Business Cube 1.0 * @param WP_Customize_Control $control WP_Customize_Control instance. * @return bool Whether the control is active to the current preview. */ function business_cube_blog_section_content_page_enable( $control ) { $content_type = $control->manager->get_setting( 'theme_options[blog_content_type]' )->value(); return business_cube_blog_section_enable( $control ) && ( 'page' == $content_type ); } /** * Check if blog section content type is category. * * @since Business Cube 1.0 * @param WP_Customize_Control $control WP_Customize_Control instance. * @return bool Whether the control is active to the current preview. */ function business_cube_blog_section_content_category_enable( $control ) { $content_type = $control->manager->get_setting( 'theme_options[blog_content_type]' )->value(); return business_cube_blog_section_enable( $control ) && ( 'category' == $content_type ); } /* Active Callback Ends */ // Add Homepage Options Panel. $wp_customize->add_panel( 'business_cube_homepage_section_option_panel', array( 'title' => esc_html__( 'Homepage Sections Options', 'business-cube' ), 'priority' => 200, ) ); /* * Featured Section */ // Featured Section Section. $wp_customize->add_section( 'business_cube_featured_section', array( 'title' => esc_html__( 'Featured Section', 'business-cube' ), 'priority' => 100, 'panel' => 'business_cube_homepage_section_option_panel', ) ); // Featured Section Enable. $wp_customize->add_setting( 'theme_options[featured_section_enable]', array( 'default' => true, 'sanitize_callback' => 'business_cube_sanitize_select', ) ); $wp_customize->add_control( 'theme_options[featured_section_enable]', array( 'label' => esc_html__( 'Enable Featured Section', 'business-cube' ), 'section' => 'business_cube_featured_section', 'type' => 'radio', 'choices' => array( true => esc_html__( 'Yes', 'business-cube' ), false => esc_html__( 'No', 'business-cube' ), ), ) ); // Featured Section Enable. $wp_customize->add_setting( 'theme_options[featured_content_type]', array( 'default' => 'page', 'sanitize_callback' => 'business_cube_sanitize_select', ) ); $wp_customize->add_control( 'theme_options[featured_content_type]', array( 'label' => esc_html__( 'Content Type', 'business-cube' ), 'section' => 'business_cube_featured_section', 'type' => 'radio', 'choices' => array( 'page' => esc_html__( 'Page', 'business-cube' ), ), 'active_callback' => 'business_cube_featured_section_enable', ) ); // Featured Section count control and setting $wp_customize->add_setting( 'theme_options[featured_section_count]', array( 'default' => 3, 'sanitize_callback' => 'business_cube_sanitize_number_range', 'validate_callback' => 'featured_section_count', ) ); $wp_customize->add_control( 'theme_options[featured_section_count]', array( 'label' => esc_html__( 'Number of Posts', 'business-cube' ), 'description' => esc_html__( 'Note: Min 1 & Max 3. Please input the valid number and save. Then refresh the page to see the change.', 'business-cube' ), 'section' => 'business_cube_featured_section', 'active_callback' => 'business_cube_featured_section_enable', 'type' => 'number', 'input_attrs' => array( 'min' => 1, 'max' => 3, 'style' => 'width: 100px;' ), ) ); $featured_count = business_cube_get_option( 'featured_section_count' ) ? business_cube_get_option( 'featured_section_count' ) : 3; for ( $i = 1; $i <= $featured_count; $i++ ) : // Featured Section Page. $wp_customize->add_setting( 'theme_options[featured_content_page_' . $i . ']', array( 'sanitize_callback' => 'business_cube_sanitize_dropdown_pages', ) ); $wp_customize->add_control( 'theme_options[featured_content_page_' . $i . ']', array( 'label' => sprintf( esc_html__( 'Select Page %d', 'business-cube' ), $i ), 'section' => 'business_cube_featured_section', 'type' => 'select', 'choices' => business_cube_page_choices(), 'active_callback' => 'business_cube_featured_section_content_page_enable', ) ); endfor; // Slider alt btn label setting and control $wp_customize->add_setting( 'theme_options[slider_btn_label]', array( 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'theme_options[slider_btn_label]', array( 'label' => esc_html__( 'Slider Button Label', 'business-cube' ), 'section' => 'business_cube_featured_section', 'active_callback' => 'business_cube_featured_section_enable', 'type' => 'text', ) ); /* * About Section */ // About Section Section. $wp_customize->add_section( 'business_cube_about_section', array( 'title' => esc_html__( 'About Section', 'business-cube' ), 'priority' => 100, 'panel' => 'business_cube_homepage_section_option_panel', ) ); // About Section Enable. $wp_customize->add_setting( 'theme_options[about_section_enable]', array( 'default' => true, 'sanitize_callback' => 'business_cube_sanitize_select', ) ); $wp_customize->add_control( 'theme_options[about_section_enable]', array( 'label' => esc_html__( 'Enable About Section', 'business-cube' ), 'section' => 'business_cube_about_section', 'type' => 'radio', 'choices' => array( true => esc_html__( 'Yes', 'business-cube' ), false => esc_html__( 'No', 'business-cube' ), ), ) ); // About Section Enable. $wp_customize->add_setting( 'theme_options[about_content_type]', array( 'default' => 'page', 'sanitize_callback' => 'business_cube_sanitize_select', ) ); $wp_customize->add_control( 'theme_options[about_content_type]', array( 'label' => esc_html__( 'Content Type', 'business-cube' ), 'section' => 'business_cube_about_section', 'type' => 'radio', 'choices' => array( 'page' => esc_html__( 'Page', 'business-cube' ), ), 'active_callback' => 'business_cube_about_section_enable', ) ); // About Section count control and setting $wp_customize->add_setting( 'theme_options[about_section_count]', array( 'default' => 1, 'sanitize_callback' => 'business_cube_sanitize_number_range', 'validate_callback' => 'about_section_count', ) ); $wp_customize->add_control( 'theme_options[about_section_count]', array( 'label' => esc_html__( 'Number of About', 'business-cube' ), 'description' => esc_html__( 'Note: Min 1 & Max 10. Please input the valid number and save. Then refresh the page to see the change.', 'business-cube' ), 'section' => 'business_cube_about_section', 'active_callback' => 'business_cube_about_section_enable', 'type' => 'number', 'input_attrs' => array( 'min' => 1, 'max' => 1, 'step' => 1, 'style' => 'width: 100px;' ), ) ); $about_count = business_cube_get_option( 'about_section_count' ) ? business_cube_get_option( 'about_section_count' ) : 3; for ( $i = 1; $i <= $about_count; $i++ ) : // About Section Page. $wp_customize->add_setting( 'theme_options[about_content_page_' . $i . ']', array( 'sanitize_callback' => 'business_cube_sanitize_dropdown_pages', ) ); $wp_customize->add_control( 'theme_options[about_content_page_' . $i . ']', array( 'label' => sprintf( esc_html__( 'Select Page %d', 'business-cube' ), $i ), 'section' => 'business_cube_about_section', 'type' => 'select', 'choices' => business_cube_page_choices(), 'active_callback' => 'business_cube_about_section_content_page_enable', ) ); endfor; // About alt btn label setting and control $wp_customize->add_setting( 'theme_options[about_btn_label]', array( 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'theme_options[about_btn_label]', array( 'label' => esc_html__( 'About Button Label', 'business-cube' ), 'section' => 'business_cube_about_section', 'active_callback' => 'business_cube_about_section_enable', 'type' => 'text', ) ); /* * Services Section */ // Services Section Section. $wp_customize->add_section( 'business_cube_services_section', array( 'title' => esc_html__( 'Services Section', 'business-cube' ), 'priority' => 100, 'panel' => 'business_cube_homepage_section_option_panel', ) ); // Services Section Enable. $wp_customize->add_setting( 'theme_options[services_section_enable]', array( 'default' => true, 'sanitize_callback' => 'business_cube_sanitize_select', ) ); $wp_customize->add_control( 'theme_options[services_section_enable]', array( 'label' => esc_html__( 'Enable Services Section', 'business-cube' ), 'section' => 'business_cube_services_section', 'type' => 'radio', 'choices' => array( true => esc_html__( 'Yes', 'business-cube' ), false => esc_html__( 'No', 'business-cube' ), ), ) ); // Services Section Enable. $wp_customize->add_setting( 'theme_options[services_column]', array( 'default' => 'col-3', 'sanitize_callback' => 'business_cube_sanitize_select', ) ); $wp_customize->add_control( 'theme_options[services_column]', array( 'label' => esc_html__( 'Column Type', 'business-cube' ), 'section' => 'business_cube_services_section', 'type' => 'radio', 'choices' => array( 'col-3' => esc_html__( 'Three', 'business-cube' ), ), 'active_callback' => 'business_cube_services_section_enable', ) ); //Services Section title $wp_customize->add_setting('theme_options[services_title]', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field' ) ); $wp_customize->add_control('theme_options[services_title]', array( 'label' => __('Section Title', 'business-cube'), 'section' => 'business_cube_services_section', 'settings' => 'theme_options[services_title]', 'active_callback' => 'business_cube_services_section_enable', 'type' => 'text' ) ); //Services Section subtitle $wp_customize->add_setting('theme_options[services_subtitle]', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field' ) ); $wp_customize->add_control('theme_options[services_subtitle]', array( 'label' => __('Section SubTitle', 'business-cube'), 'section' => 'business_cube_services_section', 'settings' => 'theme_options[services_subtitle]', 'active_callback' => 'business_cube_services_section_enable', 'type' => 'text' ) ); // Services Section Enable. $wp_customize->add_setting( 'theme_options[services_content_type]', array( 'default' => 'page', 'sanitize_callback' => 'business_cube_sanitize_select', ) ); $wp_customize->add_control( 'theme_options[services_content_type]', array( 'label' => esc_html__( 'Content Type', 'business-cube' ), 'section' => 'business_cube_services_section', 'type' => 'radio', 'choices' => array( 'page' => esc_html__( 'Page', 'business-cube' ), ), 'active_callback' => 'business_cube_services_section_enable', ) ); // Services Section count control and setting $wp_customize->add_setting( 'theme_options[services_section_count]', array( 'default' => 3, 'sanitize_callback' => 'business_cube_sanitize_number_range', 'validate_callback' => 'services_section_count', ) ); $wp_customize->add_control( 'theme_options[services_section_count]', array( 'label' => esc_html__( 'Number of Posts', 'business-cube' ), 'description' => esc_html__( 'Note: Min 1 & Max 10. Please input the valid number and save. Then refresh the page to see the change.', 'business-cube' ), 'section' => 'business_cube_services_section', 'active_callback' => 'business_cube_services_section_enable', 'type' => 'number', 'input_attrs' => array( 'min' => 3, 'max' => 3, 'style' => 'width: 100px;' ), ) ); $services_count = business_cube_get_option( 'services_section_count' ) ? business_cube_get_option( 'services_section_count' ) : 3; for ( $i = 1; $i <= $services_count; $i++ ) : // Services Section Page. $wp_customize->add_setting( 'theme_options[services_content_page_' . $i . ']', array( 'sanitize_callback' => 'business_cube_sanitize_dropdown_pages', ) ); $wp_customize->add_control( 'theme_options[services_content_page_' . $i . ']', array( 'label' => sprintf( esc_html__( 'Select Page %d', 'business-cube' ), $i ), 'section' => 'business_cube_services_section', 'type' => 'select', 'choices' => business_cube_page_choices(), 'active_callback' => 'business_cube_services_section_content_page_enable', ) ); endfor; /* * CTA Section */ // CTA Section Section. $wp_customize->add_section( 'business_cube_cta_section', array( 'title' => esc_html__( 'Cta Section', 'business-cube' ), 'priority' => 100, 'panel' => 'business_cube_homepage_section_option_panel', ) ); // CTA Section Enable. $wp_customize->add_setting( 'theme_options[cta_section_enable]', array( 'default' => true, 'sanitize_callback' => 'business_cube_sanitize_select', ) ); $wp_customize->add_control( 'theme_options[cta_section_enable]', array( 'label' => esc_html__( 'Enable Cta Section', 'business-cube' ), 'section' => 'business_cube_cta_section', 'type' => 'radio', 'choices' => array( true => esc_html__( 'Yes', 'business-cube' ), false => esc_html__( 'No', 'business-cube' ), ), ) ); // Cta Content Type. $wp_customize->add_setting( 'theme_options[cta_content_type]', array( 'default' => 'page', 'sanitize_callback' => 'business_cube_sanitize_select', ) ); $wp_customize->add_control( 'theme_options[cta_content_type]', array( 'label' => esc_html__( 'Content Type', 'business-cube' ), 'section' => 'business_cube_cta_section', 'type' => 'radio', 'choices' => array( 'page' => esc_html__( 'Page', 'business-cube' ), ), 'active_callback' => 'business_cube_cta_section_enable', ) ); // cta Section Page. $wp_customize->add_setting( 'theme_options[cta_content_page]', array( 'sanitize_callback' => 'business_cube_sanitize_dropdown_pages', ) ); $wp_customize->add_control( 'theme_options[cta_content_page]', array( 'label' => esc_html__( 'Select Page', 'business-cube' ), 'section' => 'business_cube_cta_section', 'type' => 'select', 'choices' => business_cube_page_choices(), 'active_callback' => 'business_cube_cta_section_content_page_enable', ) ); /* * Blog Section */ // Blog Section Section. $wp_customize->add_section( 'business_cube_blog_section', array( 'title' => esc_html__( 'Blog Section', 'business-cube' ), 'priority' => 100, 'panel' => 'business_cube_homepage_section_option_panel', ) ); // Blog Section Enable. $wp_customize->add_setting( 'theme_options[blog_section_enable]', array( 'default' => true, 'sanitize_callback' => 'business_cube_sanitize_select', ) ); $wp_customize->add_control( 'theme_options[blog_section_enable]', array( 'label' => esc_html__( 'Enable Blog Section', 'business-cube' ), 'section' => 'business_cube_blog_section', 'type' => 'radio', 'choices' => array( true => esc_html__( 'Yes', 'business-cube' ), false => esc_html__( 'No', 'business-cube' ), ), ) ); //Blog Section title $wp_customize->add_setting('theme_options[blog_title]', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field' ) ); $wp_customize->add_control('theme_options[blog_title]', array( 'label' => __('Section Title', 'business-cube'), 'section' => 'business_cube_blog_section', 'settings' => 'theme_options[blog_title]', 'active_callback' => 'business_cube_blog_section_enable', 'type' => 'text' ) ); //Blog Section subtitle $wp_customize->add_setting('theme_options[blog_subtitle]', array( 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field' ) ); $wp_customize->add_control('theme_options[blog_subtitle]', array( 'label' => __('Section SubTitle', 'business-cube'), 'section' => 'business_cube_blog_section', 'settings' => 'theme_options[blog_subtitle]', 'active_callback' => 'business_cube_blog_section_enable', 'type' => 'text' ) ); // Blog Column Enable. $wp_customize->add_setting( 'theme_options[blog_column]', array( 'default' => '3', 'sanitize_callback' => 'business_cube_sanitize_select', ) ); $wp_customize->add_control( 'theme_options[blog_column]', array( 'label' => esc_html__( 'Column Type', 'business-cube' ), 'section' => 'business_cube_blog_section', 'type' => 'radio', 'choices' => array( '3' => esc_html__( 'Three', 'business-cube' ), ), 'active_callback' => 'business_cube_blog_section_enable', ) ); // Blog Content Type. $wp_customize->add_setting( 'theme_options[blog_content_type]', array( 'default' => 'post', 'sanitize_callback' => 'business_cube_sanitize_select', ) ); $wp_customize->add_control( 'theme_options[blog_content_type]', array( 'label' => esc_html__( 'Content Type', 'business-cube' ), 'section' => 'business_cube_blog_section', 'type' => 'radio', 'choices' => array( 'post' => esc_html__( 'Post', 'business-cube' ), ), 'active_callback' => 'business_cube_blog_section_enable', ) ); // Blog Section count control and setting $wp_customize->add_setting( 'theme_options[blog_section_count]', array( 'default' => 3, 'sanitize_callback' => 'business_cube_sanitize_number_range', ) ); $wp_customize->add_control( 'theme_options[blog_section_count]', array( 'label' => esc_html__( 'Number of blog', 'business-cube' ), 'description' => esc_html__( 'Note: Min 1 & Max 10. Please input the valid number and save. Then refresh the page to see the change.', 'business-cube' ), 'section' => 'business_cube_blog_section', 'active_callback' => 'business_cube_blog_section_enable', 'type' => 'number', 'input_attrs' => array( 'min' => 3, 'max' => 3, 'style' => 'width: 100px;' ), ) ); $blog_count = business_cube_get_option('blog_section_count'); for ( $i = 1; $i <= $blog_count; $i++ ) : // Blog Section Post. $wp_customize->add_setting( 'theme_options[blog_content_post_' . $i . ']', array( 'sanitize_callback' => 'business_cube_sanitize_dropdown_pages', ) ); $wp_customize->add_control( 'theme_options[blog_content_post_' . $i . ']', array( 'label' => sprintf( esc_html__( 'Select Post %d', 'business-cube' ), $i ), 'section' => 'business_cube_blog_section', 'type' => 'select', 'choices' => business_cube_post_choices(), 'active_callback' => 'business_cube_blog_section_content_post_enable', ) ); endfor;