Skip to content

Instantly share code, notes, and snippets.

View rachelbaker's full-sized avatar

Rachel Baker rachelbaker

View GitHub Profile
@rachelbaker
rachelbaker / wp-head-cleanup.php
Created January 30, 2012 21:39
Clean up the WordPress head section
<?php
/**
* Cleaning up the WordPress <head> section
*/
function rb_cleanupheaderlinks() {
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
}
@rachelbaker
rachelbaker / wp-custom-title-cpt-screen.php
Created February 7, 2012 03:48
WordPress Custom Title for Custom Post Type Screen
<?php
/**
* TODO: Replace cptname with name of custom post type
* TODO: Replace Screen Title Text Here with the content for the title box
*/
function custom_cptname_title( $title ){
$screen = get_current_screen();
if ( 'cptname' == $screen->post_type ) {
$title = 'Screen Title Text Here';
@rachelbaker
rachelbaker / genesis-all-posts-by-category-template.php
Created February 16, 2012 14:54
WordPress Genesis Theme Custom Archive Listing Template - All Posts by Category
<?php
/**
* Template Name: Custom Category Archive
*
*
*/
get_header(); ?>
<?php genesis_before_content_sidebar_wrap(); ?>
<div id="content-sidebar-wrap">
<?php genesis_before_content(); ?>
@rachelbaker
rachelbaker / wordpress-custom-excerpts.php
Created February 23, 2012 03:55
WordPress Custom Excerpt Filters
<?php
################################################################################
// Custom Excerpt Filters
################################################################################
function new_excerpt_more($more) {
global $post;
return '&nbsp;...&nbsp;<a href="'. get_permalink($post->ID) . '">Read more</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');
@rachelbaker
rachelbaker / wp-featuredimage-set.php
Created March 31, 2012 18:20
Automatically set WordPress Featured Image (Post Thumbnail) from Post Image
<?php
function rb_autoset_featured_img() {
global $post;
$already_has_thumb = has_post_thumbnail($post->ID);
if (!$already_has_thumb) {
$attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
if ($attached_image) {
foreach ($attached_image as $attachment_id => $attachment) {
set_post_thumbnail($post->ID, $attachment_id);
}
@rachelbaker
rachelbaker / wordpress-mobile-browser-check.php
Created April 8, 2012 17:55
WordPress Check for Mobile Browsers
<?php
// added to functions.php
// via http://www.dannyherran.com/2012/03/mobile-browser-detection-for-wordpress-embedded-is_mobile-function/
function is_mobile()
{
if(preg_match('/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine|htc|iemobile|iphone|ipad|ipaq|ipod|j2me|java|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|webos|wireless|xda|xoom|zte)/i', $_SERVER['HTTP_USER_AGENT']))
return true;
else
@rachelbaker
rachelbaker / .gitconfig
Created June 2, 2012 18:42
Gitconfig File
[user]
name = Rachel Baker
email = [email protected]
[core]
excludesfile = /Users/rachelbaker/.gitignore_global
autocrlf = input
quotepath = false
whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol
@rachelbaker
rachelbaker / .gitignore_global
Created June 2, 2012 18:44
Gitignore Global
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*._*
@rachelbaker
rachelbaker / jquery-height-detection.js
Created June 28, 2012 21:46
Detect browser window height and set element size to detected height with jQuery
jQuery(window).load(function() {
var bodyHeight = jQuery(window).height();
console.log('browser window height is ' +bodyHeight);
jQuery("section").css("height", bodyHeight); //resizing section element to be same height as window
});
@rachelbaker
rachelbaker / buddypress-theme-keep-active.php
Created July 6, 2012 20:36
Allow BuddyPress theme to be active even if BuddyPress plugin is not active
if ( ! function_exists( 'bp_is_active' ) ) {
return false;
}