'#d02121',
'accent_font' => '#ffffff',
'contrast_color' => '#1c1c1c',
'contrast_font' => '#ffffff',
'box_background' => '#f1f1f1',
'site_background' => '#ffffff',
'wt_html_slide_background' => '#ffffff',
) ) );
// Directory path for radioimage buttons
$imagepath = HYBRIDEXTEND_INCURI . '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' => __("Logo Font (set in 'Typography' section)", 'metrolo'),
'standard' => __('Standard Body Font', 'metrolo'),
) );
/*** Add Options (Panels, Sections, Settings) ***/
/** Section **/
$section = 'links';
$sections[ $section ] = array(
'title' => __( 'Demo / Support', 'metrolo' ),
'priority' => '2',
);
$lcontent = '';
$lcontent .= '' .
' ' .
__( "Demo", 'metrolo') .
'' .
__( "Demo the theme features and options with sample content.", 'metrolo') .
'';
$ocdilink = ( class_exists( 'Hoot_Theme_Premium' ) ) ? ( ( class_exists( 'OCDI_Plugin' ) ) ? admin_url( 'themes.php?page=pt-one-click-demo-import' ) : 'https://wphoot.com/support/metrolo/#docs-section-demo-content' ) : 'https://wphoot.com/support/metrolo/#docs-section-demo-content-free';
$lcontent .= '' .
' ' .
esc_html__( "1 Click Installation", 'metrolo') .
'' .
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.", 'metrolo') .
'';
$lcontent .= '' .
' ' .
__( "Documentation / Support", 'metrolo') .
'' .
__( "Get theme related support for both free and premium users.", 'metrolo') .
'';
$lcontent .= '' .
'5 ' .
__( "Rate Us", 'metrolo') .
'' .
__( "If you are happy with the theme, give us a 5 star rating on wordpress.org", 'metrolo') .
'';
$settings['linksection'] = array(
// 'label' => __( 'Misc Links', 'metrolo' ),
'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', 'metrolo' ),
);
$settings['site_layout'] = array(
'label' => __( 'Site Layout - Boxed vs Stretched', 'metrolo' ),
'section' => $section,
'type' => 'radio',
'choices' => array(
'boxed' => __('Boxed layout', 'metrolo'),
'stretch' => __('Stretched layout (full width)', 'metrolo'),
),
'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.", 'metrolo'),
);
$settings['site_width'] = array(
'label' => __( 'Max. Site Width (pixels)', 'metrolo' ),
'section' => $section,
'type' => 'radio',
'choices' => array(
'1260' => __('1260px (wide)', 'metrolo'),
'1080' => __('1080px (standard)', 'metrolo'),
),
'default' => '1260',
);
$settings['load_minified'] = array(
'label' => __( 'Load Minified Styles and Scripts (when available)', 'metrolo' ),
'sublabel' => __( 'Checking this option reduces data size, hence increasing page load speed.', 'metrolo' ),
'section' => $section,
'type' => 'checkbox',
// 'default' => 1,
);
$settings['sidebar_desc'] = array(
'label' => __( 'Multiple Sidebars', 'metrolo' ),
'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.', 'metrolo' ), '', '', '', '', '', '' ),
);
$settings['sidebar'] = array(
'label' => __( 'Sidebar Layout (Site-wide)', 'metrolo' ),
'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',
'narrow-left-right' => $imagepath . 'sidebar-narrow-left-right.png',
'narrow-left-left' => $imagepath . 'sidebar-narrow-left-left.png',
'narrow-right-right' => $imagepath . 'sidebar-narrow-right-right.png',
'full-width' => $imagepath . 'sidebar-full.png',
'none' => $imagepath . 'sidebar-none.png',
),
'default' => 'wide-right',
'description' => __("Set the default sidebar width and position for your site.", 'metrolo'),
);
$settings['sidebar_fp'] = array(
'label' => __( 'Sidebar Layout (for Front Page)', 'metrolo' ),
'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',
'narrow-left-right' => $imagepath . 'sidebar-narrow-left-right.png',
'narrow-left-left' => $imagepath . 'sidebar-narrow-left-left.png',
'narrow-right-right' => $imagepath . 'sidebar-narrow-right-right.png',
'full-width' => $imagepath . 'sidebar-full.png',
'none' => $imagepath . 'sidebar-none.png',
),
'default' => ( ( 'page' == get_option('show_on_front' ) ) ? 'full-width' : 'wide-right' ),
/* Translators: The %s are placeholders for HTML, so the order can't be changed. */
'description' => sprintf( esc_html__( 'This is sidebar for the Frontpage Content Module in %1$sFrontpage Modules Settings%2$s', 'metrolo' ), '', '' ),
);
$settings['sidebar_archives'] = array(
'label' => __( 'Sidebar Layout (for Blog/Archives)', 'metrolo' ),
'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',
'narrow-left-right' => $imagepath . 'sidebar-narrow-left-right.png',
'narrow-left-left' => $imagepath . 'sidebar-narrow-left-left.png',
'narrow-right-right' => $imagepath . 'sidebar-narrow-right-right.png',
'full-width' => $imagepath . 'sidebar-full.png',
'none' => $imagepath . 'sidebar-none.png',
),
'default' => 'wide-right',
);
$settings['sidebar_pages'] = array(
'label' => __( 'Sidebar Layout (for Pages)', 'metrolo' ),
'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',
'narrow-left-right' => $imagepath . 'sidebar-narrow-left-right.png',
'narrow-left-left' => $imagepath . 'sidebar-narrow-left-left.png',
'narrow-right-right' => $imagepath . 'sidebar-narrow-right-right.png',
'full-width' => $imagepath . 'sidebar-full.png',
'none' => $imagepath . 'sidebar-none.png',
),
'default' => 'wide-right',
);
$settings['sidebar_posts'] = array(
'label' => __( 'Sidebar Layout (for single Posts)', 'metrolo' ),
'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',
'narrow-left-right' => $imagepath . 'sidebar-narrow-left-right.png',
'narrow-left-left' => $imagepath . 'sidebar-narrow-left-left.png',
'narrow-right-right' => $imagepath . 'sidebar-narrow-right-right.png',
'full-width' => $imagepath . 'sidebar-full.png',
'none' => $imagepath . 'sidebar-none.png',
),
'default' => 'wide-right',
);
if ( current_theme_supports( 'woocommerce' ) ) :
$settings['sidebar_wooshop'] = array(
'label' => __( 'Sidebar Layout (Woocommerce Shop/Archives)', 'metrolo' ),
'section' => $section,
'type' => 'radioimage',
'priority' => '93', // 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',
'narrow-left-right' => $imagepath . 'sidebar-narrow-left-right.png',
'narrow-left-left' => $imagepath . 'sidebar-narrow-left-left.png',
'narrow-right-right' => $imagepath . 'sidebar-narrow-right-right.png',
'full-width' => $imagepath . 'sidebar-full.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.", 'metrolo'),
);
$settings['sidebar_wooproduct'] = array(
'label' => __( 'Sidebar Layout (Woocommerce Single Product Page)', 'metrolo' ),
'section' => $section,
'type' => 'radioimage',
'priority' => '93', // 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',
'narrow-left-right' => $imagepath . 'sidebar-narrow-left-right.png',
'narrow-left-left' => $imagepath . 'sidebar-narrow-left-left.png',
'narrow-right-right' => $imagepath . 'sidebar-narrow-right-right.png',
'full-width' => $imagepath . 'sidebar-full.png',
'none' => $imagepath . 'sidebar-none.png',
),
'default' => 'wide-right',
'description' => __("Set the default sidebar width and position for WooCommerce product page", 'metrolo'),
);
endif;
/** Section **/
$section = 'header';
$sections[ $section ] = array(
'title' => __( 'Header', 'metrolo' ),
);
$settings['primary_menuarea'] = array(
'label' => __( 'Header Area (right of logo)', 'metrolo' ),
'section' => $section,
'type' => 'radio',
'choices' => array(
'menu' => __('Display Primary Menu', 'metrolo'),
'custom' => __('Custom Text', 'metrolo'),
'none' => __('None (Logo will get centre aligned)', 'metrolo'),
),
'default' => 'menu',
);
$settings['primary_menuarea_custom'] = array(
'label' => __( 'Custom Text instead of Menu', 'metrolo' ),
'section' => $section,
'type' => 'textarea',
'description' => __( 'You can use this area to display ads or custom text.', 'metrolo' ),
'active_callback' => 'hoot_callback_show_primary_menuarea_custom',
);
// Allow users to add javascript in case they need to use this area to insert code for ads
// etc. To enable this, add the following code in your child theme's functions.php file (without
// the '//'). This code is already included in premium version.
// add_filter( 'hoot_primary_menuarea_custom_allowscript', 'hoot_child_textarea_allowscript' );
// function hoot_child_textarea_allowscript(){ return true; }
if ( apply_filters( 'hoot_primary_menuarea_custom_allowscript', true ) )
$settings['primary_menuarea_custom']['sanitize_callback'] = 'hoot_custom_sanitize_textarea_allowscript';
$settings['secondary_menu_location'] = array(
'label' => __( 'Full Width Menu Area (location)', 'metrolo' ),
'section' => $section,
'type' => 'radio',
'choices' => array(
'top' => __('Top (above logo)', 'metrolo'),
'bottom' => __('Bottom (below logo)', 'metrolo'),
'none' => __("Do not display full width menu (useful if you already have 'menu' selected in 'Header Area' above')", 'metrolo'),
),
'default' => 'bottom',
);
$settings['secondary_menu_align'] = array(
'label' => __( 'Full Width Menu Area (alignment)', 'metrolo' ),
'section' => $section,
'type' => 'radio',
'choices' => array(
'left' => __('Left', 'metrolo'),
'right' => __('Right', 'metrolo'),
'center' => __('Center', 'metrolo'),
),
'default' => 'center',
);
$settings['disable_flex_menu'] = array(
'label' => __( 'Disable Flex Menu', 'metrolo' ),
'section' => $section,
'type' => 'checkbox',
// 'default' => 1,
'description' => __( 'Disable Flex Menu if you have a lot of Top Level menu items.', 'metrolo' ),
);
$settings['mobile_menu'] = array(
'label' => __( 'Mobile Menu', 'metrolo' ),
'section' => $section,
'type' => 'radio',
'choices' => array(
'inline' => __('Inline - Menu Slide Downs to open', 'metrolo'),
'fixed' => __('Fixed - Menu opens on the left', 'metrolo'),
),
'default' => 'fixed',
'priority' => '145', // @todo remove
);
$settings['mobile_submenu_click'] = array(
'label' => __( "[Mobile Menu] Submenu opens on 'Click'", 'metrolo' ),
'section' => $section,
'type' => 'checkbox',
'default' => 1,
'priority' => '145', // @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).", 'metrolo' ),
);
/** Section **/
$section = 'logo';
$sections[ $section ] = array(
'title' => __( 'Logo', 'metrolo' ),
);
$settings['logo_background_type'] = array(
'label' => __( 'Logo Background', 'metrolo' ),
'section' => $section,
'type' => 'radio',
'priority' => '145', // Non static options must have a priority
'choices' => array(
'transparent' => __('None', 'metrolo'),
'accent' => __('Accent Color', 'metrolo'),
),
'default' => 'accent',
);
$settings['logo'] = array(
'label' => __( 'Site Logo', 'metrolo' ),
'section' => $section,
'type' => 'radio',
'choices' => array(
'text' => __('Default Text (Site Title)', 'metrolo'),
'custom' => __('Custom Text', 'metrolo'),
'image' => __('Image Logo', 'metrolo'),
'mixed' => __('Image & Default Text (Site Title)', 'metrolo'),
'mixedcustom' => __('Image & Custom Text', 'metrolo'),
),
'default' => 'text',
'description' => sprintf( __('Use %sSite Title%s as default text logo', 'metrolo'), '', '' ),
);
$settings['logo_size'] = array(
'label' => __( 'Logo Text Size', 'metrolo' ),
'section' => $section,
'type' => 'select',
'priority' => '155', // Non static options must have a priority
'choices' => array(
'tiny displayfont' => __( 'Tiny (emphasized)', 'metrolo'),
'tiny' => __( 'Tiny', 'metrolo'),
'small displayfont' => __( 'Small (emphasized)', 'metrolo'),
'small' => __( 'Small', 'metrolo'),
'medium displayfont' => __( 'Medium (emphasized)', 'metrolo'),
'medium' => __( 'Medium', 'metrolo'),
'large displayfont' => __( 'Large (emphasized)', 'metrolo'),
'large' => __( 'Large', 'metrolo'),
'huge displayfont' => __( 'Huge (emphasized)', 'metrolo'),
'huge' => __( 'Huge', 'metrolo'),
),
'default' => 'small displayfont',
'active_callback' => 'hoot_callback_logo_size',
);
$settings['site_title_icon'] = array(
'label' => __( 'Site Title Icon (Optional)', 'metrolo' ),
'section' => $section,
'type' => 'icon',
// 'default' => 'fa-anchor fas',
'description' => __( 'Leave empty to hide icon.', 'metrolo' ),
'active_callback' => 'hoot_callback_site_title_icon',
);
$settings['site_title_icon_size'] = array(
'label' => __( 'Site Title Icon Size', 'metrolo' ),
'section' => $section,
'type' => 'select',
'choices' => $logosizes,
'default' => '50px',
'active_callback' => 'hoot_callback_site_title_icon',
);
$settings['logo_image_width'] = array(
'label' => __( 'Maximum Logo Width', 'metrolo' ),
'section' => $section,
'type' => 'text',
'priority' => '176', // Keep it with logo image ( 'custom_logo' )->priority logo
'default' => 200,
'description' => __( '(in pixels)
<!--default-->
tag to show the default Info Text.<!--year-->
tag to insert the current year.©
', 'metrolo'), '', '' ),
);
/*** 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 HybridExtend_Customize class options object
*
* @since 1.0
* @access public
* @return void
*/
if ( !function_exists( 'hoot_theme_add_customizer_options' ) ) :
function hoot_theme_add_customizer_options() {
$hybridextend_customize = HybridExtend_Customize::get_instance();
// Add Options
$options = hoot_theme_customizer_options();
$hybridextend_customize->add_options( array(
'settings' => $options['settings'],
'sections' => $options['sections'],
'panels' => $options['panels'],
) );
}
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 1.0
* @return void
*/
function hoot_theme_customizer_enqueue_scripts() {
// Enqueue Styles
wp_enqueue_style( 'hoot-theme-customize-styles', HYBRIDEXTEND_INCURI . 'admin/css/customize.css', array(), HYBRIDEXTEND_VERSION );
// Enqueue Scripts
wp_enqueue_script( 'hoot-theme-customize-script', HYBRIDEXTEND_INCURI . 'admin/js/customize-controls.js', array( 'jquery', 'wp-color-picker', 'customize-controls', 'hybridextend-customize-script' ), HYBRIDEXTEND_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 1.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 = 175;
$wp_customize->get_control( 'custom_logo' )->width = 250;
$wp_customize->get_control( 'custom_logo' )->height = 90;
// $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 1.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_show_primary_menuarea_custom( $control ) {
$selector = $control->manager->get_setting('primary_menuarea')->value();
return ( $selector == 'custom' ) ? 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 );
}
/**
* Helper function to return the theme mod value.
* If no value has been saved, it returns $default provided by the theme.
* If no $default provided, it checks the default value specified in the customizer settings..
*
* @since 1.0
* @access public
* @param string $name
* @param mixed $default
* @return mixed
*/
function hoot_get_mod( $name, $default = NULL ) {
if ( is_customize_preview() ) {
// We cannot use "if ( !empty( $mod ) )" as this will become false for empty values, and hence fallback to default. isset() is not an option either as $mod is always set. Hence we calculate the default here, and supply it as second argument to get_theme_mod()
$default = ( $default !== NULL ) ? $default : hybridextend_customize_get_default( $name );
$mod = get_theme_mod( $name, $default );
return apply_filters( 'hoot_get_mod_customize', $mod, $name, $default );
} else {
// Return Value
$returnvalue = false;
// Cache
static $mods = NULL;
// Set cache with database values
if ( !$mods ) {
$mods = get_theme_mods();
$mods = apply_filters( 'hoot_get_mod', $mods );
}
// Return value if set
if ( isset( $mods[$name] ) ) {
$returnvalue = $mods[$name];
}
// Return default if provided
elseif ( $default !== NULL ) {
$returnvalue = $default;
}
// Return default theme option value specified in customizer settings
else {
$default = hybridextend_customize_get_default( $name );
if ( !empty( $default ) )
$returnvalue = $default;
}
// Filter applied as in get_theme_mod() core function
$returnvalue = apply_filters( "theme_mod_{$name}", $returnvalue );
if ( $returnvalue !== false ) {
// Sanitize Value
$returnvalue = apply_filters( 'hoot_sanitize_get_mod', $returnvalue, $name );
}
return $returnvalue;
}
}
/* Transition filter for version 1.9.0 : Doesnt resolve customizer but hopefully user will visit atleast one admin screen before customizer */
add_filter( 'hoot_get_mod', 'hoot_transition_get_mods', 2 );
/**
* Function for seamless transition for changed option/values in version 1.9.0
* Updated 1.9.0 for frontpage sidebar option
*
* @since 1.9.0
* @access public
* @return void
*/
function hoot_transition_get_mods( $mods ) {
if ( !isset( $mods['sidebar_fp'] ) ) {
if ( 'page' == get_option('show_on_front' ) ) {
if ( function_exists( 'hoot_get_meta_option' ) && hoot_get_meta_option( 'sidebar_type', get_option( 'page_on_front' ) ) == 'custom' ) {
$mods['sidebar_fp'] = hoot_get_meta_option( 'sidebar', get_option( 'page_on_front' ) );
} else {
$mods['sidebar_fp'] = 'full-width';
}
} else {
$mods['sidebar_fp'] = ( isset( $mods['sidebar_archives'] ) ) ? $mods['sidebar_archives'] : ( isset( $mods['sidebar'] ) ? $mods['sidebar'] : 'wide-right' );
}
set_theme_mod( 'sidebar_fp', $mods['sidebar_fp'] );
}
// var_dump(get_theme_mods());exit;
return $mods;
}
/**
* Sanitization function for return value of theme mod
* jnes No chan-ni applied
*
* @since 1.0
* @access public
* @param mixed $value
* @param string $name
* @return mixed
*/
function hoot_sanitize_get_mod( $value, $name ) {
/** Get Setting array from the Customizer Class **/
$hybridextend_customize = HybridExtend_Customize::get_instance();
$settings = $hybridextend_customize->get_options('settings');
/** Load Sanitization functions if not loaded already (for frontend) **/
if ( !function_exists( 'hybridextend_sanitize_enum' ) )
require_once( HYBRIDEXTEND_DIR . 'includes/sanitization.php' );
/** Load Sanitization functions if not loaded already (from frontend) **/
if ( !function_exists( 'hybridextend_customize_sanitize_text' ) )
require_once( HYBRIDEXTEND_DIR . 'customize/sanitization.php' );
if ( isset( $settings[ $name ] ) ) {
/** Sanitize values **/
if ( isset( $settings[ $name ]['type'] ) && !empty( $settings[ $name ]['sanitize_callback'] ) && function_exists( $settings[ $name ]['sanitize_callback'] ) ) {
$fn_name = $settings[ $name ]['sanitize_callback'];
return $fn_name( $value );
} elseif ( isset( $settings[ $name ]['type'] ) ) {
switch ( $settings[ $name ]['type'] ) {
// Text Field
case 'text':
$value = sanitize_text_field( $value ); // Alternately, can also use "hybridextend_customize_sanitize_text" to use wp_kses() instead
break;
// Textarea Field
case 'textarea':
$value = hybridextend_sanitize_textarea( $value );
break;
// Select, Radio, Image Radio
case 'select':
case 'radio':
case 'radioimage':
$value = hybridextend_sanitize_enum( $value, $settings[ $name ]['choices'] );
break;
// Image / Upload Field
case 'image':
case 'upload':
$value = esc_url( $value );
break;
// URL Field
case 'url':
$value = esc_url( $value );
break;
// Range Field
case 'range':
$value = hybridextend_customize_sanitize_range( $value );
break;
// Dropdown Pages Field
case 'dropdown-pages':
$value = absint( $value );
break;
// Color Field
case 'color':
$value = sanitize_hex_color( $value );
break;
// Checkbox Field
case 'checkbox':
$value = hybridextend_sanitize_checkbox( $value );
break;
// MultiCheckbox Field
case 'bettercheckbox':
if ( !empty( $settings[ $name ]['choices'] ) && is_array( $settings[ $name ]['choices'] ) )
$value = hybridextend_customize_sanitize_multicheckbox( $value, $name );
else
$value = hybridextend_sanitize_checkbox( $value );
break;
// Icon Field
case 'icon':
$value = hybridextend_sanitize_icon( $value, $name );
break;
// Sortlist Field
case 'sortlist':
$value = hybridextend_customize_sanitize_sortlist( $value, $name );
break;
} // endswitch
} // endif
} // endif
return $value;
}