Skip to content

Instantly share code, notes, and snippets.

@halgatewood
halgatewood / Expanding CSS3 Menu
Created Apr 6, 2012
Simple CSS3 Menu where the menu items expand on mouse over.
View Expanding CSS3 Menu
<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 Dec 17, 2015
Convert an array of objects into rows of arrayed objects.
View make-rows.php
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 Dec 18, 2015
Add Custom Body Classes
View wp-add-body-classes.php
// 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;
}
View remove-wp-footer-text.php
@halgatewood
halgatewood / wp-remove-dashboard-widgets.php
Created Jun 15, 2013
Remove Selected Dashboard Widgets
View wp-remove-dashboard-widgets.php
// 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']);
View wp-remove-admin-bar-extras.php
// 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 Jun 15, 2013
WP Direct Link to Home Page in Admin
View wp-admin-link-to-homepage.php
@halgatewood
halgatewood / wp-get-featured-image.php
Last active Dec 18, 2015
Get Featured Image with Fall back for blank image.
View wp-get-featured-image.php
View wp-page-excerpt.php
// 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 Dec 18, 2015
WP List Single Level Menu with some nice options.
View hg-get-list-menu.php
// 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;