BITLUMEN_THEME_URI . 'img/header/default-header.png', 'width' => 956, 'height' => 90, 'flex-height' => true, 'default-text-color' => '', 'header-text' => true, 'uploads' => true, 'admin-preview-callback' => 'bitLumen_preview_headercb' ) ); add_theme_support( 'custom-background', array( 'default-color' => 'eeeeee', ) ); // custom header preview function bitLumen_preview_header_cb() { $output = '

' . get_bloginfo( 'name' ) . '

' . ( bitLumen_get_option( 'blog_subtitle' ) ? '
' : '' ); echo $output; } // 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; } // enqueues the admin section styles function bitLumen_enqueue_admin_style() { return wp_enqueue_style( 'bitLumen-options', BITLUMEN_THEME_URI . 'style-admin.css' ); } // enqueus the dynamic style sheet with bootstraped arguments function bitLumen_enqueue_dynamic_style() { $args = array( 'src' => get_header_image(), 'height' => get_custom_header()->height, 'width' => get_custom_header()->width, 'text_color' => get_header_textcolor(), 'bg_color' => get_background_color() ); $css = urlencode( serialize( $args ) ); return wp_enqueue_style( 'bitLumen-dyn', BITLUMEN_THEME_URI . 'style.php?css=' . $css, 'bitLumen-core' ); } // register theme options function bitLumen_register_options() { register_setting( BITLUMEN_OPTIONS_GROUP, BITLUMEN_OPTIONS_NAME, 'bitLumen_sanatize_input' ); } // validate/sanatize options input function bitLumen_sanatize_input( $input ) { return $input; } // gets array of all theme options function bitLumen_get_options( $use_global=true ) { if( $use_global ) global $bitLumen_options; if( !isset( $bitLumen_options ) ) $bitLumen_options = get_option( BITLUMEN_OPTIONS_NAME ); if( !$bitLumen_options ) $bitLumen_options = bitLumen_get_defaults(); return $bitLumen_options; } // get an option value from the theme's options array function bitLumen_get_option( $option_slug, $use_global=true ) { if( $use_global ) global $bitLumen_options; if( !isset( $bitLumen_options ) ) $bitLumen_options = bitLumen_get_options(); if( !array_key_exists( $option_slug, $bitLumen_options ) ) return false; else return $bitLumen_options[$option_slug]; } // delete theme options function bitLumen_delete_options() { delete_option( BITLUMEN_OPTIONS_NAME ); } // 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' => 'wp_page_menu', '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] ); } // registers nav menu locations function bitLumen_register_nav_menus() { $nav_menus = array( 'primary-menu' => 'Primary navigation menu' ); register_nav_menus( $nav_menus ); } // 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' => '

    ', 'after_title' => '

    ' ) ); register_sidebar( $sidebars['primary-sidebar'] ); } // print default sidebar function bitLumen_default_sidebar() { require_once( BITLUMEN_THEME_DIR . 'lib/bitacre/bitacreWidgets.php' ); $bitLumenWidgets = new bitacreWidgets(); $bitLumenWidgets->addMeta(); $bitLumenWidgets->addRecentComments(); $bitLumenWidgets->addCategories( 'Categories', 1, 0, 1 ); $bitLumenWidgets->addTagCloud(); $bitLumenWidgets->addText( 'BitLumen Theme', '', 'bitLumen_default_text_widget_filter' ); } // default text widget text? function bitLumen_default_text_widget_filter( $text ) { return 'Welcome.'; } // 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; } // 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; } // 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 echo implode( bitLumen_get_option( 'footer_sep' ), $items ); } // selectively returns the chosen parts of the entry meta function bitLumen_entry_meta( $echo=true ) { $items = array(); // post author if( bitLumen_get_option( 'entry_post_author' ) ) : $author_id = get_the_author_meta( 'ID' ); $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' ) array_push( $items, '' ); elseif( !empty( $author_nicename ) ) array_push( $items, '' . $author_nicename . '' ); endif; // post date if( bitLumen_get_option( 'entry_post_date' ) == 'created' ) array_push( $items, '' . get_the_date() . ( bitLumen_get_option( 'entry_post_time' ) ? ' at ' . get_the_time() : '' ) . '' ); elseif( bitLumen_get_option( 'entry_post_date' ) == 'updated' ) array_push( $items, '' . get_the_modified_date() . ( bitLumen_get_option( 'entry_post_time' ) ? ' at ' . get_the_modified_time() : '' ) . '' ); // edit link if( bitLumen_get_option( 'entry_edit_link' ) ) if( current_user_can( 'edit_posts' ) ) array_push( $items, 'Edit' ); // trash link if( bitLumen_get_option( 'entry_trash_link' ) ) if( current_user_can( 'edit_posts' ) ) array_push( $items, bitLumen_get_trash_post_link() ); // return smooshed array $output = implode( ' ' . bitLumen_get_option( 'entry_meta_sep' ) . ' ', $items ); echo $output; } // equivalent of get_comments_popup_link function bitLumen_get_comments_popup_link() { $num = get_comments_number(); if( $num == 0 ) $text = 'Leave a Comment'; elseif( $num > 1 ) $text = $num . ' Comments'; else $text = '1 Comment'; return '' . $text . ''; } // registers default custom header options function bitLumen_register_headers() { $headers = array ( 'branded' => array ( 'url' => '%s/img/header/default-header.png', 'thumbnail_url' => '%s/img/header/default-header-thumb.png', 'description' => 'default header: bitLumen icon and logo text' ), 'icon_only' => array ( 'url' => '%s/img/header/icon-header.png', 'thumbnail_url' => '%s/img/header/icon-header-thumb.png', 'description' => 'bitLumen icon only, no logo text' ), 'blank' => array ( 'url' => '%s/img/header/blank-header.png', 'thumbnail_url' => '%s/img/header/blank-header-thumb.png', 'description' => 'totally blank, transparent, 956x90 header image' ), ); return register_default_headers( $headers ); } // gets the whole link to delete a post function bitLumen_get_trash_post_link() { global $post; if( !current_user_can( 'edit_posts' ) ) return false; // can edit page if page? if( $post->post_type == 'page' && !current_user_can( 'edit_page', $post->ID ) ) return false; // else can edit posts? elseif ( !current_user_can( 'edit_post', $post->ID ) ) return false; // return link $url = home_url() . '/wp-admin/post.php?action=delete&post=' . $post->ID; $nonce_url = wp_nonce_url( $url, 'delete-post_' . $post->ID ); $output = 'Trash'; return $output; } // 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; } } // 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 ?>
  • Index

  • 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 featured images function bitLumen_the_post_thumbnail( $post_id=null ) { $post_id = ( $post_id === null ? get_the_ID() : $post_id ); if( !has_post_thumbnail( $post_id ) ) return false; // post data $permalink = get_permalink( $post_id ); $post_title = esc_attr( get_the_title( $post_id ) ); // thumb data $thumb_id = get_post_thumbnail_id( $post_id ); $thumb_html = get_the_post_thumbnail( $post_id, 'medium', array( 'class' => '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( '
    %4$s

    %5$s

    ', $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 theme options page function bitLumen_create_menu() { add_theme_page( 'bitLumen Theme Options', 'Theme Options', 'edit_theme_options', BITLUMEN_OPTIONS_NAME, 'bitLumen_do_options_page' ); } // draws options pageadd_action( 'wp_head', 'add_our_scripts',0); function bitLumen_do_options_page() { // user defined classes $section_class = 'bitlumen-option-section'; $option_class = 'bitlumen-option'; $radio_class = 'bitlumen-option-radio'; $notice_class = 'bitlumen-option-notice'; $submit_class = 'bitlumen-option-submit'; // echo updated message if( isset( $_REQUEST['settings-updated'] ) ) : ?>

    BitLumen theme options saved.

    BitLumen Theme Options

    ' . $notice . '
    '; else $notice = ''; $notice .= "\n\r" . '
    '; ?>

    type="text" value="" /> $suboption ) : ?> type="radio" value="" /> type="checkbox" value="1" />
    $bundle['default'] ) ); return $defaults; } // options structure function bitLumen_options_struct() { $output = array ( array( 'name' => 'Post Information', 'desc' => 'Options for displaying or hiding certain text and metadata.', 'type' => 'section' ), // show authors array( 'name' => 'Show post author?', 'id' => 'entry_post_author', 'desc' => 'Show the name of the post author, name with link to author page, or no author?', 'type' => 'radio', 'options' => array( false => 'don\'t show', 'text' => 'name only', 'link' => 'name & author link' ), 'default' => 'link' ), // show post date array( 'name' => 'Show post date?', 'id' => 'entry_post_date', 'desc' => 'Display the date when each post or page was last created/updated?', 'type' => 'radio', 'options' => array( false => 'don\'t show', 'created' => 'created on', 'updated' => 'last updated' ), 'default' => 'created' ), // show post times array( 'name' => 'Show post time too?', 'id' => 'entry_post_time', 'desc' => 'Display the date when each post or page was last created/updated?', 'type' => 'checkbox', 'default' => '', ), // hide edit link array( 'name' => 'Show the edit post link?', 'id' => 'entry_edit_link', 'desc' => 'Show the edit post link to logged in admin users?', 'type' => 'checkbox', 'default' => 1 ), // hide trash link array( 'name' => 'Show the trash post link?', 'id' => 'entry_trash_link', 'desc' => 'Show a trash post link to logged in admins?', 'type' => 'checkbox', 'default' => '' ), array( 'type' => 'close' ), array( 'name' => 'Site text', 'desc' => 'Custom text used on your site.', 'type' => 'section' ), array( 'name' => 'Show description in header?', 'id' => 'blog_subtitle', 'desc' => 'Should the description be shown under the title in the header (only when the header is set to display text)?', 'type' => 'checkbox', 'default' => 1 ), array( 'name' => 'Title separator character:', 'id' => 'title_sep', 'desc' => 'The character used to seperate pieces of information in the title.', 'type' => 'text', 'default' => '»' ), array( 'name' => 'Post meta separator character:', 'id' => 'entry_meta_sep', 'desc' => 'The character used to seperate strings of text or links in the post meta information.', 'type' => 'text', 'default' => '|' ), array( 'name' => 'Footer seperator character:', 'id' => 'footer_sep', 'desc' => 'The character used to seperate strings of text or links in the footer.', 'type' => 'text', 'default' => '|' ), array( 'type' => 'close' ) ); return $output; } // ON ADMIN PAGES ONLY if( is_admin() ) : add_action( 'admin_head', 'bitLumen_enqueue_admin_style' ); endif; // FILTERS add_filter( 'avatar_defaults', 'bitLumen_custom_avatar_cb', 10, 1 ); add_filter( 'wp_title', 'bitLumen_title_filter', 10, 3 ); // ACTIONS add_action( 'admin_init', 'bitLumen_register_options' ); // register theme settings add_action( 'admin_menu', 'bitLumen_create_menu' ); // add link add_action( 'after_setup_theme', 'bitLumen_register_nav_menus', 10 ); add_action( 'after_setup_theme', 'bitLumen_register_headers', 10 ); add_action( 'widgets_init', 'bitLumen_register_sidebars', 10 ); add_action( 'wp_head', 'bitLumen_superfish_init', 0 ); add_action( 'wp_footer', 'bitLumen_footer_filter', 99999 ); ?>