Skip to content

Instantly share code, notes, and snippets.

View cassler's full-sized avatar

Darin Cassler cassler

View GitHub Profile
@cassler
cassler / gradiant-mixin.scss
Created January 19, 2012 10:05
SASS gradiant @mixin
// this mixin can be used in any sass template to easily deploy
// consistent gradients quickly. Just change the values of $start
// and $end to the colors you want your gradient to travel between.
// You can pass different colors when calling the mixin like this:
// > @include grad(#279333,#192566)
// Better still you can define color variables and do it like this
// > $yellow = #f30;
@cassler
cassler / php-fastcgi
Created March 28, 2012 02:15
php-fastcgi init.d
#!/bin/bash
### BEGIN INIT INFO
# Provides: php-fastcgi
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the php-fastcgi web server
# Description: starts php-fastcgi using start-stop-daemon
@cassler
cassler / sidebar-selector.php
Last active December 23, 2015 01:49
Wordpress > Dynamic sidebar generator and selector UI.
<?php
## Replace Array of Sidebars with Your Choice of Names, Each will be generated
$dynamic_widget_areas = array(
/* rename or create new dynamic sidebars */
"Sidebar 01",
"Sidebar 02",
"Sidebar 03",
"Sidebar 04",
"Sidebar 05",
"Sidebar 06",
@cassler
cassler / gist:8857177
Created February 7, 2014 03:56
wp-get-meta-keys
/**
* Get all meta keys for given object.
*
* Finds all custom meta keys for a given post and extracts them to an array for easy access.
* @example $meta = den_get_meta;
* @example echo ($meta['my-key'] ? $meta['my-key'] : null );
* @return array of meta keys for post
* @author Darin Cassler
* @package den_framework
* @subpackage den_custom_hooks
@cassler
cassler / function-breadcrumbs.php
Created February 7, 2014 03:57
Super Easy Wordpress Breadcrumbs
/**
* Super Easy Breadcrumbs
*
* Creates an unordered list for ancestor links.
*
* @example <?php easy_breadcrumbs(); ?>
* @author Scott Nelle
* @package den_framework
* @subpackage den_custom_hooks
**/
@cassler
cassler / widget-enhanced-recent-posts.php
Created February 7, 2014 03:59
More powerful recent posts widget
<?php
class Widget_Recent_Posts_Xtra extends WP_Widget {
// name this widget.
// naming this widget allows us to use filters for unique widget areas.
var $namespace = "xtra-recent-posts-widget";
function __construct() {
$widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "The most recent posts on your site") );
parent::__construct('recent-posts', __('Custom Recent Posts'), $widget_ops);
@cassler
cassler / hook-page-title.php
Created February 7, 2014 04:07
Show the proper H1 based on context
<?php function den_page_title() {
$post = $posts[0]; // Hack. Set $post so that the_date() works.
/* If this is a category archive */
if (is_category()) {
echo '<h1>Archive for the &#8216;' . single_cat_title() . '&#8217; Category</h1>';
} elseif( is_tag() ) { // If is tag archive
echo '<h1>Posts Tagged &#8216;' . single_tag_title(); . '&#8217;</h1>';
/* If this is a daily archive */
} elseif (is_day()) {
@cassler
cassler / den_event_date.php
Created February 7, 2014 04:14
Assumes your post has a stored date meta-key called 'event-date'. This template tag will render the human readable date. If the meta-key matches the current date, it will instead return 'Today'
<?php
/**
* Return human version of zulu time
*
* Assumes your post has a stored date meta-key called 'event-date'. This template tag will render the human
* readable date. If the meta-key matches the current date, it will instead return 'Today'
*
* @package den_framework
* @subpackage den_calendar
@cassler
cassler / bootstrap-walker.php
Created February 7, 2014 04:15
Bootstrap Wordpress Nav Walker, changes markup on your menus to use bootstrap formatting
<?php class responsive_menu_walker extends Walker_Nav_Menu
{
function start_lvl(&$output, $depth) {
// update the <li> element
$bookmark = 'den-menu-top';
$li_pos = strrpos ( $output, $bookmark );
$output = substr($output, 0, $li_pos+strlen($bookmark)) . " dropdown" . substr($output, $li_pos+strlen($bookmark), strlen($output) - $li_pos);
// update the <a> element
$bookmark = "<a ";
@cassler
cassler / event-sorter.php
Created February 7, 2014 04:17
Automatically sort custom post type 'event' by meta-key 'event-date' and only display posts in the future.
<?php function order_events_by_date($request){
$dummy_query = new WP_Query();
$dummy_query->parse_query( $request );
if($dummy_query->is_singular()):
return $request;
elseif(isset($request['post_type']) && $request['post_type'] == 'event'):
if(!is_admin()):
$request['orderby'] = 'meta_value menu_order title';
$request['meta_key'] = 'event-date';
$request['order'] = 'ASC';