Esempio n. 1
0
/**
 * Possibly intercept the template being loaded
 *
 * Listens to the 'template_include' filter and waits for any bbPress specific
 * template condition to be met. If one is met and the template file exists,
 * it will be used; otherwise 
 *
 * Note that the _edit() checks are ahead of their counterparts, to prevent them
 * from being stomped on accident.
 *
 * @since bbPress (r3032)
 *
 * @param string $template
 *
 * @uses bbp_is_single_user() To check if page is single user
 * @uses bbp_get_single_user_template() To get user template
 * @uses bbp_is_single_user_edit() To check if page is single user edit
 * @uses bbp_get_single_user_edit_template() To get user edit template
 * @uses bbp_is_single_view() To check if page is single view
 * @uses bbp_get_single_view_template() To get view template
 * @uses bbp_is_forum_edit() To check if page is forum edit
 * @uses bbp_get_forum_edit_template() To get forum edit template
 * @uses bbp_is_topic_merge() To check if page is topic merge
 * @uses bbp_get_topic_merge_template() To get topic merge template
 * @uses bbp_is_topic_split() To check if page is topic split
 * @uses bbp_get_topic_split_template() To get topic split template
 * @uses bbp_is_topic_edit() To check if page is topic edit
 * @uses bbp_get_topic_edit_template() To get topic edit template
 * @uses bbp_is_reply_edit() To check if page is reply edit
 * @uses bbp_get_reply_edit_template() To get reply edit template
 * @uses bbp_set_theme_compat_template() To set the global theme compat template
 *
 * @return string The path to the template file that is being used
 */
function bbp_template_include_theme_supports($template = '')
{
    // Editing a user
    if (bbp_is_single_user_edit() && ($new_template = bbp_get_single_user_edit_template())) {
        // User favorites
    } elseif (bbp_is_favorites() && ($new_template = bbp_get_favorites_template())) {
        // User favorites
    } elseif (bbp_is_subscriptions() && ($new_template = bbp_get_subscriptions_template())) {
        // Viewing a user
    } elseif (bbp_is_single_user() && ($new_template = bbp_get_single_user_template())) {
        // Single View
    } elseif (bbp_is_single_view() && ($new_template = bbp_get_single_view_template())) {
        // Forum edit
    } elseif (bbp_is_forum_edit() && ($new_template = bbp_get_forum_edit_template())) {
        // Single Forum
    } elseif (bbp_is_single_forum() && ($new_template = bbp_get_single_forum_template())) {
        // Forum Archive
    } elseif (bbp_is_forum_archive() && ($new_template = bbp_get_forum_archive_template())) {
        // Topic merge
    } elseif (bbp_is_topic_merge() && ($new_template = bbp_get_topic_merge_template())) {
        // Topic split
    } elseif (bbp_is_topic_split() && ($new_template = bbp_get_topic_split_template())) {
        // Topic edit
    } elseif (bbp_is_topic_edit() && ($new_template = bbp_get_topic_edit_template())) {
        // Single Topic
    } elseif (bbp_is_single_topic() && ($new_template = bbp_get_single_topic_template())) {
        // Topic Archive
    } elseif (bbp_is_topic_archive() && ($new_template = bbp_get_topic_archive_template())) {
        // Editing a reply
    } elseif (bbp_is_reply_edit() && ($new_template = bbp_get_reply_edit_template())) {
        // Single Reply
    } elseif (bbp_is_single_reply() && ($new_template = bbp_get_single_reply_template())) {
        // Editing a topic tag
    } elseif (bbp_is_topic_tag_edit() && ($new_template = bbp_get_topic_tag_edit_template())) {
        // Viewing a topic tag
    } elseif (bbp_is_topic_tag() && ($new_template = bbp_get_topic_tag_template())) {
    }
    // bbPress template file exists
    if (!empty($new_template)) {
        // Override the WordPress template with a bbPress one
        $template = $new_template;
        // @see: bbp_template_include_theme_compat()
        bbpress()->theme_compat->bbpress_template = true;
    }
    return apply_filters('bbp_template_include_theme_supports', $template);
}
Esempio n. 2
0
/**
 * The main topic loop. WordPress makes this easy for us
 *
 * @since bbPress (r2485)
 *
 * @param mixed $args All the arguments supported by {@link WP_Query}
 * @uses current_user_can() To check if the current user can edit other's topics
 * @uses bbp_is_user_bozo() To add the bozo post status
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses WP_Query To make query and get the topics
 * @uses is_page() To check if it's a page
 * @uses bbp_is_single_forum() To check if it's a forum
 * @uses bbp_get_forum_id() To get the forum id
 * @uses bbp_get_paged() To get the current page value
 * @uses bbp_get_super_stickies() To get the super stickies
 * @uses bbp_get_stickies() To get the forum stickies
 * @uses wpdb::get_results() To execute our query and get the results
 * @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_topics_pagination' with the pagination args
 * @uses paginate_links() To paginate the links
 * @uses apply_filters() Calls 'bbp_has_topics' with
 *                        bbPres::topic_query::have_posts()
 *                        and bbPres::topic_query
 * @return object Multidimensional array of topic information
 */
function bbp_has_topics($args = '')
{
    global $wp_rewrite;
    // What are the default allowed statuses (based on user caps)
    if (bbp_get_view_all()) {
        $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_topic_search = !empty($_REQUEST['ts']) ? $_REQUEST['ts'] : false;
    $default_show_stickies = (bool) (bbp_is_single_forum() || bbp_is_topic_archive()) && false === $default_topic_search;
    $default_post_parent = bbp_is_single_forum() ? bbp_get_forum_id() : 'any';
    $default_post_status = join(',', $post_statuses);
    // Default argument array
    $default = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $default_post_parent, 'post_status' => $default_post_status, 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC', 'posts_per_page' => bbp_get_topics_per_page(), 'paged' => bbp_get_paged(), 's' => $default_topic_search, 'show_stickies' => $default_show_stickies, 'max_num_pages' => false);
    // Maybe query for topic tags
    if (bbp_is_topic_tag()) {
        $default['term'] = bbp_get_topic_tag_slug();
        $default['taxonomy'] = bbp_get_topic_tag_tax_id();
    }
    $bbp_t = bbp_parse_args($args, $default, 'has_topics');
    // Extract the query variables
    extract($bbp_t);
    // Get bbPress
    $bbp = bbpress();
    // Call the query
    $bbp->topic_query = new WP_Query($bbp_t);
    // Set post_parent back to 0 if originally set to 'any'
    if ('any' == $bbp_t['post_parent']) {
        $bbp_t['post_parent'] = $post_parent = 0;
    }
    // Limited the number of pages shown
    if (!empty($max_num_pages)) {
        $bbp->topic_query->max_num_pages = $max_num_pages;
    }
    // Put sticky posts at the top of the posts array
    if (!empty($show_stickies) && $paged <= 1) {
        // Get super stickies and stickies in this forum
        $stickies = bbp_get_super_stickies();
        $stickies = !empty($post_parent) ? array_merge($stickies, bbp_get_stickies($post_parent)) : $stickies;
        $stickies = array_unique($stickies);
        // We have stickies
        if (is_array($stickies) && !empty($stickies)) {
            // Setup the number of stickies and reset offset to 0
            $num_topics = count($bbp->topic_query->posts);
            $sticky_offset = 0;
            // Loop over topics and relocate stickies to the front.
            for ($i = 0; $i < $num_topics; $i++) {
                if (in_array($bbp->topic_query->posts[$i]->ID, $stickies)) {
                    $sticky = $bbp->topic_query->posts[$i];
                    // Remove sticky from current position
                    array_splice($bbp->topic_query->posts, $i, 1);
                    // Move to front, after other stickies
                    array_splice($bbp->topic_query->posts, $sticky_offset, 0, array($sticky));
                    // Increment the sticky offset.  The next sticky will be placed at this offset.
                    $sticky_offset++;
                    // Remove post from sticky posts array
                    $offset = array_search($sticky->ID, $stickies);
                    // Cleanup
                    unset($stickies[$offset]);
                    unset($sticky);
                }
            }
            // If any posts have been excluded specifically, Ignore those that are sticky.
            if (!empty($stickies) && !empty($post__not_in)) {
                $stickies = array_diff($stickies, $post__not_in);
            }
            // Fetch sticky posts that weren't in the query results
            if (!empty($stickies)) {
                // Query to use in get_posts to get sticky posts
                $sticky_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => 'any', 'post_status' => $default_post_status, 'meta_key' => '_bbp_last_active_time', 'orderby' => 'meta_value', 'order' => 'DESC', 'include' => $stickies);
                // Get all stickies
                $sticky_posts = get_posts($sticky_query);
                if (!empty($sticky_posts)) {
                    // Get a count of the visible stickies
                    $sticky_count = count($sticky_posts);
                    // Loop through stickies and add them to beginning of array
                    foreach ($sticky_posts as $sticky) {
                        $topics[] = $sticky;
                    }
                    // Loop through topics and add them to end of array
                    foreach ($bbp->topic_query->posts as $topic) {
                        $topics[] = $topic;
                    }
                    // Adjust loop and counts for new sticky positions
                    $bbp->topic_query->posts = $topics;
                    $bbp->topic_query->found_posts = (int) $bbp->topic_query->found_posts + (int) $sticky_count;
                    $bbp->topic_query->post_count = (int) $bbp->topic_query->post_count + (int) $sticky_count;
                    // Cleanup
                    unset($topics);
                    unset($stickies);
                    unset($sticky_posts);
                }
            }
        }
    }
    // If no limit to posts per page, set it to the current post_count
    if (-1 == $posts_per_page) {
        $posts_per_page = $bbp->topic_query->post_count;
    }
    // Add pagination values to query object
    $bbp->topic_query->posts_per_page = $posts_per_page;
    $bbp->topic_query->paged = $paged;
    // Only add pagination if query returned results
    if (((int) $bbp->topic_query->post_count || (int) $bbp->topic_query->found_posts) && (int) $bbp->topic_query->posts_per_page) {
        // Limit the number of topics shown based on maximum allowed pages
        if (!empty($max_num_pages) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count) {
            $bbp->topic_query->found_posts = $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count;
        }
        // If pretty permalinks are enabled, make our pagination pretty
        if ($wp_rewrite->using_permalinks()) {
            // Profile page
            if (bbp_is_single_user()) {
                $base = bbp_get_user_profile_url(bbp_get_displayed_user_id());
            } elseif (bbp_is_single_view()) {
                $base = bbp_get_view_url();
            } elseif (bbp_is_topic_tag()) {
                $base = bbp_get_topic_tag_link();
            } elseif (is_page() || is_single()) {
                $base = get_permalink();
            } elseif (bbp_is_topic_archive()) {
                $base = bbp_get_topics_url();
            } else {
                $base = get_permalink($post_parent);
            }
            // Use pagination base
            $base = trailingslashit($base) . user_trailingslashit($wp_rewrite->pagination_base . '/%#%/');
            // Unpretty pagination
        } else {
            $base = add_query_arg('paged', '%#%');
        }
        // Pagination settings with filter
        $bbp_topic_pagination = apply_filters('bbp_topic_pagination', array('base' => $base, 'format' => '', 'total' => $posts_per_page == $bbp->topic_query->found_posts ? 1 : ceil((int) $bbp->topic_query->found_posts / (int) $posts_per_page), 'current' => (int) $bbp->topic_query->paged, 'prev_text' => '&larr;', 'next_text' => '&rarr;', 'mid_size' => 1));
        // Add pagination to query object
        $bbp->topic_query->pagination_links = paginate_links($bbp_topic_pagination);
        // Remove first page from pagination
        $bbp->topic_query->pagination_links = str_replace($wp_rewrite->pagination_base . "/1/'", "'", $bbp->topic_query->pagination_links);
    }
    // Return object
    return apply_filters('bbp_has_topics', $bbp->topic_query->have_posts(), $bbp->topic_query);
}
Esempio n. 3
0
 /**
  * Display the contents of a specific topic tag in an output buffer
  * and return to ensure that post/page contents are displayed first.
  *
  * @since bbPress (r3110)
  *
  * @param array $attr
  * @param string $content
  * @uses get_template_part()
  * @return string
  */
 public function display_topics_of_tag($attr, $content = '')
 {
     // Sanity check required info
     if (!empty($content) || (empty($attr['id']) || !is_numeric($attr['id']))) {
         return $content;
     }
     // Unset globals
     $this->unset_globals();
     // Filter the query
     if (!bbp_is_topic_tag()) {
         add_filter('bbp_before_has_topics_parse_args', array($this, 'display_topics_of_tag_query'));
     }
     // Start output buffer
     $this->start('bbp_topic_tag');
     // Set passed attribute to $ag_id for clarity
     bbpress()->current_topic_tag_id = $tag_id = $attr['id'];
     // Output template
     bbp_get_template_part('content', 'archive-topic');
     // Return contents of output buffer
     return $this->end();
 }
Esempio n. 4
0
<?php

/**
 * Topics Loop
 *
 * @package bbPress
 * @subpackage Theme
 */
?>

