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/topics/functions.php

    r5055 r5060  
    276276                $topic_status = bbp_get_pending_status_id();
    277277
    278         // Default to published
     278        // Check a whitelist of possible topic status ID's
     279        } elseif ( in_array( $_POST['bbp_topic_status'], array( bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_pending_status_id(), bbp_get_trash_status_id(), bbp_get_orphan_status_id() ) ) ) {
     280                $topic_status = $_POST['bbp_topic_status'];
     281
     282        // Default to published if nothing else
    279283        } else {
    280284                $topic_status = bbp_get_public_status_id();
     
    608612                }
    609613
     614        // Check a whitelist of possible topic status ID's
     615        } elseif ( in_array( $_POST['bbp_topic_status'], array( bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_pending_status_id(), bbp_get_trash_status_id(), bbp_get_orphan_status_id() ) ) ) {
     616                $topic_status = $_POST['bbp_topic_status'];
     617
    610618        // Use existing post_status
    611619        } else {
     
    19441952}
    19451953
     1954/** Helpers *******************************************************************/
     1955
     1956/**
     1957 * Return an associative array of available topic statuses
     1958 *
     1959 * @since bbPress (r5059)
     1960 *
     1961 * @return array
     1962 */
     1963function bbp_get_topic_statuses() {
     1964        return apply_filters( 'bbp_get_topic_statuses', array(
     1965                bbp_get_public_status_id()  => _x( 'Open',    'Open the topic',        'bbpress' ),
     1966                bbp_get_closed_status_id()  => _x( 'Closed',  'Close the topic',       'bbpress' ),
     1967                bbp_get_spam_status_id()    => _x( 'Spam',    'Spam the topic',        'bbpress' ),
     1968                bbp_get_trash_status_id()   => _x( 'Trash',   'Trash the topic',       'bbpress' ),
     1969                bbp_get_pending_status_id() => _x( 'Pending', 'Mark topic as pending', 'bbpress' ),
     1970        ) );
     1971}
     1972
     1973/**
     1974 * Return an associative array of topic sticky types
     1975 *
     1976 * @since bbPress (r5059)
     1977 *
     1978 * @return array
     1979 */
     1980function bbp_get_topic_types() {
     1981        return apply_filters( 'bbp_get_topic_types', array(
     1982                'unstick' => _x( 'Normal',       'Unstick a topic',         'bbpress' ),
     1983                'stick'   => _x( 'Sticky',       'Make topic sticky',       'bbpress' ),
     1984                'super'   => _x( 'Super Sticky', 'Make topic super sticky', 'bbpress' )
     1985        ) );
     1986}
     1987
    19461988/** Stickies ******************************************************************/
    19471989
Note: See TracChangeset for help on using the changeset viewer.