Get URL of link source

If you want to determine the source of access, you can use the following logic.

$link_url = isset($_SERVER['HTTP_REFERER']) ? esc_url($_SERVER['HTTP_REFERER']) : '';

In simple terms, it is a variable that identifies the page URL before the visiting user accessed the currently open page. It has all kinds of information about the browser.

For example, on an online shopping site, clicking the “Inquire about this product” link will open a form with the product URL automatically set.

If there is a process that could not get the URL, it is more polite.

if (empty($link_url)) {
	$link_url = 'Please enter the product URL';
}

You can automatically retrieve the URL, set an arbitrary string, etc., and output it afterwards. You can use static html and system integration in any way you like.

Please refer to this page when creating a process that works with your system.

Leave a comment on the article