예제 #1
0
 function mycred_exclude_post_type_bbPress($excludes)
 {
     $excludes[] = bbp_get_forum_post_type();
     $excludes[] = bbp_get_topic_post_type();
     $excludes[] = bbp_get_reply_post_type();
     return $excludes;
 }
예제 #2
0
/**
 * Move our custom separator above our custom post types
 *
 * @since bbPress (r2957)
 *
 * @param array $menu_order Menu Order
 * @uses bbp_get_forum_post_type() To get the forum post type
 * @return array Modified menu order
 */
function bbp_admin_menu_order($menu_order)
{
    // Bail if user cannot see any top level bbPress menus
    if (empty($menu_order) || false === bbpress()->admin->show_separator) {
        return $menu_order;
    }
    // Initialize our custom order array
    $bbp_menu_order = array();
    // Menu values
    $second_sep = 'separator2';
    $custom_menus = array('separator-bbpress', 'edit.php?post_type=' . bbp_get_forum_post_type(), 'edit.php?post_type=' . bbp_get_topic_post_type(), 'edit.php?post_type=' . bbp_get_reply_post_type());
    // Loop through menu order and do some rearranging
    foreach ($menu_order as $item) {
        // Position bbPress menus above appearance
        if ($second_sep == $item) {
            // Add our custom menus
            foreach ($custom_menus as $custom_menu) {
                if (array_search($custom_menu, $menu_order)) {
                    $bbp_menu_order[] = $custom_menu;
                }
            }
            // Add the appearance separator
            $bbp_menu_order[] = $second_sep;
            // Skip our menu items
        } elseif (!in_array($item, $custom_menus)) {
            $bbp_menu_order[] = $item;
        }
    }
    // Return our custom order
    return $bbp_menu_order;
}
예제 #3
0
/**
 * The main reply loop. WordPress makes this easy for us
 *
 * @since bbPress (r2553)
 *
 * @param mixed $args All the arguments supported by {@link WP_Query}
 * @uses bbp_is_user_bozo() To add the bozo post status
 * @uses bbp_show_lead_topic() Are we showing the topic as a lead?
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_get_reply_post_type() To get the reply post type
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses bbp_is_query_name() To check if we are getting replies for a widget
 * @uses get_option() To get the replies per page option
 * @uses bbp_get_paged() To get the current page value
 * @uses current_user_can() To check if the current user is capable of editing
 *                           others' replies
 * @uses WP_Query To make query and get the replies
 * @uses WP_Rewrite::using_permalinks() To check if the blog is using permalinks
 * @uses get_permalink() To get the permalink
 * @uses add_query_arg() To add custom args to the url
 * @uses apply_filters() Calls 'bbp_replies_pagination' with the pagination args
 * @uses paginate_links() To paginate the links
 * @uses apply_filters() Calls 'bbp_has_replies' with
 *                        bbPres::reply_query::have_posts()
 *                        and bbPres::reply_query
 * @return object Multidimensional array of reply information
 */
function bbp_has_replies($args = '')
{
    global $wp_rewrite;
    // What are the default allowed statuses (based on user caps)
    if (bbp_get_view_all('edit_others_replies')) {
        $post_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id());
    } else {
        $post_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id());
    }
    // Add the bozo status if user is a bozo
    if (bbp_is_user_bozo()) {
        $post_statuses[] = bbp_get_bozo_status_id();
    }
    $default_reply_search = !empty($_REQUEST['rs']) ? $_REQUEST['rs'] : false;
    $default_post_parent = bbp_is_single_topic() ? bbp_get_topic_id() : 'any';
    $default_post_type = bbp_is_single_topic() && bbp_show_lead_topic() ? bbp_get_reply_post_type() : array(bbp_get_topic_post_type(), bbp_get_reply_post_type());
    $default_post_status = join(',', $post_statuses);
    // Default query args
    $default = array('post_type' => $default_post_type, 'post_parent' => $default_post_parent, 'post_status' => $default_post_status, 'posts_per_page' => bbp_get_replies_per_page(), 'paged' => bbp_get_paged(), 'orderby' => 'date', 'order' => 'ASC', 's' => $default_reply_search);
    // Set up topic variables
    $bbp_r = bbp_parse_args($args, $default, 'has_replies');
    // Extract the query variables
    extract($bbp_r);
    // Get bbPress
    $bbp = bbpress();
    // Call the query
    $bbp->reply_query = new WP_Query($bbp_r);
    // Add pagination values to query object
    $bbp->reply_query->posts_per_page = $posts_per_page;
    $bbp->reply_query->paged = $paged;
    // Only add pagination if query returned results
    if ((int) $bbp->reply_query->found_posts && (int) $bbp->reply_query->posts_per_page) {
        // If pretty permalinks are enabled, make our pagination pretty
        if ($wp_rewrite->using_permalinks()) {
            // Page or single
            if (is_page() || is_single()) {
                $base = get_permalink();
                // Topic
            } else {
                $base = get_permalink(bbp_get_topic_id());
            }
            $base = trailingslashit($base) . user_trailingslashit($wp_rewrite->pagination_base . '/%#%/');
            // Unpretty permalinks
        } else {
            $base = add_query_arg('paged', '%#%');
        }
        // Pagination settings with filter
        $bbp_replies_pagination = apply_filters('bbp_replies_pagination', array('base' => $base, 'format' => '', 'total' => ceil((int) $bbp->reply_query->found_posts / (int) $posts_per_page), 'current' => (int) $bbp->reply_query->paged, 'prev_text' => '←', 'next_text' => '→', 'mid_size' => 1, 'add_args' => bbp_get_view_all() ? array('view' => 'all') : false));
        // Add pagination to query object
        $bbp->reply_query->pagination_links = paginate_links($bbp_replies_pagination);
        // Remove first page from pagination
        if ($wp_rewrite->using_permalinks()) {
            $bbp->reply_query->pagination_links = str_replace($wp_rewrite->pagination_base . '/1/', '', $bbp->reply_query->pagination_links);
        } else {
            $bbp->reply_query->pagination_links = str_replace('&paged=1', '', $bbp->reply_query->pagination_links);
        }
    }
    // Return object
    return apply_filters('bbp_has_replies', $bbp->reply_query->have_posts(), $bbp->reply_query);
}
예제 #4
0
파일: secret.php 프로젝트: 082net/bbpresskr
 static function protected_title_format($format, $post)
 {
     if (in_array(get_post_type($post), array(bbp_get_topic_post_type(), bbp_get_reply_post_type()))) {
         return '%s';
     }
     // return __( '<span class="protected_title_format">Protected:</span> %s', 'bbpresskr' );
     return $format;
 }
