coresocial-sharing-print
This content is intended for WordPress developers, and it may require coding knowledge of WordPress, PHP, and JavaScript. Code examples provided here may contain errors or needs some additional coding. Make sure to test the code before using it on a live website!
Action identifier (JavaScript)
Arguments
JavaScript wp.hooks action fired after the shared frontend calls window.print() for the printer button. The timing follows the browser’s print-dialog behavior.
This is not confirmation that a document was printed; the visitor can cancel the dialog. It does not provide a print result or a filtered value.
Register with wp.hooks.addAction(), not PHP add_action(). Load the listener with the wp-hooks script dependency before the relevant user interaction. The Source Code block uses its generic action template; the code example shows the actual JavaScript API.
Example
wp.hooks.addAction( 'coresocial-sharing-print', 'my-site/print-observer', function ( link ) {
console.log( 'Print dialog requested.' );
} );