Developer DocumentationDeveloper Documentation

WP Travel Engine - Developer Documentation

Complete guide for theme and plugin developers customizing WP Travel Engine.

Introduction

WP Travel Engine - Developer documentation is a complete guide for theme and plugin developers willing to develop themes or willing to customize and modify functionalities or templates provided by WP Travel Engine plugin. The developer documentation handbook will be a guideline for developing custom travel themes powered by WP Travel Engine.

Developer Notes

  • The documentation categorized into mainly two sections based on the type of hooks available for customization in WP Travel Engine, action, and filter hooks. All of the customization and changes are to be accessed using these WordPress hooks. An action hook takes the info it receives, does something with it, and returns nothing. In other words: it acts on something and then exits, returning nothing back to the calling hook and a filter is used to modify something in a specific way so that the modification is then used by code later on. Learn more about actions and filters here.
  • All of the codes and examples in this documentation is intended too either be written inside compatible themes, child themes ( for customizations ), or in custom plugins. No code should be modified or added/edited in the WP Travel Engine core plugin itself as the changes will be lost upon the update of the plugin.
  • Plugin version: please follow along with the documentation only with the latest available version of the WP Travel Engine plugin. Some of the hooks and instructions will work only with the latest versions of WP Travel Engine.

Overriding Template Files

WP Travel Engine template files contain the markup and template structure for single-trip, archives, and HTML emails of your travel website.

When you open these files, you will notice they all contain hooks that allow you to add/move content without needing to edit template files themselves. This method protects against upgrade issues, as the template files can be left completely untouched.

Template files can be found within the****/wp-travel-engine/includes/templates/ directory.

Single Trip Template Files

  • /wp-travel-engine/includes/templates/single-trip.php
  • /wp-travel-engine/includes/templates/content-single-trip.php
  • /wp-travel-engine/includes/templates/single-trip/trip-content-wrapper-start.php
  • /wp-travel-engine/includes/templates/single-trip/trip-content.php
  • /wp-travel-engine/includes/templates/single-trip/title.php
  • /wp-travel-engine/includes/templates/single-trip/gallery.php
  • /wp-travel-engine/includes/templates/single-trip/tabs-nav.php
  • /wp-travel-engine/includes/templates/single-trip/tabs-content.php
  • /wp-travel-engine/includes/templates/single-trip/trip-content-wrapper-end.php
  • /wp-travel-engine/includes/templates/single-trip/trip-footer.php
  • /wp-travel-engine/includes/templates/single-trip/trip-sidebar.php

Single Trip Tabs

  • /wp-travel-engine/includes/templates/single-trip/trip-tabs/overview.php
  • /wp-travel-engine/includes/templates/single-trip/trip-tabs/itinerary-tab.php
  • /wp-travel-engine/includes/templates/single-trip/trip-tabs/cost.php
  • /wp-travel-engine/includes/templates/single-trip/trip-tabs/map.php
  • /wp-travel-engine/includes/templates/single-trip/trip-tabs/faqs.php

Archive Template Files

  • /wp-travel-engine/includes/templates/archive-trip.php
  • /wp-travel-engine/includes/templates/taxonomy-activities.php
  • /wp-travel-engine/includes/templates/taxonomy-destination.php
  • /wp-travel-engine/includes/templates/taxonomy-trip_types.php

Archive Template Layouts

  • /wp-travel-engine/includes/templates/content-grid.php
  • /wp-travel-engine/includes/templates/content-list.php
  • /wp-travel-engine/includes/templates/widgets/content-widget-feat-trip.php

Page Templates

  • /wp-travel-engine/includes/templates/template-activities.php
  • /wp-travel-engine/includes/templates/template-destination.php
  • /wp-travel-engine/includes/templates/template-trip_types.php
  • /wp-travel-engine/includes/templates/template-trip-listing.php

