Skip to content

Instantly share code, notes, and snippets.

View sunnyratilal's full-sized avatar

Sunny Ratilal sunnyratilal

View GitHub Profile
@sunnyratilal
sunnyratilal / 0_reuse_code.js
Created May 31, 2014 16:42
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@sunnyratilal
sunnyratilal / gist:5896912
Created June 30, 2013 21:11
Force Download MP3 and PDF files
<FilesMatch "\.(?i:mp3|pdf)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>
function custom_edd_add_custom_field_support( $supports ) {
$new = array( 'custom-fields' );
return array_merge( $new, $supports );
}
add_filter( 'edd_download_supports', 'custom_edd_add_custom_field_support' );
@sunnyratilal
sunnyratilal / pubsub.js
Created May 31, 2013 04:57 — forked from JeffreyWay/pubsub.js
jQuery PubSub in three lines. This will work in IE9+, so it's a perfect choice for jQuery 2.0 projects.
var o = $({});
$.subscribe = o.on.bind(o);
$.publish = o.trigger.bind(o);
# Replace [username] with your GitHub username.
# Replace [project]/[repository] with the project and repository where the issue resides.
# Replace [base] with the destination branch you wish to PR to (usually master or develop)
# And obviously, don't leave the [] brackets in there.
# Usage:
# @git-pr 999 features/999
<?php
class CWS_Jetpack_Modules {
function __construct() {
add_filter( 'option_jetpack_active_modules', array( $this, 'active_modules' ) );
}
function active_modules( $modules ) {
$allowed_modules = array(
'enhanced-distribution',
@sunnyratilal
sunnyratilal / gist:5652630
Last active December 17, 2015 18:19
WordPress Multisite htaccess Rules
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
@sunnyratilal
sunnyratilal / gist:5650656
Created May 25, 2013 20:23
Super quick WordPress testing
#!/bin/bash
function mu { subl ~/wp.git/wp-content/mu-plugins/custom.php }
<?php
/*
Plugin Name: Soliloquy Demo
Plugin URI: http://soliloquywp.com/
Description: Creates demo user and manages roles so Soliloquy can have a live demo.
Author: Thomas Griffin
Author URI: http://thomasgriffinmedia.com/
Version: 1.0.0
License: GNU General Public License v2.0 or later
License URI: http://www.opensource.org/licenses/gpl-license.php
<?php
/**
* Database emtpying and file removing class.
*
* Truncates all necessary tables in the defined database and removes
* any files uploaded by the demo user.
*
* @since 1.0.0
*
* @author Thomas Griffin