public function ajax_wpl_gallery() { $default_limit = get_option('wplister_gallery_items_limit', 12); $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'new'; $limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : $default_limit; $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : false; $format = isset($_REQUEST['format']) ? $_REQUEST['format'] : 'html'; $items = WPLE_ListingQueryHelper::getItemsForGallery($type, $id, $limit); // echo "<pre>";print_r($items);echo"</pre>";die(); if ($format == 'json') { $json_data = array(); foreach ($items as $item) { $json_item = new stdClass(); $json_item->ebay_id = $item['ebay_id']; $json_item->post_id = $item['post_id']; $json_item->listing_id = $item['id']; $json_item->title = $item['auction_title']; $json_item->type = $item['auction_type']; $json_item->price = $item['price']; $json_item->quantity = $item['quantity']; $json_item->quantity_sold = $item['quantity_sold']; $json_item->main_image_url = $item['GalleryURL']; $json_item->ebay_url = $item['ViewItemURL']; $json_item->site_id = $item['site_id']; $json_item->status = $item['status']; $json_data[] = $json_item; } // check if callback parameter is set (JSONP support) if (isset($_REQUEST['callback'])) { header('content-type: application/javascript; charset=utf-8'); echo $_REQUEST['callback'] . '(' . json_encode($json_data) . ')'; // JSONP } else { header('content-type: application/json; charset=utf-8'); echo json_encode($json_data); // plain JSON } exit; } // get from_item and template path $view = WPLISTER_PATH . '/views/template/gallery.php'; $from_item = $id ? ListingsModel::getItem($id) : false; if ($from_item) { // if gallery.php exists in listing template, use it $gallery_tpl_file = WPLISTER_PATH . '/../../' . $from_item['template'] . '/gallery.php'; if (file_exists($gallery_tpl_file)) { $view = $gallery_tpl_file; } // the above might fail if wp-content has been moved - better use wp_upload_dir() to get actual template path: $upload_dir = wp_upload_dir(); $gallery_tpl_file = $upload_dir['basedir'] . '/wp-lister/templates/' . basename($from_item['template']) . '/gallery.php'; if (file_exists($gallery_tpl_file)) { $view = $gallery_tpl_file; } } // load gallery template if (file_exists($view)) { header('X-Frame-Options: GOFORIT'); include $view; } else { echo "file not found: " . $view; } exit; }