Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/05/2018 06:21:08 AM (9 years ago)
Author:
imath
Message:

BP Nouveau: use a JS Template for the feedbacks of the Messages UI

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/messages/ajax.php

    r12053 r12058  
    108108function bp_nouveau_ajax_messages_send_reply() {
    109109        $response = array(
    110                 'feedback' => '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'There was a problem sending your reply. Please try again.', 'buddypress' ) . '</p></div>',
     110                'feedback' => __( 'There was a problem sending your reply. Please try again.', 'buddypress' ),
    111111                'type'     => 'error',
    112112        );
    … …  
    187187        wp_send_json_success( array(
    188188                'messages' => array( $reply ),
    189                 'feedback' => '<div class="bp-feedback success"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'Your reply was sent successfully', 'buddypress' ) . '</p></div>',
     189                'feedback' => __( 'Your reply was sent successfully', 'buddypress' ),
    190190                'type'     => 'success',
    191191        ) );
    … …  
    200200        if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'bp_nouveau_messages' ) ) {
    201201                wp_send_json_error( array(
    202                         'feedback' => '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'Unauthorized request.', 'buddypress' ) . '</p></div>',
     202                        'feedback' => __( 'Unauthorized request.', 'buddypress' ),
    203203                        'type'     => 'error'
    204204                ) );
    … …  
    215215        if ( ! bp_has_message_threads( bp_ajax_querystring( 'messages' ) ) ) {
    216216                wp_send_json_error( array(
    217                         'feedback' => '<div class="bp-feedback info"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'Sorry, no messages were found.', 'buddypress' ) . '</p></div>',
     217                        'feedback' => __( 'Sorry, no messages were found.', 'buddypress' ),
    218218                        'type'     => 'info'
    219219                ) );
    … …  
    342342        if ( empty( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'bp_nouveau_messages' ) ) {
    343343                wp_send_json_error( array(
    344                         'feedback' => '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'Unauthorized request.', 'buddypress' ) . '</p></div>',
     344                        'feedback' => __( 'Unauthorized request.', 'buddypress' ),
    345345                        'type'     => 'error'
    346346                ) );
    … …  
    348348
    349349        $response = array(
    350                 'feedback' => '<div class="bp-feedback info"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'Sorry, no messages were found.', 'buddypress' ) . '</p></div>',
     350                'feedback' => __( 'Sorry, no messages were found.', 'buddypress' ),
    351351                'type'     => 'info'
    352352        );
    … …  
    435435function bp_nouveau_ajax_delete_thread_messages() {
    436436        $response = array(
    437                 'feedback' => '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'There was a problem deleting your message(s). Please try again.', 'buddypress' ) . '</p></div>',
     437                'feedback' => __( 'There was a problem deleting your message(s). Please try again.', 'buddypress' ),
    438438                'type'     => 'error',
    439439        );
    … …  
    458458
    459459        wp_send_json_success( array(
    460                 'feedback' => '<div class="bp-feedback info"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'Message(s) deleted', 'buddypress' ) . '</p></div>',
     460                'feedback' => __( 'Message(s) deleted', 'buddypress' ),
    461461                'type'     => 'success',
    462462        ) );
    … …  
    480480
    481481        $response = array(
    482                 'feedback' => '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>' . esc_html( $error_message ) . '</p></div>',
     482                'feedback' => esc_html( $error_message ),
    483483                'type'     => 'error',
    484484        );
    … …  
    556556
    557557        wp_send_json_success( array(
    558                 'feedback' => '<div class="bp-feedback info"><span class="bp-icon" aria-hidden="true"></span><p>' . esc_html( $success_message ) . '</p></div>',
     558                'feedback' => esc_html( $success_message ),
    559559                'type'     => 'success',
    560560                'messages' => $messages,
    … …  
    579579        if ( 'unread' === $action ) {
    580580                $response = array(
    581                         'feedback' => '<div class="bp-feedback error"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'There was a problem marking your message(s) as unread. Please try again.', 'buddypress' ) . '</p></div>',
     581                        'feedback' => __( 'There was a problem marking your message(s) as unread. Please try again.', 'buddypress' ),
    582582                        'type'     => 'error',
    583583                );
    … …  
    597597
    598598        if ( 'unread' === $action ) {
    599                 $response['feedback'] = '<div class="bp-feedback info"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'Message(s) marked as unread.', 'buddypress' ) . '</p></div>';
     599                $response['feedback'] = __( 'Message(s) marked as unread.', 'buddypress' );
    600600        } else {
    601                 $response['feedback'] = '<div class="bp-feedback info"><span class="bp-icon" aria-hidden="true"></span><p>' . __( 'Message(s) marked as read.', 'buddypress' ) . '</p></div>';
     601                $response['feedback'] = __( 'Message(s) marked as read.', 'buddypress' );
    602602        }
    603603
Note: See TracChangeset for help on using the changeset viewer.