Пример #1
0
/**
 * Adds spaces after the commas in the tag edit textarea. Annoying that WP doesn't do this.
 *
 * @package BuddyPress Docs
 * @since 1.0-beta
 *
 * @param string $tags The string of tags
 * @return string $tags The string of tags with purdy commas
 */
function bp_docs_tags_comma_space($tags)
{
    if (bp_docs_is_bp_docs_page()) {
        $tags = explode(',', $tags);
        $tags = implode(', ', $tags);
    }
    return $tags;
}
 /**
  * figure out the current used buddypress group_id
  *
  * @since   0.1
  * @access public
  * @returns int  $group_id
  */
 public function bd_docs_get_current_group_id()
 {
     $group_id = false;
     if (bp_docs_is_bp_docs_page() && NULL !== bp_docs_get_current_doc()) {
         $group_id = bp_docs_get_associated_group_id(get_the_ID());
     } else {
         $path = $_SERVER['REQUEST_URI'];
         $p_arr = explode('/', $path);
         if (isset($p_arr[1]) && $p_arr[1] == bp_get_groups_root_slug()) {
             $slug = $p_arr[2];
             $group_id = BP_Groups_Group::get_id_from_slug($slug);
         } else {
             $u = parse_url(wp_get_referer());
             $path = $u['path'];
             $p_arr = explode('/', $path);
             if (isset($p_arr[1]) && $p_arr[1] == bp_get_groups_root_slug()) {
                 $slug = $p_arr[2];
                 $group_id = BP_Groups_Group::get_id_from_slug($slug);
             }
         }
     }
     return $group_id;
 }
/**
 * Adds BuddyPress Docs-specific TinyMCE plugins
 *
 * Includes:
 *   - table
 *   - tabindent
 *
 * @package BuddyPress Docs
 * @since 1.1.5
 *
 * @param array $plugins TinyMCE external plugins registered in WP
 * @return array $plugins Plugin list, with BP Docs plugins added
 */
function bp_docs_add_external_tinymce_plugins($plugins)
{
    if (bp_docs_is_bp_docs_page()) {
        $plugins['table'] = WP_PLUGIN_URL . '/' . BP_DOCS_PLUGIN_SLUG . '/lib/js/tinymce/plugins/table/editor_plugin.js';
        $plugins['tabindent'] = WP_PLUGIN_URL . '/' . BP_DOCS_PLUGIN_SLUG . '/lib/js/tinymce/plugins/tabindent/editor_plugin.js';
        $plugins['print'] = WP_PLUGIN_URL . '/' . BP_DOCS_PLUGIN_SLUG . '/lib/js/tinymce/plugins/print/editor_plugin.js';
    }
    return $plugins;
}
Пример #4
0
 /**
  * Filter the location of the comments.php template
  *
  * This function uses a little trick to make sure that the comments.php file can be
  * overridden by child themes, yet still has a fallback in the plugin folder.
  *
  * If you find this annoying, I have provided a filter for your convenience.
  *
  * @package BuddyPress Docs
  * @since 1.0-beta
  *
  * @param str $path The path (STYLESHEETPATH . $file) from comments_template()
  * @return str The path of the preferred template
  */
 function comments_template($path)
 {
     if (!bp_docs_is_bp_docs_page()) {
         return $path;
     }
     $original_path = $path;
     if (!file_exists($path)) {
         $file = str_replace(STYLESHEETPATH, '', $path);
         if (file_exists(TEMPLATEPATH . $file)) {
             $path = TEMPLATEPATH . $file;
         } else {
             $path = BP_DOCS_INSTALL_PATH . 'includes/templates' . $file;
         }
     }
     return apply_filters('bp_docs_comment_template_path', $path, $original_path);
 }
/**
 * Disables incompatible plugins in the bp_docs editor
 *
 * WP 3.1 introduced a fancy wplink plugin for TinyMCE, which allows for internal linking. It's not
 * playing nice with BuddyPress Docs, so I'm removing it for the moment and falling back on
 * TinyMCE's default link button.
 *
 * For BuddyPress Docs 1.0.9, I'm doing the same thing with the new distraction-free writing in WP
 * 3.2.
 *
 * @package BuddyPress Docs
 * @since 1.0.4
 *
 * @param array $initArray The default TinyMCE init array as set by WordPress
 * @return array $initArray The init array with the wplink plugin removed
 */
function bp_docs_remove_tinymce_plugins($initArray)
{
    if (bp_docs_is_bp_docs_page()) {
        $plugins = explode(',', $initArray['plugins']);
        // Internal linking
        $wplink_key = array_search('wplink', $plugins);
        if ($wplink_key) {
            unset($plugins[$wplink_key]);
        }
        $plugins = array_values($plugins);
        $initArray['plugins'] = implode(',', $plugins);
    }
    return $initArray;
}