Skip to content

Instantly share code, notes, and snippets.

@jaredatch
jaredatch / gist:1608960
Created January 13, 2012 22:06
Menu icons for custom post types
<?php
add_action( 'admin_head', 'ja_custom_cpt_icons' );
function ja_custom_cpt_icons() { ?>
<style type="text/css" media="screen">
#menu-posts-portfolio .wp-menu-image {
background: url(<?php echo plugin_dir_url( __FILE__ ); ?>images/portfolio-icon.png) no-repeat 6px 6px !important;
}
#menu-posts-portfolio:hover .wp-menu-image, #menu-posts-portfolio.wp-has-current-submenu .wp-menu-image {
background-position:6px -16px !important;
}
@jaredatch
jaredatch / gist:1609175
Created January 13, 2012 22:43
Excel macro to add quotes to around cells
Sub makequotes()
mc = "a"
For i = 2 To Cells(Rows.Count, mc).End(xlUp).Row
If Cells(i, mc) <> "" And Left(Cells(i, mc), 1) <> """" Then
Cells(i, mc).Value = """" & Cells(i, mc) & """"
End If
Next i
End Sub
@jaredatch
jaredatch / gist:1629862
Created January 17, 2012 23:54
Remove hentry from post_class()
<?php
/**
* Remove 'hentry' from post_class()
*/
function ja_remove_hentry( $class ) {
$class = array_diff( $class, array( 'hentry' ) );
return $class;
}
add_filter( 'post_class', 'ja_remove_hentry' );
@jaredatch
jaredatch / gist:1687328
Created January 27, 2012 06:15
Revert Techmeme.com to look closer to the previous design
/* User stylesheet for Techmeme.com */
body {
font-family: "Helvetica Neue", Helvetica, arial;
background: #bbbbcc;
}
cite,
.drhed,
h2,
@jaredatch
jaredatch / gist:1850289
Created February 17, 2012 03:21
Move Featured Image Metabox
<?php
add_action('do_meta_boxes', 'be_rotator_image_metabox' );
/**
* Move Featured Image Metabox on 'rotator' post type
* @author Bill Erickson
* @link http://www.billerickson.net/code/move-featured-image-metabox
*/
function be_rotator_image_metabox() {
remove_meta_box( 'postimagediv', 'rotator', 'side' );
add_meta_box('postimagediv', __('Custom Image'), 'post_thumbnail_meta_box', 'rotator', 'normal', 'high');
@jaredatch
jaredatch / gist:2247508
Created March 30, 2012 06:20
bbPress TinyMCE Media Upload
<?php
/*
Plugin Name: bbPress TinyMCE Media Upload
Plugin URI: http://wordpress.org/extend/plugins/bbpress-tinymce-media-upload-for-administrators/
Description: Enables the Media Upload button on the front-end TinyMCE editor for admin users.
Version: 1.0
Author: Jared Atchison
Author URI: http://jaredatchison.com
*/
<?php
/*
Plugin Name: bbPress New Topic Notifications
Plugin URI: http://wordpress.org/extend/bbpress-new-topic-notifications
Description: Send notification emails to specific users when a new bbPress topic or reply is posted.
Version: 1.2
Author: jaredatch
Author URI: http://jaredatchison.com
Much of this plugin was adapted fron Notifly!
<?php
/**
* Tweak the query
*/
function ja_query_tweaks( $query ) {
if( $query->is_post_type_archive( 'program-partners' ) ) {
$query->query_vars['orderby'] = 'title';
$query->query_vars['order'] = 'ASC'; // Can be ASC or DESC
// $query->query_vars['posts_per_page'] = -1; uncomment to show ALL on first page
return;
@jaredatch
jaredatch / global.js
Created June 29, 2012 03:38
Mobile Genesis menus
jQuery(document).ready(function($){
// Mobile navigation
$('#prim-selector, #sec-selector').change(function(){
if ($(this).val()!='') {
window.location.href=$(this).val();
}
});
});
@jaredatch
jaredatch / gist:3376641
Created August 17, 2012 07:06
try to detect if is mobile
<?php
/**
* Check useragent string for mobile device
*
* @return boolean if mobile device is detected
*/
function ja_is_mobile() {
$useragent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
if ( preg_match( '/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine|htc|iemobile|iphone|ipad|ipaq|ipod|j2me|java|lg|midp|mini|mmp|mobi|motorola|nec-|nokia|palm|panasonic|philips|phone|sagem|sharp|sie-|smartphone|sony|symbian|t-mobile|telus|up\.browser|up\.link|vodafone|wap|wm5|webos|wireless|xda|xoom|zte)/i', $useragent ) ) {
return true;