Search code examples
phpwordpresspointerspluginsadmin

How do you create a basic Wordpress admin pointer?


I have been looking around for quite awhile now and all I have found are tutorials from 3-4 years ago that explain how to do a pointer tour. All I want to do is add a pointer that pops up when someone activates my plugin so that I can notify them of a new menu option where they will go to view my plugin settings. Any help would be greatly appreciated!


Solution

  • What you are looking for is WordPress Activation / Deactivation Hooks. For example:

    register_activation_hook( __FILE__, 'pluginprefix_function_to_run' );
    

    And on pluginprefix_function_to_run, display a nice message to let users know that you've added a menu using admin_notices:

    function my_admin_notice() {
        ?>
        <div class="updated">
            <p><?php _e( 'Your message goes here!', 'my-text-domain' ); ?></p>
        </div>
        <?php
    }
    
    function pluginprefix_function_to_run() {
        add_action( 'admin_notices', 'my_admin_notice' );
    }