Skip to content

Instantly share code, notes, and snippets.

@hereswhatidid
hereswhatidid / archive-of-single-commit.git
Created February 7, 2014 21:29
Create an archive of files modified within the given commit.
git archive -o update.zip HEAD $(git diff --name-only COMMITIDHERE^)
@hereswhatidid
hereswhatidid / get-wordpress.bat
Created February 15, 2014 05:30
Windows batch file for getting the latest WordPress core files
wget64 http://wordpress.org/latest.tar.gz
7z e latest.tar.gz & 7z x latest.tar
robocopy wordpress ./ /MOVE /E
del latest.tar
del latest.tar.gz
ren wp-config-sample.php wp-config.php
@hereswhatidid
hereswhatidid / localize-bootstrap.less
Created February 16, 2014 16:17
Localize Bootstrap to a container element (pre 3.0)
.bootstrap-wrapper {
@import url( '../vendor/bootstrap/bootstrap.less' );
}
@hereswhatidid
hereswhatidid / query-user-firstname.php
Last active August 29, 2015 13:56
WP_User_Query meta parameters for first name
<?php
$args = array(
'role' => 'Administrator',
'meta_query' => array(
array(
'key' => 'first_name',
'value' => '',
'compare' => '!='
),
),
@hereswhatidid
hereswhatidid / geo-on-save.php
Created March 13, 2014 21:16
Geo code on save
<?php
//Auctions should be geocoded on save
function geocode_auction($post_id){
$auction_slug = 'auctions';
$_POST += array("{$auction_slug}_edit_nonce" => '');
if ( $auction_slug == $_POST['post_type'] && current_user_can( 'edit_post', $post_id )) {
$address = get_post_meta(get_the_ID(), 'Location', true);
@hereswhatidid
hereswhatidid / archive-dev.sh
Created May 5, 2014 20:26
Creates an archive of the files that are different between the master and development branches using Sourcetree on the Mac.
#!/bin/sh
args=("$@")
git archive -o deploy/deploy-devcompare.zip HEAD $(git diff-tree --no-commit-id --name-only -r master..development)
@hereswhatidid
hereswhatidid / bindOnce.js
Created March 11, 2015 14:40
Directive to remove watchers from an element within AngularJS
angular
.module( 'yourAppName' )
.directive( 'bindOnce', BindOnce );
function BindOnce() {
return {
scope: true,
link: function( $scope ) {
setTimeout(function() {
$scope.$destroy();
@hereswhatidid
hereswhatidid / dnn_overrides.less
Created April 3, 2015 19:49
LESS code for cleaning up link chooser dialog in DNN.
.ui-dialog {
* {
box-sizing: content-box;
}
.ui-dialog-titlebar {
border-bottom: none;
}
.page {
width: 100% !important;
}
@hereswhatidid
hereswhatidid / disable-long-comments.php
Created April 27, 2015 18:16
WordPress 4.2 comment fix - this will disable any comment over a certain lenght that could theoretically trigger the XSS vulnerability.
<?php
add_filter( 'pre_comment_content', function( $content ) {
if ( strlen( $content ) > 64000 )
wp_die( 'Invalid comment.' );
return $content;
} );
@hereswhatidid
hereswhatidid / interchange-attachments.php
Created July 15, 2015 18:05
Apply Foundation Interchange parameters to attachment images via filter
<?php
add_filter('wp_get_attachment_image_attributes', 'interchange_the_images', 10, 2);
function interchange_the_images ( $attr, $attachment )
{
/* Use ID to get the attachment object */
$lg_hero_array = wp_get_attachment_image_src( $attachment->ID, 'large', true ); //Large Hero
$md_hero_array = wp_get_attachment_image_src( $attachment->ID, 'medium', true ); // Medium Hero
$sm_hero_array = wp_get_attachment_image_src( $attachment->ID, 'thumbnail', true ); // Mobile Hero