Skip to content

Instantly share code, notes, and snippets.

@jvanja
jvanja / JavaScript: PubSub
Last active August 29, 2015 14:01 — forked from cassiano-gists/gist:4141404
JavaScript: Pub/Sub
// Works in modern browsers + IE9, but Modernizr has a polyfill baked in for function.bind.
// Hat tip Paul Irish
var o = $( {} );
$.subscribe = o.on.bind(o);
$.unsubscribe = o.off.bind(o);
$.publish = o.trigger.bind(o);
// Usage
$(document.body).on( 'click', function() {
@jvanja
jvanja / functions.php
Created March 13, 2017 08:54 — forked from martynchamberlin/functions.php
How to get_the_content() with formatting
<?php
/**
* Instead of calling get_the_content(), call this function instead, and it'll all be good
*/
function get_the_content_with_formatting()
{
ob_start();
the_content();
$the_content = ob_get_contents();
@jvanja
jvanja / filters.php
Created June 22, 2023 09:24 — forked from dkjensen/filters.php
WordPress Gutenberg Query Loop View More AJAX
<?php
/**
* Add data attributes to the query block to describe the block query.
*
* @param string $block_content Default query content.
* @param array $block Parsed block.
* @return string
*/
function query_render_block( $block_content, $block ) {
if ( 'core/query' === $block['blockName'] ) {