Plugin Directory

Changeset 3412641


Ignore:
Timestamp:
12/05/2025 09:26:58 PM (4 months ago)
Author:
globaliser
Message:

Removed custom url redirect

Location:
globaliser
Files:
88 added
4 edited

Legend:

Unmodified
Added
Removed
  • globaliser/trunk/app/controllers/security-controller.php

    r3393757 r3412641  
    1717    public function main()
    1818    {
    19         if ( !$this->service->is_custom_login_enabled() ) {
    20             return; // Skip if custom login is not enabled
     19       
     20        $this->on('wp_login', 'login', 10, 2);
     21        $this->on('wp_logout', 'logout');
     22
     23        if ( $this->service->is_custom_login_enabled() ) {
     24               
     25            $this->on('init', 'add_custom_login_rewrite');
     26            $this->on('login_init', 'redirect_wp_login');
     27            $this->on('template_redirect', 'load_custom_login_page');
     28            $this->on('login_footer', 'modify_login_form_action');
     29            $this->on('site_url', 'filter_login_url', 10, 2);
     30     
    2131        }
    22 
    23         $this->on('init', 'add_custom_login_rewrite');
    24         $this->on('login_init', 'redirect_wp_login');
    25         $this->on('template_redirect', 'load_custom_login_page');
    26         $this->on('login_footer', 'modify_login_form_action');
    27         $this->on('site_url', 'filter_login_url', 10, 2);
    2832
    2933    }
     
    5458    }
    5559
     60    public function login($user_login, $user)
     61    {
     62        $this->service->login($user_login, $user);
     63    }
     64
     65     public function logout()
     66    {
     67        $this->service->logout();
     68    }
     69
    5670}
  • globaliser/trunk/app/services/login-service.php

    r3393762 r3412641  
    3232
    3333    /**
    34      * Redirect direct access to wp-login.php
    35      * Allows logout and other special actions to proceed
     34     * Block direct access to wp-login.php
    3635     */
    3736    public function redirect_wp_login()
    3837    {
    39         $current = $_SERVER['REQUEST_URI'] ?? '';
    40         if ( strpos($current, 'wp-login.php') !== false ) {
    41             // Don't redirect logout and other special action URLs
    42             $excluded_actions = ['logout', 'postpass', 'rp', 'resetpass', 'retrievepassword', 'register'];
    43             $action = $_REQUEST['action'] ?? '';
    44 
    45             if ( !empty($action) && in_array($action, $excluded_actions, true) ) {
    46                 return; // Allow these actions to proceed normally
    47             }
    48 
    49             wp_redirect($this->login_url);
    50             exit;
     38        $current_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     39        $wp_login_url = site_url('wp-login.php');
     40       
     41        if ( strpos($current_url, $wp_login_url) === 0 ) {
     42            wp_die('Not Found', '404 Not Found', ['response' => 404]);
    5143        }
    5244    }
     
    119111    }
    120112
     113    /**
     114     * Handle actions after user login
     115     *
     116     * @param string $user_login The username
     117     * @param WP_User $user The WP_User object
     118     */
     119    public function login($user_login, $user)
     120    {
     121       
     122        if (!$user || !is_a($user, 'WP_User')) {
     123        return;
     124    }
     125   
     126    $user_roles = $user->roles;
     127    $primary_role = !empty($user_roles) ? $user_roles[0] : 'subscriber';
     128    $expiry = time() + (30 * DAY_IN_SECONDS);
     129   
     130    setcookie(
     131        'X-Globaliser-User-Role',
     132        $primary_role,
     133        $expiry,
     134        COOKIEPATH,
     135        COOKIE_DOMAIN,
     136        is_ssl(),
     137        true
     138    );
     139    }
     140
     141    public function logout() {
     142
     143    setcookie(
     144        'X-Globaliser-User-Role',
     145        '',
     146        time() - 3600,
     147        COOKIEPATH,
     148        COOKIE_DOMAIN,
     149        is_ssl(),
     150        true
     151    );
     152}
     153
    121154
    122155}
  • globaliser/trunk/globaliser.php

    r3393762 r3412641  
    22/*
    33   Plugin Name: Globaliser
    4    Plugin URI: https://www.globaliser.com/wordpress-hosting/
     4   Plugin URI: https://www.globaliser.com
    55   Description:  This plugin enables Globaliser Cloud Speed, Security, and Reliability features for WordPress sites. It is intended for Globaliser clients only.
    6    Version: 0.9.12
     6   Version: 0.9.13
    77   Author: Globaliser, Inc.
    88   Author URI: https://www.globaliser.com
  • globaliser/trunk/readme.txt

    r3393762 r3412641  
    55License: GPLv2 or later
    66Tested up to: 6.8
    7 Stable tag: 0.9.12
     7Stable tag: 0.9.13
    88Requires PHP: 8.1
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2727
    2828== Changelog ==
     29
     30= 0.9.13 =
     31* Removed login redirect for custom url.
    2932
    3033= 0.9.12 =
Note: See TracChangeset for help on using the changeset viewer.