Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function twt_render_menu_block($attr, $is_preview = false, $post_id = null) {
- if ( empty( $attr['data'] ) ) {
- //return;
- }
- if($is_preview) {
- echo '<p>To edit, click on pencil icon.</p>';
- return;
- }
- // Unique HTML ID if available.
- $id = 'twt-menu-block-' . ( $attr['id'] ?? '' );
- if ( ! empty( $attr['anchor'] ) ) {
- $id = $attr['anchor'];
- }
- // Custom CSS class name.
- $class = 'twt-menu-block ' . ( $attr['className'] ?? '' ) . (isset($attr['data']['attr']) && in_array('half-width-section', $attr['data']['attr']) ? ' half-width-section' : '');
- ?>
- <section id="<?php echo esc_attr($id); ?>"<?php echo empty($class) ? '' : 'class="'.esc_attr($class).'"'; ?>>
- <?php if(!empty($attr['data']['featured_photo'])) {
- $image = wp_get_attachment_image($attr['data']['featured_photo'], 'full');
- if(!empty($image)) {
- ?><figure class="featured-menu-photo"><?= $image; ?></figure><?php
- }
- ?>
- <?php } ?>
- <?php
- }
- if(!empty($attr['data']['menu_items'])) {
- ?>
- <ul class="block-menu-items">
- <?php
- foreach($attr['data']['menu_items'] as $menu_item) {
- $classes = array();
- $attr = (array) $menu_item['attr'];
- if(count($attr)) {
- if ( in_array( 'half-width', $menu_item['attr'] ) ) {
- $classes[] = 'half-width';
- }
- if ( in_array( 'highlight', $menu_item['attr'] ) ) {
- $classes[] = 'highlight has-blue-background-color';
- }
- if ( in_array( 'no-br', $menu_item['attr'] ) ) {
- $classes[] = 'no-br';
- }
- }
- ?>
- <li<?= empty($classes) ? '' : ' class="'.implode(' ', $classes).'"'; ?>>
- <?php if(!empty($menu_item['name']) || in_array('gf', $attr)) { ?><h3><?= in_array('gf', $attr) ? '<i class="icon-gluten-free" aria-hidden="true"></i><span class="screen-reader-text">Gluten Free</span>' : ''; ?><?= $menu_item['name']; ?></h3><?php }
- echo $menu_item['desc']; ?>
- </li><?php
- }
- ?>
- </ul>
- </div>
- <?php
- }
- if(!empty($attr['data']['content_after'])) {
- ?><?php
- }
- ?>
- </section>
- <?php
- }
Advertisement
Add Comment
Please, Sign In to add comment