Skip to:
Content

BuddyPress.org

Changeset 12930


Ignore:
Timestamp:
04/29/2021 08:31:02 AM (3 years ago)
Author:
imath
Message:

Member Invites: add missing /* translators: */ inline comments

This commit also:

  • adds some tiny improvements to get along with WP Coding Standards,
  • removes a forgotten PHP notice using the right $args variable instead of the undefined $all_args one in bp_members_invitations_get_registration_welcome_message()
  • removes an extra <hr class="wp-header-end"> into the Manage Invitations Admin screen that was causing admin notices to appear twice.
  • Uses the wpautop() function instead of an inexisting wpautop filter into bp_members_invitations_add_legacy_welcome_message() and bp_members_invitations_add_legacy_registration_disabled_message().

Huge Props dcavins for this awesome new feature!

See #8139

Location:
trunk/src
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/admin/bp-core-admin-optouts.php

    r12911 r12930  
    328328        if ( $usersearch ) {
    329329            $num_results = (int) $bp_optouts_list_table->total_items;
    330             printf( '<p><span class="subtitle">' . esc_html( _n( 'Opt-out with an email address matching &#8220;%s&#8221;', 'Opt-outs with an email address matching &#8220;%s&#8221;', $num_results, 'buddypress' ) ) . '</span></p>', esc_html( $usersearch ) );
     330            printf(
     331                '<p><span class="subtitle">%s</span></p>',
     332                sprintf(
     333                    esc_html(
     334                        /* translators: %s: the searched email. */
     335                        _n( 'Opt-out with an email address matching &#8220;%s&#8221;', 'Opt-outs with an email address matching &#8220;%s&#8221;', $num_results, 'buddypress' )
     336                    ),
     337                    esc_html( $usersearch )
     338                )
     339            );
    331340        }
    332341        ?>
  • trunk/src/bp-groups/bp-groups-template.php

    r12801 r12930  
    60346034            $message = __( 'Viewing 1 invitation', 'buddypress' );
    60356035        } else {
    6036             /* translators: 1: group invite from number. 2: group invite to number. 3: total group invites. */
    6037             $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invitation', 'Viewing %1$s - %2$s of %3$s invitations', $invites_template->total_invite_count, 'buddypress' ), $from_num, $to_num, $total );
     6036            /* translators: 1: Invitations from number. 2: Invitations to number. 3: Total invitations. */
     6037            $message = sprintf( _nx( 'Viewing %1$s - %2$s of %3$s invitation', 'Viewing %1$s - %2$s of %3$s invitations', $invites_template->total_invite_count, 'Group invites pagination', 'buddypress' ), $from_num, $to_num, $total );
    60386038        }
    60396039
  • trunk/src/bp-members/bp-members-filters.php

    r12923 r12930  
    209209        return $message;
    210210    }
     211
    211212    $invite = bp_get_members_invitation_from_request();
    212213    if ( ! $invite->id || ! $invite->invitee_email ) {
     
    220221    if ( $maybe_user ) {
    221222        $message = sprintf(
    222             esc_html__( 'Welcome! You are already a member of this site. Please %1$s to continue. ', 'buddypress' ),
    223             sprintf( '<a href="%1$s">%2$s</a>', esc_url( wp_login_url( bp_get_root_domain() ) ), esc_html__( 'log in', 'buddypress' ) )
     223            /* translators: %s: The log in link `<a href="login_url">log in</a>` */
     224            esc_html__( 'Welcome! You are already a member of this site. Please %s to continue.', 'buddypress' ),
     225            sprintf(
     226                '<a href="%1$s">%2$s</a>',
     227                esc_url( wp_login_url( bp_get_root_domain() ) ),
     228                esc_html__( 'log in', 'buddypress' )
     229            )
    224230        );
     231
    225232    // This user can register!
    226233    } else {
     
    231238            'invite_sent'   => 'sent',
    232239        );
    233         $all_invites = bp_members_invitations_get_invites( $all_args );
    234         $inviters = array();
     240
     241        $all_invites = bp_members_invitations_get_invites( $args );
     242        $inviters    = array();
     243
    235244        foreach ( $all_invites as $inv ) {
    236245            $inviters[] = bp_core_get_user_displayname( $inv->inviter_id );
     
    238247
    239248        if ( ! empty( $inviters ) ) {
    240             $message = sprintf( _n( 'Welcome! You&#8217;ve been invited to join the site by the following user: %s. ', 'Welcome! You&#8217;ve been invited to join the site by the following users: %s. ', count( $inviters ), 'buddypress' ), implode( ', ', $inviters ) );
     249            $message = sprintf(
     250                /* translators: %s: The comma separated list of inviters display names */
     251                _n( 'Welcome! You&#8217;ve been invited to join the site by the following user: %s.', 'Welcome! You&#8217;ve been invited to join the site by the following users: %s.', count( $inviters ), 'buddypress' ),
     252                implode( ', ', $inviters )
     253            );
    241254        } else {
    242255            $message = __( 'Welcome! You&#8217;ve been invited to join the site. ', 'buddypress' );
     
    270283
    271284        if ( ! $maybe_user ) {
    272             $message = __( 'Member registration is allowed by invitation only.', 'buddypress' );
     285            $message_parts = array( esc_html__( 'Member registration is allowed by invitation only.', 'buddypress' ) );
     286
    273287            // Is the user trying to accept an invitation but something is wrong?
    274288            if ( ! empty( $_GET['inv'] ) ) {
    275                 $message .= __( ' It looks like there is a problem with your invitation. Please try again.', 'buddypress' );
     289                $message_parts[] = esc_html__( 'It looks like there is a problem with your invitation. Please try again.', 'buddypress' );
    276290            }
     291
     292            $message = implode( ' ', $message_parts );
    277293        } else if ( 'nouveau' === bp_get_theme_package_id() ) {
    278294            $message = sprintf(
     295                /* translators: 1: The log in link `<a href="login_url">log in</a>`. 2: The lost password link `<a href="lost_password_url">log in</a>` */
    279296                esc_html__( 'Welcome! You are already a member of this site. Please %1$s to continue. If you have forgotten your password, you can %2$s.', 'buddypress' ),
    280                 sprintf( '<a href="%1$s">%2$s</a>', esc_url( wp_login_url( bp_get_root_domain() ) ), esc_html__( 'log in', 'buddypress' ) ),
    281                 sprintf( '<a href="%1$s">%2$s</a>', esc_url( wp_lostpassword_url(  bp_get_root_domain() ) ), esc_html__( 'reset it', 'buddypress' ) )
     297                sprintf(
     298                    '<a href="%1$s">%2$s</a>',
     299                    esc_url( wp_login_url( bp_get_root_domain() ) ),
     300                    esc_html__( 'log in', 'buddypress' )
     301                ),
     302                sprintf(
     303                    '<a href="%1$s">%2$s</a>',
     304                    esc_url( wp_lostpassword_url( bp_get_root_domain() ) ),
     305                    esc_html__( 'reset it', 'buddypress' )
     306                )
    282307            );
    283308        }
    284309    }
     310
    285311    return $message;
    286312}
  • trunk/src/bp-members/bp-members-functions.php

    r12918 r12930  
    34023402 * @return bool True on success, false on failure.
    34033403 */
    3404 function bp_members_invitations_invite_user( $args ) {
    3405     $r = bp_parse_args( $args, array(
    3406         'invitee_email' => '',
    3407         'network_id'    => get_current_network_id(),
    3408         'inviter_id'    => bp_loggedin_user_id(),
    3409         'date_modified' => bp_core_current_time(),
    3410         'content'       => '',
    3411         'send_invite'   => 0
    3412     ), 'community_invite_user' );
     3404function bp_members_invitations_invite_user( $args = array() ) {
     3405    $r = bp_parse_args(
     3406        $args,
     3407        array(
     3408            'invitee_email' => '',
     3409            'network_id'    => get_current_network_id(),
     3410            'inviter_id'    => bp_loggedin_user_id(),
     3411            'date_modified' => bp_core_current_time(),
     3412            'content'       => '',
     3413            'send_invite'   => 0
     3414        ),
     3415        'community_invite_user'
     3416    );
    34133417
    34143418    $inv_args = array(
     
    35373541 * @return bool True if all were deleted.
    35383542 */
    3539 function bp_members_invitations_delete_invites( $args ) {
    3540     $r = bp_parse_args( $args, array(
    3541         'id'            => false,
    3542         'invitee_email' => '',
    3543         'network_id'    => get_current_network_id(),
    3544         'inviter_id'    => null,
    3545         'accepted'      => null,
    3546         'invite_sent'   => null
    3547     ), 'members_invitations_delete_invites' );
     3543function bp_members_invitations_delete_invites( $args = array() ) {
     3544    $r = bp_parse_args(
     3545        $args,
     3546        array(
     3547            'id'            => false,
     3548            'invitee_email' => '',
     3549            'network_id'    => get_current_network_id(),
     3550            'inviter_id'    => null,
     3551            'accepted'      => null,
     3552            'invite_sent'   => null
     3553        ),
     3554        'members_invitations_delete_invites'
     3555    );
    35483556
    35493557    $inv_args = array(
     
    35573565
    35583566    // Find the invitation(s).
    3559     $invites       = bp_members_invitations_get_invites( $inv_args );
    3560     $total_count   = count( $invites );
     3567    $invites     = bp_members_invitations_get_invites( $inv_args );
     3568    $total_count = count( $invites );
    35613569
    35623570    // Loop through, deleting each invitation.
     
    36253633        // Check to make sure the passed hash matches a calculated hash.
    36263634        $maybe_invite = $invites_class->get_by_id( absint( $_GET['inv'] ) );
    3627         $hash = bp_members_invitations_get_hash( $maybe_invite );
     3635        $hash         = bp_members_invitations_get_hash( $maybe_invite );
     3636
    36283637        if ( $_GET['ih'] === $hash ) {
    36293638            $invite = $maybe_invite;
  • trunk/src/bp-members/bp-members-template.php

    r12919 r12930  
    30503050            $pag = __( 'Viewing 1 invitation', 'buddypress' );
    30513051        } else {
    3052             /* translators: 1: notification from number. 2: notification to number. 3: total notifications. */
    3053             $pag = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invitation', 'Viewing %1$s - %2$s of %3$s invitations', $query_loop->total_invitation_count, 'buddypress' ), $from_num, $to_num, $total );
     3052            /* translators: 1: Invitations from number. 2: Invitations to number. 3: Total invitations. */
     3053            $pag = sprintf( _nx( 'Viewing %1$s - %2$s of %3$s invitation', 'Viewing %1$s - %2$s of %3$s invitations', $query_loop->total_invitation_count, 'Community invites pagination', 'buddypress' ), $from_num, $to_num, $total );
    30543054        }
    30553055
  • trunk/src/bp-members/classes/class-bp-members-admin.php

    r12927 r12930  
    30053005            ?>
    30063006
    3007             <hr class="wp-header-end">
    3008 
    30093007            <?php // Display each invitation on its own row. ?>
    30103008            <?php $bp_members_invitations_list_table->views(); ?>
  • trunk/src/bp-members/classes/class-bp-members-invitation-manager.php

    r12917 r12930  
    4545            // Coming soon to a BuddyPress near you!
    4646            return true;
     47
    4748        // Notify the invitee of the invitation.
    4849        } else {
  • trunk/src/bp-members/classes/class-bp-members-invitations-list-table.php

    r12927 r12930  
    6767
    6868        $args = array(
    69             'invite_sent'       => 'all',
    70             'accepted'          => 'all',
    71             'search_terms'      => $search,
    72             'order_by'          => 'date_modified',
    73             'sort_order'        => 'DESC',
    74             'page'              => $paged,
    75             'per_page'          => $per_page,
     69            'invite_sent'  => 'all',
     70            'accepted'     => 'all',
     71            'search_terms' => $search,
     72            'order_by'     => 'date_modified',
     73            'sort_order'   => 'DESC',
     74            'page'         => $paged,
     75            'per_page'     => $per_page,
    7676        );
    7777
     
    123123        ?>
    124124
    125         <h2 class="screen-reader-text"><?php
     125        <h2 class="screen-reader-text">
     126            <?php
    126127            /* translators: accessibility text */
    127128            esc_html_e( 'Filter invitations list', 'buddypress' );
    128         ?></h2>
     129            ?>
     130        </h2>
    129131        <ul class="subsubsub">
    130132            <li class="all">
     
    199201         * @param array $value Array of columns to display.
    200202         */
    201         return apply_filters( 'bp_members_invitations_list_columns', array(
    202             'cb'                       => '<input type="checkbox" />',
    203             'invitee_email'            => __( 'Invitee', 'buddypress' ),
    204             'username'                 => __( 'Inviter', 'buddypress' ),
    205             'inviter_registered_date'  => __( 'Inviter Registered', 'buddypress' ),
    206             'invitation_date_modified' => __( 'Date Modified', 'buddypress' ),
    207             'invitation_sent'          => __( 'Email Sent', 'buddypress' ),
    208             'invitation_accepted'      => __( 'Accepted', 'buddypress' )
    209         ) );
     203        return apply_filters(
     204            'bp_members_invitations_list_columns',
     205            array(
     206                'cb'                       => '<input type="checkbox" />',
     207                'invitee_email'            => __( 'Invitee', 'buddypress' ),
     208                'username'                 => __( 'Inviter', 'buddypress' ),
     209                'inviter_registered_date'  => __( 'Inviter Registered', 'buddypress' ),
     210                'invitation_date_modified' => __( 'Date Modified', 'buddypress' ),
     211                'invitation_sent'          => __( 'Email Sent', 'buddypress' ),
     212                'invitation_accepted'      => __( 'Accepted', 'buddypress' )
     213            )
     214        );
    210215    }
    211216
     
    239244            esc_html_e( 'No invitations found.', 'buddypress' );
    240245        } else {
    241             $link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-settings' ), 'admin.php' ) ) ), esc_html__( 'Edit settings', 'buddypress' ) );
     246            $link = sprintf(
     247                '<a href="%1$s">%2$s</a>',
     248                esc_url( bp_get_admin_url( add_query_arg( array( 'page' => 'bp-settings' ), 'admin.php' ) ) ),
     249                esc_html__( 'Edit settings', 'buddypress' )
     250            );
    242251
    243252            /* translators: %s: url to site settings */
     
    302311     */
    303312    public function column_cb( $invite = null ) {
    304     ?>
    305         <label class="screen-reader-text" for="invitation_<?php echo intval( $invite->id ); ?>"><?php
    306             /* translators: accessibility text */
    307             printf( esc_html__( 'Select invitation: %s', 'buddypress' ), $invite->id );
    308         ?></label>
     313        ?>
     314        <label class="screen-reader-text" for="invitation_<?php echo intval( $invite->id ); ?>">
     315            <?php
     316                /* translators: accessibility text */
     317                printf( esc_html__( 'Select invitation: %s', 'buddypress' ), $invite->id );
     318            ?>
     319        </label>
    309320        <input type="checkbox" id="invitation_<?php echo intval( $invite->id ) ?>" name="invite_ids[]" value="<?php echo esc_attr( $invite->id ) ?>" />
    310321        <?php
  • trunk/src/bp-members/classes/class-bp-members-invitations-template.php

    r12919 r12930  
    163163
    164164        // Parse arguments.
    165         $r = wp_parse_args( $args, array(
    166             'id'                => false,
    167             'user_id'           => false,
    168             'inviter_id'        => false,
    169             'invitee_email'     => false,
    170             'item_id'           => false,
    171             'type'              => 'invite',
    172             'invite_sent'       => 'all',
    173             'accepted'          => 'all',
    174             'search_terms'      => '',
    175             'order_by'          => 'date_modified',
    176             'sort_order'        => 'DESC',
    177             'page'              => 1,
    178             'per_page'          => 25,
    179             'fields'            => 'all',
    180             'page_arg'          => 'ipage',
    181         ) );
     165        $r = wp_parse_args(
     166            $args,
     167            array(
     168                'id'            => false,
     169                'user_id'       => false,
     170                'inviter_id'    => false,
     171                'invitee_email' => false,
     172                'item_id'       => false,
     173                'type'          => 'invite',
     174                'invite_sent'   => 'all',
     175                'accepted'      => 'all',
     176                'search_terms'  => '',
     177                'order_by'      => 'date_modified',
     178                'sort_order'    => 'DESC',
     179                'page'          => 1,
     180                'per_page'      => 25,
     181                'fields'        => 'all',
     182                'page_arg'      => 'ipage',
     183            )
     184        );
    182185
    183186        // Sort order direction.
     
    191194        // Setup variables.
    192195        $this->pag_arg      = sanitize_key( $r['page_arg'] );
    193         $this->pag_page     = bp_sanitize_pagination_arg( $this->pag_arg, $r['page']     );
    194         $this->pag_num      = bp_sanitize_pagination_arg( 'num',          $r['per_page'] );
     196        $this->pag_page     = bp_sanitize_pagination_arg( $this->pag_arg, $r['page'] );
     197        $this->pag_num      = bp_sanitize_pagination_arg( 'num', $r['per_page'] );
    195198        $this->user_id      = $r['user_id'];
    196199        $this->search_terms = $r['search_terms'];
     
    198201        $this->sort_order   = $r['sort_order'];
    199202        $this->query_vars   = array(
    200             'id'                => $r['id'],
    201             'user_id'           => $r['user_id'],
    202             'inviter_id'        => $r['inviter_id'],
    203             'invitee_email'     => $r['invitee_email'],
    204             'item_id'           => $r['item_id'],
    205             'type'              => $r['type'],
    206             'invite_sent'       => $r['invite_sent'],
    207             'accepted'          => $r['accepted'],
    208             'search_terms'      => $this->search_terms,
    209             'order_by'          => $this->order_by,
    210             'sort_order'        => $this->sort_order,
    211             'page'              => $this->pag_page,
    212             'per_page'          => $this->pag_num,
     203            'id'            => $r['id'],
     204            'user_id'       => $r['user_id'],
     205            'inviter_id'    => $r['inviter_id'],
     206            'invitee_email' => $r['invitee_email'],
     207            'item_id'       => $r['item_id'],
     208            'type'          => $r['type'],
     209            'invite_sent'   => $r['invite_sent'],
     210            'accepted'      => $r['accepted'],
     211            'search_terms'  => $this->search_terms,
     212            'order_by'      => $this->order_by,
     213            'sort_order'    => $this->sort_order,
     214            'page'          => $this->pag_page,
     215            'per_page'      => $this->pag_num,
    213216        );
    214217
     
    225228            );
    226229
    227             $this->pag_links = paginate_links( array(
    228                 'base'      => add_query_arg( $this->pag_arg, '%#%' ),
    229                 'format'    => '',
    230                 'total'     => ceil( (int) $this->total_invitation_count / (int) $this->pag_num ),
    231                 'current'   => $this->pag_page,
    232                 'prev_text' => _x( '&larr;', 'Network invitation pagination previous text', 'buddypress' ),
    233                 'next_text' => _x( '&rarr;', 'Network invitation pagination next text',     'buddypress' ),
    234                 'mid_size'  => 1,
    235                 'add_args'  => $add_args,
    236             ) );
     230            $this->pag_links = paginate_links(
     231                array(
     232                    'base'      => add_query_arg( $this->pag_arg, '%#%' ),
     233                    'format'    => '',
     234                    'total'     => ceil( (int) $this->total_invitation_count / (int) $this->pag_num ),
     235                    'current'   => $this->pag_page,
     236                    'prev_text' => _x( '&larr;', 'Network invitation pagination previous text', 'buddypress' ),
     237                    'next_text' => _x( '&rarr;', 'Network invitation pagination next text', 'buddypress' ),
     238                    'mid_size'  => 1,
     239                    'add_args'  => $add_args,
     240                )
     241            );
    237242        }
    238243    }
  • trunk/src/bp-templates/bp-legacy/buddypress-functions.php

    r12922 r12930  
    20212021 *
    20222022 * @since 8.0.0
    2023  *
    2024  * @return string $message The message text.
    20252023 */
    20262024function bp_members_invitations_add_legacy_welcome_message() {
    20272025    $message = bp_members_invitations_get_registration_welcome_message();
     2026
    20282027    if ( $message ) {
    2029         echo apply_filters( 'wpautop', $message );
     2028        // Surround the message with `<p>` tags.
     2029        echo wpautop( $message );
    20302030    }
    20312031}
     
    20382038 *
    20392039 * @since 8.0.0
    2040  *
    2041  * @return string $message The message text.
    20422040 */
    20432041function bp_members_invitations_add_legacy_registration_disabled_message() {
    20442042    $message = bp_members_invitations_get_modified_registration_disabled_message();
     2043
    20452044    if ( $message ) {
    2046         echo apply_filters( 'wpautop', $message );
     2045        // Surround the message with `<p>` tags.
     2046        echo wpautop( $message );
    20472047    }
    20482048}
  • trunk/src/bp-templates/bp-nouveau/buddypress-functions.php

    r12921 r12930  
    696696            $messages['registration-disabled']['message'] = $disallowed_message;
    697697        }
     698
    698699        // Add information about invitations to the welcome block.
    699700        $welcome_message = bp_members_invitations_get_registration_welcome_message();
    700701        if ( $welcome_message ) {
    701             $messages['request-details']['message'] = $welcome_message . $messages['request-details']['message'];
    702         }
     702            $messages['request-details']['message'] = $welcome_message . ' ' . $messages['request-details']['message'];
     703        }
     704
    703705        return $messages;
    704706    }
Note: See TracChangeset for help on using the changeset viewer.