echo esc_html($forum_type->label);
    ?>
</option>
			<?php 
}
?>
			</select>
		</p>

		<p>
			<label for="mb_menu_order"><?php 
_e('Order:', 'message-board');
?>
</label>
			<input type="number" id="mb_menu_order" name="mb_menu_order" value="<?php 
echo esc_attr(mb_get_forum_order());
?>
" />
		</p>

		<p>
			<label for="mb_forum_content"><?php 
_e('Description:', 'message-board');
?>
</label>
			<textarea id="mb_forum_content" name="mb_forum_content"><?php 
echo format_to_edit(mb_code_trick_reverse(mb_get_forum_content(mb_get_forum_id(), 'raw')));
?>
</textarea>
		</p>
Example #2
0
/**
 * Front end edit forum handler.
 *
 * @since  1.0.0
 * @access public
 * @return void
 */
function mb_handler_edit_forum()
{
    /* Verify the nonce. */
    if (!mb_check_post_nonce('mb_edit_forum_nonce', 'mb_edit_forum_action')) {
        return;
    }
    /* Make sure we have a forum ID. */
    if (!isset($_POST['mb_forum_id'])) {
        mb_bring_the_doom('what-edit');
    }
    /* Get the forum ID. */
    $forum_id = mb_get_forum_id($_POST['mb_forum_id']);
    /* Make sure the current user can edit this forum. */
    if (!current_user_can('edit_forum', $forum_id)) {
        mb_bring_the_doom('no-permission');
    }
    /* Make sure we have a forum title. */
    if (empty($_POST['mb_forum_title'])) {
        mb_bring_the_doom('no-title');
    }
    /* Post title. */
    $post_title = apply_filters('mb_pre_insert_forum_title', $_POST['mb_forum_title']);
    /* Post content. */
    $post_content = apply_filters('mb_pre_insert_forum_content', $_POST['mb_forum_content']);
    /* Forum ID. */
    $post_parent = isset($_POST['mb_post_parent']) ? absint($_POST['mb_post_parent']) : mb_get_forum_parent_id($forum_id);
    /* Menu order. */
    $menu_order = isset($_POST['mb_menu_order']) ? intval($_POST['mb_menu_order']) : mb_get_forum_order($forum_id);
    /* Update the forum. */
    $published = wp_update_post(array('ID' => $forum_id, 'post_title' => $post_title, 'post_content' => $post_content, 'post_parent' => $post_parent, 'menu_order' => $menu_order));
    /* If the post was published. */
    if ($published && !is_wp_error($published)) {
        $user_id = mb_get_forum_author_id($published);
        /* Forum type. */
        if (isset($_POST['mb_forum_type'])) {
            mb_set_forum_type($published, sanitize_key($_POST['mb_forum_type']));
        }
        /* If the user chose to subscribe to the forum. */
        if (isset($_POST['mb_forum_subscribe']) && 1 === absint($_POST['mb_forum_subscribe'])) {
            mb_add_user_forum_subscription($user_id, $published);
        } else {
            mb_remove_user_forum_subscription($user_id, $published);
        }
        /* Redirect to the published topic page. */
        wp_safe_redirect(get_permalink($published));
        exit;
    }
}