Skip to content

Instantly share code, notes, and snippets.

@halgatewood
halgatewood / page-https.php
Created Feb 13, 2014
HTTPS Page in Wordpress
View page-https.php
<?php
/**
* Template Name: HTTPS Page
*/
if($_SERVER['HTTPS']!="on")
{
wp_redirect( "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
exit;
}
View change-testimonial-archive-order.php
function hg_change_archive_order( $query )
{
if($query->is_archive AND $query->query['post_type'] == "testimonial")
{
$query->set( 'order' , 'asc' );
$query->set( 'orderby' , 'title' );
}
}
add_filter( 'pre_get_posts' , 'hg_change_archive_order' );
View wp-color-palettes
global $_wp_admin_css_colors;
$color_scheme = get_user_option( 'admin_color' );
$current_admin_color_theme = $_wp_admin_css_colors[ $color_scheme ];
echo '
<style>
img.icon { color: ' . $current_admin_color_theme->colors[2] . '; }
img.icon.selected { color: ' . $current_admin_color_theme->colors[3] . '; }
</style>';
View wp-color-object
stdClass Object
(
[name] => Default
[url] => https://halgatewood.com/wp-admin/css/colors.min.css
[colors] => Array
(
[0] => #222, [1] => #333, [2] => #0074a2, [3] => #2ea2cc
)
[icon_colors] => Array
(
View changing-widget-testimonial-order.php
function testimonial_rotator_change_order( $args )
{
$args['order'] = "DESC";
$args['orderby'] = "date";
return $args;
}
// USE THIS add_filter FOR THE WIDGET
add_filter('testimonial_rotator_widget_testimonial_args', 'testimonial_rotator_change_order');
@halgatewood
halgatewood / ssl_post_thumbnail_html.php
Created Mar 7, 2014
Update post thumbnails in WordPress with https when needed.
View ssl_post_thumbnail_html.php
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 Apr 22, 2014
Update Excerpt More for HG Slider
View hg-slider-excerpt-link.php
@halgatewood
halgatewood / edd-stripe-checkout-currencies.php
Last active Aug 29, 2015
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
View edd-stripe-checkout-currencies.php
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
Changing the Prev/Next Font Awesome Icons for my Testimonial Rotator
View prev-next-button-filters.php
// 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 Jun 2, 2014
If the first parameter is not found then redirect to the second, If it is then do nothing.
View redirect_if_not_found.php
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");
}