/** * Handles the output for custom columns. * * @since 1.0.0 * @access public * @param string $column * @param int $post_id */ public function manage_columns($column, $post_id) { switch ($column) { /* Post status column. */ case 'status': $post_type = mb_get_forum_post_type(); $status = get_post_status_object(mb_get_forum_status($post_id)); /* If the forum has the "publish" post status, change it to "open". */ if (mb_get_publish_post_status() === $status->name) { wp_update_post(array('ID' => $post_id, 'post_status' => mb_get_open_post_status())); } $url = add_query_arg(array('post_status' => $status->name, 'post_type' => $post_type), admin_url('edit.php')); printf('<a href="%s">%s</a>', $url, $status->label); break; /* Forum type column. */ /* Forum type column. */ case 'type': $post_type = mb_get_forum_post_type(); $forum_type = mb_get_forum_type_object(mb_get_forum_type($post_id)); $url = add_query_arg(array('post_type' => $post_type, 'forum_type' => $forum_type->name), admin_url('edit.php')); printf('<a href="%s">%s</a>', $url, $forum_type->label); break; /* Topic count column. */ /* Topic count column. */ case 'subforums': $subforum_count = mb_get_forum_subforum_count($post_id); $subforum_count = !empty($subforum_count) ? absint($subforum_count) : number_format_i18n(0); if (0 < $subforum_count) { printf('<a href="%s">%s</a>', add_query_arg(array('post_type' => mb_get_forum_post_type(), 'post_parent' => $post_id), admin_url('edit.php')), $subforum_count); } else { echo $subforum_count; } break; /* Topic count column. */ /* Topic count column. */ case 'topics': $topic_count = mb_get_forum_topic_count($post_id); $topic_count = !empty($topic_count) ? absint($topic_count) : number_format_i18n(0); if (0 < $topic_count && current_user_can('edit_topics')) { printf('<a href="%s">%s</a>', add_query_arg(array('post_type' => mb_get_topic_post_type(), 'post_parent' => $post_id), admin_url('edit.php')), $topic_count); } else { echo $topic_count; } break; /* Reply count column. */ /* Reply count column. */ case 'replies': $reply_count = mb_get_forum_reply_count($post_id); $reply_count = !empty($reply_count) ? absint($reply_count) : number_format_i18n(0); if (0 < $reply_count && current_user_can('edit_replies')) { printf('<a href="%s">%s</a>', add_query_arg(array('post_type' => mb_get_reply_post_type(), 'mb_forum' => $post_id), admin_url('edit.php')), $reply_count); } else { echo $reply_count; } break; /* Datetime column. */ /* Datetime column. */ case 'datetime': the_time(get_option('date_format')); echo '<br />'; the_time(get_option('time_format')); break; /* Just break out of the switch statement for everything else. */ /* Just break out of the switch statement for everything else. */ default: break; } }
/** * Function for inserting forum data when it's first published. * * @since 1.0.0 * @access public * @param object $post * @return void */ function mb_insert_forum_data($post) { /* Hook for before inserting forum data. */ do_action('mb_before_insert_forum_data', $post); /* Get the forum ID. */ $forum_id = mb_get_forum_id($post->ID); /* Get the User ID. */ $user_id = mb_get_user_id($post->post_author); /* Update parent's subforum count. */ if (0 < $post->post_parent) { $count = mb_get_forum_subforum_count($post->post_parent); mb_set_forum_subforum_count($post->post_parent, absint($count) + 1); } /* Update user meta. */ mb_set_user_forum_count($user_id); /* Add forum meta. */ mb_reset_forum_level($forum_id); /* Notify subscribers that there's a new forum. */ mb_notify_subscribers($post); /* Hook for after inserting forum data. */ do_action('mb_after_insert_forum_data', $post); }
mb_single_forum_title(); ?> </h1> <div class="mb-forum-content"> <?php mb_forum_content(); ?> </div><!-- .mb-forum-content --> <p class="mb-forum-info"> <?php if (mb_forum_allows_subforums()) { ?> <span class="mb-subforum-count"><?php printf(mb_forum_allows_topics() ? __('Sub-forums: %s', 'message-board') : __('Forums: %s', 'message-board'), mb_get_forum_subforum_count()); ?> </span> <?php } ?> <?php if (mb_forum_allows_topics()) { ?> <span class="mb-topic-count"><?php printf(__('Topics: %s', 'message-board'), mb_get_forum_topic_count()); ?> </span> <span class="mb-reply-count"><?php printf(__('Replies: %s', 'message-board'), mb_get_forum_reply_count());
function mb_forum_subforum_count($forum_id = 0) { echo mb_get_forum_subforum_count($forum_id); }