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..34844c983 100644
|
|
|
272 | 272 | |
273 | 273 | </div> |
274 | 274 | |
275 | | <?php bp_nouveau_messages_hook( 'before', 'content' ); ?> |
| 275 | <# if ( data.beforeContent ) { #> |
| 276 | <div class="bp-messages-hook before-message-content">{{{data.beforeContent}}}</div> |
| 277 | <# } #> |
276 | 278 | |
277 | | <div class="message-content"><# print( data.content ) #></div> |
| 279 | <div class="message-content">{{{data.content}}}</div> |
278 | 280 | |
279 | | <?php bp_nouveau_messages_hook( 'after', 'content' ); ?> |
| 281 | <# if ( data.afterContent ) { #> |
| 282 | <div class="bp-messages-hook after-message-content">{{{data.afterContent}}}</div> |
| 283 | <# } #> |
280 | 284 | |
281 | 285 | </script> |
282 | 286 | |
diff --git src/bp-templates/bp-nouveau/includes/messages/ajax.php src/bp-templates/bp-nouveau/includes/messages/ajax.php
index 16c80a7c8..f49175016 100644
|
|
function bp_nouveau_ajax_messages_send_reply() { |
134 | 134 | wp_send_json_error( $response ); |
135 | 135 | } |
136 | 136 | |
137 | | // Get the message bye pretending we're in the message loop. |
| 137 | // Get the message by pretending we're in the message loop. |
138 | 138 | global $thread_template; |
139 | 139 | |
| 140 | $bp = buddypress(); |
| 141 | $reset_action = $bp->current_action; |
| 142 | |
| 143 | // Override bp_current_action(). |
| 144 | $bp->current_action = 'view'; |
| 145 | |
140 | 146 | bp_thread_has_messages( array( 'thread_id' => (int) $_POST['thread_id'] ) ); |
141 | 147 | |
142 | 148 | // Set the current message to the 2nd last. |
… |
… |
function bp_nouveau_ajax_messages_send_reply() { |
182 | 188 | $reply['is_starred'] = array_search( 'unstar', explode( '/', $star_link ) ); |
183 | 189 | } |
184 | 190 | |
| 191 | $extra_content = bp_nouveau_messages_catch_hook_content( array( |
| 192 | 'beforeContent' => 'bp_before_message_content', |
| 193 | 'afterContent' => 'bp_after_message_content', |
| 194 | ) ); |
| 195 | |
| 196 | if ( array_filter( $extra_content ) ) { |
| 197 | $reply = array_merge( $reply, $extra_content ); |
| 198 | } |
| 199 | |
185 | 200 | // Clean up the loop. |
186 | 201 | bp_thread_messages(); |
187 | 202 | |
| 203 | // Remove the bp_current_action() override. |
| 204 | $bp->current_action = $reset_action; |
| 205 | |
188 | 206 | wp_send_json_success( array( |
189 | 207 | 'messages' => array( $reply ), |
190 | 208 | 'feedback' => __( 'Your reply was sent successfully', 'buddypress' ), |
… |
… |
function bp_nouveau_ajax_get_thread_messages() { |
356 | 374 | wp_send_json_error( $response ); |
357 | 375 | } |
358 | 376 | |
359 | | $thread_id = (int) $_POST['id']; |
| 377 | $thread_id = (int) $_POST['id']; |
| 378 | $bp = buddypress(); |
| 379 | $reset_action = $bp->current_action; |
| 380 | |
| 381 | // Override bp_current_action(). |
| 382 | $bp->current_action = 'view'; |
360 | 383 | |
361 | 384 | // Simulate the loop. |
362 | 385 | if ( ! bp_thread_has_messages( array( 'thread_id' => $thread_id ) ) ) { |
| 386 | // Remove the bp_current_action() override. |
| 387 | $bp->current_action = $reset_action; |
| 388 | |
363 | 389 | wp_send_json_error( $response ); |
364 | 390 | } |
365 | 391 | |
… |
… |
function bp_nouveau_ajax_get_thread_messages() { |
422 | 448 | $thread->messages[ $i ]['star_nonce'] = wp_create_nonce( 'bp-messages-star-' . bp_get_the_thread_message_id() ); |
423 | 449 | } |
424 | 450 | |
| 451 | $extra_content = bp_nouveau_messages_catch_hook_content( array( |
| 452 | 'beforeContent' => 'bp_before_message_content', |
| 453 | 'afterContent' => 'bp_after_message_content', |
| 454 | ) ); |
| 455 | |
| 456 | if ( array_filter( $extra_content ) ) { |
| 457 | $thread->messages[ $i ] = array_merge( $thread->messages[ $i ], $extra_content ); |
| 458 | } |
| 459 | |
425 | 460 | $i += 1; |
426 | 461 | endwhile; |
427 | 462 | |
428 | 463 | $thread->messages = array_filter( $thread->messages ); |
429 | 464 | |
| 465 | // Remove the bp_current_action() override. |
| 466 | $bp->current_action = $reset_action; |
| 467 | |
430 | 468 | wp_send_json_success( $thread ); |
431 | 469 | } |
432 | 470 | |
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() { |
444 | 444 | ) |
445 | 445 | ); |
446 | 446 | } |
| 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 | */ |
| 457 | function 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 | } |