Changeset 4470
- Timestamp:
- 12/04/2016 05:54:55 PM (8 years ago)
- Location:
- sites/trunk
- Files:
-
- 14 added
- 7 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/common/includes/wporg-sso/wp-plugin.php
r4413 r4470 22 22 'lostpassword' => '/lostpassword', 23 23 'oauth' => '/oauth', 24 'register-profile' => '/register/profile/(?P<profile_user>[^/]+)/(?P<profile_nonce>[^/]+)', 25 'register-confirm' => '/register/confirm/(?P<confirm_user>[^/]+)/(?P<confirm_key>[^/]+)', 26 'register' => '/register', 24 27 ); 28 29 /** 30 * Holds the route hit in `valid_sso_paths` 31 * @var bool|string 32 */ 33 static $matched_route = false; 34 35 /** 36 * Holds any matched route params. 37 * @var array 38 */ 39 static $matched_route_params = array(); 25 40 26 41 /** … … 70 85 */ 71 86 public function disable_password_reset_for_blocked_users( $allow, $user_id ) { 72 if ( ! defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) ) {87 if ( ! $allow || ! defined( 'WPORG_SUPPORT_FORUMS_BLOGID' ) ) { 73 88 return $allow; 74 89 } … … 76 91 $user = new WP_User( $user_id, '', WPORG_SUPPORT_FORUMS_BLOGID ); 77 92 $is_blocked = ! empty( $user->allcaps['bbp_blocked'] ); 93 78 94 return ! $is_blocked; 79 95 } … … 150 166 if ( ! preg_match( '!/wp-login\.php$!', $this->script ) ) { 151 167 // ... but not on its login screen. 152 if ( preg_match( '!^(' . implode( '|', $this->valid_sso_paths ) . ')([/?]{1,2}.*)?$!', $_SERVER['REQUEST_URI'] ) ) { 153 // If we're on the path of interest 154 168 self::$matched_route = false; 169 self::$matched_route_params = array(); 170 foreach ( $this->valid_sso_paths as $route => $regex ) { 171 if ( preg_match( '!^' . $regex . '(?:[/?]{1,2}.*)?$!', $_SERVER['REQUEST_URI'], $matches ) ) { 172 self::$matched_route = $route; 173 self::$matched_route_params = $matches; 174 break; 175 } 176 } 177 178 // If we're on the path of interest 179 if ( self::$matched_route ) { 155 180 // Add a custom filter others can apply (theme, etc). 156 181 add_filter( 'is_valid_wporg_sso_path' , '__return_true' ); … … 187 212 } 188 213 } 214 } elseif ( ( is_admin() && is_super_admin() ) || preg_match( '!^/wp-json(/?$|/.+)!i', $_SERVER['REQUEST_URI'] ) ) { 215 // Do nothing, allow access to wp-admin and wp-json on login.wordpress.org 189 216 } elseif ( is_user_logged_in() ) { 190 217 // Logged in catch all, before last fallback -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions.php
r4417 r4470 5 5 * @package wporg-login 6 6 */ 7 8 require __DIR__ . '/functions-restapi.php'; 9 require __DIR__ . '/functions-registration.php'; 7 10 8 11 /** … … 26 29 */ 27 30 function wporg_login_body_class( $classes ) { 28 // $classes[] = 'wporg-responsive'; 29 $classes[] = 'wporg-login'; 31 if ( WP_WPOrg_SSO::$matched_route ) { 32 $classes[] = 'route-' . WP_WPOrg_SSO::$matched_route; 33 } 34 35 // Remove the 404 class.. 36 if ( false !== ( $pos = array_search( 'error404', $classes ) ) ) { 37 unset( $classes[ $pos ] ); 38 } 30 39 return $classes; 31 40 } … … 44 53 */ 45 54 function wporg_login_replace_css() { 46 wp_enqueue_style( 'wporg-login', get_template_directory_uri() . '/stylesheets/login.css', array( 'login', 'dashicons', 'l10n' ), 2.3);55 wp_enqueue_style( 'wporg-login', get_template_directory_uri() . '/stylesheets/login.css', array( 'login', 'dashicons', 'l10n' ), '20161204' ); 47 56 } 48 57 add_action( 'login_init', 'wporg_login_replace_css' ); … … 53 62 function wporg_login_scripts() { 54 63 $script_debug = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG; 55 $suffix = $script_debug ? '' : '.min';56 64 57 65 // Concatenates core scripts when possible. … … 61 69 62 70 wp_enqueue_style( 'wporg-normalize', get_template_directory_uri() . '/stylesheets/normalize.css', 3 ); 63 wp_enqueue_style( 'wporg-login', get_template_directory_uri() . '/stylesheets/login.css', array( 'login', 'dashicons', 'l10n' ), 2.3 ); 64 65 // No emoji support needed. 66 remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); 67 remove_action( 'wp_print_styles', 'print_emoji_styles' ); 68 69 // No Jetpack styles needed. 70 add_filter( 'jetpack_implode_frontend_css', '__return_false' ); 71 72 // No embeds needed. 73 remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); 74 remove_action( 'wp_head', 'wp_oembed_add_host_js' ); 71 wp_enqueue_style( 'wporg-login', get_template_directory_uri() . '/stylesheets/login.css', array( 'login', 'dashicons', 'l10n' ), '20161204' ); 75 72 } 76 73 add_action( 'wp_enqueue_scripts', 'wporg_login_scripts' ); 74 75 function wporg_login_register_scripts() { 76 wp_register_script( 'recaptcha-api', 'https://www.google.com/recaptcha/api.js', array(), '2' ); 77 78 wp_register_script( 'wporg-registration', get_template_directory_uri() . "/js/registration.js", array( 'recaptcha-api', 'jquery' ), '20161114' ); 79 wp_localize_script( 'wporg-registration', 'wporg_registration', array( 80 'rest_url' => esc_url_raw( rest_url( "wporg/v1" ) ) 81 ) ); 82 } 83 add_action( 'init', 'wporg_login_register_scripts' ); 84 85 /** 86 * Avoid sending a 404 header but send a 200 with nocache headers. 87 */ 88 function wporg_login_pre_handle_404( $false, $wp_query ) { 89 $wp_query->set_404(); // Set the query as 404 to avoid things running thinking it's a real page 90 status_header( 200 ); // but return a 200 91 return true; 92 } 93 add_filter( 'pre_handle_404', 'wporg_login_pre_handle_404', 10, 2 ); 94 95 /** 96 * Filters the page template to load wporg-login/$route.php. 97 * 98 * @param array $templates The templates WordPress intends to load. 99 * @return array The templates the theme intends to use. 100 */ 101 function wporg_login_filter_templates( $templates ) { 102 $route = WP_WPOrg_SSO::$matched_route; 103 104 if ( ! $route || 'root' === $route ) { 105 $route = 'login'; 106 } 107 108 return array( "{$route}.php", 'index.php' ); 109 } 110 add_filter( 'index_template_hierarchy', 'wporg_login_filter_templates' ); 111 112 // No emoji support needed. 113 remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); 114 remove_action( 'wp_print_styles', 'print_emoji_styles' ); 115 116 // No Jetpack styles needed. 117 add_filter( 'jetpack_implode_frontend_css', '__return_false' ); 118 119 // No embeds needed. 120 remove_action( 'wp_head', 'wp_oembed_add_discovery_links' ); 121 remove_action( 'wp_head', 'wp_oembed_add_host_js' ); 122 remove_action( 'rest_api_init', 'wp_oembed_register_route' ); 123 124 // Don't perform any WP_Query queries on this site.. 125 add_filter( 'posts_request', '__return_empty_string' ); 126 // Don't attempt to do canonical lookups.. 127 remove_filter( 'template_redirect', 'redirect_canonical' ); 128 // There's no need to edit the site.. 129 remove_action( 'wp_head', 'wlwmanifest_link' ); 130 remove_action( 'wp_head', 'rsd_link' ); 131 // We don't need all the rest routes either.. 132 remove_action( 'rest_api_init', 'create_initial_rest_routes', 99 ); 133 134 // Don't need all the wp-admin specific user metas on user create/update 135 add_filter( 'insert_user_meta', '__return_empty_array', 1 ); -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/header.php
r2492 r4470 16 16 <?php wp_head(); ?> 17 17 </head> 18 <body class="wp-core-ui login">18 <body <?php body_class( 'wp-core-ui login' ); ?>> 19 19 20 20 <div id="login"> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/index.php
r4119 r4470 6 6 */ 7 7 8 get_header(); 8 // Silence is Golden. If we're at this point, then no template exists for the given request yet. 9 wp_safe_redirect( '/' ); 9 10 10 /**11 * Test if the path we're on is one that we use, depending on if it12 * has a partial or not, or load the 404 partial as fallback.13 *14 * Note that the path is first validated in WP_WPOrg_SSO::redirect_all_login_or_signup_to_sso().15 * @see https://meta.trac.wordpress.org/browser/sites/trunk/common/includes/wporg-sso/wp-plugin.php16 */17 18 if ( apply_filters( 'is_valid_wporg_sso_path', false ) && preg_match( '!^(/[^/\?]*)([/\?]{1,2}.*)?$!', $_SERVER['REQUEST_URI'], $matches ) ) {19 $screen = '/' === $matches[1] ? 'login' : preg_replace( '/[^a-z0-9-]/', '', $matches[1] );20 } else {21 $screen = '404';22 }23 24 $partials_dir = __DIR__ . '/partials/';25 $partial = $partials_dir . $screen . '.php';26 27 if ( file_exists( $partial ) ) {28 if ( ! headers_sent() ) {29 status_header( 200 );30 }31 require_once( $partial );32 } else {33 if ( ! headers_sent() ) {34 status_header( 404 );35 }36 require_once( $partials_dir . '404.php');37 }38 39 get_footer(); -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/stylesheets/login.css
r2579 r4470 256 256 -webkit-box-shadow: none !important; 257 257 box-shadow: none !important; 258 overflow: visible; 258 259 } 259 260 … … 320 321 } 321 322 323 324 body.route-register, 325 body.route-register-profile, 326 body.route-register-confirm { 327 padding-top: 105px; 328 height: auto; 329 } 330 331 body.route-register #login, 332 body.route-register-profile #login, 333 body.route-register-confirm #login { 334 width: 365px; 335 } 336 337 body.route-register input.input, 338 body.route-register-profile input.input, 339 body.route-register-confirm input.input { 340 margin-bottom: 0; 341 } 342 body.route-register #login form p, 343 body.route-register-profile #login form p, 344 body.route-register-confirm #login form p { 345 margin-bottom: 16px; 346 } 347 348 body.login form input.input::-webkit-input-placeholder { /* Chrome/Opera/Safari */ 349 opacity: 0.5; 350 } 351 body.login form input.input::-moz-placeholder { /* Firefox 19+ */ 352 opacity: 0.5; 353 } 354 body.login form input.input:-ms-input-placeholder { /* IE 10+ */ 355 opacity: 0.5; 356 } 357 body.login form input.input:-moz-placeholder { /* Firefox 18- */ 358 opacity: 0.5; 359 } 360 body.login form input.error { 361 background-color: #FAE5E8; 362 border: 3px solid #D42A41; 363 } 364 body.login form input.good { 365 border-color: #83c373; 366 } 367 368 body.route-register #login .message.error, 369 body.route-register-profile #login .message.error, 370 body.route-register-confirm #login .message.error { 371 border-left-color: #dc3232; 372 margin-bottom: auto !important; 373 margin-left: -24px; 374 padding-left: 24px; 375 padding-right: 0; 376 } 377 body.route-register .message.error .avatar { 378 float: left; 379 border-radius: 50%; 380 margin-right: 1em; 381 } 382 383 form .login-mailinglist label { 384 font-size: 12px; 385 line-height: 1; 386 cursor: pointer; 387 } 388 322 389 .oauth { 323 390 width: 100%;
Note: See TracChangeset
for help on using the changeset viewer.