• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Genesis Theme Framework a2z

Genesis Theme Framework a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / genesis_layout_selector() – Output the form elements necessary to select a layout.

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;

}
 

Published: 25th November 2019 | Last updated: 25th November 2019

Primary Sidebar

Information

Function name: genesis_layout_selector
Plugin ref: Genesis Framework
Version: 3.3.5
Sourcefile: lib/functions/layout.php
File ref: lib/functions/layout.php
Deprecated?: No
API Letters: G,L,S

Footer

Genesis a2z
Genesis Theme Framework a2z
WordPress Dynamic API Reference
WordPress 5.9.3
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  genesis.wp-a2z.org
© Copyright Genesis a2z 2014-2022. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites