Пример #1
0
        $act_trm = wp_get_post_terms($wdm_single_auction->ID, 'auction-status', array("fields" => "names"));
        $query = "SELECT MAX(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $wdm_single_auction->ID;
        $curr_price = $wpdb->get_var($query);
        ?>
			<li class="wdm-auction-single-item">
				<a href="<?php 
        echo get_permalink($wdm_single_auction->ID);
        ?>
" class="wdm-auction-list-link">
				<ul class="wdm_all_li_content_auc">
			<li class="wdm-apn auc_single_list">
				<div  class="wdm_single_auction_thumb">
				<?php 
        $vid_arr = array('mpg', 'mpeg', 'avi', 'mov', 'wmv', 'wma', 'mp4', '3gp', 'ogm', 'mkv', 'flv');
        $auc_thumb = get_post_meta($wdm_single_auction->ID, 'wdm_auction_thumb', true);
        $imgMime = wdm_get_mime_type($auc_thumb);
        $img_ext = explode(".", $auc_thumb);
        $img_ext = end($img_ext);
        if (strpos($img_ext, '?') !== false) {
            $img_ext = strtolower(strstr($img_ext, '?', true));
        }
        if (strstr($imgMime, "video/") || in_array($img_ext, $vid_arr) || strstr($auc_thumb, "youtube.com") || strstr($auc_thumb, "vimeo.com")) {
            $auc_thumb = plugins_url('img/film.png', __FILE__);
        }
        if (empty($auc_thumb)) {
            $auc_thumb = plugins_url('img/no-pic.jpg', __FILE__);
        }
        ?>
				<img src="<?php 
        echo $auc_thumb;
        ?>
         } else {
             $images .= '<img class="auction-main-img"  src="' . wp_mime_type_icon($imgMime) . '" />';
         }
         $images .= '</a></div>';
     }
 }
 $images .= '</div>';
 if ($flg == 0) {
     echo '<style> .wdm-image-container{display: none;} </style>';
 }
 $images .= '<div id="bx-pager">';
 $f = 0;
 $r = 1;
 for ($c = 1; $c <= 4 + $ec; $c++) {
     $imgURL = get_post_meta($wdm_auction->ID, 'wdm-image-' . $c, true);
     $imgMime = wdm_get_mime_type($imgURL);
     $img_ext = explode(".", $imgURL);
     $img_ext = end($img_ext);
     if (strpos($img_ext, '?') !== false) {
         $img_ext = strtolower(strstr($img_ext, '?', true));
     }
     if (empty($imgURL)) {
         $images .= '';
         $f = 1;
     } else {
         if ($f == 1) {
             $r = $r + 1;
         }
         $images .= '<a data-slide-index="' . ($c - $r) . '" href="">';
         if (strstr($imgMime, "image/") || in_array($img_ext, $img_arr)) {
             $images .= '<img class="auction-small-img auction-small-img' . $c . '" src="' . $imgURL . '"  />';
function wdm_auction_listing()
{
    //enqueue css file for front end style
    wp_enqueue_style('wdm_auction_front_end_styling', plugins_url('css/ua-front-end.css', __FILE__));
    ob_start();
    //check the permalink from database and append variable to the auction single pages accordingly
    $perma_type = get_option('permalink_structure');
    //get currency code
    $currency_code = substr(get_option('wdm_currency'), -3);
    $currency_code_display = '';
    preg_match('/-([^ ]+)/', get_option('wdm_currency'), $matches);
    $currency_symbol = $matches[1];
    if (empty($currency_symbol)) {
        $currency_symbol = $currency_code . ' ';
    } else {
        if ($currency_symbol == '$' || $currency_symbol == 'kr') {
            $currency_code_display = $currency_code;
        }
    }
    //get Login url if set
    $wdm_login_url = get_option('wdm_login_page_url');
    if (empty($wdm_login_url)) {
        $wdm_login_url = wp_login_url($_SERVER['REQUEST_URI']);
    }
    if (is_front_page() || is_home()) {
        $set_char = "?";
    } elseif (empty($perma_type)) {
        $set_char = "&";
    } else {
        $set_char = "?";
    }
    $auc_time = '';
    if (is_user_logged_in() && isset($_GET["ult_auc_id"]) && !empty($_GET["ult_auc_id"]) && isset($_GET["mt"]) && !empty($_GET["mt"])) {
        $wdm_auction = get_post($_GET["ult_auc_id"]);
        $curr_user = wp_get_current_user();
        $buyer_email = $curr_user->user_email;
        //$winner_name = $curr_user->user_login;
        $ret_url = get_permalink() . $set_char . "ult_auc_id=" . $wdm_auction->ID;
        $check_method = get_post_meta($_GET["ult_auc_id"], 'wdm_payment_method', true);
        _e('Thank you for buying this product.', 'wdm-ultimate-auction');
        echo "<br /><br />";
        //$auc_post = get_post($_GET["ult_auc_id"]);
        //$auction_author_id = $auc_post->post_author;
        //$auction_author = new WP_User($auction_author_id);
        if ($check_method === 'method_wire_transfer') {
            $mthd = __('Wire Transfer', 'wdm-ultimate-auction');
            //if(in_array('administrator', $auction_author->roles))
            $det = get_option('wdm_wire_transfer');
            //else
            //	$det = get_user_meta($auction_author_id, 'wdm_wire_transfer', true);
        } elseif ($check_method === 'method_mailing') {
            $mthd = __('Cheque', 'wdm-ultimate-auction');
            //if(in_array('administrator', $auction_author->roles))
            $det = get_option('wdm_mailing_address');
            //else
            //	$det = get_user_meta($auction_author_id, 'wdm_mailing_address', true);
        } elseif ($check_method === 'method_cash') {
            $mthd = __('Cash', 'wdm-ultimate-auction');
            //if(in_array('administrator', $auction_author->roles))
            $det = get_option('wdm_cash');
            //else
            //	$det = get_user_meta($auction_author_id, 'wdm_cash', true);
        }
        $mthd = "<strong>" . $mthd . "</strong>";
        printf(__('You can make the payment by %s', 'wdm-ultimate-auction'), $mthd);
        if (!empty($det)) {
            echo "<br /><br /><strong>" . __('Details') . ":</strong> <br/>" . $det;
        }
        echo '<br /><br /><a href="' . get_permalink() . $set_char . 'ult_auc_id=' . $_GET['ult_auc_id'] . '">' . __('Go Back', 'wdm-ultimate-auction') . '</a>';
        $buy_now_price = get_post_meta($wdm_auction->ID, 'wdm_buy_it_now', true);
        ultimate_auction_email_template($wdm_auction->post_title, $wdm_auction->ID, $wdm_auction->post_content, $buy_now_price, $buyer_email, $ret_url);
    } elseif (isset($_GET["ult_auc_id"]) && $_GET["ult_auc_id"]) {
        //if single auction page is found do the following
        global $wpdb;
        $wpdb->hide_errors();
        $wdm_auction = get_post($_GET["ult_auc_id"]);
        if ($wdm_auction) {
            $auction_author_id = $wdm_auction->post_author;
            $auction_author = new WP_User($auction_author_id);
            //update single auction page url on single auction page visit - if the permalink type is updated we should have appropriate url to be sent in email
            update_post_meta($wdm_auction->ID, 'current_auction_permalink', get_permalink() . $set_char . "ult_auc_id=" . $wdm_auction->ID);
            //check if start price/opening bid price is set
            $to_bid = get_post_meta($wdm_auction->ID, 'wdm_opening_bid', true);
            //check if buy now price is set
            $to_buy = get_post_meta($wdm_auction->ID, 'wdm_buy_it_now', true);
            //latest highest/current price
            //$wdm_price_flag=false;
            $query = "SELECT MAX(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $wdm_auction->ID;
            $curr_price = $wpdb->get_var($query);
            if (empty($curr_price)) {
                $curr_price = get_post_meta($wdm_auction->ID, 'wdm_opening_bid', true);
            }
            //total no. of bids
            $qry = "SELECT COUNT(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $wdm_auction->ID;
            $total_bids = $wpdb->get_var($qry);
            //buy now price
            $buy_now_price = get_post_meta($wdm_auction->ID, 'wdm_buy_it_now', true);
            //get currency code
            $currency_code = substr(get_option('wdm_currency'), -3);
            $bef_auc = '';
            $bef_auc = apply_filters('wdm_ua_before_single_auction', $bef_auc, $wdm_auction->ID);
            echo $bef_auc;
            ?>
		
		<!--main forms container of single auction page-->
		 <div class="wdm-ultimate-auction-container">
						
			<div class="wdm-image-container">
				 <?php 
            $images = '';
            $mnimg = get_post_meta($wdm_auction->ID, 'wdm-main-image', true);
            $img_arr = array('png', 'jpg', 'jpeg', 'gif', 'bmp', 'ico');
            $vid_arr = array('mpg', 'mpeg', 'avi', 'mov', 'wmv', 'wma', 'mp4', '3gp', 'ogm', 'mkv', 'flv');
            $flg = 0;
            $images .= '<div class="auction-main-img-cont">';
            for ($c = 1; $c <= 4; $c++) {
                if ($mnimg === 'main_image_' . $c) {
                    $img_show = "display: block";
                } else {
                    $img_show = "display: none";
                }
                $imgURL = get_post_meta($wdm_auction->ID, 'wdm-image-' . $c, true);
                $imgMime = wdm_get_mime_type($imgURL);
                $img_ext = explode(".", $imgURL);
                $img_ext = end($img_ext);
                if (strpos($img_ext, '?') !== false) {
                    $img_ext = strtolower(strstr($img_ext, '?', true));
                }
                if (empty($imgURL)) {
                    $images .= '';
                } else {
                    $flg = 1;
                    $images .= '<a href="' . get_post_meta($wdm_auction->ID, 'wdm-image-' . $c, true) . '" class="auction-main-img-a auction-main-img' . $c . '" rel="gallery" style="' . $img_show . '">';
                    if (strstr($imgMime, "image/") || in_array($img_ext, $img_arr)) {
                        $images .= '<img class="auction-main-img"  src="' . get_post_meta($wdm_auction->ID, 'wdm-image-' . $c, true) . '" />';
                    } elseif (strstr($imgMime, "video/") || in_array($img_ext, $vid_arr)) {
                        $images .= '<video class="auction-main-img" style="margin-bottom:0;" controls>
				   <source src="' . get_post_meta($wdm_auction->ID, 'wdm-image-' . $c, true) . '">
					  Your browser does not support the video tag.
				   </video>';
                    } elseif (strstr($imgURL, "youtube.com") || strstr($imgURL, "vimeo.com")) {
                        $images .= '<img class="auction-main-img"  src="' . plugins_url('img/film.png', __FILE__) . '" />';
                    } else {
                        $images .= '<img class="auction-main-img"  src="' . wp_mime_type_icon($imgMime) . '" />';
                    }
                    $images .= '</a>';
                }
            }
            $images .= '</div>';
            if ($flg == 0) {
                echo '<style> .wdm-image-container{display: none;} </style>';
            }
            $images .= '<div class="auction-small-img-cont">';
            for ($c = 1; $c <= 4; $c++) {
                $imgURL = get_post_meta($wdm_auction->ID, 'wdm-image-' . $c, true);
                $imgMime = wdm_get_mime_type($imgURL);
                $img_ext = explode(".", $imgURL);
                $img_ext = end($img_ext);
                if (strpos($img_ext, '?') !== false) {
                    $img_ext = strtolower(strstr($img_ext, '?', true));
                }
                if (empty($imgURL)) {
                    $images .= '';
                } else {
                    if (strstr($imgMime, "image/") || in_array($img_ext, $img_arr)) {
                        $images .= '<img class="auction-small-img auction-small-img' . $c . '" src="' . $imgURL . '" />';
                    } elseif (strstr($imgMime, "video/") || in_array($img_ext, $vid_arr) || strstr($imgURL, "youtube.com") || strstr($imgURL, "vimeo.com")) {
                        $images .= '<img class="auction-small-img auction-small-img' . $c . '"  src="' . plugins_url('img/film.png', __FILE__) . '" />';
                    } else {
                        $images .= '<img class="auction-small-img auction-small-img' . $c . '" src="' . wp_mime_type_icon($imgMime) . '" />';
                    }
                }
            }
            $images .= '</div>';
            echo $images;
            ?>
			</div> <!--wdm-image-container ends here-->
			
			<div class="wdm_single_prod_desc">
			    
			    <div class="wdm-single-auction-title">
				<?php 
            echo $wdm_auction->post_title;
            ?>
			    </div> <!--wdm-single-auction-title ends here-->
			    
			<?php 
            $ext_html = '';
            $ext_html = apply_filters('wdm_ua_text_before_bid_section', $ext_html, $wdm_auction->ID);
            echo $ext_html;
            //get auction-status taxonomy value for the current post - live/expired
            $active_terms = wp_get_post_terms($wdm_auction->ID, 'auction-status', array("fields" => "names"));
            //incremented price value
            $inc_price = $curr_price + get_post_meta($wdm_auction->ID, 'wdm_incremental_val', true);
            //if the auction has reached it's time limit, expire it
            if (time() >= strtotime(get_post_meta($wdm_auction->ID, 'wdm_listing_ends', true))) {
                if (!in_array('expired', $active_terms)) {
                    $check_term = term_exists('expired', 'auction-status');
                    wp_set_post_terms($wdm_auction->ID, $check_term["term_id"], 'auction-status');
                }
            }
            $now = time();
            $ending_date = strtotime(get_post_meta($wdm_auction->ID, 'wdm_listing_ends', true));
            //display message for expired auction
            if (time() >= strtotime(get_post_meta($wdm_auction->ID, 'wdm_listing_ends', true)) || in_array('expired', $active_terms)) {
                $seconds = $now - $ending_date;
                $rem_tm = wdm_ending_time_calculator($seconds);
                $auc_time = 'exp';
                ?>
			    <div class="wdm-auction-ending-time"><?php 
                printf(__('Ended at', 'wdm-ultimate-auction') . ': ' . __('%s ago', 'wdm-ultimate-auction'), '<span class="wdm-single-auction-ending">' . $rem_tm . '</span>');
                ?>
</div>
			    
			    <?php 
                if (!empty($to_bid)) {
                    ?>
				   
				   <div class="wdm_bidding_price" style="float:left;">
								<strong><?php 
                    echo $currency_symbol . number_format($curr_price, 2, '.', ',') . " " . $currency_code_display;
                    ?>
</strong>
				   </div>
				   <div id="wdm-auction-bids-placed" class="wdm_bids_placed" style="float:right;">
					<a href="#wdm-tab-anchor-id" id="wdm-total-bids-link"><?php 
                    echo $total_bids . " ";
                    echo $total_bids == 1 ? __("Bid", "wdm-ultimate-auction") : __("Bids", "wdm-ultimate-auction");
                    ?>
</a>
				   </div>
			
				   <br />
				   
			<?php 
                }
                $bought = get_post_meta($wdm_auction->ID, 'auction_bought_status', true);
                if ($bought === 'bought') {
                    $buyer_id = get_post_meta($wdm_auction->ID, 'wdm_auction_buyer', true);
                    $buyer = get_user_by('id', $buyer_id);
                    printf('<div class="wdm-mark-red">' . __('This auction has been bought by %s at %s', 'wdm-ultimate-auction') . '</div>', $buyer->user_login, '[' . $currency_symbol . number_format($buy_now_price, 2, '.', ',') . ' ' . $currency_code_display . ']');
                } else {
                    $cnt_qry = "SELECT COUNT(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $wdm_auction->ID;
                    $cnt_bid = $wpdb->get_var($cnt_qry);
                    if ($cnt_bid > 0) {
                        $res_price_met = get_post_meta($wdm_auction->ID, 'wdm_lowest_bid', true);
                        $win_bid = "";
                        $bid_q = "SELECT MAX(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $wdm_auction->ID;
                        $win_bid = $wpdb->get_var($bid_q);
                        if ($win_bid >= $res_price_met) {
                            $winner_name = "";
                            $name_qry = "SELECT name FROM " . $wpdb->prefix . "wdm_bidders WHERE bid =" . $win_bid . " AND auction_id =" . $wdm_auction->ID . " ORDER BY id DESC";
                            $winner_name = $wpdb->get_var($name_qry);
                            printf('<div class="wdm-mark-red">' . __('This auction has been sold to %1$s at %2$s.', 'wdm-ultimate-auction') . '</div>', $winner_name, $currency_symbol . number_format($win_bid, 2, '.', ',') . " " . $currency_code_display);
                        } else {
                            echo '<div class="wdm-mark-red">' . __('Auction has expired without reaching its reserve price.', 'wdm-ultimate-auction') . '</div>';
                        }
                    } else {
                        if (empty($to_bid)) {
                            echo '<div class="wdm-mark-red">' . __('Auction has expired without buying.', 'wdm-ultimate-auction') . '</div>';
                        } else {
                            echo '<div class="wdm-mark-red">' . __('Auction has expired without any bids.', 'wdm-ultimate-auction') . '</div>';
                        }
                    }
                }
            } else {
                //prepare a format and display remaining time for current auction
                $seconds = $ending_date - $now;
                $rem_tm = wdm_ending_time_calculator($seconds);
                $auc_time = "live";
                if (is_user_logged_in()) {
                    $curr_user = wp_get_current_user();
                    $auction_bidder_name = $curr_user->user_login;
                    $auction_bidder_email = $curr_user->user_email;
                }
                //else
                //{
                //	$auction_bidder_name = $curr_user->user_login;
                //	$auction_bidder_email = $curr_user->user_email;
                //}
                ?>
			
				
				<div class="wdm-auction-ending-time"><?php 
                printf(__('Ending in: %s', 'wdm-ultimate-auction'), '<span class="wdm-single-auction-ending">' . $rem_tm . '</span>');
                ?>
</div>
				
				<?php 
                if (!empty($to_bid)) {
                    ?>
				<div id="wdm_place_bid_section">
				<div class="wdm_bidding_price" style="float:left;">
									<strong><?php 
                    echo $currency_symbol . number_format($curr_price, 2, '.', ',') . " " . $currency_code_display;
                    ?>
</strong>
				</div>
				<div id="wdm-auction-bids-placed" class="wdm_bids_placed" style="float:right;">
					<a href="#wdm-tab-anchor-id" id="wdm-total-bids-link"><?php 
                    echo $total_bids . " ";
                    echo $total_bids == 1 ? __("Bid", "wdm-ultimate-auction") : __("Bids", "wdm-ultimate-auction");
                    ?>
</a>
				</div>
				<?php 
                    if ($curr_price >= get_post_meta($wdm_auction->ID, 'wdm_lowest_bid', true)) {
                        ?>
				<br />
				<div class="wdm_reserved_note wdm-mark-green" style="float:left;">
					<em><?php 
                        _e('Reserve price has been met.', 'wdm-ultimate-auction');
                        ?>
</em>
				</div>
				<?php 
                    } else {
                        ?>
					<div class="wdm_reserved_note wdm-mark-red" style="float:left;">
					<em><?php 
                        _e('Reserve price has not been met by any bid.', 'wdm-ultimate-auction');
                        ?>
</em>
					</div>
					<?php 
                    }
                    if (is_user_logged_in()) {
                        //$curr_user = wp_get_current_user();
                        //$auction_bidder_name = $curr_user->user_login;
                        //$auction_bidder_email = $curr_user->user_email;
                        if ($curr_user->ID != $wdm_auction->post_author) {
                            ?>
				<br />
				<form action="<?php 
                            echo dirname(__FILE__);
                            ?>
" style="margin-top:20px;">
					<div class="wdm_bid_val" style="">
						<label for="wdm-bidder-bidval"><?php 
                            _e('Bid Value', 'wdm-ultimate-auction');
                            ?>
: </label>
						<input type="text" id="wdm-bidder-bidval" style="width:85px;" placeholder="<?php 
                            printf(__('in %s', 'wdm-ultimate-auction'), $currency_symbol . $currency_code_display);
                            ?>
" />
						<br /><span class="wdm_enter_val_text" style="float:left;">
						<small>(<?php 
                            printf(__('Enter %.2f or more', 'wdm-ultimate-auction'), $inc_price);
                            ?>
)
						<?php 
                            $ehtml = '';
                            $ehtml = apply_filters('wdm_ua_text_after_bid_form', $ehtml, $wdm_auction->ID);
                            echo $ehtml;
                            ?>
						</small>
						</span>
					</div>
					<div class="wdm_place_bid" style="float:right;">
						<input type="submit" value="<?php 
                            _e('Place Bid', 'wdm-ultimate-auction');
                            ?>
" id="wdm-place-bid-now" />
					</div>
					
				</form>
				<?php 
                            require_once 'ajax-actions/place-bid.php';
                            //file to handle ajax requests related to bid placing form
                        }
                    } else {
                        $check = get_option('wdm_users_login');
                        if ($check == 'without_login') {
                            $auction_bidder_name = '';
                            $auction_bidder_email = '';
                            ?>
				   <br />
					
					<div class="wdm_bidder_name" style="float:left;padding-top:2px">
						<label for="wdm-bidder-name"><?php 
                            _e('Name', 'wdm-ultimate-auction');
                            ?>
: </label>
						<input type="text" id="wdm-bidder-name" name="wdm-bidder-name"/>
					</div>
						
					<div class="wdm_bidder_email" style="float:left;padding-top:2px">
						<label for="wdm-bidder-email"><?php 
                            _e('Email', 'wdm-ultimate-auction');
                            ?>
:  </label>
						<input type="text" id="wdm-bidder-email" name="wdm-bidder-email" />
					</div>
					<div class="wdm_bid_val" style="float:left;padding-top:2px">
						<label for="wdm-bidder-bidval"><?php 
                            _e('Bid Value', 'wdm-ultimate-auction');
                            ?>
: </label>
						<input type="text" id="wdm-bidder-bidval" style="width:85px;" placeholder="<?php 
                            printf(__('in %s', 'wdm-ultimate-auction'), $currency_symbol . $currency_code_display);
                            ?>
" />
						<br /><span class="wdm_enter_val_text" style="float:right;">
						<small>(<?php 
                            printf(__('Enter %.2f or more', 'wdm-ultimate-auction'), $inc_price);
                            ?>
)
						<?php 
                            $ehtml = '';
                            $ehtml = apply_filters('wdm_ua_text_after_bid_form', $ehtml, $wdm_auction->ID);
                            echo $ehtml;
                            ?>
						
						</small>
						</span>
					</div>
					
					
				   <div class="wdm_place_bid" style="float:right;padding-top:6px;">
					<input type="submit" value="<?php 
                            _e('Place Bid', 'wdm-ultimate-auction');
                            ?>
" id="wdm-place-bid-now" />	
					  
				   </div>
					<?php 
                        } else {
                            ?>
						<div class="wdm_bid_val" style="float:left;padding-top:2px">
						<label for="wdm-bidder-bidval"><?php 
                            _e('Bid Value', 'wdm-ultimate-auction');
                            ?>
: </label>
						<input type="text" id="wdm-bidder-bidval" style="width:85px;" placeholder="<?php 
                            printf(__('in %s', 'wdm-ultimate-auction'), $currency_symbol . $currency_code_display);
                            ?>
" />
						<br /><span class="wdm_enter_val_text" style="float:right;">
						<small>(<?php 
                            printf(__('Enter %.2f or more', 'wdm-ultimate-auction'), $inc_price);
                            ?>
)</small>
						</span>
					</div>
					
					
				   <div class="wdm_place_bid" style="float:right;padding-top:6px;">
					<a class="wdm-login-to-place-bid" href="<?php 
                            echo $wdm_login_url;
                            ?>
" title="<?php 
                            _e('Login', 'wdm-ultimate-auction');
                            ?>
"><?php 
                            _e('Place Bid', 'wdm-ultimate-auction');
                            ?>
</a>
					  
				   </div>
				   
				<?php 
                        }
                        require_once 'ajax-actions/place-bid.php';
                    }
                    ?>
				</div> <!--wdm_place_bid_section ends here-->
				<?php 
                }
                ?>
				<br />
				<?php 
                if (!empty($to_buy) || $to_buy > 0) {
                    $a_key = get_post_meta($wdm_auction->ID, 'wdm-auth-key', true);
                    $acc_mode = get_option('wdm_account_mode');
                    if ($acc_mode == 'Sandbox') {
                        $pp_link = "https://sandbox.paypal.com/cgi-bin/webscr";
                    } else {
                        $pp_link = "https://www.paypal.com/cgi-bin/webscr";
                    }
                    if (is_user_logged_in()) {
                        $check_method = get_post_meta($wdm_auction->ID, 'wdm_payment_method', true);
                        if ($check_method == 'method_paypal') {
                            ?>
				<!--buy now button-->
				<div id="wdm_buy_now_section">
					<?php 
                            if ($curr_user->ID != $wdm_auction->post_author) {
                                ?>
					<div id="wdm-buy-line-above" >
				<form action="<?php 
                                echo $pp_link;
                                ?>
" method="post" target="_top">
				<input type="hidden" name="cmd" value="_xclick">
				<input type="hidden" name="charset" value="utf-8" />
				<input type="hidden" name="business" value="<?php 
                                echo get_option('wdm_paypal_address');
                                ?>
">
				<!--<input type="hidden" name="lc" value="US">-->
				<input type="hidden" name="item_name" value="<?php 
                                echo $wdm_auction->post_title;
                                ?>
">
				<input type="hidden" name="amount" value="<?php 
                                echo $buy_now_price;
                                ?>
">
				<?php 
                                $shipping_field = '';
                                echo apply_filters('ua_product_shipping_cost_field', $shipping_field, $wdm_auction->ID);
                                ?>
				<input type="hidden" name="currency_code" value="<?php 
                                echo $currency_code;
                                ?>
">
				<input type="hidden" name="return" value="<?php 
                                echo get_permalink() . $set_char . "ult_auc_id=" . $wdm_auction->ID;
                                ?>
">
				<input type="hidden" name="button_subtype" value="services">
				<input type="hidden" name="no_note" value="0">
				<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">
				<input type="submit" value="<?php 
                                printf(__('Buy it now for %s%s %s', 'wdm-ultimate-auction'), $currency_symbol, number_format($buy_now_price, 2, '.', ','), $currency_code_display);
                                ?>
" id="wdm-buy-now-button">
				</form>
					</div>
					<?php 
                            }
                            ?>
			        </div> <!--wdm_buy_now_section ends here-->
				
				<script type="text/javascript">
				   jQuery(document).ready(function(){
				   jQuery("#wdm_buy_now_section form").click(function(){
				   var cur_val = jQuery("#wdm_buy_now_section form input[name='return']").val();
				   jQuery("#wdm_buy_now_section form input[name='return']").val(cur_val+"&wdm="+"<?php 
                            echo $a_key;
                            ?>
");
				   });
		
			    });
			       </script>
				<?php 
                        } else {
                            if ($check_method === 'method_wire_transfer') {
                                $mthd = __('Wire Transfer', 'wdm-ultimate-auction');
                            } elseif ($check_method === 'method_mailing') {
                                $mthd = __('Cheque', 'wdm-ultimate-auction');
                            } elseif ($check_method === 'method_cash') {
                                $mthd = __('Cash', 'wdm-ultimate-auction');
                            }
                            $bn_text = sprintf(__('Buy it now for %s%s %s', 'wdm-ultimate-auction'), $currency_symbol, number_format($buy_now_price, 2, '.', ','), $currency_code_display);
                            $shipAmt = 0;
                            $shipAmt = apply_filters('ua_shipping_data_invoice', $shipAmt, $wdm_auction->ID, $auction_bidder_email);
                            if ($shipAmt > 0) {
                                $bn_text = sprintf(__('Buy it now for %s%s %s + %s%s %s(shipping)', 'wdm-ultimate-auction'), $currency_symbol, number_format($buy_now_price, 2, '.', ','), $currency_code_display, $currency_symbol, number_format($shipAmt, 2, '.', ','), $currency_code_display);
                            }
                            ?>
					<div id="wdm_buy_now_section">
						<?php 
                            if ($curr_user->ID != $wdm_auction->post_author) {
                                ?>
						<div id="wdm-buy-line-above" >
						<form action="<?php 
                                echo add_query_arg(array('mt' => 'bn', 'wdm' => $a_key), get_permalink() . $set_char . "ult_auc_id=" . $wdm_auction->ID);
                                ?>
" method="post">
							<input type="submit" value="<?php 
                                echo $bn_text;
                                ?>
" id="wdm-buy-now-button">
						</form>
						</div>
						<?php 
                            }
                            ?>
					</div>
					
					<script type="text/javascript">
						jQuery(document).ready(function($){
							$("#wdm-buy-now-button").click(function(){
								var bcnf = confirm('<?php 
                            printf(__("You need to pay %s %.2f amount via %s to %s. If you choose OK, you will receive an email with payment details and auction will expire. Choose Cancel to ignore this buy now transaction.", "wdm-ultimate-auction"), $currency_code, $buy_now_price + $shipAmt, $mthd, $auction_author->user_login);
                            ?>
');
								if(bcnf == true){ return true; }
								return false;
							});
						});
					</script>
					<?php 
                        }
                    } else {
                        ?>
				   <div id="wdm_buy_now_section">
					  <div id="wdm-buy-line-above" >
					  <a class="wdm-login-to-buy-now" href="<?php 
                        echo $wdm_login_url;
                        ?>
" title="<?php 
                        _e('Login', 'wdm-ultimate-auction');
                        ?>
">
						 <?php 
                        printf(__('Buy it now for %s%s %s', 'wdm-ultimate-auction'), $currency_symbol, number_format($buy_now_price, 2, '.', ','), $currency_code_display);
                        ?>
					  </a>
					  </div>
					  
				   </div>
				   <?php 
                    }
                }
                if (is_user_logged_in() && $curr_user->ID == $wdm_auction->post_author) {
                    echo "<span style='float: left;'>" . __('Sorry, you can not bid on your own item.', 'wdm-ultimate-auction') . "</span>";
                }
                do_action('wdm_ua_ship_short_link', $wdm_auction->ID);
                //do_action('ua_add_shipping_cost_view_field', $wdm_auction->ID); //SHP-ADD hook to add new product data
            }
            ?>
			    </div> <!--wdm_single_prod_desc ends here-->
			
		</div> <!--wdm-ultimate-auction-container ends here-->
		
		<!--<div id="wdm_auction_desc_section">
			<div class="wdm-single-auction-description">
				<strong><?php 
            //_e('Description', 'wdm-ultimate-auction');
            ?>
</strong>
				<br />
				<?php 
            //echo apply_filters('the_content', $wdm_auction->post_content);
            ?>
			</div>
			
		</div>--> <!--wdm_auction_desc_section ends here-->
			
		<?php 
            require_once 'auction-description-tabs.php';
            //file to display current auction description tabs section
            ?>
		<!--script to show small images in main image container-->
		<script type="text/javascript">
		jQuery(document).ready(function($){
		
		$('.wdm-image-container .auction-small-img').each(function(i){
				  $('.auction-small-img'+(i+1)).click(function(){
					  $('.auction-main-img-a').css('display','none');
					  $('.auction-main-img'+(i+1)).css('display','block');
				   }); 
			    });
       
		//jQuery(".auction-main-img-a").boxer({'fixed': true});
		
        var eDays = jQuery('#wdm_days');
        var eHours = jQuery('#wdm_hours');
        var eMinutes = jQuery('#wdm_minutes');
        var eSeconds = jQuery('#wdm_seconds');
	
        var timer;
        timer = setInterval(function() {
            var vDays = parseInt(eDays.html(), 10);
            var vHours = parseInt(eHours.html(), 10);
            var vMinutes = parseInt(eMinutes.html(), 10);
            var vSeconds = parseInt(eSeconds.html(), 10);
	    
	    var ac_time = '<?php 
            echo $auc_time;
            ?>
';
	    
	    if(ac_time == 'live'){
	    
	    vSeconds--;
		if(vSeconds < 0) {
                vSeconds = 59;
                vMinutes--;
                if(vMinutes < 0) {
                    vMinutes = 59;
                    vHours--;
                    if(vHours < 0) {
                        vHours = 23;
                        vDays--;
                    }
			}
		}
		else {
                if(vSeconds == 0 &&
                   vMinutes == 0 &&
                   vHours == 0 &&
                   vDays == 0) {
                    clearInterval(timer);
		    window.location.reload();
			}
		}
	    }
	    else if(ac_time == 'exp'){
	    vSeconds++;
            if(vSeconds > 59) {
                vSeconds = 0;
                vMinutes++;
                if(vMinutes > 59) {
                    vMinutes = 0;
                    vHours++;
                    if(vHours > 23) {
                        vHours = 0;
                        vDays++;
                    }
                }
            } else {
                if(vSeconds == 0 &&
                   vMinutes == 0 &&
                   vHours == 0 &&
                   vDays == 0) {
                    clearInterval(timer);
		    window.location.reload();
                }
            }
	    }
	    
            eSeconds.html(vSeconds);
            eMinutes.html(vMinutes);
            eHours.html(vHours);
            eDays.html(vDays);
	    
	    	if(vDays == 0){
		eDays.hide();
		jQuery('#wdm_days_text').html(' ');
	}
	else if(vDays == 1 || vDays == -1){
		eDays.show();
		jQuery('#wdm_days_text').html(' <?php 
            _e("day", "wdm-ultimate-auction");
            ?>
 ');
	}
	else{
		eDays.show();
		jQuery('#wdm_days_text').html(' <?php 
            _e("days", "wdm-ultimate-auction");
            ?>
 ');
	}
	    
	if(vHours == 0){
		eHours.hide();
		jQuery('#wdm_hrs_text').html(' ');
	}
	else if(vHours == 1 || vHours == -1){
		eHours.show();
		jQuery('#wdm_hrs_text').html(' <?php 
            _e("hour", "wdm-ultimate-auction");
            ?>
 ');
	}
	else{
		eHours.show();
		jQuery('#wdm_hrs_text').html(' <?php 
            _e("hours", "wdm-ultimate-auction");
            ?>
 ');
	}
	       
	if(vMinutes == 0){
		eMinutes.hide();
		jQuery('#wdm_mins_text').html(' ');
	}
	else if(vMinutes == 1 || vMinutes == -1){
		eMinutes.show();
		jQuery('#wdm_mins_text').html(' <?php 
            _e("minute", "wdm-ultimate-auction");
            ?>
 ');
	}
	else{
		eMinutes.show();
		jQuery('#wdm_mins_text').html(' <?php 
            _e("minutes", "wdm-ultimate-auction");
            ?>
 ');
	}
	       
	if(vSeconds == 0){
		eSeconds.hide();
		jQuery('#wdm_secs_text').html(' ');
	}
	else if(vSeconds == 1 || vSeconds == -1){
		eSeconds.show();
		jQuery('#wdm_secs_text').html(' <?php 
            _e("second", "wdm-ultimate-auction");
            ?>
');
	}
	else{
		eSeconds.show();
		jQuery('#wdm_secs_text').html(' <?php 
            _e("seconds", "wdm-ultimate-auction");
            ?>
');
	}
	
        }, 1000);
	
});
		</script>
		<?php 
        }
    } else {
        //file auction listing page
        require_once 'auction-feeder-page.php';
    }
    $auc_sc = ob_get_contents();
    ob_end_clean();
    return $auc_sc;
}
    /**
     * Front-end display of widget.
     *
     * @see WP_Widget::widget()
     *
     * @param array $args     Widget arguments.
     * @param array $instance Saved values from database.
     */
    public function widget($args, $instance)
    {
        $title = apply_filters('widget_title', $instance['ua_widget_title']);
        echo $args['before_widget'];
        if (!empty($title)) {
            echo $args['before_title'] . $title . $args['after_title'];
        }
        wp_enqueue_style('wdm_widget_css', plugins_url('ua-widget.css', __FILE__));
        $options = $instance['wdm_sb_auc_listing'];
        $get_link = $instance['wdm_sb_auc_see_all_link'];
        $max_auctions = $instance['wdm_sb_auc_max_no_auctions'];
        if (isset($options) && $options == 'New_Listing') {
            $arg_data = array('posts_per_page' => $max_auctions, 'post_type' => 'ultimate-auction', 'auction-status' => 'live', 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DESC', 'suppress_filters' => false);
        }
        if (isset($options) && $options == 'Most_Active') {
            $arg_data = array('posts_per_page' => $max_auctions, 'post_type' => 'ultimate-auction', 'auction-status' => 'live', 'post_status' => 'publish', 'meta_key' => 'total_bids_count', 'orderby' => 'total_bids_count', 'order' => 'DESC', 'suppress_filters' => false);
        }
        if (isset($options) && $options == 'Ending_Soon') {
            $arg_data = array('posts_per_page' => $max_auctions, 'post_type' => 'ultimate-auction', 'auction-status' => 'live', 'post_status' => 'publish', 'meta_key' => 'wdm_ending_soon', 'orderby' => 'wdm_ending_soon', 'order' => 'ASC', 'suppress_filters' => false);
        }
        if (isset($options) && $options == 'Just_Sold') {
            $arg_data = array('posts_per_page' => $max_auctions, 'post_type' => 'ultimate-auction', 'auction-status' => 'expired', 'post_status' => 'publish', 'meta_key' => 'wdm_listing_ends', 'orderby' => 'wdm_listing_ends', 'order' => 'DESC', 'suppress_filters' => false);
        }
        $wdm_auction_array = get_posts($arg_data);
        if (empty($wdm_auction_array)) {
            echo "<div class='wdm-auction-sidebar_single-item'> " . __('No Entries yet.', 'wdm-ultimate-auction') . "</div>";
        } else {
            ?>
		<aside class = "wdm_auction_sidebar_content">
		    
		<?php 
            $auction_count = 0;
            foreach ($wdm_auction_array as $wdm_single_auction) {
                if ($auction_count != $max_auctions) {
                    global $wpdb;
                    ?>
			 <div class="wdm-single-auction-wrap">
			    <div class = "wdm_auction_sidebar_auc_thumbnail">
				<?php 
                    $vid_arr = array('mpg', 'mpeg', 'avi', 'mov', 'wmv', 'wma', 'mp4', '3gp', 'ogm', 'mkv', 'flv');
                    $auc_thumb = get_post_meta($wdm_single_auction->ID, 'wdm_auction_thumb', true);
                    $imgMime = wdm_get_mime_type($auc_thumb);
                    $img_ext = end(explode(".", $auc_thumb));
                    if (strstr($imgMime, "video/") || in_array($img_ext, $vid_arr) || strstr($auc_thumb, "youtube.com") || strstr($auc_thumb, "vimeo.com")) {
                        $auc_thumb = plugins_url('../img/film.png', __FILE__);
                    }
                    if (empty($auc_thumb)) {
                        $auc_thumb = plugins_url('../img/no-pic.jpg', __FILE__);
                    }
                    ?>
				<?php 
                    //if(!empty($get_link)){
                    ?>
				<a href="<?php 
                    echo get_permalink($wdm_single_auction->ID);
                    ?>
" class="wdm-auction-sidebar-auc-link"><img src="<?php 
                    echo $auc_thumb;
                    ?>
" width="50" height="50" alt="<?php 
                    echo $wdm_single_auction->post_title;
                    ?>
" /></a>
				<?php 
                    //}
                    ?>
			    </div>
			    <div class="wdm-auction-content">
			    <div class = "wdm_auction_sidebar_auc_title">
				<?php 
                    //if(!empty($get_link)){
                    ?>
				<a href="<?php 
                    echo get_permalink($wdm_single_auction->ID);
                    ?>
" class="wdm-auction-sidebar-auc-link"><?php 
                    echo $wdm_single_auction->post_title;
                    ?>
</a>
				<?php 
                    //}
                    ?>
			    </div>
			     <div class = "wdm_auction_sidebar_auc_bids">
				<?php 
                    $query = "SELECT MAX(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $wdm_single_auction->ID;
                    $curr_price = $wpdb->get_var($query);
                    $cc = substr(get_option('wdm_currency'), -3);
                    $ob = get_post_meta($wdm_single_auction->ID, 'wdm_opening_bid', true);
                    $bnp = get_post_meta($wdm_single_auction->ID, 'wdm_buy_it_now', true);
                    if ((!empty($curr_price) || $curr_price > 0) && !empty($ob)) {
                        echo $cc . " " . sprintf("%.2f", $curr_price);
                    } elseif (!empty($ob)) {
                        echo $cc . " " . sprintf("%.2f", $ob);
                    } elseif (empty($ob) && !empty($bnp)) {
                        printf(__('Buy at %s %.2f', 'wdm-ultimate-auction'), $cc, $bnp);
                    }
                    ?>
					    </div>
			 </div>
			 <div class="clear"></div>
		    </div>
		    <?php 
                    $auction_count++;
                }
            }
            ?>
		    
		    <?php 
            if (!empty($get_link)) {
                ?>
		    <a href="<?php 
                echo $get_link;
                ?>
" class = "wdm-auction-sb-listing-all" target="_blank"> <?php 
                _e('See All', 'wdm-ultimate-auction');
                ?>
</a>
		<?php 
            }
            ?>
		
		    </aside>
			 
		
		
	    <?php 
        }
        echo $args['after_widget'];
    }
Пример #5
0
    function wdm_get_data()
    {
        $watch_auctions = get_user_meta(get_current_user_id(), 'wdm_watch_auctions', true);
        if (isset($watch_auctions)) {
            $auction_ids = explode(" ", $watch_auctions);
            $arg_data = array('post__in' => $auction_ids, 'posts_per_page' => -1, 'post_type' => 'ultimate-auction', 'post_status' => 'publish', 'order' => 'DESC');
            global $wpdb;
            $wdm_auction_array = get_posts($arg_data);
            $data_array = array();
            foreach ($wdm_auction_array as $auction) {
                $row = array();
                $act_trm = wp_get_post_terms($auction->ID, 'auction-status', array("fields" => "names"));
                $query = "SELECT MAX(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $auction->ID;
                $curr_price = $wpdb->get_var($query);
                $vid_arr = array('mpg', 'mpeg', 'avi', 'mov', 'wmv', 'wma', 'mp4', '3gp', 'ogm', 'mkv', 'flv');
                $auc_thumb = get_post_meta($auction->ID, 'wdm_auction_thumb', true);
                $imgMime = wdm_get_mime_type($auc_thumb);
                $img_ext = explode(".", $auc_thumb);
                $img_ext = end($img_ext);
                if (strpos($img_ext, '?') !== false) {
                    $img_ext = strtolower(strstr($img_ext, '?', true));
                }
                if (strstr($imgMime, "video/") || in_array($img_ext, $vid_arr) || strstr($auc_thumb, "youtube.com") || strstr($auc_thumb, "vimeo.com")) {
                    $auc_thumb = plugins_url('img/film.png', __FILE__);
                }
                if (empty($auc_thumb)) {
                    $auc_thumb = plugins_url('img/no-pic.jpg', __FILE__);
                }
                //$perma_type = get_option('permalink_structure');
                //
                //if(empty($perma_type))
                //  $set_char = "&";
                //else
                //  $set_char = "?";
                //$auc_url = get_option('wdm_auction_page_url');
                //if(!empty($auc_url)){
                $link_title = get_permalink($auction->ID);
                //}
                $row['image_1'] = "<input class='wdm_chk_auc_act' value=" . $auction->ID . " type='checkbox' style='margin: 0 5px 0 0;' />" . "<img src='" . $auc_thumb . "' width='90'";
                $row['title'] = prepare_single_auction_title($auction->ID, $auction->post_title);
                $cc = substr(get_option('wdm_currency'), -3);
                $ob = get_post_meta($auction->ID, 'wdm_opening_bid', true);
                $bnp = get_post_meta($auction->ID, 'wdm_buy_it_now', true);
                if (!in_array('expired', $act_trm)) {
                    if ((!empty($curr_price) || $curr_price > 0) && !empty($ob)) {
                        $row['current_price'] = $cc . " " . sprintf("%.2f", $curr_price);
                    } elseif (!empty($ob)) {
                        $row['current_price'] = $cc . " " . sprintf("%.2f", $ob);
                    } elseif (empty($ob) && !empty($bnp)) {
                        $row['current_price'] = sprintf(__('Buy at %s %.2f', 'wdm-ultimate-auction'), $cc, $bnp);
                    }
                } elseif (in_array('expired', $act_trm)) {
                    $bought = get_post_meta($auction->ID, 'auction_bought_status', true);
                    if ($bought === 'bought') {
                        $row['current_price'] = $cc . " " . sprintf("%.2f", $bnp);
                    } elseif ((!empty($curr_price) || $curr_price > 0) && !empty($ob)) {
                        $row['current_price'] = $cc . " " . sprintf("%.2f", $curr_price);
                    } elseif (!empty($ob)) {
                        $row['current_price'] = $cc . " " . sprintf("%.2f", $ob);
                    } elseif (empty($ob) && !empty($bnp)) {
                        $row['current_price'] = $cc . " " . sprintf("%.2f", $bnp);
                    }
                }
                $get_bids = "SELECT COUNT(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $auction->ID;
                $bids_placed = $wpdb->get_var($get_bids);
                $auc_bstat = get_post_meta($auction->ID, 'auction_bought_status', true);
                if (in_array('expired', $act_trm) && $auc_bstat === 'bought') {
                    $row['bids_placed'] = "<span class='wdm-bids-avail wdm-mark-normal'>" . __("Sold at 'Buy Now' price", 'wdm-ultimate-auction') . "</span>";
                } else {
                    if (!empty($bids_placed) || $bids_placed > 0) {
                        $row['bids_placed'] = "<span class='wdm-bids-avail'>" . $bids_placed . "</span>";
                    } else {
                        $row['bids_placed'] = "<span class='wdm-no-bids-avail'>" . __('No bids placed', 'wdm-ultimate-auction') . "</span>";
                    }
                }
                $now = time();
                $ending_date = strtotime(get_post_meta($auction->ID, 'wdm_listing_ends', true));
                $seconds = $ending_date - $now;
                if (in_array('expired', $act_trm)) {
                    $seconds = $now - $ending_date;
                    $ending_tm = '';
                    $ended_at = wdm_ending_time_calculator($seconds, $ending_tm);
                    $row['end_time'] = "<span class='wdm-mark-normal'>" . sprintf(__('%s ago', 'wdm-ultimate-auction'), $ended_at) . "</span>";
                } elseif ($seconds > 0 && !in_array('expired', $act_trm)) {
                    $ending_tm = '';
                    $ending_in = wdm_ending_time_calculator($seconds, $ending_tm);
                    $row['end_time'] = "<span class='wdm-mark-normal'>" . $ending_in . "</span>";
                } else {
                    $seconds = $now - $ending_date;
                    $ending_tm = '';
                    $ended_at = wdm_ending_time_calculator($seconds, $ending_tm);
                    $row['end_time'] = "<span class='wdm-mark-normal'>" . sprintf(__('%s ago', 'wdm-ultimate-auction'), $ended_at) . "</span>";
                }
                if (in_array('expired', $act_trm)) {
                    $row['place_bid'] = '<span class="wdm-mark-red">' . __("Expired", "wdm-ultimate-auction") . '</span>';
                } elseif (in_array('live', $act_trm)) {
                    $row['place_bid'] = '<a href="' . $link_title . '" target="_blank"><input class="wdm_bid_now_btn" type="button" value="' . __('Bid Now', 'wdm-ultimate-auction') . '" /></a>';
                }
                $row['remove'] = '<a id="wdm-rmv-frmwatch-' . $auction->ID . '" style="color:red;cursor:pointer;text-decoration:none;" href="#">' . __('Remove', 'wdm-ultimate-auction') . ' <span class="auc-ajax-img"></span></a>';
                ?>
	    <script type="text/javascript">
            jQuery(document).ready(function($){
		$('#wdm-rmv-frmwatch-<?php 
                echo $auction->ID;
                ?>
').click(function(e){
		e.preventDefault();
		var ajaxurl = '<?php 
                echo admin_url('admin-ajax.php');
                ?>
';
		var cnf = confirm('<?php 
                _e("Are you sure to remove this auction from your watchlist?", "wdm-ultimate-auction");
                ?>
');
		
		if(cnf == true){
		
		$(this).html("<?php 
                _e('Removing', 'wdm-ultimate-auction');
                echo ' ';
                ?>
 <img src='<?php 
                echo plugins_url('/img/ajax-loader.gif', __FILE__);
                ?>
' />");
		
		var data = {
			      action:'rmv_frm_watchlist',
			      rmv_id:'<?php 
                echo $auction->ID;
                ?>
',
			      usr_id:'<?php 
                echo get_current_user_id();
                ?>
',
			      auc_title: '<?php 
                echo esc_js($auction->post_title);
                ?>
',
			      force_del:'yes'
			    };
		
		$.post(ajaxurl, data, function(response) {
		    $('#wdm-rmv-frmwatch-<?php 
                echo $auction->ID;
                ?>
').html('<?php 
                _e("Remove", "wdm-ultimate-auction");
                ?>
');
		    alert(response);
		    window.location.reload();
		 });
		}
		return false;
	      });
	    });
            </script>
      <?php 
                $data_array[] = $row;
            }
        }
        $this->allData = $data_array;
        return $data_array;
    }
Пример #6
0
function wdm_my_watch()
{
    $page_num = get_option('wdm_auc_num_per_page');
    $page_num = !empty($page_num) && $page_num > 0 ? $page_num : 20;
    $wdm_auction_array = array();
    $ua_auction_array = array();
    $wdm_my_watch = '';
    if (get_query_var('paged')) {
        $paged = get_query_var('paged');
    } elseif (get_query_var('page')) {
        $paged = get_query_var('page');
    } else {
        $paged = 1;
    }
    $watch_auctions = get_user_meta(get_current_user_id(), 'wdm_watch_auctions', true);
    if (isset($watch_auctions)) {
        $auction_ids = explode(" ", $watch_auctions);
        $arg_data = array('posts_per_page' => $page_num, 'post__in' => $auction_ids, 'post_type' => 'ultimate-auction', 'post_status' => 'publish', 'paged' => $paged, 'order' => 'ASC');
        $arg_data_c = array('posts_per_page' => -1, 'post__in' => $auction_ids, 'post_type' => 'ultimate-auction', 'post_status' => 'publish', 'paged' => $paged, 'order' => 'ASC');
    }
    global $wpdb;
    $wdm_auction_array = get_posts($arg_data);
    $count_pages = count(get_posts($arg_data_c));
    //auction listing page container
    if (empty($wdm_auction_array)) {
        $wdm_my_watch .= "<li class='wdm-auction-single-item'> " . __('No Entries yet.', 'wdm-ultimate-auction') . "</li>";
    } else {
        foreach ($wdm_auction_array as $wdm_single_auction) {
            $act_trm = wp_get_post_terms($wdm_single_auction->ID, 'auction-status', array("fields" => "names"));
            $query = "SELECT MAX(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $wdm_single_auction->ID;
            $curr_price = $wpdb->get_var($query);
            $vid_arr = array('mpg', 'mpeg', 'avi', 'mov', 'wmv', 'wma', 'mp4', '3gp', 'ogm', 'mkv', 'flv');
            $auc_thumb = get_post_meta($wdm_single_auction->ID, 'wdm_auction_thumb', true);
            $imgMime = wdm_get_mime_type($auc_thumb);
            $img_ext = explode(".", $auc_thumb);
            $img_ext = end($img_ext);
            if (strpos($img_ext, '?') !== false) {
                $img_ext = strtolower(strstr($img_ext, '?', true));
            }
            if (strstr($imgMime, "video/") || in_array($img_ext, $vid_arr) || strstr($auc_thumb, "youtube.com") || strstr($auc_thumb, "vimeo.com")) {
                $auc_thumb = plugins_url('img/film.png', __FILE__);
            }
            if (empty($auc_thumb)) {
                $auc_thumb = plugins_url('img/no-pic.jpg', __FILE__);
            }
            //$perma_type = get_option('permalink_structure');
            //if(empty($perma_type))
            //$set_char = "&";
            //else
            //$set_char = "?";
            //$auc_url = get_option('wdm_auction_page_url');
            //if(!empty($auc_url)){
            $link_title = get_permalink($wdm_single_auction->ID);
            //$link_title = "<a href='".$link_title."' target='_blank'>".$title."</a>";
            $title = $link_title;
            //}
            $wdm_my_watch .= '<li class="wdm-auction-single-item">
				<a href="' . $title . '" class="wdm-auction-list-link">
				<div class="wdm-auction-listing-container">
				<ul class="wdm_all_li_content_auc">
			<li class="wdm-apn auc_single_list">
				<div  class="wdm_single_auction_thumb">
				<img src="' . $auc_thumb . '" width="100" height="80" alt="' . $wdm_single_auction->post_title . '" />
				</div>
			</li>
			
			<li class="wdm-apt auc_single_list">
				<div class="wdm-auction-title">' . $wdm_single_auction->post_title . '</div>
			</li>
			
			<li class="wdm-app auc_single_list auc_list_center">
			<span class="wdm-auction-price wdm-mark-green">';
            $cc = substr(get_option('wdm_currency'), -3);
            $ob = get_post_meta($wdm_single_auction->ID, 'wdm_opening_bid', true);
            $bnp = get_post_meta($wdm_single_auction->ID, 'wdm_buy_it_now', true);
            if (!in_array('expired', $act_trm)) {
                if ((!empty($curr_price) || $curr_price > 0) && !empty($ob)) {
                    $wdm_my_watch .= $cc . " " . sprintf("%.2f", $curr_price);
                } elseif (!empty($ob)) {
                    $wdm_my_watch .= $cc . " " . sprintf("%.2f", $ob);
                } elseif (empty($ob) && !empty($bnp)) {
                    $wdm_my_watch .= sprintf(__('Buy at %s %.2f', 'wdm-ultimate-auction'), $cc, $bnp);
                }
            } elseif (in_array('expired', $act_trm)) {
                $bought = get_post_meta($wdm_single_auction->ID, 'auction_bought_status', true);
                if ($bought === 'bought') {
                    $wdm_my_watch .= $cc . " " . sprintf("%.2f", $bnp);
                } elseif ((!empty($curr_price) || $curr_price > 0) && !empty($ob)) {
                    $wdm_my_watch .= $cc . " " . sprintf("%.2f", $curr_price);
                } elseif (!empty($ob)) {
                    $wdm_my_watch .= $cc . " " . sprintf("%.2f", $ob);
                } elseif (empty($ob) && !empty($bnp)) {
                    $wdm_my_watch .= $cc . " " . sprintf("%.2f", $bnp);
                }
            }
            $wdm_my_watch .= '</span>
			</li>
			<li class="wdm-apb auc_single_list auc_list_center">';
            $get_bids = "SELECT COUNT(bid) FROM " . $wpdb->prefix . "wdm_bidders WHERE auction_id =" . $wdm_single_auction->ID;
            $bids_placed = $wpdb->get_var($get_bids);
            $auc_bstat = get_post_meta($wdm_single_auction->ID, 'auction_bought_status', true);
            if (in_array('expired', $act_trm) && $auc_bstat === 'bought') {
                $wdm_my_watch .= "<span class='wdm-bids-avail wdm-mark-normal'>" . __("Sold at 'Buy Now' price", 'wdm-ultimate-auction') . "</span>";
            } else {
                if (!empty($bids_placed) || $bids_placed > 0) {
                    $wdm_my_watch .= "<span class='wdm-bids-avail wdm-mark-normal'>" . $bids_placed . "</span>";
                } else {
                    $wdm_my_watch .= "<span class='wdm-no-bids-avail wdm-mark-red'>" . __('No bids placed', 'wdm-ultimate-auction') . "</span>";
                }
            }
            $wdm_my_watch .= '</li>
			<li class="wdm-ape auc_single_list auc_list_center">';
            $now = time();
            $ending_date = strtotime(get_post_meta($wdm_single_auction->ID, 'wdm_listing_ends', true));
            $seconds = $ending_date - $now;
            if (in_array('expired', $act_trm)) {
                $seconds = $now - $ending_date;
                $ending_tm = '';
                $ended_at = wdm_ending_time_calculator($seconds, $ending_tm);
                $wdm_my_watch .= "<span class='wdm-mark-normal'>" . sprintf(__('%s ago', 'wdm-ultimate-auction'), $ended_at) . "</span>";
            } elseif ($seconds > 0 && !in_array('expired', $act_trm)) {
                $ending_tm = '';
                $ending_in = wdm_ending_time_calculator($seconds, $ending_tm);
                $wdm_my_watch .= "<span class='wdm-mark-normal'>" . $ending_in . "</span>";
            } else {
                $seconds = $now - $ending_date;
                $ending_tm = '';
                $ended_at = wdm_ending_time_calculator($seconds, $ending_tm);
                $wdm_my_watch .= "<span class='wdm-mark-normal'>" . sprintf(__('%s ago', 'wdm-ultimate-auction'), $ended_at) . "</span>";
            }
            $wdm_my_watch .= '<br/>
			</li>
			<li class="wdm-apbid auc_single_list auc_list_center">';
            if (in_array('expired', $act_trm)) {
                $wdm_my_watch .= '<span class="wdm-mark-red">' . __("Expired", "wdm-ultimate-auction") . '</span>';
            } elseif (in_array('live', $act_trm)) {
                $wdm_my_watch .= '<input class="wdm_bid_now_btn" type="button" value="' . __('Bid Now', 'wdm-ultimate-auction') . '" />  ';
            }
            $wdm_my_watch .= '</li>
			<li><div class="wdm-apd">' . $wdm_single_auction->post_excerpt . '</div></li>
			<li>
			<a id="wdm-rmv-frmwatch-' . $wdm_single_auction->ID . '" style="color:red;cursor:pointer;padding: 0 10px;text-decoration:none;" href="#">' . __('Remove From Watchlist', 'wdm-ultimate-auction') . ' <span class="auc-ajax-img"></span></a> 
			</li>
				</ul>
				</div>
				</a>
			</li>';
            ?>
	    <script type="text/javascript">
            jQuery(document).ready(
			      function($){
			      $('#wdm-rmv-frmwatch-<?php 
            echo $wdm_single_auction->ID;
            ?>
').click(function(e){
			      e.preventDefault();
			      var ajaxurl = '<?php 
            echo admin_url('admin-ajax.php');
            ?>
';
			      var cnf = confirm('<?php 
            _e("Are you sure to remove this auction from your watchlist?", "wdm-ultimate-auction");
            ?>
');
				
			      if(cnf == true){
			      $(this).html("<?php 
            _e('Removing', 'wdm-ultimate-auction');
            echo ' ';
            ?>
 <img src='<?php 
            echo plugins_url('/img/ajax-loader.gif', __FILE__);
            ?>
' />");       
			      var data = {
				       action:'rmv_frm_watchlist',
				       rmv_id:'<?php 
            echo $wdm_single_auction->ID;
            ?>
',
				       usr_id:'<?php 
            echo get_current_user_id();
            ?>
',
				       auc_title: '<?php 
            echo esc_js($wdm_single_auction->post_title);
            ?>
',
				       force_del:'yes'
				    };
				    $.post(ajaxurl, data, function(response) {
				    $('#wdm-rmv-frmwatch-<?php 
            echo $wdm_single_auction->ID;
            ?>
').html('<?php 
            _e("Remove From Watchlist", "wdm-ultimate-auction");
            ?>
');
				    alert(response);
				    window.location.reload();
				    });
				}
				return false;
				});
			      });
            </script>
			<?php 
        }
    }
    $wdm_my_watch .= '<input type="hidden" id="wdm_ua_auc_avail" value="' . $count_pages . '" />';
    //echo '<input type="hidden" id="wdm_ua_auc_avail" value="'.$count_pages.'" />';
    $c = ceil($count_pages / $page_num);
    wdm_auction_pagination($c, 1, $paged);
    return $wdm_my_watch;
}