<?php 
if (!bbp_is_topic_tag() && !strpos($_SERVER['REQUEST_URI'], '/forums/view/')) {
    ?>
  <?php 
    do_action('bbp_template_before_topics_loop');
    ?>
  <a href="<?php 
    echo add_query_arg(array('order' => 'DESC'), bbp_get_forum_permalink(bbp_get_forum_id()));
    ?>
"
  <?php 
    if (isset($_REQUEST['order']) && $_REQUEST['order'] && $_REQUEST['order'] == 'DESC') {
        echo 'class="order-active"';
    }
    ?>
  >Newest</a> |
  <a href="<?php 
    echo add_query_arg(array('order' => 'ASC'), bbp_get_forum_permalink(bbp_get_forum_id()));
    ?>
"
  <?php 
Esempio n. 5
0
/**
 * The main topic loop. WordPress makes this easy for us
 *
 * @since 2.0.0 bbPress (r2485)
 *
 * @param array $args All the arguments supported by {@link WP_Query}
 * @uses current_user_can() To check if the current user can edit other's topics
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses WP_Query To make query and get the topics
 * @uses is_page() To check if it's a page
 * @uses bbp_is_single_forum() To check if it's a forum
 * @uses bbp_get_forum_id() To get the forum id
 * @uses bbp_get_paged() To get the current page value
 * @uses bbp_get_super_stickies() To get the super stickies
 * @uses bbp_get_stickies() To get the forum stickies
 * @uses bbp_use_pretty_urls() To check if the site is using pretty URLs
 * @uses get_permalink() To get the permalink
 * @uses add_query_arg() To add custom args to the url
 * @uses apply_filters() Calls 'bbp_topics_pagination' with the pagination args
 * @uses paginate_links() To paginate the links
 * @uses apply_filters() Calls 'bbp_has_topics' with
 *                        bbPres::topic_query::have_posts()
 *                        and bbPres::topic_query
 * @return object Multidimensional array of topic information
 */
function bbp_has_topics($args = array())
{
    /** Defaults **************************************************************/
    // Other defaults
    $default_topic_search = !empty($_REQUEST['ts']) ? $_REQUEST['ts'] : false;
    $default_show_stickies = (bool) (bbp_is_single_forum() || bbp_is_topic_archive()) && false === $default_topic_search;
    $default_post_parent = bbp_is_single_forum() ? bbp_get_forum_id() : 'any';
    // Default argument array
    $default = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $default_post_parent, 'meta_key' => '_bbp_last_active_time', 'meta_type' => 'DATETIME', 'orderby' => 'meta_value', 'order' => 'DESC', 'posts_per_page' => bbp_get_topics_per_page(), 'paged' => bbp_get_paged(), 'show_stickies' => $default_show_stickies, 'max_num_pages' => false);
    // Only add 's' arg if searching for topics
    // See https://bbpress.trac.wordpress.org/ticket/2607
    if (!empty($default_topic_search)) {
        $default['s'] = $default_topic_search;
    }
    // What are the default allowed statuses (based on user caps)
    if (bbp_get_view_all()) {
        // Default view=all statuses
        $post_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id());
        // Add support for private status
        if (current_user_can('read_private_topics')) {
            $post_statuses[] = bbp_get_private_status_id();
        }
        // Join post statuses together
        $default['post_status'] = implode(',', $post_statuses);
        // Lean on the 'perm' query var value of 'readable' to provide statuses
    } else {
        $default['perm'] = 'readable';
    }
    // Maybe query for topic tags
    if (bbp_is_topic_tag()) {
        $default['term'] = bbp_get_topic_tag_slug();
        $default['taxonomy'] = bbp_get_topic_tag_tax_id();
    }
    /** Setup *****************************************************************/
    // Parse arguments against default values
    $r = bbp_parse_args($args, $default, 'has_topics');
    // Get bbPress
    $bbp = bbpress();
    // Call the query
    $bbp->topic_query = new WP_Query($r);
    // Set post_parent back to 0 if originally set to 'any'
    if ('any' === $r['post_parent']) {
        $r['post_parent'] = 0;
    }
    // Limited the number of pages shown
    if (!empty($r['max_num_pages'])) {
        $bbp->topic_query->max_num_pages = $r['max_num_pages'];
    }
    /** Stickies **************************************************************/
    // Put sticky posts at the top of the posts array
    if (!empty($r['show_stickies']) && $r['paged'] <= 1) {
        // Get super stickies and stickies in this forum
        $stickies = bbp_get_super_stickies();
        // Get stickies for current forum
        if (!empty($r['post_parent'])) {
            $stickies = array_merge($stickies, bbp_get_stickies($r['post_parent']));
        }
        // Remove any duplicate stickies
        $stickies = array_unique($stickies);
        // We have stickies
        if (is_array($stickies) && !empty($stickies)) {
            // Start the offset at -1 so first sticky is at correct 0 offset
            $sticky_offset = -1;
            // Loop over topics and relocate stickies to the front.
            foreach ($stickies as $sticky_index => $sticky_ID) {
                // Get the post offset from the posts array
                $post_offsets = wp_filter_object_list($bbp->topic_query->posts, array('ID' => $sticky_ID), 'OR', 'ID');
                // Continue if no post offsets
                if (empty($post_offsets)) {
                    continue;
                }
                // Loop over posts in current query and splice them into position
                foreach (array_keys($post_offsets) as $post_offset) {
                    $sticky_offset++;
                    $sticky = $bbp->topic_query->posts[$post_offset];
                    // Remove sticky from current position
                    array_splice($bbp->topic_query->posts, $post_offset, 1);
                    // Move to front, after other stickies
                    array_splice($bbp->topic_query->posts, $sticky_offset, 0, array($sticky));
                    // Cleanup
                    unset($stickies[$sticky_index]);
                    unset($sticky);
                }
                // Cleanup
                unset($post_offsets);
            }
            // Cleanup
            unset($sticky_offset);
            // If any posts have been excluded specifically, Ignore those that are sticky.
            if (!empty($stickies) && !empty($r['post__not_in'])) {
                $stickies = array_diff($stickies, $r['post__not_in']);
            }
            // Fetch sticky posts that weren't in the query results
            if (!empty($stickies)) {
                // Query to use in get_posts to get sticky posts
                $sticky_query = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => 'any', 'meta_key' => '_bbp_last_active_time', 'meta_type' => 'DATETIME', 'orderby' => 'meta_value', 'order' => 'DESC', 'include' => $stickies);
                // Cleanup
                unset($stickies);
                // Conditionally exclude private/hidden forum ID's
                $exclude_forum_ids = bbp_exclude_forum_ids('array');
                if (!empty($exclude_forum_ids)) {
                    $sticky_query['post_parent__not_in'] = $exclude_forum_ids;
                }
                // What are the default allowed statuses (based on user caps)
                if (bbp_get_view_all()) {
                    $sticky_query['post_status'] = $r['post_status'];
                    // Lean on the 'perm' query var value of 'readable' to provide statuses
                } else {
                    $sticky_query['post_status'] = $r['perm'];
                }
                // Get all stickies
                $sticky_posts = get_posts($sticky_query);
                if (!empty($sticky_posts)) {
                    // Get a count of the visible stickies
                    $sticky_count = count($sticky_posts);
                    // Merge the stickies topics with the query topics .
                    $bbp->topic_query->posts = array_merge($sticky_posts, $bbp->topic_query->posts);
                    // Adjust loop and counts for new sticky positions
                    $bbp->topic_query->found_posts = (int) $bbp->topic_query->found_posts + (int) $sticky_count;
                    $bbp->topic_query->post_count = (int) $bbp->topic_query->post_count + (int) $sticky_count;
                    // Cleanup
                    unset($sticky_posts);
                }
            }
        }
    }
    // If no limit to posts per page, set it to the current post_count
    if (-1 === $r['posts_per_page']) {
        $r['posts_per_page'] = $bbp->topic_query->post_count;
    }
    // Add pagination values to query object
    $bbp->topic_query->posts_per_page = $r['posts_per_page'];
    $bbp->topic_query->paged = $r['paged'];
    // Only add pagination if query returned results
    if (((int) $bbp->topic_query->post_count || (int) $bbp->topic_query->found_posts) && (int) $bbp->topic_query->posts_per_page) {
        // Limit the number of topics shown based on maximum allowed pages
        if (!empty($r['max_num_pages']) && $bbp->topic_query->found_posts > $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count) {
            $bbp->topic_query->found_posts = $bbp->topic_query->max_num_pages * $bbp->topic_query->post_count;
        }
        // If pretty permalinks are enabled, make our pagination pretty
        if (bbp_use_pretty_urls()) {
            // User's topics
            if (bbp_is_single_user_topics()) {
                $base = bbp_get_user_topics_created_url(bbp_get_displayed_user_id());
                // User's favorites
            } elseif (bbp_is_favorites()) {
                $base = bbp_get_favorites_permalink(bbp_get_displayed_user_id());
                // User's subscriptions
            } elseif (bbp_is_subscriptions()) {
                $base = bbp_get_subscriptions_permalink(bbp_get_displayed_user_id());
                // Root profile page
            } elseif (bbp_is_single_user()) {
                $base = bbp_get_user_profile_url(bbp_get_displayed_user_id());
                // View
            } elseif (bbp_is_single_view()) {
                $base = bbp_get_view_url();
                // Topic tag
            } elseif (bbp_is_topic_tag()) {
                $base = bbp_get_topic_tag_link();
                // Page or single post
            } elseif (is_page() || is_single()) {
                $base = get_permalink();
                // Forum archive
            } elseif (bbp_is_forum_archive()) {
                $base = bbp_get_forums_url();
                // Topic archive
            } elseif (bbp_is_topic_archive()) {
                $base = bbp_get_topics_url();
                // Default
            } else {
                $base = get_permalink((int) $r['post_parent']);
            }
            // Use pagination base
            $base = trailingslashit($base) . user_trailingslashit(bbp_get_paged_slug() . '/%#%/');
            // Unpretty pagination
        } else {
            $base = add_query_arg('paged', '%#%');
        }
        // Pagination settings with filter
        $bbp_topic_pagination = apply_filters('bbp_topic_pagination', array('base' => $base, 'format' => '', 'total' => $r['posts_per_page'] === $bbp->topic_query->found_posts ? 1 : ceil((int) $bbp->topic_query->found_posts / (int) $r['posts_per_page']), 'current' => (int) $bbp->topic_query->paged, 'prev_text' => is_rtl() ? '&rarr;' : '&larr;', 'next_text' => is_rtl() ? '&larr;' : '&rarr;', 'mid_size' => 1));
        // Add pagination to query object
        $bbp->topic_query->pagination_links = paginate_links($bbp_topic_pagination);
        // Remove first page from pagination
        $bbp->topic_query->pagination_links = str_replace(bbp_get_paged_slug() . "/1/'", "'", $bbp->topic_query->pagination_links);
    }
    // Return object
    return apply_filters('bbp_has_topics', $bbp->topic_query->have_posts(), $bbp->topic_query);
}
Esempio n. 6
0
/**
 * Custom page title for bbPress pages
 *
 * @since bbPress (r2788)
 *
 * @param string $title Optional. The title (not used).
 * @param string $sep Optional, default is '&raquo;'. How to separate the
 *                     various items within the page title.
 * @param string $seplocation Optional. Direction to display title, 'right'.
 * @uses bbp_is_single_user() To check if it's a user profile page
 * @uses bbp_is_single_user_edit() To check if it's a user profile edit page
 * @uses bbp_is_user_home() To check if the profile page is of the current user
 * @uses get_query_var() To get the user id
 * @uses get_userdata() To get the user data
 * @uses bbp_is_single_forum() To check if it's a forum
 * @uses bbp_get_forum_title() To get the forum title
 * @uses bbp_is_single_topic() To check if it's a topic
 * @uses bbp_get_topic_title() To get the topic title
 * @uses bbp_is_single_reply() To check if it's a reply
 * @uses bbp_get_reply_title() To get the reply title
 * @uses is_tax() To check if it's the tag page
 * @uses get_queried_object() To get the queried object
 * @uses bbp_is_single_view() To check if it's a view
 * @uses bbp_get_view_title() To get the view title
 * @uses apply_filters() Calls 'bbp_raw_title' with the title
 * @uses apply_filters() Calls 'bbp_profile_page_wp_title' with the title,
 *                        separator and separator location
 * @return string The tite
 */
function bbp_title($title = '', $sep = '&raquo;', $seplocation = '')
{
    // Store original title to compare
    $_title = $title;
    /** Archives **************************************************************/
    // Forum Archive
    if (bbp_is_forum_archive()) {
        $title = bbp_get_forum_archive_title();
        // Topic Archive
    } elseif (bbp_is_topic_archive()) {
        $title = bbp_get_topic_archive_title();
        /** Singles ***************************************************************/
        // Forum page
    } elseif (bbp_is_single_forum()) {
        $title = sprintf(__('Forum: %s', 'bbpress'), bbp_get_forum_title());
        // Topic page
    } elseif (bbp_is_single_topic()) {
        $title = sprintf(__('Topic: %s', 'bbpress'), bbp_get_topic_title());
        // Replies
    } elseif (bbp_is_single_reply()) {
        $title = bbp_get_reply_title();
        // Topic tag page (or edit)
    } elseif (bbp_is_topic_tag() || bbp_is_topic_tag_edit() || get_query_var('bbp_topic_tag')) {
        $term = get_queried_object();
        $title = sprintf(__('Topic Tag: %s', 'bbpress'), $term->name);
        /** Users *****************************************************************/
        // Profile page
    } elseif (bbp_is_single_user()) {
        // Current users profile
        if (bbp_is_user_home()) {
            $title = __('Your Profile', 'bbpress');
            // Other users profile
        } else {
            $userdata = get_userdata(bbp_get_user_id());
            $title = sprintf(__('%s\'s Profile', 'bbpress'), $userdata->display_name);
        }
        // Profile edit page
    } elseif (bbp_is_single_user_edit()) {
        // Current users profile
        if (bbp_is_user_home_edit()) {
            $title = __('Edit Your Profile', 'bbpress');
            // Other users profile
        } else {
            $userdata = get_userdata(bbp_get_user_id());
            $title = sprintf(__('Edit %s\'s Profile', 'bbpress'), $userdata->display_name);
        }
        /** Views *****************************************************************/
        // Views
    } elseif (bbp_is_single_view()) {
        $title = sprintf(__('View: %s', 'bbpress'), bbp_get_view_title());
    }
    // Filter the raw title
    $title = apply_filters('bbp_raw_title', $title, $sep, $seplocation);
    // Compare new title with original title
    if ($title == $_title) {
        return $title;
    }
    // Temporary separator, for accurate flipping, if necessary
    $t_sep = '%WP_TITILE_SEP%';
    $prefix = '';
    if (!empty($title)) {
        $prefix = " {$sep} ";
    }
    // sep on right, so reverse the order
    if ('right' == $seplocation) {
        $title_array = explode($t_sep, $title);
        $title_array = array_reverse($title_array);
        $title = implode(" {$sep} ", $title_array) . $prefix;
        // sep on left, do not reverse
    } else {
        $title_array = explode($t_sep, $title);
        $title = $prefix . implode(" {$sep} ", $title_array);
    }
    // Filter and return
    return apply_filters('bbp_title', $title, $sep, $seplocation);
}
Esempio n. 7
0
                <?php 
    bbp_get_template_part('form', 'search');
    ?>
            </div>
		</div>

	<?php 
}
?>

	<?php 