예제 #5
0
/**
 * Remove the meta box from some post types.
 *
 * @since 1.3.0
 * @param string $post_type The post type of the current post being edited.
 * @param object $post The current post being edited.
 * @return void
 */
function hybrid_meta_box_post_remove_seo($post_type, $post)
{
    /* Removes post stylesheets support of the bbPress 'topic' post type. */
    if (function_exists('bbp_get_topic_post_type') && bbp_get_topic_post_type() == $post_type) {
        remove_meta_box('hybrid-core-post-seo', bbp_get_topic_post_type(), 'normal');
    } elseif (function_exists('bbp_get_reply_post_type') && bbp_get_reply_post_type() == $post_type) {
        remove_meta_box('hybrid-core-post-seo', bbp_get_reply_post_type(), 'normal');
    }
}
예제 #6
0
 function register_bb_custom_sidebar_mb()
 {
     if (!function_exists('bbp_get_topic_post_type') || !function_exists('bbp_get_forum_post_type') || !function_exists('bbp_get_reply_post_type')) {
         return;
     }
     $options = array('id' => 'circleflip-custom-sidebar-page', 'title' => 'Custom Sidebar', 'callback' => 'render_page_custom_sidebar_mb', 'context' => 'normal', 'priority' => 'high', 'callback_args' => NULL);
     extract($options);
     add_meta_box($id, $title, $callback, bbp_get_topic_post_type(), $context, $priority, $callback_args);
     add_meta_box($id, $title, $callback, bbp_get_forum_post_type(), $context, $priority, $callback_args);
     add_meta_box($id, $title, $callback, bbp_get_reply_post_type(), $context, $priority, $callback_args);
 }
        function widget($args, $instance)
        {
            extract($args, EXTR_SKIP);
            $title = !empty($instance['title']) ? $instance['title'] : __('Recent Topics');
            $title = apply_filters('widget_title', $title, $instance, $this->id_base);
            $number = !empty($instance['number']) ? absint($instance['number']) : 5;
            $orderby = !empty($instance['number']) ? strip_tags($instance['order_by']) : 'newness';
            if ($orderby == 'newness') {
                $cb_meta_key = $cb_order_by = NULL;
            } elseif ($orderby == 'popular') {
                $cb_meta_key = '_bbp_reply_count';
                $cb_order_by = 'meta_value';
            } elseif ($orderby == 'freshness') {
                $cb_meta_key = '_bbp_last_active_time';
                $cb_order_by = 'meta_value';
            }
            if (!$number) {
                $number = 5;
            }
            $cb_qry = new WP_Query(array('post_type' => bbp_get_topic_post_type(), 'post_status' => array(bbp_get_public_status_id(), bbp_get_closed_status_id()), 'order' => 'DESC', 'posts_per_page' => $number, 'ignore_sticky_posts' => true, 'no_found_rows' => true, 'meta_key' => $cb_meta_key, 'orderby' => $cb_order_by));
            echo $before_widget;
            echo $before_title . $title . $after_title;
            ?>
            <ul class="cb-bbp-recent-topics">

                <?php 
            while ($cb_qry->have_posts()) {
                $cb_qry->the_post();
                ?>

                    <li>

                        <?php 
                $cb_reply_id = bbp_get_reply_id($cb_qry->post->ID);
                $cb_reply_url = '<a class="bbp-reply-topic-title" href="' . esc_url(bbp_get_reply_url($cb_reply_id)) . '" title="' . esc_attr(bbp_get_reply_excerpt($cb_reply_id, 50)) . '">' . bbp_get_reply_topic_title($cb_reply_id) . '</a>';
                $cb_number_replies = bbp_get_topic_reply_count($cb_reply_id);
                $cb_author_avatar = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'avatar', 'size' => 60));
                $cb_author_name = bbp_get_reply_author_link(array('post_id' => $cb_reply_id, 'type' => 'name'));
                echo $cb_author_avatar . '<div class="cb-bbp-meta">' . $cb_reply_url . '<div class="cb-bbp-byline">' . __('Started by', 'cubell') . ' ' . $cb_author_name . ' <i class="icon-long-arrow-right"></i> ' . $cb_number_replies . ' replies</div></div>';
                ?>

                    </li>

                <?php 
            }
            ?>

            </ul>

