Plugin Directory

Changeset 3216792


Ignore:
Timestamp:
01/04/2025 08:40:43 AM (15 months ago)
Author:
ttodua
Message:

current url detect

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sign-in-with-essentials/trunk/src/includes/class-siwe-handlers.php

    r3216630 r3216792  
    108108    }
    109109
     110    public static function get_install_subdir_from_home () {
     111        $siteurl = get_site_url('siteurl');
     112        $relpath = str_replace( ['http://', 'https://'], '', $siteurl );
     113        $relpath = str_replace( $_SERVER['HTTP_HOST'], '', $relpath );
     114        if ($relpath === '/') {
     115            $relpath = '';
     116        }
     117        return $relpath;
     118    }
     119
    110120    /**
    111121     * Uses the code response from redirection-back to authenticate the user, before anything is rendered.
     
    129139        $redir_url = $this->parent->siwe_redirect_back_url();
    130140        $is_query = str_contains ($redir_url, '?' );
     141        $start_path = str_replace ( $this->get_install_subdir_from_home(), '', $_SERVER['REQUEST_URI'] );
    131142
    132143        if (
    133144            (   $is_query && array_key_exists(str_replace('?', '', $redir_url), $_GET) )
    134145                ||
    135             ( ! $is_query && str_starts_with(sanitize_url($_SERVER['REQUEST_URI']), $redir_url ) )
     146            ( ! $is_query && str_starts_with(sanitize_url($start_path), $redir_url ) )
    136147        )
    137148        {
Note: See TracChangeset for help on using the changeset viewer.