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;
function business_x_customize_register( $wp_customize ) {
$wp_customize->add_panel(
'business_x_general',
array(
'title' => esc_html__( 'General Settings', 'business-x' ),
'description' => esc_html__('General options','business-x'),
'priority' => 20,
)
);
$wp_customize->get_section('title_tagline')->panel = 'business_x_general';
$wp_customize->get_section('header_image')->panel = 'business_x_general';
$wp_customize->get_section('static_front_page')->panel = 'business_x_general';
$wp_customize->get_section('title_tagline')->title = __('Header Logo','business-x');
if ( isset( $wp_customize->selective_refresh ) ) {
$wp_customize->selective_refresh->add_partial( 'blogname', array(
'selector' => '.site-title a',
'render_callback' => 'business_x_customize_partial_blogname',
) );
$wp_customize->selective_refresh->add_partial( 'blogdescription', array(
'selector' => '.site-description',
'render_callback' => 'business_x_customize_partial_blogdescription',
) );
}
//social icons
$wp_customize->add_section(
'business_x_social_links',
array(
'title' => __('Header Social icons', 'business-x'),
'priority' => 120,
'description' => __( 'In first input box, you need to add FONT AWESOME shortcode which you can find here and in second input box, you need to add your social media profile URL.
Enter the URL of your social accounts. Leave it empty to hide the icon.' , 'business-x'),
'panel' => 'business_x_general'
)
);
$business_x_social_icon = array();
for($i=1;$i <= 5;$i++):
$business_x_social_icon[] = array( 'slug'=>sprintf('business_x_social_icon%d',$i),
'default' => '',
'label' => esc_html__( 'Social icons ', 'business-x' ). $i,
'priority' => sprintf('%d',$i) );
endfor;
foreach($business_x_social_icon as $business_x_social_icons){
$wp_customize->add_setting(
$business_x_social_icons['slug'],
array(
'default' => '',
'capability' => 'edit_theme_options',
'type' => 'theme_mod',
'sanitize_callback' => 'sanitize_text_field',
)
);
$wp_customize->add_control(
$business_x_social_icons['slug'],
array(
'type' => 'text',
'input_attrs' => array( 'placeholder' => esc_attr__('Enter Icon','business-x') ),
'section' => 'business_x_social_links',
'label' => $business_x_social_icons['label'],
'priority' => $business_x_social_icons['priority']
)
);
}
$business_x_social_icon_links = array();
for($i=1;$i <= 5;$i++):
$business_x_social_icon_links[] = array( 'slug'=>sprintf('business_x_social_icon_links%d',$i),
'default' => '',
'label' => esc_html__( 'Social Link ', 'business-x' ) . $i,
'priority' => sprintf('%d',$i) );
endfor;
foreach($business_x_social_icon_links as $business_x_social_icons){
$wp_customize->add_setting(
$business_x_social_icons['slug'],
array(
'default' => '',
'capability' => 'edit_theme_options',
'type' => 'theme_mod',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
$business_x_social_icons['slug'],
array(
'type' => 'text',
'input_attrs' => array( 'placeholder' => esc_attr__('Enter Url','business-x') ),
'section' => 'business_x_social_links',
'priority' => $business_x_social_icons['priority']
)
);
}
/* Site logo*/
$wp_customize->add_setting(
'business_x_dark_logo',
array(
'default' => '',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'absint',
)
);
$wp_customize->add_control( new WP_Customize_Cropped_Image_Control( $wp_customize, 'business_x_dark_logo', array(
'section' => 'title_tagline',
'label' => __( 'Upload Dark Logo (300 x 70)' ,'business-x'),
'flex_width' => true,
'flex_height' => true,
'width' => 120,
'height' => 50,
'priority' => 49,
'default-image' => '',
) ) );
$wp_customize->add_setting(
'logo_height',
array(
'default' => '',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'sanitize_text_field',
)
);
$wp_customize->add_control(
'logo_height',
array(
'section' => 'title_tagline',
'label' => __('Enter Logo Size', 'business-x'),
'description' => __("Use if you want to increase or decrease logo size (optional) Don't enter `px` in the string. e.g. 20 (default: 10px)",'business-x'),
'type' => 'text',
'priority' => 49,
)
);
$wp_customize->add_setting(
'display_fixed_header',
array(
'capability' => 'edit_theme_options',
'sanitize_callback' => 'business_x_field_sanitize_checkbox',
'priority' => 49,
)
);
$wp_customize->add_control(
'display_fixed_header',
array(
'section' => 'title_tagline',
'label' => __('Fixed Header','business-x'),
'type' => 'checkbox',
)
);
//
$wp_customize->add_setting(
'theme_color',
array(
'default' => '#F54307',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'theme_color',
array(
'label' => __('Theme Color ', 'business-x'),
'section' => 'colors',
'priority' => 10
)
)
);
$wp_customize->add_setting(
'secondary_color',
array(
'default' => '#022658',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'sanitize_hex_color',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'secondary_color',
array(
'label' => __('Secondary Color', 'business-x'),
'section' => 'colors',
'priority' => 11
)
)
);
//Add Blog Settings
$wp_customize->add_section( 'blog_settings' , array(
'title' => __( 'Blog (Archive) Settings', 'business-x' ),
'description' => __( 'These settings work for default blog.','business-x' ),
'priority' => 32,
'capability' => 'edit_theme_options',
'panel' => 'business_x_general'
) );
$wp_customize->add_setting(
'blog_sidebar_style',
array(
'default' => 'right_sidebar',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'business_x_field_sanitize_input_choice',
)
);
$wp_customize->add_control(
'blog_sidebar_style',
array(
'section' => 'blog_settings',
'label' => __('Blog Sidebar Style', 'business-x'),
'type' => 'select',
'choices' => array(
'no_sidebar' => __('No Sidebar','business-x'),
'right_sidebar' => __('Right Sidebar','business-x'),
'left_sidebar' => __('Left Sidebar','business-x'),
),
)
);
//blog meta tag
$wp_customize->add_setting(
'blog_meta_tag',
array(
'default' => '0',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'business_x_field_sanitize_input_choice',
)
);
$wp_customize->add_control(
'blog_meta_tag',
array(
'section' => 'blog_settings',
'label' => __('Blog Meta Tag', 'business-x'),
'type' => 'select',
'choices' => array(
'0' => __('Show','business-x'),
'1' => __('Hide','business-x'),
)
)
);
//read more link hide and show
$wp_customize->add_setting(
'read_more_link',
array(
'default' => '0',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'business_x_field_sanitize_input_choice',
)
);
$wp_customize->add_control(
'read_more_link',
array(
'section' => 'blog_settings',
'label' => __('Read More Link ', 'business-x'),
'type' => 'select',
'choices' => array(
'0' => __('Show','business-x'),
'1' => __('Hide','business-x'),
)
)
);
//read more text
$wp_customize->add_setting(
'read_more_button_text',
array(
'default' => 'Continue Reading...',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'sanitize_text_field',
)
);
$wp_customize->add_control(
'read_more_button_text',
array(
'section' => 'blog_settings',
'label' => __('Read More button Text', 'business-x'),
'description' => __("Use if you want to change read more text.",'business-x'),
'type' => 'text',
)
);
//Add single Blog Settings
$wp_customize->add_section( 'single_blog_settings' , array(
'title' => __( 'Single Blog Settings', 'business-x' ),
'priority' => 32,
'capability' => 'edit_theme_options',
'panel' => 'business_x_general'
) );
$wp_customize->add_setting(
'single_sidebar_style',
array(
'default' => 'single_right_sidebar',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'business_x_field_sanitize_input_choice',
)
);
$wp_customize->add_control(
'single_sidebar_style',
array(
'section' => 'single_blog_settings',
'label' => __('Singal Blog Sidebar Style', 'business-x'),
'type' => 'select',
'choices' => array(
'no_sidebar' => __('No Sidebar','business-x'),
'right_sidebar' => __('Right Sidebar','business-x'),
'left_sidebar' => __('Left Sidebar','business-x'),
),
)
);
//singal blog meta tag
$wp_customize->add_setting(
'singal_blog_meta_tag',
array(
'default' => '0',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'business_x_field_sanitize_input_choice',
)
);
$wp_customize->add_control(
'singal_blog_meta_tag',
array(
'section' => 'single_blog_settings',
'label' => __('Singal Blog Meta Tag', 'business-x'),
'type' => 'select',
'choices' => array(
'0' => __('Show','business-x'),
'1' => __('Hide','business-x'),
)
)
);
//category hide and show
$wp_customize->add_setting(
'category_link',
array(
'default' => '0',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'business_x_field_sanitize_input_choice',
)
);
$wp_customize->add_control(
'category_link',
array(
'section' => 'single_blog_settings',
'label' => __('Single Blog Category List ', 'business-x'),
'type' => 'select',
'choices' => array(
'0' => __('Show','business-x'),
'1' => __('Hide','business-x'),
)
)
);
//Footer Section
$wp_customize->add_panel(
'footer',
array(
'title' => __( 'Footer', 'business-x' ),
'description' => __('Footer options','business-x'),
'priority' => 150,
)
);
$wp_customize->add_section( 'footer_copyright_area' , array(
'title' => __( 'Footer Copyright Area', 'business-x' ),
'priority' => 135,
'capability' => 'edit_theme_options',
'panel' => 'footer'
) );
$wp_customize->add_setting(
'Copyright_area_text',
array(
'capability' => 'edit_theme_options',
'sanitize_callback' => 'wp_kses_post',
'priority' => 20,
)
);
$wp_customize->add_control(
'Copyright_area_text',
array(
'section' => 'footer_copyright_area',
'label' => __('Enter Copyright Text','business-x'),
'type' => 'textarea',
)
);
}
add_action( 'customize_register', 'business_x_customize_register' );
/**
* Render the site title for the selective refresh partial.
*
* @return void
*/
function business_x_customize_partial_blogname() {
bloginfo( 'name' );
}
/**
* Render the site tagline for the selective refresh partial.
*
* @return void
*/
function business_x_customize_partial_blogdescription() {
bloginfo( 'description' );
}
function business_x_customs_css()
{
wp_enqueue_style('business-x-style', get_stylesheet_uri(), array());
$custom_css = 'header li a i {
color:#000;
}
h2.entry-title {
margin: 0 0 10px;
}
h2.entry-title a {
color: #000;
}
a:hover, a:focus {
color: #000;
text-decoration: underline;
}
.img_btn a{
background:'.get_theme_mod('theme_color','#F54307').';
}
.read-more-init{
background:'.get_theme_mod('secondary_color','#022658').';
}
aside section h3,.tagcloud a.tag-cloud-link, aside section ul li a:hover, aside section ul li a:focus{
color:'.get_theme_mod('secondary_color','#022658').';
}
.tagcloud a.tag-cloud-link{
border-color:'.get_theme_mod('secondary_color','#022658').';
}
.nav-links span.page-numbers, #return-to-top{
background:'.get_theme_mod('theme_color','#F54307').';
}
.nav-links a.page-numbers{
background:'.get_theme_mod('secondary_color','#022658').';
}
.featured_title h2 span, .everydisc a:hover{
color:'.get_theme_mod('theme_color','#F54307').';
}
';
$logo_height = (get_theme_mod('logo_height'))?(get_theme_mod('logo_height')):55;
$custom_css .=".navbar-header .logo-fixed img, .navbar-header .custom-logo-link .logo-dark {
max-height: ".esc_attr($logo_height)."px;
}";
wp_add_inline_style( 'business-x-style', $custom_css );
$custom_js='';
$display_fixed_header = get_theme_mod('display_fixed_header',true);
if($display_fixed_header)
{
$custom_js = "jQuery(window).scroll(function () {
if (jQuery(window).scrollTop() > 150) {
jQuery('.business_x_navigation').addClass('fixed-header');
} else {
jQuery('.business_x_navigation').removeClass('fixed-header');
}
});";
}
wp_add_inline_script( 'business-x-menu', $custom_js );
}