Skip to:
Content

BuddyPress.org

Ticket #7847: 7847.patch

File 7847.patch, 3.2 KB (added by imath, 7 years ago)
  • src/bp-templates/bp-nouveau/buddypress/common/js-templates/messages/index.php

    diff --git src/bp-templates/bp-nouveau/buddypress/common/js-templates/messages/index.php src/bp-templates/bp-nouveau/buddypress/common/js-templates/messages/index.php
    index c5ddaddf9..71f6e520c 100644
     
    272272
    273273        </div>
    274274
    275         <?php bp_nouveau_messages_hook( 'before', 'content' ); ?>
     275        <# if ( data.beforeContent ) { #>
     276                <div class="before-message-content">{{{data.beforeContent}}}</div>
     277        <# } #>
    276278
    277         <div class="message-content"><# print( data.content ) #></div>
     279        <div class="message-content">{{{data.content}}}</div>
    278280
    279         <?php bp_nouveau_messages_hook( 'after', 'content' ); ?>
     281        <# if ( data.afterContent ) { #>
     282                <div class="after-message-content">{{{data.afterContent}}}</div>
     283        <# } #>
    280284
    281285</script>
    282286
  • src/bp-templates/bp-nouveau/includes/messages/ajax.php

    diff --git src/bp-templates/bp-nouveau/includes/messages/ajax.php src/bp-templates/bp-nouveau/includes/messages/ajax.php
    index 16c80a7c8..d833f3573 100644
    function bp_nouveau_ajax_messages_send_reply() { 
    182182                $reply['is_starred'] = array_search( 'unstar', explode( '/', $star_link ) );
    183183        }
    184184
     185        $extra_content = bp_nouveau_messages_catch_hook_content( array(
     186                'beforeContent' => 'bp_before_message_content',
     187                'afterContent'  => 'bp_after_message_content',
     188        ) );
     189
     190        if ( array_filter( $extra_content ) ) {
     191                $reply = array_merge( $reply, $extra_content );
     192        }
     193
    185194        // Clean up the loop.
    186195        bp_thread_messages();
    187196
    function bp_nouveau_ajax_get_thread_messages() { 
    422431                        $thread->messages[ $i ]['star_nonce'] = wp_create_nonce( 'bp-messages-star-' . bp_get_the_thread_message_id() );
    423432                }
    424433
     434                $extra_content = bp_nouveau_messages_catch_hook_content( array(
     435                        'beforeContent' => 'bp_before_message_content',
     436                        'afterContent'  => 'bp_after_message_content',
     437                ) );
     438
     439                if ( array_filter( $extra_content ) ) {
     440                        $thread->messages[ $i ] = array_merge( $thread->messages[ $i ], $extra_content );
     441                }
     442
    425443                $i += 1;
    426444        endwhile;
    427445
  • src/bp-templates/bp-nouveau/includes/messages/functions.php

    diff --git src/bp-templates/bp-nouveau/includes/messages/functions.php src/bp-templates/bp-nouveau/includes/messages/functions.php
    index 191a85381..1784cedb2 100644
    function bp_nouveau_messages_notification_filters() { 
    444444                )
    445445        );
    446446}
     447
     448/**
     449 * Fires Messages Legacy hooks to catch the content and add them
     450 * as extra keys to the JSON Messages UI reply.
     451 *
     452 * @since 3.0.1
     453 *
     454 * @param array $hooks The list of hooks to fire.
     455 * @return array       An associative containing the caught content.
     456 */
     457function bp_nouveau_messages_catch_hook_content( $hooks = array() ) {
     458        $content = array();
     459
     460        ob_start();
     461        foreach ( $hooks as $js_key => $hook ) {
     462                if ( ! has_action( $hook ) ) {
     463                        continue;
     464                }
     465
     466                // Fire the hook.
     467                do_action( $hook );
     468
     469                // Catch the content.
     470                $content[ $js_key ] = ob_get_contents();
     471
     472                // Clean the buffer.
     473                ob_clean();
     474        }
     475        ob_end_clean();
     476
     477        return $content;
     478}