Skip to content

Produce HTML with PHP in simple templates #194

@szepeviktor

Description

@szepeviktor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions