WC_Admin_Pointers::enqueue_pointers( array $pointers )
Enqueue pointers and add script to page.
Description Description
Parameters Parameters
- $pointers
-
(Required) Pointers data.
Source Source
File: includes/admin/class-wc-admin-pointers.php
public function enqueue_pointers( $pointers ) { $pointers = rawurlencode( wp_json_encode( $pointers ) ); wp_enqueue_style( 'wp-pointer' ); wp_enqueue_script( 'wp-pointer' ); wc_enqueue_js( "jQuery( function( $ ) { var wc_pointers = JSON.parse( decodeURIComponent( '{$pointers}' ) ); setTimeout( init_wc_pointers, 800 ); function init_wc_pointers() { $.each( wc_pointers.pointers, function( i ) { show_wc_pointer( i ); return false; }); } function show_wc_pointer( id ) { var pointer = wc_pointers.pointers[ id ]; var options = $.extend( pointer.options, { pointerClass: 'wp-pointer wc-pointer', close: function() { if ( pointer.next ) { show_wc_pointer( pointer.next ); } }, buttons: function( event, t ) { var close = '" . esc_js( __( 'Dismiss', 'woocommerce' ) ) . "', next = '" . esc_js( __( 'Next', 'woocommerce' ) ) . "', button = $( '<a class=\"close\" href=\"#\">' + close + '</a>' ), button2 = $( '<a class=\"button button-primary\" href=\"#\">' + next + '</a>' ), wrapper = $( '<div class=\"wc-pointer-buttons\" />' ); button.bind( 'click.pointer', function(e) { e.preventDefault(); t.element.pointer('destroy'); }); button2.bind( 'click.pointer', function(e) { e.preventDefault(); t.element.pointer('close'); }); wrapper.append( button ); wrapper.append( button2 ); return wrapper; }, } ); var this_pointer = $( pointer.target ).pointer( options ); this_pointer.pointer( 'open' ); if ( pointer.next_trigger ) { $( pointer.next_trigger.target ).on( pointer.next_trigger.event, function() { setTimeout( function() { this_pointer.pointer( 'close' ); }, 400 ); }); } } });" ); }