Skip to:
Content

bbPress.org


Ignore:
Timestamp:
08/02/2013 07:20:49 AM (13 years ago)
Author:
johnjamesjacoby
Message:

Normalize forum, topic, and reply dropdown form fields and associated functions. Includes several new functions with _get_ equivalents to replace incorrectly named _select() functions.

First pass at adding custom topic status handling. Props jkudish. See #2187.

Also replaces $wpdb->update() calls with wp_update_post() in associated functions. Fixes #2351.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/forums/functions.php

    r5021 r5060  
    801801        if ( bbp_get_public_status_id() !== $current_visibility ) {
    802802
    803                 // Update forum post_status
    804                 global $wpdb;
    805                 $wpdb->update( $wpdb->posts, array( 'post_status' => bbp_get_public_status_id() ), array( 'ID' => $forum_id ) );
    806                 wp_transition_post_status( bbp_get_public_status_id(), $current_visibility, get_post( $forum_id ) );
     803                // Update forums visibility setting
     804                wp_insert_post( array(
     805                        'ID'          => $forum_id,
     806                        'post_status' => bbp_get_public_status_id()
     807                ) );
    807808        }
    808809
     
    851852
    852853                // Update forums visibility setting
    853                 global $wpdb;
    854                 $wpdb->update( $wpdb->posts, array( 'post_status' => bbp_get_private_status_id() ), array( 'ID' => $forum_id ) );
    855                 wp_transition_post_status( bbp_get_private_status_id(), $current_visibility, get_post( $forum_id ) );
     854                wp_insert_post( array(
     855                        'ID'          => $forum_id,
     856                        'post_status' => bbp_get_private_status_id()
     857                ) );
    856858        }
    857859
     
    900902
    901903                // Update forums visibility setting
    902                 global $wpdb;
    903                 $wpdb->update( $wpdb->posts, array( 'post_status' => bbp_get_hidden_status_id() ), array( 'ID' => $forum_id ) );
    904                 wp_transition_post_status( bbp_get_hidden_status_id(), $current_visibility, get_post( $forum_id ) );
     904                wp_insert_post( array(
     905                        'ID'          => $forum_id,
     906                        'post_status' => bbp_get_hidden_status_id()
     907                ) );
    905908        }
    906909
     
    15431546}
    15441547
     1548/** Helpers *******************************************************************/
     1549
     1550/**
     1551 * Return an associative array of available topic statuses
     1552 *
     1553 * @since bbPress (r5059)
     1554 *
     1555 * @return array
     1556 */
     1557function bbp_get_forum_statuses() {
     1558        return apply_filters( 'bbp_get_forum_statuses', array(
     1559                'open'   => _x( 'Open',    'Open the forum',  'bbpress' ),
     1560                'closed' => _x( 'Closed',  'Close the forum', 'bbpress' )
     1561        ) );
     1562}
     1563
     1564/**
     1565 * Return an associative array of forum types
     1566 *
     1567 * @since bbPress (r5059)
     1568 *
     1569 * @return array
     1570 */
     1571function bbp_get_forum_types() {
     1572        return apply_filters( 'bbp_get_forum_types', array(
     1573                'forum'    => _x( 'Forum',    'Forum accepts new topics', 'bbpress' ),
     1574                'category' => _x( 'Category', 'Forum is a category',      'bbpress' )
     1575        ) );
     1576}
     1577
     1578/**
     1579 * Return an associative array of forum visibility
     1580 *
     1581 * @since bbPress (r5059)
     1582 *
     1583 * @return array
     1584 */
     1585function bbp_get_forum_visibilities() {
     1586        return apply_filters( 'bbp_get_forum_visibilities', array(
     1587                bbp_get_public_status_id()  => _x( 'Public',  'Make forum public',  'bbpress' ),
     1588                bbp_get_private_status_id() => _x( 'Private', 'Make forum private', 'bbpress' ),
     1589                bbp_get_hidden_status_id()  => _x( 'Hidden',  'Make forum hidden',  'bbpress' )
     1590        ) );
     1591}
     1592
    15451593/** Queries *******************************************************************/
    15461594
Note: See TracChangeset for help on using the changeset viewer.