>>> DO NOT EDIT THIS FILE <<<<
*
* Warning! DO NOT EDIT THIS FILE, or any other theme file! If you edit ANY theme
* file, all your changes will be LOST when you update the theme to a newer version.
* Instead, if you need to change theme functionality, CREATE A CHILD THEME!
*
* >>>> DO NOT EDIT THIS FILE <<<<
*
* Sets up the theme and provides some helper functions. Some helper functions
* are used in the theme as custom template tags. Others are attached to action and
* filter hooks in WordPress to change core functionality.
*
* The first function, aspen_setup(), sets up the theme by registering support
* for various features in WordPress, such as post thumbnails, navigation menus, and the like.
*
* When using a child theme (see http://codex.wordpress.org/Theme_Development and
* http://codex.wordpress.org/Child_Themes), you can override certain functions
* (those wrapped in a function_exists() call) by defining them first in your child theme's
* functions.php file. The child theme's functions.php file is included before the parent
* theme's file, so the child theme functions would be used.
*
* Functions that are not pluggable (not wrapped in function_exists()) are instead attached
* to a filter or action hook. The hook can be removed by using remove_action() or
* remove_filter() and you can attach your own function to the hook.
*
* We can remove the parent theme's hook only after it is attached, which means we need to
* wait until setting up the child theme:
*
*
* add_action( 'after_setup_theme', 'my_child_theme_setup' );
* function my_child_theme_setup() {
* // We are providing our own filter for excerpt_length (or using the unfiltered value)
* remove_filter( 'excerpt_length', 'aspen_excerpt_length' );
* ...
* }
*
*
* For more information on hooks, actions, and filters, see http://codex.wordpress.org/Plugin_API.
*
* @package WordPress
* @subpackage Aspen
* @since Aspen 1.0
*
* This file formatted 4/8 on tabs
*
* >>>> DO NOT EDIT THIS FILE <<<<
*/
/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) )
$content_width = 705; // 940 * .75
/**
* Tell WordPress to run aspen_setup() when the 'after_setup_theme' hook is run.
*/
add_action( 'after_setup_theme', 'aspen_setup' );
if ( ! function_exists( 'aspen_setup' ) ) {
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which runs
* before the init hook. The init hook is too late for some features, such as indicating
* support post thumbnails.
*
* To override aspen_setup() in a child theme, add your own aspen_setup to your child theme's
* functions.php file.
*
* @uses load_theme_textdomain() For translation/localization support.
* @uses add_editor_style() To style the visual editor.
* @uses add_theme_support() To add support for post thumbnails, automatic feed links, and Post Formats.
* @uses register_nav_menus() To add support for navigation menus.
* @uses register_default_headers() To register the default custom header images provided with the theme.
* @uses set_post_thumbnail_size() To set a custom post thumbnail size.
*
* @since Aspen 1.0
*
* @uses add_theme_support( 'custom-header', $aspen_header ) for WP 3.4+ custom header
*/
function aspen_setup() {
/* Make Aspen available for translation. */
$tpath = trailingslashit(get_template_directory());
load_theme_textdomain( 'aspen', $tpath . 'languages' );
$locale = get_locale();
$locale_file = $tpath . "languages/$locale.php";
if ( is_readable( $locale_file ) )
require_once( $locale_file );
// This theme styles the visual editor with editor-style.css to match the theme style.
add_editor_style();
// Add default posts and comments RSS feed links to
.
add_theme_support( 'automatic-feed-links' );
// Aspen supports two main nav menus and an alternate mobile menu
register_nav_menus( array(
'primary' => 'Primary Navigation: if specified, used instead of Default menu',
'secondary' => 'Secondary Navigation: if specified, adds 2nd menu bar'
) );
// Add support for a variety of post formats
add_theme_support( 'post-formats', array( 'aside', 'audio', 'chat', 'gallery', 'image', 'link', 'quote', 'status','video') );
// This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images
add_theme_support( 'post-thumbnails' );
// now, need Aspen settings available for everything else
aspen_init_opts('functions');
$width = aspen_getopt('theme_width_int');
if (!$width)
$width = 940;
$height = aspen_getopt('header_image_height_int');
global $aspen_header;
$aspen_header = array(
'default-image' => '%s/images/headers/maroon-bells.jpg',
'random-default' => true,
'width' => $width,
'height' => $height,
'flex-height' => true,
'flex-width' => true,
'default-text-color' => '',
'header-text' => false,
'uploads' => true,
'wp-head-callback' => '',
'admin-head-callback' => 'aspen_admin_header_style',
'admin-preview-callback' => '',
);
global $content_width;
$content_width = $width; // let the WP $content_width be the same as theme width, and let our responsive CSS make it work.
if (function_exists('get_custom_header')) {
add_theme_support( 'custom-header', $aspen_header );
add_theme_support( 'custom-background' );
}
// We'll be using post thumbnails for custom header images on posts and pages.
// We want them to be the size of the header image that we just defined
// Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
set_post_thumbnail_size( $aspen_header['width'], $aspen_header['height'], true );
// Add Aspen's custom image sizes
add_image_size( 'large-feature',
$aspen_header['width'], $aspen_header['height'], true ); // Used for large feature (header) images
add_image_size( 'small-feature', 500, 300 ); // Used for featured posts if a large-feature doesn't exist
// ... and thus ends the changeable header business.
aspen_register_header_images();
}
} // aspen_setup
function aspen_admin_init_cb() { // action definition
aspen_sapi_options_init(); // This must come first as it hooks update_option used elsewhere
return;
}
if ( ! function_exists('aspen_init_opts')) {
function aspen_init_opts($who='') {
// this sets the essential values. These are the minimally required values to get the theme Preview to work.
$defaults = array(
'theme_width_int' => 940, /* should all be the same */
'header_image_height_int' => 188,
'aspen_version_id' => ASPEN_VERSION_ID,
'style_version' => 1,
'site_margins_int' => 20,
'site_fontsize_int' => 12,
'infobar_location' => 'top',
'themename' => 'none-preview',
'sb_right_1_col_width_int' => '25',
'sb_right_2_col_width_int' => '33',
'sb_left_1_col_width_int' => '25',
'sb_left_2_col_width_int' => '33',
'sb_split_left_width_int' => '17',
'sb_split_right_width_int' => '17',
'sb_2_left_area_int' => '55'
);
$changed = false;
/* initialize other stuff that needs a value */
/* now if there were no settings, need to fill in the default theme and Section and SEO default */
foreach ($defaults as $opt => $val) {
$optval = aspen_getopt($opt);
if ((!$optval && $optval !== '0')) {
$changed = true;
aspen_setopt($opt,$val,false); // set, don't save
}
}
if ($changed) {
aspen_save_opts('aspen_init_opts',false); // changed some things, so re-save
}
do_action('aspen_init_opts');
}
}
if (! function_exists( 'aspen_register_header_images')) {
function aspen_register_header_images() {
// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
register_default_headers( array(
'maroon-bells' => array(
'url' => '%s/images/headers/maroon-bells.jpg',
'thumbnail_url' => '%s/images/headers/maroon-bells-thumbnail.jpg',
/* translators: header image description */
'description' => aspen_t_( 'Maroon Bells' /*a*/ )
),
'aspen-grove' => array (
'url' => "%s/images/headers/aspen-grove.jpg",
'thumbnail_url' => "%s/images/headers/aspen-grove-thumbnail.jpg",
'description' => aspen_t_( 'Aspen Grove' /*a*/ )
),
'mountain-stream' => array(
'url' => '%s/images/headers/mountain-stream.jpg',
'thumbnail_url' => '%s/images/headers/mountain-stream-thumbnail.jpg',
/* translators: header image description */
'description' => aspen_t_( 'Mountain Stream' /*a*/ )
),
'mum' => array (
'url' => "%s/images/headers/mum.jpg",
'thumbnail_url' => "%s/images/headers/mum-thumbnail.jpg",
'description' => aspen_t_( 'Mum' /*a*/ )
),
'sopris' => array (
'url' => "%s/images/headers/sopris.jpg",
'thumbnail_url' => "%s/images/headers/sopris-thumbnail.jpg",
'description' => aspen_t_( 'Sopris' /*a*/ )
)
) );
}
}
if ( ! function_exists( 'aspen_header_style' ) ) {
/**
* Styles the header image and text displayed on the blog
*
* @since Aspen 1.0s
*/
function aspen_header_style() {
// we don't need to do anything
}
} // aspen_header_style
if ( ! function_exists( 'aspen_admin_header_style' ) ) {
/**
* Styles the header image displayed on the Appearance > Header admin panel.
* @since Aspen 1.0
*/
function aspen_admin_header_style() {
global $aspen_header;
?>
Featured Images at least as wide as default header image will be used as a replacement for default image for this page or post. Smaller images used as "thumbnail" at beginning of Page/Post.';
}
add_filter('admin_post_thumbnail_html','aspen_featured_image_info');
/**
* Sets the post excerpt length to 40 words.
*
* To override this length in a child theme, remove the filter and add your own
* function tied to the excerpt_length filter hook.
*/
function aspen_excerpt_length( $length ) {
$val = aspen_t_get('excerpt_length');
if (!$val)
$val = aspen_getopt('excerpt_length');
if ($val > 0 || $val === '0')
return $val;
return 40;
}
add_filter( 'excerpt_length', 'aspen_excerpt_length' );
/**
* Returns a "Continue Reading" link for excerpts
*/
if ( ! function_exists('aspen_continue_reading_link')) {
function aspen_continue_reading_link($add_a = true) {
$rep = aspen_t_get('more_msg');
if (!$rep)
$rep = aspen_getopt('excerpt_more_msg');
if (!empty($rep))
$msg = $rep;
else
$msg = __( 'Continue reading →','aspen');
if ($add_a)
return ' ' . $msg . '';
else
return $msg;
}
}
/**
* Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and aspen_continue_reading_link().
*
* To override this in a child theme, remove the filter and add your own
* function tied to the excerpt_more filter hook.
*/
function aspen_auto_excerpt_more( $more ) {
return ' …' . aspen_continue_reading_link();
}
add_filter( 'excerpt_more', 'aspen_auto_excerpt_more' );
/**
* Adds a pretty "Continue Reading" link to custom post excerpts.
*
* To override this link in a child theme, remove the filter and add your own
* function tied to the get_aspen_the_excerpt_featured filter hook.
*/
function aspen_custom_excerpt_more( $output ) {
if ( has_excerpt() && !is_attachment() ) {
$output .= aspen_continue_reading_link();
}
return $output;
}
add_filter( 'the_excerpt', 'aspen_custom_excerpt_more' );
if ( ! function_exists('aspen_trim_excerpt') ) {
function aspen_trim_excerpt($text = '') {
$raw_excerpt = $text;
if ( '' == $text ) {
$text = get_the_content('');
$orig_text_len = strlen($text);
$text = strip_shortcodes( $text );
// $stripped_text_len = strlen($text);
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$excerpt_length = apply_filters('excerpt_length', 55);
$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
$stripped_text_len = strlen($text);
}
if ('' == $raw_excerpt && $orig_text_len > $stripped_text_len && get_post_format() == '') { // have stripped shortcodes
if ( strpos($text,$excerpt_more) === false)
$text .= $excerpt_more;
}
return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
}
}
remove_filter( 'get_the_excerpt', 'wp_trim_excerpt' );
add_filter( 'get_the_excerpt', 'aspen_trim_excerpt' );
/**
* Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link.
*
* To override this in a child theme, remove the filter and optionally add
* your own function tied to the wp_page_menu_args filter hook.
*/
function aspen_page_menu_args( $args ) {
if (aspen_getopt('menu_nohome'))
$args['show_home'] = false;
else
$args['show_home'] = true;
// look for pages to hide from menu
$ex_list = '';
$hide_pages = get_pages(array('hierarchical' => 0, 'meta_key' => 'pp_hide_on_menu')); // get list of excluded pages
if (!empty($hide_pages)) {
foreach ($hide_pages as $page) {
$ex_list .= $page->ID . ','; /* trailing , doesn't matter */
}
}
if ($ex_list != '')
$args['exclude'] = $ex_list;
return $args;
}
add_filter( 'wp_page_menu_args', 'aspen_page_menu_args' );
/**
* Register our sidebars and widgetized areas.
*
* @since Aspen 1.0
*/
function aspen_widgets_init() {
// Big Top located at the top of the sidebar.
aspen_register_sidebar( aspen_t_( 'Primary (top) Sidebar' /*a*/ ),
'primary-widget-area',
aspen_t_( 'Primary (top) sidebar widget area, displays above Upper Sidebar (or Left+Right for multi-column layouts).' /*a*/ ));
// Primary located at the top of the sidebar.
aspen_register_sidebar( aspen_t_( 'Upper/Right Sidebar' /*a*/ ),
'right-widget-area', aspen_t_( 'The Upper Sidebar - or Right Sidebar for multi-column layouts.' /*a*/ ));
// Lower/Left located below the Primary Widget Area in the sidebar. Empty by default.
aspen_register_sidebar( aspen_t_( 'Lower/Left Sidebar' /*a*/ ),
'left-widget-area', aspen_t_( 'The Lower Sidebar - or Left Sidebar for multi-column layouts.' /*a*/ ));
// Mobile device
aspen_register_sidebar(aspen_t_( 'Mobile Device Widget Area' /*a*/ ),
'mobile-widget-area',
aspen_t_( 'This widget area provides an alternate area for Mobile Devices. It is displayed between the content and the footer, and uses the same styling as the Primary (top) Sidebar.' /*a*/ ));
## Site-wide top area
aspen_register_sidebar(aspen_t_( 'Sitewide Top Widget Area' /*a*/ ),
'sitewide-top-widget-area',
aspen_t_( 'This widget area appears at the top of the content area on all site static pages and post pages (including special post pages) EXCEPT pages using the blank or iframe page templates.' /*a*/ ));
## Site-wide bottom area
aspen_register_sidebar(aspen_t_( 'Sitewide Bottom Widget Area' /*a*/ ),
'sitewide-bottom-widget-area',
aspen_t_( 'This widget area appears at the bottom of the content area on all site static pages and post pages (including special post pages) EXCEPT pages using the blank or iframe page templates.' /*a*/ ));
## page top widget area
aspen_register_sidebar(aspen_t_( 'Pages Top Widget Area' /*a*/ ),
'top-widget-area',
aspen_t_( 'The top widget area appears above the content area of pages. It is not displayed on archive-like post pages (archives, etc.).' /*a*/ ));
## page bottom widget area
aspen_register_sidebar(aspen_t_( 'Pages Bottom Widget Area' /*a*/ ),
'bottom-widget-area', aspen_t_( 'The bottom widget area appears below the content area. It is not displayed on archive-like post pages.' /*a*/ ));
## posts top widget area
aspen_register_sidebar(aspen_t_( 'Blog Top Widget Area' /*a*/ ),
'blog-top-widget-area',
aspen_t_( 'The blog top widget area appears above the content area of blog pages, including page with posts templates. It is not displayed on archive-like post pages.' /*a*/ ));
## posts blog bottom widget area
aspen_register_sidebar(aspen_t_( 'Blog Bottom Widget Area' /*a*/ ),
'blog-bottom-widget-area', aspen_t_( 'The blog bottom widget area appears below the content area of blog pages, including page with posts templates. It is not displayed on archive-like post pages.' /*a*/ ));
## Special Post Pages Top Widget area
aspen_register_sidebar(aspen_t_( 'Archive-like Pages Top Widget Area' /*a*/ ),
'postpages-widget-area',
aspen_t_( 'This widget area will appear at the top of archive-like post pages (archives, attachment, author, category, single post).' /*a*/ ));
// Area 3, located in the footer. Empty by default.
aspen_register_sidebar( aspen_t_( 'First Footer Widget Area' /*a*/ ),
'first-footer-widget-area',
aspen_t_( 'The first footer widget area. Note: Footer widget areas auto-adujust width depending on how many areas you use.' /*a*/ ));
// Area 4, located in the footer. Empty by default.
aspen_register_sidebar(aspen_t_( 'Second Footer Widget Area' /*a*/ ),
'second-footer-widget-area',
aspen_t_( 'The second footer widget area' /*a*/ ));
// Area 5, located in the footer. Empty by default.
aspen_register_sidebar(aspen_t_( 'Third Footer Widget Area' /*a*/ ),
'third-footer-widget-area',
aspen_t_( 'The third footer widget area' /*a*/ ));
aspen_register_sidebar(aspen_t_( 'Fourth Footer Widget Area' /*a*/ ),
'fourth-footer-widget-area',
aspen_t_( 'The fourth footer widget area' /*a*/ ));
}
add_action( 'widgets_init', 'aspen_widgets_init' );
if ( ! function_exists('aspen_register_sidebar')) {
/**
* Register widgetized areas: two default sidebars, two content areq sidebars,
* a top area for specialized post pages, alternative sidebar for template pages,
* and a header widget area.
*
* To override aspen_widgets_init() in a child theme, remove the action hook and add your own
* function tied to the init hook.
*
* @uses register_sidebar
*/
function aspen_register_sidebar($name, $id, $desc, $altclass='') {
if ($altclass != '') $altclass .= ' ';
register_sidebar( array(
'name' => ' ' . $name, /* the makes our names closer to unique */
'id' => $id,
'description' => $desc,
'before_widget' => '',
'before_title' => '
]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches ) )
return false;
return esc_url_raw( $matches[1] );
}
}
/**
* Count the number of footer sidebars to enable dynamic classes for the footer
*/
if ( ! function_exists('aspen_footer_sidebar_class')) {
function aspen_footer_sidebar_class() {
$count = 0;
if ( is_active_sidebar( 'first-footer-widget-area' ) )
$count++;
if ( is_active_sidebar( 'second-footer-widget-area' ) )
$count++;
if ( is_active_sidebar( 'third-footer-widget-area' ) )
$count++;
if ( is_active_sidebar( 'fourth-footer-widget-area' ) )
$count++;
$class = '';
switch ( $count ) {
case '1':
$class = 'one';
break;
case '2':
$class = 'two';
break;
case '3':
$class = 'three';
break;
case '4':
$class = 'four';
break;
}
if ( $class )
echo 'class="' . $class . '"';
}
}
if ( ! function_exists( 'aspen_comment' ) ) {
/**
* Template for comments and pingbacks.
*
* To override this walker in a child theme without modifying the comments template
* simply create your own aspen_comment(), and that function will be used instead.
*
* Used as a callback by wp_list_comments() for displaying the comments.
*
* @since Aspen 1.0
*/
function aspen_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) {
case 'pingback' :
case 'trackback' :
?>
' ) );
}
}
// ===================================== Aspen Page / Post Sections =========================
// for pages...
if ( !function_exists( 'aspen_page_title')) {
function aspen_page_title() {
// The page title
?>
:
- %s',
esc_url( get_permalink() ), esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_time() ));
?>
\n\t\t\t";
$po .= sprintf( __( 'Posted on by %7$s','aspen'),
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
sprintf( esc_attr(__( 'View all posts by %s','aspen')), get_the_author() ),
esc_html( get_the_author() )
);
if ( (aspen_getopt('show_post_avatar')
|| aspen_is_checked_post_opt('pp_show_post_avatar')
|| aspen_t_get('show_avatar'))
&& aspen_getopt('show_tiny_avatar')) {
$po .= '';
$po .= get_avatar( get_the_author_meta('user_email') ,22,null,'avatar' );
$po .= '';
}
$po .= "\n\t\t\t";
echo apply_filters('aspen_posted_on',$po, $type);
}
}
if (! function_exists('aspen_format_posted_on_footer')) {
function aspen_format_posted_on_footer($who) {
if (aspen_is_checked_post_opt('pp_hide_bottom_post_meta') || aspen_is_checked_page_opt('pp_hide_infobot')) {
aspen_edit_link();
return;
}
?>
\n";
if ($type == 'single') {
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( __( ', ','aspen') );
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', __( ', ','aspen') );
if ( '' != $tags_list ) {
$utility_text = __( 'This entry was posted in %1$s and tagged %2$s by %5$s. Bookmark the permalink.','aspen');
} elseif ( '' != $categories_list ) {
$utility_text = __( 'This entry was posted in %1$s by %5$s. Bookmark the permalink.','aspen');
} else {
$utility_text = __( 'This entry was posted by %5$s. Bookmark the permalink.','aspen');
}
if (aspen_meta_icons_class() == '') { // not showing icons
$pi .= sprintf(
$utility_text,
$categories_list,
$tags_list,
esc_url( get_permalink() ),
the_title_attribute( 'echo=0' ),
get_the_author(),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) )
);
} else {
if ( $categories_list ) {
$cat_count = count( get_the_category() );
if ($cat_count < 2 && aspen_getopt_checked('hide_singleton_cat'))
$pi .= "\t\t\t\n";
else
$pi .="\t\t\t\n";
$pi .= sprintf( __( 'Posted in %2$s','aspen'), 'entry-utility-prep entry-utility-prep-cat-links', $categories_list );
$pi .="\t\t\t\n";
} // End if categories
/* translators: used between list items, there is a space after the comma */
if ($tags_list ) {
$pi .="\t\t\t\n";
$pi .= sprintf( __( 'Tagged %2$s','aspen'), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list );
$pi .= "\t\t\t\n";
} // End if $tags_list
$pi .= '' . __('permalink','aspen') . '';
} // end not showing icons
$pi .= aspen_edit_link('noecho');
} else if ($type == 'reply') {
$dummy = true;
} else { // else not single
$show_sep = false;
if ( 'page' != get_post_type() ) { // Hide category and tag text for pages on Search
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( __( ', ','aspen') );
$cat_count = count( get_the_category() );
$skip = ($cat_count < 2 && aspen_getopt_checked('hide_singleton_cat'));
if ( $categories_list && !$skip) {
$pi .= '';
$pi .= sprintf( __( 'Posted in %2$s','aspen'), 'entry-utility-prep entry-utility-prep-cat-links', $categories_list );
$show_sep = true;
$pi .= '';
} // End if categories
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', __( ', ','aspen') );
if ( $tags_list ) {
if ( $show_sep ) {
$pi .= ' | ';
} // End if $show_sep
$pi .= '';
$pi .= sprintf( __( 'Tagged %2$s','aspen'), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list );
$show_sep = true;
$pi .= '';
} // End if $tags_list
} // End if 'page' != get_post_type()
if ( comments_open() ) {
if ( $show_sep ) {
$pi .= ' | ';
} // End if $show_sep
$pi .= '';
ob_start(); // yuck - why doesn't WP make all the utilities have an echo option??
comments_popup_link( '' . __( 'Leave a reply','aspen') . '', __( '1 Reply','aspen'),
__( '% Replies','aspen') );
$pi .= ob_get_clean();
$pi .= '';
} // End if comments_open()
$pi .= aspen_edit_link('noecho');
} // end non-single
$pi .= "\n";
echo apply_filters('aspen_posted_in',$pi,$type);
}
}
if ( ! function_exists( 'aspen_post_top_info' ) ) {
/**
* Prints HTML with meta information for the top meta line.
*
* @since Aspen 1.0
*/
function aspen_post_top_info($type='') {
// $type for single
aspen_posted_on($type);
}
}
if ( ! function_exists( 'aspen_post_bottom_info' ) ) {
/**
* Prints HTML with meta information for the bottom meta line.
*
* @since Aspen 1.0
*/
function aspen_post_bottom_info($type='') {
aspen_posted_in($type);
}
}
if ( ! function_exists( 'aspen_comments_popup_link' ) ) {
function aspen_comments_popup_link() {
/* display comment bubble for posts */
if ( !aspen_getopt_checked('pp_hide_post_bubble') && !aspen_is_checked_post_opt('pp_hide_post_bubble')
&& comments_open() && ! post_password_required() ) { ?>
\n";
return true;
}
return false;
}
}
if ( ! function_exists('aspen_use_fi_in_content')) {
function aspen_use_fi_in_content($page_type = 'post') {
global $aspen_header;
$default = 'thumbnail';
$width = '';
if (get_post_thumbnail_id()) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( ), 'full' ); // (url, width, height)
$href = $image[0];
if ($image[1] < $aspen_header['width'] || aspen_getopt('hide_featured_header')) {
switch ($page_type) {
case 'page':
$default = 'medium'; // medium is default for pages
$width = aspen_getopt('featured_page_width');
$size = aspen_getopt('fi_size_page');
break;
case 'single':
$default = 'medium'; // medium is default for single posts
$width = aspen_getopt('featured_single_width');
$size = aspen_getopt('fi_size_post_single');
break;
default: // excerpts
$width = aspen_getopt('featured_blog_width');
$size = aspen_getopt('fi_size_post');
$href = get_permalink();
break;
}
if ($width != '0') { // don't emit any FI if the width is explicit set to 0
if (empty($size)) $size = $default;
?>
= 2 || $page >= 2 )
&& aspen_post_count() <= $n1)
return false;
}
$pwp = aspen_get_per_page_value('wvr_pwp_type');
if ($pwp == 'full') // need to check before archive/search
return false; // override global setting
if ($pwp == 'excerpt')
return true; // override global setting
if (is_search()) {
return !aspen_getopt_checked('fullpost_search');
}
if (is_archive()) {
return !aspen_getopt_checked('fullpost_archive');
}
return aspen_getopt_checked('excerpt_blog');
}
}
if ( ! function_exists('aspen_page_menu')) {
function aspen_page_menu() {
/* handle sf-menu for wp_page_menu */
$menu = wp_page_menu(array('echo' => false));
if ( aspen_use_sf() ) {
$ulpos = stripos($menu, '
');
if ($ulpos !== false) {
echo substr_replace($menu, '
',$ulpos, 4);
}
} else {
echo $menu;
}
}
}
// ========================= sidebars ================================
if ( ! function_exists( 'aspen_get_sidebar_left' ) ) {
function aspen_get_sidebar_left($who) {
$layout = aspen_get_page_layout($who);
switch ($layout) {
case 'right-1-col':
case 'right-2-col':
case 'right-2-col-bottom':
break; // no left sidebar for these layouts
case 'split':
get_sidebar('left-split');
break;
case 'left-1-col':
case 'left-2-col':
case 'left-2-col-bottom':
get_sidebar($layout);
break;
default:
break;
}
}
} // end function exists
if ( ! function_exists( 'aspen_get_sidebar_right' ) ) {
function aspen_get_sidebar_right($who) {
$layout = aspen_get_page_layout($who);
switch ($layout) {
case 'right-1-col':
case 'right-2-col':
case 'right-2-col-bottom':
get_sidebar($layout);
break;
case 'split':
get_sidebar('right-split');
break;
case 'left-1-col':
case 'left-2-col':
case 'left-2-col-bottom':
break; // no right sidebar for these layouts
default:
break;
}
}
} // end function exists
if ( ! function_exists( 'aspen_get_sidebar_top' ) ) {
function aspen_get_sidebar_top($who) {
if (!aspen_is_checked_page_opt('sitewide-top-widget-area'))
aspen_put_widgetarea('sitewide-top-widget-area','sidebar_top'); // sitewide top
if (!aspen_is_checked_page_opt('top-widget-area')) {
switch ($who) {
case 'index':
case 'pwp':
case 'single':
aspen_put_widgetarea('blog-top-widget-area','sidebar_top');
break;
case 'page':
aspen_put_widgetarea('top-widget-area','sidebar_top');
break;
case '404':
case 'archive':
case 'author':
case 'category':
case 'search':
case 'tag':
aspen_put_widgetarea('postpages-widget-area','sidebar_top');
break;
case 'image':
default:
break;
}
} // end not per page hide
}
} // end function exists
if ( ! function_exists( 'aspen_get_sidebar_bottom' ) ) {
function aspen_get_sidebar_bottom($who) {
if (!aspen_is_checked_page_opt('bottom-widget-area')) {
switch ($who) {
case 'index':
case 'pwp':
case 'single':
aspen_put_widgetarea('blog-bottom-widget-area','sidebar_bottom');
break;
case 'page':
aspen_put_widgetarea('bottom-widget-area','sidebar_bottom');
break;
case 'archive':
case 'author':
case 'category':
case 'tag':
case 'search':
case '404':
break;
case 'image':
default:
break;
}
} // end not hide bottom per page
if (!aspen_is_checked_page_opt('sitewide-bottom-widget-area'))
aspen_put_widgetarea('sitewide-bottom-widget-area','sidebar_bottom'); // sitewide bottom
}
} // end function exists
if ( ! function_exists( 'aspen_get_page_layout' ) ) {
function aspen_get_page_layout($who) {
// determine the layout structure of a page from the settings.
// blogs, pages, and single will use the 'right-1-col' as a default
// others will be 'none' - no sidebars - by default
// each page can be set to its own default. Individual pages
// can be set to a layout on a per-page basis.
$default = aspen_getopt('layout_default');
if (!$default) $default = 'right-1-col'; // use something!
$arc_default = aspen_getopt('layout_default_archive');
if (!$arc_default) $arc_default = 'one-column'; // use something!
$per_page = aspen_get_per_page_value('pp_page_layout');
if ($per_page != '')
return $per_page;
switch ($who) {
case 'index':
case 'pwp':
$l = aspen_getopt('layout_blog');
return (!$l || $l == 'default') ? $default : $l;
case 'single':
if (aspen_is_checked_post_opt('pp_hide_sidebars'))
return 'one-column';
$l = aspen_getopt('layout_single');
return (!$l || $l == 'default') ? $default : $l;
case 'page':
$l = aspen_getopt('layout_page');
return (!$l || $l == 'default') ? $default : $l;
case 'archive':
$l = aspen_getopt('layout_archive');
return (!$l || $l == 'default') ? $arc_default : $l;
case 'author':
$l = aspen_getopt('layout_author');
return (!$l || $l == 'default') ? $arc_default : $l;
case 'category':
$l = aspen_getopt('layout_category');
return (!$l || $l == 'default') ? $arc_default : $l;
case 'tag':
$l = aspen_getopt('layout_tag');
return (!$l || $l == 'default') ? $arc_default : $l;
case 'search':
case '404':
$l = aspen_getopt('layout_search');
return (!$l || $l == 'default') ? $arc_default : $l;
case 'image':
$l = aspen_getopt('layout_image');
return (!$l || $l == 'default') ? $arc_default : $l;
default:
return $default;
}
return $default;
}
} // end function exists
if ( ! function_exists( 'aspen_get_page_class' ) ) {
function aspen_get_page_class($who, $extra = '', $noecho = false) {
$class = $extra;
if ($class != '') $class .= ' equal_height';
else $class = 'equal_height';
$layout = aspen_get_page_layout($who);
if ($class == '')
$class = $layout;
else
$class .= ' ' . $layout;
if ($class != '')
$class = ' class="' . $class . '"';
if (!$noecho ) echo ($class);
return $class;
}
} // end function exists
if ( ! function_exists('aspen_show_primary_sidebar')) {
function aspen_show_primary_sidebar() {
// WordPress widget code is screwed up. If NO widget areas are defined, then it is possible
// for primary-widget-area to not be active. If the other two are active, then the is_active_sidebar
// for primary will be true, also, even if it has no widgets. Thus we use the ob stuff.
// If no areas are defined, then the is_active fails, and we end up at the default message.
$primary = apply_filters('aspen_replace_widget_area','primary-widget-area');
if ( !aspen_is_checked_page_opt('primary-widget-area') ) {
if ( is_active_sidebar( $primary ) ) {
ob_start(); // make sure not empty
$success = dynamic_sidebar( $primary );
$content = ob_get_clean();
if ($success) {
?>
\n";
get_footer($who);
}
} // end function exists
// ================================ Aspen admin ================================
function aspen_wp_head() { // action definition
require_once('includes/wphead.php');
aspen_generate_wphead();
}
function aspen_unlink_page($link, $id) { // filter definition
$stay = get_post_meta($id, 'pp_stay_on_page', true);
if ($stay) {
return "#";
} else {
return $link;
}
}
function aspen_get_css_filename() {
$updir = wp_upload_dir();
return trailingslashit($updir['basedir']) . 'aspen-subthemes/style-aspen.css';
}
function aspen_get_css_url() {
$updir = wp_upload_dir();
// make relative for https: - doesn't work right...
// return parse_url(trailingslashit($updir['baseurl']) . 'aspen-subthemes/style-aspen.css',PHP_URL_PATH);
$path = trailingslashit($updir['baseurl']) . 'aspen-subthemes/style-aspen.css';
if (is_ssl()) $path = str_replace('http:','https:',$path);
return $path;
}
function aspen_add_admin() { // action definition
/* adds our admin panel (add_action: admin_menu) */
// 'edit_theme_options' works for both single and multisite
$page = add_theme_page('Aspen', '♠' . ASPEN_THEMENAME . ' ' . aspen_t_('Admin' /*a*/ ), 'edit_theme_options', 'Aspen', 'aspen_admin');
/* using registered $page handle to hook stylesheet loading for this admin page */
add_action('admin_print_styles-'.$page, 'aspen_admin_scripts');
}
function aspen_admin() {
$wp_vers = $GLOBALS['wp_version'];
$cur_vers = $wp_vers;
$beta = strpos($cur_vers, '-');
if ( $beta > 0 ) {
$cur_vers = substr($cur_vers,0,$beta); // strip the beta part if there
}
if (version_compare($cur_vers, ASPEN_MIN_WPVERSION, '<')) {
echo '
ERROR: You are using WordPress Version ' . $GLOBALS['wp_version'] . '. Aspen requires WordPress Version ' . ASPEN_MIN_WPVERSION . ' or above. You should always upgrade to the latest version of WordPress for maximum site performance and security.
'; // admin message
return;
}
require_once(dirname( __FILE__ ) . '/includes/admin-top.php'); // NOW - load the admin stuff
do_action('aspen_pro_add_admin');
aspen_do_admin();
}
function aspen_admin_scripts() {
/* called only on the admin page, enqueue our special style sheet here (for tabbed pages) */
wp_enqueue_style('wiiStylesheet', get_template_directory_uri().'/admin-style.css');
wp_enqueue_style ("thickbox");
wp_enqueue_script ("thickbox");
wp_enqueue_script('wiiJscolor', get_template_directory_uri().'/js/jscolor/jscolor.js',ASPEN_VERSION);
wp_enqueue_script('wiiYetii', get_template_directory_uri().'/js/yetii/yetii'.ASPEN_MINIFY.'.js',ASPEN_VERSION);
wp_enqueue_script('wiiHide', get_template_directory_uri().'/js/theme/hide-css'.ASPEN_MINIFY.'.js',ASPEN_VERSION);
wp_enqueue_script('wiiMediaLib', get_template_directory_uri().'/js/theme/media-lib'.ASPEN_MINIFY.'.js',ASPEN_VERSION);
}
function aspen_admin_head() { // action definition
}
function aspen_enqueue_scripts() { // action definition
// need to know the page template for some conditional script inclusion
global $aspen_cur_template;
$aspen_cur_template = (is_page()) ? get_page_template() : 'nonpage';
$vers = aspen_getopt('style_version');
if (!$vers) $vers = '1';
else $vers = sprintf("%d",$vers);
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
// emit Aspen js vars - must be here, before scripts
// generate JS values for Aspen JS Lib
echo '\n";
//-- Aspen js lib - requires jQuery...
wp_enqueue_script('aspenJSLib', get_template_directory_uri().'/js/aspenjslib'.ASPEN_MINIFY.'.js',array('jquery'),ASPEN_VERSION);
// dynamic settings for menu fixer
$default_selector = 'li:has(ul) > a';
$default_selector_leaf = 'li li li:not(:has(ul)) > a';
$params = array(
'selector' => apply_filters('aspen_menu_selector', $default_selector),
'selector_leaf' => apply_filters('aspen_menu_selector_leaf', $default_selector_leaf)
);
wp_localize_script('aspenJSLib', 'aspen_menu_params', $params);
global $aspen_cur_page_ID;
global $post;
if (!$aspen_cur_page_ID && is_object($post))
$aspen_cur_page_ID = get_the_ID();
aspen_masonry('enqueue-script');
}
function aspen_wp_title($title) { // filter definition
if (function_exists('wpseo_get_value'))
return $title; // this is compatible with SEO plugins
/*
* Print the tag based on what is being viewed. THIS CODE DIRECTLY FROM TWENTY ELEVEN
*/
global $page, $paged;
$t = '';
if ($title) {
$title = trim(str_replace('»','',$title));
$t = $title . ' | ';
}
$t .= get_bloginfo('name');
/* Add the blog description for the home/front page. */
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
$t .= " | $site_description";
/* Add a page number if necessary: */
if ( $paged >= 2 || $page >= 2 )
$t .= ' | ' . sprintf( __( 'Page %s','aspen'), max( $paged, $page ) );
return $t;
}
if ( ! function_exists('aspen_not_found_search')) {
function aspen_not_found_search($file_name) {
?>
base || 'page' == $screen->base )
$hidden = array('slugdiv', 'trackbacksdiv', 'postexcerpt', 'commentsdiv', 'authordiv', 'revisionsdiv');
// removed 'postcustom', 'commentstatusdiv',
return $hidden;
}
function aspen_the_excerpt_filter($excerpt) { // filter definition
return do_shortcode($excerpt);
}
function aspen_get_wp_title_rss($title) { // filter definition
/* need to fix our add a | blog name to wp_title */
$ft = str_replace(' | ','',$title);
return str_replace(get_bloginfo('name'),'',$ft);
}
// apply_filters('get_bloginfo_rss', convert_chars($info), $show);
require_once(dirname( __FILE__ ) . '/settings.php'); // settings stay in theme root directory
require_once(dirname( __FILE__ ) . '/includes/lib-runtime.php'); // standard runtime library
require_once(dirname( __FILE__ ) . '/includes/aspen-shortcodes.php'); // pro runtime library
require_once(dirname( __FILE__ ) . '/includes/admin-page-posts.php'); // page-posts admin
/* This is where the theme hooks into the rest of WordPress */
// ==FILTERS
add_filter('page_link', 'aspen_unlink_page', 10, 2); // for stay on page
add_filter('wp_title', 'aspen_wp_title', 10, 1); // filter the title
add_filter('default_hidden_meta_boxes', 'aspen_hidden_meta_boxes', 10, 2);
add_filter('the_excerpt','aspen_the_excerpt_filter', 10,1);
add_filter('get_wp_title_rss', 'aspen_get_wp_title_rss',10,1);
// ==ACTIONS
add_action('admin_init', 'aspen_admin_init_cb');
add_action('wp_head', 'aspen_wp_head');
add_action('admin_menu', 'aspen_add_admin',5);
add_action('admin_head', 'aspen_admin_head');
add_action('wp_enqueue_scripts', 'aspen_enqueue_scripts' );
/* filters available for Aspen child-themes
add_filter('aspen_options','aspen_child_options',10,1);
function aspen_child_options($opt_name) {
// WP get_option (etc.) name that Aspen uses for various settings:
// does not return the options - just the option name.
// So one might change 'aspen_settings' to 'wvrchild_aspen_settings' (i.e., add 'wvrchild_' to the beginning)
//
// 'aspen_settings' - the main Aspen options
// 'aspen_pro' - Aspen Pro options
// 'aspen_settings_backup' - saved settings from Save/Restore
}
===============
Other Filters:
'aspen_author_bio_avatar_size'
'aspen_menu_selector'
'aspen_menu_selector_leaf'
'aspen_css' - process path macros in CSS code
'aspen_attachment_size'
'aspen_show_posts_wp_query' - to process [aspen_show_posts] WP_Query args (in shortcodes.php)
'aspen_pwp_wp_query' - process WP_Query args from Page with Posts template (in paget-posts.php)
'aspen_text' - text in widgets
'aspen_switch_theme' - for switch theme plugin
'aspen_attachment_size'
'aspen_menu_name'
*/
// ============================== Recommended Plugins =========================
/**
* Add plugin automation file
*/
require_once( dirname( __FILE__ ) . '/includes/class-tgm-plugin-activation.php' );
function aspen_install_plugins() {
$plugins = array(
// This is an example of how to include a plugin pre-packaged with a theme
array(
'name' => 'Aspen Shortcodes and Widgets', // The plugin name
'slug' => 'aspen-shortcodes-and-widgets', // The plugin slug (typically the folder name)
'required' => false
),
array(
'name' => 'Aspen Theme Extras', // The plugin name
'slug' => 'aspen-extras', // The plugin slug (typically the folder name)
'required' => false
)
);
// Change this to your theme text domain, used for internationalising strings
$theme_text_domain = 'weaver-ii';
/**
* Array of configuration settings. Amend each line as needed.
* If you want the default strings to be available under your own theme domain,
* leave the strings uncommented.
* Some of the strings are added into a sprintf, so see the comments at the
* end of each line for what each argument will be.
*/
$config = array(
'domain' => $theme_text_domain, // Text domain - likely want to be the same as your theme.
'default_path' => '', // Default absolute path to pre-packaged plugins
'parent_menu_slug' => 'themes.php', // Default parent menu slug
'parent_url_slug' => 'themes.php', // Default parent URL slug
'menu' => 'install-weaver-ii-addons', // Menu slug
'has_notices' => true, // Show admin notices or not
'is_automatic' => true, // Automatically activate plugins after installation or not
'message' => '
The following plugins are highly recommended for full functioning of the Aspen theme. These plugins will add shortcodes that make it easy to control and add content to your site, including [aspen_show_posts], optional display of text on mobile sites, and the ability to easily add new premium subthemes for the Aspen Theme.
', // Message to output right before the plugins table
'strings' => array(
'page_title' => __( 'Aspen Theme Recommended Plugins', $theme_text_domain ),
'menu_title' => __( '♠Aspen Plugins', $theme_text_domain ),
'installing' => __( 'Installing Plugin: %s', $theme_text_domain ), // %1$s = plugin name
'oops' => __( 'Something went wrong with the plugin API.', $theme_text_domain ),
'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.' ), // %1$s = plugin name(s)
'notice_can_install_recommended' => _n_noop( 'Aspen Theme recommends this plugin, %1$s, to enable the complete theme feature set.', 'Aspen Theme recommends these plugins, %1$s, to enable the complete theme feature set.' ), // %1$s = plugin name(s)
'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.' ), // %1$s = plugin name(s)
'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.' ), // %1$s = plugin name(s)
'notice_can_activate_recommended' => _n_noop( 'Please activate this recommended plugin, %1$s, to enable the complete Aspen Theme feature set.', 'Please activate these recommended plugins, %1$s, to enable the complete Aspen Theme feature set.' ), // %1$s = plugin name(s)
'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.' ), // %1$s = plugin name(s)
'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with Aspen: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.' ), // %1$s = plugin name(s)
'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.' ), // %1$s = plugin name(s)
'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins' ),
'activate_link' => _n_noop( 'Open Plugins Admin Page to Activate', 'Open Plugins Admin Page to Activate' ),
'return' => __( 'Return to Required Plugins Installer', $theme_text_domain ),
'plugin_activated' => __( 'Plugin activated successfully.', $theme_text_domain ),
'complete' => __( 'All plugins installed and activated successfully. %s', $theme_text_domain ) // %1$s = dashboard link
)
);
tgmpa( $plugins, $config );
}
add_action( 'tgmpa_register', 'aspen_install_plugins' );
// ============================== MORE WEAVER THEME ACTIONS ===================
function aspen_nav_action($where) {
get_template_part('nav',$where);
}
if (!has_action('aspen_nav'))
add_action( 'aspen_nav', 'aspen_nav_action');
/**
* Add theme support for infinite scroll
*
* @uses add_theme_support
* @action after_setup_theme
* @return null
*/
function aspen_infinite_scroll_init() {
add_theme_support( 'infinite-scroll', array(
'container' => 'content',
'type' => 'click'
) );
}
add_action( 'after_setup_theme', 'aspen_infinite_scroll_init' );
/*
* Support for Woo Commerece
*/
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
add_action('woocommerce_before_main_content', 'aspen_woo_wrapper_start', 10);
add_action('woocommerce_after_main_content', 'aspen_woo_wrapper_end', 10);
add_filter('widget_text', 'do_shortcode'); // add shortcode processing to standard text widget
function aspen_woo_wrapper_start() {
echo '
';
}
function aspen_woo_wrapper_end() {
echo '
';
}
add_theme_support( 'woocommerce' );
/**
* Add default options and show Options Panel after activate
*/
?>