Email Templates

  • /wp-travel-engine/includes/templates/emails/customer-lost-password.php
  • /wp-travel-engine/includes/templates/emails/customer-new-account.php
  • /wp-travel-engine/includes/templates/emails/email-header.php
  • /wp-travel-engine/includes/templates/emails/email-footer.php

How to Edit Files

Edit files in an upgrade-safe way using overrides. Copy the template into a directory within your theme named /wp-travel-engine keeping the same file structure but removing the /templates/ subdirectory.

Example: To override the Title on Single Trip, copy:

wp-content/plugins/wp-travel-engine/includes/templates/single-trip/title.php

to

wp-content/themes/yourtheme/wp-travel-engine/single-trip/title.php

The copied file will now override the WP Travel Engine default template file.

Warning: Do not edit these files within the core plugin itself as they are overwritten during the upgrade process and any customizations will be lost.

Action Hooks

All of the action hooks available in the WP Travel Engine are listed below with hook name, location, and example usage.

Trip single hooks

wte_before_single_trip

Fires before the single trip page content blocks are rendered.

Location: includes/templates/content-single-trip.php

do_action( 'wte_before_single_trip' );

wte_after_single_trip

Fires after the single trip page content blocks are rendered.

Location: includes/templates/content-single-trip.php

do_action( 'wte_after_single_trip' );

wp_travel_engine_before_trip_content

Fires before the single trip page content blocks are rendered (wrapper).

Location: includes/templates/content-single-trip.php

/**
 * wp_travel_engine_before_trip_content hook.
 *
 * @hooked trip_content_wrapper_start - 5 (outputs opening divs for the trip content)
 */
do_action( 'wp_travel_engine_before_trip_content' );

wp_travel_engine_after_trip_content

Fires after the single trip page content blocks are rendered (wrapper).

Location: includes/templates/content-single-trip.php

/**
 * wp_travel_engine_after_trip_content hook.
 *
 * @hooked trip_content_wrapper_end - 5 (outputs closing divs for the trip content)
 */
do_action( 'wp_travel_engine_after_trip_content' );

wp_travel_engine_before_trip_tabs

Fires before the tabs on trip single page.

Location: includes/templates/single-trip/tabs-nav.php

do_action('wp_travel_engine_before_trip_tabs');

wp_travel_engine_after_trip_tabs

Fires after the tabs on trip single page.

Location: includes/templates/single-trip/tabs-nav.php

do_action('wp_travel_engine_after_trip_tabs');

Dynamic Hooks

wte_single_before_trip_tab_{$field}

Dynamic hook that fires before the trip tab content. $field variable to be replaced by the tab key.

/**
* @hook - wte_single_before_trip_tab_{field_name}
* Dynamic hooks before Tab wrapper - for themes to hook content into.
*/
do_action( "wte_single_before_trip_tab_{$field}" );

wte_single_after_trip_tab_{$field}

Dynamic hook that fires after the trip tab content. $field variable to be replaced by the tab key.

/**
* @hook - wte_single_after_trip_tab_{field_name}
* Dynamic hooks after Tab wrapper - for themes to hook content into.
*/
do_action( "wte_single_after_trip_tab_{$field}" );

wp_travel_engine_before_secondary

Fires before the secondary widget area div in the trip single page.

Location: public/class-wp-travel-engine-template-hooks.php

do_action('wp_travel_engine_before_secondary');

wp_travel_engine_before_trip_price

Fires before the pricing section and calendar for dates selection on the trip single page.

Location: public/class-wp-travel-engine-template-hooks.php

do_action('wp_travel_engine_before_trip_price');

wp_travel_engine_after_trip_price

Fires after the pricing section and calendar for dates selection on the trip single page.

Location: public/class-wp-travel-engine-template-hooks.php

do_action('wp_travel_engine_after_trip_price');

wp_travel_engine_before_trip_facts

Fires before the "trips info" section in the sidebar on the trip single page.

Location: public/class-wp-travel-engine-template-hooks.php

do_action('wp_travel_engine_before_trip_facts');

wp_travel_engine_after_trip_facts

Fires after the "trips info" section in the sidebar on the trip single page.