bbp_breadcrumb();
?>

	<?php 
if (bbp_is_topic_tag()) {
    bbp_topic_tag_description();
}
?>

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

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

		<?php 
    bbp_get_template_part('pagination', 'topics');
    ?>
Esempio n. 8
0
 function x_bbpress_filter_breadcrumbs($r)
 {
     if (bbp_is_search()) {
         $current_text = bbp_get_search_title();
     } elseif (bbp_is_forum_archive()) {
         $current_text = bbp_get_forum_archive_title();
     } elseif (bbp_is_topic_archive()) {
         $current_text = bbp_get_topic_archive_title();
     } elseif (bbp_is_single_view()) {
         $current_text = bbp_get_view_title();
     } elseif (bbp_is_single_forum()) {
         $current_text = bbp_get_forum_title();
     } elseif (bbp_is_single_topic()) {
         $current_text = bbp_get_topic_title();
     } elseif (bbp_is_single_reply()) {
         $current_text = bbp_get_reply_title();
     } elseif (bbp_is_topic_tag() || get_query_var('bbp_topic_tag') && !bbp_is_topic_tag_edit()) {
         // Always include the tag name
         $tag_data[] = bbp_get_topic_tag_name();
         // If capable, include a link to edit the tag
         if (current_user_can('manage_topic_tags')) {
             $tag_data[] = '<a href="' . esc_url(bbp_get_topic_tag_edit_link()) . '" class="bbp-edit-topic-tag-link">' . esc_html__('(Edit)', 'bbpress') . '</a>';
         }
         // Implode the results of the tag data
         $current_text = sprintf(__('Topic Tag: %s', 'bbpress'), implode(' ', $tag_data));
     } elseif (bbp_is_topic_tag_edit()) {
         $current_text = __('Edit', 'bbpress');
     } else {
         $current_text = get_the_title();
     }
     $r = array('before' => '', 'after' => '', 'sep' => x_get_breadcrumb_delimiter(), 'pad_sep' => 0, 'sep_before' => '', 'sep_after' => '', 'crumb_before' => '', 'crumb_after' => '', 'include_home' => false, 'home_text' => x_get_breadcrumb_home_text(), 'include_root' => true, 'root_text' => bbp_get_forum_archive_title(), 'include_current' => true, 'current_text' => $current_text, 'current_before' => x_get_breadcrumb_current_before(), 'current_after' => x_get_breadcrumb_current_after());
     return $r;
 }
Esempio n. 9
0
/**
 * Gets the items for the breadcrumb trail if bbPress is installed.
 *
 * @since 0.5.0
 * @access public
 * @param array $args Mixed arguments for the menu.
 * @return array List of items to be shown in the trail.
 */
