Permalink
Browse files

Working copy 20110122

  • Loading branch information...
1 parent 4c59694 commit e0d794c9e03758e8cb8922f5ca77372a59d8c018 @chipbennett committed Jan 23, 2011
View
34 comments.php
@@ -57,7 +57,9 @@
}
?>
-<h3>Comments</h3>
+<h3>Comments <?php if ( ! comments_open() ) { ?> <small>(Comments are closed)</small><?php } ?></h3>
+
+
<?php $i = 0; ?>
<span id="comments-responses" style="font-weight:bold;"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to &#8220;<?php the_title(); ?>&#8221;</span>
@@ -67,13 +69,15 @@
<div class="nav-previous"><?php previous_comments_link( '<span class="meta-nav">&larr;</span> Older Comments' ); ?></div>
<div class="nav-next"><?php next_comments_link( 'Newer Comments <span class="meta-nav">&rarr;</span>' ); ?></div>
</div> <!-- .navigation -->
-<?php endif; // check for comment navigation ?>
-
+<?php endif; // check for comment navigation
+
+ if ( get_comments_number() > '0' ) { ?>
<ol class="commentlist">
<?php wp_list_comments( 'type=comment&avatar_size=40' ); ?>
</ol>
+ <?php }
-<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
+ if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?>
<div class="navigation">
<div class="nav-previous"><?php previous_comments_link( '<span class="meta-nav">&larr;</span> Older Comments' ); ?></div>
<div class="nav-next"><?php next_comments_link( 'Newer Comments <span class="meta-nav">&rarr;</span>' ); ?></div>
@@ -82,15 +86,6 @@
<?php else : // or, if we don't have comments:
- /* If there are no comments and comments are closed,
- * let's leave a little note, shall we?
- */
- if ( ! comments_open() ) :
-?>
- <p class="nocomments"><?php echo 'Comments are closed.'; ?></p>
-<?php
-endif; // end ! comments_open()
-
endif; // end have_comments()
comment_form();
@@ -175,6 +170,19 @@
get_comment_link() must be used from within the Loop, unless the $comment parameter is used.
***********************
+get_comments_number()
+----------------------------------
+get_comments_number() is a WordPress template tag.
+Codex reference: http://codex.wordpress.org/Template_Tags/get_comments_number
+
+get_comments_number() is used to return the number (as a numeric value) of comments (including
+comments, trackbacks, and pingbacks) on the current post.
+
+get_comments_number() accepts no arguments
+
+get_comments_number() must be used within the Loop.
+
+***********************
get_comment_pages_count()
----------------------------------
get_comment_pages_count() is a WordPress function.
View
1,110 functions.php
@@ -1,1065 +1,41 @@
<?php
-add_action( 'after_setup_theme', 'oenology_setup', 10 );
-add_action( 'after_setup_theme', 'oenology_setup_widgets', 11 );
-if ( ! function_exists( 'oenology_setup' ) ):
+// functions-theme-setup.php includes all of the various Theme setup:
+// add_theme_support()
+// $content_width
+// Define custom image sizes, custom headers, nav menus
+require_once( 'functions/functions-theme-setup.php' );
+
+// functions-custom.php includes all of the Theme's custom functions
+// filter wp_title
+// filter comment_count
+// Custom footer copyright notice
+// Gallery image links and metadata handling
+// 404 error handling
+// current-cat CSS class
+// navigation breadcrumb
+require_once( 'functions/functions-custom.php' );
+
+// functions-widgets.php includes the Theme's Widgetized sidebars and custom Widgets
+// register_sidebar
+// define custom widgets
+// register_widget
+require_once( 'functions/functions-widgets.php' );
+
+// functions-options.php includes the Theme options and Admin Settings page
+// Define default Theme Options
+// Register/Initialize Theme Options
+// Admin Settings Page
+// Contextual Help
+//require_once( TEMPLATEPATH . '/functions/functions-options.php' );
-function oenology_setup() {
-
-/*****************************************************************************************
-* Add theme support for various WordPress features
-*******************************************************************************************/
-
-// Automatically add RSS feed links to document header (since WP 2.9.0)
-add_theme_support('automatic-feed-links');
-
-// Post Thumbnails (since WP 2.9.0)
-add_theme_support('post-thumbnails');
-set_post_thumbnail_size( 150, 150, true ); // default dimensions for "thumbnail" image size
-add_image_size( 'post-title-thumbnail', 55, 55, true ); // Post Title thumbnail size (55px x 55px)
-add_image_size( 'attachment-nav-thumbnail', 45, 45, true ); // Gallery Navigation image thumbnail size (55px x 55px)
-
-// Custom Backgrounds (since WP 3.0.0)
-add_custom_background();
-
-// Custom Header Image (since WP 3.0.0)
-add_custom_image_header( 'oenology_header_style', 'oenology_admin_header_style' );
-
-// Custom WYSIWIG Editor Style (since WP 3.0.0)
-add_editor_style();
-
-
-/*****************************************************************************************
-* Define content_width, to keep images from overflowing.
-*******************************************************************************************/
-
-if ( ! isset( $content_width ) ) {
- $content_width = 640;
-}
-//$GLOBALS['content_width'] = 640;
-
-
-/*****************************************************************************************
-* Define Custom Headers (since WordPress 3.0)
-*******************************************************************************************/
-
-// Your changeable header business starts here
-define( 'HEADER_TEXTCOLOR', '000000' ); // Hex color value, without leading octothorpe (#)
-define('HEADER_IMAGE', get_stylesheet_directory_uri() . '/images/headers/pxwhite.jpg'); // Default header image to use
-define( 'HEADER_IMAGE_WIDTH', apply_filters( 'oenology_header_image_width', 1000 ) ); // Width to which WordPress will crop uploaded header images
-define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'oenology_header_image_height', 198 ) ); // Height to which WordPress will crop uploaded header images
-define( 'NO_HEADER_TEXT', false ); // Allow text inside the header image.
-
-// Add a way for the custom header to be styled in the admin panel that controls
-// custom headers. See oenology_admin_header_style(), below.
-
-// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
- register_default_headers( array(
- 'berries' => array(
- 'url' => '%s/../twentyten/images/headers/berries.jpg',
- 'thumbnail_url' => '%s/../twentyten/images/headers/berries-thumbnail.jpg',
- 'description' => 'Berries'
- ),
- 'cherryblossom' => array(
- 'url' => '%s/../twentyten/images/headers/cherryblossoms.jpg',
- 'thumbnail_url' => '%s/../twentyten/images/headers/cherryblossoms-thumbnail.jpg',
- 'description' => 'Cherry Blossoms'
- ),
- 'concave' => array(
- 'url' => '%s/../twentyten/images/headers/concave.jpg',
- 'thumbnail_url' => '%s/../twentyten/images/headers/concave-thumbnail.jpg',
- 'description' => 'Concave'
- ),
- 'fern' => array(
- 'url' => '%s/../twentyten/images/headers/fern.jpg',
- 'thumbnail_url' => '%s/../twentyten/images/headers/fern-thumbnail.jpg',
- 'description' => 'Fern'
- ),
- 'forestfloor' => array(
- 'url' => '%s/../twentyten/images/headers/forestfloor.jpg',
- 'thumbnail_url' => '%s/../twentyten/images/headers/forestfloor-thumbnail.jpg',
- 'description' => 'Forest Floor'
- ),
- 'inkwell' => array(
- 'url' => '%s/../twentyten/images/headers/inkwell.jpg',
- 'thumbnail_url' => '%s/../twentyten/images/headers/inkwell-thumbnail.jpg',
- 'description' => 'Inkwell', 'oenology'
- ),
- 'path' => array(
- 'url' => '%s/../twentyten/images/headers/path.jpg',
- 'thumbnail_url' => '%s/../twentyten/images/headers/path-thumbnail.jpg',
- 'description' => 'Path'
- ),
- 'sunset' => array(
- 'url' => '%s/../twentyten/images/headers/sunset.jpg',
- 'thumbnail_url' => '%s/../twentyten/images/headers/sunset-thumbnail.jpg',
- 'description' => 'Sunset'
- )
- ) );
-
-if ( ! function_exists( 'oenology_header_style' ) ) :
-
-function oenology_header_style() {
-?>
-<style type="text/css">
-/* Sets header image as background for div#header */
-#header {
- background:url('<?php header_image(); ?>') no-repeat left top;
-}
-</style>
-<?php
-}
-
-endif;
-
-if ( ! function_exists( 'oenology_admin_header_style' ) ) :
-
-function oenology_admin_header_style() {
-?>
-<style type="text/css">
- #headimg {
- width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
- height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
- }
-</style>
-<?php
-}
-
-endif;
-
-/*****************************************************************************************
-* Define Nav Menus (since WordPress 3.0)
-*******************************************************************************************/
-
-// This theme uses wp_nav_menu() in two locations: main site navigation, and left-colum page navigation.
- register_nav_menus( array(
- 'nav-header' => 'Header Navigation',
- 'nav-sidebar' => 'Sidebar Navigation',
- ) );
-
-
-} // function oenology_setup()
-
-endif; // function_exists('oenology_setup')
-
-
-/*****************************************************************************************
-* Filter wp_theme function
-*******************************************************************************************/
-
-function oenology_filter_wp_title( $title, $separator ) { // taken from TwentyTen 1.0
- // Don't affect wp_title() calls in feeds.
- if ( is_feed() )
- return $title;
-
- // The $paged global variable contains the page number of a listing of posts.
- // The $page global variable contains the page number of a single post that is paged.
- // We'll display whichever one applies, if we're not looking at the first page.
- global $paged, $page;
-
- if ( is_search() ) {
- // If we're a search, let's start over:
- $title = sprintf( 'Search results for %s', '"' . get_search_query() . '"' );
- // Add a page number if we're on page 2 or more:
- if ( $paged >= 2 )
- $title .= " $separator " . sprintf( 'Page %s', $paged );
- // Add the site name to the end:
- $title .= " $separator " . get_bloginfo( 'name', 'display' );
- // We're done. Let's send the new title back to wp_title():
- return $title;
- }
-
- // Otherwise, let's start by adding the site name to the end:
- $title .= get_bloginfo( 'name', 'display' );
-
- // If we have a site description and we're on the home/front page, add the description:
- $site_description = get_bloginfo( 'description', 'display' );
- if ( $site_description && ( is_home() || is_front_page() ) )
- $title .= " $separator " . $site_description;
-
- // Add a page number if necessary:
- if ( $paged >= 2 || $page >= 2 )
- $title .= " $separator " . sprintf( 'Page %s', max( $paged, $page ) );
-
- // Return the new title to wp_title():
- return $title;
-}
-add_filter( 'wp_title', 'oenology_filter_wp_title', 10, 2 );
-
-
-/*****************************************************************************************
-* Display correct number of comments (count only comments, not trackbacks/pingbacks)
-*******************************************************************************************/
-
-// filter get_comments_number() to return only the number of comments (excluding trackbacks/pingbacks)
-// http://www.wpbeginner.com/wp-tutorials/display-the-most-accurate-comment-count-in-wordpress/
-function oenology_comment_count( $count ) {
-if ( ! is_admin() ) {
-global $id;
-$comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id));
-return count($comments_by_type['comment']);
-} else {
-return $count;
-}
-}
-add_filter('get_comments_number', 'oenology_comment_count', 0);
-
-/*****************************************************************************************
-* Display copyright notice customized according to date of first post
-*******************************************************************************************/
-
-function oenology_copyright() {
-global $wpdb;
-$copyright_dates = $wpdb->get_results("
-SELECT
-YEAR(min(post_date_gmt)) AS firstdate,
-YEAR(max(post_date_gmt)) AS lastdate
-FROM
-$wpdb->posts
-WHERE
-post_status = 'publish'
-");
-$output = '';
-if($copyright_dates) {
-$copyright = "&copy; " . $copyright_dates[0]->firstdate;
-if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
-$copyright .= '-' . $copyright_dates[0]->lastdate;
-}
-$output = $copyright;
-}
-return $output;
-}
-
-
-/*****************************************************************************************
-* Image Handling for gallery previous/next links
-*******************************************************************************************/
-
-// function needed because WP gives no easy way to display both image and text in prev/next links.
-function oenology_gallery_links() {
- global $post;
- $post = get_post($post);
- $attachments = array_values(get_children("post_parent=$post->post_parent&post_type=attachment&post_mime_type=image&orderby=menu_order ASC, ID ASC"));
-
- foreach ( $attachments as $k => $attachment )
- if ( $attachment->ID == $post->ID )
- break;
-
- $links = array( 'prevlink' => '', 'prevthumb' => '', 'nextlink' => '', 'nextthumb' => '' );
-
- if ( isset($attachments[$k+1]) ) {
- $links['prevlink'] = get_permalink($attachments[$k+1]->ID);
- $links['prevthumb'] = wp_get_attachment_link($attachments[$k+1]->ID, 'attachment-nav-thumbnail', true);
- }
-
- if ( isset($attachments[$k-1]) ) {
- $links['nextlink'] = get_permalink($attachments[$k-1]->ID);
- $links['nextthumb'] = wp_get_attachment_link($attachments[$k-1]->ID, 'attachment-nav-thumbnail', true);
- }
-
- return $links;
-}
-
-/*****************************************************************************************
-* Image Handling for gallery image metadata
-*******************************************************************************************/
-
-function oenology_gallery_image_meta() {
- global $post;
- $post = get_post($post);
- $m = get_post_meta($post->ID, '_wp_attachment_metadata' , true);
- $image = wp_get_attachment_image( $post->ID, 'large' );
- $url = wp_get_attachment_url($post->ID);
- $uploaddir = wp_upload_dir();
- $imagesize = size_format( filesize($uploaddir['basedir'].'/'.$m['file']) );
- $image_meta = array (
- 'image' => $image,
- 'url' => $url,
- 'width' => $m['width'],
- 'height' => $m['height'],
- 'dimensions' => false,
- 'filesize' => $imagesize,
- 'created_timestamp' => $m['image_meta']['created_timestamp'],
- 'copyright' => $m['image_meta']['copyright'],
- 'credit' => $m['image_meta']['credit'],
- 'aperture' => $m['image_meta']['aperture'],
- 'focal_length' => $m['image_meta']['focal_length'],
- 'iso' => $m['image_meta']['iso'],
- 'shutter_speed' => $m['image_meta']['shutter_speed'],
- 'camera' => $m['image_meta']['camera'],
- 'caption' => '(No caption provided.)'
- );
- // image dimensions handler
- if ( $m['width'] && $m['height'] ) {
- $image_meta['dimensions'] = $m['width'] . '&#215;' . $m['height'] . ' px';
- }
- // image created_timestamp handler
- if ( $m['image_meta']['created_timestamp'] ) {
- $image_meta['created_timestamp'] = date( 'm M Y', $m['image_meta']['created_timestamp'] );
- }
- // image aperture handler
- if ( $m['image_meta']['aperture'] ) {
- $image_meta['aperture'] = 'f/' . $m['image_meta']['aperture'];
- }
- // shutter speed handler
- if ( ( $m['image_meta']['shutter_speed'] != '0' ) && ( ( 1 / $m['image_meta']['shutter_speed'] ) > 1 ) ) {
- $image_meta['shutter_speed'] = "1/";
- if (number_format((1 / $m['image_meta']['shutter_speed']), 1) == number_format((1 / $m['image_meta']['shutter_speed']), 0)) {
- $image_meta['shutter_speed'] = $image_meta['shutter_speed'] . number_format((1 / $m['image_meta']['shutter_speed']), 0, '.', '') . ' sec';
- } else {
- $image_meta['shutter_speed'] = $image_meta['shutter_speed'] . number_format((1 / $m['image_meta']['shutter_speed']), 1, '.', '') . ' sec';
- }
- } else {
- $image_meta['shutter_speed'] = $m['image_meta']['shutter_speed'].' sec';
- }
- // image caption handler
- if ( !empty($post->post_excerpt) ) {
- $image_meta['caption'] = get_the_excerpt(); // this is the "caption"
- }
- return $image_meta;
-}
-
-
-/*****************************************************************************************
-* 404 error handling
-*******************************************************************************************/
-
-function oenology_404_handler() {
-
- if ( !is_404() )
- return;
-
- // array to hold suggestions
- if ( ! isset ( $oenology404suggestions ) ) {
- $oenology404postsuggestions = false;
- $oenology404pagesuggestions = false;
- }
-
- // Extract search term from URL
- $patterns_array[] = "/?(trackback|feed|page[0-9]*)/?$";
- $patterns_array[] = "\.html$";
- $patterns_array = array_map(create_function('$a', '$sep = (strpos($a, "@") === false ? "@" : "%"); return $sep.trim($a).$sep."i";'), $patterns_array);
-
- $search = preg_replace( $patterns_array, "", urldecode( $_SERVER["REQUEST_URI"] ) );
- $search = basename(trim($search));
- $search = preg_replace( $patterns_array, "", $search);
- $search_words = preg_replace( "@[_-]@", " ", $search);
-
- // Search for posts
- $posts = get_posts( array( "s" => $search_words ) );
- $oenology404postsuggestions = $posts;
-
- // Search for pages
- $pages = get_posts( array( "s" => $search_words, "post_type" => "page" ) );
- $oenology404pagesuggestions = $pages;
-
- $oenology404suggestions = array_merge ( $oenology404postsuggestions, $oenology404pagesuggestions );
- $oenology404nopostsorpages = true;
- if ( !isset ( $oenology404suggestions ) || !is_array( $oenology404suggestions ) || count( $oenology404suggestions ) == 0 ) {
- $oenology404nopostsorpages = true;
- } else {
- $oenology404nopostsorpages = false;
- ?>
- <p>Let me try to make it up to you!</p>
- <?php
- // Display list of post suggestions
- $suggestedposts = $oenology404postsuggestions;
- if ( $suggestedposts > 0 ) {
- ?>
- <p>Here is a list of posts that you might have been looking for:</p>
- <ul class="oenology404_suggestions">
- <?php
- foreach ( $suggestedposts as $suggestedpost ) { ?>
- <li>
- <span style="text-transform:uppercase;"><?php echo $suggestedpost->post_type; ?></span>: <a href="<?php echo get_permalink($suggestedpost->ID); ?>"><?php echo $suggestedpost->post_title; ?></a>
- <blockquote>
- <?php
- if (empty($suggestedpost->post_excerpt)) {
- $suggestedpost->post_excerpt = explode(" ",strrev(substr(strip_tags($suggestedpost->post_content), 0, 300)),2);
- $suggestedpost->post_excerpt = strrev($suggestedpost->post_excerpt[1]);
- $suggestedpost->post_excerpt.= " [...]";
- }
- if ($suggestedpost->post_excerpt) {
- echo $suggestedpost->post_excerpt;
- } else {
- echo 'No excerpt available.';
- }
- ?>
- </blockquote>
- </li>
- <?php } ?>
- </ul>
- <?php
- }
- // Display list of page suggestions
- $suggestedpages = $oenology404pagesuggestions;
- if ( $suggestedpages > 0 ) {
- ?>
- <p>Here is a list of pages that you might have been looking for:</p>
- <ul class="oenology404_suggestions">
- <?php
- foreach ( $suggestedpages as $suggestedpage ) { ?>
- <li>
- <span style="text-transform:uppercase;"><?php echo $suggestedpage->post_type; ?></span>: <a href="<?php echo get_permalink($suggestedpage->ID); ?>"><?php echo $suggestedpage->post_title; ?></a>
- <blockquote>
- <?php
- if (empty($suggestedpage->post_excerpt)) {
- $suggestedpage->post_excerpt = explode(" ",strrev(substr(strip_tags($suggestedpage->post_content), 0, 300)),2);
- $suggestedpage->post_excerpt = strrev($suggestedpage->post_excerpt[1]);
- $suggestedpage->post_excerpt.= " [...]";
- }
- if ($suggestedpage->post_excerpt) {
- echo $suggestedpage->post_excerpt;
- } else {
- echo 'No excerpt available.';
- }
- ?>
- </blockquote>
- </li>
- <?php } ?>
- </ul>
- <?php
- }
- }
-
- // See if we've matched a category
- $oenology404nocategories = true;
- $categories = get_categories( array ( "name__like" => $search ) );
- if ( count($categories) > 0) {
- $oenology404nocategories = false;
- ?>
- <p>Perhaps you were looking for something in one of the following categories?</p>
- <ul class="oenology404_suggestions">
- <?php foreach ( $categories as $category ) { ?>
- <li><a href="<?php get_category_link($category->term_id); ?>"><?php echo $category->name; ?></a></li>
- <?php } ?>
- </ul>
- <?php }
- // See if we've matched a tag
- $oenology404notags = true;
- $tags = get_tags( array ( "name__like" => $search ) );
- if ( count($tags) > 0) {
- $oenology404notags = false;
- ?>
- <p>Perhaps you were looking for something with one of the following tags?</p>
- <ul class="oenology404_suggestions">
- <?php foreach ( $tags as $tag ) { ?>
- <li><a href="<?php get_tag_link($tag->term_id); ?>"><?php echo $tag->name; ?></a></li>
- <?php } ?>
- </ul>
- <?php }
-
- $oenology404noresults = false;
- if ( $oenology404nopostsorpages && $oenology404nocategories && $oenology404notags ) {
- $oenology404noresults = true;
- }
-
- if ( $oenology404noresults ) { ?>
- <p>I'm sorry. For the life of me, I can't figure out what you were trying to find. Perhaps try searching, using the search form in the upper right-hand corner?</p>
- <?php }
-}
-
-
-/*****************************************************************************************
-* Add a "current-cat" CSS class declaration
-*******************************************************************************************/
-
-/* Credit: StudioGrasshopper
-* http://www.studiograsshopper.ch/code-snippets/dynamic-category-menu-highlighting-for-single-posts/
-*/
-function oenology_show_current_cat_on_single($output) {
-
- global $post;
-
- if( is_single() ) {
-
- $categories = wp_get_post_categories($post->ID);
-
- foreach( $categories as $catid ) {
- $cat = get_category($catid);
- // Find cat-item-ID in the string
- if(preg_match('#cat-item-' . $cat->cat_ID . '#', $output)) {
- $output = str_replace('cat-item-'.$cat->cat_ID, 'cat-item-'.$cat->cat_ID . ' current-cat', $output);
- }
- }
-
- }
- return $output;
-}
-add_filter('wp_list_categories', 'oenology_show_current_cat_on_single');
-
-
-/*****************************************************************************************
-* Add navigation breadcrumb function
-*******************************************************************************************/
-
-/* Credit: Dimox
-* http://dimox.net/wordpress-breadcrumbs-without-a-plugin/
-*/
-function oenology_breadcrumb() {
-
- $containerBefore = '<li id="breadcrumbs">';
- $containerAfter = '</li>';
- $containerCrumb = '<div class="crumbs">';
- $containerCrumbEnd = '</div>';
- $delimiter = ' &raquo; ';
- $name = 'Home'; //text for the 'Home' link
- $baseLink = '';
- $hierarchy = '';
- $currentLocation = '';
- $currentBefore = '<strong>';
- $currentAfter = '</strong>';
- $currentLocationLink = '';
- $crumbPagination = '';
-
- // Start of Container
- echo $containerBefore;
-// Start of Breadcrumbs
- echo $containerCrumb;
-
-// Output the Base Link
- global $post;
- $home = home_url('/');
- $baseLink = '<a href="' . $home . '">' . $name . '</a>';
- echo $baseLink;
-
- // Define Breadcrumb Hierarchy and Current Location for various page types
-
- if ( is_category() ) { // Define Category Hierarchy Crumbs for Category Archive
- global $wp_query;
- $cat_obj = $wp_query->get_queried_object();
- $thisCat = $cat_obj->term_id;
- $thisCat = get_category($thisCat);
- $parentCat = get_category($thisCat->parent);
- if ($thisCat->parent != 0) {
- $hierarchy = ($delimiter . get_category_parents($parentCat, TRUE, $delimiter));
- } else {
- $hierarchy = $delimiter;
- }
- $currentLocation = single_cat_title( '' , FALSE ); // Set $currentLocation to the current category
-
- } elseif ( is_day() ) { // Define Year/Month Hierarchy Crumbs for Day Archive
- $hierarchy = $delimiter . 'Posts Published in: <a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ' . '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
- $currentLocation = get_the_time('d');
-
- } elseif ( is_month() ) { // Define Year Hierarchy Crumb for Month Archive
- $hierarchy = $delimiter . 'Posts Published in: <a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
- $currentLocation = get_the_time('F');
-
- } elseif ( is_year() ) { // Set CurrentLocation for Year Archive
- $hierarchy = $delimiter . 'Posts Published in: ';
- $currentLocation = get_the_time('Y');
-
- } elseif ( is_single() && !is_attachment() ) { // Define Category Hierarchy Crumbs for Single Posts
- $cat = get_the_category();
- $cat = $cat[0];
- $hierarchy = $delimiter . get_category_parents( $cat, TRUE, $delimiter );
- $currentLocation = ( get_the_title() ? get_the_title() : '(No Post Title)' );
-
- } elseif ( is_attachment() ) { // Define Category and Parent Post Crumbs for Post Attachments
- $parent = get_post($post->post_parent);
- $cat_parents = '';
- if ( get_the_category($parent->ID) ) {
- $cat = get_the_category($parent->ID);
- $cat = $cat[0];
- $cat_parents = get_category_parents( $cat, TRUE, $delimiter );
- }
- $hierarchy = $delimiter . $cat_parents . '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a> ' . $delimiter;
- $currentLocation = ( get_the_title() ? get_the_title() : '(No Attachment Title)' );
-
- } elseif ( is_page() && !$post->post_parent ) { // Define Current Location for Parent Pages
- $hierarchy = $delimiter;
- $currentLocation = ( get_the_title() ? get_the_title() : '(No Page Title)' );
-
- } elseif ( is_page() && $post->post_parent ) { // Define Parent Page Hierarchy Crumbs for Child Pages
- $parent_id = $post->post_parent;
- $breadcrumbs = array();
- while ($parent_id) {
- $page = get_page($parent_id);
- $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
- $parent_id = $page->post_parent;
- }
- $breadcrumbs = array_reverse($breadcrumbs);
- foreach ($breadcrumbs as $crumb) {
- $hierarchy = $hierarchy . $delimiter . $crumb;
- }
- $hierarchy = $hierarchy . $delimiter;
- $currentLocation = ( get_the_title() ? get_the_title() : '(No Page Title)' );
-
- } elseif ( is_search() ) { // Define current location for Search Results page
- $hierarchy = $delimiter . 'Search Results: ';
- $currentLocation = get_search_query();
-
- } elseif ( is_tag() ) { // Define current location for Tag Archives
- $hierarchy = $delimiter . 'Posts Tagged as: ';
- $currentLocation = single_tag_title( '' , FALSE );
-
-
- } elseif ( is_author() ) { // Define current location for Author Archives
- global $author;
- $userdata = get_userdata($author);
- $hierarchy = $delimiter . 'Posts Written by: ';
- $currentLocation = $userdata->display_name;
-
- } elseif ( is_404() ) { // Define current location for 404 Error page
- $hierarchy = $delimiter . 'Error 404: ';
- $currentLocation = 'Page Not Found';
- }
-
-// Build the Current Location Link markup
- $currentLocationLink = $currentBefore . $currentLocation . $currentAfter;
-
-// Define breadcrumb pagination
-
-// Define pagination for paged Archive pages
- if ( get_query_var('paged') && ! function_exists( 'wp_paginate' ) ) {
- $crumbPagination = ' (Page ' . get_query_var('paged') . ')';
- }
-
- // Define pagination for Paged Posts and Pages
- if ( get_query_var('page') ) {
- $crumbPagination = ' (Page ' . get_query_var('page') . ') ';
- }
-
-// Output the resulting Breadcrumbs
-
- echo $hierarchy; // Output Hierarchy
- echo $currentLocationLink; // Output Current Location
- echo $crumbPagination; // Output page number, if Post or Page is paginated
- echo $containerCrumbEnd; // End of BreadCrumbs
-
- // Start of Pagination
- if ( ! is_singular() ) {
- if ( function_exists( 'wp_paginate' ) ) {
- wp_paginate( 'title=' );
- } else {
- echo '<div class="postsnavlinks">';
- posts_nav_link( '&nbsp;' , '&larr;' , '&rarr;' );
- echo '</div>';
- }
- }
-
- if ( is_single() && ! is_attachment() ) {
- echo '<div class="prevnextpostlinks">';
- next_post_link( '%link', '&lArr; ' );
- previous_post_link( '%link', ' &rArr;' );
- echo '</div>';
- }
-
- echo $containerAfter; // End of Container
-
-}
-
-
-/*****************************************************************************************
-* Widget Functions
-*
-* - Register Widget Areas (Sidebars)
-* - Define Widgets
-* - Register Widgets
-*******************************************************************************************/
-
-function oenology_setup_widgets() {
-
-/*****************************************************************************************
-* Register all widget areas (sidebars) (since WordPress 2.8)
-*******************************************************************************************/
-if ( function_exists('register_sidebar') ) {
-register_sidebar(array( // Left Column widget area
-'name'=>'sidebar-left',
-'description' => 'Left-column; widget area for blog info (feeds, archives, etc.).',
-'before_widget' => '<div id="%1$s" class="widget %2$s">',
-'after_widget' => '</div>',
-'before_title' => '<div class="title widgettitle">',
-'after_title' => '</div>',
-));
-register_sidebar(array( // Right Column widget area
-'name'=>'sidebar-right',
-'description' => 'Right-column; widget area for miscellaneous.',
-'before_widget' => '',
-'after_widget' => '',
-'before_title' => '<div class="title">',
-'after_title' => '</div>',
-));
-}
-
-} // function oenology_widget_setup()
-
-
-/* Define all widgets
-**********************************************************/
-
-/* oenology_widget_recentposts */
-
-class oenology_widget_recentposts extends WP_Widget {
-
- function oenology_widget_recentposts() {
- $widget_ops = array('classname' => 'oenology-widget-recentposts', 'description' => 'oenology theme widget to display recent posts in the left column' );
- $this->WP_Widget('oenology_recentposts', 'oenology Recent Posts', $widget_ops);
- }
-
- function widget( $args, $instance ) {
- extract($args);
- $title = apply_filters( 'widget_title', empty($instance['title']) ? 'oenology Recent Posts' : $instance['title'] );
-
- echo $before_widget;
- if ( $title )
- echo $before_title . $title . $after_title;
-?>
-
-<!-- Begin Recent Posts -->
-<span>Click to <span style="color:#5588aa;" onclick="document.getElementById('arch01').style.display='inline';">view</span> / <span style="color:#5588aa;" onclick="document.getElementById('arch01').style.display='none';">hide</span>
-</span>
-<br /><br />
-<div id="arch01" style="display:none;">
- <ul class="listrecentposts">
- <?php wp_get_archives('type=postbypost&limit=20'); ?>
- </ul>
-</div>
-<!-- End Recent Posts -->
-
-<?php
- echo $after_widget;
- }
-
- function update( $new_instance, $old_instance ) {
- $instance = $old_instance;
- $instance['title'] = strip_tags($new_instance['title']);
-
- return $instance;
- }
-
- function form( $instance ) {
- $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
- $title = strip_tags($instance['title']);
-?>
- <p><label for="<?php echo $this->get_field_id('title'); ?>">Title:</label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
-<?php
- }
-}
-
-/* oenology_widget_archives */
-
-class oenology_widget_archives extends WP_Widget {
-
- function oenology_widget_archives() {
- $widget_ops = array('classname' => 'oenology-widget-archives', 'description' => 'oenology theme widget to display archives in the left column' );
- $this->WP_Widget('oenology_archives', 'oenology Archives', $widget_ops);
- }
-
- function widget( $args, $instance ) {
- extract($args);
- $title = apply_filters('widget_title', empty($instance['title']) ? 'oenology Archives' : $instance['title']);
-
- echo $before_widget;
- if ( $title )
- echo $before_title . $title . $after_title;
-?>
-
-<!-- Begin Archives -->
-<span>Click to <span style="color:#5588aa;" onclick="document.getElementById('arch02').style.display='inline';">view</span> / <span style="color:#5588aa;" onclick="document.getElementById('arch02').style.display='none';">hide</span>
-</span>
-<br /><br />
-<div id="arch02" style="display:none;">
- <ul class="listarchives">
- <?php wp_get_archives('type=monthly&show_post_count=1'); ?>
- </ul>
-</div>
-<!-- End Archives -->
-
-<?php
- echo $after_widget;
- }
-
- function update( $new_instance, $old_instance ) {
- $instance = $old_instance;
- $instance['title'] = strip_tags($new_instance['title']);
-
- return $instance;
- }
-
- function form( $instance ) {
- $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
- $title = strip_tags($instance['title']);
-?>
- <p><label for="<?php echo $this->get_field_id('title'); ?>">Title:</label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
-<?php
- }
-}
-
-/* oenology_widget_categories */
-
-class oenology_widget_categories extends WP_Widget {
-
- function oenology_widget_categories() {
- $widget_ops = array('classname' => 'oenology-widget-categories', 'description' => 'oenology theme widget to display the category list in the left column' );
- $this->WP_Widget('oenology_categories', 'oenology Categories', $widget_ops);
- }
-
- function widget( $args, $instance ) {
- extract($args);
- $title = apply_filters('widget_title', empty($instance['title']) ? 'oenology Categories' : $instance['title']);
-
- echo $before_widget;
- if ( $title )
- echo $before_title . $title . $after_title;
-?>
-
-<!-- Begin Categories -->
-<span>Click to <span style="color:#5588aa;" onclick="document.getElementById('arch03').style.display='inline';">view</span> / <span style="color:#5588aa;" onclick="document.getElementById('arch03').style.display='none';">hide</span>
-</span>
-<br /><br />
-<div id="arch03" style="display:none;">
- <ul class="leftcolcatlist">
-
- <?php
- $catrssimg = "/images/rss.png";
- $catrssurl = get_template_directory_uri() . $catrssimg;
- $customcatlist ='';
- $customcats= get_categories();
- foreach($customcats as $customcat) {
- $customcatlist = '<li><a title="Subscribe to the '.$customcat->name.' news feed" href="'.home_url().'/category/'.$customcat->category_nicename.'/feed/"><img src="'.$catrssurl.'" alt="feed" /></a><a href="'.home_url().'/category/'.$customcat->category_nicename.'/">'.$customcat->name.'</a> ('.$customcat->count.')</li>';
- echo $customcatlist;
- }
- ?>
-
- </ul>
-</div>
-<!-- End Categories -->
-
-<?php
- echo $after_widget;
- }
-
- function update( $new_instance, $old_instance ) {
- $instance = $old_instance;
- $instance['title'] = strip_tags($new_instance['title']);
-
- return $instance;
- }
-
- function form( $instance ) {
- $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
- $title = strip_tags($instance['title']);
-?>
- <p><label for="<?php echo $this->get_field_id('title'); ?>">Title:</label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
-<?php
- }
-}
-
-/* oenology_widget_tags */
-
-class oenology_widget_tags extends WP_Widget {
-
- function oenology_widget_tags() {
- $widget_ops = array('classname' => 'oenology-widget-tags', 'description' => 'oenology theme widget to display the tag list in the left column' );
- $this->WP_Widget('oenology_tags', 'oenology Tags', $widget_ops);
- }
-
- function widget( $args, $instance ) {
- extract($args);
- $title = apply_filters('widget_title', empty($instance['title']) ? 'oenology Tags' : $instance['title']);
-
- echo $before_widget;
- if ( $title )
- echo $before_title . $title . $after_title;
-?>
-
-<!-- Begin Tags -->
-<span>Click to <span style="color:#5588aa;" onclick="document.getElementById('tag01').style.display='inline';">view</span> / <span style="color:#5588aa;" onclick="document.getElementById('tag01').style.display='none';">hide</span>
-</span>
-<br /><br />
-<div id="tag01" style="display:none;">
- <ul class="leftcolcatlist">
-
- <?php
- $tagrssimg = "/images/rss.png";
- $tagrssurl = get_template_directory_uri() . $tagrssimg;
- $customtaglist ='';
- $customtags = get_tags();
- foreach($customtags as $customtag) {
- $customtaglist = '<li><a title="Subscribe to the '.$customtag->name.' feed" href="'.home_url().'/tag/'.$customtag->slug.'/feed/"><img src="'.$tagrssurl.'" alt="feed" /></a><a href="'.home_url().'/tag/'.$customtag->slug.'/">'.$customtag->name.'</a> ('.$customtag->count.')</li>';
- echo $customtaglist;
- }
- ?>
- </ul>
-
-</div>
-<!-- End Tags -->
-
-<?php
- echo $after_widget;
- }
-
- function update( $new_instance, $old_instance ) {
- $instance = $old_instance;
- $instance['title'] = strip_tags($new_instance['title']);
-
- return $instance;
- }
-
- function form( $instance ) {
- $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
- $title = strip_tags($instance['title']);
-?>
- <p><label for="<?php echo $this->get_field_id('title'); ?>">Title:</label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
-<?php
- }
-}
-
-/* oenology_widget_linkrollbycat */
-
-class oenology_widget_linkrollbycat extends WP_Widget {
-
- function oenology_widget_linkrollbycat() {
- $widget_ops = array('classname' => 'oenology-widget-linkrollbycat', 'description' => 'oenology theme widget to display linkroll by category' );
- $this->WP_Widget('oenology_linkrollbycat', 'oenology Links By Cat', $widget_ops);
- }
-
- function widget( $args, $instance ) {
-
- extract($args);
- $title = apply_filters('widget_title', empty($instance['title']) ? 'oenology Links By Cat' : $instance['title']);
- $defaultview = isset($instance['defaultView']) && $instance['defaultview'] == true ? 'inline' : 'none';
- $show_description = isset($instance['description']) ? $instance['description'] : false;
- $show_name = isset($instance['name']) ? $instance['name'] : false;
- $show_rating = isset($instance['rating']) ? $instance['rating'] : false;
- $show_images = isset($instance['images']) ? $instance['images'] : false;
- $categorize = isset($instance['categorize']) ? $instance['categorize'] : false;
- $category = isset($instance['category']) ? $instance['category'] : false;
- $categoryid = $category;
- $bookmarkid = rand();
- $bookmarksexist = get_bookmarks( array( 'category' => $categoryid));
-
- if ( $bookmarksexist ) {
- echo $before_widget;
- if ( $title )
- echo $before_title . $title . $after_title;
-?>
-<span>Click to <span style="color:#5588aa;" onclick="document.getElementById('br<?php echo $categoryid; ?>-<?php echo $bookmarkid; ?>').style.display='inline';">view</span> / <span style="color:#5588aa;" onclick="document.getElementById('br<?php echo $categoryid; ?>-<?php echo $bookmarkid; ?>').style.display='none';">hide</span>
-</span>
-<br /><br />
-<div id="br<?php echo $categoryid; ?>-<?php echo $bookmarkid; ?>" style="display:<?php echo $defaultview; ?>;">
- <ul>
- <?php
- wp_list_bookmarks(apply_filters('widget_links_args', array(
- 'title_li' => '', 'title_before' => '', 'title_after' => '',
- 'category_before' => $before_widget, 'category_after' => $after_widget,
- 'show_images' => $show_images, 'show_description' => $show_description,
- 'show_name' => $show_name, 'show_rating' => $show_rating,
- 'categorize' => $categorize, 'category' => $category,
- 'class' => 'linkcat widget'
- )));
-
- ?>
- </ul>
-</div>
-
-<?php
- echo $after_widget;
- }
- }
-
- function update( $new_instance, $old_instance ) {
- $new_instance = (array) $new_instance;
- $instance = array( 'defaultview' => 0, 'images' => 0, 'name' => 0, 'description' => 0, 'rating' => 0);
- foreach ( $instance as $field => $val ) {
- if ( isset($new_instance[$field]) )
- $instance[$field] = 1;
- }
- $instance['title'] = strip_tags( stripslashes( $new_instance['title'] ) );
- $instance['category'] = intval($new_instance['category']);
-
- return $instance;
- }
-
- function form( $instance ) {
- $defaults = array( 'defaultview' => 'false' );
- $instance = wp_parse_args( (array) $instance, array(
- 'title' => '' ,
- 'defaultview' => 'false' ,
- 'category' => '' ,
- 'images' => 'false' ,
- 'name' => 'false' ,
- 'description' => 'false' ,
- 'rating' => 'false'
- )
- );
- $title = strip_tags($instance['title']);
-?>
- <p>
- <label for="<?php echo $this->get_field_id('title'); ?>">Title:</label>
- <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" />
- </p>
- <p>
- <label for="<?php echo $this->get_field_id( 'category' ); ?>">Bookmark Category:</label>
- <select id="<?php echo $this->get_field_id( 'category' ); ?>" name="<?php echo $this->get_field_name( 'category' ); ?>" class="widefat" style="width:100%;">
- <?php $link_cats = get_terms( 'link_category'); ?>
- <?php foreach ( $link_cats as $link_cat ) : ?>
- <option <?php if ( $link_cat->term_id == $instance['category'] ) echo 'selected="selected"'; ?> value="<?php echo $link_cat->term_id; ?>"><?php echo $link_cat->name; ?></option>
- <?php endforeach; ?>
- </select>
- </p>
- <p>
- <input class="checkbox" type="checkbox" <?php checked($instance['defaultview'], true) ?> id="<?php echo $this->get_field_id('defaultview'); ?>" name="<?php echo $this->get_field_name('defaultview'); ?>" />
- <label for="<?php echo $this->get_field_id('defaultview'); ?>"><?php _e('View Inline (Unchecked: Hidden)'); ?></label><br />
- </p>
- <p>
- <input class="checkbox" type="checkbox" <?php checked($instance['images'], true) ?> id="<?php echo $this->get_field_id('images'); ?>" name="<?php echo $this->get_field_name('images'); ?>" />
- <label for="<?php echo $this->get_field_id('images'); ?>"><?php _e('Show Link Image'); ?></label><br />
- <input class="checkbox" type="checkbox" <?php checked($instance['name'], true) ?> id="<?php echo $this->get_field_id('name'); ?>" name="<?php echo $this->get_field_name('name'); ?>" />
- <label for="<?php echo $this->get_field_id('name'); ?>"><?php _e('Show Link Name'); ?></label><br />
- <input class="checkbox" type="checkbox" <?php checked($instance['description'], true) ?> id="<?php echo $this->get_field_id('description'); ?>" name="<?php echo $this->get_field_name('description'); ?>" />
- <label for="<?php echo $this->get_field_id('description'); ?>"><?php _e('Show Link Description'); ?></label><br />
- <input class="checkbox" type="checkbox" <?php checked($instance['rating'], true) ?> id="<?php echo $this->get_field_id('rating'); ?>" name="<?php echo $this->get_field_name('rating'); ?>" />
- <label for="<?php echo $this->get_field_id('rating'); ?>"><?php _e('Show Link Rating'); ?></label>
- </p>
-
-<?php
- }
-}
-
-
-/* Register all widgets
-**********************************************************/
-
-/* Add our function to the widgets_init hook. */
-add_action( 'widgets_init', 'oenology_load_widgets' );
-
-/* Function that registers our widgets. */
-function oenology_load_widgets() {
- register_widget( 'oenology_widget_recentposts' );
- register_widget( 'oenology_widget_archives' );
- register_widget( 'oenology_widget_categories' );
- register_widget( 'oenology_widget_tags' );
- register_widget( 'oenology_widget_linkrollbycat' );
-}
/*
Reference:
=============================================================================
The following functions, tags, and hooks are used (or referenced) in this Theme template file:
***********************
-FUNCTION()
-----------------------------------
-FUNCTION() is a WordPress function.
-Codex reference:
-
-FUNCTION() is used to
-
-FUNCTION()
-
-FUNCTION( $args ) accepts arguments:
- - $arg:
-
-Example:
-
-
-Used in the following template files:
-functions.php
-
-***********************
add_action()
----------------------------------
add_action() is a WordPress function.
@@ -1315,6 +291,23 @@ functions.php
Defines the "HEADER_TEXTCOLOR" constant, with a value of "000000" (the HEX value for black)
***********************
+file_exists()
+----------------------------------
+file_exists() is a PHP function.
+Codex reference: N/A
+PHP reference: http://php.net/manual/en/function.file-exists.php
+
+file_exists() is a boolean (returns TRUE or FALSE) conditional function that returns true if
+the specified file exists.
+
+file_exists( $filepath ) accepts one argument:
+ - $filepath: (string) the filepath and filename, e.g. /path/to/my/file.ext
+
+Example:
+file_exists( get_theme_root() . '/twentyten/style.css' )
+ - returns TRUE if the file is found
+
+***********************
filesize()
----------------------------------
filesize() is a PHP function.
@@ -1608,6 +601,19 @@ function_exists( 'foo' ) returns TRUE if a function named foo() is found; otherw
Displays the Post Title of the current post's parent post.
***********************
+get_theme_root()
+----------------------------------
+get_theme_root() is a WordPress template tag.
+Codex reference: http://codex.wordpress.org/Function_Reference/get_theme_root
+
+get_theme_root() is used to retrieve the file path to the directory in which
+Themes are installed (e.g. 'home/username/html/wp-content/themes').
+
+Note that the returned string has no trailing slash.
+
+get_theme_root() accepts no arguments.
+
+***********************
get_userdata()
----------------------------------
get_userdata() is a WordPress template tag.
View
518 functions/functions-custom.php
@@ -0,0 +1,518 @@
+<?php
+/*****************************************************************************************
+* Filter wp_title function
+*******************************************************************************************/
+
+function oenology_filter_wp_title( $title, $separator ) { // taken from TwentyTen 1.0
+ // Don't affect wp_title() calls in feeds.
+ if ( is_feed() )
+ return $title;
+
+ // The $paged global variable contains the page number of a listing of posts.
+ // The $page global variable contains the page number of a single post that is paged.
+ // We'll display whichever one applies, if we're not looking at the first page.
+ global $paged, $page;
+
+ if ( is_search() ) {
+ // If we're a search, let's start over:
+ $title = sprintf( 'Search results for %s', '"' . get_search_query() . '"' );
+ // Add a page number if we're on page 2 or more:
+ if ( $paged >= 2 )
+ $title .= " $separator " . sprintf( 'Page %s', $paged );
+ // Add the site name to the end:
+ $title .= " $separator " . get_bloginfo( 'name', 'display' );
+ // We're done. Let's send the new title back to wp_title():
+ return $title;
+ }
+
+ // Otherwise, let's start by adding the site name to the end:
+ $title .= get_bloginfo( 'name', 'display' );
+
+ // If we have a site description and we're on the home/front page, add the description:
+ $site_description = get_bloginfo( 'description', 'display' );
+ if ( $site_description && ( is_home() || is_front_page() ) )
+ $title .= " $separator " . $site_description;
+
+ // Add a page number if necessary:
+ if ( $paged >= 2 || $page >= 2 )
+ $title .= " $separator " . sprintf( 'Page %s', max( $paged, $page ) );
+
+ // Return the new title to wp_title():
+ return $title;
+}
+add_filter( 'wp_title', 'oenology_filter_wp_title', 10, 2 );
+
+
+/*****************************************************************************************
+* Display correct number of comments (count only comments, not trackbacks/pingbacks)
+*******************************************************************************************/
+
+// filter get_comments_number() to return only the number of comments (excluding trackbacks/pingbacks)
+// http://www.wpbeginner.com/wp-tutorials/display-the-most-accurate-comment-count-in-wordpress/
+function oenology_comment_count( $count ) {
+if ( ! is_admin() ) {
+global $id;
+$comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id));
+return count($comments_by_type['comment']);
+} else {
+return $count;
+}
+}
+add_filter('get_comments_number', 'oenology_comment_count', 0);
+
+/*****************************************************************************************
+* Display copyright notice customized according to date of first post
+*******************************************************************************************/
+
+function oenology_copyright() {
+global $wpdb;
+$copyright_dates = $wpdb->get_results("
+SELECT
+YEAR(min(post_date_gmt)) AS firstdate,
+YEAR(max(post_date_gmt)) AS lastdate
+FROM
+$wpdb->posts
+WHERE
+post_status = 'publish'
+");
+$output = '';
+if($copyright_dates) {
+$copyright = "&copy; " . $copyright_dates[0]->firstdate;
+if($copyright_dates[0]->firstdate != $copyright_dates[0]->lastdate) {
+$copyright .= '-' . $copyright_dates[0]->lastdate;
+}
+$output = $copyright;
+}
+return $output;
+}
+
+
+/*****************************************************************************************
+* Image Handling for gallery previous/next links
+*******************************************************************************************/
+
+// function needed because WP gives no easy way to display both image and text in prev/next links.
+function oenology_gallery_links() {
+ global $post;
+ $post = get_post($post);
+ $attachments = array_values(get_children("post_parent=$post->post_parent&post_type=attachment&post_mime_type=image&orderby=menu_order ASC, ID ASC"));
+
+ $k = 0;
+
+ foreach ( $attachments as $k => $attachment )
+ if ( $attachment->ID == $post->ID )
+ break;
+
+ $links = array( 'prevlink' => '', 'prevthumb' => '', 'nextlink' => '', 'nextthumb' => '' );
+
+ if ( isset($attachments[$k+1]) ) {
+ $links['prevlink'] = get_permalink($attachments[$k+1]->ID);
+ $links['prevthumb'] = wp_get_attachment_link($attachments[$k+1]->ID, 'attachment-nav-thumbnail', true);
+ }
+
+ if ( isset($attachments[$k-1]) ) {
+ $links['nextlink'] = get_permalink($attachments[$k-1]->ID);
+ $links['nextthumb'] = wp_get_attachment_link($attachments[$k-1]->ID, 'attachment-nav-thumbnail', true);
+ }
+
+ return $links;
+}
+
+/*****************************************************************************************
+* Image Handling for gallery image metadata
+*******************************************************************************************/
+
+function oenology_gallery_image_meta() {
+ global $post;
+ $post = get_post($post);
+ $is_parent = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC' ) );
+ $attachmentimage = ( $is_parent ? array_shift( $is_parent ) : false );
+ $imagepost = ( $attachmentimage ? $attachmentimage->ID : $post->ID );
+ $m = get_post_meta( $imagepost, '_wp_attachment_metadata' , true );
+ $image = wp_get_attachment_image( $imagepost, 'large' );
+ $url = wp_get_attachment_url( $imagepost );
+ $uploaddir = wp_upload_dir();
+ $imagesize = size_format( filesize( $uploaddir['basedir'] . '/' . $m['file'] ) );
+ $image_meta = array (
+ 'image' => $image,
+ 'url' => $url,
+ 'width' => $m['width'],
+ 'height' => $m['height'],
+ 'dimensions' => false,
+ 'filesize' => $imagesize,
+ 'created_timestamp' => $m['image_meta']['created_timestamp'],
+ 'copyright' => $m['image_meta']['copyright'],
+ 'credit' => $m['image_meta']['credit'],
+ 'aperture' => $m['image_meta']['aperture'],
+ 'focal_length' => $m['image_meta']['focal_length'],
+ 'iso' => $m['image_meta']['iso'],
+ 'shutter_speed' => $m['image_meta']['shutter_speed'],
+ 'camera' => $m['image_meta']['camera'],
+ 'caption' => '(No caption provided.)'
+ );
+ // image dimensions handler
+ if ( $m['width'] && $m['height'] ) {
+ $image_meta['dimensions'] = $m['width'] . '&#215;' . $m['height'] . ' px';
+ }
+ // image created_timestamp handler
+ if ( $m['image_meta']['created_timestamp'] ) {
+ $image_meta['created_timestamp'] = date( 'm M Y', $m['image_meta']['created_timestamp'] );
+ }
+ // image aperture handler
+ if ( $m['image_meta']['aperture'] ) {
+ $image_meta['aperture'] = 'f/' . $m['image_meta']['aperture'];
+ }
+ // shutter speed handler
+ if ( ( $m['image_meta']['shutter_speed'] != '0' ) && ( ( 1 / $m['image_meta']['shutter_speed'] ) > 1 ) ) {
+ $image_meta['shutter_speed'] = "1/";
+ if (number_format((1 / $m['image_meta']['shutter_speed']), 1) == number_format((1 / $m['image_meta']['shutter_speed']), 0)) {
+ $image_meta['shutter_speed'] = $image_meta['shutter_speed'] . number_format((1 / $m['image_meta']['shutter_speed']), 0, '.', '') . ' sec';
+ } else {
+ $image_meta['shutter_speed'] = $image_meta['shutter_speed'] . number_format((1 / $m['image_meta']['shutter_speed']), 1, '.', '') . ' sec';
+ }
+ } else {
+ $image_meta['shutter_speed'] = $m['image_meta']['shutter_speed'].' sec';
+ }
+ // image caption handler
+ if ( ! empty( $post->post_excerpt ) ) {
+ $image_meta['caption'] = get_the_excerpt(); // this is the "caption"
+ } elseif ( $attachmentimage->post_excerpt ) {
+ $image_meta['caption'] = $attachmentimage->post_excerpt;
+ }
+ return $image_meta;
+}
+
+
+/*****************************************************************************************
+* 404 error handling
+*******************************************************************************************/
+
+function oenology_404_handler() {
+
+ if ( !is_404() )
+ return;
+
+ // array to hold suggestions
+ if ( ! isset ( $oenology404suggestions ) ) {
+ $oenology404postsuggestions = false;
+ $oenology404pagesuggestions = false;
+ }
+
+ // Extract search term from URL
+ $patterns_array[] = "/?(trackback|feed|page[0-9]*)/?$";
+ $patterns_array[] = "\.html$";
+ $patterns_array = array_map(create_function('$a', '$sep = (strpos($a, "@") === false ? "@" : "%"); return $sep.trim($a).$sep."i";'), $patterns_array);
+
+ $search = preg_replace( $patterns_array, "", urldecode( $_SERVER["REQUEST_URI"] ) );
+ $search = basename(trim($search));
+ $search = preg_replace( $patterns_array, "", $search);
+ $search_words = preg_replace( "@[_-]@", " ", $search);
+
+ // Search for posts
+ $posts = get_posts( array( "s" => $search_words ) );
+ $oenology404postsuggestions = $posts;
+
+ // Search for pages
+ $pages = get_posts( array( "s" => $search_words, "post_type" => "page" ) );
+ $oenology404pagesuggestions = $pages;
+
+ $oenology404suggestions = array_merge ( $oenology404postsuggestions, $oenology404pagesuggestions );
+ $oenology404nopostsorpages = true;
+ if ( !isset ( $oenology404suggestions ) || !is_array( $oenology404suggestions ) || count( $oenology404suggestions ) == 0 ) {
+ $oenology404nopostsorpages = true;
+ } else {
+ $oenology404nopostsorpages = false;
+ ?>
+ <p>Let me try to make it up to you!</p>
+ <?php
+ // Display list of post suggestions
+ $suggestedposts = $oenology404postsuggestions;
+ if ( $suggestedposts > 0 ) {
+ ?>
+ <p>Here is a list of posts that you might have been looking for:</p>
+ <ul class="oenology404_suggestions">
+ <?php
+ foreach ( $suggestedposts as $suggestedpost ) { ?>
+ <li>
+ <span style="text-transform:uppercase;"><?php echo $suggestedpost->post_type; ?></span>: <a href="<?php echo get_permalink($suggestedpost->ID); ?>"><?php echo $suggestedpost->post_title; ?></a>
+ <blockquote>
+ <?php
+ if (empty($suggestedpost->post_excerpt)) {
+ $suggestedpost->post_excerpt = explode(" ",strrev(substr(strip_tags($suggestedpost->post_content), 0, 300)),2);
+ $suggestedpost->post_excerpt = strrev($suggestedpost->post_excerpt[1]);
+ $suggestedpost->post_excerpt.= " [...]";
+ }
+ if ($suggestedpost->post_excerpt) {
+ echo $suggestedpost->post_excerpt;
+ } else {
+ echo 'No excerpt available.';
+ }
+ ?>
+ </blockquote>
+ </li>
+ <?php } ?>
+ </ul>
+ <?php
+ }
+ // Display list of page suggestions
+ $suggestedpages = $oenology404pagesuggestions;
+ if ( $suggestedpages > 0 ) {
+ ?>
+ <p>Here is a list of pages that you might have been looking for:</p>
+ <ul class="oenology404_suggestions">
+ <?php
+ foreach ( $suggestedpages as $suggestedpage ) { ?>
+ <li>
+ <span style="text-transform:uppercase;"><?php echo $suggestedpage->post_type; ?></span>: <a href="<?php echo get_permalink($suggestedpage->ID); ?>"><?php echo $suggestedpage->post_title; ?></a>
+ <blockquote>
+ <?php
+ if (empty($suggestedpage->post_excerpt)) {
+ $suggestedpage->post_excerpt = explode(" ",strrev(substr(strip_tags($suggestedpage->post_content), 0, 300)),2);
+ $suggestedpage->post_excerpt = strrev($suggestedpage->post_excerpt[1]);
+ $suggestedpage->post_excerpt.= " [...]";
+ }
+ if ($suggestedpage->post_excerpt) {
+ echo $suggestedpage->post_excerpt;
+ } else {
+ echo 'No excerpt available.';
+ }
+ ?>
+ </blockquote>
+ </li>
+ <?php } ?>
+ </ul>
+ <?php
+ }
+ }
+
+ // See if we've matched a category
+ $oenology404nocategories = true;
+ $categories = get_categories( array ( "name__like" => $search ) );
+ if ( count($categories) > 0) {
+ $oenology404nocategories = false;
+ ?>
+ <p>Perhaps you were looking for something in one of the following categories?</p>
+ <ul class="oenology404_suggestions">
+ <?php foreach ( $categories as $category ) { ?>
+ <li><a href="<?php get_category_link($category->term_id); ?>"><?php echo $category->name; ?></a></li>
+ <?php } ?>
+ </ul>
+ <?php }
+ // See if we've matched a tag
+ $oenology404notags = true;
+ $tags = get_tags( array ( "name__like" => $search ) );
+ if ( count($tags) > 0) {
+ $oenology404notags = false;
+ ?>
+ <p>Perhaps you were looking for something with one of the following tags?</p>
+ <ul class="oenology404_suggestions">
+ <?php foreach ( $tags as $tag ) { ?>
+ <li><a href="<?php get_tag_link($tag->term_id); ?>"><?php echo $tag->name; ?></a></li>
+ <?php } ?>
+ </ul>
+ <?php }
+
+ $oenology404noresults = false;
+ if ( $oenology404nopostsorpages && $oenology404nocategories && $oenology404notags ) {
+ $oenology404noresults = true;
+ }
+
+ if ( $oenology404noresults ) { ?>
+ <p>I'm sorry. For the life of me, I can't figure out what you were trying to find. Perhaps try searching, using the search form in the upper right-hand corner?</p>
+ <?php }
+}
+
+
+/*****************************************************************************************
+* Add a "current-cat" CSS class declaration
+*******************************************************************************************/
+
+/* Credit: StudioGrasshopper
+* http://www.studiograsshopper.ch/code-snippets/dynamic-category-menu-highlighting-for-single-posts/
+*/
+function oenology_show_current_cat_on_single($output) {
+
+ global $post;
+
+ if( is_single() ) {
+
+ $categories = wp_get_post_categories($post->ID);
+
+ foreach( $categories as $catid ) {
+ $cat = get_category($catid);
+ // Find cat-item-ID in the string
+ if(preg_match('#cat-item-' . $cat->cat_ID . '#', $output)) {
+ $output = str_replace('cat-item-'.$cat->cat_ID, 'cat-item-'.$cat->cat_ID . ' current-cat', $output);
+ }
+ }
+
+ }
+ return $output;
+}
+add_filter('wp_list_categories', 'oenology_show_current_cat_on_single');
+
+
+/*****************************************************************************************
+* Add navigation breadcrumb function
+*******************************************************************************************/
+
+/* Credit: Dimox
+* http://dimox.net/wordpress-breadcrumbs-without-a-plugin/
+*/
+function oenology_breadcrumb() {
+
+ $containerBefore = '<li id="breadcrumbs">';
+ $containerAfter = '</li>';
+ $containerCrumb = '<div class="crumbs">';
+ $containerCrumbEnd = '</div>';
+ $delimiter = ' &raquo; ';
+ $name = 'Home'; //text for the 'Home' link
+ $baseLink = '';
+ $hierarchy = '';
+ $currentLocation = '';
+ $currentBefore = '<strong>';
+ $currentAfter = '</strong>';
+ $currentLocationLink = '';
+ $crumbPagination = '';
+
+ // Start of Container
+ echo $containerBefore;
+// Start of Breadcrumbs
+ echo $containerCrumb;
+
+// Output the Base Link
+ global $post;
+ $home = home_url('/');
+ $baseLink = '<a href="' . $home . '">' . $name . '</a>';
+ echo $baseLink;
+
+ // Define Breadcrumb Hierarchy and Current Location for various page types
+
+ if ( is_category() ) { // Define Category Hierarchy Crumbs for Category Archive
+ global $wp_query;
+ $cat_obj = $wp_query->get_queried_object();
+ $thisCat = $cat_obj->term_id;
+ $thisCat = get_category($thisCat);
+ $parentCat = get_category($thisCat->parent);
+ if ($thisCat->parent != 0) {
+ $hierarchy = ($delimiter . get_category_parents($parentCat, TRUE, $delimiter));
+ } else {
+ $hierarchy = $delimiter;
+ }
+ $currentLocation = single_cat_title( '' , FALSE ); // Set $currentLocation to the current category
+
+ } elseif ( is_day() ) { // Define Year/Month Hierarchy Crumbs for Day Archive
+ $hierarchy = $delimiter . 'Posts Published in: <a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ' . '<a href="' . get_month_link(get_the_time('Y'),get_the_time('m')) . '">' . get_the_time('F') . '</a> ' . $delimiter . ' ';
+ $currentLocation = get_the_time('d');
+
+ } elseif ( is_month() ) { // Define Year Hierarchy Crumb for Month Archive
+ $hierarchy = $delimiter . 'Posts Published in: <a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a> ' . $delimiter . ' ';
+ $currentLocation = get_the_time('F');
+
+ } elseif ( is_year() ) { // Set CurrentLocation for Year Archive
+ $hierarchy = $delimiter . 'Posts Published in: ';
+ $currentLocation = get_the_time('Y');
+
+ } elseif ( is_single() && !is_attachment() ) { // Define Category Hierarchy Crumbs for Single Posts
+ $cat = get_the_category();
+ $cat = $cat[0];
+ $hierarchy = $delimiter . get_category_parents( $cat, TRUE, $delimiter );
+ $currentLocation = ( get_the_title() ? get_the_title() : '(No Post Title)' );
+
+ } elseif ( is_attachment() ) { // Define Category and Parent Post Crumbs for Post Attachments
+ $parent = get_post($post->post_parent);
+ $cat_parents = '';
+ if ( get_the_category($parent->ID) ) {
+ $cat = get_the_category($parent->ID);
+ $cat = $cat[0];
+ $cat_parents = get_category_parents( $cat, TRUE, $delimiter );
+ }
+ $hierarchy = $delimiter . $cat_parents . '<a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a> ' . $delimiter;
+ $currentLocation = ( get_the_title() ? get_the_title() : '(No Attachment Title)' );
+
+ } elseif ( is_page() && !$post->post_parent ) { // Define Current Location for Parent Pages
+ $hierarchy = $delimiter;
+ $currentLocation = ( get_the_title() ? get_the_title() : '(No Page Title)' );
+
+ } elseif ( is_page() && $post->post_parent ) { // Define Parent Page Hierarchy Crumbs for Child Pages
+ $parent_id = $post->post_parent;
+ $breadcrumbs = array();
+ while ($parent_id) {
+ $page = get_page($parent_id);
+ $breadcrumbs[] = '<a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a>';
+ $parent_id = $page->post_parent;
+ }
+ $breadcrumbs = array_reverse($breadcrumbs);
+ foreach ($breadcrumbs as $crumb) {
+ $hierarchy = $hierarchy . $delimiter . $crumb;
+ }
+ $hierarchy = $hierarchy . $delimiter;
+ $currentLocation = ( get_the_title() ? get_the_title() : '(No Page Title)' );
+
+ } elseif ( is_search() ) { // Define current location for Search Results page
+ $hierarchy = $delimiter . 'Search Results: ';
+ $currentLocation = get_search_query();
+
+ } elseif ( is_tag() ) { // Define current location for Tag Archives
+ $hierarchy = $delimiter . 'Posts Tagged as: ';
+ $currentLocation = single_tag_title( '' , FALSE );
+
+ } elseif ( is_author() ) { // Define current location for Author Archives
+ global $author;
+ $userdata = get_userdata($author);
+ $hierarchy = $delimiter . 'Posts Written by: ';
+ $currentLocation = $userdata->display_name;
+
+ } elseif ( is_404() ) { // Define current location for 404 Error page
+ $hierarchy = $delimiter . 'Error 404: ';
+ $currentLocation = 'Page Not Found';
+
+ } elseif ( get_post_format() && ! is_home() ) { // Define current location for Post Format Archives
+ $hierarchy = $delimiter . 'Post Format: ';
+ $currentLocation = get_post_format_string( get_post_format() ) . 's';
+ }
+
+// Build the Current Location Link markup
+ $currentLocationLink = $currentBefore . $currentLocation . $currentAfter;
+
+// Define breadcrumb pagination
+
+// Define pagination for paged Archive pages
+ if ( get_query_var('paged') && ! function_exists( 'wp_paginate' ) ) {
+ $crumbPagination = ' (Page ' . get_query_var('paged') . ')';
+ }
+
+ // Define pagination for Paged Posts and Pages
+ if ( get_query_var('page') ) {
+ $crumbPagination = ' (Page ' . get_query_var('page') . ') ';
+ }
+
+// Output the resulting Breadcrumbs
+
+ echo $hierarchy; // Output Hierarchy
+ echo $currentLocationLink; // Output Current Location
+ echo $crumbPagination; // Output page number, if Post or Page is paginated
+ echo $containerCrumbEnd; // End of BreadCrumbs
+
+ // Start of Pagination
+ if ( ! is_singular() ) {
+ if ( function_exists( 'wp_paginate' ) ) {
+ wp_paginate( 'title=' );
+ } else {
+ echo '<div class="postsnavlinks">';
+ posts_nav_link( '&nbsp;' , '&larr;' , '&rarr;' );
+ echo '</div>';
+ }
+ }
+
+ if ( is_single() && ! is_attachment() ) {
+ echo '<div class="prevnextpostlinks">';
+ next_post_link( '%link', '&lArr; ' );
+ previous_post_link( '%link', ' &rArr;' );
+ echo '</div>';
+ }
+
+ echo $containerAfter; // End of Container
+
+}
+?>
View
7 functions/functions-options-help.php
@@ -0,0 +1,7 @@
+<?php
+$text .= "<h2>" . __( 'General Options', 'oenology' ) . "</h2>";
+$text .= "<h3>" . __( 'Header Nav Menu Position', 'oenology' ) . "</h3>";
+$text .= "<p>" . __('The default location of the header navigation menu is above the site title/description. Use this setting to display the header navigation menu below the site title/description.', 'oenology') . "</p>";
+$text .= "<h3>" . __( 'Footer Credit', 'oenology' ) . "</h3>";
+$text .= "<p>" . __('This setting controls the display of a footer credit link. By default, no footer credit link is displayed. You are under no obligation to display a credit link in the footer or anywhere else.', 'oenology') . "</p>";
+?>
View
85 functions/functions-options-init.php
@@ -0,0 +1,85 @@
+<?php
+
+global $oenology_options;
+$oenology_options = get_option( 'theme_oenology_options' );
+
+/*****************************************************************************************
+* Register Theme Settings
+*******************************************************************************************/
+
+// Register theme_oenology_options array to hold all theme options
+register_setting( 'theme_oenology_options', 'theme_oenology_options', 'oenology_options_validate' );
+
+/*****************************************************************************************
+* Add Theme Settings Form Sections
+*******************************************************************************************/
+
+// Add a form section for the General theme settings
+add_settings_section('oenology_settings_general', 'General Options', 'oenology_settings_general_section_text', 'oenology');
+
+/*****************************************************************************************
+* Add Form Fields to General Settings Section
+*******************************************************************************************/
+
+// Add Header Navigation Menu Position setting to the General section
+add_settings_field('oenology_setting_header_nav_menu_position', 'Header Nav Menu Position', 'oenology_setting_header_nav_menu_position', 'oenology', 'oenology_settings_general');
+// Add Footer Credit Link setting to the General section
+add_settings_field('oenology_setting_footer_credit', 'Footer Credit', 'oenology_setting_footer_credit', 'oenology', 'oenology_settings_general');
+
+/*****************************************************************************************
+* Add Section Text for Each Form Section
+*******************************************************************************************/
+
+// General Settings Section
+function oenology_settings_general_section_text() { ?>
+ <p><?php _e( 'Refer to the contextual help screen for descriptions and help regarding each theme option.', 'oenology' ); ?></p>
+<?php }
+
+/*****************************************************************************************
+* Add Form Field Markup for Each Theme Option
+*******************************************************************************************/
+
+// Navigation Menu Position Setting
+function oenology_setting_header_nav_menu_position() {
+ $oenology_options = get_option( 'theme_oenology_options' ); ?>
+ <p>
+ <label for="oenology_header_nav_menu_position">
+ Display header navigation menu above or below the site title/description?<br />
+ <select name="theme_oenology_options[header_nav_menu_position]">
+ <option <?php if ( 'above' == $oenology_options['header_nav_menu_position'] ) echo 'selected="selected"'; ?> value="above">Above</option>
+ <option <?php if ( 'below' == $oenology_options['header_nav_menu_position'] ) echo 'selected="selected"'; ?> value="below">Below</option>
+ </select>
+ </label>
+ </p>
+<?php }
+
+// Display Footer Credit Setting
+function oenology_setting_footer_credit() {
+ $oenology_options = get_option( 'theme_oenology_options' ); ?>
+ <p>
+ <label for="oenology_footer_credit">
+ Display a credit link in the footer? This option is disabled by default, and you are under no obligation whatsoever to enable it.<br />
+ <select name="theme_oenology_options[footer_credit]">
+ <option <?php if ( true == $oenology_options['footer_credit'] ) echo 'selected="selected"'; ?> value="true">Do Not Display</option>
+ <option <?php if ( false == $oenology_options['footer_credit'] ) echo 'selected="selected"'; ?> value="false">Display</option>
+ </select>
+ </label>
+ </p>
+<?php }
+
+
+/*****************************************************************************************
+* Validate/Whitelist User-Input Data Before Updating Theme Options
+*******************************************************************************************/
+function oenology_options_validate( $input ) {
+
+ $oenology_options = get_option( 'theme_oenology_options' );
+
+ $valid_input = $oenology_options;
+
+ $valid_input['header_nav_menu_location'] = ( 'below' == $input['header_nav_menu_location'] ? 'below' : 'above' );
+ $valid_input['footer_credit'] = ( 'true' == $input['footer_credit'] ? true : false );
+
+ return $valid_input;
+}
+?>
View
99 functions/functions-options.php
@@ -0,0 +1,99 @@
+<?php
+/*****************************************************************************************
+* Theme Options Functions
+*
+* - Define Default Theme Options
+* - Register/Initialize Theme Options
+* - Define Admin Settings Page
+* - Register Contextual Help
+*******************************************************************************************/
+
+global $oenology_options;
+global $oenology_admin_options_hook;
+
+/*****************************************************************************************
+* Define the default options
+*******************************************************************************************/
+global $oenology_options_default;
+$oenology_options_default = array(
+ 'header_nav_menu_position' => 'top',
+ 'display_footer_credit' => false,
+ 'theme_version' => '1.1'
+);
+
+
+/*****************************************************************************************
+* Setup initial Theme options
+*******************************************************************************************/
+
+function oenology_options_init() {
+
+ // set options equal to defaults
+ global $oenology_options_default;
+ global $oenology_options;
+ $oenology_options = get_option( 'theme_oenology_options' );
+
+ if ( false === $oenology_options ) {
+ $oenology_options_initial = $oenology_options_default;
+ }
+}
+// Initialize Theme options
+add_action('after_setup_theme', 'oenology_options_init', 9 );
+
+
+/*****************************************************************************************
+* Setup the Theme Admin Settings Page
+*******************************************************************************************/
+
+// Add "Theme Options" link to the "Appearance" menu
+function oenology_menu() {
+ global $oenology_admin_options_hook;
+ $oenology_admin_options_hook = add_theme_page('Theme Options', 'oenology', 'edit_theme_options', 'oenology', 'oenology_admin_options_page');
+}
+// Load the Admin Options page
+add_action('admin_menu', 'oenology_menu');
+
+
+// Admin settings page markup
+function oenology_admin_options_page() { ?>
+ <div>
+ <h2>Oenology Theme Options</h2>
+ <p>Manage options for the Oenology Theme</p>
+ <form action="options.php" method="post">
+ <?php
+ settings_fields('theme_oenology_options');
+ do_settings_sections('oenology');
+ ?>
+ <input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" />
+ </form>
+ </div>
+<?php }
+
+// Codex Reference: http://codex.wordpress.org/Settings_API
+// Codex Reference: http://codex.wordpress.org/Data_Validation
+// Reference: http://ottopress.com/2009/wordpress-settings-api-tutorial/
+// Reference: http://planetozh.com/blog/2009/05/handling-plugins-options-in-wordpress-28-with-register_setting/
+function oenology_admin_init(){
+ include_once( 'functions-options-init.php' );
+}
+// Settings API options initilization and validation
+add_action('admin_init', 'oenology_admin_init');
+
+
+/*****************************************************************************************
+* Setup the Theme Admin Settings Page Contextual help
+*******************************************************************************************/
+
+// Admin settings page contextual help markup
+// Separate file for ease of management
+function oenology_contextual_help( $contextual_help, $screen_id, $screen ) {
+ global $oenology_admin_options_hook;
+ include_once( 'functions-options-help.php' );
+ if ( $screen_id == $oenology_admin_options_hook ) {
+ $contextual_help = $text;
+ }
+ return $contextual_help;
+}
+// Add contextual help to Admin Options page
+add_action('contextual_help', 'oenology_contextual_help', 10, 3);
+?>
View
1 functions/functions-theme-setup.php
@@ -0,0 +1 @@
+<?php
View
1 functions/functions-widgets.php
@@ -0,0 +1 @@
+<?php
View
2 index.php
@@ -47,7 +47,7 @@