Making WordPress.org

Changeset 3166


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

WordPress.org SSO: Remove trailing spaces.

Location:
sites/trunk/common/includes/wporg-sso
Files:
3 edited

Legend:

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

    r2166 r3166  
    22/**
    33 * bbPress-specific WPORG SSO: redirects all BB login and registration screens to our SSO ones.
    4  * 
     4 *
    55 * @uses WPOrg_SSO (class-wporg-sso.php)
    66 * @author stephdau
     
    2222            }
    2323        }
    24        
     24
    2525        /**
    2626         * Redirect all attempts to get to a BB login or signup to the SSO ones, or to a safe redirect location.
    27          * 
     27         *
    2828         * @example add_action( 'bb_init', array( &$wporg_sso, 'redirect_all_bb_login_or_signup_to_sso' ) );
    2929         */
     
    4545                    return;
    4646                }
    47                    
     47
    4848                $redirect_to_sso_login = $this->sso_login_url;
    49                
     49
    5050                // Pass thru the requested action, logged out, if any
    5151                if ( ! empty( $_GET ) ) {
    5252                    $redirect_to_sso_login = add_query_arg( $_GET, $redirect_to_sso_login );
    5353                }
    54                    
     54
    5555                // Pay extra attention to the post-process redirect_to
    5656                $redirect_to_sso_login = add_query_arg( 'redirect_to', urlencode( $this->_get_safer_redirect_to() ), $redirect_to_sso_login );
    57                
     57
    5858                // Redirect to SSO login, trying to pass on a decent redirect_to request.
    5959                $this->_safe_redirect( $redirect_to_sso_login );
     
    6161        }
    6262    }
    63    
     63
    6464    new BB_WPOrg_SSO();
    6565}
  • sites/trunk/common/includes/wporg-sso/gp-plugin.php

    r2150 r3166  
    22/**
    33 * WPORG SSO: filters gp_url_login() to return the equivalent SSO URL instead, removes the login route.
    4  * 
    5  * @uses WPOrg_SSO (class-wporg-sso.php) 
     4 *
     5 * @uses WPOrg_SSO (class-wporg-sso.php)
    66 * @author stephdau
    77 */
     
    99    class GP_WPOrg_SSO extends GP_Plugin {
    1010        var $sso_obj;
    11        
     11
    1212        function __construct() {
    1313            parent::__construct();
    14            
     14
    1515            // Load SSO lib
    1616            $this->instantiate_sso();
    17            
     17
    1818            if ( $this->sso_obj->has_host() ) {
    1919                // Actions
     
    2323            }
    2424        }
    25        
     25
    2626        /**
    2727         * Instantiates a WPOrg_SSO (SSO lib) obj as self::sso_obj
     
    3535            }
    3636        }
    37        
     37
    3838        /**
    3939         * Init action: remove the /login route, login URL filtered to SSO's in self::gp_url()
     
    4242            GP::$router->remove( '/login' );
    4343        }
    44        
    45        
     44
     45
    4646        /**
    4747         * Filter gp_url to return an equivalent login URL on the SSO instead of GP.
    48          * 
     48         *
    4949         * @param string $url
    5050         * @param string $path
     
    6363                }
    6464            }
    65            
     65
    6666            return $url;
    6767        }
    6868    }
    69    
     69
    7070    GP::$plugins->wporg_sso = new GP_WPOrg_SSO();
    7171}
  • 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.