add_panel( 'theme_options', array( 'title' => __( 'Theme Options', 'business-trust' ), 'priority' => 1, 'capability' => 'edit_theme_options', ) ); // Setting show_title. $wp_customize->add_setting( 'theme_options[show_title]', array( 'default' => $default['show_title'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'business_trust_sanitize_checkbox', ) ); $wp_customize->add_control( 'theme_options[show_title]', array( 'label' => __( 'Show Site Title', 'business-trust' ), 'section' => 'title_tagline', 'type' => 'checkbox', 'priority' => 10, ) ); // Setting show_tagline. $wp_customize->add_setting( 'theme_options[show_tagline]', array( 'default' => $default['show_tagline'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'business_trust_sanitize_checkbox', ) ); $wp_customize->add_control( 'theme_options[show_tagline]', array( 'label' => __( 'Show Tagline', 'business-trust' ), 'section' => 'title_tagline', 'type' => 'checkbox', 'priority' => 11, ) ); /********* * Hero .* *********/ $wp_customize->add_section( 'hero_section' , array( 'title' => __('Hero Section', 'business-trust' ), 'description'=> __('Add hero contents and add a button with a Navigation link.', 'business-trust' ), 'panel' => 'theme_options', ) ); // title $wp_customize->add_setting('hero_title', array( 'default' => __('Add Hero title', 'business-trust'), 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control('hero_title', array( 'label' => __('Add Hero title', 'business-trust'), 'section' => 'hero_section', 'type' => 'text', 'priority' => 1, ) ); $wp_customize->selective_refresh->add_partial( 'hero_title', array( 'selector' => '.callout-title', ) ); // description $wp_customize->add_setting('hero_description', array( 'default' => __('Add Hero Description', 'business-trust'), 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control('hero_description', array( 'label' => __('Add Hero Description', 'business-trust'), 'section' => 'hero_section', 'type' => 'text', ) ); // button text $wp_customize->add_setting('hero_button_text', array( 'default' => __('Add Button Text', 'business-trust'), 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control('hero_button_text', array( 'label' => __('Add Button Text', 'business-trust'), 'section' => 'hero_section', 'type' => 'text', ) ); // button link $wp_customize->add_setting('hero_button_link', array( 'default' => '#', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url', ) ); $wp_customize->add_control('hero_button_link', array( 'label' => __('Add Button Link', 'business-trust'), 'section' => 'hero_section', 'type' => 'url', ) ); $wp_customize->add_setting( 'hero_show_all_pages' , array( 'default' => false, 'capability' => 'edit_theme_options', 'sanitize_callback' => 'business_trust_sanitize_checkbox', )); $wp_customize->add_control('hero_show_all_pages' , array( 'label' => __('Show in all pages','business-trust' ), 'description' => __('(Show hero content in all pages)','business-trust' ), 'section' => 'hero_section', 'type'=> 'checkbox', ) ); // Layout Section. $wp_customize->add_section( 'section_layout', array( 'title' => __( 'Layout', 'business-trust' ), 'capability' => 'edit_theme_options', 'panel' => 'theme_options', ) ); // Setting page_layout. $wp_customize->add_setting( 'theme_options[page_layout]', array( 'default' => $default['page_layout'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'business_trust_sanitize_select', ) ); $wp_customize->add_control( 'theme_options[page_layout]', array( 'label' => __( 'Post / Page Layout', 'business-trust' ), 'section' => 'section_layout', 'type' => 'select', 'choices' => business_trust_get_page_layout_options(), ) ); // Pagination Section. $wp_customize->add_section( 'section_pagination', array( 'title' => __( 'Paging', 'business-trust' ), 'capability' => 'edit_theme_options', 'panel' => 'theme_options', ) ); // Setting pagination_type. $wp_customize->add_setting( 'theme_options[pagination_type]', array( 'default' => $default['pagination_type'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'business_trust_sanitize_select', ) ); $wp_customize->add_control( 'theme_options[pagination_type]', array( 'label' => __( 'Posts Pagination Type', 'business-trust' ), 'section' => 'section_pagination', 'type' => 'select', 'choices' => business_trust_get_pagination_type_options(), ) ); // Footer Section. $wp_customize->add_section( 'section_excerpt', array( 'title' => __( 'Excerpt Length', 'business-trust' ), 'capability' => 'edit_theme_options', 'panel' => 'theme_options', ) ); // Setting Excerpt Length. $wp_customize->add_setting( 'theme_options[excerpt_length]', array( 'default' => $default['excerpt_length'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'business_trust_sanitize_number_range', ) ); $wp_customize->add_control( 'theme_options[excerpt_length]', array( 'label' => __( 'Excerpt Length', 'business-trust' ), 'section' => 'section_excerpt', 'type' => 'number', 'choices' => array( 'min' => 20, 'step'=> 5, ), ) ); // Footer Section. $wp_customize->add_section( 'section_footer', array( 'title' => __( 'Footer', 'business-trust' ), 'capability' => 'edit_theme_options', 'panel' => 'theme_options', ) ); // Setting copyright_text. $wp_customize->add_setting( 'theme_options[copyright_text]', array( 'default' => $default['copyright_text'], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'business_trust_sanitize_footer_content', ) ); $wp_customize->add_control( 'theme_options[copyright_text]', array( 'label' => __( 'Footer Copyright Text', 'business-trust' ), 'section' => 'section_footer', 'type' => 'text', ) ); $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; } add_action( 'customize_register', 'business_trust_customize_register' ); /** * Binds JS handlers in order to Theme Customizer preview reload changes asynchronously. * @since 1.0.3 */ function business_trust_customize_preview_js() { $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_script( 'business-trust-customizer', BUSINESS_TRUST_TEMPLATE_DIR_URI . '/assets/js/customizer' . $min . '.js', array( 'customize-preview' ), '1.1', true ); } add_action( 'customize_preview_init', 'business_trust_customize_preview_js' ); /** * Enqueue styles on customizer preview. */ function business_trust_customizer_styles() { $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; if ( is_customize_preview() ) { // Add custom css for customizer wp_enqueue_style( 'business-trust-customizer', BUSINESS_TRUST_TEMPLATE_DIR_URI . '/assets/css/customizer'. $min .'.css' ); } } add_action( 'customize_controls_print_styles', 'business_trust_customizer_styles' ); /** * Sanitization functions. * @package Business Trust */ if ( ! function_exists( 'business_trust_sanitize_select' ) ) : /** * Sanitize select. * @since 1.0 * @return sanitized value. */ function business_trust_sanitize_select( $input, $setting ) { // Ensure input is a slug. $input = sanitize_key( $input ); // Get list of choices from the control associated with the setting. $choices = $setting->manager->get_control( $setting->id )->choices; // If the input is a valid key, return it; otherwise, return the default. return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } endif; if ( ! function_exists( 'business_trust_sanitize_checkbox' ) ) : /** * Sanitize checkbox. * * @since 1.0 * @param bool $checked Whether the checkbox is checked. * @return bool Whether the checkbox is checked. */ function business_trust_sanitize_checkbox( $checked ) { return ( ( isset( $checked ) && true === $checked ) ? true : false ); } endif; if ( ! function_exists( 'business_trust_sanitize_footer_content' ) ) : /** * Sanitize footer content. * * @since 1.0 * @param string $input Content to be sanitized. * @param WP_Customize_Setting $setting WP_Customize_Setting instance. * @return string Sanitized content. */ function business_trust_sanitize_footer_content( $input, $setting ) { return ( stripslashes( wp_filter_post_kses( addslashes( $input ) ) ) ); } endif; if ( ! function_exists( 'business_trust_sanitize_number_range' ) ) : /** * Number Range sanitization callback. * */ function business_trust_sanitize_number_range( $number, $setting ) { // Ensure input is an absolute integer. $number = absint( $number ); // Get the input attributes associated with the setting. $atts = $setting->manager->get_control( $setting->id )->input_attrs; // Get minimum number in the range. $min = ( isset( $atts['min'] ) ? $atts['min'] : $number ); // Get maximum number in the range. $max = ( isset( $atts['max'] ) ? $atts['max'] : $number ); // Get step. $step = ( isset( $atts['step'] ) ? $atts['step'] : 1 ); // If the number is within the valid range, return it; otherwise, return the default return ( $min <= $number && $number <= $max && is_int( $number / $step ) ? $number : $setting->default ); } endif; /** * Custom callback. * @package Business Trust */ if ( ! function_exists( 'business_trust_is_image_in_archive_active' ) ) : /** * Check if image in archive is active. * @since 1.0 * @param WP_Customize_Control $control WP_Customize_Control instance. * @return bool Whether the control is active to the current preview. */ function business_trust_is_image_in_archive_active( $control ) { if ( 'disable' !== $control->manager->get_setting( 'theme_options[archive_image]' )->value() ) { return true; } else { return false; } } endif;