Skip to content

Instantly share code, notes, and snippets.

@lorinrivers
Created February 28, 2012 02:05
Show Gist options
  • Save lorinrivers/1928552 to your computer and use it in GitHub Desktop.
Save lorinrivers/1928552 to your computer and use it in GitHub Desktop.
Functions
<?php
/** Start the engine */
require_once( get_template_directory() . '/lib/init.php' );
/** Child theme (do not remove) */
define( 'CHILD_THEME_NAME', 'Andrew Yates Photography Theme' );
define( 'CHILD_THEME_URL', 'http://mosasaur.com' );
/** Add Viewport meta tag for mobile browsers */
add_action( 'genesis_meta', 'add_viewport_meta_tag' );
function add_viewport_meta_tag() {
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>';
}
/** Add support for custom background */
add_custom_background();
/** Add support for custom header */
add_theme_support( 'genesis-custom-header', array( 'width' => 960, 'height' => 100 ) );
/** Add support for 3-column footer widgets */
add_theme_support( 'genesis-footer-widgets', 3 );
/** Global removal of Genesis features **/
remove_action('genesis_before_post_content', 'genesis_post_info');
remove_action('genesis_after_post_content', 'genesis_post_meta');
remove_action('genesis_after_endwhile', 'genesis_posts_nav');
/** Override Magic Gallery's built-in crop */
add_image_size( 'pikachoose_images', $magicoptions['pika_width'], $magicoptions['pika_height'], false );
/**
* Add a style sheet for any IE .
*
* @author Gary Jones
* @link http://dev.studiopress.com/ie-conditional-style-sheets.htm
*/
add_action( 'wp_print_styles', 'child_add_pixie_style_sheet', 200 );
function child_add_pixie_style_sheet() {
wp_enqueue_style( 'pixie', CHILD_URL . '/iestyle.css', array(), '1.0' );
}
add_filter( 'style_loader_tag', 'child_make_pixie_style_sheet_conditional', 10, 2 );
/**
* Add conditional comments around IE style sheet.
*
* @author Gary Jones & Michael Fields (@_mfields)
* @link http://dev.studiopress.com/ie-conditional-style-sheets.htm
*
* @param string $tag Existing style sheet tag
* @param string $handle Name of the enqueued style sheet
* @return string Amended markup
*/
function child_make_pixie_style_sheet_conditional( $tag, $handle ) {
if ( 'pixie' == $handle )
$tag = '<!--[if IE]>' . "\n" . $tag . '<![endif]-->' . "\n";
return $tag;
}
// Create Video metaboxes
$prefix = '_lr_';
add_filter( 'cmb_meta_boxes', 'lr_create_metaboxes' );
function lr_create_metaboxes( $meta_boxes ) {
global $prefix;
$meta_boxes[] = array(
'id' => 'video',
'title' => 'Videos',
'pages' => array('film'),
'context' => 'normal',
'priority' => 'high',
'show_names' => true, //Show field names left of input
'fields' => array(
array(
'name' => 'Title',
'desc' => 'Title of Video',
'id' => $prefix.'video_title',
'type' => 'text'
),
array(
'name' => 'Video',
'desc' => 'Upload a video.',
'id' => $prefix.'video_file',
'type' => 'file'
),
array(
'name' => 'Poster Image',
'desc' => 'Poster Image for Video',
'id' => $prefix.'video_poster',
'type' => 'file'
),
array(
'name' => 'Thumbnail Image',
'desc' => 'Thumbnail Image for Video',
'id' => $prefix.'video_thumb',
'type' => 'file'
),
),
);
return $meta_boxes;
}
// Initialize the metabox class
add_action( 'init', 'lr_initialize_cmb_meta_boxes', 9999 );
function lr_initialize_cmb_meta_boxes() {
if ( !class_exists( 'cmb_Meta_Box' ) ) {
require_once( CHILD_DIR . '/lib/metabox/init.php' );
}
}
// Set up Videos
add_action('init', 'lr_create_videos_post_type');
/** Add custom post type for AYP Films **/
// init Sponsorship Taxonomies
add_action( 'init', 'create_film_taxonomies', 0 );
// create the taxonomy for the post type "film"
function create_film_taxonomies() {
// Set up Film taxonomy, NOT hierarchical (like tags)
$labels = array(
'name' => _x( 'Film Types', 'taxonomy general name' ),
'singular_name' => _x( 'Film Type', 'taxonomy singular name' ),
'search_items' => __( 'Search Film Types' ),
'popular_items' => __( 'Popular Film Types' ),
'all_items' => __( 'All Film Types' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Edit Film Type' ),
'update_item' => __( 'Update Film Type' ),
'add_new_item' => __( 'Add New Film Type' ),
'new_item_name' => __( 'New Film Type Name' ),
'separate_items_with_commas' => __( 'Separate Film Types with commas' ),
'add_or_remove_items' => __( 'Add or remove Film Types' ),
'choose_from_most_used' => __( 'Choose from the most used Film Types' )
);
// Create Film Type taxonomy
register_taxonomy( 'type', 'film', array(
'hierarchical' => false,
'labels' => $labels, /* NOTICE: the $labels variable here */
'show_ui' => true,
'query_var' => true,
'rewrite' => array('slug' => 'film', with_front => false),
// 'rewrite' => true,
));
} // End of create_film_taxonomies() function.
// Set up the display of the admin page
add_action("manage_posts_custom_column", "film_custom_columns");
add_filter("manage_edit-film_columns", "film_edit_columns");
function film_edit_columns($columns){
$columns = array(
"cb" => "<input type=\"checkbox\" />",
"title" => "Film Title",
"description" => "Description",
"type" => "Film Types",
);
return $columns;
}
function film_custom_columns($column){
global $post;
switch ($column) {
case "description":
the_excerpt();
break;
case "type":
echo get_the_term_list($post->ID, 'type', '', ', ','');
break;
}
}
function lr_create_videos_post_type() {
register_post_type('film',
array(
'labels' => array(
'name' => __('AYP Films'),
'singular_name' => __('AYP Film')
),
'public' => true,
'supports' => array('title','editor','thumbnail','page-attributes','excerpt','custom-fields','genesis-seo', 'genesis-layouts'),
'rewrite' => array('slug' => 'film/%type%', with_front => false),
// 'rewrite' => true,
'has_archive' => true,
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment