Skip to content

Instantly share code, notes, and snippets.

View halgatewood's full-sized avatar

Hal Gatewood halgatewood

View GitHub Profile
@halgatewood
halgatewood / Expanding CSS3 Menu
Created April 6, 2012 18:22
Simple CSS3 Menu where the menu items expand on mouse over.
<html>
<head>
<title>moveable Menu</title>
<style>
body { padding: 0; margin: 0; font-family: arial; font-size: 0.9em; }
nav { margin: 25px auto; width: 960px; padding: 10px 25px; border: solid 1px #ccc; border-left: none; border-right: none;}
nav a {
color: #666;
text-decoration: none;
padding: 5px 10px;
@halgatewood
halgatewood / make-rows.php
Last active December 17, 2015 01:29
Convert an array of objects into rows of arrayed objects.
function make_rows($array, $per = 4)
{
$rows = array();
$c = 1;
$row = 0;
foreach($array as $item)
{
$rows[ $row ][] = $item;
if($c == $per) { $row++; $c = 0; }
$c++;
@halgatewood
halgatewood / wp-add-body-classes.php
Last active December 18, 2015 12:59
Add Custom Body Classes
// ADD CUSTOM BODY CLASSES
add_filter('body_class','hg_body_classes');
function hg_body_classes($classes)
{
$classes[] = "theme-" . get_stylesheet();
// ... other theme logic
return $classes;
}
@halgatewood
halgatewood / remove-wp-footer-text.php
Created June 15, 2013 03:13
Remove WP Footer Text
@halgatewood
halgatewood / wp-remove-dashboard-widgets.php
Created June 15, 2013 03:15
Remove Selected Dashboard Widgets
// REMOVE DASHBOARD WIDGETS
function hg_remove_dashboard_widgets()
{
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
@halgatewood
halgatewood / wp-remove-admin-bar-extras.php
Created June 15, 2013 03:15
Remove WP Admin Bar Extras
// ADMIN BAR UPDATES
function hg_remove_admin_bar_links()
{
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo'); // Remove the WordPress logo
$wp_admin_bar->remove_menu('about'); // Remove the about WordPress link
$wp_admin_bar->remove_menu('wporg'); // Remove the WordPress.org link
$wp_admin_bar->remove_menu('documentation'); // Remove the WordPress documentation link
$wp_admin_bar->remove_menu('support-forums'); // Remove the support forums link
$wp_admin_bar->remove_menu('feedback'); // Remove the feedback link
@halgatewood
halgatewood / wp-admin-link-to-homepage.php
Created June 15, 2013 03:16
WP Direct Link to Home Page in Admin
@halgatewood
halgatewood / wp-get-featured-image.php
Last active December 18, 2015 12:59
Get Featured Image with Fall back for blank image.
// PAGE EXCERPT
add_action('init', 'hg_pe_init');
function hg_pe_init() { if(function_exists("add_post_type_support")) { add_post_type_support( 'page', 'excerpt' ); } }
@halgatewood
halgatewood / hg-get-list-menu.php
Last active December 18, 2015 12:59
WP List Single Level Menu with some nice options.
// LIST MENU
function hg_get_list_menu( $menu_location = 'footer', $delimiter = "&bull;", $class_name = "nav", $wrapper = "div", $echo = true )
{
$menu_locations = get_nav_menu_locations();
$menu_items = (array) wp_get_nav_menu_items( $menu_locations[ $menu_location ] );
$num_menu_items = count($menu_items);
if($num_menu_items >= 1)
{
$rtn .= "<{$wrapper} class=\"{$class_name}\">\n";
$end_of_loop = $num_menu_items - 1;