Skip to content

Instantly share code, notes, and snippets.

View Japh's full-sized avatar

Japh Japh

View GitHub Profile
/**
* This gist demonstrates how to properly load jQuery within the context of WordPress-targeted JavaScript so that you don't
* have to worry about using things such as `noConflict` or creating your own reference to the jQuery function.
*
* @version 1.0
*/
(function( $ ) {
"use strict";
$(function() {
<?php
/*
Plugin Name: Simplecart for WordPress
Plugin URI: http://wp.tutsplus.com/articles/how-to-include-javascript-and-css-in-your-wordpress-themes-and-plugins/#comment-827004468
Description: A very simple plugin to load SimpleCart in WordPress
Version: 1.0
Author: Japh
Author URI: http://wp.tutsplus.com/author/Japh
License: GPL2
*/
<?php
/**
* Allows activation of plugins via WP Bulter using the "activate" keyword (ie "activate Gravity Forms")
*
*/
add_filter('wp_butler_ajax_keyword_actions', 'wp_butler_switch_plugins_action');
function wp_butler_switch_plugins_action($term_and_actions) {
list($term, $actions) = $term_and_actions;
@Japh
Japh / gist:4564616
Created January 18, 2013 13:45 — forked from spivurno/gist:4560722
<?php
add_filter('wp_butler_ajax_keyword_actions', 'wp_butler_switch_plugins_action', 10, 2);
function wp_butler_switch_plugins_action($term_and_actions) {
list($term, $actions) = $term_and_actions;
$term_words = explode( ' ', $_REQUEST['term'] );
$keyword = $term_words[0];
@Japh
Japh / gist:3747095
Created September 19, 2012 01:27
ImageMagick Test for WP_Image_Editor_Imagemagick
protected function find_exec() {
exec( "type convert", $type, $type_rcode );
if ( ! $type_rcode ) {
$convert_type = explode( ' ', $type[0] );
$this->convert_bin = $convert_type[0];
} else {
exec( "locate " . escapeshellarg( "*/convert" ), $locate, $locate_rcode );
foreach ( $locate as $binary ) {
@Japh
Japh / bad-loop.php
Created September 3, 2012 00:33 — forked from pippinsplugins/gist:3548646
An example of how NOT to write your WordPress theme's Loop
<?php
#
# rt-theme loop
#
global $args,$content_width,$paged;
add_filter('excerpt_more', 'no_excerpt_more');
//varialbles
$video_width = ($content_width =="960") ? 940 : 606;
@Japh
Japh / circle.js
Created January 9, 2012 06:18 — forked from ryan-allen/circle.js
var Circle = function(radius) {
var calculateDiameter = function() {
return radius * 2
}
// here's a new 'circle'
return {
radius: radius,
calculateDiameter: calculateDiameter
}
@Japh
Japh / timeago.js
Created December 20, 2011 06:54
Javascript snippet for plain english relative time (e.g. "X seconds ago")
function time_ago(time) {
periods = new Array("second", "minute", "hour", "day", "week", "month", "year", "decade");
lengths = new Array("60","60","24","7","4.35","12","10");
nowdate = new Date();
now = (nowdate.getTime() / 1000);
difference = now - time;
tense = "ago";