protected function generate_html($template_type = '')
 {
     $post_ids = array();
     foreach ($this->search_results['items'] as $item_id => $item_html) {
         $post_ids[] = $item_id;
     }
     $conditions = array();
     $conditions[] = "ad_id IN ( " . implode(',', $post_ids) . " ) ";
     $args = array();
     $ads = AWPCP_Ad::get_enabled_ads($args, $conditions);
     $parity = array('displayaditemseven', 'displayaditemsodd');
     if ('ajax' == $template_type) {
         $layout = buddyboss_global_search_buffer_template_part('loop/' . $this->type, $template_type, false);
     } else {
         $layout = get_awpcp_option('displayadlayoutcode');
         if (empty($layout)) {
             $layout = awpcp()->settings->get_option_default_value('displayadlayoutcode');
         }
     }
     if (!empty($ads)) {
         foreach ($ads as $i => $listing) {
             $rendered_listing = awpcp_do_placeholders($listing, $layout, $context);
             $rendered_listing = str_replace("\$awpcpdisplayaditems", $parity[$i % 2], $rendered_listing);
             if (function_exists('awpcp_featured_ads')) {
                 $rendered_listing = awpcp_featured_ad_class($listing->ad_id, $rendered_listing);
             }
             $rendered_listing = apply_filters('awpcp-render-listing-item', $rendered_listing, $i + 1, $template_type);
             $result = array('id' => $listing->ad_id, 'type' => $this->type, 'title' => $listing->ad_title, 'html' => $rendered_listing);
             $this->search_results['items'][$listing->ad_id] = $result;
         }
     }
 }
Ejemplo n.º 2
0
/**
 * Renders each listing using the layout configured in the plugin
 * settings.
 *
 * @since 3.3.2
 *
 * @param Array $listings An array of AWPCP_Ad objects.
 * @param string $context The context where the listings will be shown: listings, ?.
 * @return Array An array of rendered items.
 */
function awpcp_render_listings_items($listings, $context)
{
    $parity = array('displayaditemseven', 'displayaditemsodd');
    $layout = get_awpcp_option('displayadlayoutcode');
    if (empty($layout)) {
        $layout = awpcp()->settings->get_option_default_value('displayadlayoutcode');
    }
    $items = array();
    foreach ($listings as $i => $listing) {
        $rendered_listing = awpcp_do_placeholders($listing, $layout, $context);
        $rendered_listing = str_replace("\$awpcpdisplayaditems", $parity[$i % 2], $rendered_listing);
        if (function_exists('awpcp_featured_ads')) {
            $rendered_listing = awpcp_featured_ad_class($listing->ad_id, $rendered_listing);
        }
        $items[] = apply_filters('awpcp-render-listing-item', $rendered_listing, $i + 1);
    }
    return $items;
}