Skip to content

Instantly share code, notes, and snippets.

View nickdaugherty's full-sized avatar

Nick Daugherty nickdaugherty

  • Automattic
  • Colorado, USA
View GitHub Profile
@nickdaugherty
nickdaugherty / authors-enforce-uploaded.js
Last active December 15, 2015 10:49
Forces only images uploaded to the post to be available for Featured Images
(function($){
if ( ! window.wp || ! wp.media ) {
return;
}
wp.media.view.AttachmentsBrowser = wp.media.view.AttachmentsBrowser.extend({
createUploader: function(){
this.$el.remove( '.uploader-inline' ).append( '<div class="uploader-inline"><h3>No Items Found.</h3></div>' );
}
});
@nickdaugherty
nickdaugherty / functions.php
Last active December 15, 2015 18:19
Redirect WordPress to homepage (via javascript) if page is 404
add_action( 'wp_head', 'mytheme_404_redirect' );
function mytheme_404_redirect() {
if ( ! is_404() )
return;
?>
<script>
window.location = '<?php echo esc_js( get_bloginfo( 'url' ) ); ?>';
</script>
@nickdaugherty
nickdaugherty / style.css
Created April 16, 2013 21:21
Increase width of sidebar to 250px
#sidebar {
width: 275px;
}
@nickdaugherty
nickdaugherty / style.css
Created April 16, 2013 21:29
Center ad regions
#1829408,
#418806848,
#418806728 {
text-align: center;
margin: 0 auto;
}
@nickdaugherty
nickdaugherty / vip-reverse-proxy-with-subdirectory.php
Last active March 30, 2018 22:53
Example code for running a VIP site behind a reverse proxy with a subdirectory. This assumes the proxy server can't rewrite the html, such as on CloudFront. Props to 10up / Dropbox for much of the code.
<?php
define( 'PROXY_URL', 'https://mysite.com/subdirectory' );
/**
* Map the mysite home page to the proxy subdirectory
*/
function mysite_map_home_page(){
add_rewrite_rule( '^'. get_mysite_proxy_subdirectory() .'/?$', 'index.php', 'top' );
add_rewrite_rule( '^'. get_mysite_proxy_subdirectory() .'/page/?([0-9]{1,})/?$', 'index.php?paged=$matches[1]', 'top' );