Skip to content

Instantly share code, notes, and snippets.

clarklab / block-whitelist.php
Created Jan 28, 2020
WordPress whitelist Gutenberg blocks
View block-whitelist.php
* Block whitelist
* Only allow certain blocks to be used
add_filter( 'allowed_block_types', 'our_allowed_block_types' );
function our_allowed_block_types( $allowed_blocks ) {
clarklab / blocks.php
Created Jan 27, 2020
WordPress Gutenberg block use only once
View blocks.php
// ... the rest of your file here
'name' => 'hero',
'title' => __('Hero'),
'description' => __('A custom hero block.'),
'render_template' => 'template-parts/blocks/hero/hero.php',
'category' => 'formatting',
clarklab / block-helpers.php
Last active Nov 23, 2020
Wordpress check if block is used first
View block-helpers.php
* Block helpers
* add special classes when certain blocks appear, put this in your functions.php file or include it somewhere
// add block classes in body and post class
function blocks_body_class( $classes ) {
global $post;
View gist:f92ad9a57fdcd857b0888d9f30b2e330
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="List Posts From WordPress Using REST API With cURL In PHP">
<title>WordPress REST API</title>
<link rel="stylesheet" href="" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
View gist:d3b4060b9cea26bb76706b39dbfe2730
DJI Osmo Mobile ($292)
DJI Osmo High Capacity Battery ($42)
DJI Osmo Base ($14)
DJI Osmo Tripod ($55)
DJI Osmo Stick ($64)
Total Retail $467
Sale Price $325
clarklab / get-shorty.php
Created Mar 30, 2017
Get first X words of WordPress post
View get-shorty.php
// toss this in your functions.php (or elsewhere)
function get_shorty($count = 15){
global $post;
$str = get_the_content();
$str = implode(' ', array_slice(explode(' ', $str), 0, $count));
return $str.'...';
clarklab / shortcodes-in-ACF.php
Last active Apr 9, 2019
Shortcodes with Advanced Custom Fields
View shortcodes-in-ACF.php
add_filter('acf/format_value/type=textarea', 'do_shortcode');


  • find me on twitter, codepen
  • heckle me on Twitter, use the hashtag
  • a little bit about myself
  • worked on the web for over a decade now
  • just left a gig at
    • a team of about 2 dozen
    • was there about 2 years
    • lone designer, lots of engineers
    • made me think about our process
clarklab / gist:243b58bd42dfba214b1f
Last active Aug 29, 2015
WordPress comment hacks
View gist:243b58bd42dfba214b1f
//start by checking for a couple of key pieces of info
$current_user = wp_get_current_user();
$private_comments = get_post_meta($post->ID, 'private_comments', true);
$meta_lock = get_post_meta($post->ID, 'meta_lock', true);
$time_lock = get_post_meta($post->ID, 'time_lock', true);
//if the post has the custom field 'meta_lock'
if ($meta_lock) {
//check the current user for that meta field
$user_meta_key = get_user_meta($current_user->ID, $meta_lock, true);
clarklab / rsvp.php
Last active Dec 12, 2015 — forked from technosailor/gist:1771566
Updated to function as a simple RSVP button with facepile (list of avatars from confirmed users).
View rsvp.php
class wordup_session_rsvp {
function __construct()
function hooks()