Skip to content

Instantly share code, notes, and snippets.

<?php
/*
Plugin Name: Less Test
Version: 0.1
Author: Joe Hoyle
*/
require_once( 'wp-less/wp-less.php' );
### LOG TEST
127.0.0.1 - - [07/Nov/2012:17:47:42 +0000] "POST /?tlc_transients_request HTTP/1.0" 499 0 "-" "WordPress/3.5-alpha-21751; http://x.y"
**Phase 1: Completed pre-decoding.
full event: '127.0.0.1 - - [07/Nov/2012:17:47:42 +0000] "POST /?tlc_transients_request HTTP/1.0" 499 0 "-" "WordPress/3.5-alpha-21751; http://x.y"'
hostname: 'ip-10-159-10-28'
program_name: '(null)'
<?php
hm_rewrite_rule( array(
'regex' => '^users/([^/]+)/?',
'query' => 'author_name=$matches[1]&',
'template' => 'user-archive.php',
'body_class_callback' => function( $classes ) {
$classes[] = 'user-archive';
$classes[] = 'user-' . get_query_var( 'author_name' );
@joehoyle
joehoyle / args.php
Last active October 12, 2015 14:27
<?php
regex // the regex pattern to match against the URL
query // the wp_query arguments
template // the template file to load for this rewrite, full path or relative to active theme
request_callback // callback called when the url is matched, useful for adding complex wp_query arguments
disable_canonical // if set to true, will disable the often pesky canonical redirect that can erosion sly run on complex queries
post_query_properties // list of properties to add / overwrite on the WP_Query object, useful for setting is_my_custom_page=1 style properties.
title_callback // called via the wp_title hook to easily set the page title
restrict_access // can be set to "logged_in_only" etc for private pages.
<?php
hm_rewrite_rule( array(
'regex' => '^reviews/([^/]+)/?', // a review category page
'query' => 'review_category=$matches[1]&',
'template' => 'review-category.php',
'request_callback' => function( WP $wp ) {
// if the review category is "laptops" then only show items in draft
@joehoyle
joehoyle / api.php
Last active October 12, 2015 14:27
<?php
hm_add_rewrite_rule( array(
'request_method' => 'DELETE',
'regex' => '/api/v3/posts/([^/]+)',
'query' => 'post_id=$matches[1]',
'request_callback' => function( WP $wp ) {
wp_delete_post( $wp->query_vars['post_id'] );
<?php
/* Path to the WordPress codebase you'd like to test. Add a backslash in the end. */
//define( 'ABSPATH', getenv( 'WP_CORE_DIR' ) . '/' );
define( 'ABSPATH', '../../../../wordpress/' );
define( 'WP_CONTENT_DIR', ABSPATH . '../content' );
// Set path to MU Plugins.
//define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins-mu' );
server {
listen 80;
server_name clickbankpowered.dev *.clickbankpowered.dev;
root /Users/joe/Sites/bailey-bridge;
index index.php;
rewrite ^(/wp-(admin|includes)/(.*))$ /wordpress$1 last;
rewrite ^(/wp-[^/]*\.php)$ /wordpress$1 last;
location /dashboard/api/upload-video {
<?php
add_filter( 'wpthumb_post_image_path', function() {
return WP_CONTENT_DIR . '/uploads/' . rand( 0, 2 ) . '.jpg';
});
add_filter( 'get_attached_file', function( $path ) {
return WP_CONTENT_DIR . '/uploads/' . rand( 0, 2 ) . '.jpg';
});
#!/bin/sh
set -e
git config -f .gitmodules --get-regexp '^submodule\..*\.path$' |
while read path_key path
do
url_key=$(echo $path_key | sed 's/\.path/.url/')
url=$(git config -f .gitmodules --get "$url_key")
git submodule add $url $path