Changeset 3166 for sites/trunk/common/includes/wporg-sso/wp-plugin.php
- Timestamp:
- 05/18/2016 09:26:41 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/common/includes/wporg-sso/wp-plugin.php
r2465 r3166 2 2 /** 3 3 * WordPress-specific WPORG SSO: redirects all WP login and registration screens to our SSO ones. 4 * 4 * 5 5 * @uses WPOrg_SSO (class-wporg-sso.php) 6 6 * @author stephdau … … 23 23 'oauth' => '/oauth', 24 24 ); 25 25 26 26 /** 27 27 * Constructor: add our action(s)/filter(s) … … 36 36 } 37 37 } 38 38 39 39 /** 40 40 * Redirect all attempts to get to a WP login or signup to the SSO ones, or to a safe redirect location. 41 41 42 42 * @example add_action( 'init', array( &$wporg_sso, 'redirect_all_wp_login_or_signup_to_sso' ) ); 43 * 43 * 44 44 * @note Also handles accesses to lost password forms, since wp-login too. 45 45 */ … … 49 49 return; 50 50 } 51 51 52 52 $redirect_req = $this->_get_safer_redirect_to(); 53 53 54 54 // Add our host to the list of allowed ones. 55 55 add_filter( 'allowed_redirect_hosts', array( &$this, 'add_allowed_redirect_host' ) ); 56 56 57 57 // Replace the lost password URL by our own 58 58 add_filter( 'lostpassword_url', array( &$this, 'lostpassword_url' ), 10, 2 ); 59 59 60 60 if ( preg_match( '!/wp-signup\.php$!', $this->script ) ) { 61 61 // If we're on any WP signup screen, redirect to the SSO host one,respecting the user's redirect_to request 62 62 $this->_safe_redirect( add_query_arg( 'redirect_to', urlencode( $redirect_req ), $this->sso_signup_url ) ); 63 63 64 64 } elseif ( self::SSO_HOST !== $this->host ) { 65 65 // If we're not on the SSO host … … 67 67 // If on a WP login screen... 68 68 $redirect_to_sso_login = $this->sso_login_url; 69 69 70 70 // Pass thru the requested action, loggedout, if any 71 71 if ( ! empty( $_GET ) ) { 72 72 $redirect_to_sso_login = add_query_arg( $_GET, $redirect_to_sso_login ); 73 73 } 74 74 75 75 // Pay extra attention to the post-process redirect_to 76 76 $redirect_to_sso_login = add_query_arg( 'redirect_to', urlencode( $redirect_req ), $redirect_to_sso_login ); 77 77 78 78 // And actually redirect to the SSO login 79 79 $this->_safe_redirect( $redirect_to_sso_login ); 80 80 81 81 } else { 82 82 // Otherwise, filter the login_url to point to the SSO 83 83 add_action( 'login_url', array( &$this, 'login_url' ), 10, 2 ); 84 84 } 85 85 86 86 } else if ( self::SSO_HOST === $this->host ) { 87 87 // If on the SSO host … … 90 90 if ( preg_match( '!^(' . implode( '|', $this->valid_sso_paths ) . ')([/?]{1,2}.*)?$!', $_SERVER['REQUEST_URI'] ) ) { 91 91 // If we're on the path of interest 92 92 93 93 // Add a custom filter others can apply (theme, etc). 94 94 add_filter( 'is_valid_wporg_sso_path' , '__return_true' ); 95 95 96 96 if ( preg_match( '!^/(\?.*)?$!', $_SERVER['REQUEST_URI'] ) ) { 97 97 // If at host root (/) … … 133 133 } 134 134 } 135 135 136 136 /** 137 137 * Modifies the network_site_url on login.wordpress.org's login screen to make sure all forms and links 138 138 * go to the SSO host, not wordpress.org 139 * 139 * 140 140 * @param string $url 141 141 * @param string $path 142 142 * @param string $scheme 143 * @return string 144 * 143 * @return string 144 * 145 145 * @example add_action( 'network_site_url', array( &$this, 'login_network_site_url' ), 10, 3 ); 146 146 */ … … 149 149 $url = preg_replace( '!^(https?://)[^/]+(/.+)$!' , '\1'.self::SSO_HOST.'\2', $url ); 150 150 } 151 151 152 152 return $url; 153 153 } 154 154 155 155 156 156 /** 157 157 * Filters the defaults captions and options for the login form 158 * 158 * 159 159 * @param array $defaults 160 160 * @return array … … 168 168 return $defaults; 169 169 } 170 170 171 171 /** 172 172 * Filters the default lost password URL and returns our custom one instead. 173 * 173 * 174 174 * @param string $lostpassword_url 175 175 * @param string $redirect … … 178 178 return home_url( $this->valid_sso_paths['lostpassword'] . '/?redirect_to=' . $redirect ); 179 179 } 180 180 181 181 /** 182 182 * Redirects the user to her/his (support) profile. … … 194 194 } 195 195 } 196 196 197 197 new WP_WPOrg_SSO(); 198 198 }
Note: See TracChangeset
for help on using the changeset viewer.