@version 0.2.6 @since Version 0.1 @todo Check the markup http://validator.w3.org/ For Those About to Rock. Fire! */ /** * Note: * * When using a child theme (see http://codex.wordpress.org/Theme_Development and * http://codex.wordpress.org/Child_Themes), you can override the functions * 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. */ /** * Disable the wpautop function so that WordPress makes no attempt to correct your markup. * http://nicolasgallagher.com/using-html5-elements-in-wordpress-post-content/ */ //remove_filter('the_excerpt', 'wpautop'); //remove_filter('the_content', 'wpautop'); /** * Set the content width based on the theme's design and stylesheet. */ if ( ! isset( $content_width ) ) $content_width = 580; /* pixels */ /** * Make theme available for translation * Translations can be filed in the /languages/ directory * If you're building a theme based on Basics, use a find and replace * to change 'basics' to the name of your theme in all the template files */ load_theme_textdomain( 'basics', TEMPLATEPATH . '/languages' ); $locale = get_locale(); $locale_file = TEMPLATEPATH . "/languages/$locale.php"; if ( is_readable( $locale_file ) ) require_once( $locale_file ); /** * This theme uses wp_nav_menu() in four locations. */ register_nav_menus( array( 'first' => __( 'First navigation', 'basics' ), 'second' => __( 'Second navigation', 'basics' ), 'third' => __( 'Third navigation', 'basics' ), 'fourth' => __( 'Fourth navigation', 'basics' ) ) ); /** * Add default posts and comments RSS feed links to head * Don't forget to remove the feed link in header.php if you decomment this line */ add_theme_support( 'automatic-feed-links' ); /** * Add support for all Post Formats. * Simply comment line(s) associated with the Post formats you want to kick off */ add_theme_support( 'post-formats', array( 'aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat' ) ); /** * Add support for custom backgrounds */ add_custom_background(); /** * Add support for Thumbnails */ add_theme_support( 'post-thumbnails' ); /** * Add support to styles the visual editor with editor-style.css to match the front theme style */ add_editor_style('markup'); /** * Get our wp_nav_menu() fallback, wp_page_menu(), to show a home link. */ add_filter( 'wp_page_menu_args', 'basics_page_menu_args' ); if ( ! function_exists( 'basics_page_menu_args' ) ) : function basics_page_menu_args($args) { $args['show_home'] = true; return $args; } endif; /** * Sets the post excerpt length to 52 characters. */ add_filter( 'excerpt_length', 'basics_excerpt_length' ); if ( ! function_exists( 'basics_excerpt_length' ) ) : function basics_excerpt_length( $length ) { return 52; } endif; /** * Returns a "Continue Reading" link for excerpts */ if ( ! function_exists( 'basics_continue_reading_link' ) ) : function basics_continue_reading_link() { return ' ' . __( 'Continue reading ', 'basics' ) . ''; } endif; /** * Replaces "[...]" (appended to automatically generated excerpts) * with an ellipsis and basics_continue_reading_link(). */ add_filter( 'excerpt_more', 'basics_auto_excerpt_more' ); if ( ! function_exists( 'basics_auto_excerpt_more' ) ) : function basics_auto_excerpt_more( $more ) { return ' …' . basics_continue_reading_link(); } endif; /** * Adds a pretty "Continue Reading" link to custom post excerpts. */ add_filter( 'get_the_excerpt', 'basics_custom_excerpt_more' ); if ( ! function_exists( 'basics_custom_excerpt_more' ) ) : function basics_custom_excerpt_more( $output ) { if ( has_excerpt() && ! is_attachment() ) { $output .= basics_continue_reading_link(); } return $output; } endif; /** * Register widgetized area and update sidebar with default widgets */ add_action( 'init', 'basics_widgets_init' ); if ( ! function_exists( 'basics_widgets_init' ) ) : function basics_widgets_init() { register_sidebar( array ( 'name' => __( 'One', 'basics' ), 'id' => 'war-1', 'description' => __( 'Widgets Area One', 'basics' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array ( 'name' => __( 'Two', 'basics' ), 'id' => 'war-2', 'description' => __( 'Widgets Area Two', 'basics' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array ( 'name' => __( 'Three', 'basics' ), 'id' => 'war-3', 'description' => __( 'Widgets Area Three', 'basics' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array ( 'name' => __( 'Four', 'basics' ), 'id' => 'war-4', 'description' => __( 'Widgets Area Four', 'basics' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array ( 'name' => __( 'Five', 'basics' ), 'id' => 'war-5', 'description' => __( 'Widgets Area Five', 'basics' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array ( 'name' => __( 'Six', 'basics' ), 'id' => 'war-6', 'description' => __( 'Widgets Area Six', 'basics' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array ( 'name' => __( 'Seven', 'basics' ), 'id' => 'war-7', 'description' => __( 'Widgets Area Seven', 'basics' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array ( 'name' => __( 'Eight', 'basics' ), 'id' => 'war-8', 'description' => __( 'Widgets Area Eight', 'basics' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array ( 'name' => __( 'Nine', 'basics' ), 'id' => 'war-9', 'description' => __( 'Widgets Area Nine', 'basics' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array ( 'name' => __( 'Ten', 'basics' ), 'id' => 'war-10', 'description' => __( 'Widgets Area Ten', 'basics' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array ( 'name' => __( 'Eleven', 'basics' ), 'id' => 'war-11', 'description' => __( 'Widgets Area Eleven', 'basics' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } endif; /** * Add custom body classes */ add_filter( 'body_class', 'basics_body_class' ); if ( ! function_exists( 'basics_body_class' ) ) : function basics_body_class($classes) { if ( is_singular() ) $classes[] = 'singular'; return $classes; } endif; /** * Display navigation to next/previous pages when applicable. (Adapted from Duster theme's functions.php). */ if ( ! function_exists( 'basics_content_nav' ) ) : function basics_content_nav($nav_id, $nav_class) { global $wp_query; if ( $wp_query->max_num_pages > 0 ) : ?> tag based on what is being viewed. */ if ( ! function_exists( 'basics_title' ) ) : function basics_title() { global $page, $paged; wp_title( '|', true, 'right' ); // Add the blog name. bloginfo( 'name' ); // Add a page number if necessary: if ( $paged >= 2 || $page >= 2 ) echo ' | ' . sprintf( __( 'Page %s', 'basics' ), max( $paged, $page ) ); } endif; /* * Print the of the web page regarding the context */ if ( ! function_exists( 'basics_description' ) ) : function basics_description() { global $post; if ( is_home() || is_front_page() ) { $basics_description = get_bloginfo( 'description', 'display' ); } else if ( '' !== $post->post_excerpt ) { $basics_description = strip_tags( $post->post_excerpt ); } else if ( is_category() ) { $basics_description = wptexturize( category_description() ); } else if ( is_tag() ) { $basics_description = wptexturize( tag_description() ); } else if ( is_author() ) { $basics_description = wptexturize( get_the_author_meta( 'description' ) ); } else { $basics_description = wp_html_excerpt( $post->post_content, 200 ); } //Prevent shortcode to appear "as is" $description = preg_replace('#\[(.+)\]#','', $basics_description); return $description; } endif; /* * Return the the section heading (title and description) regarding the context. */ if ( ! function_exists( 'basics_section_heading' ) ) : function basics_section_heading() { global $post; $category_description = wptexturize( category_description() ); $tag_description = wptexturize( tag_description() ); $author_description = wptexturize( get_the_author_meta( 'description' ) ); $section = array( 'section_title' => '', 'section_description' => '' ); if ( is_home() || is_front_page() ) { $section['section_title'] = __('Hi! What can Basics do for you?', 'basics' ); $section['section_description'] = __('See how Basics could help you as a starter theme for your own developpments with WordPress', 'basics' ); } else if ( is_category() ) { $section['section_title'] = sprintf( __( 'Category Archives: %s', 'basics' ), '' . single_cat_title( '', false ) . '' ); if ( ! empty( $category_description ) ) { $section['section_description'] = category_description(); } else { $section['section_description'] = sprintf( __( 'No description for category %s. Suggest the administrator to fill a helping description.', 'basics' ), '' . single_cat_title( '', false ) . '' ); } } else if (is_tag() ) { $section['section_title'] = $section_title = sprintf( __( 'Tag Archives: %s', 'basics' ), '' . single_tag_title( '', false ) . '' ); if ( ! empty( $tag_description ) ) { $section['section_description'] = tag_description(); } else { $section['section_description'] = sprintf( __( 'No description for tag %s. Suggest the administrator to fill a helping blurb.', 'basics' ), '' . single_cat_title( '', false ) . '' ); } } else if ( is_author() ) { $section['section_title'] = sprintf( esc_attr__( 'Archives author for: %s', 'basics' ), get_the_author() ); if ( ! empty( $author_description ) ) { $section['section_description'] = $author_description; } else { $section['section_description'] = sprintf( __( 'Sorry, there is no description for author %s. If it\'s you, feel free to write a consistent description. It is a gook way to promote yourself.', 'basics' ), '' . get_the_author() . '' ); } } else if (is_date() ) { if ( is_day() ) { $section['section_title'] = __( 'Daily Archives:', 'basics' ); $section['section_description'] = get_the_date(); } elseif ( is_month() ) { $section['section_title'] = __( 'Monthly Archives:', 'basics' ); $section['section_description'] = get_the_date('F Y'); } elseif ( is_year() ) { $section['section_title'] = __( 'Yearly Archives:', 'basics' ); $section['section_description'] = get_the_date('Y'); } else { $section['section_title'] = __( 'Blog Archives', 'basics' ); $section['section_description'] = __( 'Blog Archives description', 'basics' ); } } else if ( is_search() ) { if ( have_posts() ) { $section['section_title'] = __('Search results for:', 'basics' ); $section['section_description'] = sprintf( __( '%s', 'basics' ), '' . get_search_query() . '' ); } } else if ( is_404() ) { $section['section_title'] = __( 'Hi! This is somewhat embarrassing, isn’t it?', 'basics' ); $section['section_description'] = __( 'It seems we can’t find what you’re looking for. Perhaps searching, or one of the links below, can help.', 'basics' ); } return $section; } endif; /* * Remove p in category or tag description */ remove_filter('term_description','wpautop'); /* * Remove p in excerpt */ //remove_filter('the_excerpt', 'wpautop'); /* * Print the post meta in the post's header */ if ( ! function_exists( 'basics_posted_on' ) ) : function basics_posted_on() { printf( __( 'Posted on %2$s by %3$s', 'basics' ), 'meta-prep meta-prep-author', sprintf( '', '[ ' . get_permalink() . ' ]', esc_attr( get_the_time() ), 'entry-date', get_the_date('c'), get_the_date() ), sprintf( '%3$s', get_author_posts_url( get_the_author_meta( 'ID' ) ), sprintf( esc_attr__( 'View all posts by %s', 'basics' ), get_the_author() ), get_the_author() ) ); } endif; /* * Print the post meta in the post's footer */ if ( ! function_exists( 'basics_posted_in' ) ) : function basics_posted_in() { // Retrieves tag list of current post, separated by commas. $tag_list = get_the_tag_list( '', ', ' ); if ( $tag_list ) { $posted_in = __( 'Posted in %1$s and tagged %2$s. Bookmark the permalink.', 'basics' ); } elseif ( is_object_in_taxonomy( get_post_type(), 'category' ) ) { $posted_in = __( 'Posted in %1$s. Bookmark the permalink.', 'basics' ); } else { $posted_in = __( 'Bookmark the permalink.', 'basics' ); } // Prints the string, replacing the placeholders. printf( $posted_in, get_the_category_list( ', ' ), $tag_list, get_permalink(), the_title_attribute( 'echo=0' ) ); } endif; /** * The Caption shortcode. */ if ( ! function_exists( 'basics_img_caption_shortcode' ) ) : function basics_img_caption_shortcode($attr, $content = null) { // Allow plugins/themes to override the default caption template. $output = apply_filters('img_caption_shortcode', '', $attr, $content); if ( $output != '' ) return $output; extract(shortcode_atts(array( 'id' => '', 'align' => 'alignnone', 'width' => '', 'caption' => '' ), $attr)); if ( 1 > (int) $width || empty($caption) ) return $content; if ( $id ) $id = 'id="' . esc_attr($id) . '" '; return '
' . do_shortcode( $content ) . '
' . $caption . '
'; } endif; add_shortcode('wp_caption', 'basics_img_caption_shortcode'); add_shortcode('caption', 'basics_img_caption_shortcode'); /** * Add support for iframe element in wysiwyg editor * http://wpengineer.com/1963/customize-wordpress-wysiwyg-editor/ */ add_filter('tiny_mce_before_init', 'basics_change_mce_options'); if ( ! function_exists( 'basics_change_mce_options' ) ) : function basics_change_mce_options( $initArray ) { // Comma separated string od extendes tags // Command separated string of extended elements $ext = 'pre[id|name|class|style],iframe[align|longdesc|name|width|height|frameborder|scrolling|marginheight|marginwidth|src]'; if ( isset( $initArray['extended_valid_elements'] ) ) { $initArray['extended_valid_elements'] .= ',' . $ext; } else { $initArray['extended_valid_elements'] = $ext; } // maybe; set tiny paramter verify_html //$initArray['verify_html'] = false; return $initArray; } endif; /** * Template for comments and pingbacks. * Used as a callback by wp_list_comments() for displaying the comments. */ if ( ! function_exists( 'basics_comments' ) ) : function basics_comments( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case '' : ?>
  • id="li-comment-">
    says:', 'basics' ), sprintf( '%s', get_comment_author_link() ) ); ?>
    comment_approved == '0' ) : ?>
    __( 'Reply!', 'basics' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
  • '' ); $required_text = sprintf( ' ' . __('Required fields are marked %s'), '*' ); $defaults = array( 'fields' => apply_filters( 'comment_form_default_fields', $fields ), 'comment_field' => '

    ', 'must_log_in' => '

    ' . sprintf( __( 'You must be logged in to post a comment.','basics' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '

    ', 'logged_in_as' => '

    ' . sprintf( __( 'Logged in as %2$s. Log out?','basics' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '

    ', 'comment_notes_before' => '

    ' . __( 'Your email address will not be published.','basics' ) . ( $req ? $required_text : '' ) . '

    ', 'comment_notes_after' => '

    ' . sprintf( __( 'You may use these HTML tags and attributes: %s', 'basics' ), ' ' . allowed_tags() . '' ) . '

    ', 'id_form' => 'commentform', 'id_submit' => 'submit', 'title_reply' => __( 'Leave a Reply','basics' ), 'title_reply_to' => __( 'Leave a Reply to %s','basics' ), 'cancel_reply_link' => __( 'Cancel reply','basics' ), 'label_submit' => __( 'Post Comment','basics' ), ); return $defaults; } endif; ?>