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
//MIT License | |
//Copyright (c) 2015 Karol Wrótniak, Droids On Roids | |
package pl.droidsonroids.imagehelpers; | |
import java.io.File; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
import android.app.Activity; | |
import android.content.ActivityNotFoundException; | |
import android.content.ContentResolver; |
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 | |
/** | |
* Helper function since this function doesn't exist in core | |
*/ | |
function remove_post_terms( $post_id, $terms_to_remove, $taxonomy ) { | |
$terms_to_remove = array_map( 'intval', $terms_to_remove ); | |
array_filter( $terms_to_remove, function( $term ) { return ! empty( $term ); } ); | |
// Get the existing terms and only keep the ones we don't want removed |
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 | |
add_action( 'wp_enqueue_scripts', function() { | |
wp_register_style( 'parent-theme', get_template_directory_uri() . '/style.css' ); | |
wp_enqueue_style( 'child-theme', get_stylesheet_uri(), array( 'parent-theme' ) ); | |
} ); |
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 | |
add_action( 'generate_rewrite_rules', 'debug_action_generate_rewrite_rules', 1, 1 ); | |
// debug http://core.trac.wordpress.org/browser/trunk/wp-includes/rewrite.php#L1592 | |
// this should only be hit if the rewrite_rules option is empty. | |
// http://core.trac.wordpress.org/browser/trunk/wp-includes/rewrite.php#L1616 | |
function debug_action_generate_rewrite_rules( $rules ) { | |
global $debug_action_rules; | |
error_log( __FUNCTION__ . ' : ' . __LINE__ ); | |
error_log( var_export( $_SERVER, true ) ); | |
error_log( "Rules Option: " . var_export( get_option( 'rewrite_rules' ), true ) ); |
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 | |
add_filter( 'posts_where', 'x_kill_search_query', 10, 2 ); | |
function x_kill_search_query( $where, $query ) { | |
if ( ! is_admin() && $query->is_main_query() ) { | |
// this is a self-removing callback | |
remove_filter( current_filter(), __FUNCTION__, 10 ); | |
if ( $query->is_search() ) // only kill the main query | |
$where = ' AND 1=0 /* Query killed */'; |
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 | |
# See bigdawggi's comment below for a good combined example | |
// Pre-3.3 | |
function cf_google_search_kill_wp_search( $where, $query ) { | |
global $wp_the_query; | |
if( ! is_admin() && $query->is_search() && $query === $wp_the_query ) { | |
$where = ' AND 1=0'; |
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
#!/usr/bin/env bash | |
# args | |
MSG=${1-'deploy from git'} | |
BRANCH=${2-'trunk'} | |
# paths | |
SRC_DIR=$(git rev-parse --show-toplevel) | |
DIR_NAME=$(basename $SRC_DIR) | |
DEST_DIR=~/svn/$DIR_NAME/$BRANCH |
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
if(!jQuery('<input PLACEHOLDER="1" />')[0].placeholder){ //Uppercase attr for IE | |
jQuery(':input[placeholder]').each(function(){ | |
var $this = $(this); | |
if(!$this.val()){ | |
$this.val($this.attr('placeholder')); | |
$this.addClass('input-placeholder'); | |
} | |
}).live('focus', function(e){ | |
var $this = $(this); | |
if($this.hasClass('input-placeholder')){ |