Step-1 → Download:
在主题目录中下载引导程序所需的CSS/JS文件。
Step-2 → Tour setup script:
按照中的说明操作
bootstraptour 对于
the Tour setup script. 例如,下面的脚本将在WordPress管理面板主仪表板(页面加载)上加载教程,并显示默认WP的教程
Activity
&;
At a Glance
小部件:
Note: 查看代码中的注释以了解更多说明:
// bootstrap-tour.js file
(function($) {
var tour = new Tour({
backdrop: true,
steps: [
{
element: "#dashboard_right_now",
title: "Summary Widget.",
content: "This widget shows the summary of your WP installation."
},
{
element: "#dashboard_activity",
title: "Activity Widget.",
content: "This is WP Dashboard Activity Widget."
}]
});
tour.init();
// This will load on each page load or refresh.
// You may want to change this behaviour according to your need.
// e.g. show the tour on a click even of a custom notice or button
// within admin panel dashboard.
$( window ).load( function() {
tour.start( true );
});
})( jQuery );
Step-3 → Load the Script in Admin Panel:
使用
admin_enqueue_scripts
钩子在管理面板面板中添加引导程序CSS和JS文件,如主题中的以下代码
functions.php
文件:
function wpse308865_bootstrap_tour_enqueue_scripts( $admin_page ) {
if ( \'index.php\' != $admin_page ) {
// so basically we\'re allowing the tour only on the main dashboard
// change this if you want it elsewhere as well.
return;
}
// this is bootstrap tour css and js file inside theme\'s directory
wp_register_style( \'bootstrap_tour_css\', get_stylesheet_directory_uri() . \'/bootstrap-tour-standalone.min.css\', false, \'1.0\' );
wp_enqueue_style( \'bootstrap_tour_css\' );
wp_enqueue_script( \'bootstrap_tour_js\', get_stylesheet_directory_uri() . \'/bootstrap-tour-standalone.min.js\', array( \'jquery\' ), \'1.0\' );
// this is the custom bootstrap tour loading script inside theme\'s directory
wp_enqueue_script( \'bootstrap_tour\', get_stylesheet_directory_uri() . \'/bootstrap-tour.js\', array( \'bootstrap_tour_js\' ), \'1.0\' );
}
add_action( \'admin_enqueue_scripts\', \'wpse308865_bootstrap_tour_enqueue_scripts\' );
<小时>
Note: 这只是一个如何添加CSS的演示&;主题中WordPress管理面板面板中引导程序的JavaScript代码。显然,您必须相应地调整上述代码以满足您的需要。