setup_globals(); $this->setup_actions(); $this->setup_help(); } /** * Setup the admin hooks, actions and filters * * @since bbPress (r2646) * @access private * * @uses add_action() To add various actions * @uses add_filter() To add various filters * @uses bbp_get_forum_post_type() To get the forum post type * @uses bbp_get_topic_post_type() To get the topic post type * @uses bbp_get_reply_post_type() To get the reply post type */ function setup_actions() { // Add some general styling to the admin area add_action( 'admin_head', array( $this, 'admin_head' ) ); // Messages add_filter( 'post_updated_messages', array( $this, 'updated_messages' ) ); // Metabox actions add_action( 'add_meta_boxes', array( $this, 'attributes_metabox' ) ); add_action( 'save_post', array( $this, 'attributes_metabox_save' ) ); // Column headers. add_filter( 'manage_' . $this->post_type . '_posts_columns', array( $this, 'column_headers' ) ); // Columns (in page row) add_action( 'manage_' . $this->post_type . '_posts_custom_column', array( $this, 'column_data' ), 10, 2 ); add_filter( 'page_row_actions', array( $this, 'row_actions' ), 10, 2 ); } /** * Admin globals * * @since bbPress (r2646) * @access private */ function setup_globals() { // Setup the post type for this admin component $this->post_type = bbp_get_forum_post_type(); } /** * Contextual help for forums * * @since bbPress (r3119) * @access private */ function setup_help() { // Define local variable(s) $contextual_help = array(); /** New/Edit **********************************************************/ $bbp_contextual_help[] = __( 'The forum title field and the big forum editing area are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of the box. Use the Screen Options tab to unhide more boxes (like Slug) or to choose a 1- or 2-column layout for this screen.', 'bbpress' ); $bbp_contextual_help[] = __( 'Title - Enter a title for your forum. After you enter a title, you will see the permalink appear below it, which is fully editable.', 'bbpress' ); $bbp_contextual_help[] = __( 'Post editor - Enter the description for your forum. There are two modes of editing: Visual and HTML. Choose the mode by clicking on the appropriate tab. Visual mode gives you a WYSIWYG editor. Click the last icon in the row to get a second row of controls. The screen icon just before that allows you to expand the edit box to full screen. The HTML mode allows you to enter raw HTML along with your forum text. You can insert media files by clicking the icons above the post editor and following the directions.', 'bbpress' ); $bbp_contextual_help[] = __( 'Forum Attributes - Select the various attributes that your forum should have:', 'bbpress' ); $bbp_contextual_help[] = '
' . $paragraph . '
'; // Add help add_contextual_help( bbp_get_forum_post_type(), $contextual_help ); // Reset $contextual_help = $bbp_contextual_help = ''; /** Post Rows *********************************************************/ $bbp_contextual_help[] = __( 'This screen displays the forums available on your site.', 'bbpress' ); $bbp_contextual_help[] = __( 'You can customize the display of this screen in a number of ways:', 'bbpress' ); $bbp_contextual_help[] = '' . $paragraph . '
'; // Add help add_contextual_help( 'edit-' . bbp_get_forum_post_type(), $contextual_help ); } /** * Add the forum attributes metabox * * @since bbPress (r2746) * * @uses bbp_get_forum_post_type() To get the forum post type * @uses add_meta_box() To add the metabox * @uses do_action() Calls 'bbp_forum_attributes_metabox' */ function attributes_metabox() { add_meta_box ( 'bbp_forum_attributes', __( 'Forum Attributes', 'bbpress' ), 'bbp_forum_metabox', $this->post_type, 'side', 'high' ); do_action( 'bbp_forum_attributes_metabox' ); } /** * Pass the forum attributes for processing * * @since bbPress (r2746) * * @param int $forum_id Forum id * @uses current_user_can() To check if the current user is capable of * editing the forum * @uses bbp_get_forum() To get the forum * @uses bbp_is_forum_closed() To check if the forum is closed * @uses bbp_is_forum_category() To check if the forum is a category * @uses bbp_is_forum_private() To check if the forum is private * @uses bbp_close_forum() To close the forum * @uses bbp_open_forum() To open the forum * @uses bbp_categorize_forum() To make the forum a category * @uses bbp_normalize_forum() To make the forum normal (not category) * @uses bbp_privatize_forum() To mark the forum as private * @uses bbp_publicize_forum() To mark the forum as public * @uses do_action() Calls 'bbp_forum_attributes_metabox_save' with the * forum id * @return int Forum id */ function attributes_metabox_save( $forum_id ) { // Bail if doing an autosave if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return $forum_id; // Bail if not a post request if ( 'POST' != strtoupper( $_SERVER['REQUEST_METHOD'] ) ) return $forum_id; // Bail if current user cannot edit this forum if ( !current_user_can( 'edit_forum', $forum_id ) ) return $forum_id; // Load the forum if ( !$forum = bbp_get_forum( $forum_id ) ) return $forum_id; // Closed? if ( !empty( $_POST['bbp_forum_status'] ) && in_array( $_POST['bbp_forum_status'], array( 'open', 'closed' ) ) ) { if ( 'closed' == $_POST['bbp_forum_status'] && !bbp_is_forum_closed( $forum_id, false ) ) bbp_close_forum( $forum_id ); elseif ( 'open' == $_POST['bbp_forum_status'] && bbp_is_forum_closed( $forum_id, false ) ) bbp_open_forum( $forum_id ); } // Category? if ( !empty( $_POST['bbp_forum_type'] ) && in_array( $_POST['bbp_forum_type'], array( 'forum', 'category' ) ) ) { if ( 'category' == $_POST['bbp_forum_type'] && !bbp_is_forum_category( $forum_id ) ) { bbp_categorize_forum( $forum_id ); } elseif ( 'forum' == $_POST['bbp_forum_type'] && bbp_is_forum_category( $forum_id ) ) { bbp_normalize_forum( $forum_id ); } } // Visibility if ( !empty( $_POST['bbp_forum_visibility'] ) && in_array( $_POST['bbp_forum_visibility'], array( bbp_get_public_status_id(), bbp_get_private_status_id(), bbp_get_hidden_status_id() ) ) ) { // Get forums current visibility $visibility = bbp_get_forum_visibility( $forum_id ); // If new visibility is different, change it if ( $visibility != $_POST['bbp_forum_visibility'] ) { // What is the new forum visibility setting? switch ( $_POST['bbp_forum_visibility'] ) { // Hidden case bbp_get_hidden_status_id() : bbp_hide_forum( $forum_id, $visibility ); break; // Private case bbp_get_private_status_id() : bbp_privatize_forum( $forum_id, $visibility ); break; // Publish (default) case bbp_get_public_status_id() : default : bbp_publicize_forum( $forum_id, $visibility ); break; } } } // Parent ID $parent_id = ( !empty( $_POST['parent_id'] ) && is_numeric( $_POST['parent_id'] ) ) ? $_POST['parent_id'] : 0; // Update the forum meta bidness bbp_update_forum( array( 'forum_id' => $forum_id, 'post_parent' => (int) $parent_id ) ); do_action( 'bbp_forum_attributes_metabox_save', $forum_id ); return $forum_id; } /** * Add some general styling to the admin area * * @since bbPress (r2464) * * @uses bbp_get_forum_post_type() To get the forum post type * @uses bbp_get_topic_post_type() To get the topic post type * @uses bbp_get_reply_post_type() To get the reply post type * @uses sanitize_html_class() To sanitize the classes * @uses do_action() Calls 'bbp_admin_head' */ function admin_head() { if ( get_post_type() == $this->post_type ) : ?> '', 'title' => __( 'Forum', 'bbpress' ), 'bbp_forum_topic_count' => __( 'Topics', 'bbpress' ), 'bbp_forum_reply_count' => __( 'Replies', 'bbpress' ), 'author' => __( 'Creator', 'bbpress' ), 'bbp_forum_created' => __( 'Created' , 'bbpress' ), 'bbp_forum_freshness' => __( 'Freshness', 'bbpress' ) ); return apply_filters( 'bbp_admin_forums_column_headers', $columns ); } /** * Print extra columns for the forums page * * @since bbPress (r2485) * * @param string $column Column * @param int $forum_id Forum id * @uses bbp_forum_topic_count() To output the forum topic count * @uses bbp_forum_reply_count() To output the forum reply count * @uses get_the_date() Get the forum creation date * @uses get_the_time() Get the forum creation time * @uses esc_attr() To sanitize the forum creation time * @uses bbp_get_forum_last_active_time() To get the time when the forum was * last active * @uses do_action() Calls 'bbp_admin_forums_column_data' with the * column and forum id */ function column_data( $column, $forum_id ) { switch ( $column ) { case 'bbp_forum_topic_count' : bbp_forum_topic_count( $forum_id ); break; case 'bbp_forum_reply_count' : bbp_forum_reply_count( $forum_id ); break; case 'bbp_forum_created': printf( __( '%1$s