Skip to content

Instantly share code, notes, and snippets.

@nerrad
nerrad / modify_series_post_links_by_context.php
Created February 25, 2012 22:11
Organize Series and organize-series-multiples: allowing for post links for posts that belong to multiple series to have a context saved when clicked from series archive page. This doesn't work as is - gonna move to the main file and fix.
<?php
add_filter('init', 'modify_series_link_context');
function modify_series_link_context() {
add_filter('post_link', 'multi_series_link_mod', 10, 3);
add_filter('get_the_series', 'multi_series_get_mod');
}
function multi_series_link_mod($permalink, $post, $leavename) {
//is the displayed page a series archive page? If so, then let's make sure we append a request variable to the post links for this series.
@nerrad
nerrad / orgseries-custom-nav.php
Created August 27, 2012 13:35
custom navigation for organize series (pagination by series part) this can be added to the themes functions.php file
add_action( 'the_content', 'os_custom_series_nav_filter' );
function os_custom_series_nav_filter($content) {
global $post;
if ( is_single() ) {
$series = get_the_series();
if ( !empty($series) ) {
$cur_id = $post->ID;
$posts_in_series = array();
$result = '';
@nerrad
nerrad / categorycptrewrite.php
Created October 28, 2012 17:52
Have category archive pages display only posts in a certain custom post type
/**
* This could be extrapolated and used for tags or any other taxonomy really.
*/
add_action('init', 'category_cpt_rewrites');
function category_cpt_rewrites() {
$custom_post_types = array('video', 'audio', 'photo', 'file'); //some example post types
foreach ( $custom_post_types as $post_type ) {
$rule = '^' . $post_type . '/category/(.+?)/?$';
@nerrad
nerrad / fix-bbpress-roles-in-s2member.php
Created November 20, 2012 19:37
Fix for s2member and bbPress 2.2 plus new roles
<?php
/*
Plugin Name: Fix bbPress roles for s2member
Plugin URI: http://roughsmootheng.in
Version: 1.0
Description: This plugin adds s2member roles to the user_role_map for bbPress.
Author: Darren Ethier
Author URI: http://www.roughsmootheng.in
*/
@nerrad
nerrad / show_browser_message.php
Last active December 14, 2015 12:09
#Detect browser message (WP based sites) This is a function I created for Event Espresso to detect older versions of browsers being used to view the site and displaying a message when out of date (according to our requirements). It uses the `wp_check_browser_version()` function WordPress makes available. I've also added some things to not includ…
<?php
/**
* This function just checks the incoming browser and will display a message if it's out of date. We save transients for the user-agents so we don't need to ping the WordPress api on every request.
*
* @return string html formatted message for user
*/
function show_browser_message() {
//let's include the file that will has the wp function we need.
require_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
// Must be in an external file or loaded at the end of wp_footer()
jQuery(document).ajaxSend(function(e, x, a) {
var awesome = 1;
a.data += '&' + jQuery.param( {is_awesome: awesome} );
});
@nerrad
nerrad / 0_reuse_code.js
Created January 27, 2014 20:58
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@nerrad
nerrad / javascript_resources.md
Created January 27, 2014 20:58 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@nerrad
nerrad / css_resources.md
Created January 27, 2014 20:58 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@nerrad
nerrad / hipchatcurl.pl
Created February 5, 2014 14:49
Curl string for pinging HipChat server. Event Espresso (one of my clients) is trying out the hipchat.com service and they have a really cool api for sending notifications/messages to the chat rooms. So I wired up our git deploy repo on our server to notify the chatrooms whenever we deploy. Here's the one liner script I added.
curl --data "room_id=99999" --data "from=EEWebsiteBot" --data-urlencode "message=Event Espresso staging servers (beta and dev) have been deployed to" --data "message_format=text" --data "notify=1" --data "color=purple" https://api.hipchat.com/v1/rooms/message?auth_token=obsfucated_api_token
##So the room_id corresponds to what room you want the notifications go to and the auth token is the api key you generate via the group admin in HipChat (web).