/** * Register theme scripts for the theme * * We will use the wp_enqueue_scripts function in framework/wolf-core.php to enqueue scripts * */ function wolf_enqueue_scripts() { $theme_slug = wolf_get_theme_slug(); // Ensure to overwrite scripts enqueued by a plugin wp_dequeue_script('flexslider'); wp_deregister_script('flexslider'); wp_dequeue_script('swipebox'); wp_deregister_script('swipebox'); wp_dequeue_script('fancybox'); wp_deregister_script('fancybox'); wp_dequeue_script('isotope'); wp_deregister_script('isotope'); wp_dequeue_script('imagesloaded'); wp_deregister_script('imagesloaded'); // Modernizr wp_enqueue_script('modernizr', WOLF_THEME_URI . '/js/lib/modernizr.js', '', '2.8.3', false); // Register scripts wp_register_script('infinite-scroll', WOLF_THEME_URI . '/js/lib/jquery.infinitescroll.min.js', 'jquery', '2.0.2', true); // Countdown wp_register_script('countdown', WOLF_THEME_URI . '/js/lib/jquery.countdown.min.js', 'jquery', '2.0.1', true); // Enqueue theme scripts wp_enqueue_script('jquery'); wp_enqueue_script('wp-mediaelement'); // enqueue WP media // Check lightbox option if ('swipebox' == wolf_get_theme_option('lightbox')) { wp_enqueue_script('swipebox', WOLF_THEME_URI . '/js/lib/jquery.swipebox.min.js', 'jquery', '1.3.0.2', true); } elseif ('fancybox' == wolf_get_theme_option('lightbox')) { wp_enqueue_script('fancybox', WOLF_THEME_URI . '/js/lib/jquery.fancybox.pack.js', 'jquery', '2.1.5', true); wp_enqueue_script('fancybox-media', WOLF_THEME_URI . '/js/lib/jquery.fancybox-media.min.js', 'jquery', '1.0.6', true); } // Parallax fallback for IE ( haParallax that uses translate doesn't work well ) if (wolf_is_ie()) { wp_enqueue_script('parallax-bg', WOLF_THEME_URI . '/js/lib/jquery.parallax.min.js', 'jquery', '1.1.3', true); } // Register theme specific scripts if (wolf_get_theme_option('js_min')) { wp_register_script('infinite-scroll-blog', WOLF_THEME_URI . '/js/min/jquery.infinitescroll-blog.min.js', 'jquery', WOLF_THEME_VERSION, true); wp_register_script('gallery', WOLF_THEME_URI . '/js/min/jquery.gallery.min.js', 'jquery', WOLF_THEME_VERSION, true); wp_register_script('item-masonry', WOLF_THEME_URI . '/js/min/jquery.item-masonry.min.js', 'jquery', WOLF_THEME_VERSION, true); $tmp = WOLF_THEME_VERSION; //$tmp = time(); wp_enqueue_script("{$theme_slug}", WOLF_THEME_URI . '/js/min/app.min.js', 'jquery', "{$tmp}", true); wp_register_script($theme_slug . '-one-page', WOLF_THEME_URI . '/js/min/jquery.one-page.min.js', 'jquery', WOLF_THEME_VERSION, true); } else { wp_register_script('infinite-scroll-blog', WOLF_THEME_URI . '/js/jquery.infinitescroll-blog.js', 'jquery', WOLF_THEME_VERSION, true); wp_register_script('gallery', WOLF_THEME_URI . '/js/jquery.gallery.js', 'jquery', WOLF_THEME_VERSION, true); wp_register_script('item-masonry', WOLF_THEME_URI . '/js/jquery.item-masonry.js', 'jquery', WOLF_THEME_VERSION, true); //wp_enqueue_script( 'nicescroll', WOLF_THEME_URI . '/js/lib/jquery.nicescroll.min.js', 'jquery', '3.5.4', true ); wp_enqueue_script('isotope', WOLF_THEME_URI . '/js/lib/isotope.pkgd.min.js', 'jquery', '2.0.1', true); wp_enqueue_script('imageloaded', WOLF_THEME_URI . '/js/lib/imagesloaded.pkgd.min.js', 'jquery', '3.1.8', true); wp_enqueue_script('wow', WOLF_THEME_URI . '/js/lib/wow.min.js', 'jquery', '1.0.1', true); wp_enqueue_script('waypoints', WOLF_THEME_URI . '/js/lib/waypoints.min.js', 'jquery', '1.6.2', true); wp_enqueue_script('flexslider', WOLF_THEME_URI . '/js/lib/jquery.flexslider.min.js', 'jquery', '2.2.2', true); wp_enqueue_script('owlcarousel', WOLF_THEME_URI . '/js/lib/owl.carousel.min.js', array('jquery'), '2.0.0', true); wp_enqueue_script('parallax', WOLF_THEME_URI . '/js/lib/jquery.haParallax.js', 'jquery', '1.0.0', true); wp_enqueue_script('counterup', WOLF_THEME_URI . '/js/lib/jquery.counterup.min.js', 'jquery', '1.0', true); wp_enqueue_script('cookie', WOLF_THEME_URI . '/js/lib/jquery.memo.min.js', 'jquery', '1.0', true); wp_enqueue_script('fittext', WOLF_THEME_URI . '/js/lib/jquery.fittext.min.js', array('jquery'), '1.2', true); wp_enqueue_script('wolf-slider', WOLF_THEME_URI . '/js/jquery.wolfSlider.js', array('jquery'), WOLF_THEME_VERSION, true); wp_enqueue_script('carousels', WOLF_THEME_URI . '/js/jquery.carousels.js', 'jquery', WOLF_THEME_VERSION, true); wp_enqueue_script('viewsnlikes', WOLF_THEME_URI . '/js/jquery.likesnviews.js', 'jquery', WOLF_THEME_VERSION, true); wp_enqueue_script('youtube-video-bg', WOLF_THEME_URI . '/js/youtube-video-bg.js', 'jquery', WOLF_THEME_VERSION, true); $tmp = WOLF_THEME_VERSION; //$tmp = time(); wp_enqueue_script("{$theme_slug}", WOLF_THEME_URI . '/js/jquery.functions.js', 'jquery', "{$tmp}", true); wp_register_script($theme_slug . '-one-page', WOLF_THEME_URI . '/js/jquery.one-page.js', 'jquery', WOLF_THEME_VERSION, true); } wp_register_script('packery', WOLF_THEME_URI . '/js/lib/packery-mode.pkgd.min.js', 'jquery', '0.1.0', true); if (wolf_get_theme_option('one_page_menu')) { wp_enqueue_script($theme_slug . '-one-page'); } // Check the current post type for the ones that uses masonry $current_post_type = array(); if (wolf_is_blog()) { $current_post_type = array('postType' => 'post', 'name' => 'blog', 'trigger' => wolf_get_theme_option('blog_infinite_scroll_trigger')); } elseif (wolf_is_portfolio()) { $current_post_type = array('postType' => 'work', 'name' => 'work', 'trigger' => wolf_get_theme_option('work_infinite_scroll_trigger')); } elseif (wolf_is_videos()) { $current_post_type = array('postType' => 'video', 'name' => 'videos', 'trigger' => wolf_get_theme_option('video_infinite_scroll_trigger')); } elseif (wolf_is_albums()) { $current_post_type = array('postType' => 'gallery', 'name' => 'albums', 'trigger' => wolf_get_theme_option('gallery_infinite_scroll_trigger')); } elseif (function_exists('wolf_is_plugins') && wolf_is_plugins()) { $current_post_type = array('postType' => 'plugin', 'name' => 'plugins'); } elseif (function_exists('wolf_is_themes') && wolf_is_themes()) { $current_post_type = array('postType' => 'theme', 'name' => 'themes'); } elseif (function_exists('wolf_is_demos') && wolf_is_demos()) { $current_post_type = array('postType' => 'demo', 'name' => 'demos'); } // Add JS global variables wp_localize_script("{$theme_slug}", 'WolfThemeParams', array('ajaxUrl' => admin_url('admin-ajax.php'), 'siteUrl' => esc_url(home_url('/')), 'accentColor' => get_theme_mod('accent_color'), 'headerPercent' => 0 != wolf_get_theme_option('home_header_height') ? wolf_get_theme_option('home_header_height') : 80, 'breakPoint' => wolf_get_theme_option('breakpoint', 10000), 'lightbox' => wolf_get_theme_option('lightbox', 'swipebox'), 'videoLightbox' => wolf_get_theme_option('video_lightbox'), 'footerUncover' => wolf_get_theme_option('footer_uncover'), 'headerUncover' => wolf_get_theme_option('header_uncover'), 'sliderEffect' => wolf_get_theme_option('slider_effect', 'slide'), 'sliderAutoplay' => wolf_get_theme_option('slider_autoplay'), 'sliderSpeed' => wolf_get_theme_option('slider_speed', 5000), 'sliderPause' => wolf_get_theme_option('slider_pause'), 'infiniteScroll' => wolf_get_theme_option('blog_infinite_scroll'), 'infiniteScrollMsg' => __('Loading...', 'wolf'), 'infiniteScrollEndMsg' => __('No more post to load', 'wolf'), 'loadMoreMsg' => __('Load More', 'wolf'), 'infiniteScrollEmptyLoad' => wolf_get_theme_uri('/images/empty.gif'), 'newsletterPlaceholder' => __('Your email', 'wolf'), 'isHomeSlider' => wolf_is_slider_in_home_header(), 'heroFadeWhileScroll' => wolf_get_theme_option('hero_fade_while_scroll'), 'heroParallax' => 'parallax' == wolf_get_theme_option('hero_effect') || 'video' == wolf_get_theme_option('home_header_type'), 'homeHeaderType' => wolf_get_theme_option('home_header_type'), 'isHome' => is_page_template('page-templates/home.php'), 'blogWidth' => wolf_get_theme_option('blog_width'), 'menuPosition' => wolf_get_theme_option('menu_position'), 'modernMenu' => 'modern' == wolf_get_theme_option('menu_position'), 'currentPostType' => $current_post_type, 'enableParallaxOnMobile' => wolf_get_theme_option('enable_parallax_on_mobile'), 'enableAnimationOnMobile' => wolf_get_theme_option('enable_animation_on_mobile'), 'doPageTransition' => wolf_get_theme_option('no_page_transition') || wolf_is_ie() ? false : true, 'doBackToTopAnimation' => wolf_get_theme_option('no_back_to_top_animation') ? false : true, 'onePageMenu' => wolf_get_theme_option('one_page_menu') ? true : false, 'onePagePage' => get_permalink(wolf_get_theme_option('one_page_menu')), 'isOnePageOtherPage' => get_the_ID() != wolf_get_theme_option('one_page_menu'), 'isStickyMenu' => wolf_get_theme_option('sticky_menu'), 'addMenuType' => wolf_get_theme_option('additional_toggle_menu_type'), 'workType' => wolf_get_theme_option('work_type'), 'isTopbar' => wolf_get_theme_option('top_bar'), 'menuStyle' => wolf_get_theme_option('menu_style'), 'years' => __('Years', 'wolf'), 'months' => __('Months', 'wolf'), 'weeks' => __('Weeks', 'wolf'), 'days' => __('Days', 'wolf'), 'hours' => __('Hours', 'wolf'), 'minutes' => __('Minutes', 'wolf'), 'seconds' => __('Seconds', 'wolf'), 'replyTitle' => __('Share your thoughts', 'wolf'), 'doWoocommerceLightbox' => 'no' == get_option('woocommerce_enable_lightbox'), 'leftMenuTransparency' => wolf_get_theme_option('left_menu_transparency'), 'layout' => wolf_get_theme_option('layout'), 'HomeHeaderVideoBgType' => wolf_get_theme_option('video_header_bg_type'))); // Dequeue plugin scripts wp_dequeue_script('wolf-portfolio'); wp_deregister_script('wolf-portfolio'); wp_dequeue_script('wolf-albums'); wp_deregister_script('wolf-albums'); wp_dequeue_script('wolf-videos'); wp_deregister_script('wolf-videos'); // Enqueue scripts conditionaly for the blog if ('masonry' == wolf_get_blog_layout() && wolf_is_blog()) { if (wolf_get_theme_option('blog_infinite_scroll')) { wp_enqueue_script('wp-mediaelement'); wp_enqueue_script('infinite-scroll'); } wp_enqueue_script('item-masonry'); } if (wolf_is_portfolio() && 'modern' != wolf_get_theme_option('work_type') && 'vertical' != wolf_get_theme_option('work_type')) { if (wolf_get_theme_option('work_infinite_scroll') && 'masonry-horizontal' != wolf_get_theme_option('work_type')) { wp_enqueue_script('wp-mediaelement'); wp_enqueue_script('infinite-scroll'); } if ('masonry-horizontal' == wolf_get_theme_option('work_type')) { wp_enqueue_script('packery'); } wp_enqueue_script('item-masonry'); } if (wolf_is_albums() && 'modern' != wolf_get_theme_option('gallery_type') && 'vertical' != wolf_get_theme_option('gallery_type')) { if (wolf_get_theme_option('gallery_infinite_scroll')) { wp_enqueue_script('wp-mediaelement'); wp_enqueue_script('infinite-scroll'); } wp_enqueue_script('item-masonry'); } if (wolf_is_videos()) { if (wolf_get_theme_option('video_infinite_scroll')) { wp_enqueue_script('wp-mediaelement'); wp_enqueue_script('infinite-scroll'); } wp_enqueue_script('item-masonry'); } // Enqueue scripts conditionaly for the gallery if (is_singular('gallery')) { wp_enqueue_script('imageloaded'); wp_enqueue_script('isotope'); wp_enqueue_script('gallery'); } // loads the javascript required for threaded comments if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } }
/** * Add specific class to the body depending on theme options and page template * * @param array $classes * @return array $classes */ function wolf_body_classes($classes) { global $wp_customize, $post; if (isset($wp_customize)) { $classes[] = 'is-customizer'; } /** * Check if VC is used */ $is_vc = false; if (is_object($post)) { $pattern = get_shortcode_regex(); if (preg_match("/{$pattern}/s", $post->post_content, $match)) { if ('vc_row' == $match[2]) { $is_vc = true; } } } // $classes[] = 'do-transform'; $classes[] = 'wolf'; $classes[] = 'wolf-mailchimp'; $classes[] = wolf_get_theme_slug(); $classes[] = 'wolf-woocommerce-' . wolf_get_theme_option('woocommerce_layout'); /* Main Layout */ $classes[] = wolf_get_theme_option('layout') . '-layout'; /* Main Layout */ $skin = wolf_get_theme_option('skin') ? wolf_get_theme_option('skin') : 'light'; $classes[] = "skin-{$skin}"; /* Menu */ $classes[] = 'menu-' . wolf_get_theme_option('menu_style'); $classes[] = 'menu-' . wolf_get_theme_option('menu_position'); $classes[] = 'menu-' . wolf_get_theme_option('menu_skin'); if ('default' == wolf_get_theme_option('menu_position')) { $classes[] = 'menu-' . wolf_get_theme_option('menu_width'); if ('wide' == wolf_get_theme_option('menu_width')) { $classes[] = 'submenu-' . wolf_get_theme_option('submenu_align'); } } if ('logo-centered' == wolf_get_theme_option('menu_position') && wolf_get_theme_option('logo_overflow')) { $classes[] = 'menu-logo-overflow'; } $classes[] = 'menu-hover-' . wolf_get_theme_option('menu_hover_effect'); /* Secondary Menu */ if (wolf_get_theme_option('additional_toggle_menu')) { $classes[] = 'is-secondary-menu'; } else { $classes[] = 'no-secondary-menu'; } /* Page header type */ $header_post_id = wolf_get_header_post_id(); $page_header_type = wolf_get_theme_option('page_header_type'); $hide_title_area = 'none' == wolf_get_theme_option('page_header_type'); if ($header_post_id && get_post_meta($header_post_id, '_page_header_type', true)) { $page_header_type = get_post_meta($header_post_id, '_page_header_type', true); $hide_title_area = 'none' == get_post_meta($header_post_id, '_page_header_type', true); } if (wolf_get_category_meta('page_header_type')) { $page_header_type = wolf_get_category_meta('page_header_type'); } //$page_header_type = ( 'full' == $page_header_type ) ? 'big' : $page_header_type; $classes[] = "page-header-{$page_header_type}"; /*if ( 'full' == get_post_meta( $header_post_id, '_page_header_type', true ) || 'full' == wolf_get_theme_option( 'page_header_type' ) ) { $classes[] = "page-header-full"; }*/ if ($hide_title_area) { $classes[] = 'no-title-area'; } else { $classes[] = 'show-title-area'; } if ('left' == wolf_get_theme_option('menu_position') && $hide_title_area) { $classes[] = 'left-menu-not-title-area'; } if (get_post_meta($header_post_id, '_menu_absolute', true) && $hide_title_area) { $classes[] = 'is-home-header'; $classes[] = 'force-absolute-menu'; } /* Page template clean classes */ if (is_page_template('page-templates/full-width.php') || is_page_template('page-templates/page-with-comments.php')) { $classes[] = 'page-full-width'; } if (is_page_template('page-templates/small-width.php')) { $classes[] = 'page-small-width'; } if (is_page_template('page-templates/post-archives.php')) { $classes[] = 'post-archives'; } if (is_page_template('page-templates/page-sidebar-right.php')) { $classes[] = 'page-sidebar-right'; } if (is_page_template('page-templates/page-sidebar-left.php')) { $classes[] = 'page-sidebar-left'; } if (is_page_template('page-templates/coming-soon.php')) { $classes[] = 'coming-soon'; } // Visual Composer Pages if ('default' == get_post_meta(get_the_ID(), '_wp_page_template', true)) { if (!is_search() && !wolf_is_portfolio() && !wolf_is_albums() && !wolf_is_blog() && !wolf_is_videos() && !wolf_is_plugins() && !wolf_is_themes() && !wolf_is_discography() && !wolf_is_woocommerce()) { if ($is_vc) { $classes[] = 'is-vc-page'; } else { $classes[] = 'page-full-width'; } } } elseif (is_page_template('page-templates/home.php') && $is_vc) { $classes[] = 'is-vc-page'; } if (wolf_get_theme_option('full_screen_header') && is_page_template('page-templates/home.php') && wolf_is_home_header()) { $classes[] = 'full-window-header'; } if (wolf_get_theme_option('sticky_menu')) { $classes[] = 'is-sticky-menu'; } if (wolf_get_theme_option('top_bar')) { $classes[] = 'is-top-bar'; } else { $classes[] = 'no-top-bar'; } if (wolf_get_theme_option('fullwidth_menu')) { $classes[] = 'is-fullwidth-menu'; } if ('yes' == wolf_get_theme_option('additional_toggle_menu') && 'side' == wolf_get_theme_option('additional_toggle_menu_type') && ('default' == wolf_get_theme_option('menu_position') || 'center' == wolf_get_theme_option('menu_position') || 'logo-centered' == wolf_get_theme_option('menu_position'))) { $classes[] = 'is-side-menu'; } /* Add a class to hide the sidebar on mobile */ if (wolf_get_theme_option('blog_hide_sidebar_phone')) { $classes[] = 'hide-sidebar-phone'; } /* No loader option class */ if (!wolf_get_theme_option('loader')) { $classes[] = 'no-loader'; } /* No transition option class */ if (!wolf_get_theme_option('page_transition')) { $classes[] = 'no-page-transition'; } /* Home Header Type */ if (wolf_get_theme_option('home_header_type') && is_page_template('page-templates/home.php') || is_front_page()) { $classes[] = 'home-header-' . wolf_get_theme_option('home_header_type'); } if (is_multi_author()) { $classes[] = 'is-multi-author'; } if (wolf_is_blog()) { $classes[] = 'is-blog'; $blog_type = wolf_get_blog_layout(); if ('masonry' == $blog_type) { $classes[] = 'masonry'; } $classes[] = "blog-{$blog_type}"; $classes[] = 'blog-' . wolf_get_theme_option('blog_width'); /* Infinite Scroll class */ if (wolf_get_theme_option('blog_infinite_scroll')) { $classes[] = 'post-infinite-scroll'; } } if (is_page_template('page-templates/home.php') || is_front_page()) { $classes[] = 'is-theme-home'; if (wolf_is_home_header()) { $classes[] = 'is-home-header'; } else { $classes[] = 'no-home-header'; } if (wolf_is_slider_in_home_header()) { $classes[] = 'is-home-slider'; } } if (get_post_meta($header_post_id, '_hide_footer', true)) { $classes[] = 'no-footer'; } if (get_post_meta($header_post_id, '_hide_menu', true)) { $classes[] = 'no-menu'; } if (!is_page_template('page-templates/home.php')) { /** * Is header image ? */ $header_bg_type = get_post_meta($header_post_id, '_header_bg_type', true); $header_bg_color = get_post_meta($header_post_id, '_header_bg_color', true); $header_bg_img = get_post_meta($header_post_id, '_header_bg_img', true); $header_bg_mp4 = get_post_meta($header_post_id, '_header_video_bg_mp4', true); /* If category meta video bg */ if ('image' == wolf_get_category_meta('header_bg_type') && (wolf_get_category_meta('header_bg_img') || wolf_get_category_meta('header_bg_color'))) { $header_bg_type = 'image'; $header_bg_img = wolf_get_category_meta('header_bg_img'); } /* If category meta video bg */ if ('video' == wolf_get_category_meta('header_bg_type') && wolf_get_category_meta('header_video_bg_mp4')) { $header_bg_type = 'video'; $header_bg_mp4 = wolf_get_category_meta('header_video_bg_mp4'); } if ($header_post_id && !is_search()) { if ('image' == $header_bg_type) { if ($header_bg_img || $header_bg_color) { $classes[] = 'has-header-image'; } else { $classes[] = 'no-header-image'; } } elseif ('video' == $header_bg_type) { if ($header_bg_mp4) { $classes[] = 'has-header-image'; } else { $classes[] = 'no-header-image'; } } } /* is 404 header image? */ if (is_404()) { if (wolf_get_theme_option('404_bg')) { $classes[] = 'has-header-image'; } else { $classes[] = 'no-header-image'; } } } if (wolf_is_portfolio()) { if ('modern' != wolf_get_theme_option('work_type') && 'vertical' != wolf_get_theme_option('work_type')) { $classes[] = 'masonry'; } $classes[] = 'work-' . wolf_get_theme_option('work_width'); $classes[] = 'work-' . wolf_get_theme_option('work_type'); $classes[] = 'work-' . wolf_get_theme_option('work_padding'); /* Infinite Scroll class */ if (wolf_get_theme_option('work_infinite_scroll') && 'masonry-horizontal' != wolf_get_theme_option('work_type')) { $classes[] = 'work-infinite-scroll'; } if (wolf_get_theme_option('work_isotope') && 'masonry-horizontal' != wolf_get_theme_option('work_type')) { $classes[] = 'work-isotope'; } } if (wolf_is_albums()) { if ('modern' != wolf_get_theme_option('gallery_type') && 'vertical' != wolf_get_theme_option('gallery_type')) { $classes[] = 'masonry'; } $classes[] = 'gallery-' . wolf_get_theme_option('gallery_type'); $classes[] = 'gallery-' . wolf_get_theme_option('gallery_width'); $classes[] = 'gallery-' . wolf_get_theme_option('gallery_padding'); if (wolf_get_theme_option('gallery_infinite_scroll')) { $classes[] = 'gallery-infinite-scroll'; } if (wolf_get_theme_option('gallery_isotope')) { $classes[] = 'gallery-isotope'; } } if (wolf_is_video_search()) { $classes[] = 'wolf-videos-search-results'; } if (wolf_is_videos()) { $classes[] = 'masonry'; $classes[] = 'video-' . wolf_get_theme_option('video_width'); $classes[] = 'video-' . wolf_get_theme_option('video_padding'); $classes[] = 'video-' . wolf_get_theme_option('video_type'); if (wolf_get_theme_option('video_infinite_scroll')) { $classes[] = 'video-infinite-scroll'; } if (wolf_get_theme_option('video_isotope')) { $classes[] = 'video-isotope'; } } if (wolf_is_discography()) { $classes[] = 'release-' . wolf_get_theme_option('release_width'); $classes[] = 'release-' . wolf_get_theme_option('release_padding'); $classes[] = 'release-' . wolf_get_theme_option('release_type'); } elseif (is_singular('video')) { $classes[] = 'video-' . wolf_get_theme_option('video_type'); } if (is_singular('gallery')) { if (!wolf_get_theme_option('gallery_comments') && !wolf_get_theme_option('gallery_share')) { $classes[] = 'single-gallery-no-padding-bottom'; } } if (is_singular('post') && 'sidebar' == wolf_get_single_blog_post_layout()) { $classes[] = 'post-has-sidebar'; } return $classes; }