This file loads all the needed files for the theme to work properly. * IMPORTANT : DO NOT USE AN "ILLEGAL" COPY OF THIS THEME * IMPORTANT : DO NOT EVER EDIT THIS FILE * IMPORTANT : DO NOT COPY AND PASTE THIS FILE INTO YOUR CHILD THEME * IMPORTANT : DO NOT EVER COPY AND PASTE ANYTHING FROM THIS FILE TO YOUR CHILD THEME BECAUSE IT WILL CAUSE ERRORS * * White Paper is a very powerful theme and virtually anything can be customized * via a child theme. If you need any help altering a function, just let us know we are here to help! * * Advanced customizations aren't included with your purchase but if it's a simple task we can assist :) * * * @package White Paper WordPress Theme * @subpackage Templates * @version 1.0.0 */ // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) { exit; } class White_Papers_Init { function __construct(){ /***********************************************************************************************/ /* Theme Setup Actions and Filters */ /***********************************************************************************************/ add_action( 'after_setup_theme' , array( $this, 'wpc_theme_setup')); add_action( 'after_setup_theme' , array( $this, 'wpc_widgets')); add_action( 'vc_before_init', array( $this, 'wpc_vcSetAsTheme')); add_action( 'wp_enqueue_scripts' , array( $this, 'wpc_theme_scripts_styles')); add_action( 'widgets_init' , array( $this, 'wpc_register_sidebars')); add_action( 'wpc_pagination_nav', array($this, 'render_pagination_navigation'), 10, 3 ); add_filter('user_contactmethods', array($this, 'add_to_author_profile'), 10, 1); add_filter( 'wp_nav_menu_objects', array($this, 'add_has_children_to_nav_items')); add_filter( 'excerpt_length', array($this , 'custom_excerpt_length'), 999 ); add_action( 'wpc_breadcrumbs', array($this, 'render_wpc_breadcrumbs') ); add_filter('style_loader_tag', array($this, 'wpc_remove_type_attr'), 10, 2); add_filter('script_loader_tag', array($this, 'wpc_remove_type_attr'), 10, 2); /***********************************************************************************************/ /* Including White Paper Custom Hooks */ /***********************************************************************************************/ require_once get_parent_theme_file_path('inc/templates/related-posts.php'); require_once get_parent_theme_file_path('inc/templates/featured-image.php'); require_once get_parent_theme_file_path('inc/templates/author-bio.php'); require_once get_parent_theme_file_path('inc/templates/social-share.php'); require_once get_parent_theme_file_path('inc/templates/pre-loader.php'); require_once get_parent_theme_file_path('inc/templates/comments.php'); require_once get_parent_theme_file_path('inc/templates/login-nav.php'); require_once get_parent_theme_file_path('inc/templates/top-bar-social.php'); require_once get_parent_theme_file_path('inc/templates/search-form.php'); require_once get_parent_theme_file_path('inc/templates/post-carousel.php'); require_once get_parent_theme_file_path('inc/templates/footer-callout.php'); require_once get_parent_theme_file_path('inc/templates/footer-carousel.php'); require_once get_parent_theme_file_path('inc/templates/footer-social.php'); require_once get_parent_theme_file_path('inc/templates/footer-copyright.php'); require_once get_parent_theme_file_path('inc/templates/page-title.php'); require_once get_parent_theme_file_path('inc/templates/headers.php'); require_once get_parent_theme_file_path('inc/templates/topbar.php'); require_once get_parent_theme_file_path('inc/templates/audio-post.php'); require_once get_parent_theme_file_path('inc/templates/video-post.php'); require_once get_parent_theme_file_path('inc/templates/check-post-format.php'); require_once get_parent_theme_file_path('inc/templates/single-audio-post.php'); require_once get_parent_theme_file_path('inc/templates/single-video-post.php'); require_once get_parent_theme_file_path('inc/templates/slider.php'); /***********************************************************************************************/ /* Including Classes */ /***********************************************************************************************/ if (class_exists('Kirki')) { require_once get_parent_theme_file_path('inc/classes/theme-options.php'); } require_once get_parent_theme_file_path('inc/metaboxes/post.settings.class.php'); require_once get_parent_theme_file_path('inc/classes/nav-walker.php'); require_once get_parent_theme_file_path('inc/classes/helper-functions.php'); require_once get_parent_theme_file_path('inc/classes/class-tgm-plugin-activation.php'); require_once get_parent_theme_file_path('inc/classes/required_plugins.php'); require_once get_parent_theme_file_path('inc/classes/one-click-demo-importer.php'); } /***********************************************************************************************/ /* Function called on theme activation */ /***********************************************************************************************/ function wpc_theme_setup() { load_theme_textdomain('blue-paper', get_template_directory() . '/languages'); /** *** Set up the content width value based on the theme's design and stylesheet. **/ if (! isset ( $content_width )){ global $content_width; $content_width = 800; } /** *** 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'); /** *** register nav manu for theme *** register_nav_menus( array( '$location' => __( '$discription', 'theme_slug') , ) ); **/ register_nav_menus( array( 'primary' => __('Main Menu', 'blue-paper'), ) ); /** *** Add default posts and comments RSS feed links to head. **/ add_theme_support ('automatic-feed-links'); add_theme_support('custom-header'); add_theme_support('woocommerce'); add_editor_style(); /** *** Enable support for Post Thumbnails on posts and pages. @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails **/ add_theme_support ('post-thumbnails'); /** *** our theme sidebar images and post images size **/ add_image_size('blog-feature-img', 240, 172, true); add_image_size('blog-carousel-img', 1157, 495, true); add_image_size('footer-carousel', 318, 319, true); add_image_size('related-posts', 170, 113, true); /** *** 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' ) ); /** *** Setup the WordPress core custom background feature. **/ add_theme_support('custom-background', apply_filters ('wpc_custom_background_args', array ( 'default-color' => '#F2F2F2', 'default-image' => '' ))); /* * Enable support for Post Formats. * * See: https://codex.wordpress.org/Post_Formats */ add_theme_support('post-formats', array( 'video', 'gallery', 'audio' )); } /** * White paper - Loading all custom widget classes * @since 1.0 */ function wpc_widgets(){ // Define array of custom widgets for the theme $widgets = apply_filters( 'wpc_custom_widgets', array( 'recent-posts', 'posts-carousel', 'follow-us', )); // Loading widgets classes foreach ( $widgets as $widget ) { require_once('inc/widgets/'. $widget .'.php'); } } /** * Visual Composer Support * @since 1.0 */ function wpc_vcSetAsTheme() { vc_set_as_theme(); } function wpc_theme_scripts_styles() { // Load the html5 shiv. wp_enqueue_script('html5', get_template_directory_uri().'/js/html5shiv.min.js'); wp_script_add_data('html5', 'conditional', 'lt IE 9'); // Required CSS wp_enqueue_style('wpc-lib-css', get_template_directory_uri().'/assests/css/lib.css'); wp_enqueue_style('wpc-main-css', get_template_directory_uri().'/assests/css/main.css'); wp_enqueue_style('wpc-style-css', get_template_directory_uri().'/style.css'); wp_enqueue_style('wpc-revolution-css', get_template_directory_uri().'/assests/revolution/css/settings.css'); wp_enqueue_style('wpc-rtl-css', get_template_directory_uri().'/assests/css/rtl.css'); wp_enqueue_style('wpc-slick-css', get_template_directory_uri().'/assests/slick/slick.css'); wp_enqueue_style('wpc-slick-theme-css', get_template_directory_uri().'/assests/slick/slick-theme.css'); // JavaScript wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('wpc-popper-js', get_template_directory_uri().'/assests/js/popper.min.js', array('jquery'),'1.0',true); wp_enqueue_script('wpc-lib-js', get_template_directory_uri().'/assests/js/lib.js', array('jquery'),'1.2',true); wp_enqueue_script('wpc-themepunch-tools-js', get_template_directory_uri().'/assests/revolution/js/jquery.themepunch.tools.min.js', array('jquery'),'1.3',true); wp_enqueue_script('wpc-themepunch-js', get_template_directory_uri().'/assests/revolution/js/jquery.themepunch.revolution.min.js', array('jquery'),'1.4',true); wp_enqueue_script('wpc-themepunch-actions-js', get_template_directory_uri().'/assests/revolution/js/extensions/revolution.extension.actions.min.js', array('jquery'),'1.5',true); wp_enqueue_script('wpc-themepunch-carousel-js', get_template_directory_uri().'/assests/revolution/js/extensions/revolution.extension.carousel.min.js', array('jquery'),'1.6',true); wp_enqueue_script('wpc-themepunch-kenburn-js', get_template_directory_uri().'/assests/revolution/js/extensions/revolution.extension.kenburn.min.js', array('jquery'),'1.7',true); wp_enqueue_script('wpc-themepunch-layeranimation-js', get_template_directory_uri().'/assests/revolution/js/extensions/revolution.extension.layeranimation.min.js', array('jquery'),'1.8',true); wp_enqueue_script('wpc-themepunch-migration-js', get_template_directory_uri().'/assests/revolution/js/extensions/revolution.extension.migration.min.js', array('jquery'),'1.9',true); wp_enqueue_script('wpc-themepunch-navigation-js', get_template_directory_uri().'/assests/revolution/js/extensions/revolution.extension.navigation.min.js', array('jquery'),'1.11',true); wp_enqueue_script('wpc-themepunch-parallax-js', get_template_directory_uri().'/assests/revolution/js/extensions/revolution.extension.parallax.min.js', array('jquery'),'1.12',true); wp_enqueue_script('wpc-themepunch-slideanims-js', get_template_directory_uri().'/assests/revolution/js/extensions/revolution.extension.slideanims.min.js', array('jquery'),'1.13',true); wp_enqueue_script('wpc-themepunch-video-js', get_template_directory_uri().'/assests/revolution/js/extensions/revolution.extension.video.min.js', array('jquery'),'1.14',true); wp_enqueue_script('wpc-slick-js', get_template_directory_uri().'/assests/js/functions.js', array('jquery'),'1.15',true); wp_enqueue_script('wpc-themepunch-functions-js', get_template_directory_uri().'/assests/slick/slick.min.js', array('jquery'),'1.15',true); wp_enqueue_script('wpc-functions-js', get_template_directory_uri().'/assests/js/functions.js', array('jquery'),'1.15',true); wp_enqueue_script('wpc-responsive-menu-js', get_template_directory_uri().'/assests/js/responsive-menu.js', array('jquery'),'1.15',true); // Dynamic css for primary color and settings ob_start(); include get_parent_theme_file_path('assests/css/primary-color.php'); $inline_styles = ob_get_clean(); wp_add_inline_style( 'wpc-main-css', $inline_styles ); } /***********************************************************************************************/ /* Sidebar call back */ /***********************************************************************************************/ function wpc_register_sidebars() { register_sidebar( array( 'name' => __( 'Main Side Bar', 'blue-paper' ), 'id' => 'main-side-bar', 'description' => __( 'Sidebar for all pages, posts and archives and blog pages', 'blue-paper' ), 'class' => 'widget', 'before_widget' => '<aside id="%1$s" class="widget widget_latestposts %2$s">', 'after_widget' => '</aside>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>' )); } /***********************************************************************************************/ /* White Paper pagination callback */ /***********************************************************************************************/ function render_pagination_navigation($max_num_pages = '', $dk = '', $paged = ''){ if ($max_num_pages == '') { $max_num_pages = $GLOBALS['wp_query']->max_num_pages; } // Don't print empty markup if there's only one page. if ( $max_num_pages < 2 ) { return; } if ($paged == '') { $paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1; } $pagenum_link = html_entity_decode( get_pagenum_link() ); $query_args = array(); $url_parts = explode( '?', $pagenum_link ); if ( isset( $url_parts[1] ) ) { wp_parse_str( $url_parts[1], $query_args ); } $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link ); $pagenum_link = trailingslashit( $pagenum_link ) . '%_%'; $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : ''; $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%'; ?> <nav class="navigation pagination"> <h2 class="screen-reader-text">Posts navigation</h2> <div class="nav-links"> <?php $pagination = paginate_links( array( 'base' => $pagenum_link, 'format' => $format, 'current' => $paged, 'total' => $max_num_pages, 'end_size' => 2, 'mid_size' => 1, 'add_args' => array_map( 'urlencode', $query_args ), 'type' => 'array', 'prev_text' => '<i class="fa fa-chevron-left"></i>', 'next_text' => '<i class="fa fa-chevron-right"></i>', ) ); if (is_array($pagination)) { foreach ($pagination as $link) { $the_css = ''; if (strpos($link, 'current') !== false) { $link = '<a class="current page-numbers">'.$link.'</a>'; } if (strpos($link, 'dots') !== false) { $the_css = 'dots'; $link = '<a class="page-numbers">'.$link.'</a>'; } echo $link; } } ?> </div> </nav><!-- Pagination /- --> <?php } /***********************************************************************************************/ /* Adding social profile in user */ /***********************************************************************************************/ function add_to_author_profile($contactmethods) { $contactmethods['rss_url'] = 'RSS URL'; $contactmethods['google_profile'] = 'Google'; $contactmethods['twitter_profile'] = 'Twitter'; $contactmethods['facebook_profile'] = 'Facebook'; $contactmethods['linkedin_profile'] = 'Linkedin'; return $contactmethods; } /***********************************************************************************************/ /* Adding custom css class into navigation */ /***********************************************************************************************/ function add_has_children_to_nav_items( $items ){ $parents = wp_list_pluck( $items, 'menu_item_parent'); foreach ( $items as $item ) in_array( $item->ID, $parents ) && $item->classes[] = 'dropdown'; return $items; } /***********************************************************************************************/ /* setting excerpt length for blog post */ /***********************************************************************************************/ function custom_excerpt_length($length) { return 20; } /***********************************************************************************************/ /* setting breadcrumbs */ /***********************************************************************************************/ function render_wpc_breadcrumbs(){ $showOnHome = 0; // 1 - show breadcrumbs on the homepage, 0 - don't show $delimiter = '/'; // delimiter between crumbs $home = '<i class="fa fa-home" aria-hidden="true"></i>'; // text for the 'Home' link $showCurrent = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show $before = '<a href="#">'; // tag before the current crumb $after = '</a>'; // tag after the current crumb global $post; $homeLink = home_url(); if (is_home() || is_front_page()) { if ($showOnHome == 1) echo '<div class="page-links text-center"><a href="' . $homeLink . '">' . $home . '</a></div>'; } else { echo '<div class="page-links text-center"><a href="' . $homeLink . '">' . $home . '</a> ' . $delimiter . ' '; if ( is_category() ) { $thisCat = get_category(get_query_var('cat'), false); if ($thisCat->parent != 0) echo get_category_parents($thisCat->parent, TRUE, ' ' . $delimiter . ' '); echo $before . 'Archive by category "' . single_cat_title('', false) . '"' . $after; } elseif ( is_search() ) { echo $before . 'Search results for "' . get_search_query() . '"' . $after; } elseif ( is_day() ) { echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' '; echo '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' '; echo $before . get_the_time('d') . $after; } elseif ( is_month() ) { echo '<a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' '; echo $before . get_the_time('F') . $after; } elseif ( is_year() ) { echo $before . get_the_time('Y') . $after; } elseif ( is_single() && !is_attachment() ) { if ( get_post_type() != 'post' ) { $post_type = get_post_type_object(get_post_type()); $slug = $post_type->rewrite; echo '<a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a>'; if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after; } else { $cat = get_the_category(); $cat = $cat[0]; $cats = get_category_parents($cat, TRUE, ' ' . $delimiter . ' '); if ($showCurrent == 0) $cats = preg_replace("#^(.+)\s$delimiter\s$#", "$1", $cats); echo $cats; if ($showCurrent == 1) echo $before . get_the_title() . $after; } } elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) { $post_type = get_post_type_object(get_post_type()); echo $before . $post_type->labels->singular_name . $after; } elseif ( is_attachment() ) { $parent = get_post($post->post_parent); $cat = get_the_category($parent->ID); $cat = $cat[0]; echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' '); echo '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a>'; if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after; } elseif ( is_page() && !$post->post_parent ) { if ($showCurrent == 1) echo $before . get_the_title() . $after; } elseif ( is_page() && $post->post_parent ) { $parent_id = $post->post_parent; $breadcrumbs = array(); while ($parent_id) { $page = get_page($parent_id); $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>'; $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); for ($i = 0; $i < count($breadcrumbs); $i++) { echo $breadcrumbs[$i]; if ($i != count($breadcrumbs)-1) echo ' ' . $delimiter . ' '; } if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after; } elseif ( is_tag() ) { echo $before . 'Posts tagged "' . single_tag_title('', false) . '"' . $after; } elseif ( is_author() ) { global $author; $userdata = get_userdata($author); echo $before . 'Articles posted by ' . $userdata->display_name . $after; } elseif ( is_404() ) { echo $before . 'Error 404' . $after; } if ( get_query_var('paged') ) { if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ' ('; echo __('Page', 'blue-paper') . ' ' . get_query_var('paged'); if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) echo ')'; } echo '</div>'; } } function wpc_remove_type_attr($tag, $handle) { return preg_replace( "/type=['\"]text\/(javascript|css)['\"]/", '', $tag ); } } // class end $wpc_main_ob = new White_Papers_Init();