{"id":658,"date":"2025-04-15T05:39:00","date_gmt":"2025-04-14T20:39:00","guid":{"rendered":"https:\/\/touhyo.com\/blog\/?p=658"},"modified":"2025-04-29T20:02:31","modified_gmt":"2025-04-29T11:02:31","slug":"get-url-of-link-source","status":"publish","type":"post","link":"https:\/\/touhyo.com\/blog\/en\/get-url-of-link-source\/","title":{"rendered":"Get URL of link source"},"content":{"rendered":"\n<p>If you want to determine the source of access, you can use the following logic.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#F8F8F2;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><pre class=\"shiki monokai\" style=\"background-color: #272822\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F8F8F2\">$link_url <\/span><span style=\"color: #F92672\">=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #66D9EF\">isset<\/span><span style=\"color: #F8F8F2\">($_SERVER[<\/span><span style=\"color: #E6DB74\">&#39;HTTP_REFERER&#39;<\/span><span style=\"color: #F8F8F2\">]) <\/span><span style=\"color: #F92672\">?<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #A6E22E\">esc_url<\/span><span style=\"color: #F8F8F2\">($_SERVER[<\/span><span style=\"color: #E6DB74\">&#39;HTTP_REFERER&#39;<\/span><span style=\"color: #F8F8F2\">]) <\/span><span style=\"color: #F92672\">:<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #E6DB74\">&#39;&#39;<\/span><span style=\"color: #F8F8F2\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>For example, on an online shopping site, clicking the &#8220;Inquire about this product&#8221; link will open a form with the product URL automatically set.<\/p>\n\n\n\n<p>If there is a process that could not get the URL, it is more polite.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#F8F8F2;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><pre class=\"shiki monokai\" style=\"background-color: #272822\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F92672\">if<\/span><span style=\"color: #F8F8F2\"> (<\/span><span style=\"color: #66D9EF\">empty<\/span><span style=\"color: #F8F8F2\">($link_url)) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">\t$link_url <\/span><span style=\"color: #F92672\">=<\/span><span style=\"color: #F8F8F2\"> <\/span><span style=\"color: #E6DB74\">&#39;Please enter the product URL&#39;<\/span><span style=\"color: #F8F8F2\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F8F8F2\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>Please refer to this page when creating a process that works with your system.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you want to determine the source of access, you can use the following logic. 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 &#8220;Inquire [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"en_US","_original_post":"https:\/\/touhyo.com\/blog\/?p=655","footnotes":""},"categories":[1],"tags":[],"class_list":["post-658","post","type-post","status-publish","format-standard","hentry","category-memo","en-US"],"_links":{"self":[{"href":"https:\/\/touhyo.com\/blog\/wp-json\/wp\/v2\/posts\/658","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/touhyo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/touhyo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/touhyo.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/touhyo.com\/blog\/wp-json\/wp\/v2\/comments?post=658"}],"version-history":[{"count":6,"href":"https:\/\/touhyo.com\/blog\/wp-json\/wp\/v2\/posts\/658\/revisions"}],"predecessor-version":[{"id":681,"href":"https:\/\/touhyo.com\/blog\/wp-json\/wp\/v2\/posts\/658\/revisions\/681"}],"wp:attachment":[{"href":"https:\/\/touhyo.com\/blog\/wp-json\/wp\/v2\/media?parent=658"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/touhyo.com\/blog\/wp-json\/wp\/v2\/categories?post=658"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/touhyo.com\/blog\/wp-json\/wp\/v2\/tags?post=658"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}