Пример #1
0
/**
 * Output a select box allowing to pick which forum/topic a new topic/reply
 * belongs in.
 *
 * Can be used for any post type, but is mostly used for topics and forums.
 *
 * @since bbPress (r2746)
 *
 * @param mixed $args See {@link bbp_get_dropdown()} for arguments
 */
function bbp_dropdown($args = '')
{
    echo bbp_get_dropdown($args);
}
Пример #2
0
/**
 * Output a select box allowing to pick which forum/topic a new topic/reply
 * belongs in.
 *
 * Can be used for any post type, but is mostly used for topics and forums.
 *
 * @since 2.0.0 bbPress (r2746)
 *
 * @param array $args See {@link bbp_get_dropdown()} for arguments
 */
function bbp_dropdown($args = array())
{
    echo bbp_get_dropdown($args);
}
Пример #3
0
/**
 * Return a select box allowing to pick which topic/reply a reply belongs.
 *
 * @since 2.6.0 bbPress (r5387)
 *
 * @param int $reply_id
 *
 * @uses BBP_Reply_Walker_Dropdown() As the default walker to generate the
 *                                   dropdown
 * @uses current_user_can()          To check if the current user can read
 *                                   private forums
 * @uses bbp_get_reply_id()          To get the reply ID
 * @uses bbp_get_reply_to()          To get the reply to ID
 * @uses bbp_get_reply_topic_id()    To get the replies topic ID
 * @uses bbp_get_reply_post_type()   To get the reply post type
 * @uses bbp_get_public_status_id()  To get the reply status
 * @uses bbp_thread_replies_depth()  To get the threaded replies depth
 *
 * @uses apply_filters() Calls 'bbp_get_dropdown' with the dropdown
 *                        and args
 * @return string The dropdown
 */
