Advertisement
Guest User

Hotel Xenia: draft room amenities shortcode

a guest
Nov 15th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.65 KB | None | 0 0
  1. function plethora_shortcode_room_amenities( $args, $content = '' ) {
  2.  
  3.     // Default shortcode arguments
  4.     $args = wp_parse_args( $args, array(
  5.         'post_id' => is_singular( 'room' ) ? get_the_ID() : false,
  6.         'limit'   => 5
  7.     ));
  8.  
  9.     if ( $args['post_id'] ) {
  10.  
  11.         $room_obj = Plethora_Theme::get_feature_instance( 'posttype', 'room' );
  12.         $amenities = method_exists( $room_obj, 'get_room_amenities' ) ? $room_obj::get_room_amenities( $args['post_id'], $args['limit'] ) : false;
  13.         if ( $amenities ) {
  14.         ?>
  15.         <div class="room_single_amenities">
  16.          <?php foreach ( $amenities as $amenity ) { ?>
  17.             <div class="text-center item">
  18.                 <div class="row">
  19.                 <?php switch ( $amenity['icon_type'] ) {
  20.                     case 'library_icon': // markup for font icons
  21.                     default:
  22.                         ?>
  23.                         <i data-toggle="tooltip" data-placement="top" class="<?php echo esc_attr( $amenity['icon_class'] ); ?>" data-original-title="<?php echo esc_attr( $amenity['desc'] ); ?>"></i>
  24.                         <span><?php echo wp_kses( $amenity['title'], Plethora_Theme::allowed_html_for( 'heading' ) ); ?></span>
  25.                         <?php
  26.                         break;
  27.  
  28.                     case 'custom_icon': // markup for image icons
  29.                         ?>
  30.                         <img src="<?php echo esc_url( $amenity['icon_url'] ); ?>" data-toggle="tooltip" data-placement="top" class="<?php echo esc_attr( $amenity['icon_class'] ); ?>" data-original-title="<?php echo esc_attr( $amenity['desc'] ); ?>"/>
  31.                         <span><?php echo wp_kses( $amenity['title'], Plethora_Theme::allowed_html_for( 'heading' ) ); ?></span>
  32.                         <?php
  33.                     break;
  34.                 } ?>
  35.                 </div>
  36.             </div>
  37.         <?php }
  38.         }
  39.         ?>
  40.         </div>
  41.         <?php
  42.     }
  43. }
  44.  
  45. add_shortcode( 'ple_amenities', 'plethora_shortcode_room_amenities' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement