Prints the pointer JavaScript data.
Parameters
$pointer_id
stringrequired- The pointer ID.
$selector
stringrequired- The HTML elements, on which the pointer should be attached.
$args
arrayrequired- Arguments to be passed to the pointer JS (see wp-pointer.js).
Source
private static function print_js( $pointer_id, $selector, $args ) {
if ( empty( $pointer_id ) || empty( $selector ) || empty( $args ) || empty( $args['content'] ) ) {
return;
}
?>
<script type="text/javascript">
(function($){
var options = <?php echo wp_json_encode( $args ); ?>, setup;
if ( ! options )
return;
options = $.extend( options, {
close: function() {
$.post( ajaxurl, {
pointer: '<?php echo $pointer_id; ?>',
action: 'dismiss-wp-pointer'
});
}
});
setup = function() {
$('<?php echo $selector; ?>').first().pointer( options ).pointer('open');
};
if ( options.position && options.position.defer_loading )
$(window).bind( 'load.wp-pointers', setup );
else
$( function() {
setup();
} );
})( jQuery );
</script>
<?php
}
Changelog
Version | Description |
---|---|
3.3.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.