The advanced integration of the Intro Tour Tutorial plugin for WordPress extends usability even in situations where a standard configuration is not enough. Based on the hooks and events that the plugin generates, you can run your own pieces of code both on the server side and in the browser of your client / visitor and thus cover these specific situations.
Download our API boilerplate plugin for faster implementation and examples
You can remove specified tours per actual URL- page, post etc. Useful not only in combination with Global Start at All Pages (PRO only) settings, when you are not able to achieve your trigger requirements by standard trigger configurations.
add_filter( 'dpintro_unload_tours', function( array $tours_to_unload, string $current_url ){ /* your code eg. if ($current_url == 'xyz') $tours_to_unload[] = 2546; return $tours_to_unload; */ }, 10, 2 );
You can force to start selected tour at actual URL, even when it doesn't pass trigger conditions.
add_filter( 'dpintro_force_load_tours', function( array $tours_to_force_load, string $current_url ){ /* your code eg. if ($current_url == 'xyz') $tours_to_force_load[] = 2544; return $tours_to_force_load; */ }, 10, 2 );
Here you can adjust integrates system variables or define your own code-based URL variables. So then URL of step can be defined as eg. /my-page/{$my-new-sys-url-var} or /my-page/?param1={$my-new-sys-url-var}. Name resp. key for your own code-based URL variables has to always start with $.
add_filter( 'dpintro_sys_url_var', function( array $sys_variables, int $tour_id){ /* your code eg. if ($tour_id == 1234) { $sys_variables['$current-user-login'] = adjust integrated system variable; $sys_variables['$my-new-sys-url-var'] = value of your new sys variable; } return $sys_variables; */ }, 10, 2 );
Here is an opportunity to adjust tour configuration by code. It is not generally recommended to use this filter as it can lead to unexpected results. However it can be used based on our support recommendation to help fix some special conditions, where standard configuration is not enough.
add_filter( 'dpintro_script_tour_config', function( array $tour_config, int $tour_id, string $current_url ){ /* your code to adjust tour configuration array eg. if ($tour_id == 1234) $tour_config['showBullets'] = true; return $tour_config; */ }, 10, 3 );
Here is an opportunity to adjust main script configuration by code. It is not generally recommended to use this filter as it can lead to unexpected results. However it can be used based on our support recommendation to help fix some special conditions, where standard configuration is not enough.
add_filter( 'dpintro_script_main_config', function( array $main_config, string $current_url ){ /* your code to adjust main configuration array eg. if ($curent_url == 'xyz') $main_config['mobile_menu_opener'] = #secondary-menu-toggle; $main_config['mobile_menu_closer'] = #secondary-menu-toggle; return $main_config; */ }, 10, 2 );
Global DpitHooks object (window.DpitHooks) is exposed as an interface for yours custom code based on the events of tour.
! Text with this color is just a hint, it is not part of the code, so if you copy and use these snippets, please delete it.
DpitHooks.add_filter( tag, callback, priority = 10 )
DpitHooks.remove_filter( tag, callback )
You can disable selected tour on particular page, post etc.
DpitHooks.add_filter( 'shouldInit', (value, options{ tourId, currentUrl }) => { // your code … return false to disable tour }, priority );
You can implement custom action based on tour events.
DpitHooks.add_action( tag, callback, priority = 10 )
DpitHooks.remove_action( tag, callback )
// Tour engines loaded and tour layers are created
DpitHooks.add_action( 'onInit', (options{ tourId, currentUrl }) => { /* your code */ }, priority )
DpitHooks.add_action( 'started', (options{ tourId, currentUrl }) => { /* your code */ }, priority )
DpitHooks.add_action( 'ended', (options{ tourId, currentUrl, reason }) => { /* your code */ }, priority)
DpitHooks.add_action( 'beforeStepChange', (options{ tourId, currentUrl, currentStepObj, nextStepObj, backward }) => { /* your code */ }, priority )
DpitHooks.add_action( 'afterStepChange', (options{ tourId, currentUrl, currentStepObj, backward, isStickyTheme, isStickyThemeOnTop }) => { /* your code */ }, priority )
// Tour edit on admin board was loaded
DpitHooks.add_action( 'adminEditTourLoaded', (options{ tourId }) => { /* your code */ }, priority )
DpitHooks.add_action( 'onOverlayClick', (options{ tourId, currentUrl }) => { /* your code */ }, priority )
// When the plugin reacts and refreshes on the window resize event
DpitHooks.add_action( 'onResize', (options{ tourId, currentUrl, currentSize, oldSize }) => { /* your code */ }, priority )
index: step index starting from 1 tooltipContent: text, html of step tooltipPosition: tooltip position ('top', 'right', 'bottom', 'left', 'center' or 'auto') element: tooltip reference element (standard JS HTML element) selector: selector of reference element isEnabledInteraction: is user interaction enabled (true or false)
Following properties are available in PRO version only:
url: url of step (string) altMobileSelector: alternative selector for mobile view isInMobileMenu: is reference element in mobile menu (true or false) skipOnBigScreen: should be step skipped on big screens (true or false) skipOnMobile: should be step skipped on mobile screens (true or false)
}
Global DpitApi object (window.DpitApi) is exposed as an interface for yours custom code based tour navigation commands. This object starts to be available as soon as tour starts - after started action is triggered. So API is connected to running tour only. It is recommended to use it in combination with JS hooks above. Most suitable hook is afterStepChange.
Code example:
jQuery(document).ready(($) => { if (window.DpitHooks) { DpitHooks.add_action('afterStepChange', (args) => { if (args.currentStepObj.index === 1) DpitApi.goToNext(); else if (args.currentStepObj.index === 3) DpitApi.goToPrev(); else if (args.currentStepObj.index === 5) DpitApi.goToStep(7); else if (args.currentStepObj.index === 7) DpitApi.exit(); }); } });