Created
August 4, 2010 04:34
-
-
Save iansoper/507644 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_theme_support( 'post-thumbnails' ); | |
// add_theme_support( 'post-thumbnails', array( 'post' ) ); // Add it for posts | |
// add_theme_support( 'post-thumbnails', array( 'page' ) ); // Add it for pages | |
set_post_thumbnail_size( 50, 50, true ); // 50 pixels wide by 50 pixels tall, hard crop mode | |
add_image_size( 'large-featured-thumbnail', 340, 220, true ); // Permalink thumbnail size | |
add_image_size( 'small-featured-thumbnail', 280, 130, true ); // Permalink thumbnail size | |
add_image_size( 'small-film-still', 230, 150, true); | |
add_image_size( 'archive-thumbnail', 100, 100, true); | |
register_sidebar(array( | |
'name' => 'Page Sidebar', | |
'description' => 'Widgets in this area will be shown on the right-hand side.', | |
'before_title' => '<h3>', | |
'after_title' => '</h3>')); | |
register_sidebar(array( | |
'name' => 'Blog Sidebar', | |
'description' => 'Widgets in this area will be shown on the left-hand side of the blog.', | |
'before_title' => '<h3>', | |
'after_title' => '</h3>')); | |
register_sidebar(array( | |
'name' => 'Single Sidebar', | |
'description' => 'Widgets in this area will be shown on the left-hand side on single post pages.', | |
'before_title' => '<h3>', | |
'after_title' => '</h3>')); | |
register_sidebar(array( | |
'name' => 'Footer', | |
'description' => 'Widgets in this area will be shown in the footer of each page.', | |
'before_title' => '<li><h2>', | |
'after_title' => '</h2></li>', | |
'before_widget' => '<ul class="footer-widget span-3">', | |
'after_widget' => '</ul>', | |
)); | |
register_sidebar(array( | |
'name' => 'Films Sidebar', | |
'description' => 'Widgets in this area will be shown on the right-hand side.', | |
'before_title' => '<h3>', | |
'after_title' => '</h3>')); | |
//Load jQuery from Google, put in functions.php | |
function my_init() { | |
if (!is_admin()) { | |
// comment out the next two lines to load the local copy of jQuery | |
wp_deregister_script('jquery'); | |
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js', false, '1.4.1'); | |
wp_enqueue_script('jquery'); | |
} | |
} | |
// Actions | |
add_action("admin_init", "admin_init"); | |
add_action('init', 'my_init'); | |
add_action( 'init', 'build_taxonomies', 0 ); | |
add_action("manage_posts_custom_column", "film_custom_columns"); | |
add_filter("manage_edit-film_columns", "film_edit_columns"); | |
add_action('save_post', 'save_film_details'); | |
//Random Sponsor Widget | |
/** | |
* RandomSponsor Class | |
*/ | |
class RandomSponsor extends WP_Widget { | |
/** constructor */ | |
function RandomSponsor() { | |
parent::WP_Widget(false, $name = 'RandomSponsor'); | |
} | |
/** @see WP_Widget::widget */ | |
function widget($args, $instance) { | |
extract( $args ); | |
$title = apply_filters('widget_title', $instance['title']); | |
?> | |
<?php | |
$queryArgs = array( | |
'showposts' => 1, | |
'orderby' => 'rand', | |
'post_type' => 'sponsor' | |
); | |
$r = new WP_Query($queryArgs); | |
//get_posts($queryArgs) ?> | |
<?php if ( $r->have_posts() ) : ?> | |
<?php echo $before_widget; ?> | |
<?php if ( $title ) | |
echo $before_title . $title . $after_title; ?> | |
<?php while ( $r->have_posts() ) : $r->the_post(); ?> | |
<!-- post --> | |
<div> | |
<h4>RIFF Sponsored in part by</h4> | |
<?php //if ( has_post_thumbnail() ) : ?> | |
<?php //Get the Thumbnail URL | |
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), "medium", false ); | |
?> | |
<a class="sponsor" target="_blank" href="<?php the_permalink() ?>"><img src="<?php bloginfo('template_directory') ?>/timthumb.php?src=<?php echo $src[0] ?>&w=150&zc=1"></a> | |
</div> | |
<?php //endif; ?> | |
<?php endwhile; ?> | |
<!-- post navigation --> | |
<?php else: ?> | |
<!-- no posts found --> | |
<?php endif; ?> | |
<?php echo $after_widget; ?> | |
<?php | |
} | |
/** @see WP_Widget::update */ | |
function update($new_instance, $old_instance) { | |
return $new_instance; | |
} | |
} // class RandomSponsor | |
// register FooWidget widget | |
add_action('widgets_init', create_function('', 'return register_widget("RandomSponsor");')); | |
//Subscribe Widget | |
/** | |
* Subscribe Class | |
*/ | |
class SubscribeToRIFF extends WP_Widget { | |
/** constructor */ | |
function SubscribeToRIFF() { | |
parent::WP_Widget(false, $name = 'SubscribeToRIFF'); | |
} | |
/** @see WP_Widget::widget */ | |
function widget($args, $instance) { | |
extract( $args ); | |
$title = apply_filters('widget_title', $instance['title']); | |
?> | |
<?php echo $before_widget; ?> | |
<li><h2>Subscribe</h2> | |
<ul> | |
<li><strong>Website Updates</strong> | |
<li><a href="/feed/" class="rss">RSS Feed</a> </li> | |
<li><a href="http://feedburner.google.com/fb/a/mailverify?uri=RappahannockIndependentFilmFestival" class="email" target="_blank">Via Email</a></li> | |
</li> | |
<!-- <li class="facebook"><a href="http://www.facebook.com/pages/Fredericksburg-VA/Rappahannock-Independent-Film-Festival/24721505840" target="_blank">Facebook</a></li> | |
<li class="twitter"><a href="http://twitter.com/rifilmfestival" target="_blank">Twitter</a></li> --> | |
</ul> | |
<ul> | |
<li><strong>Email Newsletter</strong><br /> | |
<form action="http://iansoper.createsend.com/t/r/s/hrluu/" method="post"> | |
<div> | |
<input type="text" name="cm-hrluu-hrluu" id="hrluu-hrluu" /><br /> | |
<input type="submit" value="Subscribe" /> | |
</div> | |
</form></li> | |
</ul> | |
</li> | |
<?php echo $after_widget; ?> | |
<?php | |
} | |
/** @see WP_Widget::update */ | |
function update($new_instance, $old_instance) { | |
return $new_instance; | |
} | |
} // class RandomSponsor | |
// register FooWidget widget | |
add_action('widgets_init', create_function('', 'return register_widget("SubscribeToRIFF");')); | |
function build_taxonomies() { | |
register_taxonomy( | |
'sponsors', | |
'sponsor', | |
array( | |
'hierarchical' => true, | |
'label' => 'Sponsors Categories', | |
'query_var' => 'sponsors', | |
'rewrite' => true, | |
'show_ui' => true, | |
) | |
); | |
register_taxonomy( | |
'featured-placement', | |
'featured', | |
array( | |
'hierarchical' => true, | |
'label' => 'Featured Ad Placement', | |
//'query_var' => 'featured-placement', | |
'rewrite' => true, | |
'show_ui' => true, | |
) | |
); | |
register_taxonomy( | |
'screening-block', | |
'films', | |
array( | |
'hierarchical' => true, | |
'label' => 'Screening Block', | |
//'query_var' => 'screening-block', | |
'rewrite' => true, | |
'show_ui' => true, | |
) | |
); | |
register_taxonomy( | |
'country', | |
'films', | |
array( | |
'hierarchical' => true, | |
'label' => 'Country', | |
// 'query_var' => 'country', | |
'rewrite' => true, | |
'show_ui' => true, | |
) | |
); | |
register_taxonomy( | |
'finalists', | |
'films', | |
array( | |
'hierarchical' => true, | |
'label' => 'Finalists', | |
// 'query_var' => 'finalists', | |
'rewrite' => true, | |
'show_ui' => true, | |
) | |
); | |
register_taxonomy( | |
'riff-year', | |
'films', | |
array( | |
'hierarchical' => true, | |
'label' => 'RIFF Year', | |
// 'query_var' => 'riff-year', | |
'rewrite' => true, | |
'show_ui' => true, | |
) | |
); | |
} | |
function admin_init() { | |
// add_meta_box(int id, string title, string callback, string page, string context, string priority, string callback_args); | |
add_meta_box("filminfo_meta", "Film Info", "filminfo_meta", "films", "normal", "high"); | |
// Fire this during init | |
register_post_type('sponsor', array( | |
'label' => __('Sponsors '), | |
'singular_label' => __('Sponsor'), | |
'public' => true, | |
'show_ui' => true, | |
'capability_type' => 'page', | |
'hierarchical' => true, | |
'rewrite' => true, | |
'query_var' => true, | |
'exclude_from_search' => true, | |
'supports' => array('title', 'editor', 'author','thumbnail','custom-fields','page-attributes'), | |
'taxonomies' => array('sponsors') | |
)); | |
register_post_type('featured', array( | |
'label' => __('Featured '), | |
'singular_label' => __('featured'), | |
'public' => true, | |
'show_ui' => true, | |
'capability_type' => 'post', | |
'hierarchical' => false, | |
'rewrite' => true, | |
'query_var' => true, | |
'exclude_from_search' => true, | |
'supports' => array('title', 'editor', 'author','thumbnail','custom-fields','excerpt'), | |
'taxonomies' => array('featured') | |
)); | |
register_post_type('films', array( | |
'label' => __('Films'), | |
'singular_label' => __('films'), | |
'public' => true, | |
'show_ui' => true, | |
'capability_type' => 'post', | |
'hierarchical' => true, | |
'rewrite' => true, | |
'query_var' => true, | |
'exclude_from_search' => false, | |
'supports' => array('title', 'editor','thumbnail','excerpt','revisions','custom-fields'), | |
'taxonomies' => array('screening-block','country','finalists','riff-year') | |
)); | |
} | |
function filminfo_meta() { | |
setup_postdata($post); | |
global $post; | |
// if (!$post) | |
// { | |
// $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID']; | |
// $post = wp_get_single_post($post_id); | |
// } | |
$custom = get_post_custom($post->ID); | |
$producer = $custom["film_producer"][0]; | |
$director = $custom["film_director"][0]; | |
$writer = $custom["film_writer"][0]; | |
$runtime = $custom["film_runtime"][0]; | |
$website = $custom["film_website"][0]; | |
$trailer = $custom["film_trailer"][0]; | |
?> | |
<h4>Credits:</h4> | |
<p><label>Producer(s):</label><br /> | |
<input type="text" size="35" name="film_producer" value="<?php echo $producer; ?>"></p> | |
<p><label>Director(s):</label><br /> | |
<input type="text" size="35" name="film_director" value="<?php echo $director; ?>"></p> | |
<p><label>Writer(s):</label><br /> | |
<input type="text" size="35" name="film_writer" value="<?php echo $writer; ?>"></p> | |
<p><label>Runtime:</label><br /> | |
<input type="text" size="5" name="film_runtime" value="<?php echo $runtime; ?>"> minutes</p> | |
<p><label>Website (URL)</label><br /> | |
<input type="text" size="35" name="film_website" value="<?php echo $website ?>"></p> | |
<p><label>Trailer (URL)</label><br /> | |
<input type="text" size="35" name="film_trailer" value="<?php echo $trailer ?>"></p> | |
<?php | |
} | |
// $post_id is automatically passed to the save_post action hook, so no need to get | |
// the post from the global scope. | |
function save_film_details( $post_id ) { | |
// check the post type before adding additional fields. | |
if ( ! isset( $_POST['post_type'] ) || 'film' != $_POST['post_type'] ) { | |
return; | |
} | |
// there are some complications with autosave and custom post types. I recommend | |
// checking for autosave before saving custom fields. | |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) | |
return; | |
update_post_meta( $post_id, "film_producer", $_POST["film_producer"] ); | |
update_post_meta( $post_id, "film_director", $_POST["film_director"] ); | |
update_post_meta( $post_id, "film_writer" , $_POST["film_writer" ] ); | |
update_post_meta( $post_id, "film_runtime" , $_POST["film_runtime" ] ); | |
update_post_meta( $post_id, "film_website" , $_POST["film_website" ] ); | |
update_post_meta( $post_id, "film_trailer" , $_POST["film_trailer" ] ); | |
} | |
function film_edit_columns($columns){ | |
$columns = array( | |
"cb" => "<input type=\"checkbox\" />", | |
"title" => "Film", | |
"description" => "Synopsis", | |
"runtime" => "Runtime", | |
); | |
return $columns; | |
} | |
function film_custom_columns($column){ | |
global $post; | |
switch ($column) { | |
case "description": | |
the_excerpt(); | |
break; | |
case "runtime": | |
$custom = get_post_custom(); | |
echo $custom["film_runtime"][0]." min"; | |
} | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php get_header() ?> | |
<section id="content" class="container"> | |
<?php get_sidebar() ?> | |
<article id="posts" <?php post_class() ?>> | |
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> | |
<?php setup_postdata($post); | |
?> | |
<?php | |
//print_r(get_post_custom($post->ID)); | |
$custom = get_post_custom($post->ID); | |
$producer = $custom["film_producer"][0]; | |
$director = $custom["film_director"][0]; | |
$writer = $custom["film_writer"][0]; | |
$runtime = $custom["film_runtime"][0]; | |
$website = $custom["film_website"][0]; | |
$trailer = $custom["film_trailer"][0]; ?> | |
<!-- post --> | |
<h1><?php the_title() ?></h1> | |
<div class="post_meta"> | |
<div class="credits two_col"> | |
<p><span class="producer"><strong>Producer:</strong> <?php echo $producer ?></span><br /> | |
<span class="director"><strong>Director:</strong> <?php echo $director ?></span><br /> | |
<span class="writer"><strong>Writer:</strong> <?php echo $writer ?></span></p> | |
</div> | |
<div class="two_col"> | |
<p><span class="runtime"><strong>Runtime:</strong> <?php echo $runtime ?> min</span><br /> | |
<span class="website"><strong>Website:</strong> <?php echo $website ?></span></p> | |
</div> | |
<?php //echo get_the_term_list( $post->ID, 'film-categories'); ?> | |
<?php | |
$terms = wp_get_post_terms($post->ID, 'film-categories'); | |
//print_r($terms); | |
?><pre><?php | |
//echo $terms | |
?></pre><?php | |
?> | |
</div> | |
<?php the_post_thumbnail('medium') ?> | |
<?php the_content(); ?> | |
<?php endwhile; ?> | |
<!-- post navigation --> | |
<?php else: ?> | |
<!-- no posts found --> | |
<?php endif; ?> | |
<?php echo '<ul class="addtoany_list">'; if( function_exists('ADDTOANY_SHARE_SAVE_ICONS') ) ADDTOANY_SHARE_SAVE_ICONS( array("html_wrap_open" => "<li>", "html_wrap_close" => "</li>") ); if( function_exists('ADDTOANY_SHARE_SAVE_BUTTON') ) ADDTOANY_SHARE_SAVE_BUTTON( array("html_wrap_open" => "<li>", "html_wrap_close" => "</li>") ); echo '</ul>'; ?> | |
<?php //related_posts(3) ?> | |
<?php //comments_template( '', true ); ?> | |
<nav> | |
<?php previous_post_link('%link', '← Previous'); ?> | |
<?php next_post_link('%link', 'Next →'); ?> | |
</nav> | |
</article> | |
<!-- </section> --> | |
<span class="bottom"></span> | |
</section> | |
<?php get_footer(); ?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment