Making WordPress.org

Changeset 1422


Ignore:
Timestamp:
03/19/2015 04:53:16 PM (9 years ago)
Author:
ocean90
Message:

Rosetta: Add a "Promote to Translation Editor" action link to users list table.

see #741.

File:
1 edited

Legend:

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

    r1421 r1422  
    4747        add_action( 'user_row_actions', array( $this, 'user_row_action_role_editor' ), 10, 2 );
    4848        add_action( 'admin_menu', array( $this, 'register_translation_editors_page' ) );
     49        add_filter( 'user_row_actions', array( $this, 'promote_user_to_translation_editor' ), 10, 2 );
     50    }
     51
     52    /**
     53     * Adds an action link to promote an user to a translation editor.
     54     *
     55     * @param array   $actions     An array of action links to be displayed.
     56     * @param WP_User $user_object WP_User object for the currently-listed user.
     57     * @return array $actions An array of action links to be displayed.
     58     */
     59    public function promote_user_to_translation_editor( $actions, $user ) {
     60        if ( in_array( $this->translation_editor_role, $user->roles ) || ! current_user_can( 'promote_users' ) ) {
     61            return $actions;
     62        }
     63
     64        $url = menu_page_url( 'translation-editors', false );
     65        $url = add_query_arg( array(
     66            'action' => 'add-translation-editor',
     67            'user'   => $user->ID,
     68        ), $url );
     69        $url = wp_nonce_url( $url, 'add-translation-editor', '_nonce_add-translation-editor' );
     70        $actions['translation-editor'] = sprintf(
     71            '<a href="%s">%s</a>',
     72            esc_url( $url ),
     73            __( 'Promote to Translation Editor', 'rosetta' )
     74        );
     75
     76        return $actions;
    4977    }
    5078
     
    237265                    $user_details = null;
    238266                    $user = wp_unslash( $_REQUEST['user'] );
    239                     if ( false !== strpos( $user_email, '@' ) ) {
     267                    if ( false !== strpos( $user, '@' ) ) {
    240268                        $user_details = get_user_by( 'email', $user );
     269                    } elseif ( is_numeric( $user ) ) {
     270                        $user_details = get_user_by( 'id', $user );
    241271                    } else {
    242272                        $user_details = get_user_by( 'login', $user );
Note: See TracChangeset for help on using the changeset viewer.