Esempio n. 1
0
/**
 *
 * @since  1.0.0
 * @access public
 * @return bool
 */
function mb_search_query()
{
    $mb = message_board();
    /* If a query has already been created, let's roll. */
    if (!is_null($mb->search_query->query)) {
        $have_posts = $mb->search_query->have_posts();
        if (empty($have_posts)) {
            wp_reset_postdata();
        }
        return $have_posts;
    }
    /* Use the main WP query when viewing a single topic or topic archive. */
    if (mb_is_search_results()) {
        global $wp_the_query;
        $mb->search_query = $wp_the_query;
    }
    return $mb->search_query->have_posts();
}
Esempio n. 2
0
/**
 * Builds the template hierarchy for the plugin.  This function figures out what the current page 
 * is and returns an array of possible templates to use.  Note that this function only returns 
 * the templates name and not a full paths.  It is meant to be used within other functions that actually 
 * locate/load the templates.
 *
 * @since  1.0.0
 * @access public
 * @return array
 */
function mb_get_template_hierarchy()
{
    $hierarchy = array();
    /* If viewing a single forum page. */
    if (mb_is_single_forum()) {
        $hierarchy[] = 'single-forum.php';
        /* If viewing the forum archive (default forum front). */
    } elseif (mb_is_forum_archive()) {
        $hierarchy[] = 'archive-forum.php';
        /* If viewing a single topic. */
    } elseif (mb_is_single_topic()) {
        $hierarchy[] = "single-topic.php";
        /* If viewing the topic archive (possible forum front page). */
    } elseif (mb_is_topic_archive()) {
        $hierarchy[] = 'archive-topic.php';
        /* If viewing a single reply. */
    } elseif (mb_is_single_reply()) {
        $hierarchy[] = "single-reply.php";
        /* If viewing the reply archive. */
    } elseif (mb_is_reply_archive()) {
        $hierarchy[] = 'archive-reply.php';
    } elseif (mb_is_role_archive()) {
        $hierarchy[] = 'archive-role.php';
    } elseif (mb_is_single_role()) {
        $hierarchy[] = 'single-role.php';
        /* If viewing a user sub-page. */
    } elseif (mb_is_user_page()) {
        $page = sanitize_key(get_query_var('mb_user_page'));
        $hierarchy[] = "single-user-{$page}.php";
        $hierarchy[] = 'single-user.php';
        /* If viewing a user profile page. */
    } elseif (mb_is_single_user()) {
        $hierarchy[] = 'single-user.php';
        /* If viewing the user archive. */
    } elseif (mb_is_user_archive()) {
        $hierarchy[] = 'archive-user.php';
        /* If viewing a search results page. */
    } elseif (mb_is_search_results()) {
        $hierarchy[] = 'search-results.php';
        /* If viewing the advanced search page. */
    } elseif (mb_is_search()) {
        $hierarchy[] = 'search.php';
        /* If viewing the forum login page. */
    } elseif (mb_is_forum_login()) {
        $hierarchy[] = 'login.php';
        /* If viewing an edit page. */
    } elseif (mb_is_edit()) {
        if (mb_is_forum_edit()) {
            $hierarchy[] = 'edit-forum.php';
        } elseif (mb_is_topic_edit()) {
            $hierarchy[] = 'edit-topic.php';
        } elseif (mb_is_reply_edit()) {
            $hierarchy[] = 'edit-reply.php';
        } elseif (mb_is_user_edit()) {
            $hierarchy[] = 'edit-user.php';
        }
        $hierarchy[] = 'edit.php';
    }
    /* Add the fallback template. */
    $hierarchy[] = 'board.php';
    return apply_filters('mb_get_template_hierarchy', $hierarchy);
}
Esempio n. 3
0
/**
 * Overrides the 404 for the forum front page early on the `template_redirect` hook.
 *
 * @since  1.0.0
 * @access public
 * @return void
 */
function mb_404_override()
{
    global $wp_query;
    if (mb_is_user_archive() || mb_is_edit() || get_query_var('mb_custom') || mb_is_search_results()) {
        status_header(200);
        $wp_query->is_404 = false;
        $wp_query->is_front_page = false;
        $wp_query->is_home = false;
        $wp_query->is_archive = false;
        $wp_query->is_post_type_archive = false;
    }
}