Skip to content

Instantly share code, notes, and snippets.

View halgatewood's full-sized avatar

Hal Gatewood halgatewood

View GitHub Profile
@halgatewood
halgatewood / vine-thumbnails.php
Created March 4, 2014 17:38
Get Vine Thumbnails through the open-graph meta tags
function get_vine_thumbnail( $id )
{
$vine = file_get_contents("http://vine.co/v/{$id}");
preg_match('/property="og:image" content="(.*?)"/', $vine, $matches);
return ($matches[1]) ? $matches[1] : false;
}
echo get_vine_thumbnail('bv5ZeQjY352');
@halgatewood
halgatewood / ssl_post_thumbnail_html.php
Created March 7, 2014 08:04
Update post thumbnails in WordPress with https when needed.
function ssl_post_thumbnail_html( $html )
{
if( is_ssl() )
{
return str_replace("http://", "https://", $html);
}
else
{
return $html;
}
@halgatewood
halgatewood / hg-slider-excerpt-link.php
Created April 22, 2014 09:11
Update Excerpt More for HG Slider
@halgatewood
halgatewood / edd-stripe-checkout-currencies.php
Last active August 29, 2015 14:01
Add this function to your functions.php file in your theme.All support currencies for the Stripe Checkout Gateway for Easy Digital Downloads. http://halgatewood.com/downloads/stripe-checkout-gateway/ Please note that some currencies are not supported by American Express: https://support.stripe.com/questions/which-currencies-does-stripe-support
function hg_stripe_checkout_all_currencies( $currencies )
{
$currencies['INR'] = __('Indian Rupee', 'hg_edd');
$currencies['AED'] = __('United Arab Emirates Dirham', 'hg_edd');
$currencies['AFN'] = __('Afghan Afghani', 'hg_edd');
$currencies['ALL'] = __('Albanian Lek', 'hg_edd');
$currencies['AMD'] = __('Armenian Dram', 'hg_edd');
$currencies['ANG'] = __('Netherlands Antillean Gulden', 'hg_edd');
$currencies['AOA'] = __('Angolan Kwanza', 'hg_edd');
$currencies['ARS'] = __('Argentine Peso', 'hg_edd');
@halgatewood
halgatewood / prev-next-button-filters.php
Created May 15, 2014 06:10
Changing the Prev/Next Font Awesome Icons for my Testimonial Rotator
// HORIZONTAL SCROLLING AND FADING
function hg_change_next_icon()
{
return 'fa-arrow-circle-o-right';
}
add_filter('testimonial_rotator_fa_icon_next', 'hg_change_next_icon');
function hg_change_prev_icon()
{
@halgatewood
halgatewood / redirect_if_not_found.php
Created June 2, 2014 06:37
If the first parameter is not found then redirect to the second, If it is then do nothing.
function redirect_if_not_found( $item, $to )
{
if(!$item)
{
// WHATEVER OTHER HEADER OPTIONS YOU WANT CAN GO HERE, LIKE A 301
header("HTTP/1.1 301 Moved Permanently");
// REDIRECT
header("Location: $to");
}
{"icons":[{"name":"Glass","id":"glass","unicode":"f000","created":1,"categories":["Web Application Icons"]},{"name":"Music","id":"music","unicode":"f001","created":1,"categories":["Web Application Icons"]},{"name":"Search","id":"search","unicode":"f002","created":1,"categories":["Web Application Icons"]},{"name":"Envelope Outlined","id":"envelope-o","unicode":"f003","created":1,"categories":["Web Application Icons"]},{"name":"Heart","id":"heart","unicode":"f004","created":1,"categories":["Web Application Icons"]},{"name":"Star","id":"star","unicode":"f005","created":1,"categories":["Web Application Icons"]},{"name":"Star Outlined","id":"star-o","unicode":"f006","created":1,"categories":["Web Application Icons"]},{"name":"User","id":"user","unicode":"f007","created":1,"categories":["Web Application Icons"]},{"name":"Film","id":"film","unicode":"f008","created":1,"categories":["Web Application Icons"]},{"name":"th-large","id":"th-large","unicode":"f009","created":1,"categories":["Text Editor Icons"]},{"name":"
@halgatewood
halgatewood / fa-paw.php
Created July 20, 2014 05:27
Changing Stars in the Testimonial Rotator
function tr_stars( $icon, $template_name, $id )
{
return "fa-paw";
}
add_filter( 'testimonial_rotator_star' , 'tr_stars', 10, 3 );
@halgatewood
halgatewood / fa-bomb.php
Last active August 29, 2015 14:04
Changing the fa-star to whatever else you need in the Testimonial Rotator
function tr_stars( $icon, $template_name, $id )
{
if( $template_name == "boom" ) return "fa-bomb";
if( $template_name == "dogs" ) return "fa-paw";
if( $id == 115 ) return "fa-asterisk";
return $icon;
}
add_filter( 'testimonial_rotator_star' , 'tr_stars', 10, 3 );
@halgatewood
halgatewood / hg_register_type.php
Created July 27, 2014 02:48
Quickly Register Post Types, I found myself registering many of the same type of WordPress post types and create a little helper function.
function hg_register_type( $plural, $singular, $post_type = false, $position = 30, $supports = array('title','editor','thumbnail','author','custom-fields'))
{
$uc_plural = ucwords($plural);
$uc_single = ucwords($singular);
$lc_plural = strtolower($plural);
$lc_single = strtolower($singular);
$pt = ($post_type) ? $post_type : $lc_single;
$labels = array('name' => $uc_plural,'singular_name' => $uc_single,'add_new' => 'Add New','add_new_item' => 'Add New ' . $uc_single,'edit_item' => 'Edit ' . $uc_single,'new_item' => 'New ' . $uc_single,'view_item' => 'View ' . $uc_single,'search_items' => 'Search ' . $uc_plural,'not_found' => 'No ' . $uc_plural . ' Found','not_found_in_trash' => 'No ' . $uc_plural . ' Found in Trash', 'parent_item_colon' => 'Parent ' . $uc_single . ':' );