PluginProbe
Ultimate WordPress Auction Plugin / trunk
Ultimate WordPress Auction Plugin vtrunk
4.3.4 trunk 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 4.0.2 4.0.3
ultimate-auction / ultimate-auction.php

ultimate-auction.php in Ultimate WordPress Auction Plugin trunk, at ultimate-auction.php

1,264 lines 43.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 Plugin Name: Ultimate WordPress Auction Plugin
5 Plugin URI: https://auctionplugin.net
6 Description: Awesome plugin to host auctions on your WordPress site and sell anything you want.
7 Author: Nitesh Singh
8 Author URI: https://auctionplugin.net
9 Version: 4.3.4
10 Text Domain: wdm-ultimate-auction
11 License: GPLv2
12 Copyright 2026 Nitesh Singh
13 */
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 } // Exit if accessed directly
18
19 load_plugin_textdomain( 'wdm-ultimate-auction', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
20
21 require_once 'settings-page.php';
22 require_once 'auction-shortcode.php';
23 require_once 'send-auction-email.php';
24
25 // create a table for auction bidders on plugin activation
26 register_activation_hook( __FILE__, 'wdm_create_bidders_table' );
27
28
29 function wdm_create_bidders_table() {
30
31 require_once ABSPATH . 'wp-admin/includes/upgrade.php';
32 global $wpdb;
33
34 $data_table = $wpdb->prefix . 'wdm_bidders';
35 $sql = "CREATE TABLE IF NOT EXISTS $data_table
36 (
37 id MEDIUMINT(9) NOT NULL AUTO_INCREMENT,
38 name VARCHAR(45),
39 email VARCHAR(45),
40 auction_id BIGINT(20),
41 bid DECIMAL(10,2),
42 date datetime,
43 PRIMARY KEY (id)
44 );";
45
46 dbDelta( $sql );
47
48 // for old table (till 'WordPress Auction Plugin' version 1.0.2) which had 'bid' column as integer(MEDIUMINT)
49 /*
50 $alt_sql = "ALTER TABLE $data_table MODIFY bid DECIMAL(10,2);";
51 $wpdb->query($alt_sql);
52
53 //for old table which had 'bid' column without index
54 $alt_sql = "ALTER TABLE $data_table ADD INDEX (bid);";
55 $wpdb->query($alt_sql);*/
56
57 /*$indx = $wpdb->get_results("SHOW indexes FROM $data_table WHERE Column_name = 'bid';");*/
58
59 $columnname = 'bid';
60 $show_qry = $GLOBALS['wpdb']->get_results($wpdb->prepare(
61 "SHOW indexes FROM {$wpdb->prefix}wdm_bidders WHERE
62 Column_name = %s",
63 $columnname
64 ));
65
66 $indx = $show_qry;
67
68 for ( $i = 2; $i <= count( $indx ); $i++ ) {
69 $index_name = 'bid_' . intval( $i ); // Ensure $i is an integer to avoid SQL injection
70 $alt_sql = $GLOBALS['wpdb']->query($wpdb->prepare("ALTER TABLE {$wpdb->prefix}wdm_bidders DROP INDEX %s",
71 $index_name));
72 /*$alt_sql = $wpdb->query("ALTER TABLE {$wpdb->prefix}wdm_bidders DROP INDEX bid_" . $i . ';');*/
73 //$wpdb->query( $alt_sql );
74 }
75 }
76
77 // create feed page along with shortcode on plugin activation
78 register_activation_hook( __FILE__, 'wdm_create_shortcode_pages' );
79
80 function wdm_create_shortcode_pages() {
81
82 $option = 'ua_page_exists';
83 $default = array();
84 $default = get_option( $option );
85
86 if ( ! isset( $default['listing'] ) ) {
87
88 $feed_page = array(
89 'post_type' => 'page',
90 'post_title' => __( 'Auctions', 'wdm-ultimate-auction' ),
91 'post_status' => 'publish',
92 'post_content' => '[wdm_auction_listing]',
93 );
94
95 $id = wp_insert_post( $feed_page );
96
97 if ( ! empty( $id ) ) {
98 $default['listing'] = $id;
99 update_option( $option, $default );
100 }
101 }
102 }
103
104 /**
105 * AJAX callback to send winner email when an auction expires.
106 *
107 * Triggered automatically via JavaScript on wp_footer/admin_head.
108 * Reads auction data directly from the database — never trusts
109 * user-supplied title/content/email via POST.
110 *
111 * @since 4.3.2
112 * @return void
113 */
114 function send_auction_email_callback() {
115
116 // Only administrators may trigger winner emails.
117 if ( ! current_user_can( 'manage_options' ) ) {
118 wp_send_json_error( array( 'message' => __( 'Unauthorized', 'wdm-ultimate-auction' ) ), 403 );
119 wp_die();
120 }
121
122 if ( ! isset( $_POST['uwaajax_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['uwaajax_nonce'] ) ), 'uwaajax_nonce' ) ) {
123 wp_send_json_error( array( 'message' => __( 'Nonce verification failed', 'wdm-ultimate-auction' ) ), 403 );
124 wp_die();
125 }
126
127 $auc_id = absint( $_POST['auc_id'] ?? 0 );
128 if ( ! $auc_id ) {
129 wp_send_json_error( array( 'message' => __( 'Invalid auction ID', 'wdm-ultimate-auction' ) ), 400 );
130 wp_die();
131 }
132
133 $mail_sent = get_post_meta( $auc_id, 'wdm_won_email_sent', true );
134 if ( 'yes' === $mail_sent ) {
135 wp_die();
136 }
137
138 // Read trusted data from the database — do NOT use base64-decoded POST data.
139 $auc_post = get_post( $auc_id );
140 if ( ! $auc_post || 'ultimate-auction' !== $auc_post->post_type ) {
141 wp_send_json_error( array( 'message' => __( 'Invalid auction', 'wdm-ultimate-auction' ) ), 404 );
142 wp_die();
143 }
144
145 $auc_bid = round( (float) ( $_POST['auc_bid'] ?? 0 ), 2 );
146 $auc_url = isset( $_POST['auc_url'] ) ? esc_url_raw( wp_unslash( $_POST['auc_url'] ) ) : '';
147
148 global $wpdb;
149 $winner_email = $wpdb->get_var( $wpdb->prepare(
150 "SELECT email FROM {$wpdb->prefix}wdm_bidders WHERE bid = %f AND auction_id = %d ORDER BY id DESC LIMIT 1",
151 $auc_bid,
152 $auc_id
153 ) );
154
155 if ( ! empty( $winner_email ) ) {
156 $sent_email = ultimate_auction_email_template(
157 $auc_post->post_title,
158 $auc_id,
159 $auc_post->post_content,
160 $auc_bid,
161 sanitize_email( $winner_email ),
162 $auc_url
163 );
164
165 if ( $sent_email ) {
166 update_post_meta( $auc_id, 'wdm_won_email_sent', 'yes' );
167 } else {
168 update_post_meta( $auc_id, 'wdm_to_be_sent', '' );
169 }
170 }
171
172 wp_die();
173 }
174
175 // Admin-only: no nopriv hook — unauthenticated users must not trigger winner emails.
176 add_action( 'wp_ajax_send_auction_email', 'send_auction_email_callback' );
177
178 /**
179 * AJAX callback to resend winner email from the Manage Auctions page.
180 *
181 * Reads auction data directly from the database — never trusts
182 * user-supplied title/content/email via POST.
183 *
184 * @since 4.3.2
185 * @return void
186 */
187 function resend_auction_email_callback() {
188
189 // Only administrators may resend winner emails.
190 if ( ! current_user_can( 'manage_options' ) ) {
191 wp_send_json_error( array( 'message' => __( 'Unauthorized', 'wdm-ultimate-auction' ) ), 403 );
192 wp_die();
193 }
194
195 if ( ! isset( $_POST['uwaajax_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['uwaajax_nonce'] ) ), 'uwaajax_nonce' ) ) {
196 wp_send_json_error( array( 'message' => __( 'Nonce verification failed', 'wdm-ultimate-auction' ) ), 403 );
197 wp_die();
198 }
199
200 $auc_id = absint( $_POST['a_id'] ?? 0 );
201 if ( ! $auc_id ) {
202 wp_send_json_error( array( 'message' => __( 'Invalid auction ID', 'wdm-ultimate-auction' ) ), 400 );
203 wp_die();
204 }
205
206 // Read trusted data from the database — do NOT use base64-decoded POST data.
207 $auc_post = get_post( $auc_id );
208 if ( ! $auc_post || 'ultimate-auction' !== $auc_post->post_type ) {
209 wp_send_json_error( array( 'message' => __( 'Invalid auction', 'wdm-ultimate-auction' ) ), 404 );
210 wp_die();
211 }
212
213 $a_bid = round( (float) ( $_POST['a_bid'] ?? 0 ), 2 );
214 $a_url = isset( $_POST['a_url'] ) ? esc_url_raw( wp_unslash( $_POST['a_url'] ) ) : '';
215
216 global $wpdb;
217 $winner_email = $wpdb->get_var( $wpdb->prepare(
218 "SELECT email FROM {$wpdb->prefix}wdm_bidders WHERE bid = %f AND auction_id = %d ORDER BY id DESC LIMIT 1",
219 $a_bid,
220 $auc_id
221 ) );
222
223 $res_email = ultimate_auction_email_template(
224 $auc_post->post_title,
225 $auc_id,
226 $auc_post->post_content,
227 $a_bid,
228 sanitize_email( $winner_email ),
229 $a_url
230 );
231
232 if ( $res_email ) {
233 esc_html_e( 'Email sent successfully.', 'wdm-ultimate-auction' );
234 } else {
235 esc_html_e( 'Sorry, the email could not be sent.', 'wdm-ultimate-auction' );
236 }
237
238
239 wp_die();
240 }
241
242 // Admin-only: no nopriv hook.
243 add_action( 'wp_ajax_resend_auction_email', 'resend_auction_email_callback' );
244
245 /**
246 * AJAX callback to delete a single auction and its associated data.
247 *
248 * Verifies nonce and checks that the current user either owns the auction
249 * or has the manage_options capability before proceeding.
250 *
251 * @since 4.3.2
252 * @return void
253 */
254 function delete_auction_callback() {
255 global $wpdb;
256
257 // Verify nonce for security.
258 if ( ! isset( $_POST['uwaajax_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['uwaajax_nonce'] ) ), 'uwaajax_nonce' ) ) {
259 wp_send_json_error( array( 'message' => __( 'Nonce verification failed', 'wdm-ultimate-auction' ) ), 403 );
260 wp_die();
261 }
262
263 // Ensure the auction ID is passed and sanitized
264 if ( !isset( $_POST['del_id'] ) || empty( $_POST['del_id'] ) ) {
265 wp_send_json_error( array( 'message' => __( 'Missing auction ID', 'wdm-ultimate-auction' ) ), 400 );
266 wp_die();
267 }
268
269 $delete_post_id = absint( $_POST['del_id'] );
270 $force_delete = ( isset( $_POST['force_del'] ) && 'yes' === $_POST['force_del'] );
271
272 // Validate the auction post.
273 $post = get_post( $delete_post_id );
274 if ( ! $post || 'ultimate-auction' !== $post->post_type ) {
275 wp_send_json_error( array( 'message' => __( 'Invalid auction post ID', 'wdm-ultimate-auction' ) ), 404 );
276 wp_die();
277 }
278
279 // Allow admins (manage_options) or the post author with delete capability.
280 $is_owner = ( (int) $post->post_author === get_current_user_id() ) && current_user_can( 'delete_posts' );
281 $is_admin = current_user_can( 'manage_options' );
282 if ( ! $is_owner && ! $is_admin ) {
283 wp_send_json_error( array( 'message' => __( 'Permission denied', 'wdm-ultimate-auction' ) ), 403 );
284 wp_die();
285 }
286
287 $del_auc = wp_delete_post( $delete_post_id, $force_delete );
288
289 if ( $del_auc ) {
290 // Delete associated bidders.
291 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->prefix}wdm_bidders WHERE auction_id = %d", $delete_post_id ) );
292
293 // Delete associated attachments (images).
294 $image_urls = $wpdb->get_col( $wpdb->prepare(
295 "SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE meta_key LIKE %s AND post_id = %d",
296 '%wdm-image-%',
297 $delete_post_id
298 ) );
299
300 foreach ( $image_urls as $image_url ) {
301 if ( ! empty( $image_url ) ) {
302 $attachment_id = $wpdb->get_var( $wpdb->prepare(
303 "SELECT ID FROM {$wpdb->prefix}posts WHERE guid = %s AND post_type = 'attachment'",
304 $image_url
305 ) );
306 if ( $attachment_id ) {
307 wp_delete_post( (int) $attachment_id, true );
308 }
309 }
310 }
311
312 wp_send_json_success( array(
313 'message' => sprintf(
314 /* translators: %s is auction title */
315 esc_html__( 'Auction %s and its attachments have been deleted successfully.', 'wdm-ultimate-auction' ),
316 esc_html( $post->post_title )
317 ),
318 ) );
319 } else {
320 wp_send_json_error( array( 'message' => __( 'Failed to delete auction', 'wdm-ultimate-auction' ) ), 500 );
321 }
322
323 wp_die();
324 }
325
326 // Admin-only: no nopriv hook.
327 add_action( 'wp_ajax_delete_auction', 'delete_auction_callback' );
328
329 /**
330 * AJAX callback to delete multiple auctions at once.
331 *
332 * @since 4.3.2
333 * @return void
334 */
335 function multi_delete_auction_callback() {
336
337 global $wpdb;
338
339 if ( ! isset( $_POST['uwaajax_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['uwaajax_nonce'] ) ), 'uwaajax_nonce' ) ) {
340 wp_die( esc_html__( 'Nonce verification failed', 'wdm-ultimate-auction' ) );
341 }
342
343 if ( ! current_user_can( 'manage_options' ) ) {
344 wp_die( esc_html__( 'Permission denied', 'wdm-ultimate-auction' ) );
345 }
346
347 $force = ( isset( $_POST['force_del'] ) && 'yes' === $_POST['force_del'] );
348
349 // Sanitize each ID to a positive integer before use.
350 $raw_ids = isset( $_POST['del_ids'] ) ? sanitize_text_field( wp_unslash( $_POST['del_ids'] ) ) : '';
351 $all_aucs = array_filter( array_map( 'absint', explode( ',', $raw_ids ) ) );
352
353 foreach ( $all_aucs as $aa ) {
354 $delete_auction_array = $wpdb->get_col( $wpdb->prepare(
355 "SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE meta_key LIKE %s AND post_id = %d",
356 '%wdm-image-%',
357 $aa
358 ) );
359
360 $del_auc = wp_delete_post( $aa, false );
361 if ( $del_auc ) {
362 foreach ( $delete_auction_array as $delete_image_url ) {
363 if ( ! empty( $delete_image_url ) ) {
364 $auction_url_post_id = $wpdb->get_var( $wpdb->prepare(
365 "SELECT ID FROM {$wpdb->prefix}posts WHERE guid = %s AND post_type = 'attachment'",
366 $delete_image_url
367 ) );
368 if ( $auction_url_post_id ) {
369 wp_delete_post( (int) $auction_url_post_id, true );
370 }
371 }
372 }
373 }
374
375 $wpdb->query( $wpdb->prepare(
376 "DELETE FROM {$wpdb->prefix}wdm_bidders WHERE auction_id = %d",
377 $aa
378 ) );
379 }
380
381 if ( ! empty( $del_auc ) ) {
382 esc_html_e( 'Auctions and their attachments are deleted successfully.', 'wdm-ultimate-auction' );
383 } else {
384 esc_html_e( 'Sorry, the auctions cannot be deleted.', 'wdm-ultimate-auction' );
385 }
386
387 wp_die();
388 }
389
390 // Admin-only: no nopriv hook.
391 add_action( 'wp_ajax_multi_delete_auction', 'multi_delete_auction_callback' );
392
393 /**
394 * AJAX callback to manually end a live auction.
395 *
396 * Sets the auction's end date to now and marks its status as expired.
397 *
398 * @since 4.3.2
399 * @return void
400 */
401 function end_auction_callback() {
402
403 if ( ! current_user_can( 'manage_options' ) ) {
404 wp_die( esc_html__( 'Sorry, this auction cannot be ended.', 'wdm-ultimate-auction' ) );
405 }
406
407 if ( ! isset( $_POST['uwaajax_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['uwaajax_nonce'] ) ), 'uwaajax_nonce' ) ) {
408 wp_die( esc_html__( 'Nonce verification failed', 'wdm-ultimate-auction' ) );
409 }
410
411 $end_id = absint( $_POST['end_id'] ?? 0 );
412 $end_title = isset( $_POST['end_title'] ) ? sanitize_text_field( wp_unslash( $_POST['end_title'] ) ) : '';
413
414 $end_auc = update_post_meta( $end_id, 'wdm_listing_ends', gmdate( 'Y-m-d H:i:s', current_time( 'timestamp' ) ) );
415
416 $check_term = term_exists( 'expired', 'auction-status' );
417 wp_set_post_terms( $end_id, $check_term['term_id'], 'auction-status' );
418
419 if ( $end_auc ) {
420 /* translators: %s is auction name */
421 printf( esc_html__( 'Auction %s ended successfully.', 'wdm-ultimate-auction' ), esc_html( $end_title ) );
422 } else {
423 esc_html_e( 'Sorry, this auction cannot be ended.', 'wdm-ultimate-auction' );
424 }
425
426 wp_die();
427 }
428
429 // Admin-only: no nopriv hook.
430 add_action( 'wp_ajax_end_auction', 'end_auction_callback' );
431
432 /**
433 * AJAX callback to cancel (remove) the last bid entry from an auction.
434 *
435 * @since 4.3.2
436 * @return void
437 */
438 function cancel_last_bid_callback() {
439 global $wpdb;
440
441 if ( ! current_user_can( 'manage_options' ) ) {
442 wp_die( esc_html__( 'Sorry, bid entry cannot be removed.', 'wdm-ultimate-auction' ) );
443 }
444
445 if ( ! isset( $_POST['uwaajax_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['uwaajax_nonce'] ) ), 'uwaajax_nonce' ) ) {
446 wp_die( esc_html__( 'Nonce verification failed', 'wdm-ultimate-auction' ) );
447 }
448
449 $cid = absint( $_POST['cancel_id'] ?? 0 );
450 $bidder_name = isset( $_POST['bidder_name'] ) ? sanitize_text_field( wp_unslash( $_POST['bidder_name'] ) ) : '';
451
452 $cancel_bid = $wpdb->query( $wpdb->prepare(
453 "DELETE FROM {$wpdb->prefix}wdm_bidders WHERE id = %d",
454 $cid
455 ) );
456
457 if ( $cancel_bid ) {
458 /* translators: %s is bidder name */
459 printf( esc_html__( 'Bid entry of %s was removed successfully.', 'wdm-ultimate-auction' ), esc_html( wdm_ua_display_username($bidder_name) ) );
460 } else {
461 esc_html_e( 'Sorry, bid entry cannot be removed.', 'wdm-ultimate-auction' );
462 }
463
464 wp_die();
465 }
466
467 // Admin-only: no nopriv hook.
468 add_action( 'wp_ajax_cancel_last_bid', 'cancel_last_bid_callback' );
469
470 /**
471 * AJAX callback to place a bid on an auction.
472 *
473 * Available to both logged-in and guest users (when guest bidding is enabled).
474 * All monetary values are validated server-side regardless of JS validation.
475 *
476 * @since 4.3.2
477 * @return void
478 */
479 function place_bid_now_callback() {
480 if ( ! isset( $_POST['uwaajax_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['uwaajax_nonce'] ) ), 'uwaajax_nonce' ) ) {
481 wp_send_json_error( array( 'stat' => __( 'Nonce verification failed', 'wdm-ultimate-auction' ) ) );
482 wp_die();
483 }
484
485 if ( wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['uwaajax_nonce'] ) ), 'uwaajax_nonce' ) ) {
486
487 // Sanitize and validate bid amount server-side — never trust JS-only validation.
488 $ab_bid = round( (float) ( $_POST['ab_bid'] ?? 0 ), 2 );
489 if ( $ab_bid <= 0 ) {
490 echo wp_json_encode( array( 'stat' => 'inv_bid', 'bid' => 0 ) );
491 wp_die();
492 }
493
494 $check = get_option( 'wdm_users_login' );
495 $flag = false;
496 if ( $check == 'with_login' && ! is_user_logged_in() ) {
497 echo wp_json_encode( array( 'stat' => __( 'Please log in to place bid', 'wdm-ultimate-auction' ) ) );
498 wp_die();
499 } elseif ( $check == 'without_login' || is_user_logged_in() ) {
500 $flag = true;
501 }
502 if ( $flag ) {
503 global $wpdb;
504 $wpdb->hide_errors();
505
506 $auctionid = absint( $_POST['auction_id'] ?? 0 );
507 $n7_pre_qry = $GLOBALS['wpdb']->get_var($wpdb->prepare(
508 "SELECT MAX(bid) FROM {$wpdb->prefix}wdm_bidders WHERE
509 auction_id = %d",
510 $auctionid
511 ));
512 $next_bid = $n7_pre_qry;
513
514 if ( ! empty( $next_bid ) ) {
515 update_post_meta( $auctionid, 'wdm_previous_bid_value', $next_bid );
516 $first_bid = 1;
517 }
518
519 if ( empty( $next_bid ) ) {
520 $next_bid = (float) $next_bid + (float) get_post_meta( $auctionid, 'wdm_incremental_val', true );
521 $first_bid = 0;
522 }
523 $high_bid = $next_bid;
524
525 if ( 1 === $first_bid ) {
526 $next_bid = $next_bid + get_post_meta( $auctionid, 'wdm_incremental_val', true );
527 }
528
529 $terms = wp_get_post_terms( $auctionid, 'auction-status', array( 'fields' => 'names' ) );
530
531 $next_bid = round( $next_bid, 2 );
532
533 if ( $ab_bid < $next_bid ) {
534 echo wp_json_encode(
535 array(
536 'stat' => 'inv_bid',
537 'bid' => $next_bid,
538 )
539 );
540 } elseif ( in_array( 'expired', $terms ) ) {
541 echo wp_json_encode( array( 'stat' => 'Expired' ) );
542 } else {
543 // Sanitize bidder name and email.
544 $ab_name = isset( $_POST['ab_name'] ) ? sanitize_text_field( wp_unslash( $_POST['ab_name'] ) ) : '';
545 $ab_email = isset( $_POST['ab_email'] ) ? sanitize_email( wp_unslash( $_POST['ab_email'] ) ) : '';
546
547 $ab_bid = apply_filters(
548 'wdm_ua_modified_bid_amt',
549 $ab_bid,
550 $high_bid,
551 $auctionid
552 );
553
554 $a_bid = array();
555
556 if ( is_array( $ab_bid ) ) {
557 $a_bid = $ab_bid;
558 if ( ! empty( $a_bid['abid'] ) ) {
559 $ab_bid = $a_bid['abid'];
560 }
561
562 if ( ! empty( $a_bid['cbid'] ) ) {
563 $cu_bid = $a_bid['cbid'];
564 }
565
566 if ( ! empty( $a_bid['name'] ) ) {
567 $ab_name = $a_bid['name'];
568 }
569
570 if ( ! empty( $a_bid['email'] ) ) {
571 $ab_email = $a_bid['email'];
572 }
573 }
574
575 // Sanitize additional POST fields used in hook args.
576 $auc_name = isset( $_POST['auc_name'] ) ? sanitize_text_field( wp_unslash( $_POST['auc_name'] ) ) : '';
577 $auc_desc = isset( $_POST['auc_desc'] ) ? sanitize_textarea_field( wp_unslash( $_POST['auc_desc'] ) ) : '';
578 $auc_url = isset( $_POST['auc_url'] ) ? esc_url_raw( wp_unslash( $_POST['auc_url'] ) ) : '';
579 $ab_char = isset( $_POST['ab_char'] ) ? sanitize_text_field( wp_unslash( $_POST['ab_char'] ) ) : '';
580
581 $buy_price = get_post_meta( $auctionid, 'wdm_buy_it_now', true );
582
583 if ( ! empty( $buy_price ) && $ab_bid >= $buy_price ) {
584 add_post_meta( $auctionid, 'wdm_this_auction_winner', $ab_email, true );
585
586 if ( get_post_meta( $auctionid, 'wdm_this_auction_winner', true ) === $ab_email ) {
587 if ( ! empty( $a_bid ) ) {
588 do_action(
589 'wdm_ua_modified_bid_place',
590 array(
591 'email_type' => 'winner',
592 'mod_name' => $ab_name,
593 'mod_email' => $ab_email,
594 'mod_bid' => $ab_bid,
595 'orig_bid' => $cu_bid,
596 'orig_name' => $ab_name,
597 'orig_email' => $ab_email,
598 'auc_name' => $auc_name,
599 'auc_desc' => $auc_desc,
600 'auc_url' => $auc_url,
601 'site_char' => $ab_char,
602 'auc_id' => $auctionid,
603 )
604 );
605 } else {
606 $place_bid = $wpdb->insert(
607 $wpdb->prefix . 'wdm_bidders',
608 array(
609 'name' => $ab_name,
610 'email' => $ab_email,
611 'auction_id' => $auctionid,
612 'bid' => $ab_bid,
613 'date' => gmdate( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
614 ),
615 array( '%s', '%s', '%d', '%f', '%s' )
616 );
617
618 if ( $place_bid ) {
619 update_post_meta( $auctionid, 'wdm_listing_ends', gmdate( 'Y-m-d H:i:s', current_time( 'timestamp' ) ) );
620 $check_term = term_exists( 'expired', 'auction-status' );
621 wp_set_post_terms( $auctionid, $check_term['term_id'], 'auction-status' );
622 update_post_meta( $auctionid, 'email_sent_imd', 'sent_imd' );
623
624 echo wp_json_encode( array(
625 'type' => 'simple',
626 'stat' => 'Won',
627 'bid' => $ab_bid,
628 ) );
629 }
630 }
631 } else {
632 echo wp_json_encode( array( 'stat' => 'Sold' ) );
633 }
634 } else {
635
636 if ( ! empty( $a_bid ) ) {
637 do_action(
638 'wdm_ua_modified_bid_place',
639 array(
640 'mod_name' => $ab_name,
641 'mod_email' => $ab_email,
642 'mod_bid' => $ab_bid,
643 'orig_bid' => $cu_bid,
644 'orig_name' => $ab_name,
645 'orig_email' => $ab_email,
646 'auc_name' => $auc_name,
647 'auc_desc' => $auc_desc,
648 'auc_url' => $auc_url,
649 'site_char' => $ab_char,
650 'auc_id' => $auctionid,
651 )
652 );
653 } else {
654 do_action( 'wdm_extend_auction_time', $auctionid );
655
656 $place_bid = $wpdb->insert(
657 $wpdb->prefix . 'wdm_bidders',
658 array(
659 'name' => $ab_name,
660 'email' => $ab_email,
661 'auction_id' => $auctionid,
662 'bid' => $ab_bid,
663 'date' => gmdate( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
664 ),
665 array( '%s', '%s', '%d', '%f', '%s' )
666 );
667
668 if ( $place_bid ) {
669 echo wp_json_encode( array(
670 'type' => 'simple',
671 'stat' => 'Placed',
672 'bid' => $ab_bid,
673 )
674 );
675 }
676 }
677 }
678 }
679 } else {
680 echo wp_json_encode( array( 'stat' => 'Please log in to place bid' ) );
681 }
682 } /* end of if */
683
684 die();
685 }
686
687 add_action( 'wp_ajax_place_bid_now', 'place_bid_now_callback' );
688 add_action( 'wp_ajax_nopriv_place_bid_now', 'place_bid_now_callback' );
689
690 /**
691 * AJAX callback to send bid notification emails to seller, bidder, and outbid users.
692 *
693 * @since 4.3.2
694 * @return void
695 */
696 function bid_notification_callback() {
697
698 if ( ! isset( $_POST['uwaajax_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['uwaajax_nonce'] ) ), 'uwaajax_nonce' ) ) {
699 wp_die();
700 }
701
702 // Sanitize all POST inputs before use.
703 $ab_char = isset( $_POST['ab_char'] ) ? sanitize_text_field( wp_unslash( $_POST['ab_char'] ) ) : '';
704 $auc_url = isset( $_POST['auc_url'] ) ? esc_url_raw( wp_unslash( $_POST['auc_url'] ) ) : '';
705 $auc_id = absint( $_POST['auction_id'] ?? 0 );
706 $auc_name = isset( $_POST['auc_name'] ) ? sanitize_text_field( wp_unslash( $_POST['auc_name'] ) ) : '';
707 $auc_desc = isset( $_POST['auc_desc'] ) ? sanitize_textarea_field( wp_unslash( $_POST['auc_desc'] ) ) : '';
708 $ab_email = isset( $_POST['ab_email'] ) ? sanitize_email( wp_unslash( $_POST['ab_email'] ) ) : '';
709 $ab_name = isset( $_POST['ab_name'] ) ? sanitize_text_field( wp_unslash( $_POST['ab_name'] ) ) : '';
710 $md_bid = round( (float) ( $_POST['md_bid'] ?? 0 ), 2 );
711 $ab_bid = round( (float) ( $_POST['ab_bid'] ?? 0 ), 2 );
712
713 $ret_url = $auc_url . $ab_char . 'ult_auc_id=' . $auc_id;
714
715 $adm_email = get_option( 'wdm_auction_email' );
716
717 $hdr = "MIME-Version: 1.0\r\n";
718 $hdr .= "Content-type:text/html;charset=UTF-8\r\n";
719
720 wdm_ua_seller_notification_mail(
721 $adm_email,
722 $md_bid,
723 $ret_url,
724 $auc_name,
725 $auc_desc,
726 $ab_email,
727 $ab_name,
728 $hdr,
729 ''
730 );
731
732 wdm_ua_bidder_notification_mail(
733 $ab_email,
734 $ab_bid,
735 $ret_url,
736 $auc_name,
737 $auc_desc,
738 $hdr,
739 ''
740 );
741
742 // Outbid email — notify the previously highest bidder.
743 global $wpdb;
744 $wpdb->hide_errors();
745
746 $prev_bid = get_post_meta( $auc_id, 'wdm_previous_bid_value', true );
747
748 if ( ! empty( $prev_bid ) && $ab_bid > $prev_bid ) {
749 $bidder_email = $wpdb->get_var( $wpdb->prepare(
750 "SELECT email FROM {$wpdb->prefix}wdm_bidders WHERE bid = %f AND auction_id = %d",
751 $prev_bid,
752 $auc_id
753 ) );
754
755 if ( ! empty( $bidder_email ) && $bidder_email !== $ab_email ) {
756 wdm_ua_outbid_notification_mail(
757 sanitize_email( $bidder_email ),
758 $md_bid,
759 $ret_url,
760 $auc_name,
761 $auc_desc,
762 $hdr,
763 ''
764 );
765 }
766 }
767
768 // Auction won immediately via Buy Now.
769 if ( isset( $_POST['email_type'] ) && 'winner_email' === $_POST['email_type'] ) {
770 ultimate_auction_email_template(
771 $auc_name,
772 $auc_id,
773 $auc_desc,
774 $md_bid,
775 $ab_email,
776 $ret_url
777 );
778 }
779
780 wp_die();
781 }
782 add_action( 'wp_ajax_bid_notification', 'bid_notification_callback' );
783 add_action( 'wp_ajax_nopriv_bid_notification', 'bid_notification_callback' );
784
785 // private message Ajax callback - Single Auction page
786 function private_message_callback() {
787 if ( !wp_verify_nonce( $_POST['uwaajax_nonce'], 'uwaajax_nonce' ) ) {
788 wp_send_json_error('Nonce verification failed');
789 die();
790 }
791
792 $p_char = isset( $_POST['p_char'] ) ? sanitize_text_field( wp_unslash( $_POST['p_char'] ) ) : '';
793 $p_url = isset( $_POST['p_url'] ) ? esc_url_raw( wp_unslash( $_POST['p_url'] ) ) : '';
794 $p_auc_id = absint( $_POST['p_auc_id'] ?? 0 );
795 $p_name = isset( $_POST['p_name'] ) ? sanitize_text_field( wp_unslash( $_POST['p_name'] ) ) : '';
796 $p_email = isset( $_POST['p_email'] ) ? sanitize_email( wp_unslash( $_POST['p_email'] ) ) : '';
797 $p_msg = isset( $_POST['p_msg'] ) ? sanitize_textarea_field( wp_unslash( $_POST['p_msg'] ) ) : '';
798
799 $auc_url = $p_url . $p_char . 'ult_auc_id=' . $p_auc_id;
800
801 $adm_email = get_option( 'wdm_auction_email' );
802 if ( empty( $adm_email ) ) {
803 $adm_email = get_option( 'admin_email' );
804 }
805
806 $p_sub = '[' . get_bloginfo( 'name' ) . '] ' . __( 'You have a private message from a site visitor', 'wdm-ultimate-auction' );
807
808 $msg = __( 'Name', 'wdm-ultimate-auction' ) . ': ' . esc_html( $p_name ) . '<br /><br />';
809 $msg .= __( 'Email', 'wdm-ultimate-auction' ) . ': ' . esc_html( $p_email ) . '<br /><br />';
810 $msg .= __( 'Message', 'wdm-ultimate-auction' ) . ': <br />' . esc_html( $p_msg ) . '<br /><br />';
811 $msg .= __( 'Product URL', 'wdm-ultimate-auction' ) . ": <a href='" . esc_url( $auc_url ) . "'>" . esc_html( $auc_url ) . '</a><br />';
812
813 $hdr = 'Reply-To: <' . esc_attr( $p_email ) . "> \r\n";
814 $hdr .= "MIME-Version: 1.0\r\n";
815 $hdr .= "Content-type:text/html;charset=UTF-8\r\n";
816
817 $sent = wp_mail( $adm_email, $p_sub, $msg, $hdr, '' );
818
819 if ( $sent ) {
820 wp_send_json_success( __( 'Message sent successfully.', 'wdm-ultimate-auction' ) );
821 } else {
822 wp_send_json_error( __( 'Sorry, the email could not be sent.', 'wdm-ultimate-auction' ) );
823 }
824
825 wp_die();
826 }
827
828 add_action( 'wp_ajax_private_message', 'private_message_callback' );
829 add_action( 'wp_ajax_nopriv_private_message', 'private_message_callback' );
830
831 // plugin credit link
832 add_action( 'wp_footer', 'wdm_plugin_credit_link' );
833
834 function wdm_plugin_credit_link() {
835
836 $wdm_layout_style = get_option( 'wdm_layout_style', 'layout_style_two' );
837
838 if ( $wdm_layout_style == 'layout_style_one' ) {
839 wp_enqueue_style( 'wdm_auction_front_end_styling', plugins_url( 'css/ua-front-end-one.css', __FILE__ ),
840 array(), "1.0" );
841 } else {
842 wp_enqueue_style( 'wdm_auction_front_end_plugin_styling', plugins_url( 'css/ua-front-end-two.css', __FILE__ ),
843 array(), "1.0" );
844 }
845 }
846
847
848 add_action( 'init', 'wdm_set_auction_timezone' );
849 function wdm_set_auction_timezone() {
850 $get_default_timezone = get_option( 'wdm_time_zone' );
851 $timezone_string = get_option( 'timezone_string' );
852
853 if ( ! empty( $get_default_timezone ) ) {
854 return $timezone_string;
855 }
856
857 $wdm_settings_nonce = wp_create_nonce( 'wdm_settings_nonce' );
858 if ( ! isset( $wdm_settings_nonce ) || ! wp_verify_nonce( $wdm_settings_nonce, 'wdm_settings_nonce' ) ) {
859 wp_die( esc_html__( 'Nonce verification failed', 'wdm-ultimate-auction' ) );
860 }
861
862
863 if ( isset( $_GET['ult_auc_id'] ) && $_GET['ult_auc_id'] ) {
864
865 $single_auction = get_post( $_GET['ult_auc_id'] );
866
867 $auth_key = get_post_meta( $single_auction->ID, 'wdm-auth-key', true );
868
869 if ( isset( $_GET['wdm'] ) && $_GET['wdm'] === $auth_key ) {
870 $terms = wp_get_post_terms( $single_auction->ID, 'auction-status', array( 'fields' => 'names' ) );
871 if ( ! in_array( 'expired', $terms ) ) {
872 $chck_term = term_exists( 'expired', 'auction-status' );
873 wp_set_post_terms( $single_auction->ID, $chck_term['term_id'], 'auction-status' );
874 update_post_meta( $single_auction->ID, 'wdm_listing_ends', gmdate( 'Y-m-d H:i:s', current_time( 'timestamp' ) ) );
875 }
876
877 update_post_meta( $single_auction->ID, 'auction_bought_status', 'bought' );
878 update_post_meta( $single_auction->ID, 'wdm_auction_buyer', get_current_user_id() );
879 echo '<script type="text/javascript">
880 setTimeout(function() {
881 alert("' . esc_html__( 'Thank you for buying this product.', 'wdm-ultimate-auction' ) . '");
882 }, 1000);
883 </script>';
884
885 // details of a product sold through buy now link
886 if ( is_user_logged_in() ) {
887 $curr_user = wp_get_current_user();
888 $buyer_email = $curr_user->user_email;
889 $winner_name = $curr_user->user_login; // don't change here..
890 }
891
892 $auction_email = get_option( 'wdm_auction_email' );
893 $site_name = get_bloginfo( 'name' );
894 $site_url = get_bloginfo( 'url' );
895 $c_code = substr( get_option( 'wdm_currency' ), -3 );
896 $rec_email = get_option( 'wdm_paypal_address' );
897 $buy_now_price = get_post_meta( $single_auction->ID, 'wdm_buy_it_now', true );
898
899 $headers = '';
900 // $headers = "From: ". $site_name ." <". $auction_email ."> \r\n";
901 $headers .= 'Reply-To: <' . $buyer_email . "> \r\n";
902 $headers .= "MIME-Version: 1.0\r\n";
903 $headers .= 'Content-type:text/html;charset=UTF-8' . "\r\n";
904
905 $return_url = '';
906 $return_url = strstr( $_SERVER['REQUEST_URI'], 'ult_auc_id', true );
907 $return_url = $site_url . $return_url . 'ult_auc_id=' . $_GET['ult_auc_id'];
908
909 $auction_data = array(
910 'auc_id' => $single_auction->ID,
911 'auc_name' => $single_auction->post_title,
912 'auc_desc' => $single_auction->post_content,
913 'auc_price' => $buy_now_price,
914 'auc_currency' => $c_code,
915 'seller_paypal_email' => $rec_email,
916 'winner_email' => $buyer_email,
917 'seller_email' => $auction_email,
918 'winner_name' => $winner_name,
919 'pay_method' => 'method_paypal',
920 'site_name' => $site_name,
921 'site_url' => $site_url,
922 'product_url' => $return_url,
923 'header' => $headers,
924 );
925
926 $check_method = get_post_meta( $single_auction->ID, 'wdm_payment_method', true );
927
928 if ( $check_method === 'method_paypal' ) {
929 do_action( 'ua_shipping_data_email', $auction_data );
930 }
931 }
932 }
933 }
934
935 function wdm_ending_time_second_layout_calculator( $seconds ) {
936 $days = floor( $seconds / 86400 );
937 $seconds %= 86400;
938
939 $hours = floor( $seconds / 3600 );
940 $seconds %= 3600;
941
942 $minutes = floor( $seconds / 60 );
943 $seconds %= 60;
944
945 $rem_tm = '';
946
947 if ( $days == 1 || $days == -1 || $days == 0 ) {
948 $rem_tm = "<div class='days'><span class='wdm_datetime' id='wdm_days'>" . $days . "</span><span id='wdm_days_text'> " . __( 'day', 'wdm-ultimate-auction' ) . ' </span></div>';
949 } else {
950 $rem_tm = "<div class='days'><span class='wdm_datetime' id='wdm_days'>" . $days . "</span><span id='wdm_days_text'> " . __( 'days', 'wdm-ultimate-auction' ) . ' </span></div>';
951 }
952
953 if ( $hours == 1 || $hours == -1 || ( $hours == 0 ) ) {
954 $rem_tm .= "<div class='hours'><span class='wdm_datetime' id='wdm_hours'>" . $hours . "</span><span id='wdm_hrs_text'> " . __( 'hour', 'wdm-ultimate-auction' ) . ' </span></div>';
955 } else {
956 $rem_tm .= "<div class='hours'><span class='wdm_datetime' id='wdm_hours'>" . $hours . "</span><span id='wdm_hrs_text'> " . __( 'hours', 'wdm-ultimate-auction' ) . ' </span></div>';
957 }
958
959 if ( $minutes == 1 || $minutes == -1 || $minutes == 0 ) {
960 $rem_tm .= "<div class='minutes'><span class='wdm_datetime' id='wdm_minutes'>" . $minutes . "</span><span id='wdm_mins_text'> " . __( 'minute', 'wdm-ultimate-auction' ) . ' </span></div>';
961 } else {
962 $rem_tm .= "<div class='minutes'><span class='wdm_datetime' id='wdm_minutes'>" . $minutes . "</span><span id='wdm_mins_text'> " . __( 'minutes', 'wdm-ultimate-auction' ) . ' </span></div>';
963 }
964
965 if ( $seconds == 1 || $seconds == -1 || $seconds == 0 ) {
966 $rem_tm .= "<div class='second'><span class='wdm_datetime' id='wdm_seconds'>" . $seconds . "</span><span id='wdm_secs_text'> " . __( 'second', 'wdm-ultimate-auction' ) . '</span></div>';
967 } else {
968 $rem_tm .= "<div class='second'><span class='wdm_datetime' id='wdm_seconds'>" . $seconds . "</span><span id='wdm_secs_text'> " . __( 'seconds', 'wdm-ultimate-auction' ) . '</span></div>';
969 }
970
971 return $rem_tm;
972 }
973
974
975 function wdm_ending_time_calculator( $seconds ) {
976 $days = floor( $seconds / 86400 );
977 $seconds %= 86400;
978
979 $hours = floor( $seconds / 3600 );
980 $seconds %= 3600;
981
982 $minutes = floor( $seconds / 60 );
983 $seconds %= 60;
984
985 $rem_tm = '';
986
987 if ( $days == 1 || $days == -1 ) {
988 $rem_tm = "<span class='wdm_datetime' id='wdm_days'>" . $days . "</span><span id='wdm_days_text'> " . __( 'day', 'wdm-ultimate-auction' ) . ' </span>';
989 } elseif ( $days == 0 ) {
990 $rem_tm = "<span class='wdm_datetime' id='wdm_days' style='display:none;'>" . $days . "</span><span id='wdm_days_text'></span>";
991 } else {
992 $rem_tm = "<span class='wdm_datetime' id='wdm_days'>" . $days . "</span><span id='wdm_days_text'> " . __( 'days', 'wdm-ultimate-auction' ) . ' </span>';
993 }
994
995 if ( $hours == 1 || $hours == -1 ) {
996 $rem_tm .= "<span class='wdm_datetime' id='wdm_hours'>" . $hours . "</span><span id='wdm_hrs_text'> " . __( 'hour', 'wdm-ultimate-auction' ) . ' </span>';
997 } elseif ( $hours == 0 ) {
998 $rem_tm .= "<span class='wdm_datetime' id='wdm_hours' style='display:none;'>" . $hours . "</span><span id='wdm_hrs_text'></span>";
999 } else {
1000 $rem_tm .= "<span class='wdm_datetime' id='wdm_hours'>" . $hours . "</span><span id='wdm_hrs_text'> " . __( 'hours', 'wdm-ultimate-auction' ) . ' </span>';
1001 }
1002
1003 if ( $minutes == 1 || $minutes == -1 ) {
1004 $rem_tm .= "<span class='wdm_datetime' id='wdm_minutes'>" . $minutes . "</span><span id='wdm_mins_text'> " . __( 'minute', 'wdm-ultimate-auction' ) . ' </span>';
1005 } elseif ( $minutes == 0 ) {
1006 $rem_tm .= "<span class='wdm_datetime' id='wdm_minutes' style='display:none;'>" . $minutes . "</span><span id='wdm_mins_text'></span>";
1007 } else {
1008 $rem_tm .= "<span class='wdm_datetime' id='wdm_minutes'>" . $minutes . "</span><span id='wdm_mins_text'> " . __( 'minutes', 'wdm-ultimate-auction' ) . ' </span>';
1009 }
1010
1011 if ( $seconds == 1 || $seconds == -1 ) {
1012 $rem_tm .= "<span class='wdm_datetime' id='wdm_seconds'>" . $seconds . "</span><span id='wdm_secs_text'> " . __( 'second', 'wdm-ultimate-auction' ) . '</span>';
1013 } elseif ( $seconds == 0 ) {
1014 $rem_tm .= "<span class='wdm_datetime' id='wdm_seconds' style='display:none;'>" . $seconds . "</span><span id='wdm_secs_text'></span>";
1015 } else {
1016 $rem_tm .= "<span class='wdm_datetime' id='wdm_seconds'>" . $seconds . "</span><span id='wdm_secs_text'> " . __( 'seconds', 'wdm-ultimate-auction' ) . '</span>';
1017 }
1018
1019 return $rem_tm;
1020 }
1021
1022 add_filter( 'ua_list_winner_info', 'wdm_list_winner_info', 99, 4 );
1023
1024 function wdm_list_winner_info( $info, $winner, $id, $col ) {
1025
1026 if ( ! empty( $winner ) ) {
1027
1028 $info = "<a href='#' class='wdm_winner_info wdm-margin-bottom' id='wdm_winner_info_" . $col . '_' . $id . "'>" . wdm_ua_display_username($winner->user_login) . '</a>';
1029 $info .= "<div class='wdm-margin-bottom wdm_winner_info_" . $col . '_' . $id . "' style='display:none;'><div>";
1030 $info .= ! empty( $winner->first_name ) ? $winner->first_name : '';
1031 $info .= ! empty( $winner->last_name ) ? ' ' . $winner->last_name : '';
1032 $info .= "</div><div><a href='mailto:" . $winner->user_email . "'>" . $winner->user_email . '</a></div></div>';
1033 }
1034
1035 return $info;
1036 }
1037
1038 /**
1039 * Format a username for front-end display.
1040 *
1041 * If the user_login is (or contains) an email address, only the part
1042 * before the "@" is shown on front-end pages. The "@" and everything
1043 * after it is removed. Non-email usernames are returned unchanged.
1044 *
1045 * @param string $username The raw username (e.g. user_login).
1046 * @return string The username trimmed at the "@" for front-end display.
1047 */
1048 function wdm_ua_display_username( $username ) {
1049
1050 $username = (string) $username;
1051
1052 if ( is_email( $username ) ) {
1053 $at_pos = strpos( $username, '@' );
1054 $username = substr( $username, 0, $at_pos );
1055 }
1056
1057 return $username;
1058 }
1059
1060 /*
1061 add_filter('comment_post_redirect', 'redirect_after_comment');
1062 function redirect_after_comment($location)
1063 {
1064 return $_SERVER["HTTP_REFERER"];
1065 }*/
1066
1067 function prepare_single_auction_title( $id, $title ) {
1068
1069 $perma_type = get_option( 'permalink_structure' );
1070 if ( empty( $perma_type ) ) {
1071 $set_char = '&';
1072 } else {
1073 $set_char = '?';
1074 }
1075
1076 $auc_url = get_option( 'wdm_auction_page_url' );
1077
1078 if ( ! empty( $auc_url ) ) {
1079 $link_title = $auc_url . $set_char . 'ult_auc_id=' . $id;
1080 $link_title = "<a href='" . $link_title . "' target='_blank'>" . $title . '</a>';
1081 $title = $link_title;
1082 }
1083
1084 return $title;
1085 }
1086
1087 function paypal_auto_return_url_notes() {
1088
1089 $pp_ms = '<div class="paypal-config-note-text" style="float: right;width: 530px;">';
1090
1091 $pp_ms .= '<span class="pp-please-note">' . __( 'Mandatory Settings:', 'wdm-ultimate-auction' ) . '</span> <br />';
1092
1093
1094 /* translators: %1$s is auto return URL , %2$s is payment data transfer */
1095 $pp_ms .= '<span class="pp-url-notification">' . sprintf( __( 'It is mandatory to set %1$s (if not already set) and enable %2$s (if not already enabled) in your PayPal account for proper functioning of payment related features.', 'wdm-ultimate-auction' ), '<strong>Auto Return URL</strong>', '<strong>Payment Data Transfer</strong>' ) . '</span>';
1096
1097 $pp_ms .= '<a href="" class="auction_fields_tooltip"><strong>' . __( '?', 'wdm-ultimate-auction' ) . '</strong><span style="width: 370px;margin-left: -90px;">';
1098
1099 $pp_ms .= sprintf( __( "Whenever a visitor clicks on 'Buy it Now' button of a product/auction, he is redirected to PayPal where he can make payment for that product/auction.", 'wdm-ultimate-auction' ) ) . '<br />';
1100
1101 /* translators: %s is Auto return URL */
1102 $pp_ms .= sprintf( __( 'After making payment he is again redirected automatically (if the %s has been set) to this site and then the auction expires.', 'wdm-ultimate-auction' ), 'Auto Return URL' ) . '<br />';
1103
1104 $pp_ms .= '</span></a>';
1105
1106 $pp_ms .= '<br /><a href="#" id="how-set-pp-auto-return">' . __( 'How to do these settings?', 'wdm-ultimate-auction' ) . '</a><br />';
1107
1108 $pp_ms .= '<div id="wdm-steps-to-be-followed" style="display:none;"><br />';
1109
1110 $pp_ms .= sprintf( __( '1. Log in to your PayPal account', 'wdm-ultimate-auction' ) ) . '- <a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=_account" target="_blank">Live</a>/ <a href="https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_account" target="_blank">Sandbox</a><br />';
1111
1112
1113 /* translators: %s is account settings */
1114 $pp_ms .= sprintf( __( '2. Go to the %s.', 'wdm-ultimate-auction' ), '<strong>Account setting</strong>' ) . '<br />';
1115
1116 /* translators: %s is seller tools */
1117 $pp_ms .= sprintf( __( '3. Go to the %s menu.', 'wdm-ultimate-auction' ), '<strong>Seller Tools</strong>' ) . '<br />';
1118
1119 /* translators: %1$s is website preferences , %2$s is selling online section */
1120 $pp_ms .= sprintf( __( '4. Click %1$s under %2$s.', 'wdm-ultimate-auction' ), '<strong>Website preferences</strong>', '<strong>Selling online section</strong>' ) . '<br />';
1121
1122 /* translators: %s is website preferences */
1123 $pp_ms .= sprintf( __( '5. %s page will open.', 'wdm-ultimate-auction' ), '<strong>Website Preferences</strong>' ) . '<br />';
1124
1125 /* translators: %s is auto return */
1126 $pp_ms .= sprintf( __( '6. Enable %s.', 'wdm-ultimate-auction' ), '<strong>Auto Return</strong>' ) . '<br />';
1127
1128 /* translators: %s is return URL */
1129 $pp_ms .= sprintf( __( '7. Set a URL in %s box. Enter feed page URL.', 'wdm-ultimate-auction' ), '<strong>Return URL</strong>' ) . '<br />';
1130
1131 /* translators: %1$s is payment data transfer, %2$s is return URL, %3$ is PDT */
1132 $pp_ms .= sprintf( __( '8. Enable %1$s option (if the %2$s is not set, %3$s can not be enabled).', 'wdm-ultimate-auction' ), '<strong>PDT (Payment Data Transfer)</strong>', '<strong>Return URL</strong>', '<strong>PDT</strong>' ) . ' <br />';
1133
1134 $pp_ms .= '</div></div>';
1135
1136 $pp_ms .= '<script type="text/javascript">
1137 jQuery(document).ready(function(){
1138 jQuery("#how-set-pp-auto-return").click(
1139 function(){
1140 jQuery("#wdm-steps-to-be-followed").slideToggle("slow");
1141 jQuery("html, body").animate({scrollTop: jQuery(".paypal-config-note-text").offset().top - 50});
1142 return false;
1143 });
1144 });
1145 </script>';
1146
1147 return $pp_ms;
1148 }
1149
1150 require_once 'email-template.php';
1151
1152
1153 /* notice for premium auction plugin */
1154 function wdm_uwa_pro_add_plugins_notice() {
1155
1156 global $current_user;
1157 $user_id = $current_user->ID;
1158 if ( ! get_user_meta( $user_id, 'wdm_uwa_pro_ignore_notice' ) ) {
1159 ?>
1160
1161 <div class="notice notice-info">
1162 <div class="get_uwa_pro">
1163 <a rel="nofollow" href=" https://auctionplugin.net?utm_source=ultimate plugin&utm_medium=admin notice&utm_campaign=learn more" target="_blank"> <img src="<?php echo esc_url( plugins_url( '/img/UWCA_row.jpg', __FILE__ ) ); ?>" alt="" /> </a>
1164
1165 <?php
1166
1167 /* The dismiss link is a GET request, so the nonce must travel in the URL. */
1168 $dismiss_url = wp_nonce_url(
1169 add_query_arg( 'wdm_uwa_pro_ignore', '0' ),
1170 'ua_notice_wp_n_f',
1171 'ua_wdm_ignore_notice'
1172 );
1173
1174 /* translators: %1$s is querystring, %2$s is image URL */
1175 echo wp_kses( sprintf( __( '<a href="%1$s"><img src="%2$s" /></a>', 'ultimate-woocommerce-auction' ),
1176 esc_url( $dismiss_url ),
1177 esc_url( plugins_url( '/img/error.png', __FILE__ ) )
1178 ),
1179 array(
1180 'a' => array(
1181 'href' => array(),
1182 ),
1183 'img' => array(
1184 'src' => array(),
1185 ),
1186 )
1187 );
1188 ?>
1189
1190
1191 <div class="clear"></div>
1192 </div>
1193 </div>
1194 <?php
1195
1196 }
1197 }
1198 add_action( 'admin_notices', 'wdm_uwa_pro_add_plugins_notice' );
1199
1200 function wdm_uwa_pro_ignore() {
1201 global $current_user;
1202 $user_id = $current_user->ID;
1203 /* If user clicks to ignore the notice, add that to their user meta */
1204 if ( isset( $_GET['wdm_uwa_pro_ignore'] ) && '0' == $_GET['wdm_uwa_pro_ignore']
1205 && isset( $_GET['ua_wdm_ignore_notice'] )
1206 && wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['ua_wdm_ignore_notice'] ) ), 'ua_notice_wp_n_f' ) ) {
1207 add_user_meta( $user_id, 'wdm_uwa_pro_ignore_notice', 'true', true );
1208 }
1209 }
1210 add_action( 'admin_init', 'wdm_uwa_pro_ignore' );
1211
1212 add_action( 'admin_init', 'wdm_uwa_pro_ignore' );
1213
1214 function wdm_image_sizes() {
1215 add_image_size( 'wdm-list-slider-thumb', 160, 160, true );
1216 }
1217 add_action( 'init', 'wdm_image_sizes' );
1218
1219
1220 function wdm_uwa_plugin_layout_notice() {
1221
1222 global $current_user;
1223 $user_id = $current_user->ID;
1224 if ( ! get_user_meta( $user_id, 'wdm_uwa_plugin_layout_ignore_notice' ) ) {
1225
1226 /* The dismiss link is a GET request, so the nonce must travel in the URL. */
1227 $dismiss_url = wp_nonce_url(
1228 add_query_arg( 'wdm_uwa_plugin_layout_ignore', '0' ),
1229 'ua_layout_wp_n_f',
1230 'ua_wdm_ignore_layout'
1231 );
1232
1233 /* translators: %2$s is the dismiss URL */
1234
1235 echo '<div class="notice"><p>' . sprintf( wp_kses( __( '<b>Ultimate WordPress Auction Plugin:</b> Important Message - We have implemented a new layout for the auction list page and auction detail page. The new layout appears by default on both pages. We have given the option to change the layout for auction pages. So, the admin can set the old layout or new layout from the auction settings. <a href="%2$s">Hide Notice</a>', 'woo_ua' ),
1236 array(
1237 'b' => array(),
1238 'a' => array(
1239 'href' => array(),
1240 ),
1241 )
1242 ),
1243 esc_html( get_bloginfo( 'url' ) ),
1244 esc_url( $dismiss_url )
1245 ) . '</p></div>';
1246
1247 }
1248 }
1249 add_action( 'admin_notices', 'wdm_uwa_plugin_layout_notice' );
1250
1251 function wdm_uwa_plugin_layout_ignore() {
1252
1253 global $current_user;
1254 $user_id = $current_user->ID;
1255
1256 if ( isset( $_GET['wdm_uwa_plugin_layout_ignore'] ) && '0' == $_GET['wdm_uwa_plugin_layout_ignore']
1257 && isset( $_GET['ua_wdm_ignore_layout'] )
1258 && wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['ua_wdm_ignore_layout'] ) ), 'ua_layout_wp_n_f' ) ) {
1259 add_user_meta( $user_id, 'wdm_uwa_plugin_layout_ignore_notice', 'true', true );
1260 }
1261 }
1262
1263 add_action( 'admin_init', 'wdm_uwa_plugin_layout_ignore' );
1264 ?>