. add_theme_support( 'automatic-feed-links' ); // This theme uses wp_nav_menu() in one location. register_nav_menu( 'primary', __( 'Primary Menu', 'twentyeleven' ) ); // Add support for a variety of post formats add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) ); // Add support for custom backgrounds add_custom_background(); // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images add_theme_support( 'post-thumbnails' ); // The next four constants set how Twenty Eleven supports custom headers. // The default header text color define( 'HEADER_TEXTCOLOR', '000' ); // By leaving empty, we allow for random image rotation. define( 'HEADER_IMAGE', '' ); // The height and width of your custom header. // Add a filter to twentyeleven_header_image_width and twentyeleven_header_image_height to change these values. define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyeleven_header_image_width', 1000 ) ); define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyeleven_header_image_height', 288 ) ); // We'll be using post thumbnails for custom header images on posts and pages. // We want them to be the size of the header image that we just defined // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php. set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Add Twenty Eleven's custom image sizes add_image_size( 'large-feature', HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Used for large feature (header) images add_image_size( 'small-feature', 500, 300 ); // Used for featured posts if a large-feature doesn't exist // Turn on random header image rotation by default. add_theme_support( 'custom-header', array( 'random-default' => true ) ); // Add a way for the custom header to be styled in the admin panel that controls // custom headers. See twentyeleven_admin_header_style(), below. add_custom_image_header( 'twentyeleven_header_style', 'twentyeleven_admin_header_style', 'twentyeleven_admin_header_image' ); // ... and thus ends the changeable header business. // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI. register_default_headers( array( 'wheel' => array( 'url' => '%s/images/headers/wheel.jpg', 'thumbnail_url' => '%s/images/headers/wheel-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Wheel', 'twentyeleven' ) ), 'shore' => array( 'url' => '%s/images/headers/shore.jpg', 'thumbnail_url' => '%s/images/headers/shore-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Shore', 'twentyeleven' ) ), 'trolley' => array( 'url' => '%s/images/headers/trolley.jpg', 'thumbnail_url' => '%s/images/headers/trolley-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Trolley', 'twentyeleven' ) ), 'pine-cone' => array( 'url' => '%s/images/headers/pine-cone.jpg', 'thumbnail_url' => '%s/images/headers/pine-cone-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Pine Cone', 'twentyeleven' ) ), 'chessboard' => array( 'url' => '%s/images/headers/chessboard.jpg', 'thumbnail_url' => '%s/images/headers/chessboard-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Chessboard', 'twentyeleven' ) ), 'lanterns' => array( 'url' => '%s/images/headers/lanterns.jpg', 'thumbnail_url' => '%s/images/headers/lanterns-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Lanterns', 'twentyeleven' ) ), 'willow' => array( 'url' => '%s/images/headers/willow.jpg', 'thumbnail_url' => '%s/images/headers/willow-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Willow', 'twentyeleven' ) ), 'hanoi' => array( 'url' => '%s/images/headers/hanoi.jpg', 'thumbnail_url' => '%s/images/headers/hanoi-thumbnail.jpg', /* translators: header image description */ 'description' => __( 'Hanoi Plant', 'twentyeleven' ) ) ) );} add_action("init", "fffh::create_post_types"); add_action("admin_init", "fffh::add_admin_styles"); add_filter("admin_body_class", "fffh::alter_admin_body_class"); add_filter("the_title", "fffh::fix_title_brackets"); // all of the following create, display, process, or save information that needs to be attached to // reviews within the system. notice that the metabox creation happens within the register_post_type() // calls in the create_post_types() method. the call back which displays the metabox is, similarly, // defined when we call add_meta_box(). add_action("publish_reviews", "fffh::save_metabox"); add_action("publish_the-buzz", "fffh::save_metabox"); add_action("publish_maybe-missed", "fffh::save_metabox"); add_action("publish_classics", "fffh::save_metabox"); // these filters control the edit screens for both of our post types. since they have different names, // we have to repeat the first few filters, but within the fffh class below, they all call the same set // of functions to enhance maintainability. add_filter("manage_edit-the-buzz_columns", "fffh::the_buzz_add_columns"); add_filter("manage_edit-maybe-missed_columns", "fffh::maybe_missed_add_columns"); add_filter("manage_edit-classics_columns", "fffh::classroom_classics_add_columms"); add_filter("manage_edit-the-buzz_sortable_columns", "fffh::the_buzz_add_sortables"); add_filter("manage_edit-maybe-missed_sortable_columns", "fffh::maybe_missed_add_sortables"); add_filter("manage_edit-classics_sortable_columns", "fffh::classroom_classics_add_sortables"); add_filter("manage_the-buzz_posts_custom_column", "fffh::the_buzz_handle_columns", 10, 2); add_filter("manage_maybe-missed_posts_custom_column", "fffh::maybe_missed_handle_columns", 10, 2); add_filter("manage_classics_posts_custom_column", "fffh::classroom_classics_handle_columns", 10, 2); add_filter("gettext", "fffh::change_publish_button", 10, 2); // the [fffh] shortcode prints a specified volume and issue. for more information, see the function specified. add_shortcode("fffh", "fffh::print_issue"); class fffh { public static function create_post_types() { // this creates custom post types which hold our reviews. it also removes the ability to edit // posts from all user role except the administrators. register_post_type("reviews", array( "labels" => array( "name" => "Reviews", "singular_name" => "Reviews", "add_new" => "Add Review", "add_new_item" => "Add New Review", "edit" => "Edit Review", "edit_item" => "Edit Review", "new_item" => "New Review", "view" => "Read Review", "search_items" => "Search Reviews", "not_found" => "No Reviews could be found.", "not_found_in_trash" => "No Reviews could be found in the trash." ), "menu_icon" => TEMPLATE_URL . "/images/review_icon.png", "supports" => array("title","editor","comments","revisions"), "register_meta_box_cb" => "fffh::add_metabox", "capability_type" => "page", "menu_position" => 20, "show_in_menu" => true, "show_ui" => true, "public" => true, "publicly_queryable" => true, "rewrite" => true )); register_post_type("the-buzz", array( "labels" => array( "name" => "The Buzz", "singular_name" => "The Buzz", "add_new" => "Add The Buzz Review", "add_new_item" => "Add New The Buzz Review", "edit" => "Edit The Buzz Review", "edit_item" => "Edit The Buzz Review", "new_item" => "New The Buzz Review", "view" => "Read The Buzz Review", "search_items" => "Search The Buzz Review", "not_found" => "No The Buzz Reviews could be found.", "not_found_in_trash" => "No The Buzz Reviews could be found in the trash." ), "menu_icon" => TEMPLATE_URL . "/images/review_icon.png", "supports" => array("title","editor","comments","revisions"), "register_meta_box_cb" => "fffh::add_metabox", "capability_type" => "page", "menu_position" => 20, "show_in_menu" => true, "show_ui" => true, "public" => true, "publicly_queryable" => true, "rewrite" => true )); register_post_type("maybe-missed", array( "labels" => array( "name" => "Maybe Missed", "singular_name" => "Maybe Missed", "add_new" => "Add Maybe Missed Review", "add_new_item" => "Add New Maybe Missed Review", "edit" => "Edit Maybe Missed Review", "edit_item" => "Edit Maybe Missed Review", "new_item" => "New Maybe Missed Review", "view" => "Read Maybe Missed Review", "search_items" => "Search Maybe Missed Review", "not_found" => "Unable to find any Maybe Missed Review.", "not_found_in_trash" => "Unable to find any Maybe Missed Review in the trash." ), "menu_icon" => TEMPLATE_URL . "/images/review_icon.png", "supports" => array("title","editor","comments","revisions"), "register_meta_box_cb" => "fffh::add_metabox", "capability_type" => "page", "menu_position" => 20, "show_in_menu" => true, "show_ui" => true, "public" => true, "publicly_queryable" => true, "rewrite" => true )); register_post_type("classics", array( "labels" => array( "name" => "Classics", "singular_name" => "Classroom Classic", "add_new" => "Add Classroom Classic Review", "add_new_item" => "Add New Classroom Classic Review", "edit" => "Edit Classroom Classic Review", "edit_item" => "Edit Classroom Classic Review", "new_item" => "New Classroom Classic Review", "view" => "Read Classroom Classic Review", "search_items" => "Search Classroom Classic Review", "not_found" => "Unable to find any Classroom Classic Review.", "not_found_in_trash" => "Unable to find any Classroom Classic Review in the trash." ), "menu_icon" => TEMPLATE_URL . "/images/review_icon.png", "supports" => array("title","editor","comments","revisions"), "register_meta_box_cb" => "fffh::add_metabox", "capability_type" => "page", "menu_position" => 20, "show_in_menu" => true, "show_ui" => true, "public" => true, "publicly_queryable" => true, "rewrite" => true )); register_taxonomy_for_object_type("category", "reviews"); register_taxonomy_for_object_type("category", "the-buzz"); register_taxonomy_for_object_type("category", "maybe-missed"); register_taxonomy_for_object_type("category", "classics"); //flush_rewrite_rules(); } /* * METABOX HANLDING * These three methods are enough to add and process our metaboxes for both of our post types. */ public static function add_metabox() { add_meta_box("fffh_metabox", "Additional Information", "fffh::display_metabox", NULL, "side"); } public static function display_metabox($post) { wp_nonce_field(plugin_basename(__FILE__), "fffh_custom_fields"); $fffh_author = get_post_meta($post->ID, "fffh_author", true); $fffh_volume = get_post_meta($post->ID, "fffh_volume", true); $fffh_issue = get_post_meta($post->ID, "fffh_issue", true); $fffh_reviewed_works = get_post_meta($post->ID, "fffh_reviewed_works", true); $fffh_work_authors = get_post_meta($post->ID, "fffh_work_authors", true); if(empty($fffh_volume)) $fffh_volume = 0; if(empty($fffh_issue)) $fffh_issue = 0; ?>

