Skip to content

Instantly share code, notes, and snippets.

View halgatewood's full-sized avatar

Hal Gatewood halgatewood

View GitHub Profile
@halgatewood
halgatewood / wp-check-for-h1-custom-field.php
Created June 15, 2013 03:19
WP Check for H1 Custom Field value.
// H1 SUPPORT
function hg_check_for_h1_title($title, $id)
{
if (in_the_loop() AND $id == get_the_ID())
{
$h1 = get_post_meta($id, 'h1', true);
if($h1) return $h1;
}
return $title;
}
@halgatewood
halgatewood / YouTubeWidget.php
Last active December 18, 2015 14:49
Add a icon on top of the video by creating a youtube.png image and putting it in a 'images' folder in your theme.
<?php
/**
* Plugin Name: YouTube Video Widget
* Plugin URI: http://halgatewood.com/
* Description: Awesome YouTube Widget that allows single videos or latest video from channel. Uses transient api to keep it quick.
* Author: Hal Gatewood
* Author URI: http://halgatewood.com/
* Version: 1.0
* License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
@halgatewood
halgatewood / pmpro-expire-at-end-of-year.php
Created November 20, 2013 16:09
Expire all membership levels at the end of the year. If the user registers after October (10 variable on line 8) then they'll expire in the next year.
/// EXPIRATION DATE
function my_pmpro_checkout_level($level)
{
$expiration_year = date('Y');
$current_month = date('n');
// IF OCT, NOV, DEC, EXPIRE NEXT YEAR
if($current_month >= 10) { $expiration_year++; }
$expiration_date = $expiration_year . "-12-31";
@halgatewood
halgatewood / wordpress-3.8-dashicons.php
Last active December 29, 2015 08:49
WordPress 3.8: New Admin Menu Dashicons
function flexslider_hg_admin_icon()
{
echo '
<style>
#adminmenu #menu-posts-slides div.wp-menu-image:before { content: "\f181"; }
</style>
';
}
add_action( 'admin_head', 'flexslider_hg_admin_icon' );
@halgatewood
halgatewood / acf-youtube-video-object.php
Created December 26, 2013 04:19
Working with the Video Object in the Advanced Custom Fields: YouTube Field. http://halgatewood.com/downloads/acf-youtube-field/
$video = get_field('youtube_video');
echo "<h1>" . $video->title . "</h1>";
echo "<p>" . $video->desc . "</p>";
echo $video->embed;
@halgatewood
halgatewood / page-https.php
Created February 13, 2014 21:52
HTTPS Page in Wordpress
<?php
/**
* Template Name: HTTPS Page
*/
if($_SERVER['HTTPS']!="on")
{
wp_redirect( "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
exit;
}
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' );
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');
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>';
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
(