/** * Echo no widget content. * * @since 1.0.0 */ function beans_no_widget() { // Only apply this notice to sidebar_primary and sidebar_secondary. if (!in_array(beans_get_widget_area('id'), array('sidebar_primary', 'sidebar_secondary'))) { return; } beans_open_markup_e('beans_no_widget_notice', 'p', array('class' => 'uk-alert uk-alert-warning')); beans_output_e('beans_no_widget_notice_text', sprintf(__('%s does not have any widget assigned!', 'tm-beans'), beans_get_widget_area('name'))); beans_close_markup_e('beans_no_widget_notice', 'p'); }
/** * Echo the footer content. * * @since 1.0.0 */ function beans_footer_content() { beans_open_markup_e('beans_footer_credit', 'div', array('class' => 'uk-clearfix uk-text-small uk-text-muted')); beans_open_markup_e('beans_footer_credit_left', 'span', array('class' => 'uk-align-medium-left uk-margin-small-bottom')); beans_output_e('beans_footer_credit_text', sprintf(__('© %1$s - %2$s. All rights reserved.', 'tm-beans'), date('Y'), get_bloginfo('name'))); beans_close_markup_e('beans_footer_credit_left', 'span'); $framework_link = beans_open_markup('beans_footer_credit_framework_link', 'a', array('href' => 'http://www.getbeans.io', 'rel' => 'designer')); $framework_link .= beans_output('beans_footer_credit_framework_link_text', 'Beans'); $framework_link .= beans_close_markup('beans_footer_credit_framework_link', 'a'); beans_open_markup_e('beans_footer_credit_right', 'span', array('class' => 'uk-align-medium-right uk-margin-bottom-remove')); beans_output_e('beans_footer_credit_right_text', sprintf(__('%1$s theme for WordPress.', 'tm-beans'), $framework_link)); beans_close_markup_e('beans_footer_credit_right', 'span'); beans_close_markup_e('beans_footer_credit', 'div'); }
/** * Echo post meta comments shortcode. * * @since 1.0.0 */ function beans_post_meta_comments_shortcode() { global $post; if (post_password_required() || !comments_open()) { return; } $comments_number = (int) get_comments_number($post->ID); if ($comments_number < 1) { $comment_text = beans_output('beans_post_meta_empty_comment_text', __('Leave a comment', 'tm-beans')); } elseif (1 === $comments_number) { $comment_text = beans_output('beans_post_meta_comments_text_singular', __('1 comment', 'tm-beans')); } else { $comment_text = beans_output('beans_post_meta_comments_text_plurial', __('%s comments', 'tm-beans')); } beans_open_markup_e('beans_post_meta_comments', 'a', array('href' => get_comments_link())); printf($comment_text, (int) get_comments_number($post->ID)); beans_close_markup_e('beans_post_meta_comments', 'a'); }
/** * Echo field description. * * @since 1.0.0 * * @param array $field { * Array of data. * * @type string $description The field description. The description can be truncated using <!--more--> * as a delimiter. Default false. * } */ function beans_field_description($field) { if (!($description = beans_get('description', $field))) { return; } beans_open_markup_e('beans_field_description[_' . $field['id'] . ']', 'div', array('class' => 'bs-field-description')); if (preg_match('#<!--more-->#', $description, $matches)) { list($description, $extended) = explode($matches[0], $description, 2); } echo $description; if (isset($extended)) { ?> <br /><a class="bs-read-more" href="#"><?php _e('More...', 'tm-beans'); ?> </a> <div class="bs-extended-content"><?php echo $extended; ?> </div> <?php } beans_close_markup_e('beans_field_description[_' . $field['id'] . ']', 'div'); }
<?php /** * Echo the secondary sidebar structural markup. It also calls the secondary sidebar action hooks. * * @package Structure\Secondary_Sidebar */ beans_open_markup_e('beans_sidebar_secondary', 'aside', array('class' => 'tm-tertiary ' . beans_get_layout_class('sidebar_secondary'), 'role' => 'complementary', 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/WPSideBar')); /** * Fires in the secondary sidebar. * * @since 1.0.0 */ do_action('beans_sidebar_secondary'); beans_close_markup_e('beans_sidebar_secondary', 'aside');
/** * Echo no menu notice. * * @since 1.0.0 */ function beans_no_menu_notice() { beans_open_markup_e('beans_no_menu_notice', 'p', array('class' => 'uk-alert uk-alert-warning')); beans_output_e('beans_no_menu_notice_text', __('Whoops, your site does not have a menu!', 'tm-beans')); beans_close_markup_e('beans_no_menu_notice', 'p'); }
/** * Display the field content. */ public function field_content($field) { beans_open_markup_e('beans_field_wrap', 'div', array('class' => 'bs-field-wrap bs-' . $field['type'] . ' ' . $field['context']), $field); // Set fields loop to cater for groups. if ('group' === $field['type']) { $fields = $field['fields']; } else { $fields = array($field); } beans_open_markup_e('beans_field_inside', 'div', array('class' => 'bs-field-inside'), $fields); // Loop through fields. foreach ($fields as $single_field) { beans_open_markup_e('beans_field[_' . $single_field['id'] . ']', 'div', array('class' => 'bs-field bs-' . $single_field['type']), $single_field); do_action('beans_field_' . $single_field['type'], $single_field); beans_close_markup_e('beans_field[_' . $single_field['id'] . ']', 'div', $single_field); } beans_close_markup_e('beans_field_inside', 'div', $fields); beans_close_markup_e('beans_field_wrap', 'div', $field); }
<?php /** * Echo the structural markup for each comment. It also calls the comment action hooks. * * @package Structure\Comment */ beans_open_markup_e('beans_comment', 'article', array('id' => 'div-comment-' . get_comment_ID(), 'class' => 'uk-comment', 'itemprop' => 'comment', 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/Comment')); beans_open_markup_e('beans_comment_header', 'header', array('class' => 'uk-comment-header')); /** * Fires in the comment header. * * @since 1.0.0 */ do_action('beans_comment_header'); beans_close_markup_e('beans_comment_header', 'header'); beans_open_markup_e('beans_comment_body', 'div', array('class' => 'uk-comment-body', 'itemprop' => 'text')); /** * Fires in the comment body. * * @since 1.0.0 */ do_action('beans_comment_content'); beans_close_markup_e('beans_comment_body', 'div'); beans_close_markup_e('beans_comment', 'article');
do_action('beans_widget'); beans_close_markup_e('beans_widget_panel' . _beans_widget_subfilters(), 'div'); if ('grid' == beans_get_widget_area('beans_type')) { beans_close_markup_e('beans_widget_grid' . _beans_widget_subfilters(), 'div'); } } /** * Fires after the widgets loop. * * This hook only fires if widgets exist. * * @since 1.0.0 */ do_action('beans_after_widgets_loop'); } else { /** * Fires if no widgets exist. * * @since 1.0.0 */ do_action('beans_no_widget'); } if ('offcanvas' == beans_get_widget_area('beans_type')) { beans_close_markup_e('beans_widget_area_offcanvas_bar' . _beans_widget_area_subfilters(), 'div'); beans_close_markup_e('beans_widget_area_offcanvas_wrap' . _beans_widget_area_subfilters(), 'div'); } if ('grid' == beans_get_widget_area('beans_type')) { beans_close_markup_e('beans_widget_area_grid' . _beans_widget_area_subfilters(), 'div'); } // This includes everything added to wp hooks after the widgets. echo beans_get_widget_area('after_widgets');
/** * Fires in the post header. * * @since 1.0.0 */ do_action('beans_post_header'); beans_close_markup_e('beans_post_header', 'header'); beans_open_markup_e('beans_post_body', 'div', array('itemprop' => 'articleBody')); /** * Fires in the post body. * * @since 1.0.0 */ do_action('beans_post_body'); beans_close_markup_e('beans_post_body', 'div'); beans_close_markup_e('beans_post', 'article'); } /** * Fires after the posts loop. * * This hook fires if posts exist. * * @since 1.0.0 */ do_action('beans_after_posts_loop'); } else { /** * Fires if no posts exist. * * @since 1.0.0 */
/** * Echo header site title tag. * * @since 1.0.0 */ function beans_site_title_tag() { // Stop here if there isn't a description. if (!($description = get_bloginfo('description'))) { return; } beans_open_markup_e('beans_site_title_tag', 'span', array('class' => 'tm-site-title-tag uk-text-small uk-text-muted uk-display-block', 'itemprop' => 'description')); beans_output_e('beans_site_title_tag_text', $description); beans_close_markup_e('beans_site_title_tag', 'span'); }
<?php /** * Since WordPress force us to use the footer.php name to close the document, we add a footer-partial.php template for the actual footer. * * @package Structure\Footer */ beans_open_markup_e('beans_footer', 'footer', array('class' => 'tm-footer uk-block', 'role' => 'contentinfo', 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/WPFooter')); beans_open_markup_e('beans_fixed_wrap[_footer]', 'div', 'class=uk-container uk-container-center'); /** * Fires in the footer. * * This hook fires in the footer HTML section, not in wp_footer(). * * @since 1.0.0 */ do_action('beans_footer'); beans_close_markup_e('beans_fixed_wrap[_footer]', 'div'); beans_close_markup_e('beans_footer', 'footer');
/** * Echo comment fields closing wraps. * * This function must be attached to the WordPress 'comment_form_after_fields' action which is only called if * the user is not logged in. * * @since 1.0.0 */ function beans_comment_form_after_fields() { beans_close_markup_e('beans_comment_fields_inner_wrap', 'div'); beans_close_markup_e('beans_comment_fields_wrap', 'div'); }
<?php /** * Despite its name, this template echos between the opening HTML markup and the opening primary markup. * * This template must be called using get_header(). * * @package Structure\Header */ beans_output_e('beans_doctype', '<!DOCTYPE html>'); beans_open_markup_e('beans_html', 'html', str_replace(' ', '&', str_replace('"', '', beans_render_function('language_attributes')))); beans_open_markup_e('beans_head', 'head'); /** * Fires in the head. * * This hook fires in the head HTML section, not in wp_header(). * * @since 1.0.0 */ do_action('beans_head'); wp_head(); beans_close_markup_e('beans_head', 'head'); beans_open_markup_e('beans_body', 'body', array('class' => implode(' ', get_body_class('uk-form no-js')), 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/WebPage')); beans_open_markup_e('beans_site', 'div', array('class' => 'tm-site')); beans_open_markup_e('beans_main', 'main', array('class' => 'tm-main uk-block')); beans_open_markup_e('beans_fixed_wrap[_main]', 'div', 'class=uk-container uk-container-center'); beans_open_markup_e('beans_main_grid', 'div', array('class' => 'uk-grid', 'data-uk-grid-margin' => '')); beans_open_markup_e('beans_primary', 'div', array('class' => 'tm-primary ' . beans_get_layout_class('content')));
wp_list_comments(array('avatar_size' => 50, 'callback' => 'beans_comment_callback')); beans_close_markup_e('beans_comments_list', 'ol'); } else { /** * Fires if no comments exist. * * This hook only fires if comments are open. * * @since 1.0.0 */ do_action('beans_no_comment'); } /** * Fires after the comments list. * * This hook only fires if comments are open. * * @since 1.0.0 */ do_action('beans_after_open_comments'); } if (!comments_open()) { /** * Fires if comments are closed. * * @since 1.0.0 */ do_action('beans_comments_closed'); } beans_close_markup_e('beans_comments', 'div');
/** * Echo no post content. * * @since 1.0.0 */ function beans_no_post() { beans_open_markup_e('beans_post', 'article', array('class' => 'tm-no-article uk-article' . (current_theme_supports('beans-default-styling') ? ' uk-panel-box' : null))); beans_open_markup_e('beans_post_header', 'header'); beans_open_markup_e('beans_post_title', 'h1', array('class' => 'uk-article-title')); beans_output_e('beans_no_post_article_title_text', __('Whoops, no result found!', 'tm-beans')); beans_close_markup_e('beans_post_title', 'h1'); beans_close_markup_e('beans_post_header', 'header'); beans_open_markup_e('beans_post_body', 'div'); beans_open_markup_e('beans_post_content', 'div', array('class' => 'tm-article-content')); beans_open_markup_e('beans_no_post_article_content', 'p', array('class' => 'uk-alert uk-alert-warning')); beans_output_e('beans_no_post_article_content_text', __('It looks like nothing was found at this location. Maybe try a search?', 'tm-beans')); beans_close_markup_e('beans_no_post_article_content', 'p'); beans_output_e('beans_no_post_search_form', get_search_form(false)); beans_close_markup_e('beans_post_content', 'div'); beans_close_markup_e('beans_post_body', 'div'); beans_close_markup_e('beans_post', 'article'); }
<?php /** * Echo the primary sidebar structural markup. It also calls the primary sidebar action hooks. * * @package Structure\Primary_Sidebar */ beans_open_markup_e('beans_sidebar_primary', 'aside', array('class' => 'tm-secondary ' . beans_get_layout_class('sidebar_primary'), 'role' => 'complementary', 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/WPSideBar')); /** * Fires in the primary sidebar. * * @since 1.0.0 */ do_action('beans_sidebar_primary'); beans_close_markup_e('beans_sidebar_primary', 'aside');
<?php /** * Since WordPress force us to use the header.php name to open the document, we add a header-partial.php template for the actual header. * * @package Structure\Header */ beans_open_markup_e('beans_header', 'header', array('class' => 'tm-header uk-block', 'role' => 'banner', 'itemscope' => 'itemscope', 'itemtype' => 'http://schema.org/WPHeader')); beans_open_markup_e('beans_fixed_wrap[_header]', 'div', 'class=uk-container uk-container-center'); /** * Fires in the header. * * @since 1.0.0 */ do_action('beans_header'); beans_close_markup_e('beans_fixed_wrap[_header]', 'div'); beans_close_markup_e('beans_header', 'header');
/** * Echo the breadcrumb. * * @since 1.0.0 */ function beans_breadcrumb() { if (is_home() || is_front_page()) { return; } wp_reset_query(); global $post; $post_type = get_post_type(); $breadcrumbs = array(); $breadcrumbs[home_url()] = __('Home', 'tm-beans'); // Custom post type. if (!in_array($post_type, array('page', 'attachment', 'post')) && !is_404()) { if ($post_type_object = get_post_type_object($post_type)) { $breadcrumbs[get_post_type_archive_link($post_type)] = $post_type_object->labels->name; } } // Single posts. if (is_single() && 'post' == $post_type) { foreach (get_the_category($post->ID) as $category) { $breadcrumbs[get_category_link($category->term_id)] = $category->name; } $breadcrumbs[] = get_the_title(); } elseif (is_singular() && !is_home() && !is_front_page()) { // Pages/custom post type. $current_page = array($post); // Get the parent pages of the current page if they exist. if (isset($current_page[0]->post_parent)) { while ($current_page[0]->post_parent) { array_unshift($current_page, get_post($current_page[0]->post_parent)); } } // Add returned pages to breadcrumbs. foreach ($current_page as $page) { $breadcrumbs[get_page_link($page->ID)] = $page->post_title; } } elseif (is_category()) { // Categories. $breadcrumbs[] = single_cat_title('', false); } elseif (is_tax()) { // Taxonomies. $current_term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); $ancestors = array_reverse(get_ancestors($current_term->term_id, get_query_var('taxonomy'))); foreach ($ancestors as $ancestor) { $ancestor = get_term($ancestor, get_query_var('taxonomy')); $breadcrumbs[get_term_link($ancestor->slug, get_query_var('taxonomy'))] = $ancestor->name; } $breadcrumbs[] = $current_term->name; } elseif (is_search()) { // Searches. $breadcrumbs[] = __('Results:', 'tm-beans') . ' ' . get_search_query(); } elseif (is_author()) { // Author archives. $author = get_queried_object(); $breadcrumbs[] = __('Author Archives:', 'tm-beans') . ' ' . $author->display_name; } elseif (is_tag()) { // Tag archives. $breadcrumbs[] = __('Tag Archives:', 'tm-beans') . ' ' . single_tag_title('', false); } elseif (is_date()) { // Date archives. $breadcrumbs[] = __('Archives:', 'tm-beans') . ' ' . get_the_time('F Y'); } elseif (is_404()) { // 404. $breadcrumbs[] = __('404', 'tm-beans'); } // Open breadcrumb. beans_open_markup_e('beans_breadcrumb', 'ul', array('class' => 'uk-breadcrumb uk-width-1-1')); $i = 0; foreach ($breadcrumbs as $breadcrumb_url => $breadcrumb) { // Breadcrumb items. if (count($breadcrumbs) - 1 != $i) { beans_open_markup_e('beans_breadcrumb_item', 'li'); beans_open_markup_e('beans_breadcrumb_item_link', 'a', array('href' => $breadcrumb_url)); // Used for mobile devices. beans_open_markup_e('beans_breadcrumb_item_link_inner', 'span'); beans_output_e('beans_breadcrumb_item_text', $breadcrumb); beans_close_markup_e('beans_breadcrumb_item_link_inner', 'span'); beans_close_markup_e('beans_breadcrumb_item_link', 'a'); beans_close_markup_e('beans_breadcrumb_item', 'li'); } else { // Active. beans_open_markup_e('beans_breadcrumb_item[_active]', 'li', array('class' => 'uk-active uk-text-muted')); beans_output_e('beans_breadcrumb_item[_active]_text', $breadcrumb); beans_close_markup_e('beans_breadcrumb_item[_active]', 'li'); } $i++; } // Close breadcrumb. beans_close_markup_e('beans_breadcrumb', 'ul'); }
<?php /** * Despite its name, this template echos between the closing primary markup and the closing HTML markup. * * This template must be called using get_footer(). * * @package Structure\Footer */ beans_close_markup_e('beans_primary', 'div'); beans_close_markup_e('beans_main_grid', 'div'); beans_close_markup_e('beans_fixed_wrap[_main]', 'div'); beans_close_markup_e('beans_main', 'main'); beans_close_markup_e('beans_site', 'div'); wp_footer(); beans_close_markup_e('beans_body', 'body'); beans_close_markup_e('beans_html', 'html');
<?php /** * Echo the structural markup for the main content. It also calls the content action hooks. * * @package Structure\Content */ $content_attributes = array('class' => 'tm-content', 'role' => 'main', 'itemprop' => 'mainEntityOfPage'); // Blog specific attributes. if (is_home() || is_page_template('page_blog.php') || is_singular('post') || is_archive()) { $content_attributes['itemscope'] = 'itemscope'; // Automatically escaped. $content_attributes['itemtype'] = 'http://schema.org/Blog'; // Automatically escaped. } // Blog specific attributes. if (is_search()) { $content_attributes['itemscope'] = 'itemscope'; // Automatically escaped. $content_attributes['itemtype'] = 'http://schema.org/SearchResultsPage'; // Automatically escaped. } beans_open_markup_e('beans_content', 'div', $content_attributes); /** * Fires in the main content. * * @since 1.0.0 */ do_action('beans_content'); beans_close_markup_e('beans_content', 'div');