Skip to content

Instantly share code, notes, and snippets.

View johnbocook's full-sized avatar
💯
I come here for the dark theme.

John Bocook johnbocook

💯
I come here for the dark theme.
View GitHub Profile
@johnbocook
johnbocook / drupal_mail.php
Last active November 5, 2015 14:03
Use drupal_mail to send an email
<?php
/**
* Implements hook_menu()
* Call a custom form as menu callback
* @return
* $items array of menu items created programmatically
*/
function test_menu() {
$items['test'] = array(
@johnbocook
johnbocook / BrownPaperTicketsDonationHide.js
Last active November 5, 2015 14:06
Placed in the Brown Paper Ticket events custom header section to hide the donation text on the checkout page.
$(document).ready(function(){
var url = window.location.href;
if (url.search("checkout.html") >= 0) {
$('td:contains("A portion of Brown Paper Tickets profits"):last').hide();
$('td:contains("This sale should benefit "):last').parent().hide();
}
});
@johnbocook
johnbocook / AutoFocusInput.js
Last active November 5, 2015 14:14
You can place a user's cursor inside an input via focus as soon as the page is loaded. This helps ensure that visitors do not 'overlook' an important form item on your site.
//Change coolFormName to form's name.
<body onload="document.coolFormName.user.focus();">
<form name="coolFormName">
Name: <input type=text name=user size=10>
</form>
@johnbocook
johnbocook / GoBackButton.js
Last active November 5, 2015 14:16
Sends visitor back one page in their browser history.
//Improper - Does not always work on chrome
<a href="www.mypage.com" onclick="history.go(-1)"> Back </a>
//Proper
<a href="www.mypage.com" onclick="window.history.go(-1); return false;"> Back </a>
@johnbocook
johnbocook / YearlyAbortionCounter.js
Last active November 5, 2015 14:26
Yearly Abortion counter updated by seconds.
<html>
<head>
<link type="text/css" rel="stylesheet" href="stylesheet.css" media="all">
</head>
<body>
<div id="abCounter">
<p id="title">Yearly Abortion Counter</p>
<p id="aborts">Loading ...</p>
</div>
@johnbocook
johnbocook / UnbounceDynamicDegrees.js
Last active November 5, 2015 18:45
If AGS page, Auto-selects Bachelor Degree and hides/shows programs based on degree_interest selection. Built for unbounce landing pages.
<script type="text/javascript">
lp.jQuery(function($) {
//If not a trad page, run code
if (!(window.location.href.indexOf("trad") > -1 || window.location.href.indexOf("music") > -1)) {
$('#container_degree_interest option[value="Bachelors Degree"]').attr("selected", "selected");
$("#program option:not(:contains('Bachelor of'))").hide();
// Hide/Show program options based on degree selection
@johnbocook
johnbocook / playSound.js
Created November 12, 2015 20:51
$.playSound('http://example.org/sound'); File name must be set without the file extension and should in .mp3 and .ogg format
// Usage: $.playSound('http://example.org/sound.mp3');
(function($){
$.extend({
playSound: function(){
return $("<embed src='"+arguments[0]+".mp3' hidden='true' autostart='true' loop='false' class='playSound'>" + "<audio autoplay='autoplay' style='display:none;' controls='controls'><source src='"+arguments[0]+".mp3' /><source src='"+arguments[0]+".ogg' /></audio>").appendTo('body');
}
});
<?php
function add_embed_tweet_meta_box() {
add_meta_box(
'paulund_embed_tweet_meta_box', // $id
'Post Embed Tweets Meta Box', // $title
'show_embed_tweet_meta_box', // $callback
'post', // $page
'normal', // $context
'high'); // $priority
}
@johnbocook
johnbocook / author_slug_to_profile.php
Created September 28, 2013 05:16
Changes WordPress author slug from author to profile.
add_action('init', 'cng_author_base');
function cng_author_base() {
global $wp_rewrite;
$author_slug = 'profile'; // change slug name
$wp_rewrite->author_base = $author_slug;
}
@johnbocook
johnbocook / wp-config-define.php
Created September 28, 2013 05:20
Define wordpress home and site url.
define('WP_HOME','http://domain.com/wordpress');
define('WP_SITEURL','http://domain.com/wordpress');