__( 'Primary Menu', 'aperture' ), 'secondary' => __( 'Secondary Menu', 'aperture' ), ) ); // Enable support for Post Formats. add_theme_support( 'post-formats', array( 'aside', 'status', 'image', 'gallery', 'video', 'audio', 'quote', 'chat', 'link', ) ); // Enable support for the Portfolio CPT. add_theme_support( 'jetpack-portfolio' ); // This theme uses its own gallery styles. add_filter( 'use_default_gallery_style', '__return_false' ); // Setup the WordPress core custom background feature. add_theme_support( 'custom-background', apply_filters( 'aperture_custom_background_args', array( 'default-color' => '000000', 'default-image' => '', ) ) ); // Enable support for HTML5 markup. add_theme_support( 'html5', array( 'comment-list', 'search-form', 'comment-form', 'gallery', ) ); } endif; // aperture_setup add_action( 'after_setup_theme', 'aperture_setup' ); /** * Register widgetized area and update sidebar with default widgets. */ function aperture_widgets_init() { register_sidebar( array( 'name' => __( 'Sidebar', 'aperture' ), 'id' => 'right-sidebar', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'Footer', 'aperture' ), 'id' => 'footer-sidebar', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => __( 'After Post', 'aperture' ), 'id' => 'after-post-sidebar', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'aperture_widgets_init' ); /** * Enqueue scripts and styles. */ function aperture_scripts() { wp_enqueue_style( 'genericons', get_template_directory_uri() . '/fonts/genericons.css', array(), '3.0.3' ); wp_enqueue_style( 'aperture-style', get_stylesheet_uri() ); wp_enqueue_style( 'google-fonts', 'http://fonts.googleapis.com/css?family=Droid+Sans:400,700|Oswald:400,700'); wp_enqueue_script( 'sidr', get_template_directory_uri() . '/js/jquery.sidr.min.js', array( 'jquery' ), '1.2.1', true ); wp_enqueue_script( 'aperture-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true ); if ( is_page_template( 'page-slider.php' ) ) { wp_enqueue_script( 'hammer', get_template_directory_uri() . '/js/hammer.min.js', array( 'jquery' ), '1.0.5', true ); wp_enqueue_script( 'jquery-super-slides', get_template_directory_uri() . '/js/jquery.superslides.min.js', array( 'jquery' ), '0.6.2', true ); } if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'wp_enqueue_scripts', 'aperture_scripts' ); /** * Custom editor styles. */ function aperture_add_editor_styles() { add_editor_style( 'aperture-editor-style.css' ); $font_url = 'http://fonts.googleapis.com/css?family=Droid+Sans:400,700|Oswald:400,700'; add_editor_style( str_replace( ',', '%2C', $font_url ) ); } add_action( 'init', 'aperture_add_editor_styles' ); /** * Remove the Jetpack share and like buttons. * @link http://jetpack.me/2013/06/10/moving-sharing-icons/ */ if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'sharedaddy' ) ) { function aperture_remove_share() { remove_filter( 'the_content', 'sharing_display',19 ); remove_filter( 'the_excerpt', 'sharing_display',19 ); if ( class_exists( 'Jetpack_Likes' ) ) { remove_filter( 'the_content', array( Jetpack_Likes::init(), 'post_likes' ), 30, 1 ); } } add_action( 'loop_start', 'aperture_remove_share' ); } /** * Remove the Jetpack related posts. * @link http://wordpress.org/support/topic/change-location-of-related-posts */ if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'related-posts' ) ) { function remove_jprp(){ $jprp = Jetpack_RelatedPosts::init(); remove_filter( 'the_content', array( $jprp, 'filter_add_target_to_dom' ), 40 ); } add_action('wp', 'remove_jprp', 11); } /** * Removes the custom background on the page-slider template. * @link http://www.transformationpowertools.com/wordpress/twenty-eleven-new-page-template-with-sidebar-correction */ function aperture_remove_custom_background($wp_classes, $extra_classes) { if( is_page_template( 'page-slider.php' ) ) : // Filter the body classes foreach($wp_classes as $key => $value) { if ($value == 'custom-background' ) unset($wp_classes[$key]); } endif; // Add the extra classes back untouched return array_merge($wp_classes, (array) $extra_classes ); } add_filter( 'body_class', 'aperture_remove_custom_background', 20, 2 ); /** * Adds a single image background on the page-slider template. * This function is only used when the user has one image in the slider. * It places the neccesary style in the to prevent FOUC. */ function aperture_single_slide_background_css() { $slider = get_theme_mod( 'aperture_slider_image'); if ( false != $slider ) $slider = array_filter( $slider ); if ( false == $slider ) return false; $numberofslides = count( $slider ); $imageurl = array_shift( $slider ); if ( 1 == $numberofslides ) : ?> $post->post_parent, 'fields' => 'ids', 'numberposts' => -1, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID', ) ); // If there is more than 1 attachment in a gallery... if ( count( $attachment_ids ) > 1 ) { foreach ( $attachment_ids as $attachment_id ) { if ( $attachment_id == $post->ID ) { $next_id = current( $attachment_ids ); break; } } // get the URL of the next image attachment... if ( $next_id ) { $next_attachment_url = get_attachment_link( $next_id ); } // or get the URL of the first image attachment. else { $next_attachment_url = get_attachment_link( array_shift( $attachment_ids ) ); } } printf( '%2$s', esc_url( $next_attachment_url ), wp_get_attachment_image( $post->ID, $attachment_size ) ); } endif; /** * Remove post-type support for portfolio items. */ function aperture_remove_post_type_support() { remove_post_type_support( 'jetpack-portfolio', 'post-formats' ); } add_action( 'init', 'aperture_remove_post_type_support', 10 ); /** * Add a link and an infinity symbol to the aside post format. * @link http://justintadlock.com/archives/2012/09/06/post-formats-aside */ function aperture_aside_format( $content ) { if ( has_post_format( 'aside' ) && !is_singular() ) $content .= ' '; return $content; } add_filter( 'the_content', 'aperture_aside_format', 9 ); // run before wpautop /** * Add a link and an infinity symbol to the status post format. */ function aperture_status_format( $content ) { if ( has_post_format( 'status' ) && !is_singular() ) $content .= ' '; return $content; } add_filter( 'the_content', 'aperture_status_format', 9 ); // run before wpautop /** * And finally the Chat Post Format. * @link http://justintadlock.com/archives/2012/08/21/post-formats-chat */ /* Filter the content of chat posts. */ add_filter( 'the_content', 'aperture_format_chat_content' ); /* Auto-add paragraphs to the chat text. */ add_filter( 'aperture_post_format_chat_text', 'wpautop' ); /** * This function filters the post content when viewing a post with the "chat" post format. It formats the * content with structured HTML markup to make it easy for theme developers to style chat posts. The * advantage of this solution is that it allows for more than two speakers (like most solutions). You can * have 100s of speakers in your chat post, each with their own, unique classes for styling. * * @author David Chandra * @link http://www.turtlepod.org * @author Justin Tadlock * @link http://justintadlock.com * @copyright Copyright (c) 2012 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @link http://justintadlock.com/archives/2012/08/21/post-formats-chat * * @global array $_post_format_chat_ids An array of IDs for the chat rows based on the author. * @param string $content The content of the post. * @return string $chat_output The formatted content of the post. */ function aperture_format_chat_content( $content ) { global $_post_format_chat_ids; /* If this is not a 'chat' post, return the content. */ if ( !has_post_format( 'chat' ) ) return $content; /* Set the global variable of speaker IDs to a new, empty array for this chat. */ $_post_format_chat_ids = array(); /* Allow the separator (separator for speaker/text) to be filtered. */ $separator = apply_filters( 'aperture_post_format_chat_separator', ':' ); /* Open the chat transcript div and give it a unique ID based on the post ID. */ $chat_output = "\n\t\t\t" . '
'; /* Split the content to get individual chat rows. */ $chat_rows = preg_split( "/(\r?\n)+|(\s*)+/", $content ); /* Loop through each row and format the output. */ foreach ( $chat_rows as $chat_row ) { /* If a speaker is found, create a new chat row with speaker and text. */ if ( strpos( $chat_row, $separator ) ) { /* Split the chat row into author/text. */ $chat_row_split = explode( $separator, trim( $chat_row ), 2 ); /* Get the chat author and strip tags. */ $chat_author = strip_tags( trim( $chat_row_split[0] ) ); /* Get the chat text. */ $chat_text = trim( $chat_row_split[1] ); /* Get the chat row ID (based on chat author) to give a specific class to each row for styling. */ $speaker_id = aperture_format_chat_row_id( $chat_author ); /* Open the chat row. */ $chat_output .= "\n\t\t\t\t" . '
'; /* Add the chat row author. */ $chat_output .= "\n\t\t\t\t\t" . '
' . apply_filters( 'aperture_post_format_chat_author', $chat_author, $speaker_id ) . '' . $separator . '
'; /* Add the chat row text. */ $chat_output .= "\n\t\t\t\t\t" . '
' . str_replace( array( "\r", "\n", "\t" ), '', apply_filters( 'aperture_post_format_chat_text', $chat_text, $chat_author, $speaker_id ) ) . '
'; /* Close the chat row. */ $chat_output .= "\n\t\t\t\t" . '
'; } /** * If no author is found, assume this is a separate paragraph of text that belongs to the * previous speaker and label it as such, but let's still create a new row. */ else { /* Make sure we have text. */ if ( !empty( $chat_row ) ) { /* If there is no speaker_id leave this alone. */ if ( !empty( $speaker_id ) ) { /* Open the chat row. */ $chat_output .= "\n\t\t\t\t" . '
'; } else { $chat_output .= "\n\t\t\t\t" . '
'; } /* Don't add a chat row author. The label for the previous row should suffice. */ /* If there is no chat author leave this alone. */ if ( !empty( $chat_author ) ) { /* Add the chat row text. */ $chat_output .= "\n\t\t\t\t\t" . '
' . str_replace( array( "\r", "\n", "\t" ), '', apply_filters( 'aperture_post_format_chat_text', $chat_row, $chat_author, $speaker_id ) ) . '
'; } /* Close the chat row. */ $chat_output .= "\n\t\t\t
"; } } } /* Close the chat transcript div. */ $chat_output .= "\n\t\t\t
\n"; /* Return the chat content and apply filters for developers. */ return apply_filters( 'aperture_post_format_chat_content', $chat_output ); } /** * This function returns an ID based on the provided chat author name. It keeps these IDs in a global * array and makes sure we have a unique set of IDs. The purpose of this function is to provide an "ID" * that will be used in an HTML class for individual chat rows so they can be styled. So, speaker "John" * will always have the same class each time he speaks. And, speaker "Mary" will have a different class * from "John" but will have the same class each time she speaks. * * @author David Chandra * @link http://www.turtlepod.org * @author Justin Tadlock * @link http://justintadlock.com * @copyright Copyright (c) 2012 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @link http://justintadlock.com/archives/2012/08/21/post-formats-chat * * @global array $_post_format_chat_ids An array of IDs for the chat rows based on the author. * @param string $chat_author Author of the current chat row. * @return int The ID for the chat row based on the author. */ function aperture_format_chat_row_id( $chat_author ) { global $_post_format_chat_ids; /* Let's sanitize the chat author to avoid craziness and differences like "John" and "john". */ $chat_author = strtolower( strip_tags( $chat_author ) ); /* Add the chat author to the array. */ $_post_format_chat_ids[] = $chat_author; /* Make sure the array only holds unique values. */ $_post_format_chat_ids = array_unique( $_post_format_chat_ids ); /* Return the array key for the chat author and add "1" to avoid an ID of "0". */ return absint( array_search( $chat_author, $_post_format_chat_ids ) ) + 1; } /* End of chat post format. */ /** * Fix IE8 */ function add_ie_html5_shim () { echo ''; } add_action('wp_head', 'add_ie_html5_shim'); /** * Custom template tags for this theme. */ require get_template_directory() . '/inc/template-tags.php'; /** * Custom functions that act independently of the theme templates. */ require get_template_directory() . '/inc/extras.php'; /** * Customizer additions. */ require get_template_directory() . '/inc/customizer.php'; /** * Load Jetpack compatibility file. */ require get_template_directory() . '/inc/jetpack.php'; /** * Custom widgets for this theme. */ require get_template_directory() . '/inc/custom-widgets.php';