This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'bp_docs_get_default_access_options', 'my_change_docs_default_access_levels' ); | |
function my_change_docs_default_access_levels( $defaults ) { | |
/** | |
* Possible access capabilities are 'read', 'edit', 'read_comments', 'post_comments', | |
* 'view_history', or 'manage'. | |
* Possible access options are 'loggedin', 'creator', or 'anyone'. | |
* If BuddyPress groups are activated, then additional access options are available | |
* to docs that are associated with a group: | |
* 'group-members' and 'admins-mods'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$needles = array( 'a', 'an', 'the', 'and', 'or', 'but', 'aboard', 'about', 'above', 'across', 'after', 'against', 'along', 'amid', 'among', 'anti', 'around', 'as', 'at', 'before', 'behind', 'below', 'beneath', 'beside', 'besides', 'between', 'beyond', 'but', 'by', 'concerning', 'considering', 'despite', 'down', 'during', 'except', 'excepting', 'excluding', 'following', 'for', 'from', 'in', 'inside', 'into', 'like', 'minus', 'near', 'of', 'off', 'on', 'onto', 'opposite', 'outside', 'over', 'past', 'per', 'plus', 'regarding', 'round', 'save', 'since', 'than', 'through', 'to', 'toward', 'towards', 'under', 'underneath', 'unlike', 'until', 'up', 'upon', 'versus', 'via', 'with', 'within', 'without', 'long' ); | |
$needles = implode('|', $needles); | |
// ?: signifies a non-capturing group | |
// http://www.regular-expressions.info/captureall.html | |
$pattern = "/(?:(?:\b(?:$needles)\b(?:\W(?:$needles)\b)*))/"; | |
$haystack = 'By the Light of the Silvery Moon and Stars except during or until Dawn'; | |
$replacement = '(r)$0(/r)'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'bp_docs_map_meta_caps', 'bp_docs_groups_allow_group_admins_to_manage_access', 20, 4 ); | |
function bp_docs_groups_allow_group_admins_to_manage_access( $caps, $cap, $user_id, $args ) { | |
// We only want to act on the "manage" capability, in group situations. | |
if ( 'bp_docs_manage' !== $cap ) { | |
return $caps; | |
} | |
$doc = bp_docs_get_doc_for_caps( $args ); | |
if ( empty( $doc ) ) { | |
return $caps; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Enables folders for group, user, and global doc directories. | |
add_filter( 'bp_docs_enable_folders_for_current_context', '__return_true' ); | |
// Shows the folder metabox on the doc edit screen. | |
add_filter( 'bp_docs_folders_force_metabox', '__return_true' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* BuddyPress - Members Single Messages Compose | |
* | |
* @package BuddyPress | |
* @subpackage bp-legacy | |
*/ | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Create an activity item to appear in a group. Fires once a post has been saved. | |
* | |
* @param int $post_ID Post ID. | |
* @param WP_Post $post Post object. | |
* @param bool $update Whether this is an existing post being updated or not. | |
*/ | |
function add_activity_item_for_group( $post_id, $post_object, $update ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Ignore folder association temporarily. | |
remove_filter( 'bp_docs_tax_query', 'bp_docs_folder_tax_query', 10, 2 ); | |
$doc_args = array( | |
// 'folder' => , | |
'posts_per_page' => 50, | |
'paged' => 1, // increment this to work through the docs. | |
); | |
if ( bp_docs_has_docs( $doc_args ) ) : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* If a user submits a site membership request, but has a | |
* 'my-school.edu' email address, bypass the manual approval of the request. | |
* | |
* @param bool $send Whether or not this membership request should be approved | |
* immediately and the activation email sent. | |
* Default is `false` meaning that the request should be | |
* manually approved by a site admin. | |
* @param array $details The details of the request. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Allow group admins and mods to read and edit any BP Doc | |
* associated with a group they moderate. | |
* Note: this will allow direct access at `/docs/doc-title/` but | |
* the docs will not be listed in the group docs directory if the | |
* access level "should" prevent the user from accessing it. | |
* So it's of limited usefulness. | |
* | |
* @param string[] $caps Primitive capabilities required of the user. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'bp_docs_get_access_options', 'remove_creator_option_for_group_docs', 10, 4 ); | |
function remove_creator_option_for_group_docs( $options, $settings_field, $doc_id = 0, $group_id = 0 ) { | |
if ( ! $group_id ) { | |
$group_id = bp_docs_get_associated_group_id( $doc_id ); | |
} | |
// If this is the Doc creation page, check to see whether a | |
// group id has been passed somewhere | |
if ( empty( $group_id ) ) { |
NewerOlder