Skip to content

Instantly share code, notes, and snippets.

@ramseyp
ramseyp / expire_posts
Created November 3, 2011 03:59
Set Posts older than 3 years from current date to draft status
<?php
/**
* Set Posts older than 3 years from current date to draft status
* @link https://gist.github.com/
* @param string
* @return string
*/
add_action( 'init', 's25_mass_expire' );
function s25_mass_expire(){
global $wpdb;
@ramseyp
ramseyp / gist:1336624
Created November 3, 2011 14:31
Change default settings for the Genesis Primary Sidebar
<?php
/**
* Change default settings for the Genesis Primary Sidebar
* @link https://gist.github.com/
* @param string
* @return string
*/
//Gets rid of the default Primary Sidebar
unregister_sidebar( 'sidebar' );
@ramseyp
ramseyp / gist:1337144
Created November 3, 2011 17:36
Modify User Profile to include an active checkbox
<?php
//Extra Author Profile Meta
add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
function my_show_extra_profile_fields( $user ) { ?>
<h3>Is this an active author?</h3>
<table class="form-table">
<tr>
<td>
@ramseyp
ramseyp / fluidimage.js
Created November 21, 2011 02:08
Part of the WP Fluid Images plugin. Replaces pixel-based width & height attributes with style attributes using percentages.
/**
* Name: fluidimage.js
*
* @author Pat Ramsey <[email protected]>
* @copyright Copyright (c) 2011, Pat Ramsey
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @description Part of the WP Fluid Images plugin. Replaces pixel-based width & height attributes with style attributes using percentages.
*
*/
@ramseyp
ramseyp / gist:1560867
Created January 4, 2012 16:41
Truncate WordPress post title
<?php
/**
* Truncate WordPress post title
* @author Pat Ramsey
* @link
*
* @param $title, $limit
*/
function s25_trunc_title( $limit ) {
@ramseyp
ramseyp / gist:1588929
Created January 10, 2012 12:53
List & remove WordPress roles left behind by plugins
<?php
$wp_roles = new WP_Roles();
$names = $wp_roles->get_names();
print_r($names);
$wp_roles->remove_role('name_of_role_to_be_removed');
?>
@ramseyp
ramseyp / text-grow-shrink.html
Created January 11, 2012 05:12
resize text based off container size
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dynamic text sizing</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- From @Beejamin - http://stackoverflow.com/users/79068/beejamin -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
@ramseyp
ramseyp / short_user_descr.php
Created January 12, 2012 17:31
shorten user descriptions - WordPress
<?php
// filter user description to return something shorter
add_filter ( 'pre_user_description', 's25_short_description' );
function s25_short_description($description) {
$max_characters = 50;
if ( strlen( $description ) > $max_characters ) {
$description = substr( $description, 0, $max_characters + 1 );
$description = trim( substr( $description, 0, strrpos( $description, ' ' ) ) );
}
@ramseyp
ramseyp / gform_unixdatetime.php
Created January 17, 2012 20:31
convert gravity form date and time inputs to unix datetime
<?php
/*
* Takes a gravity form's date field & converts it to unix date/time format by populating a hidden field
*
*/
add_action('gform_pre_submission','s25_format_combstartdate');
function s25_format_combstartdate($form){
//submission form uid is 1
if($form["id"] != 1)
@ramseyp
ramseyp / jwplayer_metabox.php
Created January 19, 2012 21:21
How do display JWPlayer shortcode from custom meta box
<?php
/*
* The JW Player plugin drops shortcode into the editor. It's not filtered through WordPress's do_shortcode().
* You need to use jwplayer_tag_callback().
*/
global $post;
if (get_post_meta($post->ID, '_cmb_mini_wysiwyg', true) ):
$myvid = get_post_meta($post->ID, '_cmb_mini_wysiwyg', true);
$myvid = jwplayer_tag_callback( $myvid );
echo $myvid;