Example #1
0
/**
 * Possibly intercept the template being loaded
 *
 * Listens to the 'template_include' filter and waits for a BP Docs post_type
 * to appear. When one is found, we look to see whether the current theme provides
 * its own version of the template; otherwise we fall back on the template shipped
 * with BuddyPress Docs.
 *
 * @since 1.2
 *
 * @param string $template
 *
 * @return string The path to the template file that is being used
 */
function bp_docs_template_include($template = '')
{
    if (bp_docs_is_single_doc() && ($new_template = bp_docs_locate_template('single-bp_doc.php'))) {
    } elseif (bp_docs_is_doc_create() && ($new_template = bp_docs_locate_template('single-bp_doc.php'))) {
    } elseif (is_post_type_archive(bp_docs_get_post_type_name()) && ($new_template = bp_docs_locate_template('archive-bp_doc.php'))) {
    }
    // Custom template file exists
    $template = !empty($new_template) ? $new_template : $template;
    return apply_filters('bp_docs_template_include', $template);
}
Example #2
0
/**
 * Possibly intercept the template being loaded
 *
 * This function does two different things, depending on whether you're using BP
 * 1.7's theme compatibility feature.
 *  - If so, the function runs the 'bp_setup_theme_compat' hook, which tells BP
 *    to run the theme compat layer
 *  - If not, the function checks to see which page you intend to be looking at
 *    and loads the correct top-level bp-docs template
 *
 * The theme compatibility feature kicks in automatically for users running BP
 * 1.7+. If you are running 1.7+, but you do not want theme compat running for
 * a given Docs template type (archive, single, create), you can filter
 * 'bp_docs_do_theme_compat' and return false. This should only be done in the
 * case of legacy templates; if you're customizing new top-level templates for
 * Docs, you may put a file called plugin-buddypress-docs.php into the root of
 * your theme.
 *
 * @since 1.2
 *
 * @param string $template
 *
 * @return string The path to the template file that is being used
 */
function bp_docs_template_include($template = '')
{
    if (!bp_docs_is_docs_component()) {
        return $template;
    }
    $do_theme_compat = class_exists('BP_Theme_Compat') && apply_filters('bp_docs_do_theme_compat', true, $template);
    if ($do_theme_compat) {
        do_action('bp_setup_theme_compat');
    } else {
        if (bp_docs_is_single_doc() && ($new_template = bp_docs_locate_template('single-bp_doc.php'))) {
        } elseif (bp_docs_is_doc_create() && ($new_template = bp_docs_locate_template('single-bp_doc.php'))) {
        } elseif (is_post_type_archive(bp_docs_get_post_type_name()) && ($new_template = bp_docs_locate_template('archive-bp_doc.php'))) {
        }
        $template = !empty($new_template) ? $new_template : $template;
    }
    return apply_filters('bp_docs_template_include', $template);
}
 /**
  * Fires the WP query and loads the appropriate template
  *
  * @package BuddyPress Docs
  * @since 1.0-beta
  */
 function load_template()
 {
     global $bp, $post;
     // Docs are stored on the root blog
     if (!bp_is_root_blog()) {
         switch_to_blog(BP_ROOT_BLOG);
     }
     switch ($this->current_view) {
         case 'create':
             // Todo: Make sure the user has permission to create
             /** 
              * Load the template tags for the edit screen
              */
             require BP_DOCS_INCLUDES_PATH . 'templatetags-edit.php';
             $template = 'edit-doc.php';
             break;
         case 'list':
             $args = $this->build_query();
             /* Todo: Get this into its own 'tree' view */
             /*
             $the_docs = get_posts( $args );
             $f = walk_page_tree($the_docs, 0, 0, array( 'walker' => new Walker_Page ) );
             print_r( $f );
             */
             query_posts($args);
             $template = 'docs-loop.php';
             break;
         case 'category':
             // Check to make sure the category exists
             // If not, redirect back to list view with error
             // Otherwise, get args based on category ID
             // Then load the loop template
             break;
         case 'single':
         case 'edit':
         case 'delete':
         case 'history':
             $args = $this->build_query();
             // Add a 'name' argument so that we only get the specific post
             $args['name'] = $this->doc_slug;
             query_posts($args);
             // If this is the edit screen, we won't really be able to use a
             // regular have_posts() loop in the template, so we'll stash the
             // post in the $bp global for the edit-specific template tags
             if ($this->current_view == 'edit') {
                 if (have_posts()) {
                     while (have_posts()) {
                         the_post();
                         $bp->bp_docs->current_post = $post;
                         // Set an edit lock
                         wp_set_post_lock($post->ID);
                     }
                 }
                 /** 
                  * Load the template tags for the edit screen
                  */
                 require BP_DOCS_INCLUDES_PATH . 'templatetags-edit.php';
             }
             switch ($this->current_view) {
                 case 'single':
                     $template = 'single-doc.php';
                     break;
                 case 'edit':
                     $template = 'edit-doc.php';
                     break;
                 case 'history':
                     $template = 'history-doc.php';
                     break;
             }
             // Todo: Maybe some sort of error if there is no edit permission?
             break;
     }
     // Only register on the root blog
     if (!bp_is_root_blog()) {
         restore_current_blog();
     }
     $template_path = bp_docs_locate_template($template);
     if (!empty($template)) {
         include apply_filters('bp_docs_template', $template_path, $this);
     }
 }
 /**
  * Loads the display template
  *
  * @since 1.0-beta
  *
  * @param int $group_id ID of the current group. Available only in BP 2.2+.
  */
 function display($group_id = null)
 {
     global $bp;
     // Docs are stored on the root blog
     if (!bp_is_root_blog()) {
         switch_to_blog(BP_ROOT_BLOG);
     }
     switch ($bp->bp_docs->current_view) {
         case 'create':
             // Todo: Make sure the user has permission to create
             /**
              * Load the template tags for the edit screen
              */
             if (!function_exists('wp_tiny_mce')) {
                 bp_docs_define_tiny_mce();
             }
             require_once BP_DOCS_INCLUDES_PATH . 'templatetags-edit.php';
             $template = 'edit-doc.php';
             break;
         case 'list':
             $template = 'docs-loop.php';
             break;
         case 'category':
             // Check to make sure the category exists
             // If not, redirect back to list view with error
             // Otherwise, get args based on category ID
             // Then load the loop template
             break;
         case 'single':
         case 'edit':
         case 'delete':
         case 'history':
             // If this is the edit screen, we won't really be able to use a
             // regular have_posts() loop in the template, so we'll stash the
             // post in the $bp global for the edit-specific template tags
             if ($bp->bp_docs->current_view == 'edit') {
                 if (bp_docs_has_docs()) {
                     while (bp_docs_has_docs()) {
                         bp_docs_the_doc();
                         $bp->bp_docs->current_post = $post;
                         // Set an edit lock
                         wp_set_post_lock($post->ID);
                     }
                 }
                 /**
                  * Load the template tags for the edit screen
                  */
                 require_once BP_DOCS_INCLUDES_PATH . 'templatetags-edit.php';
             }
             switch ($bp->bp_docs->current_view) {
                 case 'single':
                     $template = 'single/index.php';
                     break;
                 case 'edit':
                     $template = 'single/edit.php';
                     break;
                 case 'history':
                     $template = 'single/history.php';
                     break;
             }
             // Todo: Maybe some sort of error if there is no edit permission?
             break;
     }
     // Only register on the root blog
     if (!bp_is_root_blog()) {
         restore_current_blog();
     }
     $template_path = bp_docs_locate_template($template);
     if (!empty($template)) {
         include apply_filters('bp_docs_template', $template_path, $this);
     }
 }
