Skip to content

Instantly share code, notes, and snippets.

View mattboon's full-sized avatar

Matt Berridge mattboon

View GitHub Profile
@mattboon
mattboon / gist:965501
Created May 10, 2011 22:24
Improved Facebook CSS
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("facebook.com") {
.ego_column, #pagelet_adbox {
display: none;
}
.fbx #globalContainer {
width: 1200px !important;
}
.hasLeftCol .hasRightCol #contentArea {
@mattboon
mattboon / gist:978263
Created May 18, 2011 09:17
Guide Custom Post Type
<?php
// CUSTOM POST TYPE
add_action('init', 'matt_guide_register');
function matt_guide_register() {
$labels = array(
'name' => _x('Guide', 'post type general name'),
'singular_name' => _x('Region', 'post type singular name'),
'add_new' => _x('Add new region', 'region item'),
'add_new_item' => __('Add new'),
'edit_item' => __('Edit region'),
@mattboon
mattboon / gist:1004224
Created June 2, 2011 10:29
Why you don't copy & paste directly from Microsoft Word into the WordPress visual editor!
<p><!--[if gte mso 9]><xml> <o:DocumentProperties> <o:Template>Normal.dotm</o:Template> <o:Revision>0</o:Revision> <o:TotalTime>0</o:TotalTime> <o:Pages>1</o:Pages> <o:Words>12</o:Words> <o:Characters>71</o:Characters> <o:Company>Mixd</o:Company> <o:Lines>1</o:Lines> <o:Paragraphs>1</o:Paragraphs> <o:CharactersWithSpaces>87</o:CharactersWithSpaces> <o:Version>12.256</o:Version> </o:DocumentProperties> <o:OfficeDocumentSettings> <o:AllowPNG /> </o:OfficeDocumentSettings> </xml><![endif]--><!--[if gte mso 9]><xml> <w:WordDocument> <w:Zoom>0</w:Zoom> <w:TrackMoves>false</w:TrackMoves> <w:TrackFormatting /> <w:PunctuationKerning /> <w:DrawingGridHorizontalSpacing>18 pt</w:DrawingGridHorizontalSpacing> <w:DrawingGridVerticalSpacing>18 pt</w:DrawingGridVerticalSpacing> <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery> <w:DisplayVerticalDrawingGridEvery>0</w:DisplayVerticalDrawingGridEvery> <w:ValidateAgainstSchemas /> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>fa
@mattboon
mattboon / gist:1048651
Created June 27, 2011 10:34
Nav of hell
<ul>
<?php for ($i=6;$i<13;$i++): ?>
<li<?= $root_page_id==$i ? ' class="current"' : '' ?>>
<a href="<?= get_permalink($i); ?>"<?= $i==6 ? ' accesskey="0"' : '' ?>>
<?= get_the_title($i); ?>
</a>
</li>
<?php endfor; ?>
</ul>
@mattboon
mattboon / gist:1055097
Created June 29, 2011 21:51
WordPress Custom Post Type
<?php
//---- CUSTOM POST TYPE - EXECUTIVE DEVELOPERS --------------------------------------------------------
add_action('init', '_init_developer_post_type');
function _init_developer_post_type() {
// MAKE POST TYPE
//---------------------------
register_post_type( 'developer',
array(
@mattboon
mattboon / gist:1055103
Created June 29, 2011 21:54
WordPress Small Snippets - Clean Admin Panel
<?php
// Remove columns from Posts admin
add_filter('manage_posts_columns', 'my_posts_columns');
function my_posts_columns($defaults) {
unset($defaults['comments']);
unset($defaults['author']);
unset($defaults['tags']);
//unset($defaults['date']);
return $defaults;
}
@mattboon
mattboon / gist:1055110
Created June 29, 2011 21:57
WordPress Section Index w/ shortcode and many options
<?php $the_content = apply_filters('the_content', $post->post_content);
$the_content = explode("<p>[MENU]</p>",$the_content); ?>
<?= $the_content[0]; ?>
<?php
/* GET CUSTOM FIELDS */
$menu_type = get_post_meta($post->ID, 'menu_type', true);
$menu_page_curl = get_post_meta($post->ID, 'menu_page_curl', true);
$menu_custom_array = get_post_meta($post->ID, 'menu_custom_array', true);
$menu_more_text = get_post_meta($post->ID, 'menu_more_text', true);
@mattboon
mattboon / gist:1055120
Created June 29, 2011 21:59
WordPress Generate Navigation
<?php
global $root_page_id;
if (!empty($post->ancestors)) { $root_page_id = $post->ancestors[(count($post->ancestors)-1)]; } else { $root_page_id = $post->ID; }
// get root page id
global $excluded_pages_string;
global $excluded_pages_array;
$excluded_pages_string = "";
$excluded_pages_array = explode(",", $excluded_pages_string);
// exclude confirmation etc. pages
global $primary_nav_items;
@mattboon
mattboon / gist:1056146
Created June 30, 2011 12:43
WordPress - Tree Navigation
<nav role="navigation">
<ul>
<?php foreach($primary_nav_items as $level_one) :
/* LOOP LEVEL ONE */
$level_two = get_pages('child_of='.$level_one.'&parent='.$level_one.'&sort_column=menu_order&sort_order=asc&exclude='.$excluded_pages_string.'');
/* GET ALL LEVEL TWO PAGES */ ?>
<li<?php if($root_page_id==$level_one): ?> class="current<?= $level_two ? ' open' : '' ?>"<?php endif; ?>>
<a href="<?= get_permalink($level_one); ?>">
<?= get_the_title($level_one); ?>
</a>
@mattboon
mattboon / gist:1065917
Created July 5, 2011 21:01
WordPress CPT with Taxonomy Custom Fields I
//---- CUSTOM POST TYPE - FAQs --------------------------------------------------------
add_action('init', '_init_question_post_type');
function _init_question_post_type() {
// MAKE POST TYPE
//---------------------------
register_post_type( 'question',
array(