coresocial-sharing-popup-open

Developer Knowledge Level

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!

JS
Action identifier (JavaScript)
do_action( "coresocial-sharing-popup-open", details, link, popup );
coreSocial 4.0 — src/frontend/index.ts:137
Arguments
Name
Type
Description
details
object
Shared details object: action, network, item, item_id, url, title. item_id comes from the link dataset and is normally a string.
link
HTMLAnchorElement
Activated share/print/QR link.
popup
Window|null
Result of window.open(); null when blocked.

JavaScript wp.hooks action fired after the standard share window.open() call and before the optional popup.focus(). It receives the same details object and link as popup-ready.

The action still fires if the popup was blocked. Check for null. It does not report whether the visitor completed a share, and custom app/AI handlers do not necessarily emit it.

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-popup-open', 'my-site/popup-observer', function ( details, link, popup ) {
    if ( ! popup ) {
        console.log( 'Share popup was blocked.' );
    }
} );
Rate this reference
0
0
2

You are not allowed to rate this post.

Leave a Comment

0
0
0
0
0
0
0
0
0