Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Limit excerpt to a number of characters
- *
- * @param string $excerpt
- * @return string
- */
- function custom_short_excerpt($excerpt){
- return substr($excerpt, 0, 200);
- }
- add_filter('the_excerpt', 'custom_short_excerpt');
- /* Funtion Count Posts in Category */
- function number_postpercat($idcat) {
- global $wpdb;
- $query = "SELECT count FROM $wpdb->term_taxonomy WHERE term_id = $idcat";
- $num = $wpdb->get_col($query);
- echo $num[0];
- }
- /**
- * Change the default settings of a map
- *
- * @since "Progress Map v3"
- */
- function cspm_update_map_settings($map_settings, $map_id){
- if (!class_exists('CspmMainMap'))
- return;
- $CspmMainMap = CspmMainMap::this();
- $fields_prefix = $CspmMainMap->metafield_prefix;
- if(is_tax() || is_category() || is_tag() || is_archive()){
- $queried_object = get_queried_object();
- $taxonomy = (isset($queried_object->taxonomy)) ? $queried_object->taxonomy : ''; // The taxonomy slug/name
- $term_id = (isset($queried_object->term_id)) ? $queried_object->term_id : ''; // The term ID
- $map_settings[$fields_prefix.'_taxonomie_'.$taxonomy] = serialize(array($term_id));
- }
- return $map_settings;
- }
- add_filter('cspm_map_settings', 'cspm_update_map_settings', 10, 2);
- /**
- * List & Filter!
- * This will change the content of the items displayed for the list
- *
- * @default_content | The default content when there's no custom content to display.
- * @post_id | The ID of the post.
- * @view | List view. Possible value are "list" & "grid".
- * @filter | Whether the search filter is used or not. Possible values are "yes" and "no".
- * @map_id | The ID of the map
- * @latLng | The coordinates (Latitude & Longitude) of the post on the map. Laitude and Longitude separated by underscore, for example, (15.6540_50.54802)
- *
- */
- function cspml_change_list_items_content($default_content, $post_id, $view, $filter, $map_id, $latLng){
- global $post;
- $output = '';
- $post_record = get_post( $post_id, ARRAY_A, 'display' );
- $output .= trim(preg_replace('/\s+/', ' ', $post_record['post_excerpt']));
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
- // Check for plugin using plugin name
- if ( is_plugin_active( 'reviewer/reviewer.php' ) ):
- //plugin is activated
- $output = do_shortcode('[rwp_users_rating_stars id="-1" template="rwp_template_5aa830c899604"]');
- endif;
- $price = get_field('ticket_price');
- $time = get_field('time_duration_tour');
- $from_tour = get_field('from_tour');
- $link = get_post_permalink();
- //$text_from = esc_html( 'From', 'veditalia' );
- $text_button = esc_html( 'Book now', 'veditalia' );
- $simbol = esc_html( '€', 'veditalia' );
- $output .= '<p class="hour-tour">';
- if ( $time != '' ): ?>
- <?php $output .= '<p class="time_duration_tour">'.$time.'</p>' ?>
- <?php
- endif;
- if ( $from_tour != '' ): ?>
- <?php $output .= '<p class="from_tour">' . ' ' . $from_tour . '</p>' ?>
- <?php
- endif;
- $output .= '</p>';
- if ( $price != '' ): ?>
- <?php $output .= '<p class="price-tour-p"><span class="price-tour">' . $simbol . $price . '</span>' ?>
- <?php
- endif; ?>
- <?php $output .= '<span class="btn-book"><a class="btn btn-primary pull-right btn-sm book-now" itemprop="url" href="'. $link . '">'.$text_button.'</a></span></p>' ?>
- <?php
- wp_reset_postdata();
- return !empty($output) ? $output : $default_content;
- }
- add_filter('cspml_list_item_description', 'cspml_change_list_items_content', 10, 6);
- add_filter('cspml_grid_item_description', 'cspml_change_list_items_content', 10, 6);
- /**
- * List & Filter!
- * This will change the content of the items displayed for the list
- *
- * @default_content | The default content when there's no custom content to display.
- * @post_id | The ID of the post.
- * @view | List view. Possible value are "list" & "grid".
- * @filter | Whether the search filter is used or not. Possible values are "yes" and "no".
- * @map_id | The ID of the map
- * @latLng | The coordinates (Latitude & Longitude) of the post on the map. Laitude and Longitude separated by underscore, for example, (15.6540_50.54802)
- *
- *
- *
- */
- //add_action( 'admin_footer', 'cspml_change_image' ); // Write our JS below here
- function cspml_change_image($default_content, $post_id, $view, $filter, $map_id, $latLng){
- if (!class_exists('CspmMainMap'))
- return;
- $CspmMainMap = CspmMainMap::this();
- $fields_prefix = $CspmMainMap->metafield_prefix;
- global $post;
- $output = '';
- $marker_img_array = apply_filters('cspml_post_thumb', wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'cspml-listings-thumbnail' ), $post_id);
- /*
- * Item's Label's */
- if( have_rows('tag_tour') !='' ): ?>
- <?php while( have_rows('tag_tour') ): the_row();
- $tag_type = get_sub_field('tag_type');
- $tag_discount_value = get_sub_field('tag_discount_value'); ?>
- <?php if( get_sub_field('tag_type') == 'Top Attraction' ): ?>
- <?php $output .= '<div class="tag tag-top-attraction">' ?>
- <?php $output .= '<span class="discounts"></span> '.$tag_type.'</span>' ?>
- <?php $output .= '</div>'?>
- <?php elseif( get_sub_field('tag_type') == 'Special Offer' ): ?>
- <?php $output .= '<div class="tag tag-special-offer">' ?>
- <?php $output .= '<span class="discounts"></span> '.$tag_type.'</span>' ?>
- <?php $output .= '</div>'?>
- <?php elseif( get_sub_field('tag_type') == 'Likely to sell out' ): ?>
- <?php $output .= '<div class="tag tag-likely-to-sell-out">' ?>
- <?php $output .= '<span class="discounts"></span> '.$tag_type.'</span>' ?>
- <?php $output .= '</div>'?>
- <?php elseif( get_sub_field('tag_type') == 'New Experience' ): ?>
- <?php $output .= '<div class="tag tag-new-experience">' ?>
- <?php $output .= '<span class="discounts"></span> '.$tag_type.'</span>' ?>
- <?php $output .= '</div>'?>
- <?php elseif( get_sub_field('tag_type') == 'Best Seller' ): ?>
- <?php $output .= '<div class="tag tag-best-seller">' ?>
- <?php $output .= '<span class="discounts"></span> '.$tag_type.'</span>' ?>
- <?php $output .= '</div>' ?>
- <?php elseif( get_sub_field('tag_type') == 'Default' ): ?>
- <?php $output .= '<div class="tag-discounts"></div>' ?>
- <?php elseif( get_sub_field('tag_type') == 'Discount' ): ?>
- <?php if($tag_discount_value !=''):
- $off_simbol = esc_html( '% ', 'veditalia' );
- $off_text = esc_html( 'OFF ', 'veditalia' ); ?>
- <?php $output .= '<div class="tag tag-discont">' ?>
- <?php $output .= '<span class="discounts"></span> '.$tag_discount_value.'</span><span class="after-discounts-1">'.$off_simbol.'</span><span class="after-discounts-2">'.$off_text.'</span>' ?>
- <?php $output .= '</div>' ?>
- <?php endif;
- endif;
- endwhile;
- endif;
- /**
- * Item's Gallery */
- $images = get_field( 'gallery_tour' );
- if( $images !='' ):
- $output .= '<div id="slider" class="flex-tour" itemscope >';
- $custom_js2 = "$(document).ready(function($) { $('.flex-tour').addClass('flexslider flexslider-tour'); });";
- $custom_js = "$(document).ready(function($) { $('.flexslider.flexslider-tour').flexslider({ animation: 'slide', controlNav: false, animationLoop: false, slideshow: false, }); });";
- wp_add_inline_script('custom', $custom_js2);
- wp_add_inline_script('custom', $custom_js);
- $output .= '<ul class="slides">' ?>
- <?php foreach( $images as $image ):
- $carousel = $image['sizes']['tour-home'];
- $alt = $image['alt'];
- $output .= '<li><figure><img src="'.$carousel.'" alt="'.$alt.'" class="thumb img-responsive" /></figure></li>'; ?>
- <?php endforeach; ?>
- <?php $output .= '</ul></div>' ?>
- <?php endif;
- wp_reset_postdata();
- return !empty($output) ? $output : $default_content;
- }
- add_filter('cspml_before_listing_thumb', 'cspml_change_image', 10, 6);
Advertisement
Add Comment
Please, Sign In to add comment