Skip to content

Instantly share code, notes, and snippets.

View DrewAPicture's full-sized avatar

Drew Jaynes DrewAPicture

View GitHub Profile
<?php
/**
* Integrate Imager.js with WordPress
*
* Imager.js is BBC's solution for serving responsive and retina images, without
* the double payload issues that affect other solutions. For more information:
*
* https://github.com/BBC-News/Imager.js/
*
* This collection of functions modifies the output of WordPress's
<?php
remove_filter( 'the_content', 'wpautop' );
$content = wpautop( $content, false );
echo apply_filters( 'the_content', $content );
add_filter( 'the_content', 'wpautop' );
<?php
add_filter( 'attachment_fields_to_edit', 'attachment_fields_to_edit', 10, 2 );
add_filter( 'attachment_fields_to_save', 'attachment_fields_to_save', 10, 2 );
function attachment_fields_to_edit( $form_fields, $post ) {
$form_fields["client_test_input"] = array(
"label" => __( 'Test Input URL' , 'client' ),
"value" => get_post_meta( $post->ID, "_client_test_input", true ),
"helps" => __( 'Test Input Field', 'client' )
);
@DrewAPicture
DrewAPicture / Gruntfile.js
Last active January 1, 2016 17:18
Grunt and package.json files for (in this example) packaging a theme for release. This should get you started -- plenty of Gruntjs resources out there.
// This assumes you've already installed Node.js and any related dependencies.
// 1. Drop this and package.json into your theme root
// 2. Run: npm install
// 3. Run: grunt
// 4. ??????
// 5. Profit
module.exports = function ( grunt ) {
grunt.initConfig( {
reddit powers thousands of distinct online communities.
these terms and your conduct make that possible.
Hello redditors and people of the Internet! We want you to know your rights and our rights and so we have prepared this agreement ("user agreement" or "agreement") between reddit ("we", "our," "us") and you. This agreement sets the terms of your use of the reddit website and services ("reddit") that include subreddits, communities, boards, forums, chats, reddit.tv, and tons of other greatness. This agreement is meant to encourage a fair and tolerant place for ideas, people, links, and discussion.
We also operate redditgifts, which has its own terms that you should read here.
first, the legal stuff
<?php
/**
* Filter the taxonomy hierarchy to inject a parent level of templates.
*
* @param string $template The current template.
* @return string Filtered taxonomy template.
*/
function new_tax_hierarchy( $template ) {
$term = get_queried_object();
<?php
function can_haz_link( $id ) {
?>
<a href="#">Can haz link?</a>
<?php
}
add_action( 'wpmublogsaction', 'can_haz_link' );
<?php
/**
* @type string|bool $avatar_dir The name of the subdirectory where the requested avatar should
* be found. If no value is passed, 'avatar_dir' is inferred from 'object': 'user' becomes
* 'avatars', 'group' becomes 'group-avatars', 'blog' becomes 'blog-avatars'. Remember that
* this string denotes a subdirectory of BP's main avatar directory (usually based on
* {@link wp_upload_dir()}); it's a string like 'group-avatars' rather than the full directory
* path. Generally, it'll only be necessary to override the default value if storing avatars
* in a non-default location. Defaults to false (auto-detected).
* @type int|bool $width Requested avatar width. The unit is px. This value is used to build the
<?php
function filter_menu_order( $order ) {
return array(
'index.php','separator1', 'edit.php', 'edit.php?post_type=page',
'users.php', 'upload.php', 'edit-comments.php', 'separator2', 'themes.php',
'plugins.php', 'tools.php', 'options-general.php', 'separator-last'
);
}
add_filter( 'menu_order', 'filter_menu_order' );
add_filter( 'custom_menu_order', '__return_true' );
@DrewAPicture
DrewAPicture / query_params.php
Last active December 22, 2015 15:18
WP_Query hash notation
<?php
/**
* @param array $query {
* WP_Query parameters.
*
* @type int 'author' Author id, or comma-separated list of ids
* @type string 'author_name' Use 'user_nicename'
* @type array 'author__in' Array of author ids to query from.
* @type array 'author__not_in' Array of author ids not to query from.
* @type int 'cat' Category id or comma-separated list of ids (this or any children)