* @copyright Copyright (c) 2009-2014, Edward Caissie * * @version 2.0 * @date December 3, 2012 * * @version 2.1 * @date March 4, 2013 * Refactored code formatting and code block termination comments * * @version 2.1.1 * @date April 22, 2013 * Added 'SHADES_HOME_URL' constant */ /** Define constant for easier updating */ define( 'SHADES_HOME_URL', 'BuyNowShop.com' ); /** Widget definition */ register_sidebars( 2, array( 'description' => __( 'This is a widget area in the Theme sidebar', 'shades' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); if ( ! function_exists( 'shades_dynamic_copyright' ) ) { /** * Shades Dynamic Copyright * Creates a dynamic Copyright by statement by reading the year of the first * published post and appending the current year as well as minimal boiler- * plate text. Output is then echoed via an apply_filters call. * * @package Shades * @since 1.3.3 * * @param string $args * * @internal param string start - initial text * @internal param string copy_years - (constructed) date text * @internal param string url - url link * @internal param string end - closing text * @internal param int transient_refresh - refresh in seconds; default one (1) month * * @uses __ * @uses apply_filters * @uses esc_attr * @uses get_bloginfo * @uses get_posts * @uses get_transient * @uses home_url * @uses set_transient * @uses wp_parse_args * * @version 1.8 * @date April 20, 2012 * Renamed to `shades_dynamic_copyright` * * @version 2.2.1 * @date May 31, 2014 * Improve performance impact by adding transient with one month refresh */ function shades_dynamic_copyright( $args = '' ) { $defaults = array( 'start' => '', 'copy_years' => '', 'url' => '', 'end' => '', 'transient_refresh' => 2592000 ); $args = wp_parse_args( $args, $defaults ); /** Initialize the output variable to empty */ $output = ''; /** Start common copyright notice */ empty( $args['start'] ) ? $output .= sprintf( __( 'Copyright', 'shades' ) ) : $output .= $args['start']; /** Calculate Copyright Years; and, prefix with Copyright Symbol */ if ( empty( $args['copy_years'] ) ) { /** Take some of the load off with a transient of the first post */ if ( ! get_transient( 'shades_copyright_first_post' ) ) { /** @var $all_posts - retrieve all published posts in ascending order */ $all_posts = get_posts( 'post_status=publish&order=ASC' ); /** @var $first_post - get the first post */ $first_post = $all_posts[0]; /** Set the transient (default: one month) */ set_transient( 'shades_copyright_first_post', $first_post, $args['transient_refresh'] ); } /** End if - no transient set */ /** @var $first_date - get the date in a standardized format */ $first_date = get_transient( 'shades_copyright_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' ); } /** End if - first year */ /** 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' ); } /** End if - first year */ } else { $output .= ' © ' . $args['copy_years']; } /** End if - empty 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.', 'shades' ) ) : $output .= ' ' . $args['end']; /** Construct and sprintf the copyright notice */ $output = sprintf( __( ' %1$s ', 'shades' ), $output ); echo apply_filters( 'shades_dynamic_copyright', $output, $args ); } /** End function - dynamic copyright */ } /** End if - function exists */ if ( ! function_exists( 'shades_theme_version' ) ) { /** * BNS Theme Version * Displays the theme name and version; also accounts for a Child-Theme if present * * @uses is_child_theme * @uses wp_get_theme * @uses parent * * @version 1.9.1 * Removed deprecated function call * * @version 2.1.1 * @date April 22, 2013 * Added 'SHADES_HOME_URL' constant in place of the hardcoded domain URL * Re-Added Theme Version output for Parent-Theme usage */ function shades_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, v%2$s, was grown from the %3$s theme, v%4$s, created by %5$s.', 'shades' ), $active_theme_data['Name'], $active_theme_data['Version'], $parent_theme_data['Name'], $parent_theme_data['Version'], '' . SHADES_HOME_URL . '' ); } else { printf( __( '
This site is using the %1$s theme, v%2$s, from ' . SHADES_HOME_URL . '.', 'shades' ), $active_theme_data->get( 'Name' ), $active_theme_data->get( 'Version' ) ); } /** End if - is child theme */ } /** End function - theme version */ } /** End if - function exists */ /** Tell WordPress to run shades_setup() when the 'after_setup_theme' hook is run. */ add_action( 'after_setup_theme', 'shades_setup' ); if ( ! function_exists( 'shades_setup' ) ) { /** * Shades Setup * Defines for core functionality supported by theme * * @version 1.8 * @date April 18, 2012 * Addressed call to deprecated function `add_custom_background` * * @version 2.0 * @date December 3, 2012 * Added classes to inline glyph span styles and moved to style.css */ function shades_setup() { /** 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 Custom Background Support */ add_theme_support( 'custom-background', array( 'default-color' => 'fff', 'default-image' => '' ) ); /** Add post-formats support */ add_theme_support( 'post-formats', array( 'aside', 'quote', 'status' ) ); /** Assign glyphs via unique functions so they can be over-written in Child-Theme */ if ( ! function_exists( 'shades_glyph_aside' ) ) { /** * Shades Glyph - Aside */ function shades_glyph_aside() { $aside_glyph = ''; /** default: exclamation mark */ $aside_glyph .= __( '!', 'shades' ); $aside_glyph .= ''; echo apply_filters( 'shades_glyph_aside', $aside_glyph ); } /** End function - glyph aside */ } /** End if - function exists */ if ( ! function_exists( 'shades_glyph_quote' ) ) { /** * Shades Glyph - Quote */ function shades_glyph_quote() { $quote_glyph = ''; /** default: double-quote */ $quote_glyph .= __( '"', 'shades' ); $quote_glyph .= ''; echo apply_filters( 'shades_glyph_quote', $quote_glyph ); } /** End function - glyph quote */ } /** End if - function exists */ if ( ! function_exists( 'shades_glyph_status' ) ) { /** * Shades Glyph - Status */ function shades_glyph_status() { $status_glyph = ''; /** default: amphere (at sign) */ $status_glyph .= __( '@', 'shades' ); $status_glyph .= ''; echo $status_glyph; } /** End function - glyph status */ } /** End if - function exists */ /** Add theme support for editor-style */ add_editor_style(); if ( ! function_exists( 'shades_nav_menu' ) ) { /** * Shades Navigation Menu * Adds custom menu support * * @uses shades_list_pages * @uses wp_nav_menu */ function shades_nav_menu() { if ( function_exists( 'wp_nav_menu' ) ) { wp_nav_menu( array( 'menu_class' => 'nav-menu', 'theme_location' => 'top-menu', 'fallback_cb' => 'shades_list_pages' ) ); } else { shades_list_pages(); } /** End if function exists */ } /** End function - nav menu */ } /** End if - function exists */ if ( ! function_exists( 'shades_list_pages' ) ) { /** * Shades List Pages * Fallback for Shades Navigation Menu * * @uses wp_list_pages */ function shades_list_pages() { if ( is_home() || is_front_page() ) { ?> = 2 || $page >= 2 ) { $shades_title_text .= $sep . sprintf( __( 'Page %s', 'shades' ), max( $paged, $page ) ); } /** End if - paged */ return $shades_title_text; } /** End function - wp title */ } /** End if - function exists */ add_filter( 'wp_title', 'shades_wp_title', 10, 3 ); if ( ! function_exists( 'shades_modified_post' ) ) { /** * Shades Modified Post * If the post time and the last modified time are different display * modified date and time * * @uses (global) $post * @uses get_post_meta * @uses get_userdata * @uses get_the_time * @uses get_the_modified_time * @uses home_url * @uses get_the_modified_date * * Last revised April 20, 2012 * @version 1.8 * Added link to modified author's post archive. */ function shades_modified_post() { global $post; $last_user = ''; if ( $last_id = get_post_meta( $post->ID, '_edit_last', true ) ) { $last_user = get_userdata( $last_id ); } /** End if - last id */ if ( get_the_time() <> get_the_modified_time() ) { /** CSS wrapper for modified date details */ echo '
'; printf( __( 'Last modified by %1$s on %2$s @ %3$s.', 'shades' ), '' . $last_user->display_name . '', get_the_modified_date( get_option( 'date_format' ) ), get_the_modified_time( get_option( 'time_format' ) ) ); echo '
'; } /** End if - get the time */ } /** End function - modified post */ } /** End if - function exists */ if ( ! function_exists( 'shades_use_posted' ) ) { /** * Shades Use Posted * For posts without titles * * @uses get_the_title * @uses get_permalink * * @return string text only|URL to post */ function shades_use_posted() { $shades_no_title = get_the_title(); empty( $shades_no_title ) ? $shades_no_title = '' . __( 'Posted', 'shades' ) . '' : $shades_no_title = __( 'Posted', 'shades' ); return $shades_no_title; } /** End function - use posted */ } /** End if - function exists */ /** * 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 Shades * @since 1.9 * * @uses comments_open * @uses get_option * @uses is_singular * @uses wp_enqueue_script * * @version 2.0 * @date December 7, 2012 * Change conditional to show "Threaded Comments" if they are open or closed. */ if ( ! function_exists( 'shades_enqueue_comment_reply' ) ) { function shades_enqueue_comment_reply() { if ( is_singular() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } /** End if - is singular */ } /** End function - enqueue comment reply */ } /** End if - function exists */ add_action( 'comment_form_before', 'shades_enqueue_comment_reply' ); /** * Show Featured Image * Displays the Featured Image allowing the size to be set * * @package Shades * @since 2.1.1 * * @param $size * * @uses has_post_thumbnail * @uses the_post_thumbnail */ function shades_show_featured_image( $size ) { if ( is_home() || is_front_page() && has_post_thumbnail() ) { the_post_thumbnail( $size, array( 'class' => 'aligncenter' ) ); } /** End if - is home */ } /** End function - show featured image */ /** Set the content width based on the theme's design and stylesheet, see #the-loop element in style.css */ if ( ! isset( $content_width ) ) { $content_width = 630; } /** End if - content width */