WordPress.org

Making WordPress.org

Changeset 10845


Ignore:
Timestamp:
03/25/2021 08:52:21 AM (8 weeks ago)
Author:
dd32
Message:

Login: Add the 'WordPress.org is ...' text via a action/filter instead of hard-coding it into the login template.

This allows for the text to be displayed when landing on the wp-login.php page as well.

See #5590.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions.php

    r10830 r10845  
    418418}
    419419add_filter( 'login_title', 'wporg_login_title' );
     420
     421function wporg_login_wporg_is_starpress( $redirect_to = '' ) {
     422
     423    $message = '';
     424
     425    $from = 'wordpress.org';
     426    if ( $redirect_to ) {
     427        $from = $redirect_to;
     428    } elseif ( !empty( $_REQUEST['from'] ) ) {
     429        $from = $_REQUEST['from'];
     430    } elseif ( !empty( $_REQUEST['redirect_to'] ) ) {
     431        $from = $_REQUEST['redirect_to'];
     432    }
     433
     434    if ( false !== stripos( $from, 'buddypress.org' ) ) {
     435        $message .= '<strong>' . __( 'BuddyPress is part of WordPress.org', 'wporg' ) . '</strong><br>';
     436        $message .= __( 'Log in to your WordPress.org account to contribute to BuddyPress, or get help in the support forums.', 'wporg' );
     437   
     438    } elseif ( false !== stripos( $from, 'bbpress.org' ) ) {
     439        $message .= '<strong>' . __( 'bbPress is part of WordPress.org', 'wporg' ) . '</strong><br>';
     440        $message .= __( 'Log in to your WordPress.org account to contribute to bbPress, or get help in the support forums.', 'wporg' );
     441   
     442    } elseif ( false !== stripos( $from, 'wordcamp.org' ) ) {
     443        $message .= '<strong>' . __( 'WordCamp is part of WordPress.org', 'wporg' ) . '</strong><br>';
     444        $message .= __( 'Log in to your WordPress.org account to contribute to WordCamps and meetups around the globe.', 'wporg' );
     445   
     446    } else {
     447        $message .= __( 'Log in to your WordPress.org account to contribute to WordPress, get help in the support forum, or rate and review themes and plugins.', 'wporg' );
     448    }
     449
     450    return $message;
     451}
     452
     453// This is the action in the top of `wp_login_form()`, which is not used on wp-login.php, see below.
     454function wporg_login_form_top( $message ) {
     455    $message .= '<p class="intro">' . wporg_login_wporg_is_starpress() . '</p>';
     456
     457    return $message;
     458}
     459add_filter( 'login_form_top', 'wporg_login_form_top' );
     460
     461// This is the login messages, which is displayed on wp-login.php, which does not use wp_login_form() or it's actions.
     462function wporg_login_message( $errors, $redirect_to ) {
     463    $errors->add(
     464        'pre_login_message',
     465        ( isset( $_GET['loggedout'] ) ? '<br>' : '' ) .
     466            wporg_login_wporg_is_starpress( $redirect_to ),
     467        'message' // This is not an error..
     468    );
     469
     470    return $errors;
     471}
     472add_filter( 'wp_login_errors', 'wporg_login_message', 10, 2 );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/login.php

    r9944 r10845  
    77
    88get_header();
    9 
    10 $from = $_GET['from'] ?? 'wordpress.org';
    119?>
    12 <p class="intro"><?php
    13 if ( false !== stripos( $from, 'buddypress.org' ) ) {
    14     echo '<strong>' . __( 'BuddyPress is part of WordPress.org', 'wporg' ) . '</strong><br>';
    15     _e( 'Log in to your WordPress.org account to contribute to BuddyPress, or get help in the support forums.', 'wporg' );
    16 
    17 } elseif ( false !== stripos( $from, 'bbpress.org' ) ) {
    18     echo '<strong>' . __( 'bbPress is part of WordPress.org', 'wporg' ) . '</strong><br>';
    19     _e( 'Log in to your WordPress.org account to contribute to bbPress, or get help in the support forums.', 'wporg' );
    20 
    21 } elseif ( false !== stripos( $from, 'wordcamp.org' ) ) {
    22     echo '<strong>' . __( 'WordCamp is part of WordPress.org', 'wporg' ) . '</strong><br>';
    23     _e( 'Log in to your WordPress.org account to contribute to WordCamps and meetups around the globe.', 'wporg' );
    24 
    25 } else {
    26     _e( 'Log in to your WordPress.org account to contribute to WordPress, get help in the support forum, or rate and review themes and plugins.', 'wporg' );
    27 }
    28 ?>
    29 </p>
    3010
    3111<?php wp_login_form(); ?>
Note: See TracChangeset for help on using the changeset viewer.