Skip to content

Instantly share code, notes, and snippets.

<span class="icon-mime-type video"></span><a href="#video">Video</a>
// Set the current progress in the 'status' parameter.
// List out the names of the steps in the 'steps' parameter.
[progress_bar status="5" steps="Uno,Dos,Tres,Cuatro,Cinco,Seis,Siete"]
@dcavins
dcavins / commons-tooltip-example.html
Last active February 21, 2017 16:34
Example HTML for setting up tooltips on Community Commons
<span class="add-tooltip" data-tooltip-text="Tooltip message to show">Target text</span>
@dcavins
dcavins / toggle-example.html
Created February 21, 2017 16:20
Example of toggled content structure on Community Commons
<div class="toggle-container toggle-closed">
<span class="arrow"></span><a href="https://www.communitycommons.org/cchelp/how-do-i-add-a-picture-to-my-member-profile/" class="toggle-trigger">This is probably the most common example of a toggle.</a>
<div class="toggle-content border-left">
<p>It includes the arrow toggle-state indicator and the content block gets the nice little left border and indent.</p>
<p>&hellip;</p>
</div>
</div>
@dcavins
dcavins / test-bp-docs-delete-cb.php
Last active March 16, 2017 15:38
A testing function for seeing where a BP Docs delete is going wrong.
<?php
// Remove the default
remove_action( 'bp_actions', 'bp_docs_process_folder_delete_cb' );
// Add the troubleshooting version
add_action( 'bp_actions', 'my_tshoot_bp_docs_process_folder_delete_cb' );
/**
* Catch a request to delete a folder.
*
* @since 1.9.0
@dcavins
dcavins / hgbp-user-can-create-subgroup-depth.php
Created April 4, 2017 19:56
An example of adding "user can" checks on the "create_subgroup" capability
<?php
add_filter( 'bp_user_can', 'my_create_groups_cap_change', 20, 5 );
function my_create_groups_cap_change( $retval, $user_id, $capability, $site_id, $args ) {
if ( 'create_subgroups' == $capability ) {
// We need to know which group is in question.
if ( empty( $args['group_id'] ) ) {
return false;
}
@dcavins
dcavins / admins-can-create-bp-docs-only.php
Last active February 3, 2020 12:30
Filter BP Docs capabilities so that only admins can create new docs.
<?php
function my_docs_create_admins_only( $caps, $cap, $user_id, $args ) {
if ( 'bp_docs_create' == $cap ) {
// Only admins can create docs.
if ( bp_current_user_can( 'bp_moderate' ) ) {
$caps[] = 'exist';
} else {
$caps[] = 'do_not_allow';
}
}
@dcavins
dcavins / attachments.php
Last active February 3, 2020 12:30
Only allow original uploader or site admin to delete attachments.
<?php if ( bp_docs_is_doc_edit() || bp_docs_is_doc_create() ) : ?>
<?php bp_docs_media_buttons( 'doc_content' ) ?>
<?php endif; ?>
<?php
// Maybe you'll want to do something with main doc ID.
$doc_id = get_the_ID();
?>
<ul id="doc-attachments-ul">
@dcavins
dcavins / bp-custom.php
Created July 1, 2017 12:44
Change BP Docs default read setting.
<?php
add_filter( 'bp_docs_get_default_access_options', 'my_change_docs_default_access_levels' );
function my_change_docs_default_access_levels( $defaults ) {
$defaults['read'] = 'loggedin';
return $defaults;
}
@dcavins
dcavins / bp-docs-attachments-order-by-title.php
Created July 11, 2017 16:25
Order BP Doc attachment list alphabetically by title.
<?php
add_filter( 'bp_docs_get_doc_attachments_args', 'dc_order_docs_attachments_by_title' );
function dc_order_docs_attachments_by_title( $args ) {
$args['orderby'] = 'title';
$args['order'] = 'ASC';
return $args;
}