function ppb_tour_grid_func($atts, $content) { //extract short code attr extract(shortcode_atts(array('size' => 'one', 'title' => '', 'items' => 4, 'tourcat' => '', 'order' => 'default', 'custom_css' => '', 'layout' => 'fullwidth'), $atts)); if (!is_numeric($items)) { $items = 4; } $return_html = '<div class="ppb_tour ' . $size . ' withpadding '; $columns_class = 'three_cols'; if ($layout == 'fullwidth') { $columns_class .= ' fullwidth'; } $element_class = 'one_third gallery3'; $tour_h = 'h5'; if (empty($content) && empty($title)) { $return_html .= 'nopadding '; } $return_html .= '" '; if (!empty($custom_css)) { $return_html .= 'style="' . urldecode($custom_css) . '" '; } $return_html .= '>'; $return_html .= '<div class="page_content_wrapper '; if ($layout == 'fullwidth') { $return_html .= 'full_width'; } $return_html .= '" style="text-align:center">'; //Display Title if (!empty($title)) { $return_html .= '<h2 class="ppb_title">' . $title . '</h2>'; } //Display Content if (!empty($content) && !empty($title)) { $return_html .= '<div class="page_caption_desc">' . $content . '</div>'; } //Display Horizontal Line if (empty($content) && !empty($title)) { $return_html .= '<br/>'; } $tour_order = 'ASC'; $tour_order_by = 'menu_order'; switch ($order) { case 'default': $tour_order = 'ASC'; $tour_order_by = 'menu_order'; break; case 'newest': $tour_order = 'DESC'; $tour_order_by = 'post_date'; break; case 'oldest': $tour_order = 'ASC'; $tour_order_by = 'post_date'; break; case 'title': $tour_order = 'ASC'; $tour_order_by = 'title'; break; case 'random': $tour_order = 'ASC'; $tour_order_by = 'rand'; break; } //Get tour items $args = array('numberposts' => $items, 'order' => $tour_order, 'orderby' => $tour_order_by, 'post_type' => array('tours'), 'suppress_filters' => 0); if (!empty($tourcat)) { $args['tourcats'] = $tourcat; } $tours_arr = get_posts($args); if (!empty($tours_arr) && is_array($tours_arr)) { $return_html .= '<div class="portfolio_filter_wrapper ' . $columns_class . ' shortcode gallery section content clearfix">'; foreach ($tours_arr as $key => $tour) { $image_url = ''; $tour_ID = $tour->ID; if (has_post_thumbnail($tour_ID, 'large')) { $image_id = get_post_thumbnail_id($tour_ID); $image_url = wp_get_attachment_image_src($image_id, 'full', true); $small_image_url = wp_get_attachment_image_src($image_id, 'gallery_grid', true); } //Get Tour Meta $tour_permalink_url = get_permalink($tour_ID); $tour_title = $tour->post_title; $tour_country = get_post_meta($tour_ID, 'tour_country', true); $tour_price = get_post_meta($tour_ID, 'tour_price', true); $tour_price_discount = get_post_meta($tour_ID, 'tour_price_discount', true); $tour_price_currency = get_post_meta($tour_ID, 'tour_price_currency', true); $tour_discount_percentage = 0; $tour_price_display = ''; if (!empty($tour_price)) { if (!empty($tour_price_discount)) { if ($tour_price_discount < $tour_price) { $tour_discount_percentage = intval(($tour_price - $tour_price_discount) / $tour_price * 100); } } if (empty($tour_price_discount)) { $tour_price_display = $tour_price_currency . pp_number_format($tour_price); } else { $tour_price_display = $tour_price_currency . pp_number_format($tour_price_discount); } } //Get number of your days $tour_days = 0; $tour_start_date = get_post_meta($tour_ID, 'tour_start_date', true); $tour_end_date = get_post_meta($tour_ID, 'tour_end_date', true); if (!empty($tour_start_date) && !empty($tour_end_date)) { $tour_start_date_raw = get_post_meta($tour_ID, 'tour_start_date_raw', true); $tour_end_date_raw = get_post_meta($tour_ID, 'tour_end_date_raw', true); $tour_days = pp_date_diff($tour_start_date_raw, $tour_end_date_raw); if ($tour_days > 0) { $tour_days = intval($tour_days + 1) . ' ' . __('Days', THEMEDOMAIN); } else { $tour_days = intval($tour_days + 1) . ' ' . __('Day', THEMEDOMAIN); } } $tour_permalink_url = get_permalink($tour_ID); //Begin display HTML $return_html .= '<div class="element portfolio3filter_wrapper">'; $return_html .= '<div class="' . $element_class . ' filterable gallery_type animated' . ($key + 1) . '">'; if (!empty($image_url[0])) { $return_html .= '<a href="' . $tour_permalink_url . '"> <img src="' . $small_image_url[0] . '" alt="" /> </a>'; } if (!empty($tour_discount_percentage)) { $return_html .= '<div class="tour_sale '; if ($layout == 'fullwidth') { $return_html .= 'fullwidth'; } $return_html .= '"><div class="tour_sale_text">' . __('Best Deal', THEMEDOMAIN) . '</div> ' . $tour_discount_percentage . '% ' . __('Off', THEMEDOMAIN) . ' </div>'; } $return_html .= '<div class="thumb_content '; if ($layout == 'fullwidth') { $return_html .= 'fullwidth'; } $return_html .= ' "><div class="thumb_title">'; if (!empty($tour_country)) { $return_html .= '<div class="tour_country"> ' . $tour_country . ' </div>'; } $return_html .= '<h3>' . $tour_title . '</h3> </div> <div class="thumb_meta">'; if (!empty($tour_days)) { $return_html .= '<div class="tour_days"> ' . $tour_days . ' </div>'; } if (!empty($tour_price_display)) { $return_html .= '<div class="tour_price"> ' . $tour_price_display . ' </div>'; } $return_html .= '</div>'; $return_html .= '</div>'; $return_html .= '</div>'; $return_html .= '</div>'; } $return_html .= '</div>'; } $return_html .= '</div></div>'; return $return_html; }
$tour_start_date_raw = get_post_meta($tour_ID, 'tour_start_date_raw', true); $tour_end_date_raw = get_post_meta($tour_ID, 'tour_end_date_raw', true); $tour_days = pp_date_diff($tour_start_date_raw, $tour_end_date_raw); if ($tour_days > 0) { $tour_days = intval($tour_days + 1) . ' ' . __('Days', THEMEDOMAIN); } else { $tour_days = intval($tour_days + 1) . ' ' . __('Day', THEMEDOMAIN); } } $tour_price_display = 0; if (empty($tour_price_discount)) { if (!empty($tour_price)) { $tour_price_display = $tour_price_currency . pp_number_format($tour_price); } } else { $tour_price_display = $tour_price_currency . pp_number_format($tour_price_discount); } $last_class = ''; if ($key % 3 == 0) { $last_class = 'last'; } ?> <div class="element portfolio3filter_wrapper"> <div class="one_third gallery3 filterable gallery_type animated<?php echo $key + 1; ?> " data-id="post-<?php echo $key + 1; ?>
$tour_start_date_raw = get_post_meta($current_page_id, 'tour_start_date_raw', true); $tour_end_date_raw = get_post_meta($current_page_id, 'tour_end_date_raw', true); $tour_days = pp_date_diff($tour_start_date_raw, $tour_end_date_raw); if ($tour_days > 0) { $tour_days = intval($tour_days + 1) . ' ' . __('Days', THEMEDOMAIN); } else { $tour_days = intval($tour_days + 1) . ' ' . __('Day', THEMEDOMAIN); } $tour_price_display = 0; if (empty($tour_price_discount)) { if (!empty($tour_price)) { $tour_price_display = $tour_price_currency . pp_number_format($tour_price); } } else { $tour_price_display = '<span class="tour_normal_price">' . $tour_price_currency . pp_number_format($tour_price) . '</span>'; $tour_price_display .= '<span class="tour_discount_price">' . $tour_price_currency . pp_number_format($tour_price_discount) . '</span>'; } //Check if display tour attribute $pp_tour_attribute = get_option('pp_tour_attribute'); if (empty($pp_tour_attribute)) { //Set tour attribute block class $tour_block_class = 'one_fifth'; $tour_block_count = 5; if (empty($tour_start_date) or empty($tour_end_date)) { $tour_block_count--; $tour_block_count--; } if (empty($tour_price_display)) { $tour_block_count--; } switch ($tour_block_count) {