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.


Top ↑

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;

	}


Top ↑

User Contributed Notes User Contributed Notes

30 day money back guarantee
Safe & Secure online payment
Custom CSS Slide Example
Custom Animation Example
Default Animation