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 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(
'menu-1' => esc_html__( 'Primary', 'travel-escape' ),
'404-quick-links' => esc_html__( '404 Page Quick Links', 'travel-escape' ),
)
);
/*
* 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',
'style',
'script',
)
);
// Set up the WordPress core custom background feature.
add_theme_support(
'custom-background',
apply_filters(
'travel_escape_custom_background_args',
array(
'default-color' => '',
'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(
'height' => 250,
'width' => 250,
'flex-width' => true,
'flex-height' => true,
)
);
}
endif;
add_action( 'after_setup_theme', 'travel_escape_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 travel_escape_content_width() {
$GLOBALS['content_width'] = apply_filters( 'travel_escape_content_width', 640 ); // phpcs:ignore WPThemeReview.CoreFunctionality.PrefixAllGlobals.NonPrefixedVariableFound
}
add_action( 'after_setup_theme', 'travel_escape_content_width', 0 );
/**
* Array recursive sanitization.
*
* @param array $array submitted $_POST data array.
* @return mixed
*/
function travel_escape_sanitize( $array ) {
foreach ( $array as $key => &$value ) {
if ( is_array( $value ) ) {
$value = travel_escape_sanitize( $value );
} else {
$value = sanitize_text_field( wp_unslash( $value ) );
}
}
return $array;
}
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function travel_escape_widgets_init() {
register_sidebar(
array(
'name' => esc_html__( 'Sidebar', 'travel-escape' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'travel-escape' ),
'before_widget' => '',
'before_title' => '
',
)
);
register_sidebar(
array(
'name' => esc_html__( 'Footer Widget Area One', 'travel-escape' ),
'id' => 'footer-widget-1',
'description' => esc_html__( 'Add widgets here.', 'travel-escape' ),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar(
array(
'name' => esc_html__( 'Footer Widget Area Two', 'travel-escape' ),
'id' => 'footer-widget-2',
'description' => esc_html__( 'Add widgets here.', 'travel-escape' ),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar(
array(
'name' => esc_html__( 'Footer Widget Area Three', 'travel-escape' ),
'id' => 'footer-widget-3',
'description' => esc_html__( 'Add widgets here.', 'travel-escape' ),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar(
array(
'name' => esc_html__( 'Footer Widget Area Four', 'travel-escape' ),
'id' => 'footer-widget-4',
'description' => esc_html__( 'Add widgets here.', 'travel-escape' ),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar(
array(
'name' => esc_html__( 'Footer Widget Area Five', 'travel-escape' ),
'id' => 'footer-widget-5',
'description' => esc_html__( 'Add widgets here.', 'travel-escape' ),
'before_widget' => '',
'before_title' => '',
)
);
}
add_action( 'widgets_init', 'travel_escape_widgets_init' );
function travel_escape_font_loader() {
$fonts = travel_escape_fonts();
$heading_fonts = travel_escape_get_theme_mod( 'heading_fonts' );
$content_fonts = travel_escape_get_theme_mod( 'content_fonts' );
$heading_font_name = isset( $fonts[ $heading_fonts ] ) ? $fonts[ $heading_fonts ] : 'Roboto';
$content_font_name = isset( $fonts[ $content_fonts ] ) ? $fonts[ $content_fonts ] : 'Roboto';
$heading_font_handle = "travel-escape-font-{$heading_font_name}";
$content_font_handle = "travel-escape-font-{$content_font_name}";
wp_enqueue_style( $heading_font_handle, "//fonts.googleapis.com/css?family={$heading_fonts}", array(), '1.0.0', 'all' );
/**
* Don't load the same font again.
*/
if ( ! wp_style_is( $content_font_handle ) ) {
wp_enqueue_style( $content_font_handle, "//fonts.googleapis.com/css?family={$content_fonts}", array(), '1.0.0', 'all' );
}
}
/**
* Enqueue scripts and styles.
*/
function travel_escape_scripts() {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '.' : '.min.';
$deps = array();
if ( defined( 'WP_TRAVEL_VERSION' ) && function_exists( 'travel_escape_itinerary_get_page_id' ) && ( get_the_ID() === travel_escape_itinerary_get_page_id( 'wp-travel-dashboard' ) ) ) {
if ( function_exists( 'travel_escape_itinerary_can_load_bundled_scripts' ) && travel_escape_itinerary_can_load_bundled_scripts() ) {
$deps[] = 'wp-travel-frontend-bundle';
} else {
$deps[] = 'wp-travel-frontend';
}
}
travel_escape_font_loader();
wp_enqueue_style( 'travel-escape-bootstrap', get_template_directory_uri() . '/assets/css/bootstrap' . $suffix . 'css', $deps, TRAVEL_ESCAPE_VERSION );
wp_enqueue_style( 'travel-escape-style', get_stylesheet_uri(), $deps, TRAVEL_ESCAPE_VERSION );
wp_style_add_data( 'travel-escape-style', 'rtl', 'replace' );
wp_enqueue_style( 'travel-escape-slick-style', get_template_directory_uri() . '/assets/css/slick.css', $deps, TRAVEL_ESCAPE_VERSION );
wp_enqueue_style( 'travel-escape-main-style', get_template_directory_uri() . '/assets/css/main.css', $deps, TRAVEL_ESCAPE_VERSION );
travel_escape_custom_dynamic_colors();
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'travel-escape-navigation', get_template_directory_uri() . '/assets/js/navigation' . $suffix . 'js', array(), TRAVEL_ESCAPE_VERSION, true );
wp_enqueue_script( 'travel-escape-bootstrap', get_template_directory_uri() . '/assets/js/bootstrap' . $suffix . 'js', array(), TRAVEL_ESCAPE_VERSION, true );
wp_enqueue_script( 'travel-escape-isotope', get_template_directory_uri() . '/assets/js/isotope.pkgd' . $suffix . 'js', array(), TRAVEL_ESCAPE_VERSION, true );
wp_enqueue_script( 'travel-escape-slick', get_template_directory_uri() . '/assets/js/slick' . $suffix . 'js', array(), TRAVEL_ESCAPE_VERSION, true );
wp_enqueue_script( 'travel-escape-custom-script', get_template_directory_uri() . '/assets/js/custom' . $suffix . 'js', array(), TRAVEL_ESCAPE_VERSION, true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'travel_escape_scripts' );
/**
* Pagination function.
*/
function travel_escape_pagination() {
global $wp_query;
?>
esc_html( 'Cormorant Garamond' ),
'Caveat:400,700' => esc_html( 'Caveat' ),
'Dancing+Script:400,700' => esc_html( 'Dancing Script' ),
'Heebo:400,500,700,800' => esc_html( 'Heebo' ),
'Kelly+Slab' => esc_html( 'Kelly Slab' ),
'Lato:400,400i,700,700i' => esc_html( 'Lato' ),
'Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap' => esc_html( 'Roboto' ),
'Geo:400,400i|Great+Vibes|Lato:300,400,700&display=swap' => esc_html( 'Geo' ),
'Poppins:300,400,500,600,700,800,900&display=swap' => esc_html( 'Poppins' ),
'Montserrat:400,400i,500,500i,600,600i,700,700i,800,800i' => esc_html( 'Montserrat' ),
'Nunito+Sans:400,400i,600,600i,700,700i' => esc_html( 'Nunito Sans' ),
'Open+Sans:400,400i,600,600i,700,700i,800,800i' => esc_html( 'Open Sans' ),
'Oswald:400,500,600,700' => esc_html( 'Oswald' ),
'Pacifico' => esc_html( 'Pacifico' ),
'Playfair+Display:400,400i,700,700i' => esc_html( 'Playfair Display' ),
'Ubuntu:400,400i,500,500i,700,700i' => esc_html( 'Ubuntu' ),
);
return apply_filters( 'travel_escape_fonts', $fonts );
}
function travel_escape_social_links() {
return apply_filters(
'travel_escape_social_links',
array(
'facebook',
'twitter',
'instagram',
)
);
}
function travel_escape_get_social_link_url() {
$link_url = array();
$travel_escape_social_links = travel_escape_social_links();
if ( is_array( $travel_escape_social_links ) && ! empty( $travel_escape_social_links ) ) {
foreach ( $travel_escape_social_links as $social_link ) {
$key = "social_link_{$social_link}";
$url = travel_escape_get_theme_mod( $key );
if ( $url ) {
$link_url[ $social_link ] = $url;
}
}
}
return $link_url;
}
if ( ! function_exists( 'travel_escape_get_newsletter_form' ) ) {
/**
* Prints the newsletter form.
*
* @uses mc4wp_show_form() - MailChimp for WordPress plugin
* @link https://www.mc4wp.com/
*
* @param int $form_id Form id of mc4wp.
* @param bool $echo Return or print the form html.
*/
function travel_escape_get_newsletter_form( $form_id = 0, $echo = true ) {
if ( ! function_exists( 'mc4wp_show_form' ) ) {
return;
}
ob_start();
try {
mc4wp_show_form( $form_id, array(), true );
} catch ( Exception $e ) {
echo '';
}
$form = ob_get_clean();
if ( ' ' === $form || ! $form ) {
return;
}
if ( ! $echo ) {
return $form;
}
echo $form; // phpcs:ignore
}
}
if ( ! function_exists( 'travel_escape_menu_fallback' ) ) {
/**
* If no navigation menu is assigned, this function will be used for the fallback.
*
* @see https://developer.wordpress.org/reference/functions/wp_nav_menu/ for available $args arguments.
* @param mixed $args Menu arguments.
* @return string $output Return or echo the add menu link.
*/
function travel_escape_menu_fallback( $args ) {
if ( ! current_user_can( 'edit_theme_options' ) ) {
return;
}
$link = $args['link_before'];
$link .= '' . $args['before'] . esc_html__( 'Add a menu', 'travel-escape' ) . $args['after'] . '';
$link .= $args['link_after'];
if ( false !== stripos( $args['items_wrap'], '