__( 'Primary Menu', 'aldus' ) ) ); // This theme uses its own gallery styles. add_filter( 'use_default_gallery_style', '__return_false' ); } add_action( 'after_setup_theme', 'aldus_setup' ); /** * Register widgetized area and update sidebar with default widgets */ function aldus_widgets_init() { register_sidebar( array( 'name' => __( 'First Footer Widget Area', 'aldus' ), 'id' => 'sidebar-1', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Second Footer Widget Area', 'aldus' ), 'id' => 'sidebar-2', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Third Footer Widget Area', 'aldus' ), 'id' => 'sidebar-3', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'aldus_widgets_init' ); /** * Enqueue scripts and styles */ function aldus_scripts() { wp_enqueue_style( 'aldus-style', get_stylesheet_uri(), array(), '20130728' ); wp_enqueue_script( 'aldus-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20130728', true ); wp_enqueue_script( 'aldus-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130728', true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'aldus_scripts' ); /** * Loads our special font CSS file. */ function aldus_fonts() { $fonts_url = aldus_fonts_url(); if ( ! empty( $fonts_url ) ) wp_enqueue_style( 'aldus-fonts', esc_url_raw( $fonts_url ), array(), null ); } add_action( 'wp_enqueue_scripts', 'aldus_fonts' ); /** * Returns the Google font stylesheet URL, if available. * * The use of Lora by default is localized. For languages that use characters * not supported by the font, the font can be disabled. * * Returns the font stylesheet URL or empty string if disabled. */ function aldus_fonts_url() { $fonts_url = ''; $lora = _x( 'on', "If there are characters in your language that are not supported by the Lora font, translate this to 'off'. Else don't translate at all.", 'aldus' ); if ( 'off' !== $lora ) { $font_families = array(); $font_families[] = 'Lora:400,700,400italic,700italic'; $protocol = is_ssl() ? 'https' : 'http'; $query_args = array( 'family' => implode( '|', $font_families ), 'subset' => 'latin', ); $fonts_url = add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ); } return $fonts_url; } /** * Adds additional stylesheets to the TinyMCE editor if needed. */ function aldus_mce_css( $mce_css ) { $font_url = aldus_fonts_url(); if ( empty( $font_url ) ) return $mce_css; if ( ! empty( $mce_css ) ) $mce_css .= ','; $mce_css .= esc_url_raw( str_replace( ',', '%2C', $font_url ) ); return $mce_css; } add_filter( 'mce_css', 'aldus_mce_css' ); /** * Filters wp_title to print a neat tag based on what is being viewed. */ function aldus_wp_title( $title, $sep ) { global $page, $paged; if ( is_feed() ) return $title; // Add the blog name $title .= 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() ) ) $title .= " $sep $site_description"; // Add a page number if necessary: if ( $paged >= 2 || $page >= 2 ) $title .= " $sep " . sprintf( __( 'Page %s', 'aldus' ), max( $paged, $page ) ); return $title; } add_filter( 'wp_title', 'aldus_wp_title', 10, 2 ); /** * Return the URL of the first link found in the post content. * Falls back to the post permalink of no link is found. * * Uses the get_url_in_content() function introduced in WordPress 3.6 if it exists. * If not, it falls back to the custom aldus_extract_url_from_content() function. */ function aldus_get_link_url() { $content = get_the_content(); if ( function_exists( 'get_url_in_content' ) ) { $has_url = get_url_in_content( $content ); } else { $has_url = aldus_extract_url_from_content( $content ); } return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() ); } if ( ! function_exists( 'aldus_extract_url_from_content' ) ) : /** * Returns the URL found in the post content if found. * If not returns false. */ function aldus_extract_url_from_content( $content ) { if ( empty( $content ) ) return false; $trimmed = trim( $content ); $lines = explode( "\n", $trimmed ); $line = trim( array_shift( $lines ) ); // Case 1: The post contains an URL and no other content if ( 0 === stripos( $trimmed, 'http' ) && ! preg_match( '#\s#', $trimmed ) ) { return $trimmed; } // Case 2: The content contains and HTML URL either followed by or contained in the content elseif ( preg_match( '/<a\s[^>]*?href=([\'"])(.+?)\1/is', $content, $matches ) ) { // The HTML is the first line of the post, get rid of it. if( 0 === stripos( $line, '<a href' ) && 0 === stripos( strrev( $line ), '>a/<' ) ) { $content = trim( join( "\n", $lines ) ) ; } return esc_url_raw( $matches[2] ); } // Case 3: The post contains an URL followed by content if ( 0 === stripos( $line, 'http' ) ) { return esc_url_raw( $line ); } // If none of these cases apply, return false. return false; } endif; // aldus_extract_url_from_content if ( ! function_exists( 'aldus_entry_meta' ) ) : /** * Prints HTML with meta information for the current post: Date, author (when multi-author), * permalink and edit link */ function aldus_entry_meta() { ?> <div class="entry-meta-date-links"> <time class="date" datetime="<?php echo esc_attr( get_the_date( 'c' ) ); ?>"><?php echo esc_html( get_the_date() ); ?></time> <?php if( is_multi_author() ) : ?> <span class="sep"> • </span> <?php printf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>', esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_attr( sprintf( __( 'View all posts by %s', 'aldus' ), get_the_author() ) ), get_the_author() ); ?> <?php endif; ?> <span class="sep"> • </span> <span class="permalink"><a href="<?php echo esc_url( get_permalink() ); ?>" rel="bookmark"><?php _e( '∞', 'aldus' ); ?></a></span> <?php edit_post_link( __( 'Edit', 'aldus' ), '<span class="sep"> • </span><span class="edit-link">', '</span>' ); ?> </div> <?php if( is_single() ) : ?> <?php $category_list = get_the_category_list( __( ', ', 'aldus' ) ); $tag_list = get_the_tag_list( '', __( ', ', 'aldus' ) ); if( $category_list || $tag_list ) : ?> <div class="entry-categories-tags"> <?php if( $category_list ) : ?> <p class="categories"><?php echo __( 'Posted in:', 'aldus' ) . ' ' . $category_list; ?> <?php endif; ?> <?php if( $tag_list ) : ?> <p class="tags"><?php echo __( 'Tagged:', 'aldus' ) . ' ' . $tag_list; ?> <?php endif; ?> </div> <?php endif; ?> <?php endif; } endif; // aldus_entry_meta if ( ! function_exists( 'aldus_paging_nav' ) ) : /** * Displays navigation to next/previous set of posts when applicable. */ function aldus_paging_nav() { global $wp_query; // Don't print empty markup if there's only one page. if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) ) return; ?> <nav class="navigation paging-navigation" role="navigation"> <h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'aldus' ); ?></h1> <div class="nav-links"> <?php if ( get_next_posts_link() ) : ?> <div class="nav-previous"><?php next_posts_link( '<div class="arrow">←</div>' . __( 'Older posts', 'aldus' ) ); ?></div> <?php endif; ?> <?php if ( get_previous_posts_link() ) : ?> <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <div class="arrow">→</div>', 'aldus' ) ); ?></div> <?php endif; ?> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php } endif; // aldus_paging_nav if ( ! function_exists( 'aldus_post_nav' ) ) : /** * Displays navigation to next/previous post when applicable. */ function aldus_post_nav() { global $post; // Don't print empty markup if there's nowhere to navigate. $previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true ); $next = get_adjacent_post( false, '', false ); if ( ! $next && ! $previous ) return; ?> <nav class="navigation post-navigation" role="navigation"> <h1 class="screen-reader-text"><?php _e( 'Post navigation', 'aldus' ); ?></h1> <div class="nav-links"> <?php previous_post_link( '<div class="nav-previous">%link</div>', '<div class="arrow">' . _x( '←', 'Previous post link', 'aldus' ) . '</div><div class="link">%title</div>' ); ?> <?php next_post_link( '<div class="nav-next">%link</div>', '<div class="arrow">' . _x( '→', 'Next post link', 'aldus' ) . '</div><div class="link">%title</div>' ); ?> </div><!-- .nav-links --> </nav><!-- .navigation --> <?php } endif; // aldus_post_nav if ( ! function_exists( 'aldus_comment' ) ) : /** * Template for comments and pingbacks. * * Used as a callback by wp_list_comments() for displaying the comments. */ function aldus_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; if ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) : ?> <li id="comment-<?php comment_ID(); ?>" <?php comment_class(); ?>> <div class="comment-body"> <?php _e( 'Pingback:', 'aldus' ); ?> <?php comment_author_link(); ?> <span class="sep"> • </span><?php edit_comment_link( __( 'Edit', 'aldus' ), '<span class="edit-link">', '</span>' ); ?> </div> <?php else : ?> <li id="comment-<?php comment_ID(); ?>" <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?>> <article id="div-comment-<?php comment_ID(); ?>" class="comment-body"> <footer class="comment-meta"> <div class="comment-author vcard"> <?php if ( 0 != $args['avatar_size'] ) echo get_avatar( $comment, $args['avatar_size'] ); ?> <?php printf( '<cite class="fn">%s</cite>', get_comment_author_link() ); ?> </div><!-- .comment-author --> <div class="comment-metadata"> <a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"> <time datetime="<?php comment_time( 'c' ); ?>"> <?php printf( _x( '%1$s at %2$s', '1: date, 2: time', 'aldus' ), get_comment_date(), get_comment_time() ); ?> </time> </a> </div><!-- .comment-metadata --> <?php if ( '0' == $comment->comment_approved ) : ?> <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'aldus' ); ?></p> <?php endif; ?> </footer><!-- .comment-meta --> <div class="comment-content"> <?php comment_text(); ?> </div><!-- .comment-content --> <div class="reply"> <?php comment_reply_link( array_merge( $args, array( 'add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> </div><!-- .reply --> <div class="edit-link"> <?php edit_comment_link( __( 'Edit', 'aldus' ), '<span class="edit-link">', '</span>' ); ?> </div> </article><!-- .comment-body --> <?php endif; } endif; // ends check for aldus_comment() /** * Keep WordPress from registering the default widgets. * * Based on "Remove Default Widgets" Plugin: http://wordpress.org/plugins/remove-default-widgets/ */ function aldus_do_widgets_init_action() { do_action( 'widgets_init' ); } add_action( 'init', 'aldus_do_widgets_init_action', 1 ); function aldus_remove_widgets_init_action() { remove_action( 'init', 'wp_widgets_init', 1 ); } add_action( 'plugins_loaded', 'aldus_remove_widgets_init_action' );