Extend LinkCentral with Hooks

Developers can extend LinkCentral functionality using hooks. The following hooks are available:

Link Clicks & Redirect

linkcentral_link_clicked – Action hook fired when a LinkCentral link is clicked. No further validations have happened at this point, such as a check if the link is a draft, set as private, scheduled for the future, or password protected. 

The hook passes:

  • The link ID
  • The link slug
  • The full link post object
				
					/**
 * @param int $link_id The ID of the clicked link
 * @param string $slug The slug of the clicked link
 * @param WP_Post $link The full link post object
 */
add_action('linkcentral_link_clicked', function($link_id, $slug, $link) {
    // Access post data from the link object
    $title = $link->post_title;
    $created_date = $link->post_date;
    
    // Perform custom operations with the link data
    my_custom_function($link_id, $title);
}, 10, 3);
				
			

linkcentral_before_redirect – Action hook that is triggered right before a valid link is redirected. All checks have passed. The hook passes: 

  • The link ID
  • The link slug
  • The final destination URL
  • The redirection type
  • The full link post object
				
					   /**
    * @param int $link_id The ID of the link
    * @param string $slug The slug of the link
    * @param string $destination_url The final destination URL
    * @param int $redirection_type The HTTP redirection code (301, 302, 307)
    * @param WP_Post $link The full link post object
    */
   add_action('linkcentral_before_redirect', function($link_id, $slug, $destination_url, $redirection_type, $link) {
       // Send data to an external analytics system
       my_analytics_service::track_outbound_link([
           'link_id' => $link_id,
           'slug' => $slug,
           'destination' => $destination_url,
           'user_id' => get_current_user_id()
       ]);
   }, 10, 5);
				
			

LinkCentral also supports webhooks as an alternative to hooks. Webhooks are triggered at the same time as linkcentral_before_redirect. Read more about Webhooks here.

Link Pages

These hooks run on public “Link Pages” / “Link in Bio” pages only.

linkcentral_link_page_head – Action hook fired in the <head> of a Link Page, after wp_head() and the page’s inline styles. Use it to output meta tags, tracking pixels, or other head markup.

The hook passes:

  • The Link Page post object
  • The Link Page post ID
  • The current user ID (0 when not logged in)
				
					/**
 * @param WP_Post $link_page The Link Page post object
 * @param int     $link_page_id The Link Page post ID
 * @param int     $user_id The current user ID, or 0 when not logged in
 */
add_action( 'linkcentral_link_page_head', function( $link_page, $link_page_id, $user_id ) {
    echo '<meta name="author" content="My Brand">';
}, 10, 3 );
				
			

linkcentral_link_page_footer – Action hook fired at the bottom of a Link Page, after wp_footer(). Use it for chat widgets, analytics scripts, or other footer markup.

The hook passes:

  • The Link Page post object
  • The Link Page post ID
  • The current user ID (0 when not logged in)
				
					/**
 * @param WP_Post $link_page The Link Page post object
 * @param int     $link_page_id The Link Page post ID
 * @param int     $user_id The current user ID, or 0 when not logged in
 */
add_action( 'linkcentral_link_page_footer', function( $link_page, $link_page_id, $user_id ) {
    echo '<script>/* analytics or chat widget */</script>';
}, 10, 3 );
				
			

linkcentral_link_page_allowed_assets – On public Link Pages, LinkCentral dequeues theme stylesheets and scripts so the theme cannot override the page design. Plugin assets are left intact by default. This filter controls which stylesheet and script handles are never dequeued, even when they come from the theme. Use it to pin additional handles that must always load.

The filter receives an array of asset handles and must return the updated array.

				
					add_filter( 'linkcentral_link_page_allowed_assets', function( $handles ) {
    $handles[] = 'my-plugin-styles';
    $handles[] = 'my-plugin-script';
    return $handles;
} );
				
			
Contents