Skip to content

Instantly share code, notes, and snippets.

Avatar

Clark Wimberly clarklab

View GitHub Profile
@clarklab
clarklab / block-whitelist.php
Created Jan 28, 2020
WordPress whitelist Gutenberg blocks
View block-whitelist.php
<?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
clarklab / blocks.php
Created Jan 27, 2020
WordPress Gutenberg block use only once
View blocks.php
<?php
// ... the rest of your file here
acf_register_block_type(array(
'name' => 'hero',
'title' => __('Hero'),
'description' => __('A custom hero block.'),
'render_template' => 'template-parts/blocks/hero/hero.php',
'category' => 'formatting',
@clarklab
clarklab / block-helpers.php
Last active Jan 28, 2020
Wordpress check if block is used first
View block-helpers.php
<?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">
<head>
<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="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
View gist:d3b4060b9cea26bb76706b39dbfe2730
DJI Osmo Mobile http://amzn.to/2tgSBDL ($292)
DJI Osmo High Capacity Battery http://amzn.to/2tgJz9v ($42)
DJI Osmo Base http://amzn.to/2sbfVlT ($14)
DJI Osmo Tripod http://amzn.to/2tgtvVk ($55)
DJI Osmo Stick http://amzn.to/2sbNOTH ($64)
Total Retail $467
Sale Price $325
@clarklab
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
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');
View rwd-summit-notes.md

Intro

  • 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 TheZebra.com
    • a team of about 2 dozen
    • was there about 2 years
    • lone designer, lots of engineers
    • made me think about our process
@clarklab
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
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
<?php
class wordup_session_rsvp {
function __construct()
{
$this->hooks();
}
function hooks()
You can’t perform that action at this time.