Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Produce HTML with PHP in simple templates #194

Open
szepeviktor opened this issue Jun 7, 2020 · 0 comments
Open

Produce HTML with PHP in simple templates #194

szepeviktor opened this issue Jun 7, 2020 · 0 comments

Comments

@szepeviktor
Copy link
Contributor

szepeviktor commented Jun 7, 2020

You may omit HTML code in templates by using tag()

<?php
/**
 * Template part for the breadcrumbs.
 *
 * @package Gridd
 * @since 1.0
 */

use Gridd\Theme;
use Hybrid\Breadcrumbs\Trail;

use function Toolkit4WP\tag;

// Early exit if we're on the frontpage.
if ( is_front_page() || is_home() ) {
    return;
}

$grid_part_class = 'gridd-tp gridd-tp-breadcrumbs';
if ( get_theme_mod( 'breadcrumbs_custom_options', false ) ) {
    $grid_part_class .= ' custom-options';
}

print tag(
    'div',
    Theme::get_attributes( ['class' => $grid_part_class], 'wrapper-breadcrumbs' ),
    tag(
        'div',
        ['class' => 'inner'],
        // The breadcrumbs.
        Trail::display(
            apply_filters(
                'gridd_breadcrumbs_args',
                [
                    'show_on_front' => false,
                    'labels'        => ['title' => false],
                ]
            )
        )
    )
);

https://github.com/szepeviktor/Toolkit4WP/blob/80719dfcc485aa118188e3e0054ffc86ee81498e/src/helpers.php#L17-L28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant