Skip to content

Instantly share code, notes, and snippets.

@JPry
JPry / template-hierarchy.php
Created November 13, 2012 17:39
Override template hierarchy
<?php
add_filter( 'template_include', 'jp_template_override' );
function jp_template_override( $template ) {
if ( is_page( 'home' ) ) {
$template = get_query_template( 'page' );
}
return $template;
}
?>
@JPry
JPry / rewrite.php
Created November 27, 2012 20:41
Search rewrite example
<?php
/**
* This class will add a custom query to the WordPress Rewrite rules.
*
* @author Jeremy Pry
*/
class JPry_Sample_Rewrite {
/**
* Constructor function. Adds the rewrite rule to the 'init' hook
@JPry
JPry / nginx.conf
Created November 29, 2012 18:50
Nginx - Force PDFs to download
location ~* /(.*\.pdf) {
types { application/octet-stream .pdf; }
default_type application/octet-stream;
}
@JPry
JPry / nginx.conf
Created December 3, 2012 23:10
Nginx - Allow user agent past bot checking and other rewrite rules
if ( $http_user_agent ~ "AppEngine-Google" ) {
break;
}
@JPry
JPry / nginx.conf
Created December 3, 2012 23:31
Nginx - Rewrite multisite files to single site files
rewrite "^/files/(.*)" "/wp-content/uploads/$1" permanent;
@JPry
JPry / .htaccess
Created December 3, 2012 23:36
Allow file type to bypass Nginx handling and use Apache
# Change the default
<FilesMatch "\.(?i:pdf)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>
@JPry
JPry / nginx.conf
Created December 3, 2012 23:42
Nginx - change mime type for certain file type (pdf)
location ~* /(.*\.pdf) {
types { application/octet-stream .pdf; }
default_type application/octet-stream;
}
@JPry
JPry / nginx.conf
Created December 3, 2012 23:53
Nginx - Rewrite based on query args
if ( $args ~ idFoto ) {
rewrite mypoint/foto\.aspx$ /wp-content/uploads/legado/mypoint/$arg_idFoto.jpg? permanent;
}
@JPry
JPry / find.sh
Created December 5, 2012 23:55
Find file by name
find . -name 'filename.txt'
@JPry
JPry / curl.sh
Created December 21, 2012 01:19
Use CURL to request a domain name/path from a specific IP address. Substitute the domain for "example.com", and the IP address and path in the URL.
curl -H "Host: example.com" -I http://IP.ADD.RE.SS/path/to/file/or/folder/