Skip to content

Instantly share code, notes, and snippets.

@alexeckermann
alexeckermann / category_list_block.rb
Created June 27, 2011 11:46
The Jekyll plugins used on alexeckermann.com
module Jekyll
class CategoryListBlock < Liquid::Block
include Liquid::StandardFilters
def render(context)
categories = context.registers[:site].categories.keys
result = []
context.stack do
@yoren
yoren / functions-1.php
Last active February 18, 2016 04:17
Upgrading Your AngularJS Theme To Work With WP API V2
<?php
function my_rest_prepare_post( $data, $post, $request ) {
$_data = $data->data;
$thumbnail_id = get_post_thumbnail_id( $post->ID );
$thumbnail = wp_get_attachment_image_src( $thumbnail_id );
$_data['featured_image_thumbnail_url'] = $thumbnail[0];
$data->data = $_data;
@GhazanfarMir
GhazanfarMir / wp_17072015.php
Last active February 18, 2016 04:18
Modify api base from wp-json to anything you want in WP-API Plugin
// modify api base from "wp-json" to "api"
add_filter('json_url_prefix', 'modify_url_base' );
/**
* Modifying Base URL from 'WP-JSON' to 'api'
*/
function modify_url_base($prefix) {
return 'api';
}
@arippberger
arippberger / gist:8514af9475b64442996a
Created July 23, 2014 19:32
Get public meta values in WP-API
function my_prepare_post( $post_response, $post, $context ) {
$meta = get_post_custom( $post['ID'] );
$custom_fields = array();
foreach ( $meta as $key => $value ) {
if ( '_' !== substr( $key, 0, 1 ) ) {
$custom_fields[ $key ] = $value;
}
}
$post_response['custom_fields'] = $custom_fields;
return $post_response;
@klihelp
klihelp / kli-wp-api-remove-featured-image-field.php
Last active February 18, 2016 04:18
WP-API remove featured_image field
@yoren
yoren / functions.php
Last active June 24, 2016 13:41
Add posts to term JSON data
<?php
function my_json_prepare_term( $data, $term, $context ) {
global $wp_query;
$route = $wp_query->query['json_route'];
if ( ! preg_match( '/(terms\/.+)/', $route) )
return $data;
$args = array(
@glasmasin
glasmasin / gist:6737584
Last active July 25, 2018 14:04
Google Apps Script to use mail merge the old fashioned way - to output merged Documents!
/**
* This script will output a mailmerge of documents.
* All document variables are of the form <<var_name>> (spaces are ok)
* Requires a spreadsheet with two sheets
* The first is the data table, the second has the template url in A1
* and the merged document's title in A2 (optional and can use data variables)
*
* With thanks to:
* drzaus: http://webapps.stackexchange.com/a/47255
* Google Apps Script Tutorial: Simple Mail Merge
@westy92
westy92 / QueuedCallback.js
Last active July 25, 2019 21:56
Queued Callback
/*
Sometimes you need to queue things up before a callback is available. This solves that issue.
Push any item(s) to an array.
Once you want to start consuming these items, pass the array and a callback to QueuedCallback().
QueuedCallback will overload array.push as your callback and then cycle through any queued up items.
Continue to push items to that array and they will be forwarded directly to your callback. The array will remain empty.
Compatible with all browsers and IE 5.5+.
*/
@sivel
sivel / test-head-footer.php
Created April 25, 2010 14:46
WordPress Plugin to test for the existence and functionality of wp_head and wp_footer in the active theme
<?php
/**
* @file
* Default theme implementation to display the basic html structure of a single
* Drupal page.
*
* Variables:
* - $css: An array of CSS files for the current page.
* - $language: (object) The language the site is being displayed in.