post_type}"; $context[] = "singular-{$object->post_type}-{$object_id}"; } // Archive views. elseif ( is_archive() ) { $context[] = 'archive'; // Post type archives. if ( is_post_type_archive() ) { $post_type = get_query_var( 'post_type' ); if ( is_array( $post_type ) ) reset( $post_type ); $context[] = "archive-{$post_type}"; } // Taxonomy archives. if ( is_tax() || is_category() || is_tag() ) { $context[] = 'taxonomy'; $context[] = "taxonomy-{$object->taxonomy}"; $slug = 'post_format' == $object->taxonomy ? str_replace( 'post-format-', '', $object->slug ) : $object->slug; $context[] = "taxonomy-{$object->taxonomy}-" . sanitize_html_class( $slug, $object->term_id ); } // User/author archives. if ( is_author() ) { $user_id = get_query_var( 'author' ); $context[] = 'user'; $context[] = 'user-' . sanitize_html_class( get_the_author_meta( 'user_nicename', $user_id ), $user_id ); } // Date archives. if ( is_date() ) { $context[] = 'date'; if ( is_year() ) $context[] = 'year'; if ( is_month() ) $context[] = 'month'; if ( get_query_var( 'w' ) ) $context[] = 'week'; if ( is_day() ) $context[] = 'day'; } } // Search results. elseif ( is_search() ) { $context[] = 'search'; } // Error 404 pages. elseif ( is_404() ) { $context[] = 'error-404'; } return array_map( 'esc_attr', apply_filters( 'hoot_context', array_unique( $context ) ) ); } /** * Filters the WordPress body class with a better set of classes that are more consistently handled * * @since 3.0.0 * @access public * @param array $classes * @param string|array $class * @return array */ function hoot_body_class_filter( $classes, $class ) { if ( !is_array( $classes ) ) $classes = array(); // WordPress class for uses when WordPress isn't always the only system on the site. $classes[] = 'wordpress'; // Text direction. $classes[] = is_rtl() ? 'rtl' : 'ltr'; // Locale and language. $locale = get_locale(); $lang = hoot_get_language( $locale ); if ( $locale !== $lang ) $classes[] = $lang; $classes[] = strtolower( str_replace( '_', '-', $locale ) ); // Check if the current theme is a parent or child theme. $classes[] = is_child_theme() ? 'child-theme' : 'parent-theme'; // Multisite check adds the 'multisite' class and the blog ID. if ( is_multisite() ) { $classes[] = 'multisite'; $classes[] = 'blog-' . get_current_blog_id(); } // Is the current user logged in. $classes[] = is_user_logged_in() ? 'logged-in' : 'logged-out'; // WP admin bar. if ( is_admin_bar_showing() ) $classes[] = 'admin-bar'; // Use the '.custom-background' class to integrate with the WP background feature. if ( get_background_image() || get_background_color() ) $classes[] = 'custom-background'; // Add the '.custom-header' class if the user is using a custom header. if ( get_header_image() || ( display_header_text() && get_header_textcolor() ) ) $classes[] = 'custom-header'; // Add the '.custom-logo' class if user is using a custom logo. if ( function_exists( 'has_custom_logo' ) && has_custom_logo() ) $classes[] = 'wp-custom-logo'; // Add the '.display-header-text' class if the user chose to display it. if ( display_header_text() ) $classes[] = 'display-header-text'; // Plural/multiple-post view (opposite of singular). if ( apply_filters( 'hoot_is_plural', is_home() || is_archive() || is_search() ) ) $classes[] = 'plural'; // Merge base contextual classes with $classes. $classes = array_merge( $classes, hoot_get_context() ); // Singular post (post_type) classes. if ( is_singular() ) { // Get the queried post object. $post = get_queried_object(); // Checks for custom template. $template = str_replace( array ( "{$post->post_type}-template-", "{$post->post_type}-" ), '', basename( get_page_template_slug( $post->ID ), '.php' ) ); $classes[] = $template ? "{$post->post_type}-template-{$template}" : "{$post->post_type}-template-default"; // Post format. if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) ) { $post_format = get_post_format( get_queried_object_id() ); $classes[] = $post_format && ! is_wp_error( $post_format ) ? "{$post->post_type}-format-{$post_format}" : "{$post->post_type}-format-standard"; } // Attachment mime types. if ( is_attachment() ) { foreach ( explode( '/', get_post_mime_type() ) as $type ) $classes[] = "attachment-{$type}"; } } // Paged views. if ( is_paged() ) { $classes[] = 'paged'; $classes[] = 'paged-' . intval( get_query_var( 'paged' ) ); } // Singular post paged views using . elseif ( is_singular() && 1 < get_query_var( 'page' ) ) { $classes[] = 'paged'; $classes[] = 'paged-' . intval( get_query_var( 'page' ) ); } // Input class. if ( $class ) { $class = is_array( $class ) ? $class : preg_split( '#\s+#', $class ); $classes = array_merge( $classes, $class ); } return array_map( 'esc_attr', $classes ); } /** * Filters the WordPress post class with a better set of classes that are more consistently handled * * @since 3.0.0 * @access public * @param array $classes * @param string|array $class * @param int $post_id * @return array */ function hoot_post_class_filter( $classes, $class, $post_id ) { if ( is_admin() ) return $classes; $_classes = array(); $post = get_post( $post_id ); $post_type = get_post_type(); // Set up array of classes that we want to remove. $remove = array( 'hentry', 'post-password-required' ); if ( post_type_supports( $post_type, 'post-formats' ) ) $remove[] = 'post_format-post-format-' . get_post_format(); // Remove classes. $classes = array_diff( $classes, $remove ); // Entry class. $_classes[] = 'entry'; // Author class. $_classes[] = 'author-' . sanitize_html_class( get_the_author_meta( 'user_nicename' ), get_the_author_meta( 'ID' ) ); // Password-protected posts. if ( post_password_required() ) $_classes[] = 'protected'; // Has excerpt. if ( post_type_supports( $post_type, 'excerpt' ) && has_excerpt() ) $_classes[] = 'has-excerpt'; // Has link. if ( ! is_singular() && false !== strpos( $post->post_content, ' links. if ( false !== strpos( $post->post_content, '