Changeset 2828 for branches/plugin/bbp-admin/bbp-admin.php
- Timestamp:
- 02/03/2011 08:27:09 PM (15 years ago)
- File:
-
- 1 edited
-
branches/plugin/bbp-admin/bbp-admin.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-admin/bbp-admin.php
r2818 r2828 120 120 add_action( 'bbp_admin_init', array( $this, 'toggle_reply' ) ); 121 121 add_action( 'admin_notices', array( $this, 'toggle_reply_notice' ) ); 122 123 // Anonymous metabox actions 124 add_action( 'add_meta_boxes', array( $this, 'anonymous_metabox' ) ); 125 add_action( 'save_post', array( $this, 'anonymous_metabox_save' ) ); 122 126 } 123 127 … … 359 363 * @uses bbp_privatize_forum() To mark the forum as private 360 364 * @uses bbp_publicize_forum() To mark the forum as public 361 * @uses do_action() Calls 'bbp_forum_attributes_metabox_save' 365 * @uses do_action() Calls 'bbp_forum_attributes_metabox_save' with the 366 * forum id 362 367 * @return int Forum id 363 368 */ … … 398 403 } 399 404 400 do_action( 'bbp_forum_attributes_metabox_save' );405 do_action( 'bbp_forum_attributes_metabox_save', $forum_id ); 401 406 402 407 return $forum_id; … … 434 439 * @uses current_user_can() To check if the current user is capable of 435 440 * editing the topic 436 * @uses do_action() Calls 'bbp_topic_attributes_metabox_save' 441 * @uses do_action() Calls 'bbp_topic_attributes_metabox_save' with the 442 * topic id and parent id 437 443 * @return int Parent id 438 444 */ … … 445 451 446 452 // OK, we're authenticated: we need to find and save the data 447 $parent_id = isset( $ _topic['parent_id'] ) ? $_topic['parent_id'] : 0;448 449 do_action( 'bbp_topic_attributes_metabox_save' );453 $parent_id = isset( $topic['parent_id'] ) ? $topic['parent_id'] : 0; 454 455 do_action( 'bbp_topic_attributes_metabox_save', $topic_id, $parent_id ); 450 456 451 457 return $parent_id; … … 483 489 * @uses current_user_can() To check if the current user is capable of 484 490 * editing the reply 485 * @uses do_action() Calls 'bbp_reply_attributes_metabox_save' 491 * @uses do_action() Calls 'bbp_reply_attributes_metabox_save' with the 492 * reply id and parent id 486 493 * @return int Parent id 487 494 */ … … 494 501 495 502 // OK, we're authenticated: we need to find and save the data 496 $parent_id = isset( $ _reply['parent_id'] ) ? $_reply['parent_id'] : 0;497 498 do_action( 'bbp_reply_attributes_metabox_save' );503 $parent_id = isset( $reply['parent_id'] ) ? $reply['parent_id'] : 0; 504 505 do_action( 'bbp_reply_attributes_metabox_save', $reply_id, $parent_id ); 499 506 500 507 return $parent_id; 508 } 509 510 /** 511 * Add the anonymous user info metabox 512 * 513 * Allows editing of information about an anonymous user 514 * 515 * @since bbPress (r) 516 * 517 * @uses bbp_get_topic() To get the topic 518 * @uses bbp_get_reply() To get the reply 519 * @uses bbp_is_topic_anonymous() To check if the topic is by an 520 * anonymous user 521 * @uses bbp_is_reply_anonymous() To check if the reply is by an 522 * anonymous user 523 * @uses add_meta_box() To add the metabox 524 * @uses do_action() Calls 'bbp_anonymous_metabox' with the topic/reply 525 * id 526 */ 527 function anonymous_metabox() { 528 global $bbp; 529 530 $post_id = (int) $_GET['post']; 531 532 if ( $topic = bbp_get_topic( $post_id ) ) 533 $topic_id = $topic->ID; 534 elseif ( $reply = bbp_get_reply( $post_id ) ) 535 $reply_id = $reply->ID; 536 else 537 return; 538 539 if ( !empty( $topic_id ) && !bbp_is_topic_anonymous( $topic_id ) ) 540 return; 541 542 if ( !empty( $reply_id ) && !bbp_is_reply_anonymous( $reply_id ) ) 543 return; 544 545 add_meta_box( 546 'bbp_anonymous_metabox', 547 __( 'Anonymous User Information', 'bbpress' ), 548 'bbp_anonymous_metabox', 549 !empty( $topic_id ) ? $bbp->topic_id : $bbp->reply_id, 550 'side', 551 'high' 552 ); 553 554 do_action( 'bbp_anonymous_metabox', $post_id ); 555 } 556 557 /** 558 * Save the anonymous user information for the topic/reply 559 * 560 * @since bbPress (r) 561 * 562 * @param int $post_id Topic or reply id 563 * @uses bbp_get_topic() To get the topic 564 * @uses bbp_get_reply() To get the reply 565 * @uses current_user_can() To check if the current user can edit the 566 * topic or reply 567 * @uses bbp_is_topic_anonymous() To check if the topic is by an 568 * anonymous user 569 * @uses bbp_is_reply_anonymous() To check if the reply is by an 570 * anonymous user 571 * @uses bbp_filter_anonymous_post_data() To filter the anonymous user 572 * data 573 * @uses update_post_meta() To update the anonymous user data 574 * @uses do_action() Calls 'bbp_anonymous_metabox_save' with the topic/ 575 * reply id and anonymous data 576 * @return int Topic or reply id 577 */ 578 function anonymous_metabox_save( $post_id ) { 579 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 580 return $post_id; 581 582 if ( $topic = bbp_get_topic( $post_id ) ) 583 $topic_id = $topic->ID; 584 elseif ( $reply = bbp_get_reply( $post_id ) ) 585 $reply_id = $reply->ID; 586 else 587 return $post_id; 588 589 if ( !empty( $topic_id ) && ( !current_user_can( 'edit_topic', $topic_id ) || !bbp_is_topic_anonymous( $topic_id ) ) ) 590 return $topic_id; 591 592 if ( !empty( $reply_id ) && ( !current_user_can( 'edit_reply', $reply_id ) || !bbp_is_reply_anonymous( $reply_id ) ) ) 593 return $reply_id; 594 595 $anonymous_data = bbp_filter_anonymous_post_data(); 596 597 update_post_meta( $post_id, '_bbp_anonymous_name', $anonymous_data['bbp_anonymous_name'] ); 598 update_post_meta( $post_id, '_bbp_anonymous_email', $anonymous_data['bbp_anonymous_email'] ); 599 update_post_meta( $post_id, '_bbp_anonymous_website', $anonymous_data['bbp_anonymous_website'] ); 600 601 do_action( 'bbp_anonymous_metabox_save', $post_id, $anonymous_data ); 602 603 return $post_id; 501 604 } 502 605 … … 1934 2037 1935 2038 <p> 1936 <strong><?php _e( ' Topic', 'bbpress' ); ?></strong>2039 <strong><?php _e( 'Parent Topic', 'bbpress' ); ?></strong> 1937 2040 </p> 1938 2041 … … 1945 2048 1946 2049 do_action( 'bbp_reply_metabox' ); 2050 } 2051 2052 /** 2053 * Anonymous user information metabox 2054 * 2055 * @since bbPress (r) 2056 * 2057 * @uses get_post_meta() To get the anonymous user information 2058 */ 2059 function bbp_anonymous_metabox () { 2060 global $post, $bbp; ?> 2061 2062 <p> 2063 <strong><?php _e( 'Name', 'bbpress' ); ?></strong> 2064 </p> 2065 2066 <p> 2067 <label class="screen-reader-text" for="bbp_anonymous_name"><?php _e( 'Name', 'bbpress' ); ?></label> 2068 <input type="text" id="bbp_anonymous_name" name="bbp_anonymous_name" value="<?php echo get_post_meta( $post->ID, '_bbp_anonymous_name', true ); ?>" size="38" /> 2069 </p> 2070 2071 <p> 2072 <strong><?php _e( 'Email', 'bbpress' ); ?></strong> 2073 </p> 2074 2075 <p> 2076 <label class="screen-reader-text" for="bbp_anonymous_email"><?php _e( 'Email', 'bbpress' ); ?></label> 2077 <input type="text" id="bbp_anonymous_email" name="bbp_anonymous_email" value="<?php echo get_post_meta( $post->ID, '_bbp_anonymous_email', true ); ?>" size="38" /> 2078 </p> 2079 2080 <p> 2081 <strong><?php _e( 'Website', 'bbpress' ); ?></strong> 2082 </p> 2083 2084 <p> 2085 <label class="screen-reader-text" for="bbp_anonymous_website"><?php _e( 'Website', 'bbpress' ); ?></label> 2086 <input type="text" id="bbp_anonymous_website" name="bbp_anonymous_website" value="<?php echo get_post_meta( $post->ID, '_bbp_anonymous_website', true ); ?>" size="38" /> 2087 </p> 2088 2089 <p> 2090 <strong><?php _e( 'IP Address', 'bbpress' ); ?></strong> 2091 </p> 2092 2093 <p> 2094 <label class="screen-reader-text" for="bbp_anonymous_ip_address"><?php _e( 'IP Address', 'bbpress' ); ?></label> 2095 <input type="text" id="bbp_anonymous_ip_address" name="bbp_anonymous_ip_address" value="<?php echo get_post_meta( $post->ID, '_bbp_anonymous_ip', true ); ?>" size="38" disabled="disabled" /> 2096 </p> 2097 2098 <?php 1947 2099 } 1948 2100
Note: See TracChangeset
for help on using the changeset viewer.