Version; return $blograzzi_settings; } add_filter( 'blograzzi_settings', 'blograzzi_scripts_version' ); /** * Print the stylesheets */ function blograzzi_enqueue_scripts(){ global $blograzzi_settings; $version = $blograzzi_settings['scripts_ver']; /* Enqueue scripts */ wp_enqueue_script( 'bootstrap', BLOGRAZZI_ROOTURI . '/bootstrap/js/bootstrap.min.js', array( 'jquery' ), $version ); wp_enqueue_script( 'bootstrap-hover-dropdown', BLOGRAZZI_ROOTURI . '/js/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js', array( 'jquery', 'bootstrap' ), $version ); wp_enqueue_script( 'bootstrap-submenu', BLOGRAZZI_ROOTURI . '/js/bootstrap-submenu/bootstrap-submenu.min.js', array( 'jquery', 'bootstrap' ), $version ); wp_enqueue_script( 'html5shiv', BLOGRAZZI_ROOTURI . '/js/html5shiv/html5shiv.min.js', array(), $version ); wp_enqueue_script( 'respond', BLOGRAZZI_ROOTURI . '/js/respond.js/respond.min.js', array(), $version ); wp_enqueue_script( 'infinite-scroll', BLOGRAZZI_ROOTURI . '/js/jquery.infinitescroll.min.js', array( 'jquery' ), $version ); wp_enqueue_script( 'blograzzi', BLOGRAZZI_ROOTURI . '/js/blograzzi.js', array( 'bootstrap', 'comment-reply', 'infinite-scroll' ), $version ); /* Enqueue styles */ wp_enqueue_style( 'blograzzi-google-fonts', blograzzi_google_fonts_uri(), array(), $version ); wp_enqueue_style( 'bootstrap', BLOGRAZZI_ROOTURI . '/bootstrap/css/bootstrap.min.css' ); wp_enqueue_style( 'font-awesome', BLOGRAZZI_ROOTURI . '/fonts/font-awesome/css/font-awesome.min.css', array() ); wp_enqueue_style( 'blograzzi', get_stylesheet_uri(), array( 'bootstrap', 'font-awesome' ), $version, 'screen' ); wp_enqueue_style( 'blograzzi-responsive', BLOGRAZZI_ROOTURI . '/responsive.css', array( 'bootstrap', 'font-awesome', 'blograzzi' ), $version ); if ( is_rtl() ) { wp_enqueue_style( 'bootstrap-rtl', BLOGRAZZI_ROOTURI . '/bootstrap-rtl/bootstrap-rtl.min.css', array( 'bootstrap' ), $version ); wp_enqueue_style( 'blograzzi-responsive-rtl',BLOGRAZZI_ROOTURI . '/responsive-rtl.css', array( 'bootstrap-rtl', 'blograzzi' ), $version, 'screen' ); } if ( is_singular() && $blograzzi_settings['print_css'] ) wp_enqueue_style( 'blograzzi-print', BLOGRAZZI_ROOTURI . '/style-print.css', array( 'blograzzi' ), $version, 'print' ); } add_action( 'wp_enqueue_scripts', 'blograzzi_enqueue_scripts' ); /** * Localize scripts and add JavaScript data * * @package Blograzzi * @since 1.9 */ function blograzzi_localize_scripts(){ global $blograzzi_settings, $wp_query; $posts_per_page = $wp_query->get( 'posts_per_page' ); $comments_per_page = get_option( 'comments_per_page' ); $js_object = array( /* General */ 'templateUrl' => BLOGRAZZI_ROOTURI, 'isSingular' => is_singular(), /* Comments */ 'shouldShowComments' => blograzzi_should_show_comments(), 'commentsOrder' => get_option( 'default_comments_page' ), /* Slider */ 'sliderDisable' => $blograzzi_settings['slider_disable'], 'sliderInterval' => $blograzzi_settings['slider_speed'], /* Infinite Scroll */ 'infScrollBtnLbl' => __( 'Load more', 'blograzzi' ), 'infScrollOn' => $blograzzi_settings['inf_scroll_enable'], 'infScrollCommentsOn' => $blograzzi_settings['inf_scroll_comments'], 'totalPosts' => $wp_query->found_posts, 'postsPerPage' => $posts_per_page, 'isPageNavi' => function_exists( 'wp_pagenavi' ), 'infScrollMsgText' => sprintf( __( 'Fetching %1$s of %2$s items left ...', 'blograzzi' ), 'window.blograzziInfScrollItemsPerPage', 'window.blograzziInfScrollItemsLeft' ), 'infScrollMsgTextPlural'=> sprintf( _n( 'Fetching %1$s of %2$s item left ...', 'Fetching %1$s of %2$s items left ...', $posts_per_page, 'blograzzi' ), 'window.blograzziInfScrollItemsPerPage', 'window.blograzziInfScrollItemsLeft' ), 'infScrollFinishedText' => __( 'All loaded!', 'blograzzi' ), 'commentsPerPage' => $comments_per_page, 'totalComments' => blograzzi_get_comment_count( 'comments', true, true ), 'infScrollCommentsMsg' => sprintf( __( 'Fetching %1$s of %2$s comments left ...', 'blograzzi' ), 'window.blograzziInfScrollCommentsPerPage', 'window.blograzziInfScrollCommentsLeft' ), 'infScrollCommentsMsgPlural'=> sprintf( _n( 'Fetching %1$s of %2$s comments left ...', 'Fetching %1$s of %2$s comments left ...', $comments_per_page, 'blograzzi' ), 'window.blograzziInfScrollCommentsPerPage', 'window.blograzziInfScrollCommentsLeft' ), 'infScrollCommentsFinishedMsg' => __( 'All comments loaded!', 'blograzzi' ), ); wp_localize_script( 'blograzzi', 'blograzziJS', apply_filters( 'blograzzi_js_object', $js_object ) ); } add_action( 'wp_enqueue_scripts', 'blograzzi_localize_scripts' ); /** * Generate the stylesheet link for Google Fonts */ function blograzzi_google_fonts_uri(){ $query_args = array( 'family' => 'Lato:400,400i,700,700i', 'subset' => 'latin', ); return add_query_arg( apply_filters( 'blograzzi_google_fonts', $query_args ), "//fonts.googleapis.com/css" ); } /** * Ensure correct ordering of stylesheets when using a child theme * @since Blograzzi 2.0.3 */ function blograzzi_child_stylesheets_order(){ global $wp_styles; if ( ! $wp_styles->registered ) return; $child_stylesheet = get_stylesheet_uri(); if ( $child_stylesheet == BLOGRAZZI_ROOTURI . '/style.css' ) return; $parent_theme = wp_get_theme( basename( BLOGRAZZI_ROOTDIR ) ); $parent_stylesheet = basename( BLOGRAZZI_ROOTURI ) . '/style.css'; foreach ( $wp_styles->registered as $handle => $script ) { if ( stripos( $script->src, $parent_stylesheet ) !== false ) { $wp_styles->registered[$handle]->deps = array_merge( $script->deps, array( 'bootstrap', 'font-awesome' ) ); $wp_styles->registered[$handle]->ver = $parent_theme->Version; $parent_handle = $handle; } if ( $script->src === $child_stylesheet ) $child_handles[] = $handle; } foreach ( $child_handles as $handle ){ if ( count( $child_handles ) > 1 && $handle === 'blograzzi' ) { unset( $wp_styles->registered['blograzzi'] ); continue; } if ( isset( $parent_handle ) ) { $wp_styles->registered[$handle]->deps[] = $parent_handle; $wp_styles->registered[$handle]->deps = array_unique( $wp_styles->registered[$handle]->deps ); } } } add_action( 'wp_enqueue_scripts', 'blograzzi_child_stylesheets_order', 100 );