* @copyright Copyright (c) 2009-2012, Edward Caissie
*
* @version 2.0
* @date July 6, 2012
*/
/**
* Ground Floor Login - adds link to login|Dashboard
* @todo Review for optimization
*/
function gf_login() {
$login_url = home_url() . '/wp-admin/';
if ( is_user_logged_in() ) {
echo '
';
} else {
echo '';
}
}
/**
* Widget Area Definitions
* Creating three (3) "sidebar" widget areas and three (3) "footer" widget areas
*
* @since 1.0
*
* Last modified April 16, 2012
* @version 1.9
* Added 'description' parameters for each sidebar definition
*/
register_sidebars( 3, array(
'description' => __( 'Widget area found in sidebar of theme.', 'groundfloor' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
) );
register_sidebar( array(
'name' => 'Footer Left',
'description' => __( 'Footer widget area found at the bottom of the theme on the left side.', 'groundfloor' ),
'id' => 'footer-left',
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => 'Footer Middle',
'description' => __( 'Footer widget area found at the bottom of the theme in the middle.', 'groundfloor' ),
'id' => 'footer-middle',
'before_widget' => '',
'before_title' => '',
) );
register_sidebar( array(
'name' => 'Footer Right',
'description' => __( 'Footer widget area found at the bottom of the theme on the right side.', 'groundfloor' ),
'id' => 'footer-right',
'before_widget' => '',
'before_title' => '',
) );
if ( ! function_exists( 'gf_dynamic_copyright' ) ) {
/**
* Ground Floor Dynamic Copyright
*
* Outputs a copyright notice with a beginning and ending date based on published posts.
*
* @param string $args
*
* Last modified April 16, 2012
* Changed from `bns_dynamic_copyright` to `gf_dynamic_copyright`
*/
function gf_dynamic_copyright( $args = '' ) {
/** Initialize variables */
$initialize_values = array( 'start' => '', 'copy_years' => '', 'url' => '', 'end' => '' );
$args = wp_parse_args( $args, $initialize_values );
$output = '';
/** Start common copyright notice */
empty( $args['start'] ) ? $output .= sprintf( __( 'Copyright', 'groundfloor' ) ) : $output .= $args['start'];
/* Calculate Copyright Years; and, prefix with Copyright Symbol */
if ( empty( $args['copy_years'] ) ) {
/** Get all posts */
$all_posts = get_posts( 'post_status=publish&order=ASC' );
/** Get first post */
$first_post = $all_posts[0];
/** Get date of first post */
$first_date = $first_post->post_date_gmt;
/** First post year versus current year */
$first_year = substr( $first_date, 0, 4 );
if ( $first_year == '' ) {
$first_year = date( 'Y' );
}
/** Add to output string */
if ( $first_year == date( 'Y' ) ) {
/** Only use current year if no posts in previous years */
$output .= ' © ' . date( 'Y' );
} else {
$output .= ' © ' . $first_year . "-" . date( 'Y' );
}
} else {
$output .= ' © ' . $args['copy_years'];
}
/** Create URL to link back to home of website */
empty( $args['url'] ) ? $output .= ' ' . get_bloginfo( 'name', 'display' ) .' ' : $output .= ' ' . $args['url'];
/** End common copyright notice */
empty( $args['end'] ) ? $output .= ' ' . sprintf( __( 'All rights reserved.', 'groundfloor' ) ) : $output .= ' ' . $args['end'];
/** Construct and sprintf the copyright notice */
$output = sprintf( __( ' %1$s ', 'groundfloor' ), $output );
echo apply_filters( 'gf_dynamic_copyright', $output, $args );
}
}
if ( ! function_exists( 'gf_theme_version' ) ) {
/**
* Ground Floor Theme Version
* Outputs the theme version and relevant details; if it is a Child-Theme it also outputs the Parent-Theme details
*
* @package GroundFloor
*
* @uses is_child_theme
* @uses parent
* @uses wp_get_theme
*
* @version 2.0
* @date July 5, 2012
* Removed code for calls to deprecated function `get_theme_data`
*/
function gf_theme_version () {
/** @var $active_theme_data - array object containing the current theme's data */
$active_theme_data = wp_get_theme();
if ( is_child_theme() ) {
/** @var $parent_theme_data - array object containing the Parent Theme's data */
$parent_theme_data = $active_theme_data->parent();
/** @noinspection PhpUndefinedMethodInspection - IDE commentary */
printf( __( '
%1$s theme, version %2$s, a Child-Theme of %3$s theme, version %4$s, from %5$s.', 'groundfloor' ),
$active_theme_data['Name'],
$active_theme_data['Version'],
$parent_theme_data['Name'],
$parent_theme_data['Version'],
'BuyNowShop.com' );
} else {
printf( __( '
%1$s theme, version %2$s, from %3$s.', 'groundfloor' ),
$active_theme_data['Name'],
$active_theme_data['Version'],
'BuyNowShop.com' );
}
}
}
/**
* Set the content width based on the theme's design and stylesheet
* Calculated from: Main Blog Layout section in style.css
*/
if ( !isset( $content_width ) ) $content_width = 620;
/** Tell WordPress to run ground_floor_setup() when the 'after_setup_theme' hook is run. */
add_action( 'after_setup_theme', 'ground_floor_setup' );
if ( ! function_exists( 'ground_floor_setup' ) ):
/**
* Ground Floor Setup
* Adds various core functionality to the theme
*
* @package GroundFloor
*
* @uses add_action
* @uses add_theme_support
* @uses get_locale
* @uses get_template_directory
* @uses get_template_directory_uri
* @uses gf_nav_menu
* @uses gf_list_pages
* @uses is_home
* @uses is_front_page
* @uses load_theme_textdomain
* @uses register_gf_menu
* @uses register_nav_menu
* @uses wp_list_pages
*
* @version 2.0
* @date July 6, 2012
* Removed code for calls to deprecated functions
* Updated inline documentation
*/
function ground_floor_setup(){
global $wp_version;
/** This theme uses post thumbnails */
add_theme_support( 'post-thumbnails', array( 'post', 'page' ) );
/** Add default posts and comments RSS feed links to head */
add_theme_support( 'automatic-feed-links' );
/** Add theme support for editor-style */
add_editor_style();
/** This theme allows users to set a custom background */
/** NB: Use the wf31.png for a higher definition (and larger) background image */
add_theme_support( 'custom-background', array(
'default-color' => '673000',
'default-image' => get_template_directory_uri() . '/images/wood-floor-background.jpg'
) );
if ( ! function_exists( 'gf_nav_menu' ) ) {
/** Ground Floor Navigation Menu - adds wp_nav_menu() custom menu support */
function gf_nav_menu() {
wp_nav_menu( array(
'menu_class' => 'nav-menu',
'theme_location' => 'top-menu',
'fallback_cb' => 'gf_list_pages'
) );
}
}
if ( ! function_exists( 'gf_list_pages' ) ) {
/** Ground Floor List Pages - used as callback function `gf_nav_menu` */
function gf_list_pages() {
if ( is_home() || is_front_page() ) { ?>
' . __( 'Posted', 'groundfloor' ) . ''
: $gf_no_title = __( 'Posted', 'groundfloor' );
$gf_no_title = apply_filters( 'dmm_use_posted', $gf_no_title );
return $gf_no_title;
}
}
// End: DMM Use Posted
/**
* Ground Floor Modified Post
*
* Outputs the modifying author name and date the post was modified if the post
* date and the last modified date are different.
*
* @internal Not currently implemented by default
*
* Last revised April 16, 2012
* @version 1.9
* Changed name to `gf_modified_post`
*
* @todo To be implemented ... 2.0?
*/
function gf_modified_post(){
/** */
if ( get_the_date() <> get_the_modified_date() ) {
echo ''; /* CSS wrapper for modified date details */
echo 'Last modified by ' . get_the_modified_author() . ' on ' . get_the_modified_date();
echo '
';
}
}
if ( ! function_exists( 'gf_wp_title' ) ) {
/**
* Ground Floor WP Title
*
* Utilizes the `wp_title` filter to add text to the default output
*
* @package GroundFloor
* @since 2.0
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_title
* @link https://gist.github.com/1410493
*
* @param string $old_title - default title text
* @param string $sep - separator character
* @param string $sep_location - left|right - separator placement in relationship to title
*
* @return string - new title text
*/
function gf_wp_title( $old_title, $sep, $sep_location ) {
global $page, $paged;
/** Set initial title text */
$gf_title_text = $old_title . get_bloginfo( 'name' );
/** Add wrapping spaces to separator character */
$sep = ' ' . $sep . ' ';
/** Add the blog description (tagline) for the home/front page */
$site_tagline = get_bloginfo( 'description', 'display' );
if ( $site_tagline && ( is_home() || is_front_page() ) )
$gf_title_text .= "$sep$site_tagline";
/** Add a page number if necessary */
if ( $paged >= 2 || $page >= 2 )
$gf_title_text .= $sep . sprintf( __( 'Page %s', 'groundfloor' ), max( $paged, $page ) );
return $gf_title_text;
}
}
add_filter( 'wp_title', 'gf_wp_title', 10, 3 );
/**
* Enqueue Comment Reply Script
*
* If the page being viewed is a single post/page; and, comments are open; and,
* threaded comments are turned on then enqueue the built-in comment-reply
* script.
*
* @package GroundFloor
* @since 2.0
*
* @uses comments_open
* @uses get_option
* @uses is_singular
* @uses wp_enqueue_script
*
* @todo Review comments_open conditional ... what if there are threaded comments and the comments are closed?
*/
if ( ! function_exists( 'gf_enqueue_comment_reply' ) ) {
function gf_enqueue_comment_reply() {
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
}
add_action( 'comment_form_before', 'gf_enqueue_comment_reply' );
/** Set the content width based on the theme's design and stylesheet, see #main-blog element in style.css */
if ( ! isset( $content_width ) ) $content_width = 640;