Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/28/2018 05:37:38 PM (8 years ago)
Author:
imath
Message:

Messages: catch Legacy hooks to customize the Active conversation box.

In order to preserve in the BP Nouveau Messages UI the level of PHP customization that developers are used to get in Legacy using do_action hooks, The content generated for the following hooks will be caught during Ajax requests and added as new properties of their JSON replies:

  • bp_before_message_meta
  • bp_after_message_meta
  • bp_messages_inbox_list_item
  • bp_messages_thread_options

About the bp_messages_inbox_list_item hook: as the Messages UI of BP Nouveau, unlike Legacy, is not using a table tag to display the list of messages received/starred/sent. All extra actions about messages into these loop views are done within the Active conversation box (eg: star/unstar). To inject the content of this specific hook, we are adding a table element under the message content preview as the expected output is a td tag.

Fixes #7851 (Branch 3.0)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/src/bp-templates/bp-nouveau/includes/messages/ajax.php

    r12134 r12142  
    190190
    191191    $extra_content = bp_nouveau_messages_catch_hook_content( array(
     192        'beforeMeta'    => 'bp_before_message_meta',
     193        'afterMeta'     => 'bp_after_message_meta',
    192194        'beforeContent' => 'bp_before_message_content',
    193195        'afterContent'  => 'bp_after_message_content',
     
    263265
    264266    while ( bp_message_threads() ) : bp_message_thread();
     267        $last_message_id = (int) $messages_template->thread->last_message_id;
     268
    265269        $threads->threads[ $i ] = array(
    266270            'id'            => bp_get_message_thread_id(),
    267             'message_id'    => (int) $messages_template->thread->last_message_id,
     271            'message_id'    => (int) $last_message_id,
    268272            'subject'       => html_entity_decode( bp_get_message_thread_subject() ),
    269273            'excerpt'       => html_entity_decode( bp_get_message_thread_excerpt() ),
     
    314318
    315319            // Defaults to last
    316             $sm_id = (int) $messages_template->thread->last_message_id;
     320            $sm_id = $last_message_id;
    317321
    318322            if ( $threads->threads[ $i ]['is_starred'] ) {
     
    322326            $threads->threads[ $i ]['star_nonce'] = wp_create_nonce( 'bp-messages-star-' . $sm_id );
    323327            $threads->threads[ $i ]['starred_id'] = $sm_id;
     328        }
     329
     330        $thread_extra_content = bp_nouveau_messages_catch_hook_content( array(
     331            'inboxListItem' => 'bp_messages_inbox_list_item',
     332            'threadOptions' => 'bp_messages_thread_options',
     333        ) );
     334
     335        if ( array_filter( $thread_extra_content ) ) {
     336            $threads->threads[ $i ] = array_merge( $threads->threads[ $i ], $thread_extra_content );
    324337        }
    325338
     
    472485
    473486        $extra_content = bp_nouveau_messages_catch_hook_content( array(
     487            'beforeMeta'    => 'bp_before_message_meta',
     488            'afterMeta'     => 'bp_after_message_meta',
    474489            'beforeContent' => 'bp_before_message_content',
    475490            'afterContent'  => 'bp_after_message_content',
Note: See TracChangeset for help on using the changeset viewer.