Skip to content

Instantly share code, notes, and snippets.

@dcavins
dcavins / half-block-example.html
Last active February 21, 2017 16:36
Half-block structure example
<div class="content-row clear">
<div class="half-block">
Suddenly she came upon a little three-legged table...
</div>
<div class="half-block">
Suddenly she came upon a little three-legged table...
</div>
</div>
@dcavins
dcavins / third-block-example.html
Last active February 21, 2017 16:35
Third-block structure example
<div class="content-row clear">
<div class="third-block">
Suddenly she came upon a little three-legged table...
</div>
<div class="third-block">
Suddenly she came upon a little three-legged table...
</div>
<div class="third-block">
Suddenly she came upon a little three-legged table...
</div>
@dcavins
dcavins / quarter-block-example.html
Last active February 21, 2017 16:35
Quarter-block structure example
<div class="content-row clear">
<div class="quarter-block">
Suddenly she came upon a little three-legged table...
</div>
<div class="quarter-block">
Suddenly she came upon a little three-legged table...
</div>
<div class="quarter-block">
Suddenly she came upon a little three-legged table...
</div>
@dcavins
dcavins / two-thirds-block-example.html
Last active February 21, 2017 16:35
Two-thirds-block structure example
<div class="content-row clear">
<div class="third-block spans-2">
Suddenly she came upon a little three-legged table, all made of solid glass; there was nothing on it except a tiny golden key, and Alice's first thought was that it might belong to one of the doors of the hall.
</div>
<div class="third-block">
Suddenly she came upon a little three-legged table, all made of solid glass; there was nothing on it except a tiny golden key.
</div>
</div>
@dcavins
dcavins / admin.css
Created December 28, 2014 16:02
BP Core Admin CSS
/**
* Markup for the BuddyPress wp-admin screens.
*/
.bpa-nav-logo:before {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; }
.bpa-header {
border-bottom: 1px solid #e44800;;
}
@dcavins
dcavins / regexp-remove-prepositions
Last active May 30, 2023 21:02
RegExp for finding articles and prepositions in a string
<?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)';
@dcavins
dcavins / bp_docs_unlink.1.patch
Created March 4, 2015 01:57
Unlink BP Docs from Groups
@dcavins
dcavins / bp_docs_unlink.2.patch
Created March 4, 2015 16:06
Unlink BP Docs from Groups
@dcavins
dcavins / bp_docs_test_permissions.1.patch
Created March 4, 2015 16:17
Use factory method for user creation
diff --git tests/test-permissions.php tests/test-permissions.php
index a8f766f..9b44cad 100644
--- tests/test-permissions.php
+++ tests/test-permissions.php
@@ -42,7 +42,7 @@ class BP_Docs_Tests_Permissions extends BP_Docs_TestCase {
* @group map_meta_cap
*/
public function test_loggedin_user_can_bp_docs_create() {
- $u = $this->create_user();
+ $u = $this->factory->user->create();
@dcavins
dcavins / search_where_filter
Created April 17, 2015 19:14
Modify the search "WHERE" statement in WordPress
add_filter('posts_search', 'what_the_search', $priority = 10, $accepted_args = 2);
function what_the_search( $search, $query ){
if ( $query->is_search ) {
$towrite = PHP_EOL . '$search: ' . print_r( $search, TRUE );
// $search looks like:
// AND (((wp_posts.post_title LIKE '%walking%') OR (wp_posts.post_content LIKE '%walking%'))) AND (wp_posts.post_password = '')
$fp = fopen('what_the_search.txt', 'a');
fwrite($fp, $towrite);
fclose($fp);
}