/** * Enqueue scripts and styles. */ function presscore_enqueue_scripts() { global $wp_styles; // enqueue web fonts if needed presscore_enqueue_web_fonts(); $theme_version = wp_get_theme()->get('Version'); $template_directory = PRESSCORE_THEME_DIR; $template_uri = PRESSCORE_THEME_URI; presscore_enqueue_theme_stylesheet('dt-main', 'css/main'); presscore_enqueue_theme_stylesheet('dt-old-ie', 'css/old-ie'); $wp_styles->add_data('dt-old-ie', 'conditional', 'lt IE 10'); presscore_enqueue_theme_stylesheet('dt-awsome-fonts', 'fonts/FontAwesome/css/font-awesome'); if (locate_template('fonts/fontello/css/fontello.css', false)) { presscore_enqueue_theme_stylesheet('dt-fontello', 'fonts/fontello/css/fontello'); } presscore_enqueue_dynamic_stylesheets(); $wp_styles->add_data('dt-custom-old-ie.less', 'conditional', 'lt IE 10'); $config = Presscore_Config::get_instance(); if ('slideshow' == $config->get('header_title') && '3d' == $config->get('slideshow_mode')) { presscore_enqueue_theme_stylesheet('dt-3d-slider', 'css/compatibility/3D-slider'); } wp_enqueue_style('style', get_stylesheet_uri(), array(), $theme_version); presscore_enqueue_theme_script('dt-above-fold', 'js/above-the-fold', array('jquery'), $theme_version, false); // detect device type $detect = new Mobile_Detect(); $device_type = $detect->isMobile() ? $detect->isTablet() ? 'tablet' : 'phone' : 'computer'; presscore_enqueue_theme_script('dt-main', 'js/main', array('jquery'), $theme_version, true); $config->set('device_type', $device_type); if (is_page()) { $page_data = array('type' => 'page', 'template' => $config->get('template'), 'layout' => $config->get('justified_grid') ? 'jgrid' : $config->get('layout')); } else { if (is_archive()) { $page_data = array('type' => 'archive', 'template' => $config->get('template'), 'layout' => $config->get('justified_grid') ? 'jgrid' : $config->get('layout')); } else { if (is_search()) { $page_data = array('type' => 'search', 'template' => $config->get('template'), 'layout' => $config->get('justified_grid') ? 'jgrid' : $config->get('layout')); } else { $page_data = false; } } } global $post; $dt_local = array('passText' => __('To view this protected post, enter the password below:', 'the7mk2'), 'moreButtonText' => array('loading' => __('Loading...', 'the7mk2')), 'postID' => empty($post->ID) ? null : $post->ID, 'ajaxurl' => esc_url(admin_url('admin-ajax.php')), 'contactNonce' => wp_create_nonce('dt_contact_form'), 'ajaxNonce' => wp_create_nonce('presscore-posts-ajax'), 'pageData' => $page_data, 'themeSettings' => array('smoothScroll' => of_get_option('general-smooth_scroll', 'on'), 'lazyLoading' => 'lazy_loading' === $config->get('load_style'), 'accentColor' => array(), 'floatingHeader' => array('showAfter' => $config->get('header.floating_navigation.show_after'), 'showMenu' => dt_sanitize_flag($config->get('header.floating_navigation.enabled')), 'height' => of_get_option('header-floating_navigation-height')), 'mobileHeader' => array('firstSwitchPoint' => of_get_option('header-mobile-first_switch-after', 1024), 'secondSwitchPoint' => of_get_option('header-mobile-second_switch-after', 200)), 'content' => array('responsivenessTreshold' => of_get_option('general-responsiveness-treshold', 800), 'textColor' => of_get_option('content-primary_text_color', '#000000'), 'headerColor' => of_get_option('content-headers_color', '#000000')), 'stripes' => array('stripe1' => array('textColor' => of_get_option('stripes-stripe_1_text_color', '#000000'), 'headerColor' => of_get_option('stripes-stripe_1_headers_color', '#000000')), 'stripe2' => array('textColor' => of_get_option('stripes-stripe_2_text_color', '#000000'), 'headerColor' => of_get_option('stripes-stripe_2_headers_color', '#000000')), 'stripe3' => array('textColor' => of_get_option('stripes-stripe_3_text_color', '#000000'), 'headerColor' => of_get_option('stripes-stripe_3_headers_color', '#000000'))))); // floating menu $logo = presscore_get_logo_src(presscore_get_floating_menu_logos_meta()); $dt_local['themeSettings']['floatingHeader']['logo'] = array('showLogo' => 'none' !== $config->get('header.floating_navigation.logo.style'), 'src' => empty($logo[0]) ? '' : $logo[0], 'w' => empty($logo[1]) ? '' : $logo[1], 'h' => empty($logo[2]) ? '' : $logo[2]); switch ($config->get('template.accent.color.mode')) { case 'gradient': $dt_local['themeSettings']['accentColor']['mode'] = 'gradient'; $dt_local['themeSettings']['accentColor']['color'] = of_get_option('general-accent_bg_color_gradient', array('#000000', '#000000')); break; case 'color': default: $dt_local['themeSettings']['accentColor']['mode'] = 'solid'; $dt_local['themeSettings']['accentColor']['color'] = of_get_option('general-accent_bg_color', '#000000'); } $dt_local = apply_filters('presscore_localized_script', $dt_local); // add some additional data wp_localize_script('dt-above-fold', 'dtLocal', $dt_local); // comments clear script if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } $custom_css = of_get_option('general-custom_css', ''); if ($custom_css) { wp_add_inline_style('style', $custom_css); } }
/** * Enqueue scripts and styles. */ function presscore_enqueue_scripts() { /////////////////////////// // Enqueue stylesheets // /////////////////////////// // enqueue web fonts if needed presscore_enqueue_web_fonts(); // main.css presscore_enqueue_theme_stylesheet( 'dt-main', 'css/main' ); // font-awesome presscore_enqueue_theme_stylesheet( 'dt-awsome-fonts', 'css/font-awesome' ); // compiled less stylesheets presscore_enqueue_dynamic_stylesheets(); // responsiveness if ( presscore_responsive() ) { presscore_enqueue_theme_stylesheet( 'dt-media', 'css/media' ); } // RoyalSlider presscore_enqueue_theme_stylesheet( 'dt-royalslider', 'royalslider/royalslider' ); // theme stylesheet wp_enqueue_style( 'style', get_stylesheet_uri(), array(), wp_get_theme()->get( 'Version' ) ); ////////////////// // Custom css // ////////////////// $custom_css = of_get_option( 'general-custom_css', '' ); if ( $custom_css ) { wp_add_inline_style( 'style', $custom_css ); } /////////////////////// // Enqueue scripts // /////////////////////// // in header presscore_enqueue_theme_script( 'dt-modernizr', 'js/modernizr', array( 'jquery' ), false, false ); presscore_enqueue_theme_script( 'svg-icons', 'js/svg-icons', array( 'jquery' ), false, false ); // in footer presscore_enqueue_theme_script( 'dt-royalslider', 'royalslider/jquery.royalslider' ); // presscore_enqueue_theme_script( 'dt-animate', 'js/animate-elements' ); presscore_enqueue_theme_script( 'dt-plugins', 'js/plugins' ); // detect device type $detect = new Mobile_Detect; $device_type = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer'); // enqueue device specific scripts switch( $device_type ) { case 'tablet': presscore_enqueue_theme_script( 'dt-tablet', 'js/desktop-tablet' ); break; case 'phone': presscore_enqueue_theme_script( 'dt-phone', 'js/phone' ); break; default: presscore_enqueue_theme_script( 'dt-tablet', 'js/desktop-tablet' ); presscore_enqueue_theme_script( 'dt-desktop', 'js/desktop' ); } // main.js presscore_enqueue_theme_script( 'dt-main', 'js/main' ); // comments clear script if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } ///////////////////// // Localize data // ///////////////////// $config = Presscore_Config::get_instance(); $config->set( 'device_type', $device_type ); if ( is_page() ) { $page_data = array( 'type' => 'page', 'template' => $config->get('template'), 'layout' => $config->get('justified_grid') ? 'jgrid' : $config->get('layout') ); } else if ( is_archive() ) { $page_data = array( 'type' => 'archive', 'template' => $config->get('template'), 'layout' => $config->get('justified_grid') ? 'jgrid' : $config->get('layout') ); } else if ( is_search() ) { $page_data = array( 'type' => 'search', 'template' => $config->get('template'), 'layout' => $config->get('justified_grid') ? 'jgrid' : $config->get('layout') ); } else { $page_data = false; } global $post; $dt_local = array( 'passText' => __('To view this protected post, enter the password below:', LANGUAGE_ZONE), 'moreButtonAllLoadedText' => __('Everything is loaded', LANGUAGE_ZONE), 'moreButtonText' => array( 'loading' => __( 'Loading...', LANGUAGE_ZONE ), ), 'postID' => empty( $post->ID ) ? null : $post->ID, 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'contactNonce' => wp_create_nonce('dt_contact_form'), 'ajaxNonce' => wp_create_nonce('presscore-posts-ajax'), 'pageData' => $page_data, 'themeSettings' => array( 'smoothScroll' => of_get_option('general-smooth_scroll', 'on'), 'lazyLoading' => ( 'lazy_loading' == $config->get( 'load_style' ) ) ) ); wp_localize_script( 'dt-plugins', 'dtLocal', $dt_local ); }