function breadcrumb_trail_get_bbpress_items($args = array())
{
    /* Set up a new trail items array. */
    $trail = array();
    /* Get the forum post type object. */
    $post_type_object = get_post_type_object(bbp_get_forum_post_type());
    /* If not viewing the forum root/archive page and a forum archive exists, add it. */
    if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
        $trail[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
    }
    /* If viewing the forum root/archive. */
    if (bbp_is_forum_archive()) {
        $trail[] = "<span>" . bbp_get_forum_archive_title() . "</span>";
    } elseif (bbp_is_topic_archive()) {
        $trail[] = "<span>" . bbp_get_topic_archive_title() . "</span>";
    } elseif (bbp_is_topic_tag()) {
        $trail[] = "<span>" . bbp_get_topic_tag_name() . "</span>";
    } elseif (bbp_is_topic_tag_edit()) {
        $trail[] = '<a href="' . bbp_get_topic_tag_link() . '">' . bbp_get_topic_tag_name() . '</a>';
        $trail[] = "<span>" . __('Edit', 'kleo_framework') . "</span>";
    } elseif (bbp_is_single_view()) {
        $trail[] = '<span>' . bbp_get_view_title() . '</span>';
    } elseif (bbp_is_single_topic()) {
        /* Get the queried topic. */
        $topic_id = get_queried_object_id();
        /* Get the parent items for the topic, which would be its forum (and possibly forum grandparents). */
        $trail = array_merge($trail, breadcrumb_trail_get_parents(bbp_get_topic_forum_id($topic_id)));
        /* If viewing a split, merge, or edit topic page, show the link back to the topic.  Else, display topic title. */
        if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
            $trail[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
        } else {
            $trail[] = '<span>' . bbp_get_topic_title($topic_id) . '</span>';
        }
        /* If viewing a topic split page. */
        if (bbp_is_topic_split()) {
            $trail[] = "<span>" . __('Split', 'kleo_framework') . "</span>";
        } elseif (bbp_is_topic_merge()) {
            $trail[] = "<span>" . __('Merge', 'kleo_framework') . "</span>";
        } elseif (bbp_is_topic_edit()) {
            $trail[] = "<span>" . __('Edit', 'kleo_framework') . "</span>";
        }
    } elseif (bbp_is_single_reply()) {
        /* Get the queried reply object ID. */
        $reply_id = get_queried_object_id();
        /* Get the parent items for the reply, which should be its topic. */
        $trail = array_merge($trail, breadcrumb_trail_get_parents(bbp_get_reply_topic_id($reply_id)));
        /* If viewing a reply edit page, link back to the reply. Else, display the reply title. */
        if (bbp_is_reply_edit()) {
            $trail[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
            $trail[] = "<span>" . __('Edit', 'kleo_framework') . "</span>";
        } else {
            $trail[] = '<span>' . bbp_get_reply_title($reply_id) . '</span>';
        }
    } elseif (bbp_is_single_forum()) {
        /* Get the queried forum ID and its parent forum ID. */
        $forum_id = get_queried_object_id();
        $forum_parent_id = bbp_get_forum_parent_id($forum_id);
        /* If the forum has a parent forum, get its parent(s). */
        if (0 !== $forum_parent_id) {
            $trail = array_merge($trail, breadcrumb_trail_get_parents($forum_parent_id));
        }
        /* Add the forum title to the end of the trail. */
        $trail[] = '<span>' . bbp_get_forum_title($forum_id) . '</span>';
    } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
        if (bbp_is_single_user_edit()) {
            $trail[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
            $trail[] = "<span>" . __('Edit', 'kleo_framework') . "</span>";
        } else {
            $trail[] = '<span>' . bbp_get_displayed_user_field('display_name') . '</span>';
        }
    }
    /* Return the bbPress breadcrumb trail items. */
    return apply_filters('breadcrumb_trail_get_bbpress_items', $trail, $args);
}
Esempio n. 10
0
function porto_breadcrumbs()
{
    // use yoast breadcrumbs if enabled
    if (function_exists('yoast_breadcrumb')) {
        $yoast_breadcrumbs = yoast_breadcrumb('', '', false);
        if ($yoast_breadcrumbs) {
            return $yoast_breadcrumbs;
        }
    }
    global $porto_settings;
    $post = isset($GLOBALS['post']) ? $GLOBALS['post'] : null;
    $output = '';
    // add breadcrumbs prefix
    if (!is_front_page()) {
        if (isset($porto_settings['breadcrumbs-prefix']) && $porto_settings['breadcrumbs-prefix']) {
            $output .= '<span class="breadcrumbs-prefix">' . $porto_settings['breadcrumbs-prefix'] . '</span>';
        }
    }
    // breadcrumbs start wrap
    $output .= '<ul class="breadcrumb">';
    // add home link
    if (!is_front_page()) {
        $output .= porto_breadcrumbs_link(__('Home', 'porto'), apply_filters('woocommerce_breadcrumb_home_url', home_url()));
    } elseif (is_home()) {
        $output .= porto_breadcrumbs_link($porto_settings['blog-title']);
    }
    // add woocommerce shop page link
    if (class_exists('WooCommerce') && (is_woocommerce() && is_archive() && !is_shop() || is_cart() || is_checkout() || is_account_page())) {
        $output .= porto_breadcrumbs_shop_link();
    }
    // add bbpress forums link
    if (class_exists('bbPress') && is_bbpress() && (bbp_is_topic_archive() || bbp_is_single_user() || bbp_is_search() || bbp_is_topic_tag() || bbp_is_edit())) {
        $output .= porto_breadcrumbs_link(bbp_get_forum_archive_title(), get_post_type_archive_link('forum'));
    }
    if (is_singular()) {
        if (isset($post->post_type) && get_post_type_archive_link($post->post_type) && (isset($porto_settings['breadcrumbs-archives-link']) && $porto_settings['breadcrumbs-archives-link'])) {
            $output .= porto_breadcrumbs_archive_link();
        } elseif (isset($post->post_type) && $post->post_type == 'post' && get_option('show_on_front') == 'page' && (isset($porto_settings['breadcrumbs-blog-link']) && $porto_settings['breadcrumbs-blog-link'])) {
            $output .= porto_breadcrumbs_link(get_the_title(get_option('page_for_posts', true)), get_permalink(get_option('page_for_posts')));
        }
        if (isset($post->post_parent) && $post->post_parent == 0) {
            $output .= porto_breadcrumbs_terms_link();
        } else {
            $output .= porto_breadcrumbs_ancestors_link();
        }
        $output .= porto_breadcrumb_leaf();
    } else {
        if (is_post_type_archive()) {
            if (is_search()) {
                $output .= porto_breadcrumbs_archive_link();
                $output .= porto_breadcrumb_leaf('search');
            } else {
                $output .= porto_breadcrumbs_archive_link(false);
            }
        } elseif (is_tax() || is_tag() || is_category()) {
            $html = porto_breadcrumbs_taxonomies_link();
            $html .= porto_breadcrumb_leaf('term');
            if (is_tag()) {
                if (get_option('show_on_front') == 'page' && (isset($porto_settings['breadcrumbs-blog-link']) && $porto_settings['breadcrumbs-blog-link'])) {
                    $output .= porto_breadcrumbs_link(get_the_title(get_option('page_for_posts', true)), get_permalink(get_option('page_for_posts')));
                }
                $output .= sprintf(__('Tag - %s', 'porto'), $html);
            } elseif (is_tax('product_tag')) {
                $output .= sprintf(__('Product Tag - %s', 'porto'), $html);
            } else {
                if (is_category() && get_option('show_on_front') == 'page' && (isset($porto_settings['breadcrumbs-blog-link']) && $porto_settings['breadcrumbs-blog-link'])) {
                    $output .= porto_breadcrumbs_link(get_the_title(get_option('page_for_posts', true)), get_permalink(get_option('page_for_posts')));
                }
                if (is_tax('portfolio_cat') || is_tax('portfolio_skills')) {
                    $output .= porto_breadcrumbs_link(porto_breadcrumbs_archive_name('portfolio'), get_post_type_archive_link('portfolio'));
                }
                if (is_tax('member_cat')) {
                    $output .= porto_breadcrumbs_link(porto_breadcrumbs_archive_name('member'), get_post_type_archive_link('member'));
                }
                if (is_tax('faq_cat')) {
                    $output .= porto_breadcrumbs_link(porto_breadcrumbs_archive_name('faq'), get_post_type_archive_link('faq'));
                }
                $output .= $html;
            }
        } elseif (is_date()) {
            global $wp_locale;
            if (get_option('show_on_front') == 'page' && (isset($porto_settings['breadcrumbs-blog-link']) && $porto_settings['breadcrumbs-blog-link'])) {
                $output .= porto_breadcrumbs_link(get_the_title(get_option('page_for_posts', true)), get_permalink(get_option('page_for_posts')));
            }
            $year = esc_html(get_query_var('year'));
            if (is_month() || is_day()) {
                $month = get_query_var('monthnum');
                $month_name = $wp_locale->get_month($month);
            }
            if (is_year()) {
                $output .= porto_breadcrumb_leaf('year');
            } elseif (is_month()) {
                $output .= porto_breadcrumbs_link($year, get_year_link($year));
                $output .= porto_breadcrumb_leaf('month');
            } elseif (is_day()) {
                $output .= porto_breadcrumbs_link($year, get_year_link($year));
                $output .= porto_breadcrumbs_link($month_name, get_month_link($year, $month));
                $output .= porto_breadcrumb_leaf('day');
            }
        } elseif (is_author()) {
            $output .= porto_breadcrumb_leaf('author');
        } elseif (is_search()) {
            $output .= porto_breadcrumb_leaf('search');
        } elseif (is_404()) {
            $output .= porto_breadcrumb_leaf('404');
        } elseif (class_exists('bbPress') && is_bbpress()) {
            if (bbp_is_search()) {
                $output .= porto_breadcrumb_leaf('bbpress_search');
            } elseif (bbp_is_single_user()) {
                $output .= porto_breadcrumb_leaf('bbpress_user');
            } else {
                $output .= porto_breadcrumb_leaf();
            }
        } else {
            if (is_home() && !is_front_page()) {
                if (get_option('show_on_front') == 'page') {
                    $output .= porto_breadcrumbs_link(get_the_title(get_option('page_for_posts', true)));
                } else {
                    $output .= porto_breadcrumbs_link($porto_settings['blog-title']);
                }
            }
        }
    }
    // breadcrumbs end wrap
    $output .= '</ul>';
    return apply_filters('porto_breadcrumbs', $output);
}
Esempio n. 11
0
 function wm_bbp_content_type($content_type)
 {
     //Preparing output
     if (bbp_is_search() || bbp_is_topic_tag() || bbp_is_single_view()) {
         $content_type = 'bbpress-archive';
     } elseif (bbp_is_single_reply() || bbp_is_topic_edit() || bbp_is_topic_merge() || bbp_is_topic_split() || bbp_is_reply_edit() || bbp_is_reply_move() || bbp_is_topic_tag_edit() || bbp_is_single_user() || bbp_is_single_user_edit()) {
         $content_type = 'bbpress-article';
     }
     //Output
     return apply_filters('wmhook_wm_bbp_content_type_output', $content_type);
 }
?>

<div id="bbpress-forums">

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

		<div class="bbp-search-form">

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

		</div>

	<?php endif; ?>


	<?php if ( bbp_is_topic_tag() ) bbp_topic_tag_description(); ?>

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

	<?php if ( 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 else : ?>

		<?php bbp_get_template_part( 'feedback',   'no-topics' ); ?>
Esempio n. 13
0
 /**
  * Displays or hides specific widget
  */
 private function restrict_widget($instance, $filter = true, $args = array())
 {
     global $wp_query;
     $display_lang = $display_user = $display_device = $display_main = '';
     $empty_lang = $empty_user = $empty_device = $empty_main = true;
     $return = false;
     $post_id = $wp_query->get_queried_object_id();
     $display_type = isset($instance['rw_opt']['widget_select']) ? $instance['rw_opt']['widget_select'] : false;
     //languages
     if (isset($instance['rw_opt']) && $this->is_widget_empty($instance['rw_opt'], 'lang') === false) {
         if ($this->polylang_active === true || $this->wpml_active === true) {
             $empty_lang = false;
             //fix for WPML
             if (function_exists('icl_object_id')) {
                 global $sitepress;
                 if (isset($sitepress)) {
                     $post_id = icl_object_id($post_id, 'page', true, $sitepress->get_default_language());
                 } else {
                     $post_id = icl_object_id($post_id, 'page', false);
                 }
             }
             $found_lang = defined('ICL_LANGUAGE_CODE') && isset($instance['rw_opt']['language_' . ICL_LANGUAGE_CODE]) ? true : false;
             if ($display_type === true) {
                 if ($found_lang === true) {
                     $display_lang = true;
                 } else {
                     $return = true;
                     $display_lang = false;
                 }
             } else {
                 $display_lang = $found_lang === true ? false : true;
             }
         } else {
             $display_lang = true;
         }
     } else {
         $display_lang = true;
     }
     //users
     if ($return === false) {
         if (isset($instance['rw_opt']) && $this->is_widget_empty($instance['rw_opt'], 'user') === false) {
             $empty_user = false;
             if (is_user_logged_in()) {
                 if (isset($instance['rw_opt']['users_logged_in'], $instance['rw_opt']['users_logged_out']) || isset($instance['rw_opt']['users_logged_in'])) {
                     $found_user = true;
                 } elseif (isset($instance['rw_opt']['users_logged_out'])) {
                     $found_user = false;
                 }
             } else {
                 if (isset($instance['rw_opt']['users_logged_out'], $instance['rw_opt']['users_logged_in']) || isset($instance['rw_opt']['users_logged_out'])) {
                     $found_user = true;
                 } elseif (isset($instance['rw_opt']['users_logged_in'])) {
                     $found_user = false;
                 }
             }
             if ($display_type === true) {
                 if ($found_user === true) {
                     $display_user = true;
                 } else {
                     $return = true;
                     $display_user = false;
                 }
             } else {
                 $display_user = $found_user === true ? false : true;
             }
         } else {
             $display_user = true;
         }
     }
     //devices
     if ($return === false) {
         if (isset($instance['rw_opt']) && $this->is_widget_empty($instance['rw_opt'], 'device') === false) {
             $empty_device = false;
             if (wp_is_mobile()) {
                 if (isset($instance['rw_opt']['devices_mobile'], $instance['rw_opt']['devices_desktop']) || isset($instance['rw_opt']['devices_mobile'])) {
                     $found_device = true;
                 } elseif (isset($instance['rw_opt']['devices_desktop'])) {
                     $found_device = false;
                 }
             } else {
                 if (isset($instance['rw_opt']['devices_desktop'], $instance['rw_opt']['devices_mobile']) || isset($instance['rw_opt']['devices_desktop'])) {
                     $found_device = true;
                 } elseif (isset($instance['rw_opt']['devices_mobile'])) {
                     $found_device = false;
                 }
             }
             if ($display_type === true) {
                 if ($found_device === true) {
                     $display_device = true;
                 } else {
                     $return = true;
                     $display_device = false;
                 }
             } else {
                 $display_device = $found_device === true ? false : true;
             }
         } else {
             $display_device = true;
         }
     }
     //others
     if ($return === false) {
         if (isset($instance['rw_opt']) && $this->is_widget_empty($instance['rw_opt'], 'main') === false) {
             $empty_main = false;
             if (is_front_page()) {
                 $found_main = isset($instance['rw_opt']['others_front_page']) ? true : false;
                 if (is_home() && $found_main == false) {
                     $found_main = isset($instance['rw_opt']['others_blog_page']) ? true : false;
                 }
             } elseif (is_home()) {
                 $found_main = isset($instance['rw_opt']['others_blog_page']) ? true : false;
             } elseif (is_singular()) {
                 if (is_page()) {
                     if (isset($instance['rw_opt']['cpt_' . get_post_type($post_id)])) {
                         $found_main = true;
                     } else {
                         $found_main = isset($instance['rw_opt']['pageid_' . $post_id]) ? true : false;
                     }
                 } else {
                     $found_main = isset($instance['rw_opt']['cpt_' . get_post_type($post_id)]) ? true : false;
                     if (is_single() && $found_main == false) {
                         $found_main = isset($instance['rw_opt']['others_single_post']) ? true : false;
                     }
                 }
             } elseif (is_post_type_archive()) {
                 $found_main = isset($instance['rw_opt']['cpta_' . get_query_var('post_type')]) ? true : false;
             } elseif (is_category()) {
                 $found_main = isset($instance['rw_opt']['category_' . get_query_var('cat')]) ? true : false;
             } elseif (is_tag()) {
                 if (($object = get_queried_object()) !== NULL && isset($object->taxonomy) && $object->taxonomy === 'post_tag') {
                     $tag = 'wp_log_type';
                 } else {
                     $tag = '';
                 }
                 $found_main = isset($instance['rw_opt']['taxonomy_' . $tag]) ? true : false;
             } elseif (is_tax()) {
                 $found_main = isset($instance['rw_opt']['taxonomy_' . get_query_var('taxonomy')]) ? true : false;
             } elseif (is_404()) {
                 $found_main = isset($instance['rw_opt']['others_404_page']) ? true : false;
             } elseif (is_sticky()) {
                 $found_main = isset($instance['rw_opt']['others_sticky_post']) ? true : false;
             } elseif (is_search()) {
                 $found_main = isset($instance['rw_opt']['others_search_page']) ? true : false;
             } elseif (is_author()) {
                 $found_main = isset($instance['rw_opt']['others_author_archive']) ? true : false;
             } elseif (is_date()) {
                 $found_main = isset($instance['rw_opt']['others_date_archive']) ? true : false;
             } elseif (function_exists('bbp_is_search') && bbp_is_search()) {
                 $found_main = isset($instance['rw_opt']['bbpress_search']) ? true : false;
             } elseif (function_exists('bbp_is_single_user') && bbp_is_single_user()) {
                 $found_main = isset($instance['rw_opt']['bbpress_single_user']) ? true : false;
             } elseif (function_exists('bbp_is_topic_tag') && bbp_is_topic_tag()) {
                 $found_main = isset($instance['rw_opt']['bbpress_topic_tag']) ? true : false;
             }
             $display_main = $display_type === true ? $found_main === true ? true : false : ($found_main === true ? false : true);
         } else {
             $display_main = true;
         }
     }
     if ($filter === false) {
         $instance = true;
     }
     if ($display_type === true) {
         $final_return = $display_lang === true && $display_user === true && $display_device === true && $display_main === true ? $instance : false;
     } else {
         $final_return = $empty_lang === false && $empty_user === false && $empty_device === false && $empty_main === false && $display_lang === false && $display_user === false && $display_device === false && $display_main === false || $empty_lang === false && $empty_user === false && $empty_device === false && $display_lang === false && $display_user === false && $display_device === false || $empty_lang === false && $empty_user === false && $empty_main === false && $display_lang === false && $display_user === false && $display_main === false || $empty_lang === false && $empty_device === false && $empty_main === false && $display_lang === false && $display_device === false && $display_main === false || $empty_user === false && $empty_device === false && $empty_main === false && $display_user === false && $display_device === false && $display_main === false || $empty_lang === false && $empty_user === false && $display_lang === false && $display_user === false || $empty_lang === false && $empty_device === false && $display_lang === false && $display_device === false || $empty_lang === false && $empty_main === false && $display_lang === false && $display_main === false || $empty_user === false && $empty_device === false && $display_user === false && $display_device === false || $empty_user === false && $empty_main === false && $display_user === false && $display_main === false || $empty_device === false && $empty_main === false && $display_device === false && $display_main === false || $empty_lang === false && $display_lang === false || $empty_user === false && $display_user === false || $empty_device === false && $display_device === false || $empty_main === false && $display_main === false ? false : $instance;
     }
     //filter true or false
     if ($filter === true) {
         $final_return = apply_filters_ref_array('rw_display_widget', array($final_return, $instance));
     }
     //if true return instance
     $final_return = $final_return === false ? false : $instance;
     //display: return $instance, hide: return false
     return $final_return;
 }
Esempio n. 14
0
 function hippo_title_text()
 {
     $query = get_queried_object();
     if (is_archive()) {
         if (is_day()) {
             $archive_title = get_the_time('d F, Y');
             $title = sprintf(esc_html__('Archive of: %s', 'monsoon'), $archive_title);
         } elseif (is_month()) {
             $archive_title = get_the_time('F Y');
             $title = sprintf(esc_html__('Archive of: %s', 'monsoon'), $archive_title);
         } elseif (is_year()) {
             $archive_title = get_the_time('Y');
             $title = sprintf(esc_html__('Archive of: %s', 'monsoon'), $archive_title);
         }
     }
     if (is_404()) {
         $title = esc_html__('404 Not Found', 'monsoon');
     }
     if (is_search()) {
         $title = sprintf(esc_html__('Search result for: "%s"', 'monsoon'), get_search_query());
     }
     if (function_exists('bbp_is_search') and bbp_is_search()) {
         $title = sprintf(esc_html__('Search result for: "%s"', 'monsoon'), get_search_query());
     }
     if (is_category()) {
         $title = sprintf(esc_html__('Category: %s', 'monsoon'), $query->name);
     }
     if (is_tag()) {
         $title = sprintf(esc_html__('Tag: %s', 'monsoon'), $query->name);
     }
     if (function_exists('bbp_is_topic_tag') and bbp_is_topic_tag()) {
         $title = sprintf(esc_html__('Tag: %s', 'monsoon'), $query->name);
     }
     if (is_author()) {
         $title = sprintf(esc_html__('Posts of: %s', 'monsoon'), $query->display_name);
     }
     if (is_page()) {
         $title = esc_html($query->post_title);
     }
     if (is_home() or is_single()) {
         $title = esc_html(hippo_option('blog-title'));
     }
     if (is_singular('service')) {
         $title = esc_html(get_the_title());
     }
     if (is_singular('portfolio')) {
         $title = esc_html(get_the_title());
     }
     if (is_tax('portfolio-type')) {
         $title = sprintf(esc_html__('%s', 'monsoon'), $query->name);
     }
     if (is_singular('team')) {
         $title = esc_html(get_the_title());
     }
     if (is_singular('forum')) {
         $title = esc_html(get_the_title());
     }
     if (is_singular('topic')) {
         $title = esc_html(get_the_title());
     }
     if (is_singular('product')) {
         $title = esc_html(get_the_title());
     }
     if (is_post_type_archive('product')) {
         $title = esc_html(post_type_archive_title('', FALSE));
     }
     if (is_post_type_archive('forum')) {
         $title = esc_html(post_type_archive_title('', FALSE));
     }
     if (is_post_type_archive('topic')) {
         $title = esc_html(post_type_archive_title('', FALSE));
     }
     if (function_exists('bbp_is_single_user') and bbp_is_single_user()) {
         $title = esc_html(get_the_title());
     }
     if (function_exists('bbp_is_reply_edit') and bbp_is_reply_edit()) {
         $title = esc_html(get_the_title());
     }
     if (class_exists('WooCommerce')) {
         if (is_product_category()) {
             $title = sprintf(esc_html__('%s', 'monsoon'), $query->name);
         }
         if (is_product_tag()) {
             $title = sprintf(esc_html__('%s', 'monsoon'), $query->name);
         }
     }
     $title = apply_filters('hippo_title_text', $title, $title);
     if (empty($title)) {
         $title = esc_html(get_bloginfo('name'));
     }
     return $title;
 }
Esempio n. 15
0
/**
 * Reset main query vars and filter 'the_content' to output a bbPress
 * template part as needed.
 *
 * @since bbPress (r3032)
 * @param string $template
 * @uses bbp_is_single_user() To check if page is single user
 * @uses bbp_get_single_user_template() To get user template
 * @uses bbp_is_single_user_edit() To check if page is single user edit
 * @uses bbp_get_single_user_edit_template() To get user edit template
 * @uses bbp_is_single_view() To check if page is single view
 * @uses bbp_get_single_view_template() To get view template
 * @uses bbp_is_forum_edit() To check if page is forum edit
 * @uses bbp_get_forum_edit_template() To get forum edit template
 * @uses bbp_is_topic_merge() To check if page is topic merge
 * @uses bbp_get_topic_merge_template() To get topic merge template
 * @uses bbp_is_topic_split() To check if page is topic split
 * @uses bbp_get_topic_split_template() To get topic split template
 * @uses bbp_is_topic_edit() To check if page is topic edit
 * @uses bbp_get_topic_edit_template() To get topic edit template
 * @uses bbp_is_reply_edit() To check if page is reply edit
 * @uses bbp_get_reply_edit_template() To get reply edit template
 * @uses bbp_set_theme_compat_template() To set the global theme compat template
 */
function bbp_template_include_theme_compat($template = '')
{
    // Bail if the template already matches a bbPress template. This includes
    // archive-* and single-* WordPress post_type matches (allowing
    // themes to use the expected format) as well as all bbPress-specific
    // template files for users, topics, forums, etc...
    if (!empty(bbpress()->theme_compat->bbpress_template)) {
        return $template;
    }
    /** Users *************************************************************/
    if (bbp_is_single_user_edit() || bbp_is_single_user()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_title' => esc_attr(bbp_get_displayed_user_field('display_name')), 'post_status' => bbp_get_public_status_id(), 'is_archive' => false, 'comment_status' => 'closed'));
        /** Forums ************************************************************/
        // Forum archive
    } elseif (bbp_is_forum_archive()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_forum_archive_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed'));
        // Single Forum
    } elseif (bbp_is_forum_edit() || bbp_is_single_forum()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_forum_id(), 'post_title' => bbp_get_forum_title(), 'post_author' => bbp_get_forum_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_forum_id()), 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_forum_visibility(), 'is_single' => true, 'comment_status' => 'closed'));
        /** Topics ************************************************************/
        // Topic archive
    } elseif (bbp_is_topic_archive()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_topic_archive_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed'));
        // Single Topic
    } elseif (bbp_is_topic_edit() || bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_single_topic()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_topic_id(), 'post_title' => bbp_get_topic_title(), 'post_author' => bbp_get_topic_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_topic_id()), 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_topic_status(), 'is_single' => true, 'comment_status' => 'closed'));
        /** Replies ***********************************************************/
        // Reply archive
    } elseif (is_post_type_archive(bbp_get_reply_post_type())) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => __('Replies', 'bbpress'), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
        // Single Reply
    } elseif (bbp_is_reply_edit() || bbp_is_single_reply()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_reply_id(), 'post_title' => bbp_get_reply_title(), 'post_author' => bbp_get_reply_author_id(), 'post_date' => 0, 'post_content' => get_post_field('post_content', bbp_get_reply_id()), 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_reply_status(), 'comment_status' => 'closed'));
        /** Views *************************************************************/
    } elseif (bbp_is_single_view()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_view_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
        /** Topic Tags ********************************************************/
        // Topic Tag Edit
    } elseif (bbp_is_topic_tag_edit()) {
        // Stash the current term in a new var
        set_query_var('bbp_topic_tag', get_query_var('term'));
        // Reset the post with our new title
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_title' => sprintf(__('Topic Tag: %s', 'bbpress'), '<span>' . bbp_get_topic_tag_name() . '</span>'), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
        // Topc Tag
    } elseif (bbp_is_topic_tag()) {
        // Stash the current term in a new var
        set_query_var('bbp_topic_tag', get_query_var('term'));
        // Reset the post with our new title
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => '', 'post_type' => '', 'post_title' => sprintf(__('Topic Tag: %s', 'bbpress'), '<span>' . bbp_get_topic_tag_name() . '</span>'), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
    }
    /**
     * If we are relying on bbPress's built in theme compatibility to load
     * the proper content, we need to intercept the_content, replace the
     * output, and display ours instead.
     *
     * To do this, we first remove all filters from 'the_content' and hook
     * our own function into it, which runs a series of checks to determine
     * the context, and then uses the built in shortcodes to output the
     * correct results from inside an output buffer.
     *
     * Uses bbp_get_theme_compat_templates() to provide fall-backs that
     * should be coded without superfluous mark-up and logic (prev/next
     * navigation, comments, date/time, etc...)
     * 
     * Hook into the 'bbp_get_bbpress_template' to override the array of
     * possible templates, or 'bbp_bbpress_template' to override the result.
     */
    if (bbp_is_theme_compat_active()) {
        // Remove all filters from the_content
        bbp_remove_all_filters('the_content');
        // Add a filter on the_content late, which we will later remove
        add_filter('the_content', 'bbp_replace_the_content');
        // Find the appropriate template file
        $template = bbp_get_theme_compat_templates();
    }
    return apply_filters('bbp_template_include_theme_compat', $template);
}
Esempio n. 16
0
/**
 * Add checks for bbPress conditions to parse_query action
 *
 * If it's a user page, WP_Query::bbp_is_single_user is set to true.
 * If it's a user edit page, WP_Query::bbp_is_single_user_edit is set to true
 * and the the 'wp-admin/includes/user.php' file is included.
 * In addition, on user/user edit pages, WP_Query::home is set to false & query
 * vars 'bbp_user_id' with the displayed user id and 'author_name' with the
 * displayed user's nicename are added.
 *
 * If it's a forum edit, WP_Query::bbp_is_forum_edit is set to true
 * If it's a topic edit, WP_Query::bbp_is_topic_edit is set to true
 * If it's a reply edit, WP_Query::bbp_is_reply_edit is set to true.
 *
 * If it's a view page, WP_Query::bbp_is_view is set to true
 *
 * @since bbPress (r2688)
 *
 * @param WP_Query $posts_query
 *
 * @uses get_query_var() To get {@link WP_Query} query var
 * @uses is_email() To check if the string is an email
 * @uses get_user_by() To try to get the user by email and nicename
 * @uses WP_User to get the user data
 * @uses WP_Query::set_404() To set a 404 status
 * @uses current_user_can() To check if the current user can edit the user
 * @uses apply_filters() Calls 'enable_edit_any_user_configuration' with true
 * @uses bbp_get_view_query_args() To get the view query args
 * @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
 * @uses remove_action() To remove the auto save post revision action
 */
