On this page
WP_Internal_Pointers::print_js( string $pointer_id, string $selector, array $args )
This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
Print the pointer JavaScript data.
Parameters
$pointer_idstring Required-
The pointer ID.
$selectorstring Required-
The HTML elements, on which the pointer should be attached.
$argsarray Required-
Arguments to be passed to the pointer JS (see wp-pointer.js).
Source
File: wp-admin/includes/class-wp-internal-pointers.php. View all references
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
}
Related
Uses
| Uses | Description |
|---|---|
| wp_json_encode() wp-includes/functions.php | Encodes a variable into JSON, with some sanity checks. |
Changelog
| Version | Description |
|---|---|
| 3.3.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_internal_pointers/print_js