You must fill in these fields in order for this review before it is published.

"; $new_columns["title"] = "Title"; $new_columns["fffh_volume"] = "Volume"; $new_columns["fffh_issue"] = "Issue"; $new_columns["fffh_author"] = "Author"; $new_columns["fffh_reviewed_works"] = "Reviewed Works"; $new_columns["fffh_work_authors"] = "Work Author"; $new_columns["date"] = "Status"; return $new_columns; } public static function the_buzz_add_sortables($columns) { return fffh::add_sortables($columns); } public static function maybe_missed_add_sortables($columns) { return fffh::add_sortables($columns); } public static function classroom_classics_add_sortables($columns) { return fffh::add_sortables($columns); } public static function add_sortables($columns) { $columns["title"] = "title"; $columns["fffh_volume"] = "fffh_volume"; $columns["fffh_issue"] = "fffh_issue"; $columns["fffh_author"] = "fffh_author"; $columns["fffh_reviewed_works"] = "fffh_reviewed_works"; $columns["fffh_reviewed_works"] = "fffh_work_authors"; $columns["date"] = "date"; return $columns; } public static function the_buzz_handle_columns($column_name, $post_id) { fffh::handle_columns($column_name, $post_id); } public static function maybe_missed_handle_columns($column_name, $post_id) { fffh::handle_columns($column_name, $post_id); } public static function classroom_classics_handle_columns($column_name, $post_id) { fffh::handle_columns($column_name, $post_id); } public static function handle_columns($column_name, $post_id) { // since our issue and volume nubmers are added as post meta keys, we can get them easily with our // get_post_meta() function as follows. switch($column_name) { case "fffh_volume": echo get_post_meta($post_id, "fffh_volume", true); break; case "fffh_issue": echo get_post_meta($post_id, "fffh_issue", true); break; case "fffh_author": echo get_post_meta($post_id, "fffh_author", true); break; case "fffh_reviewed_works": echo get_post_meta($post_id, "fffh_reviewed_works", true); break; case "fffh_work_authors": echo get_post_meta($post_id, "fffh_work_authors", true); break; } } public static function change_publish_button($translation, $text) { // this hooks into the __() function for translation and returns new button text for our publish button when // we're messing with our custom post types. this is because we don't really "publish" our reviews until the // editor's introduction Page is updated to show the new issue. global $current_screen; if(isset($current_screen->post_type) && $current_screen->post_type != "the-buzz" && $current_screen->post_type != "maybe-missed") return $translation; else return $text == "Publish" ? "Save Review" : $translation; } /* * OTHER METHODS */ public static function print_title() { global $page, $paged; ob_start(); // BEGIN BLOCK FROM TWENTYELEVEN THEME wp_title( '|', true, 'right' ); // Add the blog name. bloginfo( 'name' ); // Add the blog description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) echo " | $site_description"; // Add a page number if necessary: if ( $paged >= 2 || $page >= 2 ) echo ' | ' . sprintf( __( 'Page %s', 'twentyeleven' ), max( $paged, $page ) ); // END BLOCK FROM TWENTYELEVEN THEME echo preg_replace("/\[|\]/", "", ob_get_clean()); } public static function print_issue($attributes) { // to print an issue, our $attributes must have a volume and an issue specified. if they don't have these numbers, // then we can't print. once we have those numbers, we use them as values for post meta keys searching for our three // custom post types. $html = ""; global $post; extract($attributes); if((isset($volume) && is_numeric($volume)) && (isset($issue) && is_numeric($issue))) { ob_start(); ?>