function bbp_get_reply_to_dropdown($reply_id = 0)
{
    // Validate the reply data
    $reply_id = bbp_get_reply_id($reply_id);
    $reply_to = bbp_get_reply_to($reply_id);
    $topic_id = bbp_get_reply_topic_id($reply_id);
    // Get the replies
    $posts = get_posts(array('post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_public_status_id(), 'post_parent' => $topic_id, 'numberposts' => -1, 'orderby' => 'menu_order', 'order' => 'ASC'));
    // Append `reply_to` for each reply so it can be walked
    foreach ($posts as &$post) {
        // Check for reply post type
        $_reply_to = bbp_get_reply_to($post->ID);
        // Make sure it's a reply to a reply
        if (empty($_reply_to) || $topic_id === $_reply_to) {
            $_reply_to = 0;
        }
        // Add reply_to to the post object so we can walk it later
        $post->reply_to = $_reply_to;
    }
    // Get the dropdown and return it
    $retval = bbp_get_dropdown(array('show_none' => sprintf(esc_attr__('%1$s - %2$s', 'bbpress'), $topic_id, bbp_get_topic_title($topic_id)), 'select_id' => 'bbp_reply_to', 'select_class' => 'bbp_dropdown', 'exclude' => $reply_id, 'selected' => $reply_to, 'post_parent' => $topic_id, 'post_type' => bbp_get_reply_post_type(), 'max_depth' => bbp_thread_replies_depth(), 'page' => 1, 'per_page' => -1, 'walker' => new BBP_Walker_Reply_Dropdown(), 'posts' => $posts));
    // Filter and return
    return apply_filters('bbp_get_reply_to_dropdown', $retval, $reply_id, $reply_to, $topic_id);
}
Пример #4
0
    /**
     * Section for setting defaults for bbPress Topics for Posts
     */
    function general_discussion_settings()
    {
        ?>
<div id="bbppt-discussion-settings"><?php 
        if (!function_exists('bbp_has_forums')) {
            ?>
			<p><?php 
            _e('You must install or enable bbPress to use this plugin.', 'bbpress-post-topics');
            ?>
</p>
			<?php 
            return;
        }
        wp_enqueue_script('bbppt-admin-script');
        $ex_options = array('enabled' => false, 'forum_id' => false, 'copy_tags' => false, 'copy_comments' => false, 'display' => false, 'display-extras' => false);
        $ex_options = wp_parse_args(get_option('bbpress_discussion_defaults'), $ex_options);
        $forum_dropdown_options = array('selected' => $ex_options['forum_id'], 'options_only' => true);
        $forum_select_string = '<select name="bbpress_discussion_defaults[forum_id]" id="bbpress_discussion_defaults_forum_id">';
        $forum_select_string .= '<option value="0">' . __('Select a Forum', 'bbpress-post-topics') . '</option>';
        $forum_select_string .= bbp_get_dropdown($forum_dropdown_options);
        $forum_select_string .= '</select>';
        ?>
		<input type="checkbox" name="bbpress_discussion_defaults[enabled]" id="bbpress_discussion_defaults_enabled" <?php 
        checked($ex_options['enabled'], 'on');
        ?>
>
		<label for="bbpress_discussion_defaults_enabled"><?php 
        printf(__('Create a new bbPress topic in %s %s for new posts', 'bbpress-post-topics'), '</label>', $forum_select_string);
        ?>
 

		<?php 
        if (isset($ex_options['enabled']) && $ex_options['enabled'] == 'on') {
            ?>
		&mdash; <a class="button" id="create_topics" href="#" title="<?php 
            _e('Create topics and apply these settings to all existing posts', 'bbpress-post-topics');
            ?>
"><?php 
            _e('Apply settings to existing posts', 'bbpress-post-topics');
            ?>
</a>
		<?php 
        }
        ?>
		<br />

		<input type="checkbox" name="bbpress_discussion_defaults[copy_tags]" id="bbpress_discussion_defaults_copy_tags" <?php 
        checked($ex_options['copy_tags'], 'on');
        ?>
>
		<label for="bbpress_discussion_defaults_copy_tags"><?php 
        _e('Copy post tags to new topics', 'bbpress-post-topics');
        ?>
</label><br />

		<input type="checkbox" name="bbpress_discussion_defaults[copy_comments]" id="bbpress_discussion_defaults_copy_comments" <?php 
        checked($ex_options['copy_comments'], 'on');
        ?>
>
		<label for="bbpress_discussion_defaults_copy_comments"><?php 
        _e('Copy post comments to new topics (when available)', 'bbpress-post-topics');
        ?>
</label><br />

		<label for=""><?php 
        _e('On the post page, show:', 'bbpress-post-topics');
        ?>
</label><br />
		<?php 
        $xreplies_count = isset($ex_options['display-extras']['xcount']) ? $ex_options['display-extras']['xcount'] : 5;
        $xreplies_count_string = '<input type="text" name="bbpress_discussion_defaults[display-extras][xcount]" id="bbpress_discussion_defaults_display-extras_xcount" value="' . $xreplies_count . '" class="small-text" maxlength="3" />';
        $xreplies_sort_options = array('newest' => __('most recent', 'bbpress-post-topics'), 'oldest' => __('oldest', 'bbpress-post-topics'));
        $xsort_select_string = '<select name="bbpress_discussion_defaults[display-extras][xsort]" id="bbpress_discussion_defaults_display_sort">';
        foreach ($xreplies_sort_options as $option => $label) {
            $xsort_select_string .= '<option value="' . $option . '" ' . selected($ex_options['display-extras']['xsort'], $option, false) . '>' . $label . '</option>';
        }
        $xsort_select_string .= '</select>';
        /** Build list of display formats, including custom ones */
        $display_formats = array('topic' => __('Entire topic', 'bbpress-post-topics'), 'replies' => __('Replies only', 'bbpress-post-topics'), 'xreplies' => sprintf(__('Only the %s %s %s replies', 'bbpress-post-topics'), '</label>', $xreplies_count_string, $xsort_select_string), 'link' => __('A link to the topic', 'bbpress-post-topics') . '</label>');
        $display_formats = apply_filters('bbppt_display_format_options', $display_formats, 0);
        ?>
		<fieldset>
			<?php 
        foreach ($display_formats as $format_code => $format_label) {
            ?>
			<input type="radio" name="bbpress_discussion_defaults[display]" id="bbpress_discussion_default_display_<?php 
            echo $format_code;
            ?>
" value="<?php 
            echo $format_code;
            ?>
" <?php 
            checked($ex_options['display'], $format_code);
            ?>
 /><label for="bbpress_discussion_default_display_<?php 
            echo $format_code;
            ?>
"><?php 
            echo $format_label;
            ?>
</label><br />
			<?php 
        }
        ?>
		</fieldset>
		<?php 
        do_action('bbppt_display_options_fields', 0);
        ?>
</div><?php 
    }