Making WordPress.org


Ignore:
Timestamp:
12/13/2022 06:31:15 PM (2 years ago)
Author:
iandunn
Message:

Support: Create Edit Account screen.

This commits the parts of https://github.com/WordPress/wordpress.org/pull/114 that don't affect production users, and can therefore be deployed now. Adding a link to this screen and removing the email/password settings from the built-in Edit screen will needs to wait until the WPORG Two Factor UI is done.

The rewrite rule was added in r19711-dotorg.

See https://github.com/WordPress/wporg-two-factor/issues/26

File:
1 edited

Legend:

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

    r11945 r12321  
    800800}
    801801add_filter( 'bbp_after_theme_compat_reset_post_parse_args', 'wporg_support_set_is_single_on_single_replies' );
     802
     803/**
     804 * Add query vars
     805 */
     806function wporg_add_query_vars( array $vars ) : array {
     807    // For https://wordpress.org/support/users/foo/edit/account/.
     808    // See `site-support.php` for the rewrite rule.
     809    $vars[] = 'edit_account';
     810
     811    return $vars;
     812}
     813add_filter( 'query_vars', 'wporg_add_query_vars' );
     814
     815/**
     816 * Detect if the current request is for editing a bbPress Account
     817 *
     818 * The Account screen is a custom modification where the security settings are moved to a separate screen.
     819 */
     820function wporg_bbp_is_single_user_edit_account() : bool {
     821    global $wp_query;
     822
     823    return $wp_query->get( 'bbp_user', false ) && $wp_query->get( 'edit_account', false );
     824}
     825
     826/**
     827 * Determine if the current request is to show a profile.
     828 *
     829 * This is necessary because `bbp_parse_query()` assumes that the current page is a Profile if it doesn't match
     830 * any of the other built-in pages, rather than checking that the current page actually is a request for a profile.
     831 */
     832function wporg_is_single_user_profile( bool $is_single_user_profile ) : bool {
     833    // True for https://wordpress.org/support/users/foo/ but not https://wordpress.org/support/users/foo/edit/account/.
     834    // See `site-support.php` for the rewrite rule.
     835    if ( $is_single_user_profile ) {
     836            $is_single_user_profile = ! wporg_bbp_is_single_user_edit_account();
     837    }
     838
     839    return $is_single_user_profile;
     840}
     841add_filter( 'bbp_is_single_user_profile', 'wporg_is_single_user_profile' );
    802842
    803843
Note: See TracChangeset for help on using the changeset viewer.