</div>

	<?php 
}
?>

	<?php 
bbp_forum_subscription_link();
?>

	<?php 
do_action('bbp_template_before_forums_index');
?>

	<?php 
if (bbp_has_forums()) {
    ?>

		<?php 
    bbp_get_template_part('loop', 'forums');
    ?>

	<?php 
} else {
    ?>

		<?php 
    bbp_get_template_part('feedback', 'no-forums');
    ?>

	<?php 
Example #2
0
function crystalskull_my_scripts()
{
    wp_register_script('bootstrap1', get_template_directory_uri() . '/js/bootstrap.min.js', '', '', true);
    wp_enqueue_script('bootstrap1');
    if (of_get_option('appear') == 1) {
        wp_register_script('custom_js2', get_template_directory_uri() . '/js/appear-img.js', '', '', true);
        wp_enqueue_script('custom_js2');
    }
    if (function_exists('bbp_has_forums')) {
        if (bbp_has_forums()) {
            wp_register_script('bbpress_title_fix', get_template_directory_uri() . '/js/bbpress_title_fix.js', '', '', true);
            wp_enqueue_script('bbpress_title_fix');
        }
    }
    wp_register_script('fancybox', get_template_directory_uri() . '/js/jquery.fancybox.js', '', '', true);
    wp_enqueue_script('fancybox');
    wp_register_script('custom_js3', get_template_directory_uri() . '/js/jquery-ui-1.10.3.custom.min.js', '', '', true);
    wp_enqueue_script('custom_js3');
    wp_register_script('custom_js4', get_template_directory_uri() . '/js/jquery.carouFredSel-6.2.1-packed.js', '', '', true);
    wp_enqueue_script('custom_js4');
    wp_register_script('custom_js7', get_template_directory_uri() . '/js/jquery.webticker.js', '', '', true);
    wp_enqueue_script('custom_js7');
    wp_register_script('custom_js9', get_template_directory_uri() . '/js/isotope.js', '', '', true);
    wp_enqueue_script('custom_js9');
    wp_register_script('custom_js10', get_template_directory_uri() . '/js/imagesloaded.min.js', '', '', true);
    wp_enqueue_script('custom_js10');
    wp_register_script('custom_js11', get_template_directory_uri() . '/js/jquery.validate.min.js', '', '', true);
    wp_enqueue_script('custom_js11');
    wp_register_script('custom_js12', get_template_directory_uri() . '/js/ps.js', '', '', true);
    wp_enqueue_script('custom_js12');
    wp_register_script('custom_js13', get_template_directory_uri() . '/js/jquery.clickoutside.js', '', '', true);
    wp_enqueue_script('custom_js13');
    wp_register_script('custom_js14', get_template_directory_uri() . '/js/inview.js', '', '', true);
    wp_enqueue_script('custom_js14');
    wp_register_script('custom_js99', get_template_directory_uri() . '/js/global.js', array('fancybox', 'jquery'), '', true);
    wp_enqueue_script('custom_js99');
    wp_enqueue_script('owl-carousel', get_template_directory_uri() . '/addons/wp-owl-carousel/owl-carousel/owl.carousel.min.js', array('jquery'), '', true);
    wp_enqueue_script('wp-owl-carousel', get_template_directory_uri() . '/addons/wp-owl-carousel/js/wp-owl-carousel.js', array('owl-carousel'), '', true);
}
	<?php 
} else {
    ?>

		<?php 
    //bbp_single_forum_description();
    ?>
        
        
        <div class="bbp-forum-content panel panel-default"><div class="panel-body"><?php 
    bbp_forum_content();
    ?>
</div></div>

		<?php 
    if (bbp_get_forum_subforum_count() && bbp_has_forums()) {
        ?>

			<?php 
        bbp_get_template_part('loop', 'forums');
        ?>

		<?php 
    }
    ?>

		<?php 
    if (!bbp_is_forum_category() && bbp_has_topics()) {
        ?>

			<?php 
Example #4
0
/**
 * Get a user's subscribed forums
 *
 * @since bbPress (r5156)
 *
 * @param int $user_id Optional. User id
 * @uses bbp_get_user_subscribed_forum_ids() To get the user's subscriptions
 * @uses bbp_has_forums() To get the forums
 * @uses apply_filters() Calls 'bbp_get_user_forum_subscriptions' with the forum
 *                        query and user id
 * @return array|bool Results if user has subscriptions, otherwise false
 */
function bbp_get_user_forum_subscriptions($user_id = 0)
{
    // Default to the displayed user
    $user_id = bbp_get_user_id($user_id);
    if (empty($user_id)) {
        return false;
    }
    // If user has subscriptions, load them
    $subscriptions = bbp_get_user_subscribed_forum_ids($user_id);
    if (!empty($subscriptions)) {
        $query = bbp_has_forums(array('post__in' => $subscriptions));
    } else {
        $query = false;
    }
    return apply_filters('bbp_get_user_forum_subscriptions', $query, $user_id);
}
Example #5
0
 / <?php 
        bbp_show_lead_topic() ? _e('Replies', 'bbpress') : _e('Posts', 'bbpress');
        ?>
</li>
							<li class="normal bbp-forum-freshness"><?php 
        _e('Freshness', 'bbpress');
        ?>
</li>
						</ul>
				
					</div>

					<?php 
        // get sub-forums
        $orig_query = clone bbpress()->forum_query;
        bbp_has_forums(array('post_parent' => bbp_get_forum_id()));
        while (bbp_forums()) {
            bbp_the_forum();
            ?>
						
						<?php 
            bbp_get_template_part('loop', 'single-forum');
            ?>
											
					<?php 
        }
        // restore query
        bbpress()->forum_query = $orig_query;
        ?>
				</div>
					
<div id="bbpress-forums">

    <?php 
bbp_forum_subscription_link();
?>

    <?php 
do_action('bbp_template_before_forums_index');
?>

    <?php 
$arr_top = arreat_get_categories();
if (empty($arr_top)) {
    bbp_get_template_part('feedback', 'no-forums');
}
?>
    <?php 
foreach ($arr_top as $arr_forum) {
    if (bbp_has_forums(['post_parent' => $arr_forum->ID])) {
        include 'loop-forums.php';
    }
}
?>

    <?php 
do_action('bbp_template_after_forums_index');
?>

</div>
Example #7
0
        /**
         * Output the forums for a group in the edit screens
         *
         * As of right now, bbPress only supports 1-to-1 group forum relationships.
         * In the future, many-to-many should be allowed.
         *
         * @since bbPress (r3653)
         * @uses bp_get_current_group_id()
         * @uses bbp_get_group_forum_ids()
         * @uses bbp_has_forums()
         * @uses bbp_get_template_part()
         */
        public function display_forums($offset = 0)
        {
            global $wp_query;
            // Allow actions immediately before group forum output
            do_action('bbp_before_group_forum_display');
            // Load up bbPress once
            $bbp = bbpress();
            /** Query Resets ******************************************************/
            // Forum data
            $forum_action = bp_action_variable($offset);
            $forum_ids = bbp_get_group_forum_ids(bp_get_current_group_id());
            $forum_id = array_shift($forum_ids);
            // Always load up the group forum
            bbp_has_forums(array('p' => $forum_id, 'post_parent' => null));
            // Set the global forum ID
            $bbp->current_forum_id = $forum_id;
            // Assume forum query
            bbp_set_query_name('bbp_single_forum');
            ?>

		<div id="bbpress-forums">

			<?php 
            switch ($forum_action) {
                /** Single Forum **********************************************/
                case false:
                case 'page':
                    // Strip the super stickies from topic query
                    add_filter('bbp_get_super_stickies', array($this, 'no_super_stickies'), 10, 1);
                    // Unset the super sticky option on topic form
                    add_filter('bbp_get_topic_types', array($this, 'unset_super_sticky'), 10, 1);
                    // Query forums and show them if they exist
                    if (bbp_forums()) {
                        // Setup the forum
                        bbp_the_forum();
                        ?>

						<h3><?php 
                        bbp_forum_title();
                        ?>
</h3>

						<?php 
                        bbp_get_template_part('content', 'single-forum');
                        // No forums found
                    } else {
                        ?>

						<div id="message" class="info">
							<p><?php 
                        esc_html_e('This group does not currently have a forum.', 'bbpress');
                        ?>
</p>
						</div>

					<?php 
                    }
                    break;
                    /** Single Topic **********************************************/
                /** Single Topic **********************************************/
                case $this->topic_slug:
                    // hide the 'to front' admin links
                    add_filter('bbp_get_topic_stick_link', array($this, 'hide_super_sticky_admin_link'), 10, 2);
                    // Get the topic
                    bbp_has_topics(array('name' => bp_action_variable($offset + 1), 'posts_per_page' => 1, 'show_stickies' => false));
                    // If no topic, 404
                    if (!bbp_topics()) {
                        bp_do_404(bbp_get_forum_permalink($forum_id));
                        ?>
						<h3><?php 
                        bbp_forum_title();
                        ?>
</h3>
						<?php 
                        bbp_get_template_part('feedback', 'no-topics');
                        return;
                    }
                    // Setup the topic
                    bbp_the_topic();
                    ?>

					<h3><?php 
                    bbp_topic_title();
                    ?>
</h3>

					<?php 
                    // Topic edit
                    if (bp_action_variable($offset + 2) === bbp_get_edit_rewrite_id()) {
                        // Unset the super sticky link on edit topic template
                        add_filter('bbp_get_topic_types', array($this, 'unset_super_sticky'), 10, 1);
                        // Set the edit switches
                        $wp_query->bbp_is_edit = true;
                        $wp_query->bbp_is_topic_edit = true;
                        // Setup the global forum ID
                        $bbp->current_topic_id = get_the_ID();
                        // Merge
                        if (!empty($_GET['action']) && 'merge' === $_GET['action']) {
                            bbp_set_query_name('bbp_topic_merge');
                            bbp_get_template_part('form', 'topic-merge');
                            // Split
                        } elseif (!empty($_GET['action']) && 'split' === $_GET['action']) {
                            bbp_set_query_name('bbp_topic_split');
                            bbp_get_template_part('form', 'topic-split');
                            // Edit
                        } else {
                            bbp_set_query_name('bbp_topic_form');
                            bbp_get_template_part('form', 'topic');
                        }
                        // Single Topic
                    } else {
                        bbp_set_query_name('bbp_single_topic');
                        bbp_get_template_part('content', 'single-topic');
                    }
                    break;
                    /** Single Reply **********************************************/
                /** Single Reply **********************************************/
                case $this->reply_slug:
                    // Get the reply
                    bbp_has_replies(array('name' => bp_action_variable($offset + 1), 'posts_per_page' => 1));
                    // If no topic, 404
                    if (!bbp_replies()) {
                        bp_do_404(bbp_get_forum_permalink($forum_id));
                        ?>
						<h3><?php 
                        bbp_forum_title();
                        ?>
</h3>
						<?php 
                        bbp_get_template_part('feedback', 'no-replies');
                        return;
                    }
                    // Setup the reply
                    bbp_the_reply();
                    ?>

					<h3><?php 
                    bbp_reply_title();
                    ?>
</h3>

					<?php 
                    if (bp_action_variable($offset + 2) === bbp_get_edit_rewrite_id()) {
                        // Set the edit switches
                        $wp_query->bbp_is_edit = true;
                        $wp_query->bbp_is_reply_edit = true;
                        // Setup the global reply ID
                        $bbp->current_reply_id = get_the_ID();
                        // Move
                        if (!empty($_GET['action']) && 'move' === $_GET['action']) {
                            bbp_set_query_name('bbp_reply_move');
                            bbp_get_template_part('form', 'reply-move');
                            // Edit
                        } else {
                            bbp_set_query_name('bbp_reply_form');
                            bbp_get_template_part('form', 'reply');
                        }
                    }
                    break;
            }
            // Reset the query
            wp_reset_query();
            ?>

		</div>

		<?php 
            // Allow actions immediately after group forum output
            do_action('bbp_after_group_forum_display');
        }
                                        </div>

                                        <div
                                            class="topics_list_divider"><?php 
_e('Недавние обсуждения', 'qode');
?>
</div>

                                            
                                    <div class="topics_list" data-list="2" data-forum="<?php 
echo $forum_id;
?>
">
                                        <?php 
$isForumModerator = bbp_get_user_role(get_current_user_id()) != 'bbp_moderator' && bbp_get_user_role(get_current_user_id()) != 'bbp_keymaster';
if (bbp_has_forums($buddypress_id)) {
    $topics = false;
    while (bbp_forums()) {
        bbp_the_forum();
        if ($forum_id != bbp_get_forum_id()) {
            continue;
        }
        $topics = bbp_has_topics(array('post_parent' => $forum_id, 'posts_per_page' => 11));
        if (!$topics) {
            _e('This forum does not have topics', 'qode');
            break;
        }
        $counter = 0;
        if (bp_group_is_visible($group)) {
            global $post;
            $post = bbp_get_forum($forum_id);
<div id="bbpress-forums">


	<?php bbp_forum_subscription_link(); ?>

	<?php do_action( 'bbp_template_before_single_forum' ); ?>

	<?php if ( post_password_required() ) : ?>

		<?php bbp_get_template_part( 'form', 'protected' ); ?>

	<?php else : ?>

		<?php bbp_single_forum_description(); ?>

		<?php if ( bbp_has_forums() ) : ?>

			<?php bbp_get_template_part( 'loop', 'forums' ); ?>

		<?php endif; ?>

		<?php if ( !bbp_is_forum_category() && bbp_has_topics() ) : ?>

			<?php bbp_get_template_part( 'pagination', 'topics'    ); ?>

			<?php bbp_get_template_part( 'loop',       'topics'    ); ?>

			<?php bbp_get_template_part( 'pagination', 'topics'    ); ?>

			<?php bbp_get_template_part( 'form',       'topic'     ); ?>
Example #10
0
 /**
  * @covers ::bbp_get_user_forum_subscriptions
  */
 public function test_bbp_get_user_forum_subscriptions()
 {
     $u = $this->factory->user->create();
     $f = $this->factory->forum->create_many(3);
     // Add forum subscriptions.
     bbp_add_user_forum_subscription($u, $f[0]);
     bbp_add_user_forum_subscription($u, $f[1]);
     bbp_add_user_forum_subscription($u, $f[2]);
     $expected = bbp_has_forums(array('post__in' => array($f[0], $f[1], $f[2])));
     $subscriptions = bbp_get_user_forum_subscriptions($u);
     $this->assertEquals($expected, $subscriptions);
     // Remove forum subscription.
     bbp_remove_user_forum_subscription($u, $f[1]);
     $expected = bbp_has_forums(array('post__in' => array($f[0], $f[2])));
     $subscriptions = bbp_get_user_forum_subscriptions($u);
     $this->assertEquals($expected, $subscriptions);
 }
Example #11
0
 protected function get_views()
 {
     global $post;
     $views = array();
     if (bbp_is_forum_category() && bbp_has_forums()) {
         $views['all'] = '<a class="current bbp-forum-title" href="' . bbp_get_forum_permalink() . '">' . __('All', 'bbpresskr') . '</a>';
         while (bbp_forums()) {
             bbp_the_forum();
             $views[] = '<a class="bbp-forum-title" href="' . bbp_get_forum_permalink() . '">' . bbp_get_forum_title() . '</a>';
         }
     } else {
         $forum_id = bbp_get_forum_id();
         $forum = get_post($forum_id);
         if ($forum->post_parent && bbp_has_forums(array('post_parent' => $forum->post_parent))) {
             $views['all'] = '<a class="bbp-forum-title" href="' . bbp_get_forum_permalink($forum->post_parent) . '">' . __('All', 'bbpresskr') . '</a>';
             while (bbp_forums()) {
                 bbp_the_forum();
                 $current = $forum_id == $post->ID ? ' current' : '';
                 $views[$post->post_name] = '<a class="bbp-forum-title' . $current . '" href="' . bbp_get_forum_permalink() . '">' . bbp_get_forum_title() . '</a>';
             }
         }
     }
     return $views;
 }
<?php

/**
 * Apocrypha Theme Single Forum Contents
 * Andrew Clayton
 * Version 2.0
 * 7-23-2014
 */
?>

<?php 
// Top-level categories
if (bbp_is_forum_category() && bbp_has_forums()) {
    ?>
	<?php 
    bbp_get_template_part('loop', 'single-forum');
    ?>

<?php 
    // Single sub-forum
} elseif (!bbp_is_forum_category()) {
    ?>
	
	<?php 
    // Topics found
    if (bbp_has_topics()) {
        ?>
		<?php 
        bbp_get_template_part('loop', 'topics');
        ?>
		<?php 
Example #13
0
        /**
         * Output the forums for a group in the edit screens
         *
         * @since bbPress (r3653)
         * @uses bp_get_current_group_id()
         * @uses bbp_get_group_forum_ids()
         * @uses bbp_has_forums()
         * @uses bbp_get_template_part()
         */
        public function display_forums($offset = 0)
        {
            global $wpdb;
            $bbp = bbpress();
            // Forum data
            $forum_ids = bbp_get_group_forum_ids(bp_get_current_group_id());
            $forum_args = array('post__in' => $forum_ids, 'post_parent' => null);
            ?>

		<div id="bbpress-forums">

			<?php 
            // Looking at the group forum root
            if (!bp_action_variable($offset)) {
                // Query forums and show them if
                if (!empty($forum_ids) && bbp_has_forums($forum_args)) {
                    bbp_the_forum();
                    // Only one forum found
                    if ($bbp->forum_query->post_count == 1) {
                        ?>

						<h3><?php 
                        _e('Forum', 'bbpress');
                        ?>
</h3>

						<?php 
                        bbp_set_query_name('bbp_single_forum');
                        ?>

						<?php 
                        if (bbp_has_topics(array('post_parent' => bbp_get_forum_id()))) {
                            ?>

							<?php 
                            bbp_get_template_part('pagination', 'topics');
                            ?>

							<?php 
                            bbp_get_template_part('loop', 'topics');
                            ?>

							<?php 
                            bbp_get_template_part('pagination', 'topics');
                            ?>

							<?php 
                            bbp_get_template_part('form', 'topic');
                            ?>

						<?php 
                        } else {
                            ?>

							<?php 
                            bbp_get_template_part('feedback', 'no-topics');
                            ?>

							<?php 
                            bbp_get_template_part('form', 'topic');
                            ?>

						<?php 
                        }
                        // More than 1 forum found
                    } elseif ($bbp->forum_query->post_count > 1) {
                        ?>

						<h3><?php 
                        _e('Forums', 'bbpress');
                        ?>
</h3>

						<?php 
                        bbp_get_template_part('loop', 'forums');
                        ?>

						<h3><?php 
                        _e('Topics', 'bbpress');
                        ?>
</h3>

						<?php 
                        if (bbp_has_topics(array('post_parent__in' => $forum_ids))) {
                            ?>

							<?php 
                            bbp_get_template_part('pagination', 'topics');
                            ?>

							<?php 
                            bbp_get_template_part('loop', 'topics');
                            ?>

							<?php 
                            bbp_get_template_part('pagination', 'topics');
                            ?>

							<?php 
                            bbp_get_template_part('form', 'topic');
                            ?>

						<?php 
                        } else {
                            ?>

							<?php 
                            bbp_get_template_part('feedback', 'no-topics');
                            ?>

							<?php 
                            bbp_get_template_part('form', 'topic');
                            ?>

						<?php 
                        }
                        // No forums found
                    } else {
                        ?>

						<div id="message" class="info">
							<p><?php 
                        _e('This group does not currently have any forums.', 'bbpress');
                        ?>
</p>
						</div>

						<?php 
                        if (bp_is_group_admin_screen($this->slug)) {
                            bbp_get_template_part('form', 'forum');
                        }
                    }
                    // No forums found
                } else {
                    ?>

					<div id="message" class="info">
						<p><?php 
                    _e('This group does not currently have any forums.', 'bbpress');
                    ?>
</p>
					</div>

					<?php 
                    if (bp_is_group_admin_screen($this->slug)) {
                        bbp_get_template_part('form', 'forum');
                    }
                }
                // Single forum
            } elseif (bp_action_variable($offset) != $this->slug && bp_action_variable($offset) != $this->topic_slug) {
                // Get the forum
                $forum_post_type = bbp_get_forum_post_type();
                $forum_slug = bp_action_variable($offset);
                $forums = $wpdb->get_row("SELECT ID FROM {$wpdb->posts} WHERE post_name = '{$forum_slug}' AND post_type = '{$forum_post_type}'", ARRAY_N);
                // Forum exists
                if (!empty($forums)) {
                    $forum_id = $forums[0];
                    $bbp->current_forum_id = $forum_id;
                    bbp_set_query_name('bbp_single_forum');
                    ?>

					<h3><?php 
                    bbp_forum_title();
                    ?>
</h3>

					<?php 
                    bbp_get_template_part('content', 'single-forum');
                    ?>

				<?php 
                } else {
                    ?>

					<?php 
                    bbp_get_template_part('feedback', 'no-topics');
                    ?>

					<?php 
                    bbp_get_template_part('form', 'topic');
                    ?>

				<?php 
                }
                // Single topic
            } elseif (bp_action_variable($offset) != $this->slug && bp_action_variable($offset) == $this->topic_slug) {
                // Get the topic
                $topic_post_type = bbp_get_topic_post_type();
                $topic_slug = bp_action_variable($offset + 1);
                $topics = $wpdb->get_row("SELECT ID FROM {$wpdb->posts} WHERE post_name = '{$topic_slug}' AND post_type = '{$topic_post_type}'", ARRAY_N);
                // Topic exists
                if (!empty($topics)) {
                    $topic_id = $topics[0];
                    $bbp->current_topic_id = $topic_id;
                    bbp_set_query_name('bbp_single_topic');
                    ?>

					<h3><?php 
                    bbp_topic_title();
                    ?>
</h3>

					<?php 
                    bbp_get_template_part('content', 'single-topic');
                    ?>

				<?php 
                } else {
                    ?>

					<?php 
                    bbp_get_template_part('feedback', 'no-topics');
                    ?>

					<?php 
                    bbp_get_template_part('form', 'topic');
                    ?>

				<?php 
                }
            }
            ?>

		</div>

		<?php 
        }
Example #14
0
        ?>
</li>
                                            </ul>
     
                                    </li><!-- .bbp-header -->
    <?php 
    }
    ?>
     
                            <li class="bbp-body">
           
    <?php 
    /* If the forum is a category, we're gonna make another loop to show its subforums and sub-subforums as if those were forums */
    if (bbp_is_forum_category()) {
        $temp_query = clone bbpress()->forum_query;
        bbp_has_forums('post_parent=' . bbp_get_forum_id());
        while (bbp_forums()) {
            bbp_the_forum();
            bbp_get_template_part('loop', 'single-forum');
        }
        bbpress()->forum_query = clone $temp_query;
    } else {
        bbp_get_template_part('loop', 'single-forum');
        $bbp_forums_noheader = 1;
        /* This prevents the header part to be printed again on next post in the loop */
    }
    ?>
     
                            </li><!-- .bbp-body -->
     
    <?php 
    /**
     * Add the bbPress topic option to the Discussion meta box
     */
    function display_topic_option($post)
    {
        /** Store the post being edited and restore it after looping over forums */
        global $post;
        $the_post = $post;
        if (!function_exists('bbp_has_forums')) {
            ?>
<br /><p><?php 
            _e('bbPress Topics for Posts has been enabled, but cannot detect your bbPress setup.', 'bbpress-post-topics');
            ?>
</p><?php 
            return;
        }
        $bbpress_topic_options = $this->get_topic_options_for_post($post->ID);
        $bbpress_topic_status = $bbpress_topic_options['enabled'] != false;
        $bbpress_topic_display = $bbpress_topic_options['display'];
        $bbpress_topic_slug = $bbpress_topic_options['topic_id'];
        if ($bbpress_topic_slug) {
            $bbpress_topic = bbp_get_topic($bbpress_topic_slug);
            $bbpress_topic_slug = $bbpress_topic->post_name;
            /** If a topic already exists, don't select default forum */
            $bbpress_topic_options['forum_id'] = 0;
        }
        $forums = bbp_has_forums();
        if (!$forums) {
            ?>
<br /><p><?php 
            _e('bbPress Topics for Posts has been enabled, but you have not created any forums yet.', 'bbpress-post-topics');
            ?>
</p><?php 
            return;
        }
        ?>
		<br />
		<input type="hidden" name="bbpress_topic[form_displayed]" value="true" />
		<label for="bbpress_topic_status" class="selectit"><input name="bbpress_topic[enabled]" type="checkbox" id="bbpress_topic_status" value="open" <?php 
        checked($bbpress_topic_status);
        ?>
 /> <?php 
        _e('Use a bbPress forum topic for comments on this post.', 'bbpress-post-topics');
        ?>
</label><br />
		<div id="bbpress_topic_status_options" class="inside" style="display: <?php 
        echo checked($bbpress_topic_status, true, false) ? 'block' : 'none';
        ?>
;">
			<h4>bbPress Topic Options</h4>
			<label for="bbpress_topic_slug"><?php 
        _e('Use an existing topic:', 'bbpress-post-topics');
        ?>
 </label> <input type="text" name="bbpress_topic[slug]" id="bbpress_topic_slug" placeholder="<?php 
        _e('Topic ID or slug', 'bbpress-post-topics');
        ?>
" value="<?php 
        echo $bbpress_topic_slug;
        ?>
" <?php 
        if ($bbpress_topic_options['forum_id']) {
            echo ' disabled="true"';
        }
        ?>
 />
			  - OR - <label for="bbpress_topic_forum"><?php 
        _e('Create a new topic in forum:', 'bbpress-post-topics');
        ?>
</label>
			<select name="bbpress_topic[forum_id]" id="bbpress_topic_forum">
				<option value="0" selected><?php 
        _e('Select a Forum', 'bbpress-post-topics');
        ?>
</option>
				<?php 
        $forum_dropdown_options = array('selected' => $bbpress_topic_options['forum_id'], 'options_only' => true);
        bbp_dropdown($forum_dropdown_options);
        ?>
			</select><br />
			
			&mdash; <input type="checkbox" name="bbpress_topic[copy_tags]" id="bbpress_topic_copy_tags" <?php 
        checked($bbpress_topic_options['copy_tags'], 'on');
        ?>
 /> <label for="bbpress_topic_copy_tags"><?php 
        _e('Copy post tags to new topic', 'bbpress-post-topics');
        ?>
</label>
			<?php 
        if ($import_date = get_post_meta($post->ID, 'bbpress_discussion_tags_copied', true)) {
            printf('( ' . __('last copied %s ago', 'bbpress-post-topics') . ' )', human_time_diff($import_date));
        }
        ?>
			<br />
					
			<?php 
        if (wp_count_comments($post->ID)->total_comments > 0) {
            ?>
				&mdash; <input type="checkbox" name="bbpress_topic[copy_comments]" id="bbpress_topic_copy_comments" <?php 
            checked($bbpress_topic_options['copy_comments'], 'on');
            ?>
 /> <label for="bbpress_topic_copy_comments"><?php 
            _e('Copy comments to bbPress topic', 'bbpress-post-topics');
            ?>
</label>
				<?php 
            if ($import_date = get_post_meta($post->ID, 'bbpress_discussion_comments_copied', true)) {
                printf('( ' . __('last copied %s ago', 'bbpress-post-topics') . ' )', human_time_diff($import_date));
            }
            ?>
				<br />
			<?php 
        }
        ?>
			
			&mdash; <input type="checkbox" name="bbpress_topic[use_defaults]" id="bbpress_topic_use_defaults" <?php 
        checked($bbpress_topic_options['use_defaults']);
        ?>
 /> <label for="bbpress_topic_use_defaults"><?php 
        _e('Use default display settings', 'bbpress-post-topics');
        ?>
</label>
			<div id="bbpress_topic_display_options"  style="display: <?php 
        echo checked($bbpress_topic_options['use_defaults'], true, false) ? 'none' : 'block';
        ?>
; border-left: 1px solid #ccc; margin-left: 9px; padding-left: 5px;">
				<label for=""><?php 
        _e('On the post page, show:', 'bbpress-post-topics');
        ?>
</label><br />
				<?php 
        $xreplies_sort_options = array('newest' => __('most recent', 'bbpress-post-topics'), 'oldest' => __('oldest', 'bbpress-post-topics'));
        $xreplies_count = isset($bbpress_topic_options['display-extras']['xcount']) ? $bbpress_topic_options['display-extras']['xcount'] : 5;
        $xreplies_count_string = '<input type="text" name="bbpress_topic[display-extras][xcount]" value="' . $xreplies_count . '" class="small-text" maxlength="3" />';
        $xsort_select_string = '<select name="bbpress_topic[display-extras][xsort]" id="bbpress_topic_display_sort">';
        foreach ($xreplies_sort_options as $option => $label) {
            $xsort_select_string .= '<option value="' . $option . '" ' . selected($bbpress_topic_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'));
        $display_formats = apply_filters('bbppt_display_format_options', $display_formats, $the_post->ID);
        ?>
				<fieldset>
					<?php 
        foreach ($display_formats as $format_code => $format_label) {
            ?>
					<input type="radio" name="bbpress_topic[display]" id="bbpress_topic_display_<?php 
            echo $format_code;
            ?>
" value="<?php 
            echo $format_code;
            ?>
" <?php 
            checked($bbpress_topic_options['display'], $format_code);
            ?>
 /><label for="bbpress_topic_display_<?php 
            echo $format_code;
            ?>
"><?php 
            echo $format_label;
            ?>
</label><br />
					<?php 
        }
        ?>
				</fieldset>
			</div>
		</div>
		<script type="text/javascript">

			/** hide topic options when not checked */
			jQuery('#bbpress_topic_status').change(function() {
				if(jQuery(this).attr('checked')) {
					jQuery('#bbpress_topic_status_options').show();
				} else {
					jQuery('#bbpress_topic_status_options').hide();
				}
			});

			/** hide display options when defaults are selected */
			jQuery('#bbpress_topic_use_defaults').change(function() {
				if(jQuery(this).attr('checked')) {
					jQuery('#bbpress_topic_display_options').hide();
				} else {
					jQuery('#bbpress_topic_display_options').show();
				}
			});
			
			/** disable topic slug field when a forum is selected to prevent confusion */
			jQuery('#bbpress_topic_forum').change(function() {
				if(jQuery(this).val() != 0) {
					jQuery('#bbpress_topic_slug').attr('disabled','true');
				} else {
					jQuery('#bbpress_topic_slug').removeAttr('disabled');
				}
			});
			
		</script>
		<?php 
        do_action('bbppt_display_options_fields', $the_post->ID);
        /** Restore the original post being edited */
        $post = $the_post;
    }
Example #16
0
        /**
         * Output the forums for a group in the edit screens
         *
         * @since bbPress (r3653)
         * @uses bp_get_current_group_id()
         * @uses bbp_get_group_forum_ids()
         * @uses bbp_has_forums()
         * @uses bbp_get_template_part()
         */
        public function display_forums($offset = 0)
        {
            // Allow actions immediately before group forum output
            do_action('bbp_before_group_forum_display');
            // Load up bbPress once
            $bbp = bbpress();
            // Forum data
            $forum_slug = bp_action_variable($offset);
            $forum_ids = bbp_get_group_forum_ids(bp_get_current_group_id());
            $forum_args = array('post__in' => $forum_ids, 'post_parent' => null);
            // Unset global queries
            $bbp->forum_query = new stdClass();
            $bbp->topic_query = new stdClass();
            $bbp->reply_query = new stdClass();
            // Unset global ID's
            $bbp->current_forum_id = 0;
            $bbp->current_topic_id = 0;
            $bbp->current_reply_id = 0;
            $bbp->current_topic_tag_id = 0;
            // Reset the post data
            wp_reset_postdata();
            // Allow admins special views
            $post_status = array(bbp_get_closed_status_id(), bbp_get_public_status_id());
            if (is_super_admin() || current_user_can('moderate') || bp_is_item_admin() || bp_is_item_mod()) {
                $post_status = array_merge($post_status, array(bbp_get_spam_status_id(), bbp_get_trash_status_id()));
            }
            ?>

		<div id="bbpress-forums">

			<?php 
            // Looking at the group forum root
            if (empty($forum_slug) || 'page' == $forum_slug) {
                // Query forums and show them if they exist
                if (!empty($forum_ids) && bbp_has_forums($forum_args)) {
                    // Only one forum found
                    if (1 == $bbp->forum_query->post_count) {
                        // Remove 'name' check for paginated requests
                        if ('page' == $forum_slug) {
                            $forum_args = array('post_type' => bbp_get_forum_post_type());
                        } else {
                            $forum_args = array('name' => $forum_slug, 'post_type' => bbp_get_forum_post_type());
                        }
                        // Get the forums
                        $forums = get_posts($forum_args);
                        bbp_the_forum();
                        // Forum exists
                        if (!empty($forums)) {
                            $forum = $forums[0];
                            // Suppress subforums for now
                            add_filter('bbp_get_forum_subforum_count', '__return_false');
                            // Set up forum data
                            bbpress()->current_forum_id = $forum->ID;
                            bbp_set_query_name('bbp_single_forum');
                            ?>

							<h3><?php 
                            bbp_forum_title();
                            ?>
</h3>

							<?php 
                            bbp_get_template_part('content', 'single-forum');
                            ?>

							<?php 
                            // Remove the subforum suppression filter
                            remove_filter('bbp_get_forum_subforum_count', '__return_false');
                            ?>

						<?php 
                        } else {
                            ?>

							<?php 
                            bbp_get_template_part('feedback', 'no-topics');
                            ?>

							<?php 
                            bbp_get_template_part('form', 'topic');
                            ?>

						<?php 
                        }
                        // More than 1 forum found or group forum admin screen
                    } elseif (1 < $bbp->forum_query->post_count) {
                        ?>

						<h3><?php 
                        _e('Forums', 'bbpress');
                        ?>
</h3>

						<?php 
                        bbp_get_template_part('loop', 'forums');
                        ?>

						<h3><?php 
                        _e('Topics', 'bbpress');
                        ?>
</h3>

						<?php 
                        if (bbp_has_topics(array('post_parent__in' => $forum_ids))) {
                            ?>

							<?php 
                            bbp_get_template_part('pagination', 'topics');
                            ?>

							<?php 
                            bbp_get_template_part('loop', 'topics');
                            ?>

							<?php 
                            bbp_get_template_part('pagination', 'topics');
                            ?>

							<?php 
                            bbp_get_template_part('form', 'topic');
                            ?>

						<?php 
                        } else {
                            ?>

							<?php 
                            bbp_get_template_part('feedback', 'no-topics');
                            ?>

							<?php 
                            bbp_get_template_part('form', 'topic');
                            ?>

						<?php 
                        }
                        // No forums found
                    } else {
                        ?>

						<div id="message" class="info">
							<p><?php 
                        _e('This group does not currently have any forums.', 'bbpress');
                        ?>
</p>
						</div>

					<?php 
                    }
                    // No forums found
                } else {
                    ?>

					<div id="message" class="info">
						<p><?php 
                    _e('This group does not currently have any forums.', 'bbpress');
                    ?>
</p>
					</div>

				<?php 
                }
                // Single forum
            } elseif (bp_action_variable($offset) != $this->slug && bp_action_variable($offset) != $this->topic_slug && bp_action_variable($offset) != $this->reply_slug) {
                // Get forum data
                $forum_slug = bp_action_variable($offset);
                $forum_args = array('name' => $forum_slug, 'post_type' => bbp_get_forum_post_type());
                $forums = get_posts($forum_args);
                // Forum exists
                if (!empty($forums)) {
                    $forum = $forums[0];
                    // Set up forum data
                    $forum_id = bbpress()->current_forum_id = $forum->ID;
                    // Reset necessary forum_query attributes for forums loop to function
                    $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type();
                    $bbp->forum_query->in_the_loop = true;
                    $bbp->forum_query->post = get_post($forum_id);
                    // Forum edit
                    if (bp_action_variable($offset + 1) == $bbp->edit_id) {
                        global $wp_query, $post;
                        $wp_query->bbp_is_edit = true;
                        $wp_query->bbp_is_forum_edit = true;
                        $post = $forum;
                        bbp_set_query_name('bbp_forum_form');
                        bbp_get_template_part('form', 'forum');
                    } else {
                        bbp_set_query_name('bbp_single_forum');
                        ?>

						<h3><?php 
                        bbp_forum_title();
                        ?>
</h3>

						<?php 
                        bbp_get_template_part('content', 'single-forum');
                    }
                } else {
                    bbp_get_template_part('feedback', 'no-topics');
                    bbp_get_template_part('form', 'topic');
                }
                // Single topic
            } elseif (bp_action_variable($offset) == $this->topic_slug) {
                // Get topic data
                $topic_slug = bp_action_variable($offset + 1);
                $topic_args = array('name' => $topic_slug, 'post_type' => bbp_get_topic_post_type(), 'post_status' => $post_status);
                $topics = get_posts($topic_args);
                // Topic exists
                if (!empty($topics)) {
                    $topic = $topics[0];
                    // Set up topic data
                    $topic_id = bbpress()->current_topic_id = $topic->ID;
                    $forum_id = bbp_get_topic_forum_id($topic_id);
                    // Reset necessary forum_query attributes for topics loop to function
                    $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type();
                    $bbp->forum_query->in_the_loop = true;
                    $bbp->forum_query->post = get_post($forum_id);
                    // Reset necessary topic_query attributes for topics loop to function
                    $bbp->topic_query->query_vars['post_type'] = bbp_get_topic_post_type();
                    $bbp->topic_query->in_the_loop = true;
                    $bbp->topic_query->post = $topic;
                    // Topic edit
                    if (bp_action_variable($offset + 2) == $bbp->edit_id) {
                        global $wp_query, $post;
                        $wp_query->bbp_is_edit = true;
                        $wp_query->bbp_is_topic_edit = true;
                        $post = $topic;
                        // Merge
                        if (!empty($_GET['action']) && 'merge' == $_GET['action']) {
                            bbp_set_query_name('bbp_topic_merge');
                            bbp_get_template_part('form', 'topic-merge');
                            // Split
                        } elseif (!empty($_GET['action']) && 'split' == $_GET['action']) {
                            bbp_set_query_name('bbp_topic_split');
                            bbp_get_template_part('form', 'topic-split');
                            // Edit
                        } else {
                            bbp_set_query_name('bbp_topic_form');
                            bbp_get_template_part('form', 'topic');
                        }
                        // Single Topic
                    } else {
                        bbp_set_query_name('bbp_single_topic');
                        ?>

						<h3><?php 
                        bbp_topic_title();
                        ?>
</h3>

						<?php 
                        bbp_get_template_part('content', 'single-topic');
                    }
                    // No Topics
                } else {
                    bbp_get_template_part('feedback', 'no-topics');
                    bbp_get_template_part('form', 'topic');
                }
                // Single reply
            } elseif (bp_action_variable($offset) == $this->reply_slug) {
                // Get reply data
                $reply_slug = bp_action_variable($offset + 1);
                $reply_args = array('name' => $reply_slug, 'post_type' => bbp_get_reply_post_type());
                $replies = get_posts($reply_args);
                if (empty($replies)) {
                    return;
                }
                // Get the first reply
                $reply = $replies[0];
                // Set up reply data
                $reply_id = bbpress()->current_reply_id = $reply->ID;
                $topic_id = bbp_get_reply_topic_id($reply_id);
                $forum_id = bbp_get_reply_forum_id($reply_id);
                // Reset necessary forum_query attributes for reply to function
                $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type();
                $bbp->forum_query->in_the_loop = true;
                $bbp->forum_query->post = get_post($forum_id);
                // Reset necessary topic_query attributes for reply to function
                $bbp->topic_query->query_vars['post_type'] = bbp_get_topic_post_type();
                $bbp->topic_query->in_the_loop = true;
                $bbp->topic_query->post = get_post($topic_id);
                // Reset necessary reply_query attributes for reply to function
                $bbp->reply_query->query_vars['post_type'] = bbp_get_reply_post_type();
                $bbp->reply_query->in_the_loop = true;
                $bbp->reply_query->post = $reply;
                if (bp_action_variable($offset + 2) == $bbp->edit_id) {
                    global $wp_query, $post;
                    $wp_query->bbp_is_edit = true;
                    $wp_query->bbp_is_reply_edit = true;
                    $post = $reply;
                    bbp_set_query_name('bbp_reply_form');
                    bbp_get_template_part('form', 'reply');
                }
            }
            ?>

		</div>

		<?php 
            // Allow actions immediately after group forum output
            do_action('bbp_after_group_forum_display');
        }