Skip to content

Instantly share code, notes, and snippets.

View coreyweb's full-sized avatar

corey brown coreyweb

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>iTunes Album Playlist</title>
<!-- Bootstrap -->
<div class="row">
<h3>My Pictures</h3>
<?php
$json = file_get_contents('https://api.instagram.com/v1/users/[YOUR_USER_ID]/media/recent?access_token=[YOUR_ACCESS_TOKEN]&count=5');
$data = json_decode($json);
foreach ($data->data as $key=>$value) {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="author" content="">
@coreyweb
coreyweb / wp_check_post_date
Created January 19, 2014 14:58
Check post date in a WordPress post and establish rules for before and after a certain date
<?php
if (strtotime($post->post_date) > strtotime('January 01 2014')) {
// this is a newer post
} else {
// this is an older post
}
?>
@coreyweb
coreyweb / wp_table-shortcode.php
Last active January 3, 2016 07:28
WordPress Table Shortcode
<?php
// this shortcode allows you to add multiple rows and columns in a table
// corey modified from this from a shortcode found here:
// http://wpsnipp.com/index.php/functions-php/shortcode-tables-with-multiple-rows-and-columns/
// example shortcode:
// [specs cols="2" data="Row1 Item1:|Row1 Item2|Row2 Item1:|Row2 Item2"]
// (define # of columns in 'cols' and place your contents in 'data' with a delimiter)
// markup is Bootstrap
function specs_list( $atts ) {
<?php if ($feed = coreylib('http://api.bigcartel.com/notreble/products.xml','10 minutes')) { ?>
<?php foreach($feed->get('product') as $product) { ?>
<p><strong>URL: </strong> http://shop.notreble.com<?php echo $product->get('url') ?></p>
<p><strong>Item name: </strong> <?php echo $product->get('name') ?></p>
<p><strong>Item image: </strong> <?php echo $product->get('image/url') ?></p>
@coreyweb
coreyweb / wp_soundcloud-shortcode.php
Created June 15, 2013 17:01
Soundcloud Shortcode function for self-hosted WordPress
<?php
// Soundcloud has a shortcode for WordPress.com,
// but it doesn't work on self-hosted WordPress sites.
// To make the standard shortcode work, add this to your functions.php file.
// Here is what Soundcloud's "WordPress Code" shortcode looks like:
// [soundcloud url="http://api.soundcloud.com/tracks/95232600" params="" width=" 100%" height="166" iframe="true" /]
function soundcloud( $atts, $url='' ) {
extract(shortcode_atts(array(
'url' => 'http://',
@coreyweb
coreyweb / tweet linkifier
Created January 21, 2013 22:04
Convert Twitter @mentions, #hashtags and URLs within a string to anchor links.
<?php
// Convert URL's with protocol prefix
$tweet = ereg_replace("[a-zA-Z]+://([-]*[.]?[a-zA-Z0-9_/-?&%])*", "<a href=\"\\0\">\\0</a>", $tweet);
//Convert URL with just www.
$tweet = ereg_replace("(^| |\n)(www([-]*[.]?[a-zA-Z0-9_/-?&%])*)", "\\1<a href=\"http://\\2\">\\2</a>", $tweet);
//Convert # hashtags
$tweet = ereg_replace("(^| |\n)(\#([-]*[.]?[a-zA-Z0-9_/-?&%])*)", "\\1<a href=\"http://search.twitter.com/search?q=\\2\">\\2</a>", $tweet);
$tweet = str_replace("/#", "/", $tweet);
@coreyweb
coreyweb / vt_resize.php
Created May 20, 2012 17:03
WordPress Dynamic Image Resizing
<?php
/**
* Resize images dynamically using wp built in functions.
* @author Victor Teixeira http://profiles.wordpress.org/vteixeira/
* @author Aaron Collegeman http://aaroncollegeman.com
* @see http://core.trac.wordpress.org/ticket/15311
*
* @coreyweb's note: I asked Aaron to simplify Victor's original by excluding
* the lookup to see if the original image is big enough to render the newly sized image.
* Our themes don't increase image sizes (ever), and if they did, they would
@coreyweb
coreyweb / gist:2732543
Created May 19, 2012 22:07
Get WP Pages by Custom Template Name
<?php /*
Get a list of all pages on a site, by their template name.
This is useful in determining which custom page templates are in use (and the reverse: which are not)
source: Jorge Pedret
http://jorgepedret.com/web-development/get-pages-by-template-name-in-wordpress/
*/