__( 'Primary Menu', 'straightup' ), ) ); /** * Add support for the Aside Post Formats */ add_theme_support( 'post-formats', array( 'aside', ) ); } add_action( 'after_setup_theme', 'straightup_setup' ); /** * Register widgetized area and update sidebar with default widgets * * @since 1.0 */ function straightup_widgets_init() { register_sidebar( array( 'name' => __( 'Sidebar', 'straightup' ), 'id' => 'sidebar-1', 'before_widget' => '", 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'straightup_widgets_init' ); /** * Enqueue scripts and styles * * @since 1.0 */ function straightup_scripts() { global $post; wp_enqueue_style( 'corben', 'http://fonts.googleapis.com/css?family=Corben:700' ); wp_enqueue_style( 'style', get_stylesheet_uri() ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } if ( is_singular() && wp_attachment_is_image( $post->ID ) ) { wp_enqueue_script( 'keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' ); } } add_action( 'wp_enqueue_scripts', 'straightup_scripts' ); /** * Remove ridiculous inline width style from captions * Source: http://wordpress.stackexchange.com/questions/4281/how-to-customize-the-default-html-for-wordpress-attachments * * @since 1.0 */ function straightup_remove_caption_width( $current_html, $attr, $content ) { 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 . '

'; } add_filter( 'img_caption_shortcode', 'straightup_remove_caption_width', 10, 3 ); /** * Add CSS class to menus for submenu indicator * * @since 1.0 */ class StraightUp_Page_Navigation_Walker extends Walker_Nav_Menu { function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) { $id_field = $this->db_fields['id']; if ( !empty( $children_elements[ $element->$id_field ] ) ) { $element->classes[] = 'menu-item-parent'; } Walker_Nav_Menu::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); } } /** * Filter wp_nav_menu() arguments to specify the above walker * * @since 1.0 */ function straightup_nav_menu_args( $args ) { if ( has_nav_menu( 'primary' ) ) { $args[ 'walker' ] = new StraightUp_Page_Navigation_Walker; } return $args; } add_filter( 'wp_nav_menu_args', 'straightup_nav_menu_args' ); /** * Generate comment HTML * Based on the P2 theme by Automattic * http://wordpress.org/extend/themes/p2 * * @since 1.0 */ function straightup_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; if ( !is_single() && get_comment_type() != 'comment' ) return; $can_edit_post = current_user_can( 'edit_post', $comment->comment_post_ID ); $content_class = 'comment-content'; if ( $can_edit_post ) $content_class .= ' comment-edit'; ?>
  • id="li-comment-">
    $depth, 'max_depth' => $args['max_depth'], 'before' => ' ⋅ ' ) ) ); if ( $can_edit_post ) { edit_comment_link( __( 'Edit', 'straightup' ), ' ⋅ ' ); } ?>


    comment_approved == '0' ): ?>

    comment_content ); ?>
  • '
    ', 'email' => '
    ', 'url' => '
    ' ); $args[ 'comment_field' ] = '
    '; $args[ 'comment_notes_before' ] = '

    ' . esc_html__( 'Your email will not be published. Name and Email fields are required.', 'straightup' ) . '

    '; return $args; } add_filter( 'comment_form_defaults', 'straightup_comment_form_args' ); /** * Add additional classes to the body element * * @since 1.0 */ function straightup_body_classes( $classes ) { // Adds a class of group-blog to blogs with more than 1 published author if ( is_multi_author() ) { $classes[] = 'group-blog'; } return $classes; } add_filter( 'body_class', 'straightup_body_classes' ); /** * Filter in a link to a content ID attribute for the next/previous image links on image attachment pages * * @since 1.0 */ function straightup_enhanced_image_navigation( $url, $id ) { if ( ! is_attachment() && ! wp_attachment_is_image( $id ) ) return $url; $image = get_post( $id ); if ( ! empty( $image->post_parent ) && $image->post_parent != $id ) $url .= '#main'; return $url; } add_filter( 'attachment_link', 'straightup_enhanced_image_navigation', 10, 2 ); /** * Display navigation to next/previous pages when applicable * * @since 1.0 */ function straightup_content_nav( $nav_id ) { global $wp_query; $nav_class = 'site-navigation paging-navigation'; if ( is_single() ) $nav_class = 'site-navigation post-navigation'; ?> by ', 'straightup' ), 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' ) ) ), esc_attr( sprintf( __( 'View all posts by %s', 'straightup' ), get_the_author() ) ), esc_html( get_the_author() ) ); } /** * Returns true if a blog has more than one category * * @since 1.0 */ function straightup_categorized_blog() { if ( false === ( $all_the_cool_cats = get_transient( 'all_the_cool_cats' ) ) ) { // Create an array of all the categories that are attached to posts $all_the_cool_cats = get_categories( array( 'hide_empty' => 1, ) ); // Count the number of categories that are attached to the posts $all_the_cool_cats = count( $all_the_cool_cats ); set_transient( 'all_the_cool_cats', $all_the_cool_cats ); } if ( '1' != $all_the_cool_cats ) { // This blog has more than 1 category so straightup_categorized_blog should return true return true; } else { // This blog has only 1 category so straightup_categorized_blog should return false return false; } } /** * Flush out the transients used in straightup_categorized_blog * * @since 1.0 */ function straightup_category_transient_flusher() { // Like, beat it. Dig? delete_transient( 'all_the_cool_cats' ); } add_action( 'edit_category', 'straightup_category_transient_flusher' ); add_action( 'save_post', 'straightup_category_transient_flusher' );