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 --- src/bp-templates/bp-nouveau/buddypress/common/js-templates/messages/index.php +++ src/bp-templates/bp-nouveau/buddypress/common/js-templates/messages/index.php @@ -272,11 +272,15 @@ - + <# if ( data.beforeContent ) { #> +
+ <# } #> - + - + <# if ( data.afterContent ) { #> + + <# } #> diff --git src/bp-templates/bp-nouveau/includes/messages/ajax.php src/bp-templates/bp-nouveau/includes/messages/ajax.php index 16c80a7c8..d833f3573 100644 --- src/bp-templates/bp-nouveau/includes/messages/ajax.php +++ src/bp-templates/bp-nouveau/includes/messages/ajax.php @@ -182,6 +182,15 @@ function bp_nouveau_ajax_messages_send_reply() { $reply['is_starred'] = array_search( 'unstar', explode( '/', $star_link ) ); } + $extra_content = bp_nouveau_messages_catch_hook_content( array( + 'beforeContent' => 'bp_before_message_content', + 'afterContent' => 'bp_after_message_content', + ) ); + + if ( array_filter( $extra_content ) ) { + $reply = array_merge( $reply, $extra_content ); + } + // Clean up the loop. bp_thread_messages(); @@ -422,6 +431,15 @@ function bp_nouveau_ajax_get_thread_messages() { $thread->messages[ $i ]['star_nonce'] = wp_create_nonce( 'bp-messages-star-' . bp_get_the_thread_message_id() ); } + $extra_content = bp_nouveau_messages_catch_hook_content( array( + 'beforeContent' => 'bp_before_message_content', + 'afterContent' => 'bp_after_message_content', + ) ); + + if ( array_filter( $extra_content ) ) { + $thread->messages[ $i ] = array_merge( $thread->messages[ $i ], $extra_content ); + } + $i += 1; endwhile; diff --git src/bp-templates/bp-nouveau/includes/messages/functions.php src/bp-templates/bp-nouveau/includes/messages/functions.php index 191a85381..1784cedb2 100644 --- src/bp-templates/bp-nouveau/includes/messages/functions.php +++ src/bp-templates/bp-nouveau/includes/messages/functions.php @@ -444,3 +444,35 @@ function bp_nouveau_messages_notification_filters() { ) ); } + +/** + * Fires Messages Legacy hooks to catch the content and add them + * as extra keys to the JSON Messages UI reply. + * + * @since 3.0.1 + * + * @param array $hooks The list of hooks to fire. + * @return array An associative containing the caught content. + */ +function bp_nouveau_messages_catch_hook_content( $hooks = array() ) { + $content = array(); + + ob_start(); + foreach ( $hooks as $js_key => $hook ) { + if ( ! has_action( $hook ) ) { + continue; + } + + // Fire the hook. + do_action( $hook ); + + // Catch the content. + $content[ $js_key ] = ob_get_contents(); + + // Clean the buffer. + ob_clean(); + } + ob_end_clean(); + + return $content; +}