function bbp_parse_query($posts_query)
{
    // Bail if $posts_query is not the main loop
    if (!$posts_query->is_main_query()) {
        return;
    }
    // Bail if filters are suppressed on this query
    if (true == $posts_query->get('suppress_filters')) {
        return;
    }
    // Bail if in admin
    if (is_admin()) {
        return;
    }
    // Get query variables
    $bbp_user = $posts_query->get(bbp_get_user_rewrite_id());
    $bbp_view = $posts_query->get(bbp_get_view_rewrite_id());
    $is_edit = $posts_query->get(bbp_get_edit_rewrite_id());
    // It is a user page - We'll also check if it is user edit
    if (!empty($bbp_user)) {
        // Not a user_id so try email and slug
        if (!is_numeric($bbp_user)) {
            // Email was passed
            if (is_email($bbp_user)) {
                $bbp_user = get_user_by('email', $bbp_user);
                // Try nicename
            } else {
                $bbp_user = get_user_by('slug', $bbp_user);
            }
            // If we were successful, set to ID
            if (is_object($bbp_user)) {
                $bbp_user = $bbp_user->ID;
            }
        }
        // Create new user
        $user = new WP_User($bbp_user);
        // Bail if no user
        if (!isset($user) || empty($user) || empty($user->ID)) {
            $posts_query->set_404();
            return;
        }
        /** User Exists *******************************************************/
        // View or edit?
        if (!empty($is_edit)) {
            // We are editing a profile
            $posts_query->bbp_is_single_user_edit = true;
            // Load the core WordPress contact methods
            if (!function_exists('_wp_get_user_contactmethods')) {
                include_once ABSPATH . 'wp-includes/registration.php';
            }
            // Load the edit_user functions
            if (!function_exists('edit_user')) {
                require_once ABSPATH . 'wp-admin/includes/user.php';
            }
            // Editing a user
            $posts_query->bbp_is_edit = true;
            // We are viewing a profile
        } else {
            $posts_query->bbp_is_single_user = true;
        }
        // Make sure 404 is not set
        $posts_query->is_404 = false;
        // Correct is_home variable
        $posts_query->is_home = false;
        // Set bbp_user_id for future reference
        $posts_query->set('bbp_user_id', $user->ID);
        // Set author_name as current user's nicename to get correct posts
        $posts_query->set('author_name', $user->user_nicename);
        // Set the displayed user global to this user
        bbpress()->displayed_user = $user;
        // View Page
    } elseif (!empty($bbp_view)) {
        // Check if the view exists by checking if there are query args are set
        $view_args = bbp_get_view_query_args($bbp_view);
        // Bail if view args is false (view isn't registered)
        if (false === $view_args) {
            $posts_query->set_404();
            return;
        }
        // Correct is_home variable
        $posts_query->is_home = false;
        // We are in a custom topic view
        $posts_query->bbp_is_view = true;
        // Forum/Topic/Reply Edit Page
    } elseif (!empty($is_edit)) {
        // Get the post type from the main query loop
        $post_type = $posts_query->get('post_type');
        // Check which post_type we are editing, if any
        if (!empty($post_type)) {
            switch ($post_type) {
                // We are editing a forum
                case bbp_get_forum_post_type():
                    $posts_query->bbp_is_forum_edit = true;
                    $posts_query->bbp_is_edit = true;
                    break;
                    // We are editing a topic
                // We are editing a topic
                case bbp_get_topic_post_type():
                    $posts_query->bbp_is_topic_edit = true;
                    $posts_query->bbp_is_edit = true;
                    break;
                    // We are editing a reply
                // We are editing a reply
                case bbp_get_reply_post_type():
                    $posts_query->bbp_is_reply_edit = true;
                    $posts_query->bbp_is_edit = true;
                    break;
            }
            // We are editing a topic tag
        } elseif (bbp_is_topic_tag()) {
            $posts_query->bbp_is_topic_tag_edit = true;
            $posts_query->bbp_is_edit = true;
        }
        // We save post revisions on our own
        remove_action('pre_post_update', 'wp_save_post_revision');
        // Topic tag page
    } elseif (bbp_is_topic_tag()) {
        $posts_query->set('bbp_topic_tag', get_query_var('term'));
        $posts_query->set('post_type', bbp_get_topic_post_type());
        $posts_query->set('posts_per_page', bbp_get_topics_per_page());
    }
}
Esempio n. 17
0
/**
 * Add checks for bbPress conditions to parse_query action
 *
 * If it's a user page, WP_Query::bbp_is_single_user is set to true.
 * If it's a user edit page, WP_Query::bbp_is_single_user_edit is set to true
 * and the the 'wp-admin/includes/user.php' file is included.
 * In addition, on user/user edit pages, WP_Query::home is set to false & query
 * vars 'bbp_user_id' with the displayed user id and 'author_name' with the
 * displayed user's nicename are added.
 *
 * If it's a forum edit, WP_Query::bbp_is_forum_edit is set to true
 * If it's a topic edit, WP_Query::bbp_is_topic_edit is set to true
 * If it's a reply edit, WP_Query::bbp_is_reply_edit is set to true.
 *
 * If it's a view page, WP_Query::bbp_is_view is set to true
 * If it's a search page, WP_Query::bbp_is_search is set to true
 *
 * @since bbPress (r2688)
 *
 * @param WP_Query $posts_query
 *
 * @uses get_query_var() To get {@link WP_Query} query var
 * @uses is_email() To check if the string is an email
 * @uses get_user_by() To try to get the user by email and nicename
 * @uses get_userdata() to get the user data
 * @uses current_user_can() To check if the current user can edit the user
 * @uses is_user_member_of_blog() To check if user profile page exists
 * @uses WP_Query::set_404() To set a 404 status
 * @uses apply_filters() Calls 'enable_edit_any_user_configuration' with true
 * @uses bbp_get_view_query_args() To get the view query args
 * @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
 * @uses remove_action() To remove the auto save post revision action
 */
