for posts and comments.
add_theme_support( 'automatic-feed-links' );
// Enable support for Post Thumbnails, and declare two sizes.
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 672, 372, true );
add_image_size( 'basetheme-full-width', 1038, 576, true );
// This theme uses wp_nav_menu() in two locations.
register_nav_menus( array(
'primary' => __( 'Top primary menu', 'basee' ),
'secondary' => __( 'Secondary menu in left sidebar', 'basee' ),
'topmenu' => __( 'Topbar Menu in Topbar sidebar', 'basee' )
) );
/*
* 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', 'audio', 'quote', 'link', 'gallery',
) );
// This theme allows users to set a custom background.
add_theme_support( 'custom-background', apply_filters( 'basetheme_fnc_custom_background_args', array(
'default-color' => 'f5f5f5',
) ) );
// add support for display browser title
add_theme_support( 'title-tag' );
// This theme uses its own gallery styles.
add_filter( 'use_default_gallery_style', '__return_false' );
basetheme_fnc_get_load_plugins();
}
endif; // basetheme_fnc_setup
add_action( 'after_setup_theme', 'basetheme_fnc_setup' );
/**
* batch including all files in a path.
*
* @param String $path : PATH_DIR/*.php or PATH_DIR with $ifiles not empty
*/
function basetheme_pbr_includes( $path, $ifiles=array() ){
if( !empty($ifiles) ){
foreach( $ifiles as $key => $file ){
$file = $path.'/'.$file;
if(is_file($file)){
require($file);
}
}
}else {
$files = glob($path);
foreach ($files as $key => $file) {
if(is_file($file)){
require($file);
}
}
}
}
/**
* Get Theme Option Value.
* @param String $name : name of prameters
*/
function basetheme_fnc_theme_options($name, $default = false) {
// get the meta from the database
$options = ( get_option( 'pbr_theme_options' ) ) ? get_option( 'pbr_theme_options' ) : null;
// d( $options );
// return the option if it exists
if ( isset( $options[$name] ) ) {
return apply_filters( 'pbr_theme_options_$name', $options[ $name ] );
}
if( get_option( $name ) ){
return get_option( $name );
}
// return default if nothing else
return apply_filters( 'pbr_theme_options_$name', $default );
}
/**
* Adjust content_width value for image attachment template.
*
* @since Basee 1.0
*/
function basetheme_fnc_content_width() {
if ( is_attachment() && wp_attachment_is_image() ) {
$GLOBALS['content_width'] = 810;
}
}
add_action( 'template_redirect', 'basetheme_fnc_content_width' );
/**
* Require function for including 3rd plugins
*
*/
basetheme_pbr_includes( get_template_directory() . '/inc/plugins/*.php' );
function basetheme_fnc_get_load_plugins(){
$plugins[] =(array(
'name' => 'MetaBox', // The plugin name
'slug' => 'meta-box', // The plugin slug (typically the folder name)
'required' => true, // If false, the plugin is only 'recommended' instead of required
));
$plugins[] =(array(
'name' => 'WooCommerce', // The plugin name
'slug' => 'woocommerce', // The plugin slug (typically the folder name)
'required' => true, // If false, the plugin is only 'recommended' instead of required
));
$plugins[] =(array(
'name' => 'YITH WooCommerce Zoom Magnifier', // The plugin name
'slug' => 'yith-woocommerce-zoom-magnifier', // The plugin slug (typically the folder name)
'required' => true
));
$plugins[] =(array(
'name' => 'MailChimp', // The plugin name
'slug' => 'mailchimp-for-wp', // The plugin slug (typically the folder name)
'required' => true
));
$plugins[] =(array(
'name' => 'Contact Form 7', // The plugin name
'slug' => 'contact-form-7', // The plugin slug (typically the folder name)
'required' => true, // If false, the plugin is only 'recommended' instead of required
));
$plugins[] =(array(
'name' => 'Opal Import/Export Sample', // The plugin name
'slug' => 'opalsampletools', // The plugin slug (typically the folder name)
'required' => true ,
'source' => 'http://www.wpopal.com/thememods/opalsampletools.zip'
));
$plugins[] =(array(
'name' => 'Image Widget', // The plugin name
'slug' => 'image-widget', // The plugin slug (typically the folder name)
'required' => true
));
$plugins[] =(array(
'name' => 'Slideshow', // The plugin name
'slug' => 'slideshow-jquery-image-gallery', // The plugin slug (typically the folder name)
'required' => true
));
$plugins[] =(array(
'name' => 'Boostrap Shortcodes', // The plugin name
'slug' => 'bootstrap-shortcodes', // The plugin slug (typically the folder name)
'required' => true
));
if( function_exists("tgmpa") ){
tgmpa( $plugins );
}
}
/* Back end */
if( is_admin() ) {
basetheme_pbr_includes( get_template_directory() . '/inc/classes/admin/*.php' );
}
/**
* Register three Basee widget areas.
*
* @since Basee 1.0
*/
function basetheme_fnc_registart_widgets_sidebars() {
register_sidebar(
array(
'name' => __( 'Sidebar Default', 'basee' ),
'id' => 'sidebar-default',
'description' => __( 'Appears on posts and pages in the sidebar.', 'basee'),
'before_widget' => '',
'before_title' => '
',
));
register_sidebar(
array(
'name' => __( 'Blog Left Sidebar' , 'basee'),
'id' => 'blog-sidebar-left',
'description' => __( 'Appears on posts and pages in the sidebar.', 'basee'),
'before_widget' => '',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Blog Right Sidebar', 'basee'),
'id' => 'blog-sidebar-right',
'description' => __( 'Appears on posts and pages in the sidebar.', 'basee'),
'before_widget' => '',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Footer 1' , 'basee'),
'id' => 'footer-1',
'description' => __( 'Appears in the footer section of the site.', 'basee'),
'before_widget' => '',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Footer 2' , 'basee'),
'id' => 'footer-2',
'description' => __( 'Appears in the footer section of the site.', 'basee'),
'before_widget' => '',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Footer 3' , 'basee'),
'id' => 'footer-3',
'description' => __( 'Appears in the footer section of the site.', 'basee'),
'before_widget' => '',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Footer 4' , 'basee'),
'id' => 'footer-4',
'description' => __( 'Appears in the footer section of the site.', 'basee'),
'before_widget' => '',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Footer 5' , 'basee'),
'id' => 'footer-5',
'description' => __( 'Appears in the footer section of the site.', 'basee'),
'before_widget' => '',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Mass Header Body' , 'basee'),
'id' => 'mass-header-body',
'description' => __( 'Appears in the top of header section of the site.', 'basee'),
'before_widget' => '',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Mass Footer Body' , 'basee'),
'id' => 'mass-footer-body',
'description' => __( 'Appears in the end of footer section of the site.', 'basee'),
'before_widget' => '',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Top HightLight' , 'basee'),
'id' => 'top-highlight-sidebar',
'description' => __( 'Appears in the top of main content section of the site.', 'basee'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Main Content Sidebar' , 'basee'),
'id' => 'main-content-sidebar',
'description' => __( 'Appears in the main column of the site.', 'basee'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Promo Sidebar' , 'basee'),
'id' => 'promo-sidebar',
'description' => __( 'Appears in the main content of the site.', 'basee'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Left One Half Sidebar' , 'basee'),
'id' => 'left-one-half-sidebar',
'description' => __( 'Appears wih one half of main content of the site.', 'basee'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Right One Half Sidebar' , 'basee'),
'id' => 'right-one-half-sidebar',
'description' => __( 'Appears wih one half of main content of the site.', 'basee'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Full Width Sidebar' , 'basee'),
'id' => 'fullwidth-sidebar',
'description' => __( 'Appears in the main content of the site.', 'basee'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Left One Third Sidebar' , 'basee'),
'id' => 'left-one-third-sidebar',
'description' => __( 'Appears in the main content of the site.', 'basee'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Right One Third Sidebar' , 'basee'),
'id' => 'right-one-third-sidebar',
'description' => __( 'Appears in the main content of the site.', 'basee'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Center One Third Sidebar' , 'basee'),
'id' => 'center-one-third-sidebar',
'description' => __( 'Appears in the main content of the site.', 'basee'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Contact Left Sidebar' , 'basee'),
'id' => 'contact-left-sidebar',
'description' => __( 'Appears in the contact page of the site.', 'basee'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Contact Right Sidebar' , 'basee'),
'id' => 'contact-right-sidebar',
'description' => __( 'Appears in the contact page of the site.', 'basee'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'WooCommerce Sidebar' , 'basee'),
'id' => 'woocommerce-sidebar',
'description' => __( 'Appears in the shop page of the site.', 'basee'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'Parallax Sidebar' , 'basee'),
'id' => 'parallax-sidebar',
'description' => __( 'Appears in the about page of the site.', 'basee'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
register_sidebar(
array(
'name' => __( 'About Main Sidebar' , 'basee'),
'id' => 'about-main-sidebar',
'description' => __( 'Appears in the about page of the site.', 'basee'),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
));
}
add_action( 'widgets_init', 'basetheme_fnc_registart_widgets_sidebars' );
/**
* Register Roboto Google font for Basee.
*
* @since Basee 1.0
*
* @return string
*/
function basetheme_fnc_font_url() {
$fonts_url = '';
/* Translators: If there are characters in your language that are not
* supported by Lora, translate this to 'off'. Do not translate
* into your own language.
*/
$lora = _x( 'on', 'Hind font: on or off', 'basee' );
/* Translators: If there are characters in your language that are not
* supported by Open Sans, translate this to 'off'. Do not translate
* into your own language.
*/
$roboto = _x( 'on', 'Roboto font: on or off', 'basee' );
if ( 'off' !== $lora || 'off' !== $roboto ) {
$font_families = array();
if ( 'off' !== $lora ) {
$font_families[] = 'Montserrat:400,700';
}
if ( 'off' !== $roboto ) {
$font_families[] = 'Roboto:400,400italic,300,300italic,900,700italic,700,500';
}
$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 );
}
/**
* Enqueue scripts and styles for the front end.
*
* @since Basee 1.0
*/
function basetheme_fnc_scripts() {
// Add Lato font, used in the main stylesheet.
wp_enqueue_style( 'basetheme-roboto', basetheme_fnc_font_url(), array(), null );
// Add Genericons font, used in the main stylesheet.
wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.0.3' );
// Load our main stylesheet.
wp_enqueue_style( 'basetheme-style', get_stylesheet_uri() );
// Load the Internet Explorer specific stylesheet.
wp_enqueue_style( 'basetheme-ie', get_template_directory_uri() . '/css/ie.css', array( 'basetheme-style' ), '20131205' );
wp_style_add_data( 'basetheme-ie', 'conditional', 'lt IE 9' );
// Load FlexSlider stylesheet
wp_enqueue_style('basetheme-flexslider', get_template_directory_uri() . '/css/flexslider.css');
wp_enqueue_style('basetheme-fonticon', get_template_directory_uri() . '/css/font-awesome.css');
wp_enqueue_script( 'basetheme-bootstrap-min', get_template_directory_uri() . '/js/bootstrap.min.js', array( 'jquery' ), '20130402' );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_singular() && wp_attachment_is_image() ) {
wp_enqueue_script( 'basetheme-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20130402' );
}
if ( is_active_sidebar( 'sidebar-3' ) ) {
wp_enqueue_script( 'jquery-masonry' );
}
if ( is_front_page() && 'slider' == get_theme_mod( 'featured_content_layout' ) ) {
wp_enqueue_script( 'basetheme-slider', get_template_directory_uri() . '/js/slider.js', array( 'jquery' ), '20131205', true );
wp_localize_script( 'basetheme-slider', 'featuredSliderDefaults', array(
'prevText' => __( 'Previous', 'basee' ),
'nextText' => __( 'Next', 'basee' )
) );
}
wp_enqueue_script( 'basetheme-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20150315', true );
wp_enqueue_script( 'basetheme-owl-carousel', get_template_directory_uri() . '/js/owl-carousel/owl.carousel.js', array( 'jquery' ), '20150315', true );
wp_enqueue_script('basetheme-flexslider', get_template_directory_uri() . '/js/jquery.flexslider.js', array('jquery'), '2.2.0', true);
wp_enqueue_script('basetheme-custom-js', get_template_directory_uri() . '/js/custom.js', array('jquery'), '2.2.0', true);
}
add_action( 'wp_enqueue_scripts', 'basetheme_fnc_scripts' );
/**
* Enqueue Google fonts style to admin screen for custom header display.
*
* @since Basee 1.0
*/
function basetheme_fnc_admin_fonts() {
wp_enqueue_style( 'basetheme-lato', basetheme_fnc_font_url(), array(), null );
}
add_action( 'admin_print_scripts-appearance_page_custom-header', 'basetheme_fnc_admin_fonts' );
/**
* Implement rick meta box for post and page, custom post types. These 're used with metabox plugins
*/
if( is_admin() ){
basetheme_pbr_includes( get_template_directory() . '/inc/admin/metabox/*.php' );
}
basetheme_pbr_includes( get_template_directory() . '/inc/classes/*.php' );
basetheme_pbr_includes( get_template_directory() . '/inc/*.php' );
/**
* Register Widget
*/
//require get_template_directory() . '/includes/widgets.php';
basetheme_pbr_includes( get_template_directory() . '/inc/widgets/*.php' );
function basetheme_widgets() {
register_widget( 'Prestabase_Articles_List_Widget' );
register_widget( 'Prestabase_Tagline_Widget' );
register_widget( 'Prestabase_Our_Service_Widget' );
register_widget( 'Prestabase_Products_List_Widget' );
register_widget( 'Prestabase_Products_Tabs_Widget' );
register_widget( 'Prestabase_Products_Category_Widget' );
// register_widget( 'Prestabase_Brands_Widget' );
// register_widget( 'Prestabase_Testimonials_Widget' );
// register_widget( 'Prestabase_Our_Team_Widget' );
}
add_action( 'widgets_init', 'basetheme_widgets' );
function base_get_page_layout() {
global $post;
$layout = get_post_meta( $post->ID, 'layout_skin', 1 );
if ('right' == $layout) {
$layout = 'right-sidebar';
} elseif ('left' == $layout) {
$layout = 'left-sidebar';
} else {
$layout = 'full-width';
}
return 'templates/' . $layout;
}
function search_by_cat() {
global $wp_query;
if (is_search() && $_GET['post_type'] == 'product' && isset($_GET['product_category'])) {
$cat = $_GET['product_category'];
$cat = $cat ? $cat : '';
$wp_query->query_vars['product_cat'] = $cat;
}
}
add_action('pre_get_posts', 'search_by_cat');
if(!function_exists('basetheme_pagination_nav')) {
function basetheme_pagination_nav($per_page, $total, $max_num_pages=''){
?>
'')) {
global $wp_query, $wp_rewrite;
$wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
if($pages==''){
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
$pagination = array(
'base' => @add_query_arg('paged','%#%'),
'format' => '',
'total' => $pages,
'current' => $current,
'prev_text' => $prev,
'next_text' => $next,
'type' => 'array'
);
if( $wp_rewrite->using_permalinks() )
$pagination['base'] = user_trailingslashit( trailingslashit( remove_query_arg( 's', get_pagenum_link( 1 ) ) ) . 'page/%#%/', 'paged' );
if(isset( $_GET['s'])){
$cq = $_GET['s'];
$sq = str_replace(" ", "+", $cq);
}
if( !empty($wp_query->query_vars['s']) ){
$pagination['add_args'] = array( 's' => $sq);
}
if(paginate_links( $pagination )!=''){
$paginations = paginate_links( $pagination );
echo '';
}
}
}
if(!function_exists('basetheme_cartdropdown')){
function basetheme_cartdropdown(){
if(PBR_WOOCOMMERCE_ACTIVED){
global $woocommerce;
?>
'primary',
'theme_location' => 'primary',
'depth' => 2,
'container' => 'div',
'container_class' => 'collapse navbar-collapse navbar-ex1-collapse',
'menu_class' => 'nav navbar-nav',
'fallback_cb' => 'Basee_Bootstrap_navwalker::fallback',
'walker' => new Basee_Bootstrap_navwalker()
));
}
}