/**
* Defines customizer options
*
* This file is loaded at 'after_setup_theme' hook with 10 priority.
*
* @package hoot
* @subpackage responsive-brix
* @since responsive-brix 2.0
*/
/**
* Build the Customizer options (panels, sections, settings)
*
* Always remember to mention specific priority for non-static options like:
* - options being added based on a condition (eg: if woocommerce is active)
* - options which may get removed (eg: logo_size, headings_fontface)
* - options which may get rearranged (eg: logo_background_type)
* This will allow other options inserted with priority to be inserted at
* their intended place.
*
* @since 2.0
* @access public
* @return array
*/
if ( !function_exists( 'hoot_theme_customizer_options' ) ) :
function hoot_theme_customizer_options() {
// Stores all the settings to be added
$settings = array();
// Stores all the sections to be added
$sections = array();
// Stores all the panels to be added
$panels = array();
// Theme defaults
extract( apply_filters( 'hoot_theme_options_defaults', array(
'accent_color' => '#f3595b',
'accent_font' => '#ffffff',
'box_background' => '#ffffff',
'site_background' => '#ffffff',
// 'font_size' => '14px',
// 'font_face' => '"Open Sans", sans-serif',
// 'font_style' => 'none',
// 'font_color' => '#666666',
) ) );
// Directory path for radioimage buttons
$imagepath = trailingslashit( HOOT_THEMEURI ) . 'admin/images/';
// Logo Sizes (different range than standard typography range)
$logosizes = array();
$logosizerange = range( 14, 110 );
foreach ( $logosizerange as $isr )
$logosizes[ $isr . 'px' ] = $isr . 'px';
$logosizes = apply_filters( 'hoot_theme_options_logosizes', $logosizes);
// Logo Font Options for Lite version
$logofont = apply_filters( 'hoot_theme_options_logofont', array(
'heading' => __("Heading Font (set in 'Typography' section)", 'responsive-brix'),
'standard' => __('Standard Body Font', 'responsive-brix'),
) );
/*** Add Options (Panels, Sections, Settings) ***/
/** Section **/
$section = 'links';
$sections[ $section ] = array(
'title' => __( 'Demo / Support', 'responsive-brix' ),
'priority' => '2',
);
$lcontent = '';
$lcontent .= '' .
' ' .
__( "Demo", 'responsive-brix') .
'' .
__( "Demo the theme features and options with sample content.", 'responsive-brix') .
'';
$ocdilink = ( class_exists( 'Hoot_Premium_Theme' ) ) ? ( ( class_exists( 'OCDI_Plugin' ) ) ? admin_url( 'themes.php?page=pt-one-click-demo-import' ) : 'https://wphoot.com/support/responsive-brix/#docs-section-demo-content' ) : 'https://wphoot.com/support/responsive-brix/#docs-section-demo-content-free';
$lcontent .= '' .
' ' .
esc_html__( "1 Click Installation", 'responsive-brix') .
'' .
esc_html__( "Install demo content to make your site look exactly like the Demo Site. Use it as a starting point instead of starting from scratch.", 'responsive-brix') .
'';
$lcontent .= '' .
' ' .
__( "Documentation / Support", 'responsive-brix') .
'' .
__( "Get theme related support for both free and premium users.", 'responsive-brix') .
'';
$lcontent .= '' .
'5 ' .
__( "Rate Us", 'responsive-brix') .
'' .
__( "If you are happy with the theme, give us a 5 star rating on wordpress.org", 'responsive-brix') .
'';
$settings['linksection'] = array(
// 'label' => __( 'Misc Links', 'responsive-brix' ),
'section' => $section,
'type' => 'content',
'priority' => '8', // Non static options must have a priority
'content' => $lcontent,
);
/** Section **/
$section = 'title_tagline';
$sections[ $section ] = array(
'title' => __( 'Setup & Layout', 'responsive-brix' ),
);
$settings['site_layout'] = array(
'label' => __( 'Site Layout - Boxed vs Stretched', 'responsive-brix' ),
'section' => $section,
'type' => 'radio',
'choices' => array(
'boxed' => __('Boxed layout', 'responsive-brix'),
'stretch' => __('Stretched layout (full width)', 'responsive-brix'),
),
'default' => 'stretch',
'description' => __("For boxed layouts, both backgrounds (site and content box) can be set in the 'Backgrounds' section.
For Stretched Layout, only site background is available.", 'responsive-brix'),
);
$settings['site_width'] = array(
'label' => __( 'Max. Site Width (pixels)', 'responsive-brix' ),
'section' => $section,
'type' => 'radio',
'choices' => array(
'1260' => __('1260px (wide)', 'responsive-brix'),
'1080' => __('1080px (standard)', 'responsive-brix'),
),
'default' => '1260',
);
$settings['mobile_menu'] = array(
'label' => __( 'Mobile Menu', 'responsive-brix' ),
'section' => $section,
'type' => 'radio',
'choices' => array(
'inline' => __('Inline - Menu Slide Downs to open', 'responsive-brix'),
'fixed' => __('Fixed - Menu opens on the left', 'responsive-brix'),
),
'default' => 'fixed',
'priority' => '25', // @todo remove
);
$settings['mobile_submenu_click'] = array(
'label' => __( "[Mobile Menu] Submenu opens on 'Click'", 'responsive-brix' ),
'section' => $section,
'type' => 'checkbox',
'default' => 1,
'priority' => '25', // @todo remove
'description' => __( "Uncheck this option to make all Submenus appear in 'Open' state. By default, submenus open on clicking (i.e. single tap on mobile).", 'responsive-brix' ),
);
$settings['load_minified'] = array(
'label' => __( 'Load Minified Styles and Scripts (when available)', 'responsive-brix' ),
'sublabel' => __( 'Checking this option reduces data size, hence increasing page load speed.', 'responsive-brix' ),
'section' => $section,
'type' => 'checkbox',
// 'default' => 1,
);
$settings['sidebar_desc'] = array(
'label' => __( 'Multiple Sidebars', 'responsive-brix' ),
'section' => $section,
'type' => 'content',
'content' => sprintf( __( 'This theme can display different sidebar content on different pages of your site with the %1sCustom Sidebars%2s plugin. Simply install and activate the plugin to use it with this theme. Or if you are using %3sJetpack%4s, you can use the %5s"Widget Visibility"%6s module.', 'responsive-brix' ), '', '', '', '', '', '' ),
);
$settings['sidebar'] = array(
'label' => __( 'Sidebar Layout (Site-wide)', 'responsive-brix' ),
'section' => $section,
'type' => 'radioimage',
'choices' => array(
'wide-right' => $imagepath . 'sidebar-wide-right.png',
'narrow-right' => $imagepath . 'sidebar-narrow-right.png',
'wide-left' => $imagepath . 'sidebar-wide-left.png',
'narrow-left' => $imagepath . 'sidebar-narrow-left.png',
'none' => $imagepath . 'sidebar-none.png',
),
'default' => 'wide-right',
);
$settings['sidebar_archives'] = array(
'label' => __( 'Sidebar Layout (for Blog/Archives)', 'responsive-brix' ),
'section' => $section,
'type' => 'radioimage',
'choices' => array(
'wide-right' => $imagepath . 'sidebar-wide-right.png',
'narrow-right' => $imagepath . 'sidebar-narrow-right.png',
'wide-left' => $imagepath . 'sidebar-wide-left.png',
'narrow-left' => $imagepath . 'sidebar-narrow-left.png',
'none' => $imagepath . 'sidebar-none.png',
),
'default' => 'wide-right',
'description' => __("Set the default sidebar width and position for blog and archives pages like categories, tags etc.", 'responsive-brix'),
);
$settings['sidebar_pages'] = array(
'label' => __( 'Sidebar Layout (for Pages)', 'responsive-brix' ),
'section' => $section,
'type' => 'radioimage',
'choices' => array(
'wide-right' => $imagepath . 'sidebar-wide-right.png',
'narrow-right' => $imagepath . 'sidebar-narrow-right.png',
'wide-left' => $imagepath . 'sidebar-wide-left.png',
'narrow-left' => $imagepath . 'sidebar-narrow-left.png',
'none' => $imagepath . 'sidebar-none.png',
),
'default' => 'wide-right',
);
$settings['sidebar_posts'] = array(
'label' => __( 'Sidebar Layout (for single Posts)', 'responsive-brix' ),
'section' => $section,
'type' => 'radioimage',
'choices' => array(
'wide-right' => $imagepath . 'sidebar-wide-right.png',
'narrow-right' => $imagepath . 'sidebar-narrow-right.png',
'wide-left' => $imagepath . 'sidebar-wide-left.png',
'narrow-left' => $imagepath . 'sidebar-narrow-left.png',
'none' => $imagepath . 'sidebar-none.png',
),
'default' => 'wide-right',
);
if ( current_theme_supports( 'woocommerce' ) ) :
$settings['sidebar_wooshop'] = array(
'label' => __( 'Sidebar Layout (Woocommerce Shop/Archives)', 'responsive-brix' ),
'section' => $section,
'type' => 'radioimage',
'priority' => '83', // Non static options must have a priority
'choices' => array(
'wide-right' => $imagepath . 'sidebar-wide-right.png',
'narrow-right' => $imagepath . 'sidebar-narrow-right.png',
'wide-left' => $imagepath . 'sidebar-wide-left.png',
'narrow-left' => $imagepath . 'sidebar-narrow-left.png',
'none' => $imagepath . 'sidebar-none.png',
),
'default' => 'wide-right',
'description' => __("Set the default sidebar width and position for WooCommerce shop and archives pages like product categories etc.", 'responsive-brix'),
);
$settings['sidebar_wooproduct'] = array(
'label' => __( 'Sidebar Layout (Woocommerce Single Product Page)', 'responsive-brix' ),
'section' => $section,
'type' => 'radioimage',
'priority' => '83', // Non static options must have a priority
'choices' => array(
'wide-right' => $imagepath . 'sidebar-wide-right.png',
'narrow-right' => $imagepath . 'sidebar-narrow-right.png',
'wide-left' => $imagepath . 'sidebar-wide-left.png',
'narrow-left' => $imagepath . 'sidebar-narrow-left.png',
'none' => $imagepath . 'sidebar-none.png',
),
'default' => 'wide-right',
'description' => __("Set the default sidebar width and position for WooCommerce product pages", 'responsive-brix'),
);
endif;
/** Section **/
$section = 'logo';
$sections[ $section ] = array(
'title' => __( 'Logo', 'responsive-brix' ),
);
$settings['logo_background_type'] = array(
'label' => __( 'Logo Background', 'responsive-brix' ),
'section' => $section,
'type' => 'radio',
'priority' => '85', // Non static options must have a priority
'choices' => array(
'transparent' => __('None', 'responsive-brix'),
'accent' => __('Accent Color', 'responsive-brix'),
),
'default' => 'accent',
);
$settings['logo'] = array(
'label' => __( 'Site Logo', 'responsive-brix' ),
'section' => $section,
'type' => 'radio',
'choices' => array(
'text' => __('Default Text (Site Title)', 'responsive-brix'),
'custom' => __('Custom Text', 'responsive-brix'),
'image' => __('Image Logo', 'responsive-brix'),
'mixed' => __('Image & Default Text (Site Title)', 'responsive-brix'),
'mixedcustom' => __('Image & Custom Text', 'responsive-brix'),
),
'default' => 'text',
'description' => sprintf( __('Use %sSite Title%s as default text logo', 'responsive-brix'), '', '' ),
);
$settings['logo_size'] = array(
'label' => __( 'Logo Size', 'responsive-brix' ),
'section' => $section,
'type' => 'select',
'priority' => '95', // Non static options must have a priority
'choices' => array(
'tiny' => __( 'Tiny', 'responsive-brix'),
'small' => __( 'Small', 'responsive-brix'),
'medium' => __( 'Medium', 'responsive-brix'),
'large' => __( 'Large', 'responsive-brix'),
'huge' => __( 'Huge', 'responsive-brix'),
),
'default' => 'medium',
'active_callback' => 'hoot_callback_logo_size',
); // Removed in premium
$settings['site_title_icon'] = array(
'label' => __( 'Site Title Icon (Optional)', 'responsive-brix' ),
'section' => $section,
'type' => 'icon',
// 'default' => 'fa-anchor fas',
'description' => __( 'Leave empty to hide icon.', 'responsive-brix' ),
'active_callback' => 'hoot_callback_site_title_icon',
);
$settings['site_title_icon_size'] = array(
'label' => __( 'Site Title Icon Size', 'responsive-brix' ),
'section' => $section,
'type' => 'select',
'choices' => $logosizes,
'default' => '50px',
'active_callback' => 'hoot_callback_site_title_icon',
);
$settings['logo_image_width'] = array(
'label' => __( 'Maximum Logo Width', 'responsive-brix' ),
'section' => $section,
'type' => 'text',
'priority' => '116', // Keep it with logo image ( 'custom_logo' )->priority logo
'default' => 200,
'description' => __( '(in pixels)
'Widgetized Template' is a special Page Template which is often used as a quick way to create a Front Page.
This is a sample description text for the slide.
', 'responsive-brix'), 'description' => __('You can use the<h3>Lorem Ipsum Dolor</h3>
tag to create styled heading.', 'responsive-brix'),
),
'button' => array(
'label' => __( 'Button Text', 'responsive-brix' ),
'type' => 'text',
),
'url' => array(
'label' => __( 'Button URL', 'responsive-brix' ),
'type' => 'url',
'description' => __( 'Leave empty if you do not want to show the button.', 'responsive-brix' ),
'input_attrs' => array(
'placeholder' => 'http://',
),
),
),
);
$settings["wt_html_slide_{$slide}-background"] = array(
'label' => sprintf( __( 'Slide %s Background', 'responsive-brix' ), $slide),
'section' => $section,
'type' => 'betterbackground',
'priority' => 185, // Non static options must have a priority
'default' => array(
'color' => '#ffffff',
),
'options' => array( 'color', 'image', 'pattern' ),
);
} // end for
/** Section **/
$section = 'slider_img';
$sections[ $section ] = array(
'title' => __( 'Widgetized Template - Image Slider', 'responsive-brix' ),
// 'description' => __( 'The premium version comes with a separate Slider type allowing creation of Unlimited slides.', 'responsive-brix' ),
);
$settings['wt_img_slider_width'] = array(
'label' => __( 'Slider Width', 'responsive-brix' ),
'sublabel' => __("Note: This option is useful only if the Site Layout option is set to Stretched in 'Setup & Layout' section.", 'responsive-brix'),
'section' => $section,
'type' => 'radioimage',
'choices' => array(
'boxed' => $imagepath . 'slider-width-boxed.png',
'stretch' => $imagepath . 'slider-width-stretch.png',
),
'default' => 'boxed',
);
for ( $slide = 1; $slide <= 4; $slide++ ) {
$settings["wt_img_slide_{$slide}"] = array(
'label' => '',//sprintf( __( 'Slide %s Content', 'responsive-brix' ), $slide),
'section' => $section,
'type' => 'group',
'priority' => 195, // Non static options must have a priority
'button' => sprintf( __( 'Edit Slide %s', 'responsive-brix' ), $slide),
'options' => array(
'description' => array(
'label' => '',
'type' => 'content',
'content' => '' . sprintf( __( 'Slide %s Content', 'responsive-brix' ), $slide) . '' . __( 'To hide this slide, simply leave the Image empty.', 'responsive-brix' ),
),
'image' => array(
'label' => __( 'Slide Image', 'responsive-brix' ),
'type' => 'image',
'description' => __( 'The main showcase image.', 'responsive-brix' ),
),
'caption' => array(
'label' => __( 'Slide Caption (optional)', 'responsive-brix' ),
'type' => 'text',
),
'url' => array(
'label' => __( 'Slide Link', 'responsive-brix' ),
'type' => 'url',
'description' => __( 'Leave empty if you do not want to link the slide.', 'responsive-brix' ),
'input_attrs' => array(
'placeholder' => 'http://',
),
),
'button' => array(
'label' => __( 'Slide Button Text', 'responsive-brix' ),
'type' => 'text',
'description' => __( 'Leave empty if you do not want to show the button and instead link the slide image (if you have a url set in the above field)', 'responsive-brix' ),
),
),
);
} // end for
endif;
/** Section **/
$section = 'archives';
$sections[ $section ] = array(
'title' => __( 'Archives (Blog, Cats, Tags)', 'responsive-brix' ),
);
$settings['archive_post_content'] = array(
'label' => __( 'Post Items Content', 'responsive-brix' ),
'section' => $section,
'type' => 'radio',
'choices' => array(
'none' => __('None', 'responsive-brix'),
'excerpt' => __('Post Excerpt', 'responsive-brix'),
'full-content' => __('Full Post Content', 'responsive-brix'),
),
'default' => 'excerpt',
'description' => __( 'Content to display for each post in the list', 'responsive-brix' ),
);
$settings['archive_post_meta'] = array(
'label' => __( 'Meta Information for Post List Items', 'responsive-brix' ),
'sublabel' => __( 'Check which meta information to display for each post item in the archive list.', 'responsive-brix' ),
'section' => $section,
'type' => 'checkbox',
'choices' => array(
'author' => __('Author', 'responsive-brix'),
'date' => __('Date', 'responsive-brix'),
'cats' => __('Categories', 'responsive-brix'),
'tags' => __('Tags', 'responsive-brix'),
'comments' => __('No. of comments', 'responsive-brix')
),
'default' => 'author, date, cats, comments',
);
$settings['excerpt_length'] = array(
'label' => __( 'Excerpt Length', 'responsive-brix' ),
'section' => $section,
'type' => 'text',
'description' => __( 'Number of words in excerpt. Default is 105. Leave empty if you dont want to change it.', 'responsive-brix' ),
'input_attrs' => array(
'placeholder' => __( 'default: 105', 'responsive-brix' ),
),
);
$settings['read_more'] = array(
'label' => __( "'Read More' Text", 'responsive-brix' ),
'section' => $section,
'type' => 'text',
'description' => __( "Replace the default 'Read More' text. Leave empty if you dont want to change it.", 'responsive-brix' ),
'input_attrs' => array(
'placeholder' => __( 'default: READ MORE →', 'responsive-brix' ),
),
);
/** Section **/
$section = 'singular';
$sections[ $section ] = array(
'title' => __( 'Single (Posts, Pages)', 'responsive-brix' ),
);
$settings['page_header_full'] = array(
'label' => __( 'Stretch Page Header to Full Width', 'responsive-brix' ),
'sublabel' => '<!--default-->
tag to show the default Info Text.<!--year-->
tag to insert the current year.©
', 'responsive-brix'), '', '' ),
);
/*** Return Options Array ***/
return apply_filters( 'hoot_theme_customizer_options', array(
'settings' => $settings,
'sections' => $sections,
'panels' => $panels,
) );
}
endif;
/**
* Add Options (settings, sections and panels) to Hoot_Customizer class options object
*
* @since 2.0
* @access public
* @return void
*/
if ( !function_exists( 'hoot_theme_add_customizer_options' ) ) :
function hoot_theme_add_customizer_options() {
$hoot_customizer = Hoot_Customizer::get_instance();
// Add Options
$options = hoot_theme_customizer_options();
$hoot_customizer->add_options( array(
'settings' => $options['settings'],
'sections' => $options['sections'],
'panels' => $options['panels'],
) );
// Add Inforbuttons
// $hoot_customizer->add_infobuttons( array(
// 'demo' => array( 'text' => __( 'Demo', 'responsive-brix'),
// 'url' => 'https://demo.wphoot.com/responsive-brix/',
// 'icon' => 'fas fa-eye' ),
// 'docs' => array( 'text' => __( 'Docs / Support', 'responsive-brix'),
// 'url' => 'https://wphoot.com/support/',
// 'icon' => 'far fa-life-ring' ),
// 'rate' => array( 'text' => __( 'Rating', 'responsive-brix'),
// 'url' => 'https://wordpress.org/support/theme/responsive-brix/reviews/#new-post',
// 'icon' => 'fas fa-star' ),
// ) );
// Add Premium Infobutton
// $hoot_customizer->add_infobuttons( array(
// 'premium' => array( 'text' => __( 'Premium', 'responsive-brix'),
// 'type' => 'premium',
// 'url' => esc_url( admin_url('themes.php?page=responsive-brix-welcome') ),
// 'icon' => 'fa-rocket fas' ),
// ) );
}
endif;
add_action( 'init', 'hoot_theme_add_customizer_options', 0 ); // cannot hook into 'after_setup_theme' as this hook is already being executed (this file is loaded at after_setup_theme @priority 10) (hooking into same hook from within while hook is being executed leads to undesirable effects as $GLOBALS[$wp_filter]['after_setup_theme'] has already been ksorted)
// Hence, we hook into 'init' @priority 0, so that settings array gets populated before 'widgets_init' action ( which itself is hooked to 'init' at priority 1 ) for creating widget areas ( settings array is needed for creating defaults when user value has not been stored )
/**
* Enqueue custom scripts to customizer screen
*
* @since 4.1
* @return void
*/
function hoot_theme_customizer_enqueue_scripts() {
// Enqueue Styles
wp_enqueue_style( 'hoot-theme-customizer-styles', trailingslashit( HOOT_THEMEURI ) . 'admin/css/customizer.css', array(), HOOT_VERSION );
// Enqueue Scripts
wp_enqueue_script( 'hoot-theme-customizer-script', trailingslashit( HOOT_THEMEURI ) . 'admin/js/customize-controls.js', array( 'jquery', 'wp-color-picker', 'customize-controls', 'hoot-customizer-script' ), HOOT_VERSION, true );
}
// Load scripts at priority 12 so that Hoot Customizer Interface (11) / Custom Controls (10) have loaded their scripts
add_action( 'customize_controls_enqueue_scripts', 'hoot_theme_customizer_enqueue_scripts', 12 );
/**
* Modify default WordPress Settings Sections and Panels
*
* @since 2.0
* @param object $wp_customize
* @return void
*/
function hoot_customizer_modify_default_options( $wp_customize ) {
$wp_customize->get_control( 'custom_logo' )->section = 'logo';
$wp_customize->get_control( 'custom_logo' )->priority = 115;
$wp_customize->get_control( 'custom_logo' )->width = 255;
$wp_customize->get_control( 'custom_logo' )->height = 95;
// $wp_customize->get_control( 'custom_logo' )->type = 'image'; // Stored value becomes url instead of image ID (fns like the_custom_logo() dont work)
// Defaults: [type] => cropped_image, [width] => 150, [height] => 150, [flex_width] => 1, [flex_height] => 1, [button_labels] => array(...), [label] => Logo
$wp_customize->get_control( 'custom_logo' )->active_callback = 'hoot_callback_logo_image';
if ( function_exists( 'get_site_icon_url' ) )
$wp_customize->get_control( 'site_icon' )->priority = 10;
$wp_customize->get_section( 'static_front_page' )->priority = 3;
// $wp_customize->get_section( 'title_tagline' )->panel = 'general';
// $wp_customize->get_section( 'title_tagline' )->priority = 1;
// $wp_customize->get_section( 'colors' )->panel = 'styling';
// global $wp_version;
// if ( version_compare( $wp_version, '4.3', '>=' ) ) // 'Creating Default Object from Empty Value' error before 4.3 since 'nav_menus' panel did not exist ( we did have 'nav' section till 4.1.9 i.e. before 4.2 )
// $wp_customize->get_panel( 'nav_menus' )->priority = 999;
// This will set the priority, however will give a 'Creating Default Object from Empty Value' error first.
// $wp_customize->get_panel( 'widgets' )->priority = 999;
}
add_action( 'customize_register', 'hoot_customizer_modify_default_options', 100 );
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @since 2.0
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
* @return void
*/
function hoot_customizer_customize_register( $wp_customize ) {
// $wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
}
add_action( 'customize_register', 'hoot_customizer_customize_register' );
/**
* Callback Functions for customizer settings
*/
function hoot_callback_logo_size( $control ) {
$selector = $control->manager->get_setting('logo')->value();
return ( $selector == 'text' || $selector == 'mixed' ) ? true : false;
}
function hoot_callback_site_title_icon( $control ) {
$selector = $control->manager->get_setting('logo')->value();
return ( $selector == 'text' || $selector == 'custom' ) ? true : false;
}
function hoot_callback_logo_image( $control ) {
$selector = $control->manager->get_setting('logo')->value();
return ( $selector == 'image' || $selector == 'mixed' || $selector == 'mixedcustom' ) ? true : false;
}
function hoot_callback_logo_image_width( $control ) {
$selector = $control->manager->get_setting('logo')->value();
return ( $selector == 'mixed' || $selector == 'mixedcustom' ) ? true : false;
}
function hoot_callback_logo_custom( $control ) {
$selector = $control->manager->get_setting('logo')->value();
return ( $selector == 'custom' || $selector == 'mixedcustom' ) ? true : false;
}
function hoot_callback_show_tagline( $control ) {
$selector = $control->manager->get_setting('logo')->value();
return ( $selector == 'text' || $selector == 'custom' || $selector == 'mixed' || $selector == 'mixedcustom' ) ? true : false;
}
function hoot_callback_box_background_color( $control ) {
$selector = $control->manager->get_setting('site_layout')->value();
return ( $selector == 'boxed' ) ? true : false;
}
/**
* Specific Sanitization Functions for customizer settings
* See specific settings above for more details.
*/
function hoot_custom_sanitize_textarea_allowscript( $value ) {
global $allowedposttags;
// Allow javascript to let users ad code for ads etc.
$allow = array_merge( $allowedposttags, array(
'script' => array( 'async' => true, 'charset' => true, 'defer' => true, 'src' => true, 'type' => true ),
) );
return wp_kses( $value , $allow );
}/**
* Social Icons Widget
*
* @package hoot
* @subpackage responsive-brix
* @since responsive-brix 1.0
*/
/**
* Class Hoot_Social_Icons_Widget
*/
class Hoot_Social_Icons_Widget extends Hoot_WP_Widget {
function __construct() {
$settings['id'] = 'hoot-social-icons-widget';
$settings['name'] = __( 'Hoot > Social Icons', 'responsive-brix' );
$settings['widget_options'] = array(
'description' => __('Display Social Icons', 'responsive-brix'),
// 'classname' => 'hoot-social-icons-widget', // CSS class applied to frontend widget container via 'before_widget' arg
);
$settings['control_options'] = array();
$settings['form_options'] = array(
//'name' => can be empty or false to hide the name
array(
'name' => __( 'Title (optional)', 'responsive-brix' ),
'id' => 'title',
'type' => 'text',
),
array(
'name' => __( 'Icon Size', 'responsive-brix' ),
'id' => 'size',
'type' => 'select',
'std' => 'small',
'options' => array(
'small' => __( 'Small', 'responsive-brix' ),
'medium' => __( 'Medium', 'responsive-brix' ),
'large' => __( 'Large', 'responsive-brix' ),
'huge' => __( 'Huge', 'responsive-brix' ),
),
),
array(
'name' => __( 'Social Icons', 'responsive-brix' ),
'id' => 'icons',
'type' => 'group',
'options' => array(
'item_name' => __( 'Icon', 'responsive-brix' ),
),
'fields' => array(
array(
'name' => __( 'Social Icon', 'responsive-brix' ),
'id' => 'icon',
'type' => 'select',
'options' => hoot_enum_social_profiles(),
),
array(
'name' => __( 'URL (enter username for Skype, email address for Email)', 'responsive-brix' ),
'id' => 'url',
'type' => 'text',
'sanitize' => 'social_icons_sanitize_url',
),
),
),
array(
'name' => __( 'Widget CSS', 'responsive-brix' ),
'id' => 'customcss',
'type' => 'collapse',
'fields' => array(
array(
'name' => __( 'Custom CSS Class', 'responsive-brix' ),
'desc' => __( 'Give this widget a custom css classname', 'responsive-brix' ),
'id' => 'class',
'type' => 'text',
),
array(
'name' => __( 'Margin Top', 'responsive-brix' ),
'desc' => __( '(in pixels) Leave empty to load default margins', 'responsive-brix' ),
'id' => 'mt',
'type' => 'text',
'settings' => array( 'size' => 3 ),
'sanitize' => 'integer',
),
array(
'name' => __( 'Margin Bottom', 'responsive-brix' ),
'desc' => __( '(in pixels) Leave empty to load default margins', 'responsive-brix' ),
'id' => 'mb',
'type' => 'text',
'settings' => array( 'size' => 3 ),
'sanitize' => 'integer',
),
array(
'name' => __( 'Widget ID', 'responsive-brix' ),
'id' => 'widgetid',
'type' => ' ',
),
),
),
);
$settings = apply_filters( 'hoot_social_icons_widget_settings', $settings );
parent::__construct( $settings['id'], $settings['name'], $settings['widget_options'], $settings['control_options'], $settings['form_options'] );
}
/**
* Echo the widget content
*/
function display_widget( $instance, $before_title = '', $title='', $after_title = '' ) {
extract( $instance, EXTR_SKIP );
include( hoot_locate_widget( 'social-icons' ) ); // Loads the widget/social-icons or template-parts/widget-social-icons.php template.
}
}
/**
* Register Widget
*/
function hoot_social_icons_widget_register(){
register_widget('Hoot_Social_Icons_Widget');
}
add_action('widgets_init', 'hoot_social_icons_widget_register');
/**
* Custom Sanitization Function
*/
function hoot_social_icons_sanitize_url( $value, $name, $instance ){
if ( $name == 'social_icons_sanitize_url' ) {
if ( !empty( $instance['icon'] ) && $instance['icon'] == 'fa-skype' )
$new = sanitize_user( $value, true );
elseif ( !empty( $instance['icon'] ) && $instance['icon'] == 'fa-envelope' )
$new = is_email( $value );
else
$new = esc_url_raw( $value );
return $new;
}
return $value;
}
add_filter('widget_admin_sanitize_field', 'hoot_social_icons_sanitize_url', 10, 3);