function bbp_parse_query($posts_query)
{
    // Bail if $posts_query is not the main loop
    if (!$posts_query->is_main_query()) {
        return;
    }
    // Bail if filters are suppressed on this query
    if (true === $posts_query->get('suppress_filters')) {
        return;
    }
    // Bail if in admin
    if (is_admin()) {
        return;
    }
    // Get query variables
    $bbp_view = $posts_query->get(bbp_get_view_rewrite_id());
    $bbp_user = $posts_query->get(bbp_get_user_rewrite_id());
    $is_edit = $posts_query->get(bbp_get_edit_rewrite_id());
    // It is a user page - We'll also check if it is user edit
    if (!empty($bbp_user)) {
        /** Find User *********************************************************/
        // Setup the default user variable
        $the_user = false;
        // If using pretty permalinks, use the email or slug
        if (get_option('permalink_structure')) {
            // Email was passed
            if (is_email($bbp_user)) {
                $the_user = get_user_by('email', $bbp_user);
                // Try nicename
            } else {
                $the_user = get_user_by('slug', $bbp_user);
            }
        }
        // No user found by slug/email, so try the ID if it's numeric
        if (empty($the_user) && is_numeric($bbp_user)) {
            $the_user = get_user_by('id', $bbp_user);
        }
        // 404 and bail if user does not have a profile
        if (empty($the_user->ID) || !bbp_user_has_profile($the_user->ID)) {
            $posts_query->set_404();
            return;
        }
        /** User Exists *******************************************************/
        $is_favs = $posts_query->get(bbp_get_user_favorites_rewrite_id());
        $is_subs = $posts_query->get(bbp_get_user_subscriptions_rewrite_id());
        $is_topics = $posts_query->get(bbp_get_user_topics_rewrite_id());
        $is_replies = $posts_query->get(bbp_get_user_replies_rewrite_id());
        // View or edit?
        if (!empty($is_edit)) {
            // We are editing a profile
            $posts_query->bbp_is_single_user_edit = true;
            // Load the core WordPress contact methods
            if (!function_exists('_wp_get_user_contactmethods')) {
                include_once ABSPATH . 'wp-includes/registration.php';
            }
            // Load the edit_user functions
            if (!function_exists('edit_user')) {
                require_once ABSPATH . 'wp-admin/includes/user.php';
            }
            // Load the grant/revoke super admin functions
            if (is_multisite() && !function_exists('revoke_super_admin')) {
                require_once ABSPATH . 'wp-admin/includes/ms.php';
            }
            // Editing a user
            $posts_query->bbp_is_edit = true;
            // User favorites
        } elseif (!empty($is_favs)) {
            $posts_query->bbp_is_single_user_favs = true;
            // User subscriptions
        } elseif (!empty($is_subs)) {
            $posts_query->bbp_is_single_user_subs = true;
            // User topics
        } elseif (!empty($is_topics)) {
            $posts_query->bbp_is_single_user_topics = true;
            // User topics
        } elseif (!empty($is_replies)) {
            $posts_query->bbp_is_single_user_replies = true;
            // User profile
        } else {
            $posts_query->bbp_is_single_user_profile = true;
        }
        // Looking at a single user
        $posts_query->bbp_is_single_user = true;
        // Make sure 404 is not set
        $posts_query->is_404 = false;
        // Correct is_home variable
        $posts_query->is_home = false;
        // User is looking at their own profile
        if (get_current_user_id() === $the_user->ID) {
            $posts_query->bbp_is_single_user_home = true;
        }
        // Set bbp_user_id for future reference
        $posts_query->set('bbp_user_id', $the_user->ID);
        // Set author_name as current user's nicename to get correct posts
        $posts_query->set('author_name', $the_user->user_nicename);
        // Set the displayed user global to this user
        bbpress()->displayed_user = $the_user;
        // View Page
    } elseif (!empty($bbp_view)) {
        // Check if the view exists by checking if there are query args are set
        $view_args = bbp_get_view_query_args($bbp_view);
        // Bail if view args is false (view isn't registered)
        if (false === $view_args) {
            $posts_query->set_404();
            return;
        }
        // Correct is_home variable
        $posts_query->is_home = false;
        // We are in a custom topic view
        $posts_query->bbp_is_view = true;
        // Search Page
    } elseif (isset($posts_query->query_vars[bbp_get_search_rewrite_id()])) {
        // Check if there are search query args set
        $search_terms = bbp_get_search_terms();
        if (!empty($search_terms)) {
            $posts_query->bbp_search_terms = $search_terms;
        }
        // Correct is_home variable
        $posts_query->is_home = false;
        // We are in a search query
        $posts_query->bbp_is_search = true;
        // Forum/Topic/Reply Edit Page
    } elseif (!empty($is_edit)) {
        // Get the post type from the main query loop
        $post_type = $posts_query->get('post_type');
        // Check which post_type we are editing, if any
        if (!empty($post_type)) {
            switch ($post_type) {
                // We are editing a forum
                case bbp_get_forum_post_type():
                    $posts_query->bbp_is_forum_edit = true;
                    $posts_query->bbp_is_edit = true;
                    break;
                    // We are editing a topic
                // We are editing a topic
                case bbp_get_topic_post_type():
                    $posts_query->bbp_is_topic_edit = true;
                    $posts_query->bbp_is_edit = true;
                    break;
                    // We are editing a reply
                // We are editing a reply
                case bbp_get_reply_post_type():
                    $posts_query->bbp_is_reply_edit = true;
                    $posts_query->bbp_is_edit = true;
                    break;
            }
            // We are editing a topic tag
        } elseif (bbp_is_topic_tag()) {
            $posts_query->bbp_is_topic_tag_edit = true;
            $posts_query->bbp_is_edit = true;
        }
        // We save post revisions on our own
        remove_action('pre_post_update', 'wp_save_post_revision');
        // Topic tag page
    } elseif (bbp_is_topic_tag()) {
        $posts_query->set('bbp_topic_tag', get_query_var('term'));
        $posts_query->set('post_type', bbp_get_topic_post_type());
        $posts_query->set('posts_per_page', bbp_get_topics_per_page());
        // Do topics on forums root
    } elseif (is_post_type_archive(array(bbp_get_forum_post_type(), bbp_get_topic_post_type())) && 'topics' === bbp_show_on_root()) {
        $posts_query->bbp_show_topics_on_root = true;
    }
}
Esempio n. 18
0
 static function media_view_settings($settings, $post)
 {
     $forum_id = 0;
     if (is_admin()) {
     } elseif (bbp_is_single_user_edit() || bbp_is_single_user()) {
     } elseif (bbp_is_forum_archive()) {
     } elseif (bbp_is_forum_edit()) {
         $forum_id = bbp_get_forum_id();
     } elseif (bbp_is_single_forum()) {
         $forum_id = bbp_get_forum_id();
     } elseif (bbp_is_topic_archive()) {
     } elseif (bbp_is_topic_edit() || bbp_is_single_topic()) {
         $forum_id = bbp_get_forum_id();
     } elseif (is_post_type_archive(bbp_get_reply_post_type())) {
     } elseif (bbp_is_reply_edit() || bbp_is_single_reply()) {
         $forum_id = bbp_get_forum_id();
     } elseif (bbp_is_single_view()) {
     } elseif (bbp_is_search()) {
     } elseif (bbp_is_topic_tag_edit() || bbp_is_topic_tag()) {
         $forum_id = bbp_get_forum_id();
     }
     if ($forum_id) {
         // @setcookie('_bbp_forum_id', $forum_id, 0, COOKIEPATH, COOKIE_DOMAIN);
         if (empty($settings['post'])) {
             $settings['post'] = array('id' => $forum_id, 'nonce' => wp_create_nonce('update-post_' . $forum_id));
         }
     } else {
         // @setcookie('_bbp_forum_id', ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN);
     }
     return $settings;
 }
Esempio n. 19
0
/**
 * Custom page title for bbPress pages
 *
 * @since bbPress (r2788)
 *
 * @param string $title Optional. The title (not used).
 * @param string $sep Optional, default is '&raquo;'. How to separate the
 *                     various items within the page title.
 * @param string $seplocation Optional. Direction to display title, 'right'.
 * @uses bbp_is_single_user() To check if it's a user profile page
 * @uses bbp_is_single_user_edit() To check if it's a user profile edit page
 * @uses bbp_is_user_home() To check if the profile page is of the current user
 * @uses get_query_var() To get the user id
 * @uses get_userdata() To get the user data
 * @uses bbp_is_single_forum() To check if it's a forum
 * @uses bbp_get_forum_title() To get the forum title
 * @uses bbp_is_single_topic() To check if it's a topic
 * @uses bbp_get_topic_title() To get the topic title
 * @uses bbp_is_single_reply() To check if it's a reply
 * @uses bbp_get_reply_title() To get the reply title
 * @uses is_tax() To check if it's the tag page
 * @uses get_queried_object() To get the queried object
 * @uses bbp_is_single_view() To check if it's a view
 * @uses bbp_get_view_title() To get the view title
 * @uses apply_filters() Calls 'bbp_raw_title' with the title
 * @uses apply_filters() Calls 'bbp_profile_page_wp_title' with the title,
 *                        separator and separator location
 * @return string The tite
 */
function bbp_title($title = '', $sep = '&raquo;', $seplocation = '')
{
    // Title array
    $new_title = array();
    /** Archives **************************************************************/
    // Forum Archive
    if (bbp_is_forum_archive()) {
        $new_title['text'] = bbp_get_forum_archive_title();
        // Topic Archive
    } elseif (bbp_is_topic_archive()) {
        $new_title['text'] = bbp_get_topic_archive_title();
        /** Edit ******************************************************************/
        // Forum edit page
    } elseif (bbp_is_forum_edit()) {
        $new_title['text'] = bbp_get_forum_title();
        $new_title['format'] = esc_attr__('Forum Edit: %s', 'bbpress');
        // Topic edit page
    } elseif (bbp_is_topic_edit()) {
        $new_title['text'] = bbp_get_topic_title();
        $new_title['format'] = esc_attr__('Topic Edit: %s', 'bbpress');
        // Reply edit page
    } elseif (bbp_is_reply_edit()) {
        $new_title['text'] = bbp_get_reply_title();
        $new_title['format'] = esc_attr__('Reply Edit: %s', 'bbpress');
        // Topic tag edit page
    } elseif (bbp_is_topic_tag_edit()) {
        $new_title['text'] = bbp_get_topic_tag_name();
        $new_title['format'] = esc_attr__('Topic Tag Edit: %s', 'bbpress');
        /** Singles ***************************************************************/
        // Forum page
    } elseif (bbp_is_single_forum()) {
        $new_title['text'] = bbp_get_forum_title();
        $new_title['format'] = esc_attr__('Forum: %s', 'bbpress');
        // Topic page
    } elseif (bbp_is_single_topic()) {
        $new_title['text'] = bbp_get_topic_title();
        $new_title['format'] = esc_attr__('Topic: %s', 'bbpress');
        // Replies
    } elseif (bbp_is_single_reply()) {
        $new_title['text'] = bbp_get_reply_title();
        // Topic tag page
    } elseif (bbp_is_topic_tag() || get_query_var('bbp_topic_tag')) {
        $new_title['text'] = bbp_get_topic_tag_name();
        $new_title['format'] = esc_attr__('Topic Tag: %s', 'bbpress');
        /** Users *****************************************************************/
        // Profile page
    } elseif (bbp_is_single_user()) {
        // User is viewing their own profile
        if (bbp_is_user_home()) {
            $new_title['text'] = esc_attr_x('Your', 'User viewing his/her own profile', 'bbpress');
            // User is viewing someone else's profile (so use their display name)
        } else {
            $new_title['text'] = sprintf(esc_attr_x("%s's", 'User viewing another users profile', 'bbpress'), get_userdata(bbp_get_user_id())->display_name);
        }
        // User topics created
        if (bbp_is_single_user_topics()) {
            $new_title['format'] = esc_attr__("%s Topics", 'bbpress');
            // User rueplies created
        } elseif (bbp_is_single_user_replies()) {
            $new_title['format'] = esc_attr__("%s Replies", 'bbpress');
            // User favorites
        } elseif (bbp_is_favorites()) {
            $new_title['format'] = esc_attr__("%s Favorites", 'bbpress');
            // User subscriptions
        } elseif (bbp_is_subscriptions()) {
            $new_title['format'] = esc_attr__("%s Subscriptions", 'bbpress');
            // User "home"
        } else {
            $new_title['format'] = esc_attr__("%s Profile", 'bbpress');
        }
        // Profile edit page
    } elseif (bbp_is_single_user_edit()) {
        // Current user
        if (bbp_is_user_home_edit()) {
            $new_title['text'] = esc_attr__('Edit Your Profile', 'bbpress');
            // Other user
        } else {
            $new_title['text'] = get_userdata(bbp_get_user_id())->display_name;
            $new_title['format'] = esc_attr__("Edit %s's Profile", 'bbpress');
        }
        /** Views *****************************************************************/
        // Views
    } elseif (bbp_is_single_view()) {
        $new_title['text'] = bbp_get_view_title();
        $new_title['format'] = esc_attr__('View: %s', 'bbpress');
        /** Search ****************************************************************/
        // Search
    } elseif (bbp_is_search()) {
        $new_title['text'] = bbp_get_search_title();
    }
    // This filter is deprecated. Use 'bbp_before_title_parse_args' instead.
    $new_title = apply_filters('bbp_raw_title_array', $new_title);
    // Set title array defaults
    $new_title = bbp_parse_args($new_title, array('text' => $title, 'format' => '%s'), 'title');
    // Get the formatted raw title
    $new_title = sprintf($new_title['format'], $new_title['text']);
    // Filter the raw title
    $new_title = apply_filters('bbp_raw_title', $new_title, $sep, $seplocation);
    // Compare new title with original title
    if ($new_title === $title) {
        return $title;
    }
    // Temporary separator, for accurate flipping, if necessary
    $t_sep = '%WP_TITILE_SEP%';
    $prefix = '';
    if (!empty($new_title)) {
        $prefix = " {$sep} ";
    }
    // sep on right, so reverse the order
    if ('right' === $seplocation) {
        $new_title_array = array_reverse(explode($t_sep, $new_title));
        $new_title = implode(" {$sep} ", $new_title_array) . $prefix;
        // sep on left, do not reverse
    } else {
        $new_title_array = explode($t_sep, $new_title);
        $new_title = $prefix . implode(" {$sep} ", $new_title_array);
    }
    // Filter and return
    return apply_filters('bbp_title', $new_title, $sep, $seplocation);
}
Esempio n. 20
0
/**
 * Reset main query vars and filter 'the_content' to output a bbPress
 * template part as needed.
 *
 * @since 2.0.0 bbPress (r3032)
 *
 * @param string $template
 * @uses bbp_is_single_user() To check if page is single user
 * @uses bbp_get_single_user_template() To get user template
 * @uses bbp_is_single_user_edit() To check if page is single user edit
 * @uses bbp_get_single_user_edit_template() To get user edit template
 * @uses bbp_is_single_view() To check if page is single view
 * @uses bbp_get_single_view_template() To get view template
 * @uses bbp_is_search() To check if page is search
 * @uses bbp_get_search_template() To get search template
 * @uses bbp_is_forum_edit() To check if page is forum edit
 * @uses bbp_get_forum_edit_template() To get forum edit template
 * @uses bbp_is_topic_merge() To check if page is topic merge
 * @uses bbp_get_topic_merge_template() To get topic merge template
 * @uses bbp_is_topic_split() To check if page is topic split
 * @uses bbp_get_topic_split_template() To get topic split template
 * @uses bbp_is_topic_edit() To check if page is topic edit
 * @uses bbp_get_topic_edit_template() To get topic edit template
 * @uses bbp_is_reply_move() To check if page is reply move
 * @uses bbp_get_reply_move_template() To get reply move template
 * @uses bbp_is_reply_edit() To check if page is reply edit
 * @uses bbp_get_reply_edit_template() To get reply edit template
 * @uses bbp_set_theme_compat_template() To set the global theme compat template
 */
