You appear to be a bot. Output may be restricted
Description
Output the form elements necessary to select a layout.
You must manually wrap this in an HTML element with the class of genesis-layout-selector
in order for the CSS and JavaScript to apply properly.
Supported $args
keys are: – name (default is ''), – selected (default is ''), – echo (default is true).
The Genesis admin script is enqueued to ensure the layout selector behaviour (amending label class to add border on selected layout) works.
Usage
$null|string = genesis_layout_selector( $args );
Parameters
- $args
- ( array ) optional – Optional. Function arguments. Default is empty array.
Returns
null|string HTML markup of labels, images and radio inputs for layout selector.
Source
File name: genesis/lib/functions/layout.php
Lines:
1 to 43 of 43
function genesis_layout_selector( $args = [] ) { // Enqueue the JavaScript. genesis_scripts()->enqueue_and_localize_admin_scripts(); // Merge defaults with user args. $args = wp_parse_args( $args, [ 'name' => '', 'selected' => '', 'type' => 'type', 'echo' => true, ] ); $output = ''; foreach ( genesis_get_layouts( $args['type'] ) as $id => $data ) { $class = $id === $args['selected'] ? ' selected' : ''; $output .= sprintf( '<label class="box%2$s" for="%5$s"><span class="screen-reader-text">%1$s </span><img src="%3$s" alt="%1$s" /><input type="radio" name="%4$s" id="%5$s" value="%5$s" %6$s class="screen-reader-text" /></label>', esc_attr( $data['label'] ), esc_attr( $class ), esc_url( $data['img'] ), esc_attr( $args['name'] ), esc_attr( $id ), checked( $id, $args['selected'], false ) ); } // Echo or return output. if ( $args['echo'] ) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $output; return null; } return $output; }