Skip to content

Instantly share code, notes, and snippets.

View tddewey's full-sized avatar

Taylor Dewey tddewey

View GitHub Profile
@jeffsebring
jeffsebring / pu01_options_modal_uploader.js
Created September 16, 2013 19:31
WP 3.5 Options Page Modal Uploader
jQuery( document ).ready( function() {
function pu01_show_image() {
var pu01_image_1 = jQuery( '#pu01_image_1' ).val(),
pu01_image_2 = jQuery( '#pu01_image_2' ).val(),
pu01_image_3 = jQuery( '#pu01_image_3' ).val();
jQuery( '#pu01_image_1_preview' ).after( '<div id="pu01_image_1_preview_image"><img width="300" height="140" src="' + pu01_image_1 + '" /></div>' );
jQuery( '#pu01_image_2_preview' ).after( '<div id="pu01_image_2_preview_image"><img width="300" height="140" src="' + pu01_image_2 + '" /></div>' );
@jeffsebring
jeffsebring / pu01_metabox_uploader_modal.html
Last active December 23, 2015 05:09
WP 3.5 Metabox Uploader
<script>
var file_frame;
var wp_media_post_id = wp.media.model.settings.post.id;
var set_to_post_id = <?php echo get_the_ID(); ?>;
jQuery('.upload_image_button').on('click', function( event ){
event.preventDefault();
@tomjn
tomjn / gist:6140601
Last active December 20, 2015 13:39
If you're lucky enough to be using any version of PHP 5 with WordPress ( 100% chance! ) You can do this:
<?php
$posts = new posts_loop();
foreach( $posts as $id => $post ) {
the_title();
// etc...
}
// put this below in your functions.php:
@westonruter
westonruter / readme.md
Last active December 19, 2015 17:38
vassh: Vagrant Host-Guest SSH Command Wrapper/Proxy/Forwarder

THIS REPO HAS MOVED! It has graduated to a dedicated GitHub project: https://github.com/x-team/vassh

The big pain of doing vagrant ssh is that it doesn’t drop you into the corresponding working directory in the Vagrant guest’s synced_folder, so you have to cd to the dir and then run whatever you needed to do (e.g. wp core update). This is the problem that vassh solves: it will make sure you start out in the corresponding directory. So if you’re in your WordPress project on your host machine, all you need to do is:

$ vassh wp core update

There’s also a wrapper called vasshin which will shell you into Vagrant at the current directory, with a prompt for entering commands. This gets you colors and interactive TTY. You can also pass commands as arguments to vasshin to have them executed right away in the colorized TTY (with some additional Vagrant .bash_login echoes and SSH connection close):

@jeremyfelt
jeremyfelt / proxy-production.conf
Last active May 14, 2019 18:02
Nginx configuration to proxy 404 files locally to a production domain
# Adjust this to include any other necessary files.
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
try_files $uri $uri/ @production;
}
location @production {
resolver 1.1.1.1;
proxy_pass http://{replace-with.domain.com}/$uri;
@n1k0
n1k0 / 404checker.js
Created January 11, 2013 10:55
A CasperJS script to check for 404 & 500 internal links on a given website
/**
* This casper scipt checks for 404 internal links for a given root url.
*
* Usage:
*
* $ casperjs 404checker.js http://mysite.tld/
* $ casperjs 404checker.js http://mysite.tld/ --max-depth=42
*/
/*global URI*/
@jeremyfelt
jeremyfelt / google-dfp-acm-config.php
Created August 23, 2012 21:23
Google DFP JS Explanation
<?php
/**
* Basic configuration for multiple DFP JS ad tags in Ad Code Manager
*
* Our ad units are named 'test_ad_300x250' and 'test_ad_728x90'
* Our DFP ID is 12345678
* Our ad slot IDs will be automatically created
*
*/
@luetkemj
luetkemj / wp-query-ref.php
Last active April 25, 2024 09:37
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/
@jimbojsb
jimbojsb / gist:1630790
Created January 18, 2012 03:52
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2: