Beispiel #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);
}
 /**
  * PHP 5 constructor
  *
  * @package BuddyPress Docs
  * @since 1.0-beta
  */
 function __construct($args = array())
 {
     global $bp;
     $this->post_type_name = $bp->bp_docs->post_type_name;
     $this->associated_item_tax_name = $bp->bp_docs->associated_item_tax_name;
     // Get the item slug, if there is one available
     if (bp_docs_is_single_doc()) {
         $this->doc_slug = $this->get_doc_slug();
     } else {
         $this->doc_slug = '';
     }
     $defaults = array('doc_id' => array(), 'doc_slug' => $this->doc_slug, 'group_id' => array(), 'parent_id' => 0, 'author_id' => array(), 'edited_by_id' => array(), 'tags' => array(), 'order' => 'ASC', 'orderby' => 'modified', 'paged' => 1, 'posts_per_page' => 10, 'search_terms' => '');
     $r = wp_parse_args($args, $defaults);
     $this->query_args = $r;
 }
Beispiel #3
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);
}
/**
 * Is this the History tab?
 *
 * @since 1.2
 * @return bool
 */
function bp_docs_is_doc_history()
{
    $is_doc_history = false;
    if (bp_docs_is_single_doc() && 1 == get_query_var(BP_DOCS_HISTORY_SLUG)) {
        $is_doc_history = true;
    }
    return apply_filters('bp_docs_is_doc_history', $is_doc_history);
}
Beispiel #5
0
 /**
  * Loads JavaScript
  *
  * @package BuddyPress Docs
  * @since 1.0-beta
  */
 function enqueue_scripts()
 {
     wp_register_script('bp-docs-js', plugins_url(BP_DOCS_PLUGIN_SLUG . '/includes/js/bp-docs.js'), array('jquery'));
     // This is for edit/create scripts
     if (bp_docs_is_doc_edit() || bp_docs_is_doc_create() || !empty($this->query->current_view) && ('edit' == $this->query->current_view || 'create' == $this->query->current_view)) {
         require_once ABSPATH . '/wp-admin/includes/post.php';
         wp_enqueue_script('common');
         wp_enqueue_script('jquery-color');
         wp_enqueue_script('editor');
         wp_enqueue_script('utils');
         wp_register_script('bp-docs-idle-js', plugins_url(BP_DOCS_PLUGIN_SLUG . '/includes/js/idle.js'), array('jquery', 'bp-docs-js'));
         wp_enqueue_script('bp-docs-idle-js');
         wp_register_script('jquery-colorbox', plugins_url(BP_DOCS_PLUGIN_SLUG . '/lib/js/colorbox/jquery.colorbox-min.js'), array('jquery'));
         wp_enqueue_script('jquery-colorbox');
         // Edit mode requires bp-docs-js to be dependent on TinyMCE, so we must
         // reregister bp-docs-js with the correct dependencies
         wp_deregister_script('bp-docs-js');
         wp_register_script('bp-docs-js', plugins_url(BP_DOCS_PLUGIN_SLUG . '/includes/js/bp-docs.js'), array('jquery', 'editor', 'heartbeat'));
         wp_register_script('word-counter', site_url() . '/wp-admin/js/word-count.js', array('jquery'));
         wp_enqueue_script('bp-docs-edit-validation', plugins_url(BP_DOCS_PLUGIN_SLUG . '/includes/js/edit-validation.js'), array('jquery', 'bp-docs-js'));
     }
     // Only load our JS on the right sorts of pages. Generous to account for
     // different item types
     if (in_array(bp_docs_get_docs_slug(), $this->slugstocheck) || bp_docs_is_single_doc() || bp_docs_is_global_directory() || bp_docs_is_mygroups_directory() || bp_docs_is_doc_create()) {
         wp_enqueue_script('bp-docs-js');
         wp_enqueue_script('comment-reply');
         $strings = array('upload_title' => __('Upload File', 'bp-docs'), 'upload_button' => __('OK', 'bp-docs'), 'still_working' => __('Still working?', 'bp-docs'), 'and_x_more' => __('and %d more', 'bp-docs'), 'failed_submission' => !empty(buddypress()->bp_docs->submitted_data) ? 1 : 0);
         if (bp_docs_is_doc_edit()) {
             $strings['pulse'] = bp_docs_heartbeat_pulse();
         }
         wp_localize_script('bp-docs-js', 'bp_docs', $strings);
     }
 }
Beispiel #6
0
 /**
  * Loads JavaScript
  *
  * @package BuddyPress Docs
  * @since 1.0-beta
  */
 function enqueue_scripts()
 {
     wp_register_script('bp-docs-js', plugins_url('buddypress-docs/includes/js/bp-docs.js'), array('jquery'));
     // This is for edit/create scripts
     if (bp_docs_is_doc_edit() || bp_docs_is_doc_create() || !empty($this->query->current_view) && ('edit' == $this->query->current_view || 'create' == $this->query->current_view)) {
         require_once ABSPATH . '/wp-admin/includes/post.php';
         wp_enqueue_script('common');
         wp_enqueue_script('jquery-color');
         wp_enqueue_script('editor');
         wp_enqueue_script('utils');
         wp_register_script('bp-docs-idle-js', plugins_url('buddypress-docs/includes/js/idle.js'), array('jquery', 'bp-docs-js'));
         wp_enqueue_script('bp-docs-idle-js');
         wp_register_script('jquery-colorbox', plugins_url('buddypress-docs/lib/js/colorbox/jquery.colorbox-min.js'), array('jquery'));
         wp_enqueue_script('jquery-colorbox');
         // Edit mode requires bp-docs-js to be dependent on TinyMCE, so we must
         // reregister bp-docs-js with the correct dependencies
         wp_deregister_script('bp-docs-js');
         wp_register_script('bp-docs-js', plugins_url('buddypress-docs/includes/js/bp-docs.js'), array('jquery', 'editor'));
         wp_register_script('word-counter', site_url() . '/wp-admin/js/word-count.js', array('jquery'));
         wp_enqueue_script('bp-docs-edit-validation', plugins_url('buddypress-docs/includes/js/edit-validation.js'), array('jquery'));
     }
     // Only load our JS on the right sorts of pages. Generous to account for
     // different item types
     if (in_array(BP_DOCS_SLUG, $this->slugstocheck) || bp_docs_is_single_doc() || bp_docs_is_global_directory()) {
         wp_enqueue_script('bp-docs-js');
         wp_enqueue_script('comment-reply');
         wp_localize_script('bp-docs-js', 'bp_docs', array('still_working' => __('Still working?', 'bp-docs')));
     }
 }