<?php 
            echo $after_widget;
            // Reset the $post global
            wp_reset_postdata();
        }
예제 #8
0
/**
 * Remove the meta box from some post types.
 *
 * @since  1.3.0
 * @access public
 * @param  string $post_type The post type of the current post being edited.
 * @param  object $post      The current post being edited.
 * @return void
 */
function hybrid_meta_box_post_remove_template($post_type, $post)
{
    /* Removes meta box from pages since this is a built-in WordPress feature. */
    if ('page' == $post_type) {
        remove_meta_box('hybrid-core-post-template', 'page', 'side');
    } elseif (function_exists('bbp_get_topic_post_type') && bbp_get_topic_post_type() == $post_type) {
        remove_meta_box('hybrid-core-post-template', bbp_get_topic_post_type(), 'side');
    } elseif (function_exists('bbp_get_reply_post_type') && bbp_get_reply_post_type() == $post_type) {
        remove_meta_box('hybrid-core-post-template', bbp_get_reply_post_type(), 'side');
    }
}
예제 #9
0
/**
 * Removes post stylesheets support for certain post types created by plugins.
 *
 * @since 1.0
 * @access public
 * @return void
 */
function post_stylesheets_remove_post_type_support()
{
    /* Removes post stylesheets support of the bbPress 'topic' post type. */
    if (function_exists('bbp_get_topic_post_type')) {
        remove_post_type_support(bbp_get_topic_post_type(), 'post-stylesheets');
    }
    /* Removes post stylesheets support of the bbPress 'reply' post type. */
    if (function_exists('bbp_get_reply_post_type')) {
        remove_post_type_support(bbp_get_reply_post_type(), 'post-stylesheets');
    }
}
예제 #10
0
파일: reply.php 프로젝트: 082net/bbpresskr
 public static function comments_template($file)
 {
     global $post;
     if (get_post_type($post->ID) != bbp_get_topic_post_type()) {
         return $file;
     }
     $open = comments_open($post->ID);
     if (!$open) {
         return BBPKR_PATH . '/templates/blank-comments.php';
     }
     return $file;
 }
예제 #11
0
 /**
  * @covers ::bbp_topic_post_type
  * @covers ::bbp_get_topic_post_type
  */
 public function test_bbp_topic_post_type()
 {
     $t = $this->factory->topic->create();
     $tobj = get_post_type_object('topic');
     $this->assertInstanceOf('stdClass', $tobj);
     $this->assertEquals('topic', $tobj->name);
     // Test some defaults
     $this->assertFalse(is_post_type_hierarchical('topic'));
     $topic_type = bbp_topic_post_type($t);
     $this->expectOutputString('topic', $topic_type);
     $topic_type = bbp_get_topic_post_type($t);
     $this->assertSame('topic', $topic_type);
 }
