Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Guided Tour/Pointer API
<?php
/*
Guided Tour/Pointer API
Notes:
- exit button is by default
- next button is there if another pointer is linked to this one via previous-pointer
- if no attach-to, put it in the center if the window
- tour and pointer slugs are used for IDs in HTML and keys in user options
*/
$tour = new WPGuidedTour('admin');
$tour->add_pointer( 'welcome', array(
'content' => '<h3>Welcome</h3><p>We will guide you throughout the wp-admin interface.</p>',
'show-on' => 'each-admin-page',
) );
$tour->add_pointer( 'posts', array(
'content' => '<p>Posts are cool. Hover the posts menu to get started.</p>',
'show-on' => 'each-admin-page',
'attach-to' => '#menu-posts',
'position' => 'right',
'previous-pointer' => 'welcome',
) );
$tour->add_pointer( 'add-new-post', array(
'content' => '<p>New posts are even cooler. Click on </p>',
'show-on' => 'each-admin-page',
'attach-to' => '#menu-posts li[href="post-new.php"]',
'position' => 'right',
'previous-pointer' => 'posts',
'pre-create-js' => 'function($) { $("#menu-posts").hover(); }',
) );
$tour->add_pointer( 'post-title', array(
'content' => 'Write a title',
'show-on' => array( 'hook-suffix' => 'post-new.php' ),
'attach-to' => '#title',
'position' => 'bottom',
'previous-pointer' => 'add-new-post',
'js-pre-create' => <<<JS
function($) {
window.location.href = "post-new.php";
$("#title").focus();
}
JS;
) );
$tour->add_pointer( 'post-body', array(
'content' => 'Write a body',
'show-on' => array( 'hook-suffix' => 'post-new.php' ),
'attach-to' => '#body',
'position' => array( 'my' => 'left top', 'at' => 'center bottom', 'offset' => '-25 0' ),
'previous-pointer' => 'post-title',
'js-pre-create' => <<<JS
function($) {
$("#body").focus();
}
JS;
) );
/* Init will set all the needed hooks, enqueue scripts, etc. */
add_action( 'init', function() use ($tour) { $tour->init(); } );
$pointer = $tour->get_pointer( 'add-new-post' );
$pointer = $tour->get_next_pointer_of( 'add-new-post' );
$pointers = $tour->get_pointers();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.