Skip to content

Instantly share code, notes, and snippets.

Pat Ramsey ramseyp

Block or report user

Report or block ramseyp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ramseyp
ramseyp / expire_posts
Created Nov 3, 2011
Set Posts older than 3 years from current date to draft status
View expire_posts
<?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 Nov 3, 2011
Change default settings for the Genesis Primary Sidebar
View gist:1336624
<?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 Nov 3, 2011
Modify User Profile to include an active checkbox
View gist:1337144
<?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 Nov 21, 2011
Part of the WP Fluid Images plugin. Replaces pixel-based width & height attributes with style attributes using percentages.
View fluidimage.js
/**
* Name: fluidimage.js
*
* @author Pat Ramsey <pat@slash25.com>
* @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 Jan 4, 2012
Truncate WordPress post title
View gist:1560867
<?php
/**
* Truncate WordPress post title
* @author Pat Ramsey
* @link
*
* @param $title, $limit
*/
function s25_trunc_title( $limit ) {
@ramseyp
ramseyp / gist:1588929
Created Jan 10, 2012
List & remove WordPress roles left behind by plugins
View gist:1588929
<?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 Jan 11, 2012
resize text based off container size
View text-grow-shrink.html
<!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 Jan 12, 2012
shorten user descriptions - WordPress
View short_user_descr.php
<?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 Jan 17, 2012
convert gravity form date and time inputs to unix datetime
View gform_unixdatetime.php
<?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 Jan 19, 2012
How do display JWPlayer shortcode from custom meta box
View jwplayer_metabox.php
<?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;
You can’t perform that action at this time.