function _wpbdp_render_excerpt()
{
    global $post;
    static $counter = 0;
    $sticky_status = wpbdp_listings_api()->get_sticky_status($post->ID);
    $html = '';
    $html .= sprintf('<div id="wpbdp-listing-%d" class="wpbdp-listing excerpt wpbdp-listing-excerpt %s %s %s cf">', $post->ID, $sticky_status, $counter & 1 ? 'odd' : 'even', apply_filters('wpbdp_excerpt_view_css', '', $post->ID));
    $html .= wpbdp_capture_action('wpbdp_before_excerpt_view', $post->ID);
    $d = WPBDP_ListingFieldDisplayItem::prepare_set($post->ID, 'excerpt');
    $listing_fields = implode('', WPBDP_ListingFieldDisplayItem::walk_set('html', $d->fields));
    $social_fields = implode('', WPBDP_ListingFieldDisplayItem::walk_set('html', $d->social));
    $vars = array('is_sticky' => $sticky_status == 'sticky', 'thumbnail' => wpbdp_get_option('allow-images') && wpbdp_get_option('show-thumbnail') ? wpbdp_listing_thumbnail(null, 'link=listing&class=wpbdmthumbs wpbdp-excerpt-thumbnail') : '', 'title' => get_the_title(), 'listing_fields' => apply_filters('wpbdp_excerpt_listing_fields', $listing_fields, $post->ID), 'fields' => $d->fields, 'listing_id' => $post->ID);
    $vars = apply_filters('wpbdp_listing_template_vars', $vars, $post->ID);
    $vars = apply_filters('wpbdp_excerpt_template_vars', $vars, $post->ID);
    $html .= wpbdp_render('businessdirectory-excerpt', $vars, true);
    $social_fields = apply_filters('wpbdp_excerpt_social_fields', $social_fields, $post->ID);
    if ($social_fields) {
        $html .= '<div class="social-fields cf">' . $social_fields . '</div>';
    }
    $html .= wpbdp_capture_action('wpbdp_after_excerpt_view', $post->ID);
    $html .= wpbdp_render('parts/listing-buttons', array('listing_id' => $post->ID, 'view' => 'excerpt'), false);
    $html .= '</div>';
    $counter++;
    return $html;
}
Exemple #2
0
 public function view_listings($include_buttons = false, $args_ = array())
 {
     $paged = 1;
     if (get_query_var('page')) {
         $paged = get_query_var('page');
     } elseif (get_query_var('paged')) {
         $paged = get_query_var('paged');
     }
     $args = array('post_type' => WPBDP_POST_TYPE, 'posts_per_page' => wpbdp_get_option('listings-per-page') > 0 ? wpbdp_get_option('listings-per-page') : -1, 'post_status' => 'publish', 'paged' => intval($paged), 'orderby' => wpbdp_get_option('listings-order-by', 'date'), 'order' => wpbdp_get_option('listings-sort', 'ASC'));
     if (isset($args_['numberposts'])) {
         $args['numberposts'] = $args_['numberposts'];
     }
     // See if we need to call query_posts() directly in case the user is using the template without
     // the $query argument.
     $template = file_get_contents(wpbdp_locate_template('businessdirectory-listings'));
     $compat = false === stripos($template, '$query->the_post') ? true : false;
     if ($compat) {
         query_posts($args);
         $q = $GLOBALS['wp_query'];
     } else {
         $q = new WP_Query($args);
     }
     wpbdp_push_query($q);
     $html = wpbdp_capture_action('wpbdp_before_viewlistings_page');
     $html .= wpbdp_render('businessdirectory-listings', array('query' => $q, 'excludebuttons' => !$include_buttons), true);
     $html .= wpbdp_capture_action('wpbdp_after_viewlistings_page');
     if (!$compat) {
         wp_reset_postdata();
     }
     wp_reset_query();
     wpbdp_pop_query($q);
     return $html;
 }