Skip to content

Instantly share code, notes, and snippets.

View mfields's full-sized avatar

Michael Fields mfields

  • Portland, Oregon, USA
View GitHub Profile
$template_name = 'my-custom-template.php';
$path = locate_template( $template_name );
if ( empty( $path ) )
$path = dirname( __FILE__ ) . '/' . $template_name;
@mfields
mfields / gist:4014915
Created November 5, 2012 02:09
Theme Review of Black Zebra for Extend.
Need to be fixed for inclusion
------------------------------
* The function ```register_sidebar()``` needs to be called during the ```widgets_init``` hook. Please refer to Twenty Twelve's function.php file for an example of how to do this.
* The template tag ```the_title()``` may not be printed inside an attribute. Please use ```the_title_attribute()``` instead. This code was found in line 14 of 404.php, line 11 of archive.php, line 9 of header.php, line 11 of index.php, line 11 of page.php, line 13 of search.php, and line 11 of single.php.
* Please move the function definition for ```blackzebra_custom_styles()``` into functions.php.
* Please remove the additional enqueue for a child theme from ```blackzebra_custom_styles()```. It is best to let the child theme make this decision.
* Please remove the favicon from header.php.
* Please remove the Atom Link from header.php. This functionality should be taken care of by ```add_theme_support( 'automatic-feed-links' )```
* Table headings are the same color as the
@mfields
mfields / gist:3951401
Created October 25, 2012 08:24
WordPress: Echoing categories and tags independent of post_type.
<?php
if ( is_object_in_taxonomy( get_post_type(), 'post_tag' ) ) {
/* translators: used between list items, there is a space after the comma. */
$tag_list = get_the_tag_list( '', __( ', ', '_s' ) );
if ( $tag_list && _s_categorized_blog() )
echo '<span class="entry-tags">' . $tag_list . '</span>';
}
if ( is_object_in_taxonomy( get_post_type(), 'category' ) ) {
/* translators: used between list items, there is a space after the comma. */
@mfields
mfields / gist:3951293
Created October 25, 2012 08:00
World Ipsum
This is basically a list of words in languages that I do not know. I created it to help when researching/testing various fonts. Feel free to add stuff!
Russian
=======
На западе она граничит с Норвегией, Финляндией, Балтийскими государствами, Белоруссией и Украиной.
@mfields
mfields / gist:3951260
Created October 25, 2012 07:49
Twenty Twelve: Google fonts enqueue.
/**
* An Example of how Twenty Twelve Enqueues a Google font.
*
* This is interesting because it allows translators to disable the font
* as well as conditionally load subsets.
*/
function test_theme_enqueue_opensans() {
/* translators: If there are characters in your language that are not supported
by Open Sans, translate this to 'off'. Do not translate into your own language. */
@mfields
mfields / gist:3950905
Created October 25, 2012 06:47
Contain Floats
.entry-content:after {
clear: both;
content: '';
display: block;
}
@mfields
mfields / gist:3950447
Created October 25, 2012 04:43
Raven Post Labels
<?php
/**
* Post Label.
*
* Returns a noun representing the type or format of the global
* post object. This function is used internally by the
* raven_entry_meta_taxonomy() function to create a sentence much
* like the following: "This Status Update is filed under News."
* where "Status Update" is the post label and "News" is the category.
/**
* Exclude asides from the blog queries.
*/
function mytheme_pre_get_posts( $query = false ) {
// Bail if not home, not a query, not main query.
if ( ! is_home() || ! is_a( $query, 'WP_Query' ) || ! $query->is_main_query() )
return $query;
// Exclude aside formatted posts from the main query.
<?php
final class MfieldsDumpHook {
/**
* A list of hooks to dump
*/
private static $hooks = null;
@mfields
mfields / gist:3231663
Created August 1, 2012 23:55
Get Audio
<?php
$audio = get_children( array(
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
'post_mime_type' => 'audio',
'orderby' => 'menu_order',
'order' => 'ASC'
) );
?>