public function getTopicList() { if (is_null($_POST['param']) || empty($_POST['param'])) { $this->_die(); } $return = array(); $loadFrom = empty($_POST['param']['from']) ? 0 : $_POST['param']['from']; $loadTo = empty($_POST['param']['to']) ? 0 : $_POST['param']['to']; $param = array('post_parent' => $this->forumId); if (!bbp_has_topics($param)) { $this->_die(); } while (bbp_topics()) { bbp_the_topic(); $topicId = bbp_get_topic_id(); $topic = new ForumBbpAjaxIntegratorPost($topicId, 'topic'); $returnItem = $topic->getPostData(); $returnItem['replyList'] = $this->getReplyList($topicId); $return[] = $returnItem; } wp_die(json_encode($return)); }
bbp_show_lead_topic() ? _e('Replies', 'bbpress') : _e('Posts', 'bbpress'); ?> </li> <li class="bbp-topic-freshness"><?php _e('Last Post', 'cubell'); ?> </li> </ul> </li> <li class="bbp-body"> <?php while (bbp_topics()) { bbp_the_topic(); ?> <?php bbp_get_template_part('loop', 'single-topic'); ?> <?php } ?> </li> </ul><!-- #bbp-forum-<?php bbp_forum_id(); ?>
/** * Output an RSS2 feed of topics, based on the query passed. * * @since bbPress (r3171) * * @uses bbp_version() * @uses bbp_is_single_topic() * @uses bbp_user_can_view_forum() * @uses bbp_get_topic_forum_id() * @uses bbp_show_load_topic() * @uses bbp_topic_permalink() * @uses bbp_topic_title() * @uses bbp_get_topic_reply_count() * @uses bbp_topic_content() * @uses bbp_has_topics() * @uses bbp_topics() * @uses bbp_the_topic() * @uses get_wp_title_rss() * @uses get_option() * @uses bloginfo_rss * @uses self_link() * @uses the_author() * @uses get_post_time() * @uses rss_enclosure() * @uses do_action() * @uses apply_filters() * * @param array $topics_query */ function bbp_display_topics_feed_rss2($topics_query = array()) { // User cannot access this forum if (bbp_is_single_forum() && !bbp_user_can_view_forum(array('forum_id' => bbp_get_forum_id()))) { return; } // Display the feed header('Content-Type: ' . feed_content_type('rss2') . '; charset=' . get_option('blog_charset'), true); header('Status: 200 OK'); echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>'; ?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" <?php do_action('bbp_feed'); ?> > <channel> <title><?php bloginfo_rss('name'); ?> » <?php _e('All Topics', 'bbpress'); ?> </title> <atom:link href="<?php self_link(); ?> " rel="self" type="application/rss+xml" /> <link><?php self_link(); ?> </link> <description><?php // ?> </description> <pubDate><?php echo mysql2date('D, d M Y H:i:s O', current_time('mysql'), false); ?> </pubDate> <generator>http://bbpress.org/?v=<?php bbp_version(); ?> </generator> <language><?php bloginfo_rss('language'); ?> </language> <?php do_action('bbp_feed_head'); ?> <?php if (bbp_has_topics($topics_query)) { ?> <?php while (bbp_topics()) { bbp_the_topic(); ?> <item> <guid><?php bbp_topic_permalink(); ?> </guid> <title><![CDATA[<?php bbp_topic_title(); ?> ]]></title> <link><?php bbp_topic_permalink(); ?> </link> <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_meta(bbp_get_topic_id(), '_bbp_last_active_time', true)); ?> </pubDate> <dc:creator><?php the_author(); ?> </dc:creator> <?php if (!post_password_required()) { ?> <description> <![CDATA[ <p><?php printf(esc_html__('Replies: %s', 'bbpress'), bbp_get_topic_reply_count()); ?> </p> <?php bbp_topic_content(); ?> ]]> </description> <?php rss_enclosure(); ?> <?php } ?> <?php do_action('bbp_feed_item'); ?> </item> <?php } ?> <?php } ?> <?php do_action('bbp_feed_footer'); ?> </channel> </rss> <?php exit; }
/** * 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'); }
function load_more_topics() { $content = ''; ob_start(); $forum_id = $_POST['forum']; if ($topics = bbp_has_topics(array('post_parent' => $forum_id, 'posts_per_page' => 11, 'paged' => $_POST['list']))) { $counter = 0; while (bbp_topics()) { bbp_the_topic(); if (++$counter == 12) { break; } ?> <div class="topics_list_single_topic <?php $postUser = new WP_User(bbp_get_topic_author_id()); echo $postUser->has_cap('bbp_keymaster') || $postUser->has_cap('bbp_moderator') ? "isAdmin" : ""; ?> " id="topic-<?php echo bbp_get_topic_id(); ?> " data-bbp_forum_id="<?php echo $forum_id; ?> " data-id="<?php echo bbp_get_topic_id(); ?> "> <div class="single_topic_header"> <div class="photo"> <a href="<?php echo bp_core_get_user_domain(bbp_get_topic_author_id()); ?> "><?php echo bp_core_fetch_avatar(array('item_id' => bbp_get_topic_author_id(), 'height' => 40, 'width' => 40)); ?> </a> </div> <div class="info"> <div class="name"> <a href="<?php echo bp_core_get_user_domain(bbp_get_topic_author_id()); ?> "><?php echo bbp_get_topic_author_display_name(bbp_get_topic_id()); ?> </a> <?php if ($postUser->has_cap('bbp_keymaster')) { echo "<small>(Администратор форума)</small>"; } elseif ($postUser->has_cap('bbp_moderator')) { echo "<small>(Преподаватель)</small>"; } ?> </div> <div class="date"><?php echo get_post_time('j F ', false, bbp_get_topic_id(), true) . __('at', 'qode') . get_post_time(' H:i', false, bbp_get_topic_id(), true); ?> </div> </div> <?php if (bbp_get_topic_author_id() == get_current_user_id()) { ?> <a href="#" class="addi_actions_open"></a> <div class="addi_actions" style="display: none"> <ul> <li><a class="edit_action" href="#">Редактировать</a></li> <li><a class="remove_action" href="#">Удалить</a></li> </ul> </div> <?php } ?> </div> <div class="single_topic_content"> <?php $content = bbp_get_topic_content(); if (mb_strlen($content) > 500) { echo '<div class="show">' . mb_substr($content, 0, 500) . '... <a href="#" class="show_all">' . __('More', 'qode') . '</a></div>'; ?> <div class="hide"><?php echo $content; ?> </div> <?php } else { echo $content; } ?> </div> <div style="display: none" class="single_topic_content_edit"> <textarea class="edit_content"><?php echo get_post_field('post_content', bbp_get_topic_id()); ?> </textarea> <div class="edit_actions"> <button class="cancel"><?php _e('Cancel', 'qode'); ?> </button> <button class="save"><?php _e('Save', 'qode'); ?> </button> </div> </div> <div class="single_topic_replies_container"> <div class="single_topic_replies"> <?php $replies = get_posts($default = array('post_type' => bbp_get_reply_post_type(), 'post_parent' => bbp_get_topic_id(), 'posts_per_page' => 5, 'orderby' => 'date', 'order' => 'DESC', 'ignore_sticky_posts' => true)); // Stickies not supported $i = count($replies); if ($i == 5) { $count = new WP_Query($default = array('numberposts' => -1, 'post_type' => bbp_get_reply_post_type(), 'post_parent' => bbp_get_topic_id(), 'posts_per_page' => 5, 'orderby' => 'date', 'order' => 'DESC', 'ignore_sticky_posts' => true)); // Stickies not supported $count = $count->found_posts - 4; ?> <a href="#" class="load_all_replies"><i class="comments_img"></i>Просмотреть еще <?php echo $count . ' ' . custom_plural_form($count, 'комментарий', 'комментария', 'комментариев'); ?> </a> <?php } $replies = array_reverse($replies); //array_shift ( $replies ); foreach ($replies as $reply) { ?> <div class="single_topic_reply <?php $postUser = new WP_User($reply->post_author); echo $postUser->has_cap('bbp_keymaster') || $postUser->has_cap('bbp_moderator') ? "isAdmin" : ""; ?> " data-id="<?php echo $reply->ID; ?> "> <div class="photo"> <a href="<?php echo bp_core_get_user_domain($reply->post_author); ?> "><?php echo bp_core_fetch_avatar(array('item_id' => $reply->post_author, 'height' => 32, 'width' => 32)); ?> </a> </div> <div class="content_wrapper"> <div class="reply_content"> <a class="author-link" href="<?php echo bp_core_get_user_domain($reply->post_author); ?> "><?php echo bbp_get_reply_author_display_name($reply->ID); ?> </a> <?php if ($postUser->has_cap('bbp_keymaster')) { echo "<small>(Администратор форума)</small>"; } elseif ($postUser->has_cap('bbp_moderator')) { echo "<small>(Преподаватель)</small>"; } ?> <?php echo bbp_get_reply_content($reply->ID); ?> </div> <div style="display: none" class="reply_content_edit"> <textarea class="reply_content_edit_textarea"><?php echo get_post_field('post_content', $reply->ID); ?> </textarea> <div class="edit_actions"> <a class="cancel" href="#">Отменить</a> </div> </div> <div class="date"> <?php echo get_post_time('j F ', false, $reply->ID, true) . __('at', 'qode') . get_post_time(' H:i', false, $reply->ID, true); ?> </span><?php $like = get_post_meta($reply->ID, 'like_' . get_current_user_id(), true); ?> </div> </div> <?php if ($reply->post_author == get_current_user_id()) { ?> <a class="addi_actions_open" href="#"></a> <div class="addi_actions" style="display: none"> <ul> <li><a class="edit_action" href="#">Редактировать</a></li> <li><a class="remove_action" href="#">Удалить</a></li> </ul> </div> <?php } ?> </div> <?php } $url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"; ?> </div> <div class="single_topic_reply_form"> <form action="<?php echo $url; ?> #topic-<?php echo bbp_get_topic_id(); ?> " data-bbp_forum_id="<?php echo $forum_id; ?> " data-bbp_topic_id="<?php echo bbp_get_topic_id(); ?> " method="post"> <div class="photo"> <a href="<?php echo bp_core_get_user_domain(get_current_user_id()); ?> "><?php echo bp_core_fetch_avatar(array('item_id' => get_current_user_id(), 'height' => 32, 'width' => 32)); ?> </a> </div> <div class="reply-form"> <textarea placeholder="<?php _e('Введите текст сообщения...', 'qode'); ?> " name="content"></textarea> </div> <input type="hidden" name="bbp_forum_id" value="<?php echo $forum_id; ?> "> <input type="hidden" name="bbp_topic_id" value="<?php echo bbp_get_topic_id(); ?> "> <input type="hidden" name="action" value="custom-bbp-reply-create"> <input type="hidden" name="security" value="<?php echo wp_create_nonce('custom-bbp-reply-create'); ?> "> </form> </div> </div> </div> <?php } if ($counter == 11) { ?> <a class="load_more_topics" href="#"><?php _e('Load more discussions', 'qode'); ?> </a> <?php } } $content = ob_get_contents(); ob_end_clean(); die(json_encode(array('result' => 'OK', 'content' => $content))); }