Changeset 12121
- Timestamp:
- 05/25/2018 03:48:20 AM (7 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-functions.php
r12067 r12121 3841 3841 ) ); 3842 3842 } 3843 3844 /** 3845 * Remove script and style tags from a string. 3846 * 3847 * @since 3.0.1 3848 * 3849 * @param string $string The string to strip tags from. 3850 * @return string The stripped tags string. 3851 */ 3852 function bp_strip_script_and_style_tags( $string ) { 3853 return preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string ); 3854 } -
trunk/src/bp-templates/bp-nouveau/buddypress/common/js-templates/messages/index.php
r12115 r12121 273 273 </div> 274 274 275 <?php bp_nouveau_messages_hook( 'before', 'content' ); ?> 276 277 <div class="message-content"><# print( data.content ) #></div> 278 279 <?php bp_nouveau_messages_hook( 'after', 'content' ); ?> 275 <# if ( data.beforeContent ) { #> 276 <div class="bp-messages-hook before-message-content">{{{data.beforeContent}}}</div> 277 <# } #> 278 279 <div class="message-content">{{{data.content}}}</div> 280 281 <# if ( data.afterContent ) { #> 282 <div class="bp-messages-hook after-message-content">{{{data.afterContent}}}</div> 283 <# } #> 280 284 281 285 </script> -
trunk/src/bp-templates/bp-nouveau/includes/messages/ajax.php
r12104 r12121 135 135 } 136 136 137 // Get the message by epretending we're in the message loop.137 // Get the message by pretending we're in the message loop. 138 138 global $thread_template; 139 140 $bp = buddypress(); 141 $reset_action = $bp->current_action; 142 143 // Override bp_current_action(). 144 $bp->current_action = 'view'; 139 145 140 146 bp_thread_has_messages( array( 'thread_id' => (int) $_POST['thread_id'] ) ); … … 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(); 202 203 // Remove the bp_current_action() override. 204 $bp->current_action = $reset_action; 187 205 188 206 wp_send_json_success( array( … … 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 } … … 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 ); 464 465 // Remove the bp_current_action() override. 466 $bp->current_action = $reset_action; 429 467 430 468 wp_send_json_success( $thread ); -
trunk/src/bp-templates/bp-nouveau/includes/messages/functions.php
r12119 r12121 439 439 ); 440 440 } 441 442 /** 443 * Fires Messages Legacy hooks to catch the content and add them 444 * as extra keys to the JSON Messages UI reply. 445 * 446 * @since 3.0.1 447 * 448 * @param array $hooks The list of hooks to fire. 449 * @return array An associative containing the caught content. 450 */ 451 function bp_nouveau_messages_catch_hook_content( $hooks = array() ) { 452 $content = array(); 453 454 ob_start(); 455 foreach ( $hooks as $js_key => $hook ) { 456 if ( ! has_action( $hook ) ) { 457 continue; 458 } 459 460 // Fire the hook. 461 do_action( $hook ); 462 463 // Catch the sanitized content. 464 $content[ $js_key ] = bp_strip_script_and_style_tags( ob_get_contents() ); 465 466 // Clean the buffer. 467 ob_clean(); 468 } 469 ob_end_clean(); 470 471 return $content; 472 }
Note: See TracChangeset
for help on using the changeset viewer.