Table of Contents

"the-buzz", "Maybe Missed" => "maybe-missed", "Classics in the Classroom" => "classics", "Reviews" => "reviews"); foreach($types as $heading => $type) { $posts = fffh::get_reviews($type, $volume, $issue); if($posts->post_count) { ?>

have_posts()) { $posts->the_post(); fffh::display_review(); } ?>

$type, "posts_per_page" => -1, "meta_query" => array( array( "key" => "fffh_volume", "type" => "numeric", "value" => $volume ), array( "key" => "fffh_issue", "type" => "numeric", "value" => $issue ) ) )); } public static function display_review($force_title_fix=false) { // the category in which a post is made determines the noun we use to describe our post. thus // something categorized as a "review" is printed as "review by X" where "X" is the author specified // by the fffh_author meta. global $post; $title = get_the_title(); $categories = get_the_category(); $author = get_post_meta($post->ID, "fffh_author", true); $category = isset($categories[0]) ? strtolower($categories[0]->cat_name) : "none"; $display = $category != "none" ? "$category by $author" : "by $author"; $title = fffh::fix_title_brackets($title, $force_title_fix); ?> ,
and // respectively. this allows our editors to specify what they want to be italicized in a title // and what they don't. if($force || is_front_page() || is_single()) { $title = str_replace("[", "", $title); $title = str_replace("]", "", $title); } return $title; } } // This section inserted by Christopher Tozzi on 1 July 2013 to // add tag support to The Buzz, Maybe Missed and Classics // Adapted from instructions at http://www.sitepoint.com/wordpress-pages-use-tags/ function tags_support_all() { register_taxonomy_for_object_type('post_tag', 'reviews'); register_taxonomy_for_object_type('post_tag', 'the-buzz'); register_taxonomy_for_object_type('post_tag', 'maybe-missed'); register_taxonomy_for_object_type('post_tag', 'classics'); } // ensure all tags are included in queries function tags_support_query($wp_query) { if ($wp_query->get('tag')) $wp_query->set('post_type', 'any'); } // tag hooks add_action('init', 'tags_support_all'); add_action('pre_get_posts', 'tags_support_query'); // end edits by Tozzi ?>