Example #5
0
<?php

include apply_filters('bp_docs_header_template', bp_docs_locate_template('docs-header.php'));
?>

<div class="docs-info-header">
	<div class="doc-search">
		<form action="" method="get">
			<input name="s" value="<?php 
the_search_query();
?>
">
			<input name="search_submit" type="submit" value="<?php 
_e('Search', 'bp-docs');
?>
" />
		</form>
	</div>

	<?php 
bp_docs_info_header();
?>
</div>

<?php 
bp_docs_inline_toggle_js();
?>

<?php 
if (bp_docs_has_docs()) {
    ?>
Example #6
0
 /**
  * Utility function for selecting the correct Docs template to be loaded in the component
  *
  * At the moment, this only loads a single template. Logic could be
  * put here in the future in case more than one template needs to be
  * displayable on the component page
  *
  * @since 1.2
  */
 function select_template()
 {
     $template = 'docs-loop.php';
     include bp_docs_locate_template(apply_filters('bp_docs_select_template', $template));
 }
Example #7
0
		<?php 
do_action('template_notices');
?>

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

		<h3><?php 
_e('Docs Directory', 'bp-docs');
?>
</h3>

		<?php 
include bp_docs_locate_template('docs-loop.php');
?>

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

		</div><!-- .padder -->
	</div><!-- #content -->

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

<?php 
bp_docs_get_sidebar('buddypress');
/**
 * Handle AJAX requests for the contents of folders.
 *
 * @since 1.9
 */
function bp_docs_get_folder_content_cb()
{
    bp_docs_locate_template('docs-folder-loop.php', true, true);
    exit;
}
	</div>

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

	<?php 
if (bp_docs_enable_attachments() && bp_docs_doc_has_attachments()) {
    ?>
		<div class="doc-attachments">
			<h3><?php 
    _e('Attachments', 'bp-docs');
    ?>
</h3>
			<?php 
    include bp_docs_locate_template('single/attachments.php');
    ?>
		</div>
	<?php 
}
?>

	<div class="doc-meta">
		<?php 
do_action('bp_docs_single_doc_meta');
?>
	</div>

	<?php 
if (apply_filters('bp_docs_allow_comment_section', true)) {
    ?>
Example #10
0
<!-- docs/archive-bp_doc.php -->

<?php 
bp_docs_locate_template('index.php', true);
Example #11
0
    <!-- Start Page Header -->

    <!-- Start Page Content -->
	<section id="page-full" class="section">
		<div class="container">
			<div class="row">
			<?php 
    if ('bp_doc' == get_post_type() || is_post_type_archive('bp_doc')) {
        ?>
				<div class="col-md-9 page-content">
					<?php 
        the_content();
        ?>
				</div>
				<?php 
        include bp_docs_locate_template('single/sidebar.php');
        ?>
			<?php 
    } else {
        ?>
				<div class="col-md-12">
					<?php 
        the_content();
        ?>
				</div>
			<?php 
    }
    ?>
			</div>
		</div>
	</section>
Example #12
0
if (bp_docs_is_doc_edit() || bp_docs_is_doc_create()) {
    ?>
			<?php 
    include bp_docs_locate_template('single/edit.php');
    ?>
		<?php 
} elseif (bp_docs_is_doc_history()) {
    ?>
			<?php 
    include bp_docs_locate_template('single/history.php');
    ?>
		<?php 
} else {
    ?>
			<?php 
    include bp_docs_locate_template('single/index.php');
    ?>
		<?php 
}
?>

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

		</div><!-- .padder -->
	</div><!-- #content -->

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