Changeset 5712
- Timestamp:
- 07/23/2017 01:26:46 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-user-notes.php
r5671 r5712 63 63 64 64 // Make sure our nonces are in order. 65 if ( ! bbp_verify_nonce_request( sprintf( 'wporg-bbp-add-user-note_%d _%d', $user_id, $post_id ) ) ) {65 if ( ! bbp_verify_nonce_request( sprintf( 'wporg-bbp-add-user-note_%d', $user_id ) ) ) { 66 66 return; 67 67 } … … 290 290 291 291 /** 292 * Retrieves user notes output for a particular user. 293 * 294 * Replaces '###POST_ID###' and '###POST_PERMALINK###' placeholders 295 * in the note adding/editing form with the current post ID and permalink. 296 * 297 * @param int $user_id User ID. Defaults to the current post author. 298 * @return string User notes output. 299 */ 300 public function get_user_notes_html( $user_id ) { 301 $user_notes = $this->get_user_notes( $user_id )->html; 302 303 if ( ! bbp_is_single_user_profile() ) { 304 $post_id = get_the_ID(); 305 } else { 306 $post_id = 0; 307 } 308 309 $post_permalink = $this->get_user_note_post_permalink( $post_id ); 310 311 $user_notes = strtr( $user_notes, array( 312 '###POST_ID###' => esc_attr( $post_id ), 313 '###POST_PERMALINK###' => esc_url( $post_permalink ), 314 ) ); 315 316 return $user_notes; 317 } 318 319 /** 292 320 * Retrieves permalink to the post associated with a note. 293 321 * … … 301 329 */ 302 330 public function get_user_note_post_permalink( $post_id = 0, $user_id = 0, $site_id = 0 ) { 303 switch_to_blog( $site_id ); 331 if ( $site_id ) { 332 switch_to_blog( $site_id ); 333 } 304 334 305 335 $post_type = $post_id ? get_post_type( $post_id ) : ''; … … 321 351 } 322 352 323 restore_current_blog(); 353 if ( $site_id ) { 354 restore_current_blog(); 355 } 324 356 325 357 return $permalink; … … 334 366 if ( ! $user_id ) { 335 367 $user_id = get_the_author_meta( 'ID' ); 336 }337 338 if ( ! bbp_is_single_user_profile() ) {339 $post_id = get_the_ID();340 } else {341 $post_id = 0;342 368 } 343 369 … … 354 380 $button_label = esc_html__( 'Add your note', 'wporg-forums' ); 355 381 } 356 357 $post_permalink = $this->get_user_note_post_permalink( $post_id );358 382 ?> 359 <form action=" <?php echo esc_url( $post_permalink ); ?>" method="post" class="wporg-bbp-add-user-note">360 <?php wp_nonce_field( sprintf( 'wporg-bbp-add-user-note_%d _%d', $user_id, $post_id ) ); ?>383 <form action="###POST_PERMALINK###" method="post" class="wporg-bbp-add-user-note"> 384 <?php wp_nonce_field( sprintf( 'wporg-bbp-add-user-note_%d', $user_id ) ); ?> 361 385 <input type="hidden" name="action" value="wporg_bbp_add_user_note"> 362 386 <input type="hidden" name="user_id" value="<?php echo esc_attr( $user_id ); ?>"> 363 <input type="hidden" name="post_id" value=" <?php echo esc_attr( $post_id ); ?>">387 <input type="hidden" name="post_id" value="###POST_ID###"> 364 388 <?php if ( $edit_note ) : ?> 365 389 <input type="hidden" name="note_id" value="<?php echo esc_attr( $note_id ); ?>"> … … 436 460 ?> 437 461 <div class="<?php echo esc_attr( $class ); ?>" id="wporg-bbp-user-notes-<?php echo esc_attr( $post_id ); ?>"> 438 <?php echo $this->get_user_notes ( $user_id )->html; ?>462 <?php echo $this->get_user_notes_html( $user_id ); ?> 439 463 </div> 440 464 <?php … … 464 488 <h2 id="user-notes" class="entry-title"><?php esc_html_e( 'User Notes', 'wporg-forums' ); ?></h2> 465 489 <div class="bbp-user-section"> 466 <?php echo $this->get_user_notes ( $user_id )->html; ?>490 <?php echo $this->get_user_notes_html( $user_id ); ?> 467 491 </div> 468 492 </div>
Note: See TracChangeset
for help on using the changeset viewer.