Home / admin / Add custom pointers in themes and plugins
  • How to Add custom pointers in themes and plugins

    add-custom-pointers-in-themes-and-plugins

    Adding this snippet to the functions.php of your wordpress theme will let you take advantage of a new feature called pointers. Many of you may have noticed pointers in recent wordpress updates. Just update the pointer_content variables with the information you would like to display and the ID with jquery to assign the pointer “$(‘#menu-appearance’)”.

    ( example screenshot ) ( click code to copy )

    wordpress snippet : PHP

    <>
    add_action( 'admin_enqueue_scripts', 'my_admin_enqueue_scripts' );
    function my_admin_enqueue_scripts() {
        wp_enqueue_style( 'wp-pointer' );
        wp_enqueue_script( 'wp-pointer' );
        add_action( 'admin_print_footer_scripts', 'my_admin_print_footer_scripts' );
    }
    function my_admin_print_footer_scripts() {
        $pointer_content = '<h3>wpsnipp.com | Notice</h3>';
        $pointer_content .= '<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>';
    ?>
       <script type="text/javascript">
       //<![CDATA[
       jQuery(document).ready( function($) {
        $('#menu-appearance').pointer({
            content: '<?php echo $pointer_content; ?>',
            position: 'left',
            close: function() {
                // Once the close button is hit
            }
          }).pointer('open');
       });
       //]]>
       </script>
    <?php
    }
    

    ( WordPress codex functions, hooks, in this snippet. )

    query, add_action, _e, wp_enqueue_script, wp_enqueue_style, wp,
  • Gabriel

    Nice little function! However I noticed that even if you click “Dismiss” the notice comes back your next page. Are we missing some sort of save function to make sure it is dismissed permanently?

  • danbodenstein

    I agree, there has to be a way to only show this once. 

    • kachan64

      Yes, I wish the same!

  • MyFriendsHotel

    Hi, just wondering if this works on the front end of a website or if you know of a plugin for WordPress that allows this functionality? Thanks.

    • No support for the front end yet… But I think it may be coming. I know my company is developing API for a front end version and we may contribute it to the core.

    • No support for the front end yet… But I think it may be coming. I know my company is developing API for a front end version and we may contribute it to the core.

    • No support for the front end yet… But I think it may be coming. I know my company is developing API for a front end version and we may contribute it to the core.