Making WordPress.org

Changeset 14459


Ignore:
Timestamp:
06/05/2025 10:17:20 AM (5 months ago)
Author:
dd32
Message:

Plugin Directory: Plugin Transfer: You can only transfer to users who have plugin management capabilities, which requires that the committer has 2FA setup.

Don't allow users to attempt to transfer to a user for whom the transfer will fail to.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/template-tags.php

    r14390 r14459  
    651651    echo '<div class="plugin-notice notice notice-warning notice-alt"><p>' . __( '<strong>Warning:</strong> Transferring a plugin is intended to be <em>permanent</em>. There is no way to get plugin ownership back without contacting the plugin team.', 'wporg-plugins' ) . '</p></div>';
    652652
    653     $users = [];
     653    $disabled_users = [];
     654    $users          = [];
    654655    foreach ( Tools::get_plugin_committers( $post->post_name ) as $user_login ) {
    655656        $user = get_user_by( 'login', $user_login );
    656657        if ( $user->ID != get_current_user_id() ) {
    657658            $users[] = $user;
     659
     660            // Mark users as disabled if they don't have 2FA enabled, as plugins can't be transferred to users without 2FA.
     661            if ( class_exists( 'Two_Factor_Core' ) && ! \Two_Factor_Core::is_user_using_two_factor( $user->ID ) ) {
     662                $disabled_users[ $user->ID ] = true;
     663            }
    658664        }
    659665    }
     
    661667        echo '<div class="plugin-notice notice notice-error notice-alt"><p>' . __( 'To transfer a plugin, you must first add the new owner as a committer.', 'wporg-plugins' ) . '</p></div>';
    662668        return;
     669    }
     670
     671    // Users must have 2FA enabled to be able to transfer a plugin.
     672    if ( $disabled_users ) {
     673        echo '<div class="plugin-notice notice notice-info notice-alt"><p>' . __( 'Only users with Two-Factor authentication enabled can be selected.', 'wporg-plugins' ) . '</p></div>';
    663674    }
    664675
     
    669680    foreach ( $users as $user ) {
    670681        printf(
    671             '<option value="%d">%s</option>' . "\n",
     682            '<option value="%d" %s>%s</option>' . "\n",
    672683            esc_attr( $user->ID ),
     684            disabled( isset( $disabled_users[ $user->ID ] ), true, false ),
    673685            esc_html( $user->display_name . ' (' . $user->user_login . ')' )
    674686        );
    675687    }
    676688    echo '</select></p>';
     689
    677690    // Translators: %s is the plugin name, as defined by the plugin itself.
    678691    echo '<p class="wp-block-button is-small"><input class="wp-block-button__link" type="submit" value="' . esc_attr( sprintf( __( 'Please transfer %s.', 'wporg-plugins' ), get_the_title() ) ) . '" /></p>';
Note: See TracChangeset for help on using the changeset viewer.