function bbp_template_include_theme_compat($template = '')
{
    /**
     * Bail if a root template was already found. This prevents unintended
     * recursive filtering of 'the_content'.
     *
     * @link https://bbpress.trac.wordpress.org/ticket/2429
     */
    if (bbp_is_template_included()) {
        return $template;
    }
    /**
     * If BuddyPress is activated at a network level, the action order is
     * reversed, which causes the template integration to fail. If we're looking
     * at a BuddyPress page here, bail to prevent the extra processing.
     *
     * This is a bit more brute-force than is probably necessary, but gets the
     * job done while we work towards something more elegant.
     */
    if (function_exists('is_buddypress') && is_buddypress()) {
        return $template;
    }
    // Define local variable(s)
    $bbp_shortcodes = bbpress()->shortcodes;
    // Bail if shortcodes are unset somehow
    if (!is_a($bbp_shortcodes, 'BBP_Shortcodes')) {
        return $template;
    }
    /** Users *************************************************************/
    if (bbp_is_single_user_edit() || bbp_is_single_user()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => bbp_buffer_template_part('content', 'single-user', false), 'post_type' => '', 'post_title' => bbp_get_displayed_user_field('display_name'), 'post_status' => bbp_get_public_status_id(), 'is_single' => true, 'is_archive' => false, 'comment_status' => 'closed'));
        /** Forums ************************************************************/
        // Forum archive
    } elseif (bbp_is_forum_archive()) {
        // Page exists where this archive should be
        $page = bbp_get_page_by_path(bbp_get_root_slug());
        // Should we replace the content...
        if (empty($page->post_content)) {
            // Use the topics archive
            if ('topics' === bbp_show_on_root()) {
                $new_content = $bbp_shortcodes->display_topic_index();
                // No page so show the archive
            } else {
                $new_content = $bbp_shortcodes->display_forum_index();
            }
            // ...or use the existing page content?
        } else {
            $new_content = apply_filters('the_content', $page->post_content);
        }
        // Should we replace the title...
        if (empty($page->post_title)) {
            // Use the topics archive
            if ('topics' === bbp_show_on_root()) {
                $new_title = bbp_get_topic_archive_title();
                // No page so show the archive
            } else {
                $new_title = bbp_get_forum_archive_title();
            }
            // ...or use the existing page title?
        } else {
            $new_title = apply_filters('the_title', $page->post_title);
        }
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => !empty($page->ID) ? $page->ID : 0, 'post_title' => $new_title, 'post_author' => 0, 'post_date' => 0, 'post_content' => $new_content, 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed'));
        // Single Forum
    } elseif (bbp_is_forum_edit()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_forum_id(), 'post_title' => bbp_get_forum_title(), 'post_author' => bbp_get_forum_author_id(), 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_forum_form(), 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_forum_visibility(), 'is_single' => true, 'comment_status' => 'closed'));
    } elseif (bbp_is_single_forum()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_forum_id(), 'post_title' => bbp_get_forum_title(), 'post_author' => bbp_get_forum_author_id(), 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_forum(array('id' => bbp_get_forum_id())), 'post_type' => bbp_get_forum_post_type(), 'post_status' => bbp_get_forum_visibility(), 'is_single' => true, 'comment_status' => 'closed'));
        /** Topics ************************************************************/
        // Topic archive
    } elseif (bbp_is_topic_archive()) {
        // Page exists where this archive should be
        $page = bbp_get_page_by_path(bbp_get_topic_archive_slug());
        // Should we replace the content...
        if (empty($page->post_content)) {
            $new_content = $bbp_shortcodes->display_topic_index();
            // ...or use the existing page content?
        } else {
            $new_content = apply_filters('the_content', $page->post_content);
        }
        // Should we replace the title...
        if (empty($page->post_title)) {
            $new_title = bbp_get_topic_archive_title();
            // ...or use the existing page title?
        } else {
            $new_title = apply_filters('the_title', $page->post_title);
        }
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => !empty($page->ID) ? $page->ID : 0, 'post_title' => bbp_get_topic_archive_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => $new_content, 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_public_status_id(), 'is_archive' => true, 'comment_status' => 'closed'));
        // Single Topic
    } elseif (bbp_is_topic_edit() || bbp_is_single_topic()) {
        // Split
        if (bbp_is_topic_split()) {
            $new_content = bbp_buffer_template_part('form', 'topic-split', false);
            // Merge
        } elseif (bbp_is_topic_merge()) {
            $new_content = bbp_buffer_template_part('form', 'topic-merge', false);
            // Edit
        } elseif (bbp_is_topic_edit()) {
            $new_content = $bbp_shortcodes->display_topic_form();
            // Single
        } else {
            $new_content = $bbp_shortcodes->display_topic(array('id' => bbp_get_topic_id()));
        }
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_topic_id(), 'post_title' => bbp_get_topic_title(), 'post_author' => bbp_get_topic_author_id(), 'post_date' => 0, 'post_content' => $new_content, 'post_type' => bbp_get_topic_post_type(), 'post_status' => bbp_get_topic_status(), 'is_single' => true, 'comment_status' => 'closed'));
        /** Replies ***********************************************************/
        // Reply archive
    } elseif (is_post_type_archive(bbp_get_reply_post_type())) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => __('Replies', 'bbpress'), 'post_author' => 0, 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_reply_index(), 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
        // Single Reply
    } elseif (bbp_is_reply_edit() || bbp_is_single_reply()) {
        // Move
        if (bbp_is_reply_move()) {
            $new_content = bbp_buffer_template_part('form', 'reply-move', false);
            // Edit
        } elseif (bbp_is_reply_edit()) {
            $new_content = $bbp_shortcodes->display_reply_form();
            // Single
        } else {
            $new_content = $bbp_shortcodes->display_reply(array('id' => get_the_ID()));
        }
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => bbp_get_reply_id(), 'post_title' => bbp_get_reply_title(), 'post_author' => bbp_get_reply_author_id(), 'post_date' => 0, 'post_content' => $new_content, 'post_type' => bbp_get_reply_post_type(), 'post_status' => bbp_get_reply_status(), 'comment_status' => 'closed'));
        /** Views *************************************************************/
    } elseif (bbp_is_single_view()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_view_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_view(array('id' => get_query_var(bbp_get_view_rewrite_id()))), 'post_type' => '', 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
        /** Search ************************************************************/
    } elseif (bbp_is_search()) {
        // Reset post
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_title' => bbp_get_search_title(), 'post_author' => 0, 'post_date' => 0, 'post_content' => $bbp_shortcodes->display_search(array('search' => get_query_var(bbp_get_search_rewrite_id()))), 'post_type' => '', 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed'));
        /** Topic Tags ********************************************************/
        // Topic Tag Edit
    } elseif (bbp_is_topic_tag_edit() || bbp_is_topic_tag()) {
        // Stash the current term in a new var
        set_query_var('bbp_topic_tag', get_query_var('term'));
        // Show topics of tag
        if (bbp_is_topic_tag()) {
            $new_content = $bbp_shortcodes->display_topics_of_tag(array('id' => bbp_get_topic_tag_id()));
            // Edit topic tag
        } elseif (bbp_is_topic_tag_edit()) {
            $new_content = $bbp_shortcodes->display_topic_tag_form();
        }
        // Reset the post with our new title
        bbp_theme_compat_reset_post(array('ID' => 0, 'post_author' => 0, 'post_date' => 0, 'post_content' => $new_content, 'post_type' => '', 'post_title' => sprintf(__('Topic Tag: %s', 'bbpress'), '<span>' . bbp_get_topic_tag_name() . '</span>'), 'post_status' => bbp_get_public_status_id(), 'comment_status' => 'closed', 'is_tax' => true));
    }
    /**
     * Bail if the template already matches a bbPress template. This includes
     * archive-* and single-* WordPress post_type matches (allowing
     * themes to use the expected format) as well as all bbPress-specific
     * template files for users, topics, forums, etc...
     *
     * We do this after the above checks to prevent incorrect 404 body classes
     * and header statuses, as well as to set the post global as needed.
     *
     * @see https://bbpress.trac.wordpress.org/ticket/1478/
     */
    if (bbp_is_template_included()) {
        return $template;
        /**
         * If we are relying on bbPress's built in theme compatibility to load
         * the proper content, we need to intercept the_content, replace the
         * output, and display ours instead.
         *
         * To do this, we first remove all filters from 'the_content' and hook
         * our own function into it, which runs a series of checks to determine
         * the context, and then uses the built in shortcodes to output the
         * correct results from inside an output buffer.
         *
         * Uses bbp_get_theme_compat_templates() to provide fall-backs that
         * should be coded without superfluous mark-up and logic (prev/next
         * navigation, comments, date/time, etc...)
         *
         * Hook into the 'bbp_get_bbpress_template' to override the array of
         * possible templates, or 'bbp_bbpress_template' to override the result.
         */
    } elseif (bbp_is_theme_compat_active()) {
        bbp_remove_all_filters('the_content');
        $template = bbp_get_theme_compat_templates();
    }
    return apply_filters('bbp_template_include_theme_compat', $template);
}
Esempio n. 21
0
/**
 * Replaces the_content() if the post_type being displayed is one that would
 * normally be handled by bbPress, but proper single page templates do not
 * exist in the currently active theme.
 *
 * Note that we do *not* currently use is_main_query() here. This is because so
 * many existing themes either use query_posts() or fail to use wp_reset_query()
 * when running queries before the main loop, causing theme compat to fail.
 *
 * @since bbPress (r3034)
 * @param string $content
 * @return type
 */
