Making WordPress.org

Changeset 8385


Ignore:
Timestamp:
03/01/2019 09:52:15 PM (6 years ago)
Author:
ocean90
Message:

Rosetta Roles: Remove translation editor badges only when all editor roles have been removed.

Fixes #4232.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/global.wordpress.org/public_html/wp-content/mu-plugins/roles/rosetta-roles.php

    r7050 r8385  
    511511     */
    512512    public function update_wporg_profile_badge( $user ) {
     513        global $wpdb;
     514
    513515        $action = 'translation_editor_added' === current_filter() ? 'add' : 'remove';
     516
     517        // Remove badge only when all roles have been removed.
     518        if ( 'remove' === $action ) {
     519            $count = (int) $wpdb->get_var(
     520                $wpdb->prepare(
     521                    "SELECT COUNT(*) FROM {$wpdb->wporg_translation_editors}
     522                    WHERE `user_id` = %d AND `locale` != 'all-locales'",
     523                    $user->ID
     524                )
     525            );
     526
     527            if ( 0 !== $count ) {
     528                return;
     529            }
     530        }
    514531
    515532        $this->notify_profiles_wporg_translation_editor_update( $user->ID, $action );
Note: See TracChangeset for help on using the changeset viewer.