Skip to content

Instantly share code, notes, and snippets.

@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';
}
@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(
@paulirish
paulirish / bling.js
Last active May 1, 2024 19:56
bling dot js
/* bling.js */
window.$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function (name, fn) {
this.addEventListener(name, fn);
}
NodeList.prototype.__proto__ = Array.prototype;
@klihelp
klihelp / kli-wp-api-remove-featured-image-field.php
Last active February 18, 2016 04:18
WP-API remove featured_image field
@JLarky
JLarky / 1_README.md
Last active January 19, 2022 22:35 — forked from Daniel15/1_README.md

Google Drive File Picker Example

This is an example of how to use the Google Drive file picker and Google Drive API to retrieve files from Google Drive using pure JavaScript. At the time of writing (14th July 2013), Google have good examples for using these two APIs separately, but no documentation on using them together.

Note that this is just sample code, designed to be concise to demonstrate the API. In a production environment, you should include more error handling.

See a demo at http://stuff.dan.cx/js/filepicker/google/

@rileypaulsen
rileypaulsen / functions.php
Created August 19, 2014 16:08
Add Advanced Custom Fields Fields to the WP REST API
function wp_api_encode_acf($data,$post,$context){
$data['meta'] = array_merge($data['meta'],get_fields($post['ID']));
return $data;
}
if( function_exists('get_fields') ){
add_filter('json_prepare_post', 'wp_api_encode_acf', 10, 3);
}
@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;
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@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
@LeaVerou
LeaVerou / dabblet.css
Created July 20, 2013 23:09
Loading animation like the one seen on http://www.freeger.com/projects/contextad/ with CSS
/**
* Loading animation like the one seen on http://www.freeger.com/projects/contextad/ with CSS
* Caveat: Not DRY. The content needs to be repeated in a data- attribute (or directly in the CSS).
*/
body {
background: #ccc51c;
min-height: 100%;
}