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 ); } function legal_posts_category(){ $args = array('parent' => 0); $categories = get_categories($args); $category = array(); $category[0]='All'; $i = 0; foreach($categories as $categorys){ if($i==0){ $default = $categorys->slug; $i++; } $category[$categorys->term_id] = $categorys->name; } return $category; } function legal_customize_register( $wp_customize ) { $legal_options = get_option('legal_theme_options'); $wp_customize->add_panel( 'general', array( 'title' => __( 'General', 'legal' ), 'description' => __('styling options','legal'), 'priority' => 20, ) ); //All our sections, settings, and controls will be added here $wp_customize->add_section( 'TopHeaderSocialLinks', array( 'title' => __('Top Header: Social Accounts', 'legal'), 'priority' => 120, 'description' => __( 'In first input box, you need to add FONT AWESOME shortcode which you can find ' , 'legal').''.__('here' , 'legal').''.__(' and in second input box, you need to add your social media profile URL.', 'legal').'
'.__(' Enter the URL of your social accounts. Leave it empty to hide the icon.' , 'legal'), 'panel' => 'general' ) ); $TopHeaderSocialIconDefault = array( array('url'=>isset($legal_options['facebook'])?$legal_options['facebook']:'','icon'=>'fa-facebook'), array('url'=>isset($legal_options['twitter'])?$legal_options['twitter']:'','icon'=>'fa-twitter'), array('url'=>isset($legal_options['pinterest'])?$legal_options['pinterest']:'','icon'=>'fa-pinterest'), array('url'=>isset($legal_options['gplus'])?$legal_options['gplus']:'','icon'=>'fa-google-plus'), ); $TopHeaderSocialIcon = array(); for($i=1;$i <= 4;$i++): $TopHeaderSocialIcon[] = array( 'slug'=>sprintf('TopHeaderSocialIcon%d',$i), 'default' => $TopHeaderSocialIconDefault[$i-1]['icon'], 'label' => esc_html__( 'Social Account ', 'legal') .$i, 'priority' => sprintf('%d',$i) ); endfor; foreach($TopHeaderSocialIcon as $TopHeaderSocialIcons){ $wp_customize->add_setting( $TopHeaderSocialIcons['slug'], array( 'default' => $TopHeaderSocialIcons['default'], 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( $TopHeaderSocialIcons['slug'], array( 'type' => 'text', 'section' => 'TopHeaderSocialLinks', 'input_attrs' => array( 'placeholder' => esc_attr__('fa fa-legal','legal') ), 'label' => $TopHeaderSocialIcons['label'], 'priority' => $TopHeaderSocialIcons['priority'] ) ); } $TopHeaderSocialIconLink = array(); for($i=1;$i <= 4;$i++): $TopHeaderSocialIconLink[] = array( 'slug'=>sprintf('TopHeaderSocialIconLink%d',$i), 'default' => $TopHeaderSocialIconDefault[$i-1]['url'], 'label' => esc_html__( 'Social Link ', 'legal' ) .$i, 'priority' => sprintf('%d',$i) ); endfor; foreach($TopHeaderSocialIconLink as $TopHeaderSocialIconLinks){ $wp_customize->add_setting( $TopHeaderSocialIconLinks['slug'], array( 'default' => $TopHeaderSocialIconLinks['default'], 'capability' => 'edit_theme_options', 'type' => 'theme_mod', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize->add_control( $TopHeaderSocialIconLinks['slug'], array( 'type' => 'text', 'section' => 'TopHeaderSocialLinks', 'priority' => $TopHeaderSocialIconLinks['priority'], 'input_attrs' => array( 'placeholder' => esc_html__('Enter URL','legal')), ) ); } $wp_customize->get_section('title_tagline')->panel = 'general'; $wp_customize->get_section('static_front_page')->panel = 'general'; $wp_customize->get_section('header_image')->panel = 'general'; $wp_customize->get_section('title_tagline')->title = __('Header & Logo','legal'); $wp_customize->add_section( 'headerNlogo', array( 'title' => __('Header & Logo','legal'), 'panel' => 'general' ) ); $wp_customize->add_setting( 'theme_logo_height', array( 'default' => '', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( 'theme_logo_height', array( 'section' => 'title_tagline', 'label' => __('Enter Logo Size', 'legal'), 'description' => __("Use if you want to increase or decrease logo size (optional) Don't enter `px` in the string. e.g. 20 (default: 40px)",'legal'), 'type' => 'text', 'priority' => 50, ) ); $wp_customize->add_section( 'TopHeaderOthersettings', array( 'title' => __('Top Header : Other settings', 'legal'), 'description' => __('Contact Email , Contact number which you like to display in the Top Header','legal'), 'priority' => 120, 'panel' => 'general' ) ); $wp_customize->add_setting( 'theme_email_id', array( 'default' => isset($legal_options['email'])?$legal_options['email']:'', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'theme_email_id', array( 'section' => 'TopHeaderOthersettings', 'label' => __('Enter Email id', 'legal'), 'description' => __("Enter e-mail id for your site .",'legal'), 'type' => 'text', 'input_attrs' => array( 'placeholder' => esc_html__('Enter Email','legal')), 'priority' => 50, ) ); $wp_customize->add_setting( 'theme_contact_title', array( 'default' => isset($legal_options['number-title'])?$legal_options['number-title']:'', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'theme_contact_title', array( 'section' => 'TopHeaderOthersettings', 'label' => __('Enter Contact Title Text', 'legal'), 'description' => __("Enter Contact title Text here .",'legal'), 'input_attrs' => array( 'placeholder' => esc_html__('Enter Contact title text','legal')), 'type' => 'text', 'priority' => 54, ) ); $wp_customize->add_setting( 'theme_phone_number', array( 'default' => isset($legal_options['number'])?$legal_options['number']:'', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'theme_phone_number', array( 'section' => 'TopHeaderOthersettings', 'label' => __('Enter Contact Number', 'legal'), 'description' => __("Enter Contact number for your site .",'legal'), 'input_attrs' => array( 'placeholder' => esc_html__('Enter Contact number','legal')), 'type' => 'text', 'priority' => 54, ) ); /*-------------------- Home Page Option Setting --------------------------*/ $wp_customize->add_panel( 'frontpage_section', array( 'title' => __( 'Front Page Options', 'legal' ), 'description' => __('Front Page options','legal'), 'priority' => 20, ) ); $wp_customize->add_section( 'frontpage_slider_section' , array( 'title' => __( 'Front Page : Banner Slider', 'legal' ), 'priority' => 32, 'capability' => 'edit_theme_options', 'panel' => 'frontpage_section' ) ); for($i=1;$i <= 5;$i++): $wp_customize->add_setting( 'legal_homepage_sliderimage'.$i.'_image', array( 'default' => isset($legal_options['slider-img-'.$i])?legal_get_image_id($legal_options['slider-img-'.$i]):'', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( new WP_Customize_Cropped_Image_Control( $wp_customize, 'legal_homepage_sliderimage'.$i.'_image', array( 'section' => 'frontpage_slider_section', 'label' => __( 'Upload Slider Image ' ,'legal').$i, 'description' => __( 'Image (Recommended Size : 1350px * 539px)' ,'legal'), 'flex_width' => true, 'flex_height' => true, 'width' => 1350, 'height' => 539, 'default-image' => '', ) ) ); $wp_customize->add_setting( 'legal_homepage_sliderimage'.$i.'_icon', array( 'default' => $legal_options['slidecaption-one-' . $i], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', 'priority' => 19, ) ); $wp_customize->add_control( 'legal_homepage_sliderimage'.$i.'_icon', array( 'section' => 'frontpage_slider_section', 'label' => __('Icon Class Name ','legal').$i, 'type' => 'text', 'input_attrs' => array( 'placeholder' => esc_html__('Enter Slider Icon class name (i.e fa-inr)','legal')), ) ); $wp_customize->add_setting( 'legal_homepage_sliderimage'.$i.'_title', array( 'default' => $legal_options['slidecaption-one-' . $i], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', 'priority' => 20, ) ); $wp_customize->add_control( 'legal_homepage_sliderimage'.$i.'_title', array( 'section' => 'frontpage_slider_section', 'label' => __('First Caption ','legal').$i, 'type' => 'text', 'input_attrs' => array( 'placeholder' => esc_html__('Enter Slider First Caption','legal')), ) ); $wp_customize->add_setting( 'legal_homepage_sliderimage'.$i.'_content', array( 'default' => $legal_options['slidecaption-second-' . $i], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', 'priority' => 22, ) ); $wp_customize->add_control( 'legal_homepage_sliderimage'.$i.'_content', array( 'section' => 'frontpage_slider_section', 'label' => __('Second Caption ','legal').$i, 'type' => 'text', 'input_attrs' => array( 'placeholder' => esc_html__('Enter Slider Second Caption','legal')), ) ); $wp_customize->add_setting( 'legal_homepage_sliderimage'.$i.'_btn_text', array( 'default' => $legal_options['slidebuttontext-' . $i], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', 'priority' => 22, ) ); $wp_customize->add_control( 'legal_homepage_sliderimage'.$i.'_btn_text', array( 'section' => 'frontpage_slider_section', 'label' => __('Button Text ','legal').$i, 'type' => 'text', 'input_attrs' => array( 'placeholder' => esc_html__('Enter Slider Button Text','legal')), ) ); $wp_customize->add_setting( 'legal_homepage_sliderimage'.$i.'_link', array( 'default' => $legal_options['slidebuttonlink-'.$i], 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw', 'priority' => 20, ) ); $wp_customize->add_control( 'legal_homepage_sliderimage'.$i.'_link', array( 'section' => 'frontpage_slider_section', 'label' => __('Link URL ','legal').$i, 'type' => 'text', 'input_attrs' => array( 'placeholder' => esc_html__('Enter Slider URL','legal')), ) ); endfor; //Title Bar $wp_customize->add_section( 'frontpage_title_bar_section' , array( 'title' => __( 'Front Page : Title Bar', 'legal' ), 'priority' => 32, 'capability' => 'edit_theme_options', 'panel' => 'frontpage_section' ) ); $wp_customize->add_setting( 'legal_homepage_section_title', array( 'default' => isset($legal_options['home-title'])?$legal_options['home-title']:'', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', 'priority' => 20, ) ); $wp_customize->add_control( 'legal_homepage_section_title', array( 'section' => 'frontpage_title_bar_section', 'label' => __('Enter Title ','legal'), 'description' => __("Enter home page title for your site , you would like to display in the Home Page.",'legal'), 'type' => 'text', 'input_attrs' => array( 'placeholder' => esc_html__('Enter Title','legal')), ) ); $wp_customize->add_setting( 'legal_homepage_section_desc', array( 'default' => isset($legal_options['home-content'])?$legal_options['home-content']:'', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'wp_kses_post', 'priority' => 20, ) ); $wp_customize->add_control( 'legal_homepage_section_desc', array( 'section' => 'frontpage_title_bar_section', 'label' => __('Enter Short Description ','legal'), 'description' => __("Enter content for your site , you would like to display in the Home Page.",'legal'), 'type' => 'textarea', 'input_attrs' => array( 'placeholder' => esc_html__('Enter Description','legal')), ) ); /* Front page First section */ $wp_customize->add_section( 'frontpage_first_section' , array( 'title' => __( 'Front Page : Benefits Section', 'legal' ), 'priority' => 32, 'capability' => 'edit_theme_options', 'panel' => 'frontpage_section' ) ); /*legal_homepage_sectionswitch*/ $wp_customize->add_setting( 'legal_homepage_first_sectionswitch', array( 'default' => '1', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'legal_field_sanitize_input_choice', ) ); $wp_customize->add_control( 'legal_homepage_first_sectionswitch', array( 'section' => 'frontpage_first_section', 'label' => __('Benefits Section', 'legal'), 'description' => __('Benefits Section hide or show .','legal'), 'type' => 'select', 'choices' => array( "1" => esc_html__( "Show", 'legal' ), "2" => esc_html__( "Hide", 'legal' ), ), ) ); $wp_customize->add_setting( 'legal_homepage_first_section_title', array( 'default' => isset($legal_options['benifits-title'])?$legal_options['benifits-title']:'', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', 'priority' => 20, ) ); $wp_customize->add_control( 'legal_homepage_first_section_title', array( 'section' => 'frontpage_first_section', 'label' => __('Enter Title ','legal'), 'description' => __("Enter Benefits title for your site , you would like to display in the Home Page.",'legal'), 'type' => 'text', 'input_attrs' => array( 'placeholder' => esc_html__('Enter Title','legal')), ) ); $wp_customize->add_setting( 'legal_homepage_first_section_desc', array( 'default' => isset($legal_options['benifits-content'])?$legal_options['benifits-content']:'', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'wp_kses_post', 'priority' => 20, ) ); $wp_customize->add_control( 'legal_homepage_first_section_desc', array( 'section' => 'frontpage_first_section', 'label' => __('Enter Short Description ','legal'), 'description' => __("Enter Benefits content for your site , you would like to display in the Home Page.",'legal'), 'type' => 'textarea', 'input_attrs' => array( 'placeholder' => esc_html__('Enter Short Description','legal')), ) ); for($i=1;$i <= 8;$i++): $wp_customize->add_setting( 'legal_homepage_first_section'.$i.'_icon', array( 'default' => isset($legal_options['faicons-' . $i])?$legal_options['faicons-' . $i]:'', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', 'priority' => 20, ) ); $wp_customize->add_control( 'legal_homepage_first_section'.$i.'_icon', array( 'section' => 'frontpage_first_section', 'label' => __('Enter Font Awesome Icon Code ','legal').$i, 'type' => 'text', 'input_attrs' => array( 'placeholder' => esc_html__('fa fa-legal','legal')), ) ); $wp_customize->add_setting( 'legal_homepage_first_section'.$i.'_title', array( 'default' => isset($legal_options['section-title-' . $i])?$legal_options['section-title-' . $i]:'', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', 'priority' => 20, ) ); $wp_customize->add_control( 'legal_homepage_first_section'.$i.'_title', array( 'section' => 'frontpage_first_section', 'label' => __('Enter Benefit Title ','legal').$i, 'type' => 'text', 'input_attrs' => array( 'placeholder' => esc_html__('Enter title','legal')), ) ); endfor; /*----------------------------------------------------------------------------------------*/ /* Front page First section */ $wp_customize->add_section( 'frontpage_background_section' , array( 'title' => __( 'Front Page : Background Section', 'legal' ), 'priority' => 32, 'capability' => 'edit_theme_options', 'panel' => 'frontpage_section' ) ); /*legal_homepage_background_sectionswitch*/ $wp_customize->add_setting( 'legal_homepage_background_sectionswitch', array( 'default' => '1', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'legal_field_sanitize_input_choice', ) ); $wp_customize->add_control( 'legal_homepage_background_sectionswitch', array( 'section' => 'frontpage_background_section', 'label' => __('Benefits Section', 'legal'), 'description' => __('Benefits Section hide or show .','legal'), 'type' => 'select', 'choices' => array( "1" => esc_html__( "Show", 'legal' ), "2" => esc_html__( "Hide", 'legal' ), ), ) ); $wp_customize->add_setting( 'legal_homepage_background_section_image', array( 'default' => isset($legal_options['bg-img'])?legal_get_image_id($legal_options['bg-img']):'', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( new WP_Customize_Cropped_Image_Control( $wp_customize, 'legal_homepage_background_section_image', array( 'section' => 'frontpage_background_section', 'label' => __( 'Upload Benefit Image ' ,'legal'), 'description' => __( 'Image (Recommended Size : 362px * 400px)' ,'legal'), 'flex_width' => true, 'flex_height' => true, 'width' => 362, 'height' => 400, 'default-image' => '', ) ) ); $wp_customize->add_setting( 'legal_homepage_background_section_title', array( 'default' => isset($legal_options['bg-title'])?$legal_options['bg-title']:'', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', 'priority' => 20, ) ); $wp_customize->add_control( 'legal_homepage_background_section_title', array( 'section' => 'frontpage_background_section', 'label' => __('Enter Title ','legal'), 'type' => 'text', 'input_attrs' => array( 'placeholder' => esc_html__('Enter title','legal')), ) ); $wp_customize->add_setting( 'legal_homepage_background_section_btn_title', array( 'default' => isset($legal_options['bg-btn-title'])?$legal_options['bg-btn-title']:'', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', 'priority' => 20, ) ); $wp_customize->add_control( 'legal_homepage_background_section_btn_title', array( 'section' => 'frontpage_background_section', 'label' => __('Enter Button Title ','legal'), 'type' => 'text', 'input_attrs' => array( 'placeholder' => esc_html__('Enter Button title','legal')), ) ); $wp_customize->add_setting( 'legal_homepage_background_section_link', array( 'default' => isset($legal_options['bg-btn-link'])?$legal_options['bg-btn-link']:'', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw', 'priority' => 20, ) ); $wp_customize->add_control( 'legal_homepage_background_section_link', array( 'section' => 'frontpage_background_section', 'label' => __('Enter Benefit Link ','legal'), 'type' => 'text', 'input_attrs' => array( 'placeholder' => esc_html__('Enter URL','legal')), ) ); /* Front page Recent Post section */ $wp_customize->add_section( 'frontpage_second_section' , array( 'title' => __( 'Front Page : Recent Post Section', 'legal' ), 'priority' => 32, 'capability' => 'edit_theme_options', 'panel' => 'frontpage_section' ) ); /*legal_homepage_sectionswitch*/ $wp_customize->add_setting( 'legal_homepage_second_sectionswitch', array( 'default' => '1', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'legal_field_sanitize_input_choice', ) ); $wp_customize->add_control( 'legal_homepage_second_sectionswitch', array( 'section' => 'frontpage_second_section', 'label' => __('Recent Post Section', 'legal'), 'description' => __('Recent Post Section hide or show .','legal'), 'type' => 'select', 'choices' => array( "1" => esc_html__( "Show", 'legal' ), "2" => esc_html__( "Hide", 'legal' ), ), ) ); $wp_customize->add_setting( 'legal_homepage_second_section_title', array( 'default' => isset($legal_options['post-title'])?$legal_options['post-title']:'', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', 'priority' => 20, ) ); $wp_customize->add_control( 'legal_homepage_second_section_title', array( 'section' => 'frontpage_second_section', 'label' => __('Enter Recent Post Section Title ','legal'), 'type' => 'text', 'input_attrs' => array( 'placeholder' => esc_html__('Enter Title','legal')), ) ); $wp_customize->add_setting( 'legal_homepage_second_section_desc', array( 'default' => isset($legal_options['post-content'])?$legal_options['post-content']:'', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'wp_kses_post', 'priority' => 20, ) ); $wp_customize->add_control( 'legal_homepage_second_section_desc', array( 'section' => 'frontpage_second_section', 'label' => __('Enter Short Description','legal'), 'type' => 'textarea', 'input_attrs' => array( 'placeholder' => esc_html__('Enter Description','legal')), ) ); $wp_customize->add_setting( 'legal_homepage_second_section_category', array( 'default' => isset($legal_options['post-category'])?$legal_options['post-category']:'1', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'legal_field_sanitize_input_choice', ) ); $wp_customize->add_control( 'legal_homepage_second_section_category', array( 'section' => 'frontpage_second_section', 'label' => __('Select Category', 'legal'), 'description' => __('Select Categories of posts for your site , you would like to display in the Home Page.','legal'), 'type' => 'select', 'choices' => legal_posts_category(), ) ); $wp_customize->add_setting( 'legal_homepage_second_section_postperpage', array( 'default' => isset($legal_options['posts-per-page-home'])?$legal_options['posts-per-page-home']:6, 'capability' => 'edit_theme_options', 'sanitize_callback' => 'absint', 'priority' => 20, ) ); $wp_customize->add_control( 'legal_homepage_second_section_postperpage', array( 'section' => 'frontpage_second_section', 'label' => __('Enter number of blog items , you would like to display in the home page. ','legal'), 'type' => 'text', 'input_attrs' => array( 'placeholder' => esc_html__('Enter Number','legal')), ) ); //Footer Section $wp_customize->add_section( 'footerCopyright' , array( 'title' => __( 'Footer', 'legal' ), 'priority' => 100, 'capability' => 'edit_theme_options', ) ); $wp_customize->add_setting( 'footertext', array( 'default' => isset($legal_options['copyright-text'])?$legal_options['copyright-text']:'', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'wp_kses_post', 'priority' => 20, ) ); $wp_customize->add_control( 'footertext', array( 'section' => 'footerCopyright', 'label' => __('Enter Copyright Text','legal'), 'type' => 'textarea', ) ); // Text Panel Starts Here } add_action( 'customize_register', 'legal_customize_register' ); function legal_custom_css(){ $legal_options = get_option('legal_theme_options'); $custom_css=''; $theme_logo_height = (get_theme_mod('theme_logo_height'))?(get_theme_mod('theme_logo_height')):40; $custom_css.= ".logo-fixed img{ max-height: ".esc_attr($theme_logo_height)."px; }"; $image_id = get_theme_mod('legal_homepage_background_section_image',isset($legal_options['bg-img'])?legal_get_image_id($legal_options['bg-img']):''); $bg_image_url = wp_get_attachment_image_src($image_id,'full'); if(!empty($bg_image_url)): $custom_css.= '.home-image-section { background :url("'. esc_url($bg_image_url[0]) .'"); }'; endif; wp_add_inline_style( 'legal-style', $custom_css ); }