Changeset 5837
- Timestamp:
- 07/15/2015 05:29:22 PM (10 years ago)
- Location:
- trunk/src/includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/forums/functions.php
r5829 r5837 129 129 $forum_parent_id = $forum_author = 0; 130 130 $forum_title = $forum_content = ''; 131 $terms = array( bbp_get_forum_mod_tax_id() => array() ); 131 132 132 133 /** Forum Author **********************************************************/ … … 237 238 if ( ! bbp_check_for_moderation( $anonymous_data, $forum_author, $forum_title, $forum_content ) ) { 238 239 $post_status = bbp_get_pending_status_id(); 240 } 241 242 /** Forum Mods ************************************************************/ 243 244 if ( bbp_allow_forum_mods() && ! empty( $_POST['bbp_forum_mods'] ) ) { 245 246 // Escape tag input 247 $terms = sanitize_text_field( $_POST['bbp_forum_mods'] ); 248 249 // Explode by comma 250 if ( strstr( $terms, ',' ) ) { 251 $terms = explode( ',', $terms ); 252 } 253 254 // Add forum_mod ID as main key 255 $terms = array( bbp_get_forum_mod_tax_id() => $terms ); 239 256 } 240 257 … … 259 276 'post_status' => $post_status, 260 277 'post_type' => bbp_get_forum_post_type(), 278 'tax_input' => $terms, 261 279 'comment_status' => 'closed' 262 280 ) ); … … 495 513 } 496 514 515 /** Forum Mods ************************************************************/ 516 517 // Either replace terms 518 if ( bbp_allow_forum_mods() && current_user_can( 'assign_forum_mods' ) && ! empty( $_POST['bbp_forum_mods'] ) ) { 519 520 // Escape tag input 521 $terms = sanitize_text_field( $_POST['bbp_forum_mods'] ); 522 523 // Explode by comma 524 if ( strstr( $terms, ',' ) ) { 525 $terms = explode( ',', $terms ); 526 } 527 528 // Add forum mod ID as main key 529 $terms = array( bbp_get_forum_mod_tax_id() => $terms ); 530 531 // ...or remove them. 532 } elseif ( isset( $_POST['bbp_forum_mods'] ) ) { 533 $terms = array( bbp_get_forum_mod_tax_id() => array() ); 534 535 // Existing terms 536 } else { 537 $terms = array( bbp_get_forum_mod_tax_id() => explode( ',', bbp_get_forum_mod_names( $forum_id, ',' ) ) ); 538 } 539 497 540 /** Additional Actions (Before Save) **************************************/ 498 541 … … 1661 1704 } 1662 1705 1706 /** Forum Mods ****************************************************************/ 1707 1708 /** 1709 * Get forum mods for a specific forum ID 1710 * 1711 * @since bbPress (r5836) 1712 * 1713 * @param int $forum_id 1714 * 1715 * @return string 1716 */ 1717 function bbp_get_forum_mods( $forum_id = 0 ) { 1718 $forum_id = bbp_get_forum_id( $forum_id ); 1719 $terms = (array) get_the_terms( $forum_id, bbp_get_forum_mod_tax_id() ); 1720 $forum_mods = array_filter( $terms ); 1721 1722 return apply_filters( 'bbp_get_forum_mods', $forum_mods, $forum_id ); 1723 } 1724 1725 /** 1726 * Get forum mods for a specific forum ID 1727 * 1728 * @since bbPress (r4165) 1729 * 1730 * @param int $forum_id 1731 * @param string $sep 1732 * 1733 * @return string 1734 */ 1735 function bbp_get_forum_mod_names( $forum_id = 0, $sep = ', ' ) { 1736 $forum_mods = bbp_get_topic_tags( $forum_id ); 1737 $pluck = wp_list_pluck( $forum_mods, 'name' ); 1738 $terms = ! empty( $pluck ) ? implode( $sep, $pluck ) : ''; 1739 1740 return apply_filters( 'bbp_get_forum_mod_names', $terms, $forum_id, $sep ); 1741 } 1742 1663 1743 /** Helpers *******************************************************************/ 1664 1744 -
trunk/src/includes/topics/functions.php
r5829 r5837 3682 3682 * Get topic tags for a specific topic ID 3683 3683 * 3684 * @since bbPress (r5836) 3685 * 3686 * @param int $topic_id 3687 * 3688 * @return string 3689 */ 3690 function bbp_get_topic_tags( $topic_id = 0 ) { 3691 $topic_id = bbp_get_topic_id( $topic_id ); 3692 $terms = (array) get_the_terms( $topic_id, bbp_get_topic_tag_tax_id() ); 3693 $topic_tags = array_filter( $terms ); 3694 3695 return apply_filters( 'bbp_get_topic_tags', $topic_tags, $topic_id ); 3696 } 3697 3698 /** 3699 * Get topic tags for a specific topic ID 3700 * 3684 3701 * @since bbPress (r4165) 3685 3702 * 3686 * @param int $topic_id3703 * @param int $topic_id 3687 3704 * @param string $sep 3705 * 3688 3706 * @return string 3689 3707 */ 3690 3708 function bbp_get_topic_tag_names( $topic_id = 0, $sep = ', ' ) { 3691 $topic_id = bbp_get_topic_id( $topic_id ); 3692 $topic_tags = array_filter( (array) get_the_terms( $topic_id, bbp_get_topic_tag_tax_id() ) ); 3693 $terms = array(); 3694 foreach ( $topic_tags as $term ) { 3695 $terms[] = $term->name; 3696 } 3697 $terms = ! empty( $terms ) ? implode( $sep, $terms ) : ''; 3698 3699 return apply_filters( 'bbp_get_topic_tags', $terms, $topic_id ); 3709 $topic_tags = bbp_get_topic_tags( $topic_id ); 3710 $pluck = wp_list_pluck( $topic_tags, 'name' ); 3711 $terms = ! empty( $pluck ) ? implode( $sep, $pluck ) : ''; 3712 3713 return apply_filters( 'bbp_get_topic_tag_names', $terms, $topic_id, $sep ); 3700 3714 } 3701 3715
Note: See TracChangeset
for help on using the changeset viewer.