/**
* travel-tour functions and definitions
*
* @package Travel Tour
*/
// freemius integration start
if ( !function_exists( 'fs_travel_tour' ) ) {
// Create a helper function for easy SDK access.
function fs_travel_tour() {
global $fs_travel_tour;
if ( !isset( $fs_travel_tour ) ) {
// Include Freemius SDK.
require_once dirname( __FILE__ ) . '/freemius/start.php';
$fs_travel_tour = fs_dynamic_init( array(
'id' => '6953',
'slug' => 'travel-tour',
'premium_slug' => 'travel-tour-pro',
'type' => 'theme',
'public_key' => 'pk_5ba452bca36d531b9de0708da3575',
'is_premium' => false,
'premium_suffix' => 'Pro',
'has_addons' => false,
'has_paid_plans' => true,
'navigation' => 'tabs',
'menu' => array(
'slug' => 'travel-tour',
'parent' => array(
'slug' => 'themes.php',
),
'first-path' => 'themes.php?page=travel-tour',
'contact' => true,
'account' => true,
'support' => false,
'addons' => false,
'affiliation' => false,
'pricing' => false,
),
'is_live' => true,
) );
}
return $fs_travel_tour;
}
// Init Freemius.
fs_travel_tour();
// Signal that SDK was initiated.
do_action( 'fs_travel_tour_loaded' );
}
// freemius integration end
if ( !defined( 'TRAVEL_TOUR_VERSION' ) ) {
// Replace the version number of the theme on each release.
define( 'TRAVEL_TOUR_VERSION', '3.2.2' );
}
if ( !function_exists( 'travel_tour_setup' ) ) {
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function travel_tour_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on travel-tour, use a find and replace
* to change 'travel-tour' to the name of your theme in all the template files
*/
load_theme_textdomain( 'travel-tour' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* 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' );
/*
* 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' );
add_theme_support( 'post-templates' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => esc_html__( 'Primary Menu', 'travel-tour' ),
) );
/*
* 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 http://codex.wordpress.org/Post_Formats
*/
add_theme_support( 'custom-logo', array(
'height' => 90,
'width' => 400,
'flex-width' => true,
) );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'travel_tour_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
add_theme_support( "custom-header", array(
'default-color' => 'ffffff',
'default-image' => get_template_directory_uri() . '/images/banner.webp',
) );
add_editor_style();
add_theme_support( 'register_block_style' );
add_theme_support( 'register_block_pattern' );
add_theme_support( "wp-block-styles" );
add_theme_support( "responsive-embeds" );
add_theme_support( "align-wide" );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
// Define Image Sizes:
add_image_size(
'travel-tour-slider',
256,
350,
true
);
require get_template_directory() . '/inc/starter-content.php';
$starter_content = travel_tour_starter_content();
add_theme_support( 'starter-content', $starter_content );
}
// travel_tour_setup
}
add_action( 'after_setup_theme', 'travel_tour_setup' );
/**
* Enqueue scripts and styles.
*/
function travel_tour_scripts() {
$font_family = get_theme_mod( 'font_family', 'Raleway' );
$heading_font_family = get_theme_mod( 'heading_font_family', 'Montserrat' );
$logo_font_family = esc_attr( get_theme_mod( 'travel_tour_site_identity_font_family', 'Montserrat' ) );
wp_enqueue_style(
'bootstrap',
get_template_directory_uri() . '/css/bootstrap.css',
array(),
TRAVEL_TOUR_VERSION
);
wp_enqueue_style(
'font-awesome',
get_template_directory_uri() . '/css/font-awesome.css',
array(),
"4.6.1"
);
wp_enqueue_style(
'owl',
get_template_directory_uri() . '/css/owl.carousel.css',
array(),
"2.3.4"
);
wp_enqueue_style( 'travel-tour-googlefonts', '//fonts.googleapis.com/css?family=' . esc_attr( $font_family ) . ':200,300,400,500,600,700,800,900|' . esc_attr( $heading_font_family ) . ':200,300,400,500,600,700,800,900' . esc_attr( $logo_font_family ) . ':200,300,400,500,600,700,800,900|' );
wp_enqueue_style(
'travel-tour-style',
get_stylesheet_uri(),
array(),
TRAVEL_TOUR_VERSION
);
wp_enqueue_script(
'bootstrap',
get_template_directory_uri() . '/js/bootstrap.js',
array('jquery'),
'5.3.3',
true
);
wp_enqueue_script(
'wow',
get_template_directory_uri() . '/js/wow.js',
array('jquery'),
'1.0.0',
true
);
wp_enqueue_script(
'owl',
get_template_directory_uri() . '/js/owl.carousel.js',
array('jquery'),
'2.3.4',
true
);
wp_enqueue_script(
'travel-tour-scripts',
get_template_directory_uri() . '/js/script.js',
array('jquery'),
TRAVEL_TOUR_VERSION,
true
);
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'travel_tour_scripts' );
/**
* Required Plugins
*/
add_theme_support( 'required-plugins', array(array(
'slug' => 'tbthemes-demo-import',
'name' => 'TBThemes Theme Import',
'active_filename' => 'tbthemes-demo-import/tbthemes-demo-import.php',
), array(
'slug' => 'wp-travel-engine',
'name' => 'WP Travel Engine',
'active_filename' => 'wp-travel-engine/wp-travel-engine.php',
)) );
/**
* 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
*/
if ( !isset( $content_width ) ) {
$content_width = 900;
}
function travel_tour_content_width() {
$GLOBALS['content_width'] = apply_filters( 'travel_tour_content_width', 640 );
}
add_action( 'after_setup_theme', 'travel_tour_content_width', 0 );
/**
* Call Widget page
**/
require get_template_directory() . '/inc/widgets/widgets.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/extras.php';
require get_template_directory() . '/inc/custom-controls/custom-control.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer/customizer.php';
/**
* Custom navigation walker
*/
require get_template_directory() . '/inc/wp_bootstrap_navwalker.php';
/**
* Custom comment walker
*/
require get_template_directory() . '/inc/wp_bootstrap_comment_walker.php';
/**
* Demo Content Section
*/
require get_template_directory() . '/inc/demo-content.php';
require get_template_directory() . '/inc/dynamic-css.php';
// Remove default "Category or Tags" from title
add_filter( 'get_the_archive_title', 'travel_tour_remove_defalut_tax_title' );
function travel_tour_remove_defalut_tax_title( $title ) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
}
return $title;
}
// add classes for post_class function
add_filter(
'post_class',
'travel_tour_sticky_classes',
10,
3
);
function travel_tour_sticky_classes( $classes, $class, $post_id ) {
$classes[] = 'col-sm-12 eq-blocks';
return $classes;
}
function travel_tour_get_trip_info( $post_id ) {
if ( !class_exists( 'Wp_Travel_Engine' ) ) {
return;
}
$trip_info = get_post_meta( $post_id, 'wp_travel_engine_setting', true );
return $trip_info;
}
function travel_tour_trip_settings() {
if ( !class_exists( 'Wp_Travel_Engine' ) ) {
return;
}
$trip_settings = get_option( 'wp_travel_engine_settings', true );
return $trip_settings;
}
/**
* Theme Admin Dashboard
*/
require get_template_directory() . '/inc/admin/dashboard.php';
/**
* Sidebar panel
*/
require get_template_directory() . '/inc/gutenberg/sidebar/sidebar_panel.php';
/**
* Set permalinks so that WPTE API works properly
*/
function travel_tour_change_permalinks() {
global $wp_rewrite;
$wp_rewrite->set_permalink_structure( '/%postname%/' );
$wp_rewrite->flush_rules();
}
add_action( 'init', 'travel_tour_change_permalinks' );
/**
* Social media
*
*/
function travel_tour_social_media() {
$social_media = array(
'facebook' => esc_html__( 'Facebook', 'travel-tour' ),
'twitter' => esc_html__( 'Twitter', 'travel-tour' ),
'pinterest' => esc_html__( 'Pinterest', 'travel-tour' ),
'instagram' => esc_html__( 'Instagram', 'travel-tour' ),
'youtube' => esc_html__( 'Youtube', 'travel-tour' ),
'linkedin' => esc_html__( 'LinkedIn', 'travel-tour' ),
'tripadvisor' => esc_html__( 'Tripadvisor', 'travel-tour' ),
);
return $social_media;
}
/**
* Generate Bootstrap 5.3 compatible pagination.
*
* @param WP_Query|null $query Optional. Custom WP_Query object. Defaults to global $wp_query.
*/
function travel_tour_pagination( $query = null ) {
// Use the global query if no custom query is passed.
if ( !$query ) {
global $wp_query;
$query = $wp_query;
}
// Don't render pagination if there's only one page.
if ( $query->max_num_pages <= 1 ) {
return;
}
// Get the current page.
$current_page = max( 1, get_query_var( 'paged' ) );
// Pagination arguments.
$pagination_links = paginate_links( array(
'total' => $query->max_num_pages,
'current' => $current_page,
'type' => 'array',
'prev_text' => __( '«', 'travel-tour' ),
'next_text' => __( '»', 'travel-tour' ),
) );
// If pagination links exist, output them in Bootstrap format.
if ( !empty( $pagination_links ) ) {
echo '';
}
}
Đăng nhập ‹ Du lịch Lê Gia — WordPress