'eeeeee',
'default-image' => '',
)));
// This variable is intended to be overruled from themes.
// Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}.
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
$GLOBALS['content_width'] = apply_filters( 'jatra_content_width', 1140 );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
add_image_size('jatra-500-300',500,300,true);
add_theme_support(
'custom-logo',
array(
'height' => 120,
'width' => 90,
'flex-height' => true,
'flex-width' => true,
)
);
/*
* 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' );
/*
* 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',
'script',
'style',
)
);
/*
* Posts Format.
*
* https://wordpress.org/support/article/post-formats/
*/
add_theme_support( 'post-formats', array(
'video',
'audio',
'gallery',
'quote',
'image'
) );
// Woocommerce Support
add_theme_support( 'woocommerce' );
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on Jatra, use a find and replace
* to change 'jatra' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'jatra', get_template_directory() . '/languages' );
// Add support for full and wide align images.
add_theme_support( 'align-wide' );
add_theme_support( 'responsive-embeds' );
add_theme_support( 'wp-block-styles' );
}
endif;
add_action( 'after_setup_theme', 'jatra_after_theme_support' );
/**
* Register and Enqueue Styles.
*/
function jatra_register_styles() {
$theme_version = wp_get_theme()->get( 'Version' );
$fonts_url = jatra_fonts_url();
if( $fonts_url ){
require_once get_theme_file_path( 'assets/lib/custom/css/wptt-webfont-loader.php' );
wp_enqueue_style(
'jatra-google-fonts',
wptt_get_webfont_url( $fonts_url ),
array(),
$theme_version
);
}
wp_enqueue_style( 'magnific-popup', get_template_directory_uri() . '/assets/lib/magnific-popup/magnific-popup.css' );
wp_enqueue_style( 'slick', get_template_directory_uri() . '/assets/lib/slick/css/slick.min.css');
wp_enqueue_style( 'jatra-style', get_stylesheet_uri(), array(), $theme_version );
wp_style_add_data('jatra-style', 'rtl', 'replace');
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
wp_enqueue_script( 'imagesloaded' );
wp_enqueue_script( 'magnific-popup', get_template_directory_uri() . '/assets/lib/magnific-popup/jquery.magnific-popup.min.js', array('jquery'), '', 1 );
wp_enqueue_script( 'slick', get_template_directory_uri() . '/assets/lib/slick/js/slick.min.js', array('jquery'), '', 1);
wp_enqueue_script( 'marquee', get_template_directory_uri() . '/assets/lib/jquery-marquee/jquery.marquee.min.js', array('jquery'), '', 1);
wp_enqueue_script( 'jatra-ajax', get_template_directory_uri() . '/assets/lib/custom/js/ajax.js', array('jquery'), '', 1 );
wp_enqueue_script( 'jatra-custom', get_template_directory_uri() . '/assets/lib/custom/js/custom.js', array('jquery'), '', 1);
wp_enqueue_script( 'jatra-pagination', get_template_directory_uri() . '/assets/lib/custom/js/pagination.js', array('jquery'), '', 1 );
$ajax_nonce = wp_create_nonce('jatra_ajax_nonce');
wp_localize_script(
'jatra-ajax',
'jatra_ajax',
array(
'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ),
'ajax_nonce' => $ajax_nonce,
)
);
// Global Query
if( is_front_page() ){
$posts_per_page = absint( get_option('posts_per_page') );
$c_paged = ( get_query_var( 'page' ) ) ? absint( get_query_var( 'page' ) ) : 1;
$posts_args = array(
'posts_per_page' => $posts_per_page,
'paged' => $c_paged,
);
$posts_qry = new WP_Query( $posts_args );
$max = $posts_qry->max_num_pages;
}else{
global $wp_query;
$max = $wp_query->max_num_pages;
$c_paged = ( get_query_var( 'paged' ) > 1 ) ? get_query_var( 'paged' ) : 1;
}
$jatra_default = jatra_get_default_theme_options();
$jatra_pagination_layout = get_theme_mod( 'jatra_pagination_layout',$jatra_default['jatra_pagination_layout'] );
// Get the permalink structure from WordPress settings.
$permalink_structure = get_option('permalink_structure');
// Pagination Data
wp_localize_script(
'jatra-pagination',
'jatra_pagination',
array(
'paged' => absint( $c_paged ),
'maxpage' => absint( $max ),
'nextLink' => next_posts( $max, false ),
'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ),
'loadmore' => esc_html__( 'Load More Posts', 'jatra' ),
'nomore' => esc_html__( 'No More Posts', 'jatra' ),
'loading' => esc_html__( 'Loading...', 'jatra' ),
'pagination_layout' => esc_html( $jatra_pagination_layout ),
'permalink_structure' => esc_html( $permalink_structure ),
'ajax_nonce' => $ajax_nonce,
)
);
global $post;
$single_post = 0;
$jatra_ed_post_reaction = '';
if( isset( $post->ID ) && isset( $post->post_type ) && $post->post_type == 'post' ){
$jatra_ed_post_reaction = esc_html( get_post_meta( $post->ID, 'jatra_ed_post_reaction', true ) );
$single_post = 1;
}
wp_localize_script(
'jatra-custom',
'jatra_custom',
array(
'single_post' => absint( $single_post ),
'jatra_ed_post_reaction' => esc_html( $jatra_ed_post_reaction ),
'next_svg' => jatra_theme_svg('chevron-right',true),
'prev_svg' => jatra_theme_svg('chevron-left',true),
'play' => jatra_theme_svg( 'play', $return = true ),
'pause' => jatra_theme_svg( 'pause', $return = true ),
'mute' => jatra_theme_svg( 'mute', $return = true ),
'unmute' => jatra_theme_svg( 'unmute', $return = true ),
'play_text' => esc_html__('Play','jatra'),
'pause_text' => esc_html__('Pause','jatra'),
'mute_text' => esc_html__('Mute','jatra'),
'unmute_text' => esc_html__('Unmute','jatra'),
)
);
}
add_action( 'wp_enqueue_scripts', 'jatra_register_styles' );
/**
* Admin enqueue script
*/
function jatra_admin_scripts($hook){
$current_screen = get_current_screen();
wp_enqueue_style('jatra-admin', get_template_directory_uri() . '/assets/lib/custom/css/admin.css');
if( $current_screen->id != "widgets" ) {
wp_enqueue_media();
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script('jatra-admin', get_template_directory_uri() . '/assets/lib/custom/js/admin.js', array('jquery','wp-color-picker'), '', 1);
$ajax_nonce = wp_create_nonce('jatra_ajax_nonce');
wp_localize_script(
'jatra-admin',
'jatra_admin',
array(
'ajax_url' => esc_url( admin_url( 'admin-ajax.php' ) ),
'ajax_nonce' => $ajax_nonce,
'upload_image' => esc_html__('Choose Image','jatra'),
'use_image' => esc_html__('Select','jatra'),
'active' => esc_html__('Active','jatra'),
'deactivate' => esc_html__('Deactivate','jatra'),
)
);
}
if( $current_screen->id === "widgets" ) {
// Enqueue Script Only On Widget Page.
wp_enqueue_media();
wp_enqueue_script('jatra-widget', get_template_directory_uri() . '/assets/lib/custom/js/widget.js', array('jquery'), '', 1);
}
}
add_action('admin_enqueue_scripts', 'jatra_admin_scripts');
if( !function_exists( 'jatra_js_no_js_class' ) ) :
// js no-js class toggle
function jatra_js_no_js_class() { ?>
esc_html__( 'Primary Menu', 'jatra' ),
'jatra-social-menu' => esc_html__( 'Social Menu', 'jatra' ),
);
register_nav_menus( $locations );
}
add_action( 'init', 'jatra_menus' );
add_filter('wp_nav_menu_items', 'jatra_add_admin_link', 1, 2);
function jatra_add_admin_link($items, $args){
if( $args->theme_location == 'jatra-primary-menu' ){
$item = '';
$item.= jatra_theme_svg('home',true);
$item.= '';
$items = $item . $items;
}
return $items;
}
add_filter( 'walker_nav_menu_start_el', 'jatra_add_description', 10, 2 );
function jatra_add_description( $item_output, $item ) {
$description = $item->post_content;
if (('' !== $description) && (' ' !== $description) ) {
return preg_replace( '/(