Skip to content

Instantly share code, notes, and snippets.

@viankakrisna
viankakrisna / jQuery Dump
Last active January 12, 2016 12:02
This is a jQuery plugin for dumping variable to a JSON string.
(function ($) {
$.fn.dump = function (variable) {
this.html($('<pre></pre>')
.text(JSON.stringify(variable, null, 4)));
return this;
};
})(jQuery);
//How to use:
/*
@charset "UTF-8";
@import "https://fonts.googleapis.com/css?family=Oswald";
* {
animation: fadeIn 1s;
}
a {
transition: 250ms;
}
@viankakrisna
viankakrisna / mobiledesktop.js
Last active May 26, 2017 18:59
Mobile and Desktop Responsive Layout Handler
var mobileManager = function (mobile, desktop, breakpoint) {
//Defaults to 767, not much desktop running below that right now isn't it?
var _breakpoint = breakpoint || 767;
//Defaults to function, we need to invoke this later
var _desktop = desktop || function () {};
var _mobile = mobile || function () {};
//Counter to see where we are right now
@viankakrisna
viankakrisna / ml_restrict_media_library.php
Created November 17, 2015 09:36
Restrict non admin to only show image that they upload
add_action( 'pre_get_posts', 'ml_restrict_media_library' );
function ml_restrict_media_library( $wp_query_obj ) {
global $current_user, $pagenow;
if (!in_array( 'administrator', $current_user->roles )){
if( !is_a( $current_user, 'WP_User') )
return;
if( 'admin-ajax.php' != $pagenow || $_REQUEST['action'] != 'query-attachments' )
function add_countries(){
$country_array = array(
"afg" => "Afghanistan",
"alb" => "Albania",
"dza" => "Algeria",
"and" => "Andorra",
"ago" => "Angola",
"atg" => "Antigua and Barbuda",
"arg" => "Argentina",
"arm" => "Armenia",
var getWPJRA = function( baseUrl, child , callback){
if (baseUrl !== undefined ){
switch( child ) {
case undefined:
return jQuery.getJSON( '/' + baseUrl + "/wp-json" , callback);
break;
default:
return jQuery.getJSON( '/' + baseUrl + "/wp-json/" + child, callback);
}
} else if (baseUrl === undefined || baseUrl.length == 0) {