Skip to content

Instantly share code, notes, and snippets.

View sunnyratilal's full-sized avatar

Sunny Ratilal sunnyratilal

View GitHub Profile
// Checks to see if jQuery is loaded and if it is a high enough version; if not, jQuery is loaded.
this.loadjQuery = function(){
// Store localized copy of our main object instance.
var self = this;
// If jQuery is not present or not the correct version, load it asynchronously and fire the rest of the app once jQuery has loaded.
if ( window.jQuery === undefined || window.jQuery.fn.jquery !== '1.9.1' ) {
var om = document.createElement('script');
om.src = '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js';
om.onload = om.onreadystatechange = function(){
// Checks to see if jQuery is loaded and if it is a high enough version; if not, jQuery is loaded.
this.loadjQuery = function(){
// Store localized copy of our main object instance.
var self = this;
// If jQuery is not present or not the correct version, load it asynchronously and fire the rest of the app once jQuery has loaded.
if ( window.jQuery === undefined || window.jQuery.fn.jquery !== '1.9.1' ) {
var om = document.createElement('script');
om.src = '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js';
om.onload = om.onreadystatechange = function(){
@sunnyratilal
sunnyratilal / gist:5650341
Created May 25, 2013 19:03 — forked from thomasgriffin/gist:4953041
Rendering custom attachment fields in the new media manager via Backbone.
/**
* The code below renders additional custom attachment fields into the
* new media manager.
*
* I am assuming you are using your own custom media modal frame. By
* extending the default Attachment.Details subview, we can append our
* custom fields to the default fields listed.
*
* In the initialize function, we ensure that our changes are always up
* to date by "listening" to our model's change event and updating the
// Use the new media manager to handle uploads to Soliloquy.
$('#soliloquy-area').on('click.soliloquyUpload', '#soliloquy-upload', function(e){
// Prevent the default action from occuring.
e.preventDefault();
// Variable to hold our media applicaton.
var soliloquy_frame;
// If the media frame already exists, reopen it and return.
if ( soliloquy_frame ) {
// Open up the media manager to handle editing image metadata.
$('#soliloquy-area').on('click.soliloquyModify', '.modify-image', function(e) {
e.preventDefault();
var soliloquy_frames = {}; // Store our workflows in an object
var frame_id = $(this).next().attr('id').split('-')[3]; // Unique ID for each workflow
var default_view = wp.media.view.AttachmentsBrowser; // Store the default view to restore it later
// If the media frame already exists, reopen it.
if ( soliloquy_frames[frame_id] ) {
soliloquy_frames[frame_id].open();
<?php
/**
* Filters the image quality for thumbnails to be at the highest ratio possible.
*
* Supports the new 'wp_editor_set_quality' filter added in WP 3.5.
*
* @since 1.0.0
*
* @param int $quality The default quality (90)
* @return int $quality Amended quality (100)
<?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
<?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
@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 }
@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]