tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
// Image size
add_image_size( 'adventure-travel-blog', 770, 470, true );
add_image_size( 'adventure-travel-480x604', 480, 604, true );
add_image_size( 'adventure-travel-480x325', 480, 325, true );
add_image_size( 'adventure-travel-270x310', 270, 310, true );
add_image_size( 'adventure-travel-768x576', 768, 576, true );
add_image_size( 'adventure-travel-banner-slider', 1920, 988, true );
/*
* 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' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => esc_html__( 'Primary', 'adventure-travel' ),
) );
/**
* Add support for custom header.
*/
add_theme_support( 'custom-header', apply_filters( 'adventure_travel_custom_header_args', array(
'default-image' => get_template_directory_uri() . '/images/fallback/adventure-travel-banner.jpg',
'video' => true,
'width' => 1920,
'height' => 988,
'header-text' => false
) ) );
// Register default headers.
register_default_headers( array(
'default-banner' => array(
'url' => '%s/images/fallback/adventure-travel-banner.jpg',
'thumbnail_url' => '%s/images/fallback/adventure-travel-banner.jpg',
'description' => esc_html_x( 'Default Banner', 'header image description', 'adventure-travel' ),
),
) );
/*
* 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',
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'adventure_travel_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/**
* Add support for core custom logo.
*
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support( 'custom-logo', array(
'header-text' => array( 'site-title', 'site-description' ),
'height' => 50,
'width' => 120,
'flex-width' => true,
'flex-height' => true,
) );
// Add theme support for Responsive Videos.
add_theme_support( 'jetpack-responsive-videos' );
// Add excerpt support for pages
add_post_type_support( 'page', 'excerpt' );
}
endif;
add_action( 'after_setup_theme', 'adventure_travel_setup' );
/*
*
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function adventure_travel_content_width() {
// 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( 'adventure_travel_content_width', 910 );
}
add_action( 'after_setup_theme', 'adventure_travel_content_width', 0 );
/*
*
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function adventure_travel_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Right Sidebar', 'adventure-travel' ),
'id' => 'right-sidebar',
'description' => esc_html__( 'Add widgets here.', 'adventure-travel' ),
'before_widget' => '',
'before_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer one', 'adventure-travel' ),
'id' => 'footer-one',
'description' => esc_html__( 'Add widgets here.', 'adventure-travel' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer two', 'adventure-travel' ),
'id' => 'footer-two',
'description' => esc_html__( 'Add footer widgets here.', 'adventure-travel' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer three', 'adventure-travel' ),
'id' => 'footer-three',
'description' => esc_html__( 'Add footer widgets here.', 'adventure-travel' ),
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer Four', 'adventure-travel' ),
'id' => 'footer-four',
'description' => esc_html__( 'Add footer widgets here.', 'adventure-travel' ),
'before_widget' => '',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'adventure_travel_widgets_init' );
/*
*
* Enqueue scripts and styles.
*
*/
function adventure_travel_scripts() {
// CSS
$google_font_args = array(
'family' => 'Raleway:300,300i,400,400i,500,500i,600,600i,700,700i,800,800i',
);
wp_enqueue_style( 'adventure-travel-google-fonts', add_query_arg( $google_font_args, "//fonts.googleapis.com/css" ) ); //Google Fonts
wp_enqueue_style( 'adventure-travel-owl-carousel', get_template_directory_uri(). '/css/owl.carousel.css' );//owl-carousel
wp_enqueue_style( 'adventure-travel-fancybox', get_template_directory_uri(). '/css/jquery.fancybox.css' );//owl-carousel
wp_enqueue_style( 'adventure-travel-fontawesome', get_template_directory_uri(). '/css/all.css' ); //fontawesome
wp_enqueue_style( 'adventure-travel-style', get_stylesheet_uri() ); //theme-style
wp_enqueue_style( 'adventure-travel-custom-style', get_template_directory_uri(). '/css/custom-style.css' );//owl-carousel
// JS
wp_enqueue_script( 'adventure-travel-owlCarousel', get_template_directory_uri() . '/js/owl.carousel.js', array('jquery'), '2.3.4', true );//owl-carousel js
wp_enqueue_script( 'adventure-travel-isotope', get_template_directory_uri() . '/js/isotope.pkgd.js', array('jquery'), '3.0.6', true );//custom js
wp_enqueue_script( 'adventure-travel-fontawesome', get_template_directory_uri() . '/js/all.js', array('jquery'), '5.3.1', true );//fontawesome
wp_enqueue_script( 'adventure-travel-counterup', get_template_directory_uri() . '/js/jquery.counterup.js', array('jquery'), '1.0', true );//counterup
wp_enqueue_script( 'adventure-travel-rateo', get_template_directory_uri() . '/js/jquery.rateyo.js', array('jquery'), '2.3.2', true );//counterup
wp_enqueue_script( 'adventure-travel-fancybox', get_template_directory_uri() . '/js/jquery.fancybox.js', array('jquery'), '1.0', true );//fancybox
wp_enqueue_script( 'adventure-travel-waypoint', get_template_directory_uri() . '/js/jquery.waypoints.js', array('jquery'), '5.3.1', true );//waypoints
wp_enqueue_script( 'adventure-travel-custom', get_template_directory_uri() . '/js/custom.js', array('jquery'), '3.0.0', true );//custom js
wp_enqueue_script( 'adventure-travel-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );//navigation
wp_enqueue_script( 'adventure-travel-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );//skip-link-focus
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_jetpack_activated( true ) ) {
wp_enqueue_style( 'tiled-gallery', plugins_url() . '/jetpack/modules/tiled-gallery/tiled-gallery/tiled-gallery.css' );
}
}
add_action( 'wp_enqueue_scripts', 'adventure_travel_scripts' );
/*
*
* Add a pingback url auto-discovery header for singularly identifiable articles.
*
*/
if( ! function_exists( 'adventure_travel_pingback_header' ) ) :
function adventure_travel_pingback_header() {
if ( is_singular() && pings_open() ) {
echo '';
}
}
add_action( 'wp_head', 'adventure_travel_pingback_header' );
endif;
/*
*
* Replaces "[...]" (appended to automatically generated excerpts) with ... *
*
*/
if ( ! function_exists( 'adventure_travel_excerpt_more' ) ) :
function adventure_travel_excerpt_more() {
return ' … ';
}
add_filter( 'excerpt_more', 'adventure_travel_excerpt_more' );
endif;
/*
*
* Excerpt length
*
*/
if( ! function_exists( 'adventure_travel_custom_excerpt_length' ) ) :
function adventure_travel_custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'adventure_travel_custom_excerpt_length', 999 );
endif;
/*
*
* Single Post Schema
*
* @return string
*/
if( ! function_exists( 'adventure_travel_single_post_schema' ) ) :
function adventure_travel_single_post_schema() {
if ( is_singular( 'post' ) ) {
global $post;
$custom_logo_id = get_theme_mod( 'custom_logo' );
$site_logo = wp_get_attachment_image_src( $custom_logo_id , 'travel-agency-schema' );
$images = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
$excerpt = Adventure_Travel_escape_text_tags( $post->post_excerpt );
$content = $excerpt === "" ? mb_substr( Adventure_Travel_escape_text_tags( $post->post_content ), 0, 110 ) : $excerpt;
$schema_type = ! empty( $custom_logo_id ) && has_post_thumbnail( $post->ID ) ? "BlogPosting" : "Blog";
$args = array(
"@context" => "http://schema.org",
"@type" => $schema_type,
"mainEntityOfPage" => array(
"@type" => "WebPage",
"@id" => get_permalink( $post->ID )
),
"headline" => ( function_exists( '_wp_render_title_tag' ) ? wp_get_document_title() : wp_title( '', false, 'right' ) ),
"image" => array(
"@type" => "ImageObject",
"url" => $images[0],
"width" => $images[1],
"height" => $images[2]
),
"datePublished" => get_the_time( DATE_ISO8601, $post->ID ),
"dateModified" => get_post_modified_time( DATE_ISO8601, __return_false(), $post->ID ),
"author" => array(
"@type" => "Person",
"name" => Adventure_Travel_escape_text_tags( get_the_author_meta( 'display_name', $post->post_author ) )
),
"publisher" => array(
"@type" => "Organization",
"name" => get_bloginfo( 'name' ),
"description" => get_bloginfo( 'description' ),
"logo" => array(
"@type" => "ImageObject",
"url" => $site_logo[0],
"width" => $site_logo[1],
"height" => $site_logo[2]
)
),
"description" => ( class_exists('WPSEO_Meta') ? WPSEO_Meta::get_value( 'metadesc' ) : $content )
);
if ( has_post_thumbnail( $post->ID ) ) :
$args['image'] = array(
"@type" => "ImageObject",
"url" => $images[0],
"width" => $images[1],
"height" => $images[2]
);
endif;
if ( ! empty( $custom_logo_id ) ) :
$args['publisher'] = array(
"@type" => "Organization",
"name" => get_bloginfo( 'name' ),
"description" => get_bloginfo( 'description' ),
"logo" => array(
"@type" => "ImageObject",
"url" => $site_logo[0],
"width" => $site_logo[1],
"height" => $site_logo[2]
)
);
endif;
echo '' , PHP_EOL;
}
}
endif;
add_action( 'wp_head', 'adventure_travel_single_post_schema' );
/*
*
* Add og meta tags in header for social sharing
*
*/
if( ! function_exists( 'adventure_travel_og_header' ) ) :
function adventure_travel_og_header() {
if( is_single() ){
global $post;
$post_thumbnail_id = get_post_thumbnail_id( $post->ID );
if( $post_thumbnail_id ){
$featured_image = wp_get_attachment_image_url( $post_thumbnail_id, 'lawyer-landing-page-portfolio' );
}
if( has_excerpt( $post->ID ) ){
$description = $post->post_excerpt;
}
else {
$description = adventure_travel_truncate( $post->post_content, 250 );
}
if( $post_thumbnail_id && $featured_image && $description ){ ?>