/** * Are we looking at something that needs docs theme compatability? * * @since 1.3 */ public function is_docs() { // Bail if not looking at the docs component if (!bp_docs_is_docs_component()) { return; } add_filter('bp_get_template_stack', array($this, 'add_plugin_templates_to_stack')); add_filter('bp_get_buddypress_template', array($this, 'query_templates')); if (bp_docs_is_global_directory()) { bp_update_is_directory(true, 'docs'); do_action('bp_docs_screen_index'); add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post')); add_filter('bp_replace_the_content', array($this, 'directory_content')); } else { if (bp_docs_is_existing_doc()) { if (bp_docs_is_doc_history()) { $this->single_content_template = 'docs/single/history'; add_filter('bp_force_comment_status', '__return_false'); } else { if (bp_docs_is_doc_edit()) { $this->single_content_template = 'docs/single/edit'; add_filter('bp_force_comment_status', '__return_false'); } else { $this->single_content_template = 'docs/single/index'; add_filter('bp_docs_allow_comment_section', '__return_false'); } } add_action('bp_template_include_reset_dummy_post_data', array($this, 'single_dummy_post')); add_filter('bp_replace_the_content', array($this, 'single_content')); } else { if (bp_docs_is_doc_create()) { add_action('bp_template_include_reset_dummy_post_data', array($this, 'create_dummy_post')); add_filter('bp_replace_the_content', array($this, 'create_content')); } } } }
/** * Is this the Docs tab of a user profile? * * @since 1.2 * @return bool */ function bp_docs_is_user_docs() { $is_user_docs = false; if (bp_is_user() && bp_docs_is_docs_component()) { $is_user_docs = true; } return apply_filters('bp_docs_is_user_docs', $is_user_docs); }
/** * Loads styles * * @package BuddyPress Docs * @since 1.0-beta */ function enqueue_styles() { global $bp; // Load the main CSS only on the proper pages if (in_array(bp_docs_get_docs_slug(), $this->slugstocheck) || bp_docs_is_docs_component()) { wp_enqueue_style('bp-docs-css', $this->includes_url . 'css/screen.css'); } if (bp_docs_is_doc_edit() || bp_docs_is_doc_create()) { wp_enqueue_style('bp-docs-edit-css', $this->includes_url . 'css/edit.css'); wp_enqueue_style('thickbox'); } }
/** * Get the absolute path of a given template. * * Looks first for a template in [theme-dir]/docs/, and falls back on the provided templates. * * Ideally, I would not need this function. But WP's locate_template() plays funny with directory * paths, and bp_core_load_template() does not have an option that will let you locate but not load * the found template. * * @package BuddyPress Docs * @since 1.0.5 * * @param str $template This string should be of the format 'edit-docs.php'. Ie, you need '.php', * but you don't need the leading '/docs/' * @return str $template_path The absolute path of the located template file. */ function bp_docs_locate_template($template = '', $load = false, $require_once = true) { if (empty($template)) { return false; } // Try to load custom templates first $stylesheet_path = STYLESHEETPATH . '/docs/'; $template_path = TEMPLATEPATH . '/docs/'; if (file_exists($stylesheet_path . $template)) { $template_path = $stylesheet_path . $template; } elseif (file_exists($template_path . $template)) { $template_path = $template_path . $template; } else { $template_path = BP_DOCS_INCLUDES_PATH . 'templates/docs/' . $template; } $template_path = apply_filters('bp_docs_locate_template', $template_path, $template); if ($template_path) { if ($load) { load_template($template_path, $require_once); } else { return $template_path; } } else { if (function_exists('is_buddypress')) { if (bp_docs_is_docs_component()) { status_header(200); $wp_query->is_page = true; $wp_query->is_singular = true; $wp_query->is_404 = false; } do_action('bp_setup_theme_compat'); } } }
/** * Process folder creation from manage-folders. */ function bp_docs_process_folder_create_cb() { if (!bp_docs_is_docs_component() && !bp_is_current_action(bp_docs_get_docs_slug())) { return; } if (!bp_docs_is_folder_manage_view()) { return; } if (empty($_POST['bp-docs-create-folder-submit'])) { return; } $nonce = isset($_POST['bp-docs-create-folder-nonce']) ? stripslashes($_POST['bp-docs-create-folder-nonce']) : ''; $redirect_url = bp_get_requested_url(); if (!wp_verify_nonce($nonce, 'bp-docs-create-folder')) { bp_core_add_message(__('There was a problem editing that folder. Please try again.', 'bp-docs'), 'error'); bp_core_redirect($redirect_url); die; } $folder_args = array('name' => stripslashes($_POST['new-folder'])); $parent = isset($_POST['new-folder-parent']) ? intval($_POST['new-folder-parent']) : null; if (!empty($parent)) { $folder_args['parent'] = $parent; } // If there's a parent, the parent's folder type takes precedence if (!empty($parent)) { $folder_args['group_id'] = bp_docs_get_folder_group($parent); $folder_args['user_id'] = bp_docs_get_folder_user($parent); // Otherwise, trust the values passed } else { // Type $folder_type = stripslashes($_POST['new-folder-type']); if ('global' === $folder_type) { // Nothing to do } else { if ('me' === $folder_type) { $folder_args['user_id'] = bp_loggedin_user_id(); } else { if (is_numeric($folder_type)) { // This is a group $folder_args['group_id'] = intval($folder_type); } } } } // Create the folder // @todo permissions checks $success = bp_docs_create_folder($folder_args); if (!empty($success) && !is_wp_error($success)) { bp_core_add_message(__('Folder successfully created.', 'bp-docs'), 'success'); } else { bp_core_add_message(__('There was a problem creating the folder. Please try again.', 'bp-docs'), 'error'); } bp_core_redirect($redirect_url); die; }
public static function icon_dir_uri($url) { if (bp_docs_is_docs_component()) { $url = plugins_url(BP_DOCS_PLUGIN_SLUG . '/lib/nuvola'); } return $url; }
/** * Are we looking at something that needs docs theme compatability? * * @since 1.3 */ public function is_docs() { $is_docs = bp_docs_is_docs_component(); if (bp_is_active('groups') && bp_is_group() && bp_is_current_action(buddypress()->bp_docs->slug)) { $is_docs = true; } // Bail if not looking at the docs component if (!$is_docs) { return; } add_filter('bp_get_template_stack', array($this, 'add_plugin_templates_to_stack')); add_filter('bp_get_buddypress_template', array($this, 'query_templates')); add_filter('bp_use_theme_compat_with_current_theme', 'bp_docs_do_theme_compat'); if (bp_docs_is_global_directory() || bp_docs_is_mygroups_directory()) { bp_update_is_directory(true, 'docs'); do_action('bp_docs_screen_index'); add_action('bp_template_include_reset_dummy_post_data', array($this, 'directory_dummy_post')); add_filter('bp_replace_the_content', array($this, 'directory_content')); } else { if (bp_docs_is_existing_doc()) { if (bp_docs_is_doc_history()) { $this->single_content_template = 'docs/single/history'; add_filter('bp_force_comment_status', '__return_false'); } else { if (bp_docs_is_doc_edit()) { $this->single_content_template = 'docs/single/edit'; add_filter('bp_force_comment_status', '__return_false'); } else { $this->single_content_template = 'docs/single/index'; add_filter('bp_docs_allow_comment_section', '__return_false'); // Necessary as of BP 1.9.2 remove_action('bp_replace_the_content', 'bp_theme_compat_toggle_is_page', 9999); } } add_action('bp_template_include_reset_dummy_post_data', array($this, 'single_dummy_post')); add_filter('bp_replace_the_content', array($this, 'single_content')); } else { if (bp_docs_is_doc_create()) { add_action('bp_template_include_reset_dummy_post_data', array($this, 'create_dummy_post')); add_filter('bp_replace_the_content', array($this, 'create_content')); } } } }
/** * Loads styles * * @package BuddyPress Docs * @since 1.0-beta */ function enqueue_styles() { global $bp; // Load the main CSS only on the proper pages if (in_array(BP_DOCS_SLUG, $this->slugstocheck) || bp_docs_is_docs_component()) { wp_enqueue_style('bp-docs-css', $this->includes_url . 'css/bp-docs.css'); } if (!empty($this->query->current_view) && ('edit' == $this->query->current_view || 'create' == $this->query->current_view)) { wp_enqueue_style('thickbox'); } }
/** * Add the parent and child theme names to the body class when on a BP Docs page. * * @since 1.9.0 * * @param array $classes An array of body classes. */ public function filter_body_class($classes) { if (bp_docs_is_docs_component()) { $classes[] = 'bp-docs-body-theme-' . get_stylesheet(); $classes[] = 'bp-docs-body-theme-' . get_template(); } return $classes; }
/** * Is this a single group's Docs tab? * * @since 1.9 * @return bool */ function bp_docs_is_group_docs() { $is_directory = false; if (bp_is_active('groups') && bp_is_group() && bp_docs_is_docs_component()) { $is_directory = true; } return apply_filters('bp_docs_is_group_docs', $is_directory); }