Skip to content

Instantly share code, notes, and snippets.

View davisshaver's full-sized avatar

Davis Shaver davisshaver

View GitHub Profile
@davisshaver
davisshaver / 0_reuse_code.js
Created August 15, 2014 18:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@davisshaver
davisshaver / example.php
Created November 5, 2014 19:51
How we register a UI for [fusion-content]
<?php
add_action( 'init', 'register_fusion_content_ui' );
function register_fusion_content_ui() {
shortcode_ui_register_for_shortcode(
'fusion-content',
array(
'label' => 'Content',
@davisshaver
davisshaver / example.php
Created November 10, 2014 17:08
Registering a shortcode UI for pullquotes
<?php
add_action( 'init', 'register_fusion_pullquote_ui' );
function register_fusion_pullquote_ui() {
shortcode_ui_register_for_shortcode(
'fusion-pullquote',
array(
'label' => 'Pullquote',
'listItemImage' => 'dashicons-editor-quote',
@davisshaver
davisshaver / brainstorming.md
Last active August 29, 2015 14:16
Brainstorming notes: YIP human centered design for elections

AGENDA

Go over ground rules

  • Defer judgement
  • Aim high
  • Yes, and
  • Focus
  • Quantity over quality

Draw me something

  • Make city government cool
@davisshaver
davisshaver / class-publishing-checklist.php
Created June 26, 2015 16:02
Gist for adding a basic Publishing Checklists
<?php
class Publishing_Checklist {
private static $instance;
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new Publishing_Checklist;
self::$instance->setup_actions();
}
@davisshaver
davisshaver / publishing-checklist-integration.php
Last active August 29, 2015 14:23
Snippet for adding a basic Publishing Checklist
<?php
add_action( 'publishing_checklist_init', function() {
$args = array(
'label' => esc_html__( 'Featured Image', 'demo_publishing_checklist' ),
'callback' => function ( $post_id, $id ) {
return has_post_thumbnail( $post_id );
},
'explanation' => esc_html__( 'A featured image is required.', 'demo_publishing_checklist' ),
'post_type' => array( 'post' ),
@davisshaver
davisshaver / one.php
Created July 21, 2015 14:19
Speed Bumps – Example code
<?php
register_speed_bump( 'rickroll', array(
'string_to_inject' => function() { return '<iframe width="420" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allowfullscreen></iframe>'; },
'minimum_content_length' => false,
'from_start' => false,
'from_end' => false,
));
add_filter( 'the_content', 'insert_speed_bumps', 1 );
@davisshaver
davisshaver / first-functions-sample.php
Last active August 29, 2015 14:25
Speed Bumps – Example code to accompany http://fus.in/1MidK1N
<?php
register_speed_bump( 'rickroll', array(
'string_to_inject' => function() { return '<iframe width="420" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allowfullscreen></iframe>'; },
'minimum_content_length' => false,
'from_start' => false,
'from_end' => false,
));
add_filter( 'the_content', 'insert_speed_bumps', 1 );
@davisshaver
davisshaver / second-functions-sample.php
Created July 21, 2015 14:23
Speed Bumps – Example code to accompany http://fus.in/1MidK1N
<?php
add_filter( 'speed_bumps_rickroll_constraints', 'give_you_up', 10, 4 );
function give_you_up( $can_insert, $context, $args, $already_inserted ) {
if ( ! preg_match( '/give [^ ]+ up/i', $context['prev_paragraph'] ) ) {
$can_insert = false;
}
return $can_insert;
}
@davisshaver
davisshaver / third-functions-sample.php
Last active August 29, 2015 14:25
Speed Bumps – Example code to accompany http://fus.in/1MidK1N
<?php
if ( current_user_can( 'manage_options' ) ) {
add_filter( 'speed_bumps_rickroll_constraints', '__return_false' );
}