예제 #12
0
function bbpvotes_buddypress_voted_activity($post_id, $user_id, $vote)
{
    //check vote value
    if (is_bool($vote) === false) {
        return new WP_Error('vote_is_not_bool', __('Vote is not a boolean', 'bbpvotes'));
    }
    $voteplus = $vote === true;
    $voteminus = $vote === false;
    $post = get_post($post_id);
    $user_link = bbp_get_user_profile_link($user_id);
    //build item link
    if ($post->post_type == bbp_get_topic_post_type()) {
        $topic_id = $post->ID;
        $post_permalink = get_permalink($post->ID);
    } elseif ($post->post_type == bbp_get_reply_post_type()) {
        $topic_id = bbp_get_reply_topic_id($post->ID);
        $post_permalink = bbp_get_reply_url($post->ID);
    }
    //topic infos
    $topic = get_post($topic_id);
    $topic_author_link = bbp_get_user_profile_link($topic->post_author);
    $topic_title = $topic->post_title;
    $post_link = '<a href="' . $post_permalink . '">' . $topic_title . '</a>';
    if ($voteplus) {
        $type = 'bbpvotes_voted_up';
        if ($post->post_type == bbp_get_topic_post_type()) {
            $action = sprintf(esc_html__('%1$s voted up to the topic %2$s by %3$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        } elseif ($post->post_type == bbp_get_reply_post_type()) {
            $action = sprintf(esc_html__('%1$s voted up to a reply by %3$s in the topic %2$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        }
    } else {
        $type = 'bbpvotes_voted_down';
        if ($post->post_type == bbp_get_topic_post_type()) {
            $action = sprintf(esc_html__('%1$s voted down to the topic %2$s by %3$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        } elseif ($post->post_type == bbp_get_reply_post_type()) {
            $action = sprintf(esc_html__('%1$s voted down to a reply by %3$s in the topic %2$s', 'bbpress'), $user_link, $post_link, $topic_author_link);
        }
    }
    $args = array('action' => $action, 'component' => 'bbpress', 'type' => $type, 'item_id' => $topic->ID);
    if ($post->post_type == bbp_get_reply_post_type()) {
        $args['secondary_item_id'] = $post->ID;
    }
    /*
        if ($is_update){
       $previous_activity_id = 
       $args['id'] = $previous_activity_id;
        }
    */
    bp_activity_add($args);
}
예제 #13
0
파일: meta.php 프로젝트: 082net/bbpresskr
 static function setup_actions()
 {
     if (!is_admin()) {
         add_action('bbp_theme_after_topic_form_content', array(__CLASS__, 'print_meta_fields'));
         add_action('bbpkr_' . bbp_get_topic_post_type() . '_list_custom_column', array(__CLASS__, 'meta_column'), 10, 2);
         add_action('bbpkr_' . bbp_get_topic_post_type() . '_list_columns', array(__CLASS__, 'meta_columns'), 10, 2);
     } elseif (!defined('DOING_AJAX') || !DOING_AJAX) {
         // bbp_new_topic_post_extras, bbp_edit_topic_post_extras
         // add_action( 'bbp_new_topic_post_extras', array(__CLASS__, 'update_bbpmeta') );
         // add_action( 'bbp_edit_topic_post_extras', array(__CLASS__, 'update_bbpmeta') );
         add_action('save_post_' . bbp_get_topic_post_type(), array(__CLASS__, 'update_bbpmeta'));
         add_action('add_meta_boxes_' . bbp_get_topic_post_type(), array(__CLASS__, 'add_meta_box'));
     }
 }
function gpbbp_new_post($post_id, $post, $update)
{
    $TOPIC_POST_TYPE = bbp_get_topic_post_type();
    $REPLY_POST_TYPE = bbp_get_reply_post_type();
    $post_type = get_post_type($post);
    $forum_id = NULL;
    if ($post_type == $TOPIC_POST_TYPE) {
        $forum_id = wp_get_post_parent_id($post_id);
        gpbbp_apply_capabilities_from_forum($post_id, $forum_id);
    }
    if ($post_type == $REPLY_POST_TYPE) {
        $forum_id = bbp_get_forum_id();
        gpbbp_apply_capabilities_from_forum($post_id, $forum_id);
    }
    gpbbp_new_post_notification($post_id, $post, $post_type);
}
예제 #15
0
 /**
  * bbPress post types.
  *
  * @since 150821 Improving bbPress support.
  *
  * @return array All bbPress post types.
  */
 public function bbPressPostTypes()
 {
     if (!$this->isBbPressActive()) {
         return [];
     }
     if (!is_null($types =& $this->cacheKey('bbPressPostTypes'))) {
         return $types;
         // Already did this.
     }
     $types = [];
     // Initialize.
     $types[] = bbp_get_forum_post_type();
     $types[] = bbp_get_topic_post_type();
     $types[] = bbp_get_reply_post_type();
     return $types;
 }
예제 #16
0
 /**
  * @covers ::bbp_clean_post_cache
  */
 public function test_bbp_clean_post_cache()
 {
     // Get the topic post type.
     $tpt = bbp_get_topic_post_type();
     // Set up a forum with 1 topic and 1 reply to that topic.
     $f = $this->factory->forum->create();
     $t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
     $r = $this->factory->topic->create(array('post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
     // Make sure we've cached some data.
     bbp_get_all_child_ids($f, $tpt);
     bbp_get_all_child_ids($t, $tpt);
     $this->assertEquals(array($t), wp_cache_get("bbp_parent_all_{$f}_type_{$tpt}_child_ids", 'bbpress_posts'));
     $this->assertEquals(array($r), wp_cache_get("bbp_parent_all_{$t}_type_{$tpt}_child_ids", 'bbpress_posts'));
     // Clean the cache.
     bbp_clean_post_cache($r);
     $this->assertEquals(false, wp_cache_get("bbp_parent_all_{$f}_type_{$tpt}_child_ids", 'bbpress_posts'));
     $this->assertEquals(false, wp_cache_get("bbp_parent_all_{$t}_type_{$tpt}_child_ids", 'bbpress_posts'));
 }
예제 #17
0
 /**
  * @covers ::bbp_topic_post_type
  * @covers ::bbp_get_topic_post_type
  */
 public function test_bbp_topic_post_type()
 {
     $t = $this->factory->topic->create();
     $tobj = get_post_type_object('topic');
     // WordPress 4.6 introduced `WP_Post_Type` class
     if (bbp_get_major_wp_version() < 4.6) {
         $this->assertInstanceOf('stdClass', $tobj);
     } else {
         $this->assertInstanceOf('WP_Post_Type', $tobj);
     }
     $this->assertEquals('topic', $tobj->name);
     // Test some defaults
     $this->assertFalse(is_post_type_hierarchical('topic'));
     $topic_type = bbp_topic_post_type($t);
     $this->expectOutputString('topic', $topic_type);
     $topic_type = bbp_get_topic_post_type($t);
     $this->assertSame('topic', $topic_type);
 }
예제 #18
0
function check_private_groups_topic_ids($post_ids)
{
    //Init the Array which will hold our list of allowed posts
    $allowed_posts = array();
    //Loop through all the posts
    foreach ($post_ids as $post_id) {
        //Get the Forum ID based on Post Type Topic
        $topic = bbp_get_topic_post_type();
        $forum_id = private_groups_get_forum_id_from_post_id($post_id, $topic);
        //Check if User has permissions to view this Post ID
        //by calling the function that checks if the user can view this forum, and hence this post
        if (private_groups_can_user_view_post_id($forum_id)) {
            //User can view this post - add it to the allowed array
            array_push($allowed_posts, $post_id);
        }
    }
    //Return the list
    return $allowed_posts;
}
예제 #19
0
 static function nav_menu_css_class($classes, $item, $args, $depth)
 {
     if ($item->object == bbp_get_forum_post_type() && is_bbpress()) {
         if (bbp_is_topic_edit() || bbp_is_single_topic()) {
             $forum_id = bbp_get_topic_forum_id();
             if ($forum_id == $item->object_id) {
                 $classes[] = 'current-menu-parent';
                 $classes[] = 'current-' . bbp_get_topic_post_type() . '-parent';
             } elseif ($ancestors = self::forum_ancestors($forum_id, array())) {
                 if (in_array($item->object_id, $ancestors)) {
                     $classes[] = 'current-menu-ancestor';
                     $classes[] = 'current-' . bbp_get_topic_post_type() . '-ancestor';
                 }
             }
         } elseif (bbp_is_reply_edit() || bbp_is_single_reply()) {
             $forum_id = bbp_get_reply_forum_id();
         }
     }
     return $classes;
 }
 function bbpress_topicslist_settings_field($settings, $value)
 {
     $dependency = vc_generate_dependencies_attributes($settings);
     $param_name = isset($settings['param_name']) ? $settings['param_name'] : '';
     $type = isset($settings['type']) ? $settings['type'] : '';
     $args = array('post_type' => bbp_get_topic_post_type(), 'orderby' => 'title', 'order' => 'ASC');
     $forums = new WP_Query($args);
     $output = '';
     $output .= '<select name="' . $settings['param_name'] . '" class="wpb_vc_param_value wpb-input wpb-select ' . $settings['param_name'] . ' ' . $settings['type'] . '">';
     while ($forums->have_posts()) {
         $forums->the_post();
         if ($value != '' && get_the_ID() == $value) {
             $selected = ' selected="selected"';
         } else {
             $selected = "";
         }
         $output .= '<option class="' . get_the_ID() . '" data-id="' . get_the_ID() . '" data-value="' . get_the_title() . '" value="' . get_the_ID() . '"' . $selected . '>' . get_the_title() . '</option>';
     }
     wp_reset_query();
     $output .= '</select>';
     return $output;
 }
function tehnik_bpp_get_forum_id_from_post_id($post_id, $post_type)
{
    $forum_id = 0;
    // Check post type
    switch ($post_type) {
        // Forum
        case bbp_get_forum_post_type():
            $forum_id = bbp_get_forum_id($post_id);
            break;
            // Topic
        // Topic
        case bbp_get_topic_post_type():
            $forum_id = bbp_get_topic_forum_id($post_id);
            break;
            // Reply
        // Reply
        case bbp_get_reply_post_type():
            $forum_id = bbp_get_reply_forum_id($post_id);
            break;
    }
    return $forum_id;
}
예제 #22
0
 /**
  * Ajax action for facilitating the forum auto-suggest
  *
  * @since bbPress (r4261)
  *
  * @uses get_posts()
  * @uses bbp_get_topic_post_type()
  * @uses bbp_get_topic_id()
  * @uses bbp_get_topic_title()
  */
 public function suggest_topic()
 {
     global $wpdb;
     // Bail early if no request
     if (empty($_REQUEST['q'])) {
         wp_die('0');
     }
     // Bail if user cannot moderate - only moderators can change hierarchy
     if (!current_user_can('moderate')) {
         wp_die('0');
     }
     // Check the ajax nonce
     check_ajax_referer('bbp_suggest_topic_nonce');
     // Try to get some topics
     $topics = get_posts(array('s' => $wpdb->esc_like($_REQUEST['q']), 'post_type' => bbp_get_topic_post_type()));
     // If we found some topics, loop through and display them
     if (!empty($topics)) {
         foreach ((array) $topics as $post) {
             printf(esc_html__('%s - %s', 'bbpress'), bbp_get_topic_id($post->ID), bbp_get_topic_title($post->ID) . "\n");
         }
     }
     die;
 }
							<?php 
    if (bbp_has_topics(array('show_stickies' => false, 'post_parent' => bbp_get_reply_forum_id(bbp_get_reply_id()), 'post__not_in' => array(bbp_get_reply_topic_id(bbp_get_reply_id()))))) {
        ?>

								<div>
									<input name="bbp_reply_move_option" id="bbp_reply_move_option_existing" type="radio" value="existing" tabindex="<?php 
        bbp_tab_index();
        ?>
" />
									<label for="bbp_reply_move_option_existing"><?php 
        _e('Use an existing topic in this forum:', 'bbpress');
        ?>
</label>

									<?php 
        bbp_dropdown(array('post_type' => bbp_get_topic_post_type(), 'post_parent' => bbp_get_reply_forum_id(bbp_get_reply_id()), 'selected' => -1, 'exclude' => bbp_get_reply_topic_id(bbp_get_reply_id()), 'select_id' => 'bbp_destination_topic'));
        ?>

								</div>

							<?php 
    }
    ?>

						</fieldset>

						<div class="bbp-template-notice error">
							<p><?php 
    _e('<strong>WARNING:</strong> This process cannot be undone.', 'bbpress');
    ?>
</p>
예제 #24
0
/**
 * Output a select box allowing to pick which forum/topic a new
 * topic/reply belongs in.
 *
 * @since bbPress (r2746)
 *
 * @param mixed $args The function supports these args:
 *  - post_type: Post type, defaults to bbp_get_forum_post_type() (bbp_forum)
 *  - selected: Selected ID, to not have any value as selected, pass
 *               anything smaller than 0 (due to the nature of select
 *               box, the first value would of course be selected -
 *               though you can have that as none (pass 'show_none' arg))
 *  - orderby: Defaults to 'menu_order title'
 *  - post_parent: Post parent. Defaults to 0
 *  - post_status: Which all post_statuses to find in? Can be an array
 *                  or CSV of publish, category, closed, private, spam,
 *                  trash (based on post type) - if not set, these are
 *                  automatically determined based on the post_type
 *  - posts_per_page: Retrieve all forums/topics. Defaults to -1 to get
 *                     all posts
 *  - walker: Which walker to use? Defaults to
 *             {@link BBP_Walker_Dropdown}
 *  - select_id: ID of the select box. Defaults to 'bbp_forum_id'
 *  - tab: Tabindex value. False or integer
 *  - options_only: Show only <options>? No <select>?
 *  - show_none: False or something like __( '(No Forum)', 'bbpress' ),
 *                will have value=""
 *  - none_found: False or something like
 *                 __( 'No forums to post to!', 'bbpress' )
 *  - disable_categories: Disable forum categories and closed forums?
 *                         Defaults to true. Only for forums and when
 *                         the category option is displayed.
 * @uses BBP_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_forum_post_type() To get the forum post type
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses walk_page_dropdown_tree() To generate the dropdown using the
 *                                  walker
 * @uses apply_filters() Calls 'bbp_get_dropdown' with the dropdown
 *                        and args
 * @return string The dropdown
 */
function stachestack_bbp_get_dropdown($args = '')
{
    /** Arguments *********************************************************/
    // Parse arguments against default values
    $r = bbp_parse_args($args, array('post_type' => bbp_get_forum_post_type(), 'post_parent' => null, 'post_status' => null, 'selected' => 0, 'exclude' => array(), 'numberposts' => -1, 'orderby' => 'menu_order title', 'order' => 'ASC', 'walker' => '', 'select_id' => 'bbp_forum_id', 'tab' => bbp_get_tab_index(), 'options_only' => false, 'show_none' => false, 'none_found' => false, 'disable_categories' => true, 'disabled' => ''), 'get_dropdown');
    if (empty($r['walker'])) {
        $r['walker'] = new BBP_Walker_Dropdown();
        $r['walker']->tree_type = $r['post_type'];
    }
    // Force 0
    if (is_numeric($r['selected']) && $r['selected'] < 0) {
        $r['selected'] = 0;
    }
    // Force array
    if (!empty($r['exclude']) && !is_array($r['exclude'])) {
        $r['exclude'] = explode(',', $r['exclude']);
    }
    /** Setup variables ***************************************************/
    $retval = '';
    $posts = get_posts(array('post_type' => $r['post_type'], 'post_status' => $r['post_status'], 'exclude' => $r['exclude'], 'post_parent' => $r['post_parent'], 'numberposts' => $r['numberposts'], 'orderby' => $r['orderby'], 'order' => $r['order'], 'walker' => $r['walker'], 'disable_categories' => $r['disable_categories']));
    /** Drop Down *********************************************************/
    // Items found
    if (!empty($posts)) {
        // Build the opening tag for the select element
        if (empty($r['options_only'])) {
            // Should this select appear disabled?
            $disabled = disabled(isset(bbpress()->options[$r['disabled']]), true, false);
            // Setup the tab index attribute
            $tab = !empty($r['tab']) ? ' tabindex="' . intval($r['tab']) . '"' : '';
            // Build the opening tag
            $retval .= '<select class="form-control" name="' . esc_attr($r['select_id']) . '" id="' . esc_attr($r['select_id']) . '"' . $disabled . $tab . '>' . "\n";
        }
        // Get the options
        $retval .= !empty($r['show_none']) ? "\t<option value=\"\" class=\"level-0\">" . esc_html($r['show_none']) . '</option>' : '';
        $retval .= walk_page_dropdown_tree($posts, 0, $r);
        // Build the closing tag for the select element
        if (empty($r['options_only'])) {
            $retval .= '</select>';
        }
        // No items found - Display feedback if no custom message was passed
    } elseif (empty($r['none_found'])) {
        // Switch the response based on post type
        switch ($r['post_type']) {
            // Topics
            case bbp_get_topic_post_type():
                $retval = __('No topics available', 'bbpress');
                break;
                // Forums
            // Forums
            case bbp_get_forum_post_type():
                $retval = __('No forums available', 'bbpress');
                break;
                // Any other
            // Any other
            default:
                $retval = __('None available', 'bbpress');
                break;
        }
    }
    return apply_filters('bbp_get_dropdown', $retval, $r);
}
    ?>
</p>
					</div>
					<h4><?php 
    _e('Destination', 'bbpress');
    ?>
</h4>
					<?php 
    if (bbp_has_topics(array('show_stickies' => false, 'post_parent' => bbp_get_topic_forum_id(bbp_get_topic_id()), 'post__not_in' => array(bbp_get_topic_id())))) {
        ?>
						<label for="bbp_destination_topic"><?php 
        _e('Merge with this topic:', 'bbpress');
        ?>
</label>
						<?php 
        bbp_dropdown(array('post_type' => bbp_get_topic_post_type(), 'post_parent' => bbp_get_topic_forum_id(bbp_get_topic_id()), 'selected' => -1, 'exclude' => bbp_get_topic_id(), 'select_id' => 'bbp_destination_topic', 'none_found' => __('No topics were found to which the topic could be merged to!', 'bbpress')));
        ?>
					<?php 
    } else {
        ?>
						<p class="alert alert-danger"><?php 
        _e('There are no other topics in this forum to merge with.', 'bbpress');
        ?>
</p>
					<?php 
    }
    ?>

					<h4><?php 
    _e('Topic Extras', 'bbpress');
    ?>
예제 #26
0
파일: tools.php 프로젝트: joeyblake/bbpress
/**
 * Handle the processing and feedback of the admin tools page
 *
 * @since 2.0.0 bbPress (r2613)
 *
 * @uses check_admin_referer() To verify the nonce and the referer
 * @uses wp_cache_flush() To flush the cache
 * @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 bbp_admin_reset_handler()
{
    // Bail if not resetting
    if (!bbp_is_post_request() || empty($_POST['bbpress-are-you-sure'])) {
        return;
    }
    // Only keymasters can proceed
    if (!bbp_is_user_keymaster()) {
        return;
    }
    check_admin_referer('bbpress-reset');
    // Stores messages
    $messages = array();
    $failed = __('Failed!', 'bbpress');
    $success = __('Success!', 'bbpress');
    // Flush the cache; things are about to get ugly.
    wp_cache_flush();
    /** Posts *****************************************************************/
    // Post types and status
    $fpt = bbp_get_forum_post_type();
    $tpt = bbp_get_topic_post_type();
    $rpt = bbp_get_reply_post_type();
    // Define variables
    $bbp_db = bbp_db();
    $statement = __('Deleting Posts&hellip; %s', 'bbpress');
    $sql_posts = $bbp_db->get_results("SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` IN ('{$fpt}', '{$tpt}', '{$rpt}')", OBJECT_K);
    $sql_delete = "DELETE FROM `{$bbp_db->posts}` WHERE `post_type` IN ('{$fpt}', '{$tpt}', '{$rpt}')";
    $result = is_wp_error($bbp_db->query($sql_delete)) ? $failed : $success;
    $messages[] = sprintf($statement, $result);
    /** Post Meta *************************************************************/
    if (!empty($sql_posts)) {
        $sql_meta = array();
        foreach ($sql_posts as $key => $value) {
            $sql_meta[] = $key;
        }
        $statement = __('Deleting Post Meta&hellip; %s', 'bbpress');
        $sql_meta = implode("', '", $sql_meta);
        $sql_delete = "DELETE FROM `{$bbp_db->postmeta}` WHERE `post_id` IN ('{$sql_meta}');";
        $result = is_wp_error($bbp_db->query($sql_delete)) ? $failed : $success;
        $messages[] = sprintf($statement, $result);
    }
    /** Forum moderators ******************************************************/
    $statement = __('Deleting Forum Moderators&hellip; %s', 'bbpress');
    $sql_delete = "DELETE a,b,c FROM `{$bbp_db->terms}` AS a LEFT JOIN `{$bbp_db->term_taxonomy}` AS c ON a.term_id = c.term_id LEFT JOIN `{$bbp_db->term_relationships}` AS b ON b.term_taxonomy_id = c.term_taxonomy_id WHERE c.taxonomy = 'forum-mod';";
    $result = is_wp_error($bbp_db->query($sql_delete)) ? $failed : $success;
    $messages[] = sprintf($statement, $result);
    /** Topic Tags ************************************************************/
    $statement = __('Deleting Topic Tags&hellip; %s', 'bbpress');
    $sql_delete = "DELETE a,b,c FROM `{$bbp_db->terms}` AS a LEFT JOIN `{$bbp_db->term_taxonomy}` AS c ON a.term_id = c.term_id LEFT JOIN `{$bbp_db->term_relationships}` AS b ON b.term_taxonomy_id = c.term_taxonomy_id WHERE c.taxonomy = 'topic-tag';";
    $result = is_wp_error($bbp_db->query($sql_delete)) ? $failed : $success;
    $messages[] = sprintf($statement, $result);
    /** User ******************************************************************/
    // First, if we're deleting previously imported users, delete them now
    if (!empty($_POST['bbpress-delete-imported-users'])) {
        $sql_users = $bbp_db->get_results("SELECT `user_id` FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '_bbp_user_id'", OBJECT_K);
        if (!empty($sql_users)) {
            $sql_meta = array();
            foreach ($sql_users as $key => $value) {
                $sql_meta[] = $key;
            }
            $statement = __('Deleting User&hellip; %s', 'bbpress');
            $sql_meta = implode("', '", $sql_meta);
            $sql_delete = "DELETE FROM `{$bbp_db->users}` WHERE `ID` IN ('{$sql_meta}');";
            $result = is_wp_error($bbp_db->query($sql_delete)) ? $failed : $success;
            $messages[] = sprintf($statement, $result);
            $statement = __('Deleting User Meta&hellip; %s', 'bbpress');
            $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `user_id` IN ('{$sql_meta}');";
            $result = is_wp_error($bbp_db->query($sql_delete)) ? $failed : $success;
            $messages[] = sprintf($statement, $result);
        }
    }
    // Next, if we still have users that were not imported delete that meta data
    $statement = __('Deleting User Meta&hellip; %s', 'bbpress');
    $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `meta_key` LIKE '%%_bbp_%%';";
    $result = is_wp_error($bbp_db->query($sql_delete)) ? $failed : $success;
    $messages[] = sprintf($statement, $result);
    /** Converter *************************************************************/
    $statement = __('Deleting Conversion Table&hellip; %s', 'bbpress');
    $table_name = $bbp_db->prefix . 'bbp_converter_translator';
    if ($bbp_db->get_var("SHOW TABLES LIKE '{$table_name}'") === $table_name) {
        $bbp_db->query("DROP TABLE {$table_name}");
        $result = $success;
    } else {
        $result = $failed;
    }
    $messages[] = sprintf($statement, $result);
    /** Options ***************************************************************/
    $statement = __('Deleting Settings&hellip; %s', 'bbpress');
    bbp_delete_options();
    $messages[] = sprintf($statement, $success);
    /** Roles *****************************************************************/
    $statement = __('Deleting Roles and Capabilities&hellip; %s', 'bbpress');
    bbp_remove_roles();
    bbp_remove_caps();
    $messages[] = sprintf($statement, $success);
    /** Output ****************************************************************/
    if (count($messages)) {
        foreach ($messages as $message) {
            bbp_admin_tools_feedback($message);
        }
    }
}
예제 #27
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);
}
예제 #28
0
/**
 * Adjust the total anonymous reply count of a topic
 *
 * @since bbPress (r2567)
 *
 * @param int $topic_id Optional. Topic id to update
 * @uses bbp_is_reply() To check if the passed topic id is a reply
 * @uses bbp_get_reply_topic_id() To get the reply topic id
 * @uses bbp_get_topic_id() To get the topic id
 * @uses bbp_get_reply_topic_id() To get the reply topic id
 * @uses bbp_get_reply_post_type() To get the reply post type
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses wpdb::prepare() To prepare our sql query
 * @uses wpdb::get_col() To execute our query and get the column back
 * @uses update_post_meta() To update the topic anonymous reply count meta
 * @uses apply_filters() Calls 'bbp_update_topic_anonymous_reply_count' with the
 *                        anonymous reply count and topic id
 * @return int Anonymous reply count
 */
function bbp_update_topic_anonymous_reply_count($topic_id = 0)
{
    global $wpdb;
    // If it's a reply, then get the parent (topic id)
    if (bbp_is_reply($topic_id)) {
        $topic_id = bbp_get_reply_topic_id($topic_id);
    } elseif (bbp_is_topic($topic_id)) {
        $topic_id = bbp_get_topic_id($topic_id);
    } else {
        return;
    }
    $anonymous_replies = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT( ID ) FROM {$wpdb->posts} WHERE ( post_parent = %d AND post_status = '%s' AND post_type = '%s' AND post_author = 0 ) OR ( ID = %d AND post_type = '%s' AND post_author = 0 );", $topic_id, bbp_get_public_status_id(), bbp_get_reply_post_type(), $topic_id, bbp_get_topic_post_type()));
    update_post_meta($topic_id, '_bbp_anonymous_reply_count', (int) $anonymous_replies);
    return apply_filters('bbp_update_topic_anonymous_reply_count', (int) $anonymous_replies, $topic_id);
}
예제 #29
0
							<?php 
    if (bbp_has_topics(array('show_stickies' => false, 'post_parent' => bbp_get_topic_forum_id(bbp_get_topic_id()), 'post__not_in' => array(bbp_get_topic_id())))) {
        ?>

								<div>
									<input name="bbp_topic_split_option" id="bbp_topic_split_option_existing" type="radio" value="existing" tabindex="<?php 
        bbp_tab_index();
        ?>
" />
									<label for="bbp_topic_split_option_existing"><?php 
        _e('Use an existing topic in this forum:', 'bbpress');
        ?>
</label>

									<?php 
        bbp_dropdown(array('post_type' => bbp_get_topic_post_type(), 'post_parent' => bbp_get_topic_forum_id(bbp_get_topic_id()), 'selected' => -1, 'exclude' => bbp_get_topic_id(), 'select_id' => 'bbp_destination_topic', 'none_found' => __('No other topics found!', 'bbpress')));
        ?>

								</div>

							<?php 
    }
    ?>

						</fieldset>

						<fieldset class="bbp-form">
							<legend><?php 
    _e('Topic Extras', 'bbpress');
    ?>
</legend>
예제 #30
0
/**
 * Get the topic merge template
 *
 * @since bbPress (r3311)
 *
 * @uses bbp_get_topic_post_type()
 * @uses bbp_get_query_template()
 * @return string Path to template file
 */
function bbp_get_topic_merge_template()
{
    $templates = array('single-' . bbp_get_topic_post_type() . '-merge.php');
    return bbp_get_query_template('topic_merge', $templates);
}