coresocial-sharing-copy-error
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 when ClipboardJS reports a Copy URL failure. Independent of tracking success. It does not report AI prompt copying or the absence of ClipboardJS itself.
Register with wp.hooks.addAction(), using a unique namespace. Enqueue the listener with wp-hooks and coresocial-main dependencies before the interaction. The Source Code block uses a generic action template; the example shows the JavaScript API. Keep listeners lightweight and handle their own errors.
Example
wp.hooks.addAction( 'coresocial-sharing-copy-error', 'my-site/clipboard', function ( link ) {
console.log( 'Copy failed for', link.dataset.url );
} );