Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/05/2018 06:48:40 AM (2 years ago)
Author:
imath
Message:

BP Nouveau: use a JS Template for the Group Invites UI feedbacks

Using a JS template avoids to transport common HTML tags inside the Ajax replies.

See #7794

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-nouveau/includes/groups/ajax.php

    r12024 r12060  
    254254
    255255    $response = array(
    256         'feedback' => bp_nouveau_message_markup_wrapper( esc_html__( 'There was a problem performing this action. Please try again.', 'buddypress' ), 'error' ),
     256        'feedback' => __( 'There was a problem performing this action. Please try again.', 'buddypress' ),
    257257        'type'     => 'error',
    258258    );
     
    282282
    283283    $bp->groups->invites_scope = 'members';
    284     $message = bp_nouveau_message_markup_wrapper( __( 'Select members to invite by clicking the + button. Once you\'ve made your selection, use the "Send Invites" nav item to continue.', 'buddypress' ), 'info' );
     284    $message = __( 'Select members to invite by clicking the + button. Once you\'ve made your selection, use the "Send Invites" nav item to continue.', 'buddypress' );
    285285
    286286    if ( 'friends' === $request['scope'] ) {
    287287        $request['user_id'] = bp_loggedin_user_id();
    288288        $bp->groups->invites_scope = 'friends';
    289         $message = bp_nouveau_message_markup_wrapper( __( 'Select friends to invite by clicking the + button. Once you\'ve made your selection, use the "Send Invites" nav item to continue.', 'buddypress' ), 'info' );
     289        $message = __( 'Select friends to invite by clicking the + button. Once you\'ve made your selection, use the "Send Invites" nav item to continue.', 'buddypress' );
    290290    }
    291291
     
    294294        if ( ! bp_group_has_invites( array( 'user_id' => 'any' ) ) ) {
    295295            wp_send_json_error( array(
    296                 'feedback' => bp_nouveau_message_markup_wrapper( __( 'No pending invites found.', 'buddypress' ), 'info' ),
     296                'feedback' => __( 'No pending invites found.', 'buddypress' ),
    297297                'type'     => 'info',
    298298            ) );
     
    301301        $request['is_confirmed'] = false;
    302302        $bp->groups->invites_scope = 'invited';
    303         $message = bp_nouveau_message_markup_wrapper( __( 'You can view all the group\'s pending invites from this screen.', 'buddypress' ), 'info' );
     303        $message = __( 'You can view all the group\'s pending invites from this screen.', 'buddypress' );
    304304    }
    305305
     
    308308    if ( empty( $potential_invites->users ) ) {
    309309        $error = array(
    310             'feedback' => bp_nouveau_message_markup_wrapper( __( 'No members were found. Try another filter.', 'buddypress' ), 'info' ),
     310            'feedback' => __( 'No members were found. Try another filter.', 'buddypress' ),
    311311            'type'     => 'info',
    312312        );
     
    314314        if ( 'friends' === $bp->groups->invites_scope ) {
    315315            $error = array(
    316                 'feedback' => bp_nouveau_message_markup_wrapper( __( 'All your friends are already members of this group, or have already received an invite to join this group, or have requested to join it.', 'buddypress' ), 'info' ),
     316                'feedback' => __( 'All your friends are already members of this group, or have already received an invite to join this group, or have requested to join it.', 'buddypress' ),
    317317                'type'     => 'info',
    318318            );
     
    320320            if ( 0 === (int) bp_get_total_friend_count( bp_loggedin_user_id() ) ) {
    321321                $error = array(
    322                     'feedback' => bp_nouveau_message_markup_wrapper( __( 'You have no friends!', 'buddypress' ), 'info' ),
     322                    'feedback' => __( 'You have no friends!', 'buddypress' ),
    323323                    'type'     => 'info',
    324324                );
     
    349349
    350350    $response = array(
    351         'feedback' => bp_nouveau_message_markup_wrapper( __( 'Invites could not be sent. Please try again.', 'buddypress' ), 'error' ),
     351        'feedback' => __( 'Invites could not be sent. Please try again.', 'buddypress' ),
     352        'type'     => 'error',
    352353    );
    353354
    354355    // Verify nonce
    355356    if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'groups_send_invites' ) ) {
    356         wp_send_json_error(
    357             array(
    358                 'feedback' => bp_nouveau_message_markup_wrapper( __( 'Invites could not be sent. Please try again.', 'buddypress' ), 'error' ),
    359                 'type'     => 'error',
    360             )
    361         );
     357        wp_send_json_error( $response );
    362358    }
    363359
     
    369365
    370366    if ( ! bp_groups_user_can_send_invites( $group_id ) ) {
    371         wp_send_json_error(
    372             array(
    373                 'feedback' => bp_nouveau_message_markup_wrapper( __( 'You are not allowed to send invites for this group.', 'buddypress' ), 'error' ),
    374                 'type'     => 'error',
    375             )
    376         );
     367        $response['feedback'] = __( 'You are not allowed to send invites for this group.', 'buddypress' );
     368        wp_send_json_error( $response );
    377369    }
    378370
     
    416408        wp_send_json_error(
    417409            array(
    418                 'feedback' => bp_nouveau_message_markup_wrapper( esc_html( $error_message ), 'error' ),
     410                'feedback' => $error_message,
    419411                'users'    => $errors,
    420412                'type'     => 'error',
     
    425417    wp_send_json_success(
    426418        array(
    427             'feedback' => bp_nouveau_message_markup_wrapper( __( 'Invites sent.', 'buddypress' ), 'success' ),
     419            'feedback' => __( 'Invites sent.', 'buddypress' ),
     420            'type'     => 'success',
    428421        )
    429422    );
     
    441434        wp_send_json_error(
    442435            array(
    443                 'feedback' => bp_nouveau_message_markup_wrapper( __( 'Invites could not be removed. Please try again.', 'buddypress' ), 'error' ),
     436                'feedback' => __( 'Invites could not be removed. Please try again.', 'buddypress' ),
     437                'type'     => 'error',
    444438            )
    445439        );
     
    449443        wp_send_json_error(
    450444            array(
    451                 'feedback' => bp_nouveau_message_markup_wrapper( __( 'Too late! The user is already a member of the group.', 'buddypress' ), 'warning' ),
     445                'feedback' => __( 'Too late! The user is already a member of the group.', 'buddypress' ),
     446                'type'     => 'warning',
    452447                'code'     => 1,
    453448            )
     
    459454        wp_send_json_error(
    460455            array(
    461                 'feedback' => bp_nouveau_message_markup_wrapper( __( 'Invite could not be removed successfully.', 'buddypress' ), 'error' ),
     456                'feedback' => __( 'Invite could not be removed successfully.', 'buddypress' ),
     457                'type'     => 'error',
    462458                'code'     => 0,
    463459            )
     
    467463    wp_send_json_success(
    468464        array(
    469             'feedback'    => bp_nouveau_message_markup_wrapper( __( 'No more pending invites for the group.', 'buddypress' ), 'info' ),
     465            'feedback'    => __( 'No more pending invites for the group.', 'buddypress' ),
     466            'type'        => 'info',
    470467            'has_invites' => bp_group_has_invites( array( 'user_id' => 'any' ) ),
    471468        )
Note: See TracChangeset for help on using the changeset viewer.