/*
* This theme styles the visual editor to resemble the theme style,
* specifically font, colors, icons, and column width.
*/
/**
* huza functions and definitions
*
* Set up the theme and provides some helper functions, which are used in the
* theme as custom template tags. Others are attached to action and filter
* hooks in WordPress to change core functionality.
*
* When using a child theme you can override certain functions (those wrapped
* in a function_exists() call) by defining them first in your child theme's
* functions.php file. The child theme's functions.php file is included before
* the parent theme's file, so the child theme functions would be used.
*
* @link https://codex.wordpress.org/Theme_Development
* @link https://codex.wordpress.org/Child_Themes
*
* Functions that are not pluggable (not wrapped in function_exists()) are
* instead attached to a filter or action hook.
*
* For more information on hooks, actions, and filters,
* {@link https://codex.wordpress.org/Plugin_API}
*
* @package WordPress
* @subpackage Huza
* @since Huza 1.13
*/
define( 'HUZA_THEME_VERSION', '1.13' );
define( 'HUZA_DEMO_MODE', false );
if ( ! isset( $content_width ) ) {
$content_width = 660;
}
if ( ! function_exists( 'huza_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*
* @since Huza 1.0
*/
function huza_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on huza, use a find and replace
* to change 'huza' to the name of your theme in all the template files
*/
load_theme_textdomain( 'huza', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded
tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* See: https://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
*/
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 1200, 750, true );
add_image_size( 'huza-event-medium', 300, 300, true );
add_image_size( 'huza-event-grid', 275, 360, true );
add_image_size( 'huza-give-image-grid', 555 , 412, true );
add_image_size( 'huza-give-image-list', 270, 355, true );
// This theme uses wp_nav_menu() in two locations.
register_nav_menus( array(
'primary' => esc_html__( 'Primary Menu', 'huza' ),
'topmenu' => esc_html__( 'Top Menu', 'huza' ),
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
) );
/*
* Enable support for Post Formats.
*
* See: https://codex.wordpress.org/Post_Formats
*/
add_theme_support( 'post-formats', array(
'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat'
) );
$color_scheme = huza_get_color_scheme();
$default_color = trim( $color_scheme[0], '#' );
// Setup the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'huza_custom_background_args', array(
'default-color' => $default_color,
'default-attachment' => 'fixed',
) ) );
// woocommerce support
add_theme_support( "woocommerce" );
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
// Add support for Block Styles.
add_theme_support( 'wp-block-styles' );
add_theme_support( 'responsive-embeds' );
// Add support for full and wide align images.
add_theme_support( 'align-wide' );
// Add support for editor styles.
add_theme_support( 'editor-styles' );
// Enqueue editor styles.
add_editor_style( array( 'css/style-editor.css', huza_get_fonts_url() ) );
huza_get_load_plugins();
}
endif; // huza_setup
add_action( 'after_setup_theme', 'huza_setup' );
/**
* Load Google Front
*/
function huza_get_fonts_url() {
$fonts_url = '';
/* Translators: If there are characters in your language that are not
* supported by Montserrat, translate this to 'off'. Do not translate
* into your own language.
*/
$montserrat = _x( 'on', 'Montserrat font: on or off', 'huza' );
$roboto = _x( 'on', 'Roboto font: on or off', 'huza' );
$open = _x( 'on', 'Open Sans font: on or off', 'huza' );
if ( 'off' !== $montserrat || 'off' !== $open || 'off' !== $roboto ) {
$font_families = array();
if ( 'off' !== $montserrat ) {
$font_families[] = 'Montserrat:300,400,500,600,700,800,900';
}
if ( 'off' !== $roboto ) {
$font_families[] = 'Roboto';
}
if ( 'off' !== $open ) {
$font_families[] = 'Open+Sans:400,600,700';
}
$query_args = array(
'family' => ( implode( '|', $font_families ) ),
'subset' => urlencode( 'latin,latin-ext' ),
);
$protocol = is_ssl() ? 'https:' : 'http:';
$fonts_url = add_query_arg( $query_args, $protocol .'//fonts.googleapis.com/css' );
}
return esc_url_raw( $fonts_url );
}
function huza_fonts_url() {
$protocol = is_ssl() ? 'https:' : 'http:';
wp_enqueue_style( 'huza-theme-fonts', huza_get_fonts_url(), array(), null );
}
add_action('wp_enqueue_scripts', 'huza_fonts_url');
/**
* JavaScript Detection.
*
* Adds a `js` class to the root `` element when JavaScript is detected.
*
* @since Huza 1.1
*/
function huza_javascript_detection() {
wp_add_inline_script( 'huza-typekit', "(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);" );
}
add_action( 'wp_enqueue_scripts', 'huza_javascript_detection', 0 );
/**
* Enqueue scripts and styles.
*
* @since Huza 1.0
*/
function huza_scripts() {
// Load our main stylesheet.
//load font awesome
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.css', array(), '4.5.0' );
//load font awesome
wp_enqueue_style( 'font-monia', get_template_directory_uri() . '/css/font-monia.css', array(), '1.0.0' );
wp_enqueue_style( 'font-themify', get_template_directory_uri() . '/css/themify-icons.css', array(), '1.0.0' );
// load animate version 1.2.0
wp_enqueue_style( 'material-design-iconic-font', get_template_directory_uri() . '/css/material-design-iconic-font.css', array(), '2.2.0' );
// load animate version 3.5.0
wp_enqueue_style( 'animate', get_template_directory_uri() . '/css/animate.css', array(), '3.5.0' );
// load bootstrap style
if( is_rtl() ){
wp_enqueue_style( 'bootstrap-rtl', get_template_directory_uri() . '/css/bootstrap-rtl.css', array(), '3.2.0' );
}else{
wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.css', array(), '3.2.0' );
}
wp_enqueue_style( 'huza-template', get_template_directory_uri() . '/css/template.css', array(), '3.2' );
$footer_style = huza_print_style_footer();
if ( !empty($footer_style) ) {
wp_add_inline_style( 'huza-template', $footer_style );
}
$custom_style = huza_custom_styles();
if ( !empty($custom_style) ) {
wp_add_inline_style( 'huza-template', $custom_style );
}
wp_enqueue_style( 'huza-style', get_template_directory_uri() . '/style.css', array(), '3.2' );
wp_enqueue_script( 'skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20141010', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array( 'jquery' ), '20150330', true );
wp_enqueue_script( 'owl-carousel', get_template_directory_uri() . '/js/owl.carousel.min.js', array( 'jquery' ), '2.0.0', true );
wp_enqueue_script( 'huza-countdown', get_template_directory_uri() . '/js/countdown.js', array( 'jquery' ), '20150315', true );
wp_enqueue_script( 'circle-progress', get_template_directory_uri() . '/js/circle-progress.js', array( 'jquery' ), '20150315', true );
wp_enqueue_script( 'perfect-scrollbar', get_template_directory_uri() . '/js/perfect-scrollbar.jquery.min.js', array( 'jquery' ), '0.6.12', true );
wp_enqueue_style( 'perfect-scrollbar', get_template_directory_uri() . '/css/perfect-scrollbar.css', array(), '0.6.12' );
wp_enqueue_script( 'jquery-magnific-popup', get_template_directory_uri() . '/js/magnific/jquery.magnific-popup.min.js', array( 'jquery' ), '1.1.0', true );
wp_enqueue_style( 'magnific-popup', get_template_directory_uri() . '/js/magnific/magnific-popup.css', array(), '1.1.0' );
wp_enqueue_script( 'jquery-unveil', get_template_directory_uri() . '/js/jquery.unveil.js', array( 'jquery' ), '1.1.0', true );
wp_enqueue_script( 'jquery-appear', get_template_directory_uri() . '/js/jquery.appear.js', array( 'jquery' ), '0.3.3', true );
wp_register_script( 'huza-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20150330', true );
wp_localize_script( 'huza-script', 'huza_ajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));
wp_enqueue_script( 'huza-script' );
}
add_action( 'wp_enqueue_scripts', 'huza_scripts', 100 );
// style compare wp_head
function huza_head_compare_scripts() {
wp_enqueue_style( 'huza-compare', get_template_directory_uri() . '/css/compare.css', array(), '3.2' );
}
add_action('wp_enqueue_scripts', 'huza_head_compare_scripts');
/**
* Display descriptions in main navigation.
*
* @since Huza 1.0
*
* @param string $item_output The menu item output.
* @param WP_Post $item Menu item object.
* @param int $depth Depth of the menu.
* @param array $args wp_nav_menu() arguments.
* @return string Menu item with possible description.
*/
function huza_nav_description( $item_output, $item, $depth, $args ) {
if ( 'primary' == $args->theme_location && $item->description ) {
$item_output = str_replace( $args->link_after . '', '
' . $item->description . '
' . $args->link_after . '', $item_output );
}
return $item_output;
}
add_filter( 'walker_nav_menu_start_el', 'huza_nav_description', 10, 4 );
/**
* Add a `screen-reader-text` class to the search form's submit button.
*
* @since Huza 1.0
*
* @param string $html Search form HTML.
* @return string Modified search form HTML.
*/
function huza_search_form_modify( $html ) {
return str_replace( 'class="search-submit"', 'class="search-submit screen-reader-text"', $html );
}
add_filter( 'get_search_form', 'huza_search_form_modify' );
/**
* Function for remove srcset (WP4.4)
*
*/
function huza_disable_srcset( $sources ) {
return false;
}
add_filter( 'wp_calculate_image_srcset', 'huza_disable_srcset' );
/**
* Function get opt_name
*
*/
function huza_get_opt_name() {
return 'huza_theme_options';
}
add_filter( 'apus_framework_get_opt_name', 'huza_get_opt_name' );
function huza_register_demo_mode() {
if ( defined('HUZA_DEMO_MODE') && HUZA_DEMO_MODE ) {
return true;
}
return false;
}
add_filter( 'apus_framework_register_demo_mode', 'huza_register_demo_mode' );
function huza_get_demo_preset() {
$preset = '';
if ( defined('HUZA_DEMO_MODE') && HUZA_DEMO_MODE ) {
if ( isset($_GET['_preset']) && $_GET['_preset'] ) {
$presets = get_option( 'apus_framework_presets' );
if ( is_array($presets) && isset($presets[$_GET['_preset']]) ) {
$preset = $_GET['_preset'];
}
} else {
$preset = get_option( 'apus_framework_preset_default' );
}
}
return $preset;
}
function huza_get_config($name, $default = '') {
global $apus_options;
if ( isset($apus_options[$name]) ) {
return $apus_options[$name];
}
return $default;
}
function huza_get_global_config($name, $default = '') {
$options = get_option( 'huza_theme_options', array() );
if ( isset($options[$name]) ) {
return $options[$name];
}
return $default;
}
function huza_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar Default', 'huza' ),
'id' => 'sidebar-default',
'description' => esc_html__( 'Add widgets here to appear in your Sidebar.', 'huza' ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Shop sidebar', 'huza' ),
'id' => 'shop-sidebar',
'description' => esc_html__( 'Add widgets here to appear in your sidebar.', 'huza' ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Blog left sidebar', 'huza' ),
'id' => 'blog-left-sidebar',
'description' => esc_html__( 'Add widgets here to appear in your sidebar.', 'huza' ),
'before_widget' => '',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Blog right sidebar', 'huza' ),
'id' => 'blog-right-sidebar',
'description' => esc_html__( 'Add widgets here to appear in your sidebar.', 'huza' ),
'before_widget' => '',
'before_title' => '