Skip to content

Instantly share code, notes, and snippets.

@goldenapples
Created May 15, 2015 19:42
Show Gist options
  • Save goldenapples/52b3b7e4542d4554dac7 to your computer and use it in GitHub Desktop.
Save goldenapples/52b3b7e4542d4554dac7 to your computer and use it in GitHub Desktop.
Speed Bumps API concept
// This should be all a theme has to do to register a speed bump and get it inserted
register_speed_bump(
'polar', // speedbump ID, just a hook in case it needs to be disabled on case-by-case basis anywhere else
10, // priority. WP uses priority integers like this a lot to look
// through arrays. The $_speed_bumps array would be sorted by
// priority and looped through, so that the speed bumps with the
// lowest priority get inserted first.
array(
// $args array. See http://codex.wordpress.org/wp_parse_args for an
// idea how to use this pattern
// callback, required if it returns any output
'callback' => function() { return '<div id="polar"></div>'; }
// optional overrides to default settings.
'minimum_content_length' => 1200,
'element_constraints' => array(
'blockquote',
'embed',
'img'
'caption'
),
)
);
add_filter( 'the_content', 'Speed_Bumps::insert_speed_bumps' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment