You appear to be a bot. Output may be restricted
Description
Output markup conditionally.
Supported keys for $args
are:
– html5
(`sprintf()` pattern markup), – context
(name of context), – echo
(default is true).
Applies a genesis_markup_{context}
filter early to allow shortcutting the function.
Applies a genesis_markup_{context}_output
filter at the end.
Usage
$string|null = genesis_markup( $args );
Parameters
- $args
- ( array ) optional – { Contains markup arguments.
- html5
- ( string ) optional – Legacy HTML5 markup.
- context
- ( string ) optional – Markup context.
- open
- ( string ) optional – Opening HTML markup.
- close
- ( string ) optional – Closing HTML markup.
- atts
- ( array ) optional – Initial attributes to apply to `open`, before filters.
- content
- ( string ) optional – Content to be placed between open and close HTML markup.
- echo
- ( bool ) optional – Flag indicating whether to echo or return the resultant string.
- params
- ( array ) optional – Additional information/data to pass to the various filters. }
Returns
string|null Markup.
Source
File name: genesis/lib/functions/markup.php
Lines:
1 to 100 of 149
function genesis_markup( $args = [] ) { $defaults = [ 'html5' => '', 'context' => '', 'open' => '', 'close' => '', 'atts' => [], 'content' => '', 'echo' => true, 'params' => [], ]; $args = wp_parse_args( $args, $defaults ); /** * Filter to short circuit the markup API. * * @since 1.9.0 * * @param bool false Flag indicating short circuit content. * @param array $args Array with markup arguments. * * @see genesis_markup $args Array. */ $pre = apply_filters( "genesis_markup_{$args['context']}", false, $args ); if ( false !== $pre ) { if ( ! $args['echo'] ) { return $pre; } // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- We print html on purpose to render the page echo $pre; return null; } if ( $args['html5'] ) { $tag = $args['context'] ? sprintf( $args['html5'], genesis_attr( $args['context'] ) ) : $args['html5']; /** * Legacy contextual filter to modify 'html5' output markup. * * @since 1.9.0 * * @param string $tag HTML tag being processed by the API. * @param array $args Array with markup arguments. * * @see genesis_markup $args Array. */ $tag = $args['context'] ? apply_filters( "genesis_markup_{$args['context']}_output", $tag, $args ) : $tag; if ( ! $args['echo'] ) { return $tag; } // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- We print html on purpose to render the page echo $tag; return null; } if ( $args['context'] ) { $open = $args['open'] ? sprintf( $args['open'], genesis_attr( $args['context'], $args['atts'], $args ) ) : ''; /** * Contextual filter to modify 'open' markup. * * @since 2.4.0 * * @param string $open HTML tag being processed by the API. * @param array $args Array with markup arguments. * * @see genesis_markup $args Array. */ $open = apply_filters( "genesis_markup_{$args['context']}_open", $open, $args ); /** * Contextual filter to modify 'close' markup. * * @since 2.4.0 * * @param string $close HTML tag being processed by the API. * @param array $args Array with markup arguments. * * @see genesis_markup $args Array. */ $close = apply_filters( "genesis_markup_{$args['context']}_close", $args['close'], $args ); /** * Contextual filter to modify 'content'. * * @since 2.6.0 * * @param string $content Content being passed through Markup API. * @param array $args Array with markup arguments. * * @see genesis_markup $args Array.