Skip to content

Instantly share code, notes, and snippets.

View coreyweb's full-sized avatar

corey brown coreyweb

View GitHub Profile
@coreyweb
coreyweb / gist:1436214
Created December 6, 2011 01:10
DIY Template - Proposed
<?php get_header(); ?>
<?php get_template_part( 'layouts/head', 'single' ); ?>
<?php get_template_part( 'content/article-header', 'single' ); ?>
<?php get_template_part( 'content/article-content', 'single' ); ?>
<?php get_template_part( 'content/article-footer', 'single' ); ?>
<?php get_sidebar(); ?>
<?php get_template_part( 'layouts/foot', 'single' ); ?>
<?php get_footer(); ?>
@coreyweb
coreyweb / gist:1917503
Created February 26, 2012 16:30
Better thumbnail approach CSS
<!-- demo: http://sandbox.squidplex.com/new/bootstrap/media.html -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Better Thumbnail Layouts</title>
@coreyweb
coreyweb / gist:1978504
Created March 5, 2012 14:21
Display Custom Data in WordPress Layouts
<?php // Code awesomeness by Aaron Collegeman : https://github.com/collegeman ?>
<?php if ($foo = get_post_meta($post->ID, 'foo', true)) { ?>
<?php echo "<strong>{$foo}</strong>" ?>
<?php } ?>
@coreyweb
coreyweb / youtube-shortcode.php
Created March 6, 2012 00:45
Youtube shortcode for WordPress
/**
* Youtube Shortcode Solution
*
* Set your desired width for all the videos on your site (below)
* Paste any Youtube video link in the shortcode, using this format, i.e.:
* [youtube value="http://www.youtube.com/watch?feature=player_embedded&v=GGT8ZCTBoBA"]
* This code will automatically resize your video to the appropriate size and aspect ratio.
* Modify the width value (set to 590 here), and the iframe code below to your desired settings.
* This requires coreylib (coreylib.com)
* Shortcode by coreyweb: https://github.com/coreyweb
@coreyweb
coreyweb / gist:1983601
Created March 6, 2012 04:42
Retrieve screenshot of any page on the web
<?php
$snap = 'http://s.wordpress.com/mshots/v1/';
$url = 'http://www.squidoo.com';
$alt = 'alt value';
$width = '400';
$height = '300';
?>
<img src="<?php echo $snap . urlencode($url) ?>?w=<?php echo $width ?>&amp;h=<?php echo $height ?>" alt="<?php echo $alt ?>" title="<?php echo $alt ?>" />
@coreyweb
coreyweb / gist:2161836
Created March 22, 2012 19:02
wordpress-user-custom-fields
// =================================================================
// add custom fields to user profiles
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>Extra profile information</h3>
<table class="form-table">
<tr>
<th><label for="facebook">Facebook Profile</label></th>
@coreyweb
coreyweb / gist:2194743
Created March 25, 2012 13:58
PHP Randomizer
<?php
// Set the lowest & highest numeric point in you series names of your includes files - example here is 1 and 4
$sl = rand(1,4);
echo $sl;
?>
@coreyweb
coreyweb / gist:2194781
Created March 25, 2012 14:00
Twitter: rewrite URLs and replies as links
<?php
// Convert URL's with protocol prefix
$text = ereg_replace("[a-zA-Z]+://([-]*[.]?[a-zA-Z0-9_/-?&%])*", "<a href=\"\\0\">\\0</a>", $text);
//Convert URL with just www.
$text = ereg_replace("(^| |\n)(www([-]*[.]?[a-zA-Z0-9_/-?&%])*)", "\\1<a href=\"http://\\2\">\\2</a>", $text);
//Convert @ replies
$text = ereg_replace("(^| |\n)(\@([-]*[.]?[a-zA-Z0-9_/-?&%])*)", "\\1<a href=\"http://www.twitter.com/\\2\">\\2</a>", $text);
$text = str_replace("/@", "/", $text);
@coreyweb
coreyweb / gist:2194845
Created March 25, 2012 14:02
Force www (mod rewrite)
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain-name\.com
RewriteCond %{HTTPS} =on
RewriteRule .* https://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} ^domain-name\.com
RewriteCond %{HTTPS} !=on
RewriteRule .* http://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
@coreyweb
coreyweb / gist:2194861
Created March 25, 2012 14:02
Custom 404 (Mod Rewrite)
ErrorDocument 404 /404.php