Changeset 5837 for trunk/src/includes/forums/functions.php
- Timestamp:
- 07/15/2015 05:29:22 PM (10 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.