coresocial_page_context
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!
Definition
Arguments
Returns
Runs when a sharing method resolves its page context. The underlying context is cached for the request, but the filter runs when context() returns it.
Preserve the complete array. item is post, term, or custom; item_id is the WordPress ID or 0 for custom URLs. image is the featured-image URL or an empty string.
This controls the shared page context, not only its appearance. AJAX validation still requires valid signatures, appropriate action/network/module combinations, and publicly viewable post or term targets.
Example
add_filter( 'coresocial_page_context', function ( $context ) {
if ( $context['item'] === 'custom' ) {
$context['title'] = wp_strip_all_tags( $context['title'] );
}
return $context;
} );