Noptin_Mailer::make_links_trackable( string $content, array $data )
Makes campaign links trackable.
Parameters Parameters
- $content
(string) (Required) The email content.
- $data
(array) (Required) The new campaign data.
Source Source
File: includes/class-noptin-mailer.php
public function make_links_trackable( $content, $data ) { if ( empty( $data['campaign_id'] ) || empty( $data['subscriber_id'] ) ) { return $content; } $url = get_noptin_action_url( 'email_click' ); $url = add_query_arg( array( 'sid' => intval( $data['subscriber_id'] ), 'cid' => intval( $data['campaign_id'] ), 'noptin_hide' => 'true' ), $url ); $_content = preg_replace_callback( '/<a(.*?)href=["\'](.*?)["\'](.*?)>/mi', function ( $matches ) use ( $url ) { $_url = add_query_arg( 'to', urlencode( $matches[2] ), $url ); $pre = $matches[1]; $post = $matches[3]; return "<a $pre href='$_url' $post >"; }, $content ); if ( empty( $_content ) ) { return $content; } return $_content; }
Expand full source code Collapse full source code View on GitHub