Exemplo n.º 1
0
/**
 * Return value of topic tags field
 *
 * @since 2.0.0 bbPress (r2976)
 *
 * @uses bbp_is_topic_edit() To check if it's the topic edit page
 * @uses apply_filters() Calls 'bbp_get_form_topic_tags' with the tags
 * @return string Value of topic tags field
 */
function bbp_get_form_topic_tags()
{
    // Default return value
    $topic_tags = '';
    // Get _POST data
    if ((bbp_is_topic_form_post_request() || bbp_is_reply_form_post_request()) && isset($_POST['bbp_topic_tags'])) {
        $topic_tags = wp_unslash($_POST['bbp_topic_tags']);
        // Get edit data
    } elseif (bbp_is_single_topic() || bbp_is_single_reply() || bbp_is_topic_edit() || bbp_is_reply_edit()) {
        // Determine the topic id based on the post type
        switch (get_post_type()) {
            // Post is a topic
            case bbp_get_topic_post_type():
                $topic_id = bbp_get_topic_id(get_the_ID());
                break;
                // Post is a reply
            // Post is a reply
            case bbp_get_reply_post_type():
                $topic_id = bbp_get_reply_topic_id(get_the_ID());
                break;
        }
        // Topic exists
        if (!empty($topic_id)) {
            // Topic is spammed so display pre-spam terms
            if (bbp_is_topic_spam($topic_id)) {
                // Get pre-spam terms
                $spam_terms = get_post_meta($topic_id, '_bbp_spam_topic_tags', true);
                $topic_tags = !empty($spam_terms) ? implode(', ', $spam_terms) : '';
                // Topic is not spam so get real terms
            } else {
                $topic_tags = bbp_get_topic_tag_names($topic_id);
            }
        }
    }
    return apply_filters('bbp_get_form_topic_tags', $topic_tags);
}
Exemplo n.º 2
0
/**
 * Returns reply status downdown
 *
 * This dropdown is only intended to be seen by users with the 'moderate'
 * capability. Because of this, no additional capablitiy checks are performed
 * within this function to check available reply statuses.
 *
 * @since 2.6.0 bbPress (r5399)
 *
 * @param $args This function supports these arguments:
 *  - select_id: Select id. Defaults to bbp_reply_status
 *  - tab: Deprecated. Tabindex
 *  - reply_id: Reply id
 *  - selected: Override the selected option
 */
function bbp_get_form_reply_status_dropdown($args = array())
{
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('select_id' => 'bbp_reply_status', 'select_class' => 'bbp_dropdown', 'tab' => false, 'reply_id' => 0, 'selected' => false), 'reply_status_dropdown');
    // No specific selected value passed
    if (empty($r['selected'])) {
        // Post value is passed
        if (bbp_is_reply_form_post_request() && isset($_POST[$r['select_id']])) {
            $r['selected'] = sanitize_key($_POST[$r['select_id']]);
            // No Post value was passed
        } else {
            // Edit reply
            if (bbp_is_reply_edit()) {
                $r['reply_id'] = bbp_get_reply_id($r['reply_id']);
                $r['selected'] = bbp_get_reply_status($r['reply_id']);
                // New reply
            } else {
                $r['selected'] = bbp_get_public_status_id();
            }
        }
    }
    // Used variables
    $tab = !empty($r['tab']) ? ' tabindex="' . (int) $r['tab'] . '"' : '';
    // Start an output buffer, we'll finish it after the select loop
    ob_start();
    ?>

		<select name="<?php 
    echo esc_attr($r['select_id']);
    ?>
" id="<?php 
    echo esc_attr($r['select_id']);
    ?>
_select" class="<?php 
    echo esc_attr($r['select_class']);
    ?>
"<?php 
    echo $tab;
    ?>
>

			<?php 
    foreach (bbp_get_reply_statuses($r['reply_id']) as $key => $label) {
        ?>

				<option value="<?php 
        echo esc_attr($key);
        ?>
"<?php 
        selected($key, $r['selected']);
        ?>
><?php 
        echo esc_html($label);
        ?>
</option>

			<?php 
    }
    ?>

		</select>

		<?php 
    // Return the results
    return apply_filters('bbp_get_form_reply_status_dropdown', ob_get_clean(), $r);
}