function bbp_replace_the_content($content = '')
{
    // Bail if not inside the query loop
    if (!in_the_loop()) {
        return $content;
    }
    $bbp = bbpress();
    // Define local variable(s)
    $new_content = '';
    // Bail if shortcodes are unset somehow
    if (!is_a($bbp->shortcodes, 'BBP_Shortcodes')) {
        return $content;
    }
    // Use shortcode API to display forums/topics/replies because they are
    // already output buffered and ready to fit inside the_content
    /** Users *************************************************************/
    // Profile View
    if (bbp_is_single_user_edit() || bbp_is_single_user()) {
        ob_start();
        bbp_get_template_part('content', 'single-user');
        $new_content = ob_get_contents();
        ob_end_clean();
        /** Forums ************************************************************/
        // Forum archive
    } elseif (bbp_is_forum_archive()) {
        // Page exists where this archive should be
        $page = bbp_get_page_by_path(bbp_get_root_slug());
        if (!empty($page)) {
            // Restore previously unset filters
            bbp_restore_all_filters('the_content');
            // Remove 'bbp_replace_the_content' filter to prevent infinite loops
            remove_filter('the_content', 'bbp_replace_the_content');
            // Start output buffer
            ob_start();
            // Grab the content of this page
            $new_content = apply_filters('the_content', $page->post_content);
            // Clean up the buffer
            ob_end_clean();
            // Add 'bbp_replace_the_content' filter back (@see $this::start())
            add_filter('the_content', 'bbp_replace_the_content');
            // No page so show the archive
        } else {
            $new_content = $bbp->shortcodes->display_forum_index();
        }
        // Forum Edit
    } elseif (bbp_is_forum_edit()) {
        $new_content = $bbp->shortcodes->display_forum_form();
        // Single Forum
    } elseif (bbp_is_single_forum()) {
        $new_content = $bbp->shortcodes->display_forum(array('id' => get_the_ID()));
        /** Topics ************************************************************/
        // Topic archive
    } elseif (bbp_is_topic_archive()) {
        // Page exists where this archive should be
        $page = bbp_get_page_by_path(bbp_get_topic_archive_slug());
        if (!empty($page)) {
            // Restore previously unset filters
            bbp_restore_all_filters('the_content');
            // Remove 'bbp_replace_the_content' filter to prevent infinite loops
            remove_filter('the_content', 'bbp_replace_the_content');
            // Start output buffer
            ob_start();
            // Grab the content of this page
            $new_content = apply_filters('the_content', $page->post_content);
            // Clean up the buffer
            ob_end_clean();
            // Add 'bbp_replace_the_content' filter back (@see $this::start())
            add_filter('the_content', 'bbp_replace_the_content');
            // No page so show the archive
        } else {
            $new_content = $bbp->shortcodes->display_topic_index();
        }
        // Topic Edit
    } elseif (bbp_is_topic_edit()) {
        // Split
        if (bbp_is_topic_split()) {
            ob_start();
            bbp_get_template_part('form', 'topic-split');
            $new_content = ob_get_contents();
            ob_end_clean();
            // Merge
        } elseif (bbp_is_topic_merge()) {
            ob_start();
            bbp_get_template_part('form', 'topic-merge');
            $new_content = ob_get_contents();
            ob_end_clean();
            // Edit
        } else {
            $new_content = $bbp->shortcodes->display_topic_form();
        }
        // Single Topic
    } elseif (bbp_is_single_topic()) {
        $new_content = $bbp->shortcodes->display_topic(array('id' => get_the_ID()));
        /** Replies ***********************************************************/
        // Reply archive
    } elseif (is_post_type_archive(bbp_get_reply_post_type())) {
        //$new_content = $bbp->shortcodes->display_reply_index();
        // Reply Edit
    } elseif (bbp_is_reply_edit()) {
        $new_content = $bbp->shortcodes->display_reply_form();
        // Single Reply
    } elseif (bbp_is_single_reply()) {
        $new_content = $bbp->shortcodes->display_reply(array('id' => get_the_ID()));
        /** Views *************************************************************/
    } elseif (bbp_is_single_view()) {
        $new_content = $bbp->shortcodes->display_view(array('id' => get_query_var('bbp_view')));
        /** Topic Tags ********************************************************/
        // Show topics of tag
    } elseif (bbp_is_topic_tag()) {
        $new_content = $bbp->shortcodes->display_topics_of_tag(array('id' => bbp_get_topic_tag_id()));
        // Edit topic tag
    } elseif (bbp_is_topic_tag_edit()) {
        $new_content = $bbp->shortcodes->display_topic_tag_form();
    }
    // Juggle the content around and try to prevent unsightly comments
    if (!empty($new_content) && $new_content != $content) {
        // Set the content to be the new content
        $content = apply_filters('bbp_replace_the_content', $new_content, $content);
        // Clean up after ourselves
        unset($new_content);
        // Reset the $post global
        wp_reset_postdata();
    }
    // Return possibly hi-jacked content
    return $content;
}
Esempio n. 22
0
 protected function get_page_header_title()
 {
     global $oxy_theme_options;
     if (bbp_is_forum_archive()) {
         return $oxy_theme_options['bbpress_header_forums'];
     } else {
         if (bbp_is_topic_archive()) {
             return $oxy_theme_options['bbpress_header_topics'];
         } else {
             if (bbp_is_single_view()) {
                 return bbp_get_view_title();
             } else {
                 if (bbp_is_single_forum()) {
                     return bbp_get_forum_title();
                 } else {
                     if (bbp_is_single_topic()) {
                         return bbp_get_topic_title();
                     } else {
                         if (bbp_is_topic_tag()) {
                             return __('Tag: ', 'omega-td') . bbp_get_topic_tag_name();
                         } else {
                             if (bbp_is_single_reply()) {
                                 return bbp_get_reply_title();
                             } else {
                                 if (bbp_is_topic_tag_edit()) {
                                     return __('Edit', 'omega-td');
                                 } else {
                                     if (bbp_is_search()) {
                                         return bbp_get_search_title();
                                     } else {
                                         if (bbp_is_single_user()) {
                                             return bbp_get_displayed_user_field('display_name');
                                         } else {
                                             return get_the_title();
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 23
0
/**
 * Possibly intercept the template being loaded
 *
 * Listens to the 'template_include' filter and waits for any bbPress specific
 * template condition to be met. If one is met and the template file exists,
 * it will be used; otherwise 
 *
 * Note that the _edit() checks are ahead of their counterparts, to prevent them
 * from being stomped on accident.
 *
 * @since bbPress (r3032)
 *
 * @param string $template
 *
 * @uses bbp_is_single_user() To check if page is single user
 * @uses bbp_get_single_user_template() To get user template
 * @uses bbp_is_single_user_edit() To check if page is single user edit
 * @uses bbp_get_single_user_edit_template() To get user edit template
 * @uses bbp_is_single_view() To check if page is single view
 * @uses bbp_get_single_view_template() To get view template
 * @uses bbp_is_search() To check if page is search
 * @uses bbp_get_search_template() To get search template
 * @uses bbp_is_forum_edit() To check if page is forum edit
 * @uses bbp_get_forum_edit_template() To get forum edit template
 * @uses bbp_is_topic_merge() To check if page is topic merge
 * @uses bbp_get_topic_merge_template() To get topic merge template
 * @uses bbp_is_topic_split() To check if page is topic split
 * @uses bbp_get_topic_split_template() To get topic split template
 * @uses bbp_is_topic_edit() To check if page is topic edit
 * @uses bbp_get_topic_edit_template() To get topic edit template
 * @uses bbp_is_reply_move() To check if page is reply move
 * @uses bbp_get_reply_move_template() To get reply move template
 * @uses bbp_is_reply_edit() To check if page is reply edit
 * @uses bbp_get_reply_edit_template() To get reply edit template
 * @uses bbp_set_theme_compat_template() To set the global theme compat template
 *
 * @return string The path to the template file that is being used
 */
function bbp_template_include_theme_supports($template = '')
{
    // Editing a user
    if (bbp_is_single_user_edit() && ($new_template = bbp_get_single_user_edit_template())) {
        // User favorites
    } elseif (bbp_is_favorites() && ($new_template = bbp_get_favorites_template())) {
        // User favorites
    } elseif (bbp_is_subscriptions() && ($new_template = bbp_get_subscriptions_template())) {
        // Viewing a user
    } elseif (bbp_is_single_user() && ($new_template = bbp_get_single_user_template())) {
        // Single View
    } elseif (bbp_is_single_view() && ($new_template = bbp_get_single_view_template())) {
        // Search
    } elseif (bbp_is_search() && ($new_template = bbp_get_search_template())) {
        // Forum edit
    } elseif (bbp_is_forum_edit() && ($new_template = bbp_get_forum_edit_template())) {
        // Single Forum
    } elseif (bbp_is_single_forum() && ($new_template = bbp_get_single_forum_template())) {
        // Forum Archive
    } elseif (bbp_is_forum_archive() && ($new_template = bbp_get_forum_archive_template())) {
        // Topic merge
    } elseif (bbp_is_topic_merge() && ($new_template = bbp_get_topic_merge_template())) {
        // Topic split
    } elseif (bbp_is_topic_split() && ($new_template = bbp_get_topic_split_template())) {
        // Topic edit
    } elseif (bbp_is_topic_edit() && ($new_template = bbp_get_topic_edit_template())) {
        // Single Topic
    } elseif (bbp_is_single_topic() && ($new_template = bbp_get_single_topic_template())) {
        // Topic Archive
    } elseif (bbp_is_topic_archive() && ($new_template = bbp_get_topic_archive_template())) {
        // Reply move
    } elseif (bbp_is_reply_move() && ($new_template = bbp_get_reply_move_template())) {
        // Editing a reply
    } elseif (bbp_is_reply_edit() && ($new_template = bbp_get_reply_edit_template())) {
        // Single Reply
    } elseif (bbp_is_single_reply() && ($new_template = bbp_get_single_reply_template())) {
        // Editing a topic tag
    } elseif (bbp_is_topic_tag_edit() && ($new_template = bbp_get_topic_tag_edit_template())) {
        // Viewing a topic tag
    } elseif (bbp_is_topic_tag() && ($new_template = bbp_get_topic_tag_template())) {
    }
    // A bbPress template file was located, so override the WordPress template
    // and use it to switch off bbPress's theme compatibility.
    if (!empty($new_template)) {
        $template = bbp_set_template_included($new_template);
    }
    return apply_filters('bbp_template_include_theme_supports', $template);
}
Esempio n. 24
0
                the_post();
                if (has_excerpt()) {
                    the_excerpt();
                }
            }
        }
    } elseif (class_exists('WooCommerce') and is_shop() || is_singular('product') || is_tax('product_cat') || is_tax('product_tag')) {
        if (hippo_option('shop-short-description')) {
            ?>
                                                <p><?php 
            echo wp_kses(hippo_option('shop-short-description'), array('a' => array('href' => array(), 'title' => array(), 'class' => array()), 'br' => array(), 'em' => array(), 'strong' => array(), 'ul' => array('class' => array()), 'li' => array('class' => array()), 'p' => array('class' => array()), 'span' => array('class' => array())));
            ?>
                                                </p>
                                           <?php 
        }
    } elseif (function_exists('is_bbpress') and is_bbpress() || bbp_is_forum_archive() || bbp_is_topic_archive() || bbp_is_topic_tag() || bbp_is_single_forum() || bbp_is_single_topic() || bbp_is_single_user() || bbp_is_search()) {
        if (hippo_option('forum-short-description')) {
            ?>
                                                <p><?php 
            echo wp_kses(hippo_option('forum-short-description'), array('a' => array('href' => array(), 'title' => array(), 'class' => array()), 'br' => array(), 'em' => array(), 'strong' => array(), 'ul' => array('class' => array()), 'li' => array('class' => array()), 'p' => array('class' => array()), 'span' => array('class' => array())));
            ?>
                                                </p>
                                           <?php 
        }
    } else {
        if (hippo_option('blog-short-description')) {
            ?>

                                                <p><?php 
            echo wp_kses(hippo_option('blog-short-description'), array('a' => array('href' => array(), 'title' => array(), 'class' => array()), 'br' => array(), 'em' => array(), 'strong' => array(), 'ul' => array('class' => array()), 'li' => array('class' => array()), 'p' => array('class' => array()), 'span' => array('class' => array())));
            ?>
Esempio n. 25
0
 /**
  * Runs through the various bbPress conditional tags to check the current page being viewed.  Once
  * a condition is met, add items to the $items array.
  *
  * @since  0.6.0
  * @access public
  * @return void
  */
 public function do_trail_items()
 {
     /* Add the network and site home links. */
     $this->do_network_home_link();
     $this->do_site_home_link();
     /* Get the forum post type object. */
     $post_type_object = get_post_type_object(bbp_get_forum_post_type());
     /* If not viewing the forum root/archive page and a forum archive exists, add it. */
     if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
         $this->items[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
     }
     /* If viewing the forum root/archive. */
     if (bbp_is_forum_archive()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_forum_archive_title();
         }
     } elseif (bbp_is_topic_archive()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_topic_archive_title();
         }
     } elseif (bbp_is_topic_tag()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_topic_tag_name();
         }
     } elseif (bbp_is_topic_tag_edit()) {
         $this->items[] = '<a href="' . bbp_get_topic_tag_link() . '">' . bbp_get_topic_tag_name() . '</a>';
         if (true === $this->args['show_title']) {
             $this->items[] = __('Edit', 'breadcrumb-trail');
         }
     } elseif (bbp_is_single_view()) {
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_view_title();
         }
     } elseif (bbp_is_single_topic()) {
         /* Get the queried topic. */
         $topic_id = get_queried_object_id();
         /* Get the parent items for the topic, which would be its forum (and possibly forum grandparents). */
         $this->do_post_parents(bbp_get_topic_forum_id($topic_id));
         /* If viewing a split, merge, or edit topic page, show the link back to the topic.  Else, display topic title. */
         if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
             $this->items[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
         } elseif (true === $this->args['show_title']) {
             $this->items[] = bbp_get_topic_title($topic_id);
         }
         /* If viewing a topic split page. */
         if (bbp_is_topic_split() && true === $this->args['show_title']) {
             $this->items[] = __('Split', 'breadcrumb-trail');
         } elseif (bbp_is_topic_merge() && true === $this->args['show_title']) {
             $this->items[] = __('Merge', 'breadcrumb-trail');
         } elseif (bbp_is_topic_edit() && true === $this->args['show_title']) {
             $this->items[] = __('Edit', 'breadcrumb-trail');
         }
     } elseif (bbp_is_single_reply()) {
         /* Get the queried reply object ID. */
         $reply_id = get_queried_object_id();
         /* Get the parent items for the reply, which should be its topic. */
         $this->do_post_parents(bbp_get_reply_topic_id($reply_id));
         /* If viewing a reply edit page, link back to the reply. Else, display the reply title. */
         if (bbp_is_reply_edit()) {
             $this->items[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
             if (true === $this->args['show_title']) {
                 $this->items[] = __('Edit', 'breadcrumb-trail');
             }
         } elseif (true === $this->args['show_title']) {
             $this->items[] = bbp_get_reply_title($reply_id);
         }
     } elseif (bbp_is_single_forum()) {
         /* Get the queried forum ID and its parent forum ID. */
         $forum_id = get_queried_object_id();
         $forum_parent_id = bbp_get_forum_parent_id($forum_id);
         /* If the forum has a parent forum, get its parent(s). */
         if (0 !== $forum_parent_id) {
             $this->do_post_parents($forum_parent_id);
         }
         /* Add the forum title to the end of the trail. */
         if (true === $this->args['show_title']) {
             $this->items[] = bbp_get_forum_title($forum_id);
         }
     } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
         if (bbp_is_single_user_edit()) {
             $this->items[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
             if (true === $this->args['show_title']) {
                 $this->items[] = __('Edit', 'breadcrumb-trail');
             }
         } elseif (true === $this->args['show_title']) {
             $this->items[] = bbp_get_displayed_user_field('display_name');
         }
     }
     /* Return the bbPress breadcrumb trail items. */
     $this->items = apply_filters('breadcrumb_trail_get_bbpress_items', $this->items, $this->args);
 }
Esempio n. 26
0
 public static function template_no_access($template)
 {
     global $wp_query, $post;
     $check_perm = false;
     if (bbp_is_single_user_edit() || bbp_is_single_user()) {
     } elseif (bbp_is_forum_archive()) {
     } elseif (bbp_is_forum_edit()) {
         $forum_id = bbp_get_forum_id();
         if (bbp_is_forum($forum_id) && !bbp_user_can_view_forum(array('forum_id' => $forum_id)) && !bbp_is_forum_private($forum_id, false)) {
             $check_perm = true;
         }
     } elseif (bbp_is_single_forum()) {
         $forum_id = bbp_get_forum_id();
         if (bbp_is_forum($forum_id) && !bbp_user_can_view_forum(array('forum_id' => $forum_id)) && !bbp_is_forum_private($forum_id, false)) {
             $check_perm = true;
         }
     } elseif (bbp_is_topic_archive()) {
     } elseif (bbp_is_topic_edit() || bbp_is_single_topic()) {
         $check_perm = true;
     } elseif (is_post_type_archive(bbp_get_reply_post_type())) {
     } elseif (bbp_is_reply_edit() || bbp_is_single_reply()) {
         $check_perm = true;
     } elseif (bbp_is_single_view()) {
     } elseif (bbp_is_search()) {
     } elseif (bbp_is_topic_tag_edit() || bbp_is_topic_tag()) {
     }
     if ($check_perm && empty($post->post_content)) {
         $user_id = get_current_user_id();
         $forum_id = bbp_get_forum_id();
         if (!self::view_forum(false, $forum_id, $user_id)) {
             ob_start();
             bbp_get_template_part('feedback', 'no-access');
             $content = ob_get_clean();
             $post->post_content = "\n{$content}\n";
             $wp_query->post = $post;
             $wp_query->posts = array($post);
         }
     }
     return $template;
 }