Skip to:
Content

bbPress.org


Ignore:
Timestamp:
03/01/2011 05:56:35 PM (15 years ago)
Author:
johnjamesjacoby
Message:

First pass at allowing topics and replies to be created via their respective "New" screens in wp-admin.

@todo - metaboxes to match new core functionalities

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-topic-functions.php

    r2933 r2947  
    345345
    346346/**
     347 * Handles new topic submission from within wp-admin
     348 *
     349 * @param int $post_id
     350 * @param obj $post
     351 *
     352 * @uses bbp_get_topic_post_type()
     353 * @uses bbp_update_topic()
     354 */
     355function bbp_new_topic_admin_handler( $post_id, $post ) {
     356    global $bbp;
     357
     358    if (    // Check if POST action
     359            'POST'                        === $_SERVER['REQUEST_METHOD'] &&
     360
     361            // Check Actions exist in POST
     362            !empty( $_POST['action']    )                                &&
     363            !empty( $_POST['post_type'] )                                &&
     364
     365            // Check that actions match what we need
     366            'editpost'                    === $_POST['action']           &&
     367            bbp_get_topic_post_type()     === $_POST['post_type']
     368    ) {
     369
     370        // Update the topic meta bidness
     371        bbp_update_topic( $post_id, (int) $_POST['parent_id'] );
     372    }
     373}
     374
     375/**
    347376 * Handle all the extra meta stuff from posting a new topic
    348377 *
     
    372401 */
    373402function bbp_update_topic( $topic_id = 0, $forum_id = 0, $anonymous_data = false, $author_id = 0, $is_edit = false ) {
     403
    374404    // Validate the ID's passed from 'bbp_new_topic' action
    375405    $topic_id = bbp_get_topic_id( $topic_id );
    376406    $forum_id = bbp_get_forum_id( $forum_id );
     407
     408    // Check author_id
    377409    if ( empty( $author_id ) )
    378410        $author_id = bbp_get_current_user_id();
     411
     412    // Check forum_id
     413    if ( empty( $forum_id ) )
     414        $forum_id = bbp_get_topic_forum_id( $topic_id );
    379415
    380416    // If anonymous post, store name, email, website and ip in post_meta.
     
    13621398    else
    13631399        $topic_id = bbp_get_topic_id( $topic_id );
    1364    
    1365     $forum_id = bbp_get_forum_id( $forum_id );
    13661400
    13671401    if ( empty( $forum_id ) )
Note: See TracChangeset for help on using the changeset viewer.