'eeeeee' ) );
add_theme_support( 'custom-header', array(
'default-image' => BITLUMEN_THEME_URI . 'img/header/default.png',
'random-default' => false,
'width' => 435,
'height' => 90,
'flex-height' => true,
'flex-width' => true,
'default-text-color' => '',
'header-text' => true,
'uploads' => true,
'admin-preview-callback' => 'bitLumen_preview_header_cb' ) );
/* =HEADERS
------------------------------------------------------------------------- */
// custom header preview
function bitLumen_preview_header_cb() {
// variables
$text_color = get_header_textcolor();
$header_img = get_header_image();
$bg_color = get_background_color();
$height = get_custom_header()->height;
$width = get_custom_header()->width;
$site_width = bitLumen_get_option( 'content_width' ) + bitLumen_get_option( 'sidebar_width' ) + 33;
// background color
$style = 'background-color:' . ( empty( $bg_color ) ? 'transparent' : '#' . $bg_color ) . ';';
// header image
$style .= ( empty( $header_img ) ? 'min-height:' . $height . 'px; width:' . $site_width . 'px;' : 'background-image:url(\'' . $header_img . '\');background-size:' . $width . 'px ' . $height . 'px;background-position:top left;background-repeat:no-repeat;' );
// header font
$style .= 'font-family:' . ( bitLumen_get_options( 'web_fonts' ) == 'none' ? 'Verdana,Geneva,sans-serif;' : '\'Droid Sans\';' );
// header text color
$color = 'color:#' . $text_color . ';text-decoration:none;';
// title & desc
$class = ( $text_color == 'blank' || empty( $text_color ) ? 'assistive-text display-none' : 'fake-masthead' );
?>
array (
'url' => BITLUMEN_THEME_URI . 'img/header/default.png',
'thumbnail_url' => BITLUMEN_THEME_URI . 'img/header/default-thumb.png',
'description' => 'Default header image' ) );
return register_default_headers( $headers );
}
/* =HELPER FUNCTIONS
------------------------------------------------------------------------- */
// pluralize conditionally
function bitLumen_plural( $count, $noun, $echo=true, $irregular_suffix=false ) {
if( $count !== 1 )
$suffix = ( $irregular_suffix ? $irregular_suffix : 's' ); // special suffix
else $suffix = '';
$output = $count . ' ' . $noun . $suffix;
if( $echo ) echo $output;
else return $output;
}
// get attachment data
function bitLumen_get_attachment( $attachment_id='' ) {
if( empty( $attachment_id ) ) $attachment_id = get_the_ID(); // use current id if none
if( !wp_attachment_is_image( $attachment_id ) ) return false; // check if image
$attachment = get_post( $attachment_id ); // get attachment
if( !$attachment ) return false;
else return array(
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
'id' => $attachment->ID,
'caption' => $attachment->post_excerpt,
'description' => $attachment->post_content,
'href' => get_permalink( $attachment->ID ),
'parent_id' => $attachment->post_parent,
'src' => $attachment->guid,
'title' => $attachment->post_title
);
}
// print settings error message
function bitLumen_settings_message( $message ) { ?>
'site-name',
'id' => 'theme_options',
'title' => 'Theme Options',
'href' => admin_url( 'themes.php?page=' . BITLUMEN_OPTIONS_NAME ),
'meta' => false );
$wp_admin_bar->add_menu( $theme_options );
endif;
}
// index page next/previous posts links
function bitLumen_index_nav( $older_text='« Older posts', $newer_text='Newer posts »' ) {
$older = get_next_posts_link( $older_text );
$newer = get_previous_posts_link( $newer_text );
$output = '';
if( !empty( $older ) ) $output .= '' . $older . '
';
if( !empty( $newer ) ) $output .= '' . $newer . '
';
if( !empty( $output ) ) {
$output = '' . $output . '
';
echo $output;
}
}
// registers nav menu locations
function bitLumen_register_nav_menus() {
$nav_menus = array(
'primary-menu' => 'Primary navigation menu'
);
register_nav_menus( $nav_menus );
}
// prints a nav menu
function bitLumen_nav_menu( $menu_id = 'primary-menu' ) {
$nav_menus = array(
'primary-menu' => array(
'theme_location' => 'primary-menu',
'menu' => '',
'container_id' => 'navwrap',
'menu_class' => 'sf-menu',
'menu_id' => '',
'echo' => true,
'fallback_cb' => 'bitLumen_nav_menu_fb',
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'items_wrap' => '',
'depth' => 0,
'walker' => ''
)
);
if( !isset( $nav_menus[$menu_id] ) )
return false;
else
wp_nav_menu( $nav_menus[$menu_id] );
}
// fallback function for the nav menu
function bitLumen_nav_menu_fb() {
/*
*/
}
/* =SIDEBAR
------------------------------------------------------------------------- */
// registers sidebar locations
function bitLumen_register_sidebars() {
$sidebars = array(
'primary-sidebar' => array(
'name' => 'Primary Sidebar',
'id' => 'primary-sidebar',
'description' => 'The primary sidebar',
'class' => '',
'before_widget' => '',
'after_widget' => '',
'before_title' => '' )
);
register_sidebar( $sidebars['primary-sidebar'] );
}
// print default sidebar
function bitLumen_default_sidebar() {
$args = array(
'before_widget' => '',
'after_widget' => '',
'before_title' => ''
);
$admin = 'Hi there Administrator!
- Thanks for adding the bitLumen theme!
- You will probably want to add some custom widgets and menus to get rid of the default ones.
- You should also checkout the special theme options.
';
$normal = '';
$instance = array( 'title' => 'BitLumen Theme', 'text' => ( current_user_can( 'manage_options' ) ? $admin : $normal ) );
$args['before_widget'] = '';
the_widget( 'WP_Widget_Text', $instance, $args );
}
/* =FILTERS
------------------------------------------------------------------------- */
// wp_title filter
function bitLumen_title_filter( $title, $sep, $seplocation ) {
$ssep = ' ' . $sep . ' ';
$pre = $num = '';
if( !is_single() ) {
if( is_category() ) $pre = $ssep . 'Category';
elseif( is_tag() ) $pre = $ssep . 'Tag';
elseif( is_author() ) $pre = $ssep . 'Author';
elseif( is_year() || is_month() || is_day() ) $pre = $ssep . 'Archives';
}
// get the page number (index format)
if( get_query_var( 'paged' ) )
$num = $ssep . get_query_var( 'paged' );
// get the page number (multipage post format)
elseif( get_query_var( 'page' ) )
$num = $ssep . get_query_var( 'page' );
// concoct and return title
return get_bloginfo( 'name' ) . $pre . $title . $num;
}
// wp_foot filter
function bitLumen_footer_filter() {
$items = array(
'Powered by WordPress',
'bitLumen theme',
'created by Shinra Web Holdings' );
$user_foot = bitLumen_get_option( 'extra_footer' );
if( !empty( $user_foot ) )
array_push( $items, bitLumen_get_option( 'extra_footer' ) );
// build footer links
$output = implode( bitLumen_get_option( 'footer_sep' ), $items ); ?>
comment_status;
$pi = $post->ping_status;
$pa = ( $post->post_type == 'page' ? true : false );
if( $po == 'open' && $pi == 'open' ) :
$msg = ' or leave a trackback.';
elseif( $po != 'open' && $pi == 'open' ) :
if( $pa ) $msg = 'Leave a trackback.';
else $msg = 'Comments are closed, but you can leave a trackback.';
elseif( $po == 'open' && $pi != 'open' ) :
if( $pa ) $msg = '.';
else $msg = 'Trackbacks are closed, but you can .';
else :
if( $pa ) $msg = ' ';
else $msg = 'Both comments and trackbacks are currently closed.';
endif;
$msg = '' . $msg . '';
}
// safely print post title and link
function bitLumen_post_title( $echo=true ) {
$post_id = get_the_ID();
$permalink = get_permalink( $post_id );
$post_title = get_the_title( $post_id );
$post_title_clean = esc_attr( strip_tags( $post_title ) );
if( empty( $post_title_clean ) ) {
$post_title_clean = 'this post';
$post_title = '(no title)';
}
$output = sprintf( '%3$s', $permalink, $post_title_clean, $post_title );
if( $echo ) echo $output;
else return $output;
}
// safely get (attachment) post title
function bitLumen_attachment_title( $echo=true ) {
$parent_title = get_the_title( $post->post_parent );
if( empty( $parent_title ) ) $parent_title = '(no title)';
$output = sprintf( 'From %4$s: %3$s',
get_permalink( $post->post_parent ),
get_permalink(),
$parent_title,
( is_page( $post->post_parent ) ? 'Page' : 'Post' ),
( wp_attachment_is_image() ? 'image' : 'file' ) );
if( $echo ) echo $output;
else return $output;
}
// selectively returns the chosen parts of the entry meta
function bitLumen_entry_meta( $echo=true ) {
$items = array(
bitLumen_post_author(),
bitLumen_post_date(),
( bitLumen_get_option( 'entry_edit_link' ) ? bitLumen_edit_post_link() : false ),
( bitLumen_get_option( 'entry_trash_link' ) ? bitLumen_trash_post_link() : false )
);
$items = array_filter( $items );
$output = implode( ' ' . bitLumen_get_option( 'entry_meta_sep' ) . ' ', $items );
echo $output;
}
// post author meta item
function bitLumen_post_author() {
if( bitLumen_get_option( 'entry_post_author' ) == 'none' ) return false;
$author_id = get_the_author_meta( 'ID' );
$author_name = get_the_author();
$author_nicename = get_the_author_meta( 'user_nicename' );
$author_url = get_author_posts_url( $author_id, $author_nicename );
if( bitLumen_get_option( 'entry_post_author' ) == 'link' )
$output = '' . $author_name . '';
else
$output = '' . $author_name . '';
return $output;
}
// post date
function bitLumen_post_date() {
if( bitLumen_get_option( 'entry_post_date' ) == 'none' ) return false;
elseif( bitLumen_get_option( 'entry_post_date' ) == 'updated' ) {
$date = get_the_modified_date();
$time = get_the_modified_time();
}
else {
$date = get_the_date();
$time = get_the_time();
}
if( !bitLumen_get_option( 'entry_post_time' ) ) $time = '';
else $time = ' at ' . $time;
$output = $date . $time;
if( !empty( $output ) )
return '' . $output . '';
}
// edit link
function bitLumen_edit_post_link() {
if( current_user_can( 'edit_posts' ) )
return 'Edit';
}
// trash link
function bitLumen_trash_post_link() {
if( current_user_can( 'delete_posts' ) )
return 'Trash';
}
// equivalent of get_comments_popup_link
function bitLumen_get_comments_popup_link() {
if( !comment_open() ) return '';
$num = get_comments_number();
if( $num == 0 ) $text = 'Leave a Comment';
elseif( $num > 1 ) $text = $num . ' Comments';
else $text = '1 Comment';
return '';
}
// special index page type
function bitLumen_special_index_type( $post ) {
if( is_category( $post ) ) { // category
$title = 'Category';
$item = single_cat_title( '', false );
$message = 'You are now browsing all items filed in the “' . $item . '” category.';
}
elseif( is_tag( $post ) ) { // tag
$title = 'Tag';
$item = single_tag_title( '', false );
$message = 'You are now browsing all items tagged with “' . $item . '”';
}
elseif( is_author() ) { // author
$title = 'Author';
$item = get_the_author();
$message = 'You are now browsing all items authored by “' . $item . '.”';
}
elseif( is_month() || is_day() ) { // archives (month or day)
$title = 'Archives';
$item = substr( single_month_title(', ', false ), 2 );
$message = 'You are now browsing the archives for items from “' . $item . '.”';
}
elseif( is_year() ) { // archive (year)
$title = 'Archives';
$item = get_the_date( 'Y');
$message = 'You are now browsing the archives for posts from the year “' . $item . '.”';
}
elseif( is_search() ) { // search
$title = 'Search';
$item = get_search_query();
$message= 'You are now browsing our search results for “' . $item . '.”';
}
else return false;
// print content ?>
'post-thumbnail' ) );
$thumb = bitLumen_get_attachment( $thumb_id );
if( !empty( $thumb['caption'] ) ) $caption = $thumb['caption'];
elseif( !empty( $thumb['description'] ) ) $caption = $thumb['description'];
elseif( !empty( $thumb['title'] ) ) $caption = $thumb['title'];
else $caption = $post_title;
printf( '',
$thumb_id, $permalink, $post_title, $thumb_html, $caption );
}
// add custom avatar callback
function bitLumen_custom_avatar_cb( $avatar_defaults ) {
$theme_image = BITLUMEN_THEME_URI . 'img/avatar.png';
$avatar_defaults[$theme_image] = 'bitLumen Avatar';
return $avatar_defaults;
}
// adds meta description (in header) if found
function bitLumen_meta_description_filter() {
if( !is_single() ) $meta_description = get_bloginfo( 'description' );
else $meta_description = bitLumen_get_meta_description();
if( !empty( $meta_description ) ) :
?>