Location: public/class-wp-travel-engine-template-hooks.php

do_action('wp_travel_engine_after_trip_facts');

Hook to add section/block before the related trips section on the trip single page.

Location: public/class-wp-travel-engine-template-hooks.php

do_action('wp_travel_engine_before_related_posts');

Hook to add section/block after the related trips section on the trip single page.

Location: public/class-wp-travel-engine-template-hooks.php

do_action('wp_travel_engine_after_related_posts');

wpte_after_travellers_input

Fires after the traveler numbers input field in the booking form on the single trip page.

Location: public/class-wp-travel-engine-template-hooks.php

do_action('wpte_after_travellers_input');

Removing template actions

Besides all of the available template hooks for a trip single page developers can also unhook any added sections/actions as per their requirements. This can be beneficial in a situation that requires modification of HTML structures and swapping actions priorities to customize the trip single page.

Applies to: class WP_Travel_Engine_Template_Hooks();

Methods: init_hook(); & init_single_trip_hooks();

Example: Removing gallery slider from trip single page.

/**
 * Removing Gallery Slider from Trip Content
 *
 * @package Wp_Travel_Engine
 */
$single_trip_hooks = WP_Travel_Engine_Template_Hooks::get_instance();
remove_action( 'wte_single_trip_content', array( $single_trip_hooks, 'display_single_trip_gallery' ), 10 );

Checkout page hooks

wp_travel_engine_before_billing_form

Fires before the output of billing form in the checkout page.

<?php do_action('wp_travel_engine_before_billing_form'); ?>

wte_booking_before_submit_button

Fires before the billing form submit button on the checkout page.

<?php do_action('wte_booking_before_submit_button'); ?>

wte_booking_after_submit_button

Fires after the billing form submit button on the checkout page.

<?php do_action('wte_booking_after_submit_button'); ?>

Mini-cart hooks

wte_bf_after_trip_name

Location: includes/templates/checkout/mini-cart.php

Fires after the trip name in the mini cart of the checkout page.

<?php do_action('wte_bf_after_trip_name'); ?>

Thank You page hooks

wp_travel_engine_before_traveller_information_save

Fires before saving the billing details are saved in thank you page.

<?php do_action('wp_travel_engine_before_traveller_information_save'); ?>

wp_travel_engine_after_traveller_information_save

Fires after saving the billing details are saved in thank you page.

<?php do_action('wp_travel_engine_after_traveller_information_save'); ?>

Trip archive hooks

wp_travel_engine_trip_archive_outer_wrapper

Fires on the trip archive page that contains the outer wrapper div of the trip archive.

<?php
/**
* wp_travel_engine_trip_archive_outer_wrapper hook.
*
* @hooked wp_travel_engine_trip_archive_outer_wrapper - 10 (main wrapper)
*/
do_action('wp_travel_engine_trip_archive_outer_wrapper');
?>

wp_travel_engine_trip_archive_loop_start

Action hook that contains the trip archive loop start.

<?php
/**
* wp_travel_engine_trip_archive_loop_start hook.
*
* @hooked wp_travel_engine_trip_archive_loop_start - 10 (loop starts)
*/
do_action('wp_travel_engine_trip_archive_loop_start');
?>

wp_travel_engine_trip_archive_loop_end

Action hook that contains the trip archive loop end.

<?php
/**
* wp_travel_engine_trip_archive_loop_end hook.
*
* @hooked wp_travel_engine_trip_archive_end_start - 10 (loop ends)
*/
do_action('wp_travel_engine_trip_archive_loop_end');
?>

Filter Hooks

Filter hooks are available in the WP Travel Engine that lets you filter the output of certainly function or variable based on the filter hook's location. The major template filter hooks are listed below under the titles of pages they apply to.

Trip archive page

wp_travel_engine_archive_header_sorting_options

Location: includes/class-wp-travel-engine-archive-hooks.php

Filters the archive page search bar sorting options on the trip archive page.

Example

