Make WordPress Core

Changes between Version 3 and Version 4 of Ticket #63376, comment 3


Ignore:
Timestamp:
05/02/2025 07:17:12 AM (6 months ago)
Author:
sh4lin
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #63376, comment 3

    v3 v4  
    77> The URL for the current site where the front end is accessible.
    88> https://developer.wordpress.org/reference/functions/home_url/
     9
     10
     11Also, `get_self_link()` uses `home_url()`. It parses the URL, extracts the domain and port, sets the scheme for the URL, and appends `REQUEST_URI` from the server global variable.
     12
     13{{{#!php
     14<?php
     15function get_self_link() {
     16        $parsed = parse_url( home_url() );
     17
     18        $domain = $parsed['host'];
     19        if ( isset( $parsed['port'] ) ) {
     20                $domain .= ':' . $parsed['port'];
     21        }
     22
     23        return set_url_scheme( 'http://' . $domain . wp_unslash( $_SERVER['REQUEST_URI'] ) );
     24}
     25}}}
     26
     27