This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Jekyll | |
class CategoryListBlock < Liquid::Block | |
include Liquid::StandardFilters | |
def render(context) | |
categories = context.registers[:site].categories.keys | |
result = [] | |
context.stack do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Use with JSON_API_VERSION <= 1.1.1 | |
* Note: Include the action in your functions.php | |
*/ | |
/** | |
* Remove featured_image field from response | |
* @param object $data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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+. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. |
OlderNewer