Making WordPress.org


Ignore:
Timestamp:
05/18/2016 09:26:41 AM (9 years ago)
Author:
ocean90
Message:

WordPress.org SSO: Remove trailing spaces.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/common/includes/wporg-sso/wp-plugin.php

    r2465 r3166  
    22/**
    33 * WordPress-specific WPORG SSO: redirects all WP login and registration screens to our SSO ones.
    4  * 
     4 *
    55 * @uses WPOrg_SSO (class-wporg-sso.php)
    66 * @author stephdau
     
    2323            'oauth'        => '/oauth',
    2424        );
    25        
     25
    2626        /**
    2727         * Constructor: add our action(s)/filter(s)
     
    3636            }
    3737        }
    38    
     38
    3939        /**
    4040         * Redirect all attempts to get to a WP login or signup to the SSO ones, or to a safe redirect location.
    41          
     41
    4242         * @example add_action( 'init', array( &$wporg_sso, 'redirect_all_wp_login_or_signup_to_sso' ) );
    43          * 
     43         *
    4444         * @note Also handles accesses to lost password forms, since wp-login too.
    4545         */
     
    4949                return;
    5050            }
    51            
     51
    5252            $redirect_req = $this->_get_safer_redirect_to();
    53            
     53
    5454            // Add our host to the list of allowed ones.
    5555            add_filter( 'allowed_redirect_hosts', array( &$this, 'add_allowed_redirect_host' ) );
    56            
     56
    5757            // Replace the lost password URL by our own
    5858            add_filter( 'lostpassword_url', array( &$this, 'lostpassword_url' ), 10, 2 );
    59            
     59
    6060            if ( preg_match( '!/wp-signup\.php$!', $this->script ) ) {
    6161                // If we're on any WP signup screen, redirect to the SSO host one,respecting the user's redirect_to request
    6262                $this->_safe_redirect( add_query_arg( 'redirect_to', urlencode( $redirect_req ), $this->sso_signup_url ) );
    63            
     63
    6464            } elseif ( self::SSO_HOST !== $this->host ) {
    6565                // If we're not on the SSO host
     
    6767                    // If on a WP login screen...
    6868                    $redirect_to_sso_login = $this->sso_login_url;
    69                    
     69
    7070                    // Pass thru the requested action, loggedout, if any
    7171                    if ( ! empty( $_GET ) ) {
    7272                        $redirect_to_sso_login = add_query_arg( $_GET, $redirect_to_sso_login );
    7373                    }
    74                    
     74
    7575                    // Pay extra attention to the post-process redirect_to
    7676                    $redirect_to_sso_login = add_query_arg( 'redirect_to', urlencode( $redirect_req ), $redirect_to_sso_login );
    77                    
     77
    7878                    // And actually redirect to the SSO login
    7979                    $this->_safe_redirect( $redirect_to_sso_login );
    80                
     80
    8181                } else {
    8282                    // Otherwise, filter the login_url to point to the SSO
    8383                    add_action( 'login_url', array( &$this, 'login_url' ), 10, 2 );
    8484                }
    85            
     85
    8686            } else if ( self::SSO_HOST === $this->host ) {
    8787                // If on the SSO host
     
    9090                    if ( preg_match( '!^(' . implode( '|', $this->valid_sso_paths ) . ')([/?]{1,2}.*)?$!', $_SERVER['REQUEST_URI'] ) ) {
    9191                        // If we're on the path of interest
    92                        
     92
    9393                        // Add a custom filter others can apply (theme, etc).
    9494                        add_filter( 'is_valid_wporg_sso_path' , '__return_true' );
    95                        
     95
    9696                        if ( preg_match( '!^/(\?.*)?$!', $_SERVER['REQUEST_URI'] ) ) {
    9797                            // If at host root (/)
     
    133133            }
    134134        }
    135        
     135
    136136        /**
    137137         * Modifies the network_site_url on login.wordpress.org's login screen to make sure all forms and links
    138138         * go to the SSO host, not wordpress.org
    139          * 
     139         *
    140140         * @param string $url
    141141         * @param string $path
    142142         * @param string $scheme
    143          * @return string 
    144          * 
     143         * @return string
     144         *
    145145         * @example add_action( 'network_site_url', array( &$this, 'login_network_site_url' ), 10, 3 );
    146146         */
     
    149149                $url = preg_replace( '!^(https?://)[^/]+(/.+)$!' , '\1'.self::SSO_HOST.'\2', $url );
    150150            }
    151            
     151
    152152            return $url;
    153153        }
    154154
    155        
     155
    156156        /**
    157157         * Filters the defaults captions and options for the login form
    158          * 
     158         *
    159159         * @param array $defaults
    160160         * @return array
     
    168168            return $defaults;
    169169        }
    170        
     170
    171171        /**
    172172         * Filters the default lost password URL and returns our custom one instead.
    173          * 
     173         *
    174174         * @param string $lostpassword_url
    175175         * @param string $redirect
     
    178178            return home_url( $this->valid_sso_paths['lostpassword'] . '/?redirect_to=' . $redirect );
    179179        }
    180        
     180
    181181        /**
    182182         * Redirects the user to her/his (support) profile.
     
    194194        }
    195195    }
    196    
     196
    197197    new WP_WPOrg_SSO();
    198198}
Note: See TracChangeset for help on using the changeset viewer.