Skip to content

Instantly share code, notes, and snippets.

View jacobdubail's full-sized avatar

Jacob Dubail jacobdubail

View GitHub Profile
@ryanflorence
ryanflorence / pubsub.js
Created October 14, 2011 22:47
Simple Pub/Sub
!function () {
var channels = {};
this.subscribe = function (channel, subscription) {
if (!channels[channel]) channels[channel] = [];
channels[channel].push(subscription);
};
this.publish = function (channel) {
if (!channels[channel]) return;
@corsonr
corsonr / RCP auto redirection
Created October 9, 2012 07:55
Restrict Content Pro - automatic redirection
// redirection if user is logged in
function rcp_redirect_if_user_is_logged() {
if (is_plugin_active('restrict-content-pro/restrict-content-pro.php')) {
if( is_user_logged_in() ) {
wp_redirect( home_url() ); // replace home_url() by whatever url/page you want
exit;
}
}
}
add_action( 'rcp_after_login_form', 'rcp_redirect_if_user_is_logged' );
if( tribe_is_month() && !is_tax() ) { // The Main Calendar Page
} elseif( tribe_is_month() && is_tax() ) { // Calendar Category Pages
} elseif( tribe_is_event() && !tribe_is_day() && !is_single() ) { // The Main Events List
} elseif( tribe_is_event() && is_single() ) { // Single Events
} elseif( tribe_is_day() ) { // Single Event Days
@jmcd
jmcd / multiSelectToCheckboxes.js
Created April 2, 2012 15:52
jQuery plugin to convert multi-select HTML to checkbox list
(function($) {
var methods = {
init: function() {
var $ul = $("<ul/>").insertAfter(this);
var baseId = "_" + $(this).attr("id");
$(this).children("option").each(function(index) {
var $option = $(this);
var id = baseId + index;
var $li = $("<li/>").appendTo($ul);
@ericakfranz
ericakfranz / om-unload-jquery.js
Created November 18, 2015 18:58
OptinMonster loads jQuery v1.11.3 by default, use this to remove this function. Useful if the site is already loading a different version of jQuery and the page source is outputting multiple copies. One version for WP users, the other as plain JS.
<script type="text/javascript">
var om_load_jquery = false;
</script>
@jchristopher
jchristopher / gist:6798262
Created October 2, 2013 18:25
SearchWP snippet to limit results to the current category page being viewed
<?php
function mySearchIncludeIds( $ids, $engine, $terms )
{
// if we're viewing a category page and the SearchWP engine is the default engine
if( is_category() && $engine == 'default' ) {
$termID = get_queried_object_id(); // determine which category we're viewing
// get the IDs of all the posts in this category
@rosshanney
rosshanney / gce-parser.php
Created November 16, 2012 21:54
Modified version of gce-parser.php that groups events within each day by feed, then by start time
<?php
class GCE_Parser {
private $feeds = array();
private $merged_feed_data = array();
private $errors = array();
private $title = null;
private $max_events_display = 0;
private $start_of_week = 0;
private $sort_order = 'asc';
@davatron5000
davatron5000 / blur-validate.js
Created May 28, 2015 19:34
HTML5 Validation on blur()
var inputs = document.querySelectorAll('input, textarea');
for(var i=0;i<inputs.length;i++) {
inputs[i].addEventListener('blur', function(){
if(!this.checkValidity()) {
this.classList.add('has-error');
} else {
this.classList.remove('has-error');
}
});
}
@mcrider
mcrider / Gulpfile.js
Created May 21, 2015 19:40
Gulpfile for Apostrophe CMS -- Enables BrowserSync for live reloading (+ more) and compiles Sass into the main stylesheet
var gulp = require('gulp');
var nodemon = require('gulp-nodemon');
var jshint = require('gulp-jshint');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var notifier = require('node-notifier');
var uglify = require('gulp-uglify');
var sequence = require('run-sequence');
var util = require('gulp-util');