/**
* Remove the Name in Ascending option from sorting options.
*
* @param array $options
* @return array $options
*/
function wpte_dev_doc_filter_archive_sorting_opts( $options) {
    if ( isset($options['name']) ) {
        unset($options['name']);
    }
  return $options;
}

add_filter( 'wp_travel_engine_archive_header_sorting_options', 'wpte_dev_doc_filter_archive_sorting_opts' );

wte_trip_archive_description_page_header

Location: includes/class-wp-travel-engine-archive-hooks.php

Filters the display of page header in the archive block.

Example

add_filter( 'wte_trip_archive_description_page_header', '__return_false' );

Remove the page header section on the trips archive page.

wp_travel_engine_template_banner_size

Location: includes/class-wp-travel-engine-archive-hooks.php

Filters the size of the banner in archive pages. Accepts WordPress default image sizes and images registered form add_image_size().

Example:

/**
* Change image size to large
**/
add_filter('wp_travel_engine_template_banner_size', function( $size ){
     return 'large';
});

wte_trip_archive_description_below_title

Location: includes/class-wp-travel-engine-archive-hooks.php

Controls the display of archive description in the taxonomy archive pages, Defaults to true.

Example

add_filter( 'wte_trip_archive_description_below_title', '__return_false' );

Trip single page

wp_travel_engine_trip_prev_price

Filters the trip main price of the trips. Accepts price and trip id is arguments.

Location: includes/wp-travel-engine-helpers.php

wp_travel_engine_enquiry_fields_display

Filters the fields of the Enquiry form on Trip single page. When adding a new field with this hook, proper array structure should be maintained for the supported field type.

Example

/**
* Remove enquiry form field
*/
add_filter( 'wp_travel_engine_enquiry_fields_display', function( $enquiry_fields ) {
  unset( $enquiry_fields['some_key'] );
  return $enquiry_fields;
} );

wpte_show_tab_titles_inside_tabs

Controls the display of the tab titles inside the Trip single page tabs.

Example

add_filter( 'wpte_show_tab_titles_inside_tabs', '__return_false' );

Checkout page

wp_travel_engine_show_checkout_header_steps

Filters the display of the header steps in the checkout page. Returns a boolean value.

Example

/**
* Removes the Progress Checkout Workflow from the content
*/
add_filter( 'wp_travel_engine_show_checkout_header_steps', '__return_false' );

wp_travel_engine_booking_fields_display

Filters the array of checkout booking form fields. Takes array of structured values of supported field types.

Location: includes/backend/booking/booking-parts/customer-details.php

Example

/**
* Remove Checkout form field
*/
add_filter( 'wp_travel_engine_booking_fields_display', function( $booking_fields ) {
  unset( $booking_fields['some_key'] );
  return $booking_fields;
} );

Constants

WP_TRAVEL_ENGINE_FILE_PATH

Gives the __FILE__ path of the main plugin file.

define( 'WP_TRAVEL_ENGINE_FILE_PATH', __FILE__ );

WP_TRAVEL_ENGINE_BASE_PATH

Gives the base path of the WP Travel Engine plugin file.

define( 'WP_TRAVEL_ENGINE_BASE_PATH', dirname( __FILE__ ) );

WP_TRAVEL_ENGINE_TEMPLATE_PATH

Gives the path of the templates directory of all of the templates used by the WP Travel Engine. The path is /templates in the plugin directory.

define( 'WP_TRAVEL_ENGINE_TEMPLATE_PATH', WP_TRAVEL_ENGINE_BASE_PATH.'/includes/templates' );

WP_TRAVEL_ENGINE_FILE_URL

Gives the file URL of the plugin directory.

define( 'WP_TRAVEL_ENGINE_FILE_URL', plugins_url( '', __FILE__ ) );

WP_TRAVEL_ENGINE_VERSION

The main version constant of the WP Travel Engine. Returns the current version number of WP Travel Engine plugin.

define( 'WP_TRAVEL_ENGINE_VERSION', 'version_number' );