* @author Sami Keijonen * @copyright Copyright (c) 2008 - 2014, Justin Tadlock * @link http://themehybrid.com/hybrid-core * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ /* Attributes for major structural elements. */ add_filter('hybrid_attr_body', 'hybrid_attr_body', 5); add_filter('hybrid_attr_header', 'hybrid_attr_header', 5); add_filter('hybrid_attr_footer', 'hybrid_attr_footer', 5); add_filter('hybrid_attr_content', 'hybrid_attr_content', 5); add_filter('hybrid_attr_sidebar', 'hybrid_attr_sidebar', 5, 2); add_filter('hybrid_attr_menu', 'hybrid_attr_menu', 5, 2); /* Header attributes. */ add_filter('hybrid_attr_branding', 'hybrid_attr_branding', 5); add_filter('hybrid_attr_site-title', 'hybrid_attr_site_title', 5); add_filter('hybrid_attr_site-description', 'hybrid_attr_site_description', 5); /* Loop attributes. */ add_filter('hybrid_attr_loop-meta', 'hybrid_attr_loop_meta', 5); add_filter('hybrid_attr_loop-title', 'hybrid_attr_loop_title', 5); add_filter('hybrid_attr_loop-description', 'hybrid_attr_loop_description', 5); /* Post-specific attributes. */ add_filter('hybrid_attr_post', 'hybrid_attr_post', 5); add_filter('hybrid_attr_entry', 'hybrid_attr_post', 5); // Alternate for "post". add_filter('hybrid_attr_entry-title', 'hybrid_attr_entry_title', 5); add_filter('hybrid_attr_entry-author', 'hybrid_attr_entry_author', 5); add_filter('hybrid_attr_entry-published', 'hybrid_attr_entry_published', 5); add_filter('hybrid_attr_entry-content', 'hybrid_attr_entry_content', 5); add_filter('hybrid_attr_entry-summary', 'hybrid_attr_entry_summary', 5); add_filter('hybrid_attr_entry-terms', 'hybrid_attr_entry_terms', 5, 2); /* Comment specific attributes. */ add_filter('hybrid_attr_comment', 'hybrid_attr_comment', 5); add_filter('hybrid_attr_comment-author', 'hybrid_attr_comment_author', 5); add_filter('hybrid_attr_comment-published', 'hybrid_attr_comment_published', 5); add_filter('hybrid_attr_comment-permalink', 'hybrid_attr_comment_permalink', 5); add_filter('hybrid_attr_comment-content', 'hybrid_attr_comment_content', 5); /** * Outputs an HTML element's attributes. * * @since 2.0.0 * @access public * @param string $slug The slug/ID of the element (e.g., 'sidebar'). * @param string $context A specific context (e.g., 'primary'). * @return void */ function hybrid_attr($slug, $context = '') { echo hybrid_get_attr($slug, $context); } /** * Gets an HTML element's attributes. This function is actually meant to be filtered by theme authors, plugins, * or advanced child theme users. The purpose is to allow folks to modify, remove, or add any attributes they * want without having to edit every template file in the theme. So, one could support microformats instead * of microdata, if desired. * * @since 2.0.0 * @access public * @param string $slug The slug/ID of the element (e.g., 'sidebar'). * @param string $context A specific context (e.g., 'primary'). * @return string */ function hybrid_get_attr($slug, $context = '') { $out = ''; $attr = apply_filters("hybrid_attr_{$slug}", array(), $context); //if ( empty( $attr ) ) //$attr['class'] = $slug; foreach ($attr as $name => $value) $out .= !empty($value) ? sprintf(' %s="%s"', esc_html($name), esc_attr($value)) : esc_html(" {$name}"); return trim($out); } /* === Structural === */ /** * element attributes. * * @since 2.0.0 * @access public * @param array $attr * @return array */ function hybrid_attr_body($attr) { $attr['itemscope'] = 'itemscope'; $attr['itemtype'] = 'http://schema.org/WebPage'; if (is_singular('post') || is_home() || is_archive()) { $attr['itemscope'] = ''; $attr['itemtype'] = 'http://schema.org/Blog'; } if (is_search()) { $attr['itemtype'] = 'http://schema.org/SearchResultsPage'; } return $attr; } /** * Page
element attributes. * * @since 2.0.0 * @access public * @param array $attr * @return array */ function hybrid_attr_header($attr) { $attr['itemscope'] = 'itemscope'; $attr['itemtype'] = 'http://schema.org/WPHeader'; return $attr; } /** * Page