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 / settings-page.php

settings-page.php in Ultimate WordPress Auction Plugin trunk, at settings-page.php

1,132 lines 43.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4 } // Exit if accessed directly
5
6 // handle basic plugin settings
7 if ( ! class_exists( 'wdm_settings' ) ) {
8
9 class wdm_settings {
10
11 var $auction_id;
12 var $auction_type;
13
14 // constructor
15 public function __construct() {
16 if ( is_admin() ) {
17 // call functions required only in admin section
18 add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
19 add_action( 'admin_init', array( $this, 'wdm_page_init' ) );
20 add_action( 'admin_notices', array( $this, 'wdm_admin_notices_action' ) );
21 add_action( 'admin_enqueue_scripts', array( $this, 'wdm_enqueue_style' ) );
22 add_action( 'wp_ajax_wdm_ajax', array( $this, 'wdm_ajax_callback' ) );
23 }
24 // register auction post
25 add_action( 'init', array( $this, 'wdm_reg_post_contents' ) );
26 }
27
28 public function wdm_reg_post_contents() {
29 // register custom post ultimate-auction
30 $args = array(
31 'public' => true,
32 'show_in_menu' => false,
33 'label' => 'Ultimate Auction',
34 'supports' => array( 'title', 'editor', 'author', 'excerpt', 'comments', 'custom-fields' ),
35 );
36 register_post_type( 'ultimate-auction', $args );
37
38 // code for adding taxonomy auction-status
39 $labels = array(
40 'name' => 'Auction Status',
41 );
42 $args = array(
43 'hierarchical' => true,
44 'labels' => $labels,
45 'show_ui' => true,
46 );
47 register_taxonomy(
48 'auction-status',
49 'ultimate-auction',
50 $args
51 );
52 // code for adding taxonomy auction-status ends here
53
54 // code for adding term live
55 if ( ! term_exists( 'live', 'auction-status' ) ) {
56 $r = wp_insert_term(
57 'live', // the term
58 'auction-status' // the taxonomy
59 );
60 }
61
62 // code for adding term expired
63 if ( ! term_exists( 'expired', 'auction-status' ) ) {
64 $r = wp_insert_term(
65 'expired', // the term
66 'auction-status' // the taxonomy
67 );
68 }
69
70 // enqueue validation files
71 wp_enqueue_script( 'wdm_jq_validate', plugins_url( '/js/wdm-jquery-validate.js', __FILE__ ), array( 'jquery' ),
72 "1.19.5", array("in_footer" => false) );
73
74 $trans_arr = array(
75 'req' => __( 'This field is required.' ),
76 'eml' => __( 'Please enter a valid email address.' ),
77 'url' => __( 'Please enter a valid URL.' ),
78 'num' => __( 'Please enter a valid number.' ),
79 'min' => __( 'Please enter a value greater than or equal to 0' ),
80 );
81
82 wp_localize_script( 'wdm_jq_validate', 'wdm_ua_obj_l10n', $trans_arr );
83 wp_enqueue_script( 'wdm_jq_valid', plugins_url( '/js/wdm-validate.js', __FILE__ ), array( 'jquery' ),
84 "1.0", array("in_footer" => false) );
85 }
86
87 /**
88 * AJAX callback to list bidders — 'See More' link on Manage Auctions page.
89 *
90 * @since 4.3.2
91 * @return void
92 */
93 public function wdm_ajax_callback() {
94
95 // Capability check — only admins may view bidder details.
96 if ( ! current_user_can( 'manage_options' ) ) {
97 wp_die( esc_html__( 'Permission denied', 'wdm-ultimate-auction' ) );
98 }
99
100 // Verify the nonce submitted from the JS side.
101 if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ) ), 'wdm_auction_listing_nonce' ) ) {
102 wp_die( esc_html__( 'Nonce verification failed', 'wdm-ultimate-auction' ) );
103 }
104
105 global $wpdb;
106 $currency_code = substr( get_option( 'wdm_currency' ), -3 );
107
108 $auctionid = absint( $_POST['auction_id'] ?? 0 );
109
110 if ( $_POST['show_rows'] == -1 ) {
111
112 $cache_key = 'auction_results_' . $auctionid;
113 $cache_group = 'auction_data';
114
115 $results = wp_cache_get( $cache_key, $cache_group );
116 if ( false === $results ) {
117 $query = $GLOBALS['wpdb']->get_results($wpdb->prepare(
118 "SELECT * FROM {$wpdb->prefix}wdm_bidders WHERE auction_id = %d
119 ORDER BY date DESC",
120 $auctionid
121 ));
122 } else {
123 $query = $GLOBALS['wpdb']->get_results($wpdb->prepare(
124 "SELECT * FROM {$wpdb->prefix}wdm_bidders WHERE auction_id = %d
125 ORDER BY date DESC",
126 $auctionid
127 ));
128 wp_cache_set( $cache_key, $results, $cache_group, 3600 );
129 }
130 } else {
131 $query = $GLOBALS['wpdb']->get_results($wpdb->prepare(
132 "SELECT * FROM {$wpdb->prefix}wdm_bidders WHERE auction_id = %d
133 ORDER BY date DESC LIMIT 5",
134 $auctionid
135 ));
136 }
137
138 $results = $query;
139 if ( ! empty( $results ) ) {
140 echo '<ul>';
141 foreach ( $results as $result ) {
142 ?>
143 <li><strong><a href='#'>
144 <?php echo esc_html( wdm_ua_display_username($result->name) ); ?></a></strong> -
145 <?php echo esc_html( $currency_code ) . ' ' . esc_html( $result->bid ); ?>
146 </li>
147 <?php
148 }
149 echo '</ul>';
150 }
151 wp_die();
152 }
153
154 public function wdm_admin_notices_action() {
155 settings_errors( 'test_option_group' );
156 }
157
158 // register menus and submenus
159 public function add_plugin_page() {
160 global $wp_version;
161 if ( $wp_version >= '3.8' ) {
162 $ua_icon_url = esc_url( plugins_url( 'img/favicon.png', __FILE__ ) );
163 } else {
164 $ua_icon_url = esc_url( plugins_url( 'img/favicon_black.png', __FILE__ ) );
165 }
166
167 add_menu_page( __( 'Ultimate Auction', 'wdm-ultimate-auction' ), __( 'Ultimate Auction', 'wdm-ultimate-auction' ), 'manage_options', 'ultimate-auction', array( $this, 'create_admin_page' ), $ua_icon_url );
168 add_submenu_page( 'ultimate-auction', __( 'Settings', 'wdm-ultimate-auction' ), __( 'Settings', 'wdm-ultimate-auction' ), 'manage_options', 'ultimate-auction', array( $this, 'create_admin_page' ) );
169 add_submenu_page( 'ultimate-auction', __( 'Payment', 'wdm-ultimate-auction' ), __( 'Payment', 'wdm-ultimate-auction' ), 'manage_options', 'payment', array( $this, 'create_admin_page' ) );
170 do_action( 'ua_add_submenu_after_setting', 'ultimate-auction', array( $this, 'create_admin_page' ) );
171 add_submenu_page( 'ultimate-auction', __( 'Add Auction', 'wdm-ultimate-auction' ), __( 'Add Auction', 'wdm-ultimate-auction' ), 'manage_options', 'add-new-auction', array( $this, 'create_admin_page' ) );
172 add_submenu_page( 'ultimate-auction', __( 'Manage Auctions', 'wdm-ultimate-auction' ), __( 'Manage Auctions', 'wdm-ultimate-auction' ), 'manage_options', 'manage_auctions', array( $this, 'create_admin_page' ) );
173 do_action( 'ua_add_auction_submenu', 'ultimate-auction', array( $this, 'create_admin_page' ) );
174 // add_submenu_page( 'ultimate-auction', __("Support", "wdm-ultimate-auction"), __("Support", "wdm-ultimate-auction"), 'manage_options', 'help-support', array($this, 'create_admin_page') );
175 add_submenu_page( 'ultimate-auction', __( 'PRO Features', 'wdm-ultimate-auction' ), __( "<span style='color:#ff9a4b'>PRO Features</span>", 'wdm-ultimate-auction' ), 'manage_options', 'wdm_why_pro', array( $this, 'wdm_why_pro_page_handler' ) );
176 }
177 public function wdm_why_pro_page_handler() {
178 include_once 'wdm-why-pro.php';
179 }
180
181 /**
182 * Enqueue admin JS and CSS files for the date picker and media upload.
183 *
184 * @since 4.3.2
185 * @return void
186 */
187 public function wdm_enqueue_style() {
188 if ( isset( $_GET['page'] ) && 'add-new-auction' === $_GET['page'] ) {
189 wp_enqueue_style( 'date-picker-style', plugins_url( '/css/jquery-ui.css', __FILE__ ),
190 array(), "1.0" );
191 wp_enqueue_script( 'jquery-timepicker-js', plugins_url( '/js/date-picker.js', __FILE__ ),
192 array( 'jquery', 'jquery-ui-datepicker' ), "1.4.3", array("in_footer" => false) );
193 wp_enqueue_style( 'jquery-timepicker-css', plugins_url( '/css/jquery-time-picker.css', __FILE__ ),
194 array(), "1.0" );
195 }
196
197 if ( isset( $_GET['page'] ) && 'manage_auctions' === $_GET['page'] ) {
198 wp_enqueue_script( 'wdm-ajax-scripts', plugins_url( '/js/wdm-ajax-scripts.js', __FILE__ ),
199 array( 'jquery' ), '1.0', array( 'in_footer' => false ) );
200 $trans_ar = array(
201 'msg1' => __( 'Showing All', 'wdm-ultimate-auction' ),
202 'msg2' => __( 'Showing Top 5', 'wdm-ultimate-auction' ),
203 'nonce' => wp_create_nonce( 'wdm_auction_listing_nonce' ),
204 );
205 wp_localize_script( 'wdm-ajax-scripts', 'wdm_ua_obj_l10n1', $trans_ar );
206 }
207 }
208
209 /**
210 * Render the main admin page with tabbed navigation.
211 *
212 * @since 4.3.2
213 * @return void
214 */
215 public function create_admin_page() {
216 ?>
217 <div class="wrap" id="wdm_auction_setID">
218 <h2>
219 <?php esc_html_e( 'Ultimate Auction', 'wdm-ultimate-auction' ); ?>
220 </h2>
221 </div>
222 <div class="uwa_setting_left">
223 <!--code for displaying tabbed navigation-->
224 <?php
225 $active_tab = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : 'ultimate-auction';
226
227 ?>
228
229
230 <h2 class="nav-tab-wrapper">
231 <a href="?page=ultimate-auction" class="nav-tab <?php echo $active_tab == 'ultimate-auction' ? 'nav-tab-active' : ''; ?>">
232 <?php esc_html_e( 'Settings', 'wdm-ultimate-auction' ); ?></a>
233 <a href="?page=payment" class="nav-tab <?php echo $active_tab == 'payment' ? 'nav-tab-active' : ''; ?>">
234 <?php esc_html_e( 'Payment', 'wdm-ultimate-auction' ); ?></a>
235 <?php do_action( 'ua_add_tab_after_setting', 'page', 'nav-tab', 'nav-tab-active', $active_tab ); ?>
236 <a href="?page=add-new-auction" class="nav-tab <?php echo $active_tab == 'add-new-auction' ? 'nav-tab-active' : ''; ?>">
237 <?php esc_html_e( 'Add Auction', 'wdm-ultimate-auction' ); ?></a>
238 <a href="?page=manage_auctions" class="nav-tab <?php echo $active_tab == 'manage_auctions' ? 'nav-tab-active' : ''; ?>">
239 <?php esc_html_e( 'Manage Auctions', 'wdm-ultimate-auction' ); ?></a>
240 <?php do_action( 'ua_add_auction_tab', 'page', 'nav-tab', 'nav-tab-active', $active_tab ); ?>
241
242
243 <a rel="nofollow" href="https://auctionplugin.net" style="background-color: #04be5b;color: #fff" target="_blank" class="nav-tab <?php echo $active_tab == 'help-support' ? 'nav-tab-active' : ''; ?>"></i>
244 <?php esc_html_e( 'Upgrade to PRO for more features', 'wdm-ultimate-auction' ); ?></a>
245 </h2>
246 <!--#code for displaying tabbed navigation-->
247
248 <?php
249 if ( $active_tab == 'ultimate-auction' ) {
250 if ( isset( $_GET['setting_section'] ) ) {
251 $manage_setting_tab = esc_attr( $_GET['setting_section'] );
252 } else {
253 $manage_setting_tab = 'payment';
254 }
255 ?>
256 <ul class="subsubsub">
257 <li><a href="?page=ultimate-auction&setting_section=payment" class="<?php echo $manage_setting_tab == 'payment' ? 'current' : ''; ?>">
258 <?php esc_html_e( 'Payment', 'wdm-ultimate-auction' ); ?></a>|</li>
259 <li><a href="?page=ultimate-auction&setting_section=auction" class="<?php echo $manage_setting_tab == 'auction' ? 'current' : ''; ?>">
260 <?php esc_html_e( 'Auction', 'wdm-ultimate-auction' ); ?></a>|</li>
261 <li><a href="?page=ultimate-auction&setting_section=email" class="<?php echo $manage_setting_tab == 'email' ? 'current' : ''; ?>">
262 <?php esc_html_e( 'Email', 'wdm-ultimate-auction' ); ?></a></li>
263 </ul><br class="clear">
264
265 <form id="auction-settings-form" class="auction_settings_section_style" method="post" action="options.php">
266 <?php
267 settings_fields( 'test_option_group' );// adds all the nonce/hidden fields and verifications
268 do_settings_sections( 'test-setting-admin' );
269 // echo wp_nonce_field('ua_setting_wp_n_f','ua_wdm_setting_auc');
270
271 $nonce_field = wp_nonce_field( 'ua_setting_wp_n_f', 'ua_wdm_setting_auc' );
272 echo wp_kses_post( $nonce_field );
273 ?>
274 <?php submit_button( __( 'Save Changes', 'wdm-ultimate-auction' ) ); ?>
275 </form>
276
277 <?php
278 } elseif ( $active_tab == 'manage_auctions' ) {
279 require_once 'manage-auctions.php';
280 } elseif ( $active_tab == 'add-new-auction' ) {
281 require_once 'add-new-auction.php';
282 } elseif ( $active_tab == 'help-support' ) {
283 require_once 'help-and-support.php';
284 } elseif ( $active_tab == 'payment' ) {
285 require_once 'payment.php';
286 }
287 do_action( 'ua_call_setting_file', $active_tab );
288 ?>
289 </div>
290 <div class="uwa_setting_right">
291
292 <div class="box_like_plugin">
293 <a href="#">
294 <div class="like_plugin">
295 <h2 class="title_uwa_setting">Like this plugin?</h2>
296 <div class="text_uwa_setting">
297 <div class="star_rating">
298 <form class="rating">
299 <label>
300 <input type="radio" name="stars" value="1" />
301 <span class="icon">�
302 </span>
303 </label>
304 <label>
305 <input type="radio" name="stars" value="2" />
306 <span class="icon">�
307 </span>
308 <span class="icon">�
309 </span>
310 </label>
311 <label>
312 <input type="radio" name="stars" value="3" />
313 <span class="icon">�
314 </span>
315 <span class="icon">�
316 </span>
317 <span class="icon">�
318 </span>
319 </label>
320 <label>
321 <input type="radio" name="stars" value="4" />
322 <span class="icon">�
323 </span>
324 <span class="icon">�
325 </span>
326 <span class="icon">�
327 </span>
328 <span class="icon">�
329 </span>
330 </label>
331 <label>
332 <input type="radio" name="stars" value="5" />
333 <span class="icon">�
334 </span>
335 <span class="icon">�
336 </span>
337 <span class="icon">�
338 </span>
339 <span class="icon">�
340 </span>
341 <span class="icon">�
342 </span>
343 </label>
344 </form>
345 </div>
346
347 <div class="happy_img">
348 <a target="_blank" href="https://wordpress.org/support/plugin/ultimate-auction/reviews?rate=5#new-post">
349 <img src="<?php echo esc_url( plugins_url( '/img/we_just_need_love.png', __FILE__ ) ); ?>" alt="<?php echo esc_attr( 'We Just Need Love' ); ?>" />
350 </a>
351 </div>
352 </div>
353 </div>
354 </a>
355 </div>
356
357 <div class="box_get_premium">
358 <div class="get_premium">
359 <div class="box_get_premium">
360 <a rel="nofollow" href="https://auctionplugin.net?utm_source=ultimate plugin&utm_medium=vertical banner&utm_campaign=learn more" target="_blank">
361 <img src="<?php echo esc_url( plugins_url( '/img/UWCA_col.jpg', __FILE__ ) ); ?>" alt="" />
362 </a>
363 </div>
364 </div>
365 </div>
366
367
368 </div>
369
370 </div>
371 <?php
372 if ( isset( $_GET['settings-updated'] ) ) {
373 echo "<div class='updated'><p><strong>" . esc_html__( 'Settings saved.', 'wdm-ultimate-auction' ) . '</strong></p></div>';
374 }
375 }
376
377 // create setting sections under 'Settings' tab to handle plugin configuration options
378 public function wdm_page_init() {
379
380 // enqueue css file for admin section style
381 wp_enqueue_style( 'ult_auc_be_css', plugins_url( '/css/ua-back-end.css', __FILE__ ),
382 array(), "1.0" );
383
384 register_setting(
385 'test_option_group',
386 'wdm_auc_settings_data',
387 array( $this, 'wdm_validate_save_data' )
388 );
389
390 $current_page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
391 $setting_section = isset( $_GET['setting_section'] ) ? sanitize_text_field( wp_unslash( $_GET['setting_section'] ) ) : '';
392
393 if ( 'ultimate-auction' === $current_page && 'auction' === $setting_section ) {
394 add_settings_section(
395 'setting_section_id', // this is the unique id for the section
396 __( 'General Settings', 'wdm-ultimate-auction' ), // title or name of the section that appears on the page
397 array( $this, 'print_section_info' ), // callback function
398 'test-setting-admin' // the parameter in do_settings_sections
399 );
400
401 add_settings_field(
402 'wdm_timezone_id',
403 __( 'Timezone', 'wdm-ultimate-auction' ),
404 array( $this, 'wdm_timezone_field' ),
405 'test-setting-admin',
406 'setting_section_id'
407 );
408 add_settings_field(
409 'wdm_allow_users_id',
410 __( 'Allow users to bid', 'wdm-ultimate-auction' ),
411 array( $this, 'wdm_allow_users_field' ),
412 'test-setting-admin',
413 'setting_section_id'
414 );
415
416 add_settings_field(
417 'wdm_layout_style_id',
418 __( 'Choose bid layout', 'wdm-ultimate-auction' ),
419 array( $this, 'wdm_layout_style_field' ),
420 'test-setting-admin',
421 'setting_section_id'
422 );
423
424 $bidding_engine = array();
425
426 $bidding_engine = apply_filters( 'ua_add_bidding_engine_option', $bidding_engine );
427
428 if ( ! empty( $bidding_engine ) ) {
429 add_settings_field(
430 'wdm_bidding_engines',
431 __( 'Default Bidding Engine', 'wdm-ultimate-auction' ),
432 array( $this, 'wdm_bid_engine_field' ),
433 'test-setting-admin',
434 'setting_section_id',
435 $bidding_engine
436 );
437 }
438
439 do_action( 'wdm_auto_extend_auction_endtime', 'test-setting-admin', 'setting_section_id' );
440
441 add_settings_field(
442 'wdm_auctions_page_num_id',
443 __( 'How many auctions should list on one feed page?', 'wdm-ultimate-auction' ),
444 array( $this, 'wdm_auctions_num_per_page' ),
445 'test-setting-admin',
446 'setting_section_id'
447 );
448
449 add_settings_field(
450 'wdm_auction_url_id',
451 __( 'Auction Page URL', 'wdm-ultimate-auction' ),
452 array( $this, 'wdm_auction_url_field' ),
453 'test-setting-admin',
454 'setting_section_id'
455 );
456
457 do_action( 'wdm_ua_after_auction_page_url_settings', 'test-setting-admin', 'setting_section_id' );
458
459 add_settings_field(
460 'wdm_login_url_id',
461 __( 'Login Page URL', 'wdm-ultimate-auction' ),
462 array( $this, 'wdm_login_url_field' ),
463 'test-setting-admin',
464 'setting_section_id'
465 );
466
467 add_settings_field(
468 'wdm_register_url_id',
469 __( 'Register Page URL', 'wdm-ultimate-auction' ),
470 array( $this, 'wdm_register_url_field' ),
471 'test-setting-admin',
472 'setting_section_id'
473 );
474
475 /*
476 add_settings_field(
477 'wdm_comment_set_id',
478 __("Show Comment Section", "wdm-ultimate-auction"),
479 array($this, 'wdm_comment_set_field'),
480 'test-setting-admin',
481 'setting_section_id'
482 );*/
483
484 add_settings_field(
485 'wdm_show_enddate_id',
486 __( 'Show Ending Date', 'wdm-ultimate-auction' ),
487 array( $this, 'wdm_show_enddate_field' ),
488 'test-setting-admin',
489 'setting_section_id'
490 );
491
492 add_settings_field(
493 'wdm_show_timezone_id',
494 __( 'Show Timezone', 'wdm-ultimate-auction' ),
495 array( $this, 'wdm_show_timezone_field' ),
496 'test-setting-admin',
497 'setting_section_id'
498 );
499
500 add_settings_field(
501 'wdm_show_prvt_msg_id',
502 __( 'Show Send Private Message', 'wdm-ultimate-auction' ),
503 array( $this, 'wdm_show_prvt_msg_field' ),
504 'test-setting-admin',
505 'setting_section_id'
506 );
507
508 } elseif ( 'ultimate-auction' === $current_page && 'email' === $setting_section ) {
509
510 add_settings_section(
511 'email_section_id', // this is the unique id for the section
512 __( 'Email Settings', 'wdm-ultimate-auction' ), // title or name of the section that appears on the page
513 array( $this, 'print_email_info' ), // callback function
514 'test-setting-admin' // the parameter in do_settings_sections
515 );
516
517 add_settings_field(
518 'wdm_email_id',
519 __( 'Email for receiving bid notification', 'wdm-ultimate-auction' ),
520 array( $this, 'wdm_email_field' ),
521 'test-setting-admin',
522 'email_section_id'
523 );
524 } else {
525
526 add_settings_section(
527 'payment_section_id',
528 __( 'Payment Settings', 'wdm-ultimate-auction' ),
529 array( $this, 'print_payment_info' ),
530 'test-setting-admin'
531 );
532
533 add_settings_field(
534 'wdm_currency_id',
535 __( 'Currency', 'wdm-ultimate-auction' ),
536 array( $this, 'wdm_currency_field' ),
537 'test-setting-admin',
538 'payment_section_id'
539 );
540
541 add_settings_field(
542 'wdm_payment_opt',
543 __( 'Enable Payment Options', 'wdm-ultimate-auction' ),
544 array( $this, 'wdm_set_payment_options' ),
545 'test-setting-admin',
546 'payment_section_id'
547 );
548 }
549 // enqueue script to handle validations related to bidding logic
550 wp_enqueue_script( 'wdm_logic_valid', plugins_url( '/js/logic-validation.js', __FILE__ ), array( 'jquery' ),
551 "1.0", array("in_footer" => false) );
552
553
554 $trans_a = array(
555 'pmt' => __( 'You should fill data for atleast one payment method.', 'wdm-ultimate-auction' ),
556 'ttl' => __( 'Please enter Product Title.', 'wdm-ultimate-auction' ),
557 'et' => __( 'Please enter Ending Date/Time.', 'wdm-ultimate-auction' ),
558 'set' => __( "You should fill PayPal email address in 'Settings' tab to enable 'Buy Now' feature.", 'wdm-ultimate-auction' ),
559 'opb' => __( 'Please enter Opening Price.', 'wdm-ultimate-auction' ),
560 'rp' => __( 'Please enter Lowest Price (Reserve Price).', 'wdm-ultimate-auction' ),
561 'ob' => __( 'Please enter either Opening Price or Buy Now price.', 'wdm-ultimate-auction' ),
562 'olp' => __( 'You have entered Opening Price. Please also enter Lowest Price (Reserve Price).', 'wdm-ultimate-auction' ),
563 'lpo' => __( 'You have entered Lowest Price. Please also enter Opening Price.', 'wdm-ultimate-auction' ),
564 'iop' => __( 'You have entered Incremental Value. Please also enter Opening Price.', 'wdm-ultimate-auction' ),
565 'rpo' => __( 'Lowest/Reserve price should be more than or equal to Opening Price.', 'wdm-ultimate-auction' ),
566 'bnl' => __( 'Buy Now price should be more than or equal to Lowest/Reserve price.', 'wdm-ultimate-auction' ),
567 'oinc' => __( 'Incremental Value should be greater than 0.', 'wdm-ultimate-auction' ),
568 );
569
570 wp_localize_script( 'wdm_logic_valid', 'wdm_ua_obj_l10nv', $trans_a );
571 }
572
573 // save/update fields under 'Settings tab'
574 public function wdm_validate_save_data( $input ) {
575 $mid = $input;
576
577 if ( isset( $_POST['ua_wdm_setting_auc'] ) && wp_verify_nonce(
578 $_POST['ua_wdm_setting_auc'],
579 'ua_setting_wp_n_f'
580 ) ) {
581
582 if ( isset( $mid['wdm_auction_email'] ) ) {
583 if ( is_email( $mid['wdm_auction_email'] ) ) {
584 update_option( 'wdm_auction_email', $mid['wdm_auction_email'] );
585 } else {
586 add_settings_error(
587 'test_option_group', // whatever you registered in register_setting
588 'wdm-error', // this will be appended to the div ID
589 __( 'Please enter a valid Email address', 'wdm-ultimate-auction' ),
590 'error' // error or notice works to make things pretty
591 );
592 $mid['wdm_auction_email'] = '';
593 }
594 }
595
596 if ( isset( $mid['wdm_time_zone'] ) ) {
597 update_option( 'wdm_time_zone', $mid['wdm_time_zone'] );
598 }
599
600 if ( isset( $mid['wdm_currency'] ) ) {
601 update_option( 'wdm_currency', $mid['wdm_currency'] );
602 }
603
604 if ( isset( $mid['wdm_auction_page_url'] ) ) {
605 update_option( 'wdm_auction_page_url', $mid['wdm_auction_page_url'] );
606 }
607
608 if ( isset( $mid['wdm_login_page_url'] ) ) {
609 update_option( 'wdm_login_page_url', $mid['wdm_login_page_url'] );
610 }
611
612 if ( isset( $mid['wdm_register_page_url'] ) ) {
613 update_option( 'wdm_register_page_url', $mid['wdm_register_page_url'] );
614 }
615
616 if ( isset( $mid['wdm_bidding_engines'] ) ) {
617 update_option( 'wdm_bidding_engines', $mid['wdm_bidding_engines'] );
618 }
619
620 /*
621 if(isset($mid['wdm_comment_set']))
622 update_option('wdm_comment_set',$mid['wdm_comment_set']);*/
623
624 if ( isset( $mid['wdm_show_enddate_msg'] ) ) {
625 update_option( 'wdm_show_enddate_msg', $mid['wdm_show_enddate_msg'] );
626 }
627
628 if ( isset( $mid['wdm_show_timezone_msg'] ) ) {
629 update_option( 'wdm_show_timezone_msg', $mid['wdm_show_timezone_msg'] );
630 }
631
632 if ( isset( $mid['wdm_show_prvt_msg'] ) ) {
633 update_option( 'wdm_show_prvt_msg', $mid['wdm_show_prvt_msg'] );
634 }
635
636 if ( isset( $mid['payment_options_enabled'] ) ) {
637 update_option( 'payment_options_enabled', $mid['payment_options_enabled'] );
638 }
639
640 if ( isset( $mid['wdm_auc_num_per_page'] ) ) {
641 update_option( 'wdm_auc_num_per_page', $mid['wdm_auc_num_per_page'] );
642 }
643
644 if ( isset( $mid['wdm_users_login'] ) ) {
645 update_option( 'wdm_users_login', $mid['wdm_users_login'] );
646 }
647
648 if ( isset( $mid['wdm_layout_style'] ) ) {
649 update_option( 'wdm_layout_style', $mid['wdm_layout_style'] );
650 }
651
652 do_action( 'wdm_ua_update_ext_settings' );
653
654 } else {
655 die( esc_html( __( 'Sorry, your nonce did not verify.', 'wdm-ultimate-auction' ) ) );
656 }
657 return $mid;
658 }
659
660 // 'Email Settings' section
661 public function print_email_info() {
662 }
663
664 // 'General Settings' section
665 public function print_section_info() {
666 }
667
668 // 'Payment Settings' section
669 public function print_payment_info() {
670 wp_enqueue_script( 'curr-detect', plugins_url( '/js/curr-detect.js', __FILE__ ), array( 'jquery' ),
671 "1.0", array("in_footer" => false) );
672 wp_localize_script( 'curr-detect', 'curr_script_vars', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
673 }
674
675 // auctions per page
676 public function wdm_auctions_num_per_page() {
677 add_option( 'wdm_auc_num_per_page', 20 );
678 ?>
679 <input class="wdm_settings_input number required" min="1" type="number" size="5" id="wdm_auctions_page_num_id" name="wdm_auc_settings_data[wdm_auc_num_per_page]" value="<?php echo esc_html( get_option( 'wdm_auc_num_per_page' ) ); ?>" />
680 <div class="ult-auc-settings-tip">
681 <?php esc_html_e( 'Please enter a number greater than or equal to 1.', 'wdm-ultimate-auction' ); ?>
682 </div>
683 <?php
684 }
685
686 // admin email field
687 public function wdm_email_field() {
688 ?>
689 <input class="wdm_settings_input email required" type="text" id="wdm_email_id" name="wdm_auc_settings_data[wdm_auction_email]" value="<?php echo esc_html( get_option( 'wdm_auction_email' ) ); ?>" />
690 <?php
691 }
692
693 // timezone field
694 public function wdm_timezone_field() {
695 $timezone_identifiers = DateTimeZone::listIdentifiers();
696
697 echo "<select class='wdm_settings_input required' id='wdm_timezone_id' name='wdm_auc_settings_data[wdm_time_zone]'>";
698 echo "<option value=''>" . esc_html( __( 'Select your Timezone', 'wdm-ultimate-auction' ) ) . '</option>';
699 foreach ( $timezone_identifiers as $time_ids ) {
700 $selected = ( get_option( 'wdm_time_zone' ) == $time_ids ) ? 'selected="selected"' : '';
701 ?>
702 <option value="<?php echo esc_attr( $time_ids ); ?>" <?php echo esc_attr( $selected ); ?>>
703 <?php echo esc_html( $time_ids ); ?>
704 </option>
705 <?php
706 }
707 echo '</select>';
708 echo '<div class="ult-auc-settings-tip">' . esc_html( __( 'Please select your local Timezone.', 'wdm-ultimate-auction' ) ) . '</div>';
709 }
710
711 // extra bidding engine field
712 public function wdm_bid_engine_field( $bidding_engine ) {
713
714 add_option( 'wdm_bidding_engines', 'Standard' );
715
716 echo '<select id="bidding_engines" name="wdm_auc_settings_data[wdm_bidding_engines]">
717 <option value="">' . esc_html( __( 'Simple Bidding', 'wdm-ultimate-auction' ) ) . '</option>';
718
719 foreach ( $bidding_engine as $be ) {
720 $select = get_option( 'wdm_bidding_engines' ) == $be['val'] ? 'selected' : '';
721 echo '<option value="' . esc_attr( $be['val'] ) . '" ' . esc_attr( $select ) . '>' . esc_attr( $be['text'] ) . '</option>';
722 }
723
724 echo '</select>';
725 echo '<div class="ult-auc-settings-tip">' . esc_html( __( 'Please select a default bidding engine.', 'wdm-ultimate-auction' ) ) . '</div>';
726 }
727
728 // currency codes field
729 public function wdm_currency_field() {
730 $b = '$b';
731 $U = '$U';
732 $currencies = array(
733 'Albania Lek -Lek ALL',
734 'Afghanistan Afghani -؋ AFN',
735 'Arab Emirates Dirham -د.إ AED',
736 'Argentina Peso -$ ARS',
737 'Aruba Guilder -ƒ AWG',
738 'Australian Dollar -$ AUD',
739 'Azerbaijan Manat -ман AZN',
740 'Bahamas Dollar -$ BSD',
741 'Barbados Dollar -$ BBD',
742 'Belarus Ruble -p. BYR',
743 'Belize Dollar -BZ$ BZD',
744 'Bermuda Dollar -$ BMD',
745 "Bolivia Boliviano -$b BOB",
746 'Bosnia and Herzegovina Convertible Marka -KM BAM',
747 'Botswana Pula -P BWP',
748 'Bulgaria Lev -лв BGN',
749 'Brazilian Real -R$ BRL',
750 'Brunei Dollar -$ BND',
751 'Cambodia Riel -៛ KHR',
752 'Canadian Dollar -$ CAD',
753 'Cayman Dollar -$ KYD',
754 'Chile Peso -$ CLP',
755 'China Yuan Renminbi -¥ CNY',
756 'Colombia Peso -$ COP',
757 'Costa Rica Colon -₡ CRC',
758 'Croatia Kuna -kn HRK',
759 'Cuba Peso -₱ CUP',
760 'Czech Koruna -Kč CZK',
761 'Danish Krone -kr DKK',
762 'Dominican Republic Peso -RD$ DOP',
763 'East Caribbean Dollar -$ XCD',
764 'Egypt Pound -£ EGP',
765 'El Salvador Colon -$ SVC',
766 'Estonia Kroon -kr EEK',
767 'Euro -€ EUR',
768 'Falkland Islands Pound -£ FKP',
769 'Fiji Dollar -$ FJD',
770 'Ghana Cedis -¢ GHC',
771 'Gibraltar Pound -£ GIP',
772 'Guatemala Quetzal -Q GTQ',
773 'Guernsey Pound -£ GGP',
774 'Guyana Dollar -$ GYD',
775 'Honduras Lempira -L HNL',
776 'Hong Kong Dollar -$ HKD',
777 'Hungarian Forint -kr HUF',
778 'Iceland Krona -kr ISK',
779 'India Rupee -₹ INR',
780 'Indonesia Rupiah -Rp IDR',
781 'Iran Rial -﷼ IRR',
782 'Isle of Man Pound -£ IMP',
783 'Israeli New Shekel -₪ ILS',
784 'Jamaica Dollar -J$ JMD',
785 'Japanese Yen -¥ JPY',
786 'Jersey Pound -£ JEP',
787 'Kazakhstan Tenge -лв KZT',
788 'Korea (North) Won -₩ KPW',
789 'Korea (South) Won -₩ KRW',
790 'Kyrgyzstan Som -лв KGS',
791 'Laos Kip -₭ LAK',
792 'Latvia Lat -Ls LVL',
793 'Lebanon Pound -£ LBP',
794 'Liberia Dollar -$ LRD',
795 'Lithuania Litas -Lt LTL',
796 'Macedonia Denar -ден MKD',
797 'Malaysian Ringgit -RM MYR',
798 'Mauritius Rupee -₨ MUR',
799 'Mexican Peso -$ MXN',
800 'Mongolia Tughrik -₮ MNT',
801 'Mozambique Metical -MT MZN',
802 'Namibia Dollar -$ NAD',
803 'Nepal Rupee -₨ NPR',
804 'Netherlands Antilles Guilder -ƒ ANG',
805 'New Zealand Dollar -$ NZD',
806 'Nicaragua Cordoba -C$ NIO',
807 'Nigeria Naira -₦ NGN',
808 'Norwegian Krone -kr NOK',
809 'Oman Rial -﷼ OMR',
810 'Pakistan Rupee -₨ PKR',
811 'Panama Balboa -B/. PAB',
812 'Paraguay Guarani -Gs PYG',
813 'Peru Nuevo Sol -S/. PEN',
814 'Philippine Peso -₱ PHP',
815 'Polish Zloty -zł PLN',
816 'Qatar Riyal -﷼ QAR',
817 'Romania New Leu -lei RON',
818 'Russia Ruble -руб RUB',
819 'Saint Helena Pound -£ SHP',
820 'Saudi Arabia Riyal -﷼ SAR',
821 'Serbia Dinar -Дин. RSD',
822 'Seychelles Rupee -₨ SCR',
823 'Singapore Dollar -$ SGD',
824 'Solomon Islands Dollar -$ SBD',
825 'Somalia Shilling -S SOS',
826 'South Africa Rand -R ZAR',
827 'Sri Lanka Rupee -₨ LKR',
828 'Swedish Krona -kr SEK',
829 'Swiss Franc -CHF CHF',
830 'Suriname Dollar -$ SRD',
831 'Syria Pound -£ SYP',
832 'New Taiwan Dollar -NT$ TWD',
833 'Tanzanian shilling -TSh TZS',
834 'Thai Baht -฿ THB',
835 'Trinidad and Tobago Dollar -TT$ TTD',
836 'Turkey Lira -₤ TRL',
837 'Tuvalu Dollar -$ TVD',
838 'Ukraine Hryvna -₴ UAH',
839 'British Pound -£ GBP',
840 'U.S. Dollar -$ USD',
841 "Uruguay Peso $U UYU",
842 'Uzbekistan Som -лв UZS',
843 'Venezuela Bolivar Fuerte -Bs VEF',
844 'Viet Nam Dong -₫ VND',
845 'Yemen Rial -﷼ YER',
846 'Zimbabwe Dollar -Z$ ZWD',
847 'Turkish Lira -₺ TRY',
848 );
849 $pp_currencies = array(
850 'Arab Emirates Dirham -د.إ AED',
851 'Australian Dollar -$ AUD',
852 'Canadian Dollar -$ CAD',
853 'Euro -€ EUR',
854 'British Pound -£ GBP',
855 'Japanese Yen -¥ JPY',
856 'U.S. Dollar -$ USD',
857 'New Zealand Dollar -$ NZD',
858 'Swiss Franc -CHF CHF',
859 'Hong Kong Dollar -$ HKD',
860 'Singapore Dollar -$ SGD',
861 'Swedish Krona -kr SEK',
862 'Danish Krone -kr DKK',
863 'Polish Zloty -zł PLN',
864 'Norwegian Krone -kr NOK',
865 'Hungarian Forint -kr HUF',
866 'Czech Koruna -Kč CZK',
867 'Israeli New Shekel -₪ ILS',
868 'Mexican Peso -$ MXN',
869 'Brazilian Real -R$ BRL',
870 'Malaysian Ringgit -RM MYR',
871 'Philippine Peso -₱ PHP',
872 'New Taiwan Dollar -NT$ TWD',
873 'Thai Baht -฿ THB',
874 'Turkish Lira -₺ TRY',
875 );
876
877 echo "<select class='wdm_settings_input' id='wdm_currency_id' name='wdm_auc_settings_data[wdm_currency]'>";
878 foreach ( $currencies as $currency ) {
879 $selected = ( substr( get_option( 'wdm_currency' ), -3 ) == substr( $currency, -3 ) ) ? 'selected="selected"' : '';
880
881 if ( ! in_array( $currency, $pp_currencies ) ) {
882 ?>
883 <option data-curr="<?php echo esc_attr( 'npl' ); ?>" value="<?php echo esc_attr( $currency ); ?>" <?php echo esc_attr( $selected ); ?>>
884 <?php echo esc_html( $currency ); ?>
885 </option>
886 <?php
887 } else {
888 ?>
889 <option value="<?php echo esc_attr( $currency ); ?>" <?php echo esc_attr( $selected ); ?>>
890 <?php echo esc_html( $currency ); ?>
891 </option>
892 <?php
893 }
894 }
895 echo '</select>';
896 echo ' <div id="nonpaypal" style="display: none; color: red;">' . esc_html( __( 'This currency is not available for PayPal.', 'wdm-ultimate-auction' ) ) . '</div>';
897 }
898
899 public function wdm_set_payment_options() {
900 $default = array(
901 'method_paypal' => __( 'PayPal', 'wdm-ultimate-auction' ),
902 'method_wire_transfer' => __( 'Wire Transfer', 'wdm-ultimate-auction' ),
903 'method_mailing' => __( 'Cheque', 'wdm-ultimate-auction' ),
904 'method_cash' => __( 'Cash', 'wdm-ultimate-auction' ),
905 );
906
907 $options = apply_filters( 'ua_add_new_payment_option', $default );
908
909 add_option( 'payment_options_enabled', array( 'method_paypal' => __( 'PayPal', 'wdm-ultimate-auction' ) ) );
910 $values = array();
911 foreach ( $options as $key => $option ) {
912 $values = get_option( 'payment_options_enabled' );
913 $values = ( ! empty( $values ) ) ? $values : array();
914 $checked = ( array_key_exists( $key, $values ) ) ? ' checked="checked" ' : '';
915
916 ?>
917 <input
918 <?php echo esc_attr( $checked ); ?>
919 value="<?php echo esc_attr( $option ); ?>"
920 name="wdm_auc_settings_data[payment_options_enabled][<?php echo esc_attr( $key ); ?>]"
921 type="checkbox"
922 class="wdm_<?php echo esc_attr( $key ); ?>"/>
923 <?php echo esc_html( $option ); ?>
924 <br />
925 <?php
926 }
927
928 echo '<br/><br/>';
929
930 esc_html_e( 'NOTE: If you choose to activate any payment method, please go to Payment tab and enter its details. For example: if you enable Wire Transfer, go to Payment -> Wire Transfer and enter its details. Same would apply to Paypal and Cheque.', 'wdm-ultimate-auction' );
931 }
932
933 // Auction feeder page URL
934 public function wdm_auction_url_field() {
935 ?>
936 <input type="text" class="wdm_settings_input url" id="wdm_auction_url_id" name="wdm_auc_settings_data[wdm_auction_page_url]" size="40" value="<?php echo esc_html( get_option( 'wdm_auction_page_url' ) ); ?>" />
937 <div>
938 <span class="ult-auc-settings-tip">
939 <?php esc_html_e( 'Enter your auction feeder page URL.', 'wdm-ultimate-auction' ); ?></span>
940
941 <a href="" class="auction_fields_tooltip"><strong>
942 <?php esc_html_e( '?', 'wdm-ultimate-auction' ); ?></strong>
943 <span style="width: 370px;margin-left: -90px;">
944 <?php esc_html_e( "If you want to make each auction title as a link to the front end single auction page in 'Title' columns of the plugin dashboard, you'll need to enter front end URL of the page where you have used shortcode for auctions listing.", 'wdm-ultimate-auction' ); ?>
945 <br /><br />
946 <?php esc_html_e( 'NOTE: Whenever you change the permalink, do not forget to enter the modified URL here. Also, if you select auction page as Home page, do not enter Home page URL, instead use actual full URL of the feeder page.', 'wdm-ultimate-auction' ); ?>
947 </span>
948 </a>
949 <br /><br />
950 <span class="ult-auc-settings-tip">
951 <?php esc_html_e( 'Use this shortcode in a page to make it auction feeder page:', 'wdm-ultimate-auction' ); ?></span>
952 <?php echo esc_html( '<code>[wdm_auction_listing]</code>' ); ?>
953 </div>
954 <?php
955 }
956
957 // Front end Login page URL
958 public function wdm_login_url_field() {
959 ?>
960 <input type="text" class="wdm_settings_input url" id="wdm_login_url_id" name="wdm_auc_settings_data[wdm_login_page_url]" size="40" value="<?php echo esc_html( get_option( 'wdm_login_page_url' ) ); ?>" />
961 <div>
962 <span class="ult-auc-settings-tip">
963 <?php esc_html_e( 'Enter Custom Login page URL (if have any).', 'wdm-ultimate-auction' ); ?></span>
964
965 <a href="" class="auction_fields_tooltip"><strong>
966 <?php esc_html_e( '?', 'wdm-ultimate-auction' ); ?></strong>
967 <span style="width: 370px;margin-left: -90px;">
968 <?php esc_html_e( 'If your site has a custom Login page and you want the bidders should log in through that page, you should set its URL here, so that while placing the bid, non logged in bidders should visit the custom Login page and not the default WordPress Login page. Please note, with the custom login URL the bidder will not be redirected automatically to the auction page where he/she was going to place the bid. As of now, this functionality works with the default WordPress Login page only. Also, whenever you change the permalink, do not forget to enter the modified URL over here.', 'wdm-ultimate-auction' ); ?>
969 <br /><br />
970 <?php esc_html_e( "NOTE: If your site uses default WordPress Login page. You don't need to set it.", 'wdm-ultimate-auction' ); ?>
971 </span>
972 </a>
973 </div>
974 <?php
975 }
976
977 // Front end Register page URL
978 public function wdm_register_url_field() {
979 ?>
980 <input type="text" class="wdm_settings_input url" id="wdm_register_url_id" name="wdm_auc_settings_data[wdm_register_page_url]" size="40" value="<?php echo esc_html( get_option( 'wdm_register_page_url' ) ); ?>" />
981 <div>
982 <span class="ult-auc-settings-tip">
983 <?php esc_html_e( 'Enter Custom Registration page URL (if have any).', 'wdm-ultimate-auction' ); ?></span>
984
985 <a href="" class="auction_fields_tooltip"><strong>
986 <?php esc_html_e( '?', 'wdm-ultimate-auction' ); ?></strong>
987 <span style="width: 370px;margin-left: -90px;">
988 <?php esc_html_e( 'If your site has a custom Register page and you want the bidders should register through that page, you should set its URL here, so that while placing the bid, non registered bidders should visit the custom Register page and not the default WordPress Register page. Also, whenever you change the permalink, do not forget to enter the modified URL over here.', 'wdm-ultimate-auction' ); ?>
989 <br /><br />
990 <?php esc_html_e( "NOTE: If your site uses default WordPress Register page. You don't need to set it.", 'wdm-ultimate-auction' ); ?>
991 </span>
992 </a>
993 </div>
994 <?php
995 }
996
997 // Comment set section
998 /*
999 public function wdm_comment_set_field(){
1000 $options = array("Yes", "No");
1001
1002 add_option('wdm_comment_set','Yes');
1003
1004 foreach($options as $option) {
1005 $checked = (get_option('wdm_comment_set')== $option) ? ' checked="checked" ' : '';
1006 echo "<input ".$checked." value='$option' name='wdm_auc_settings_data[wdm_comment_set]' type='radio' /> $option <br />";
1007 }
1008 printf("<div class='ult-auc-settings-tip'>".__("Choose Yes if you want to display comments tab under auction.", "wdm-ultimate-auction")."</div>");
1009 }*/
1010
1011 public function wdm_show_enddate_field() {
1012 $options = array( 'Yes', 'No' );
1013
1014 add_option( 'wdm_show_enddate_msg', 'Yes' );
1015
1016 foreach ( $options as $option ) {
1017 $checked = ( get_option( 'wdm_show_enddate_msg' ) == $option ) ? ' checked="checked" ' : '';
1018 echo '<input ' . esc_attr( $checked ) . " value='" . esc_attr( $option ) . "' name='wdm_auc_settings_data[wdm_show_enddate_msg]' type='radio' /> " . esc_attr( $option ) . " <br />";
1019 }
1020 printf( "<div class='ult-auc-settings-tip'>" . esc_html( __( 'Choose Yes if you want to display end date section.', 'wdm-ultimate-auction' ) ) . '</div>' );
1021 }
1022
1023 public function wdm_show_timezone_field() {
1024 $options = array( 'Yes', 'No' );
1025
1026 add_option( 'wdm_show_timezone_msg', 'Yes' );
1027
1028 foreach ( $options as $option ) {
1029 $checked = ( get_option( 'wdm_show_timezone_msg' ) == $option ) ? ' checked="checked" ' : '';
1030 echo '<input ' . esc_attr( $checked ) . " value='" . esc_attr( $option ) . "' name='wdm_auc_settings_data[wdm_show_timezone_msg]' type='radio' />" . esc_attr( $option ) . " <br />";
1031 }
1032 printf( "<div class='ult-auc-settings-tip'>" . esc_html( __( 'Choose Yes if you want to display timezone section.', 'wdm-ultimate-auction' ) ) . '</div>' );
1033 }
1034
1035 public function wdm_show_prvt_msg_field() {
1036 $options = array( 'Yes', 'No' );
1037
1038 add_option( 'wdm_show_prvt_msg', 'Yes' );
1039
1040 foreach ( $options as $option ) {
1041 $checked = ( get_option( 'wdm_show_prvt_msg' ) == $option ) ? ' checked="checked" ' : '';
1042 echo '<input ' . esc_attr( $checked ) . " value='" . esc_attr( $option ) . "' name='wdm_auc_settings_data[wdm_show_prvt_msg]' type='radio' /> " . esc_html( $option ) . " <br />";
1043 }
1044 printf( "<div class='ult-auc-settings-tip'>" . esc_html( __( 'Choose Yes if you want to display private message section.', 'wdm-ultimate-auction' ) ) . '</div>' );
1045 }
1046 public function wdm_allow_users_field() {
1047 $options = array( 'with_login', 'without_login' );
1048 add_option( 'wdm_users_login', 'with_login' );
1049 foreach ( $options as $option ) {
1050 $checked = ( get_option( 'wdm_users_login' ) == $option ) ? ' checked="checked" ' : '';
1051 if ( $option == 'with_login' ) {
1052 $opt = __( "Only if they are logged in", "wdm-ultimate-auction" );
1053 } else {
1054 $opt = __( "Without login as well", "wdm-ultimate-auction" );
1055 }
1056 echo '<input ' . esc_attr( $checked ) . " value='" . esc_attr( $option ) . "' name='wdm_auc_settings_data[wdm_users_login]' type='radio' />
1057 " . esc_html( $opt ) . " <br />";
1058 }
1059 echo "<br /><div class='ult-auc-settings-tip'>" . sprintf( esc_html__( "%1\$sPLEASE NOTE:%2\$s 'Without login as well' option is not compatible with Shipping and Proxy bidding add ons for ultimate auction. Also, for 'Buy it now' option, login is still compulsory.", 'wdm-ultimate-auction' ), '<strong>', '</strong>' ) . '</div>';
1060 }
1061
1062 public function wdm_layout_style_field() {
1063 $options = array( 'layout_style_one', 'layout_style_two' );
1064 foreach ( $options as $option ) {
1065 $checked = ( get_option( 'wdm_layout_style', 'layout_style_two' ) == $option ) ? ' checked="checked" ' : '';
1066 if ( $option == 'layout_style_one' ) {
1067 $opt = __( 'Enable the first layout', 'wdm-ultimate-auction' );
1068 } else {
1069 $opt = __( 'Enable the second layout', 'wdm-ultimate-auction' );
1070 }
1071 echo '<input ' . esc_attr( $checked ) . " value='" . esc_attr( $option ) . "' name='wdm_auc_settings_data[wdm_layout_style]' type='radio' /> " . esc_html( $opt ) . " <br />";
1072 }
1073 // echo "<br /><div class='ult-auc-settings-tip'>".sprintf(__("%sPLEASE NOTE:%s 'Without login as well' option is not compatible with Shipping and Proxy bidding add ons for ultimate auction. Also, for 'Buy it now' option, login is still compulsory.", "wdm-ultimate-auction"), '<strong>', '</strong>')."</div>";
1074 }
1075
1076
1077 // handle post meta keys
1078 public function wdm_post_meta( $meta_key ) {
1079 $wdm_settings_nonce = wp_create_nonce( 'wdm_settings_nonce' );
1080 if ( ! isset( $wdm_settings_nonce ) || ! wp_verify_nonce( $wdm_settings_nonce, 'wdm_settings_nonce' ) ) {
1081 wp_die( esc_html__( 'Nonce verification failed', 'wdm-ultimate-auction' ) );
1082 }
1083 if ( $this->auction_id != '' ) {
1084 return get_post_meta( $this->auction_id, $meta_key, true );
1085 } elseif ( isset( $_POST['update_auction'] ) && ! empty( $_POST['update_auction'] ) ) {
1086 return get_post_meta( esc_attr( $_POST['update_auction'] ), $meta_key, true );
1087 } elseif ( isset( $_GET['edit_auction'] ) && ! empty( $_GET['edit_auction'] ) ) {
1088 return get_post_meta( esc_attr( $_GET['edit_auction'] ), $meta_key, true );
1089 } else {
1090 return '';
1091 }
1092 }
1093
1094 public function wdm_set_auction( $args ) {
1095 $this->auction_id = $args;
1096 }
1097
1098 public function wdm_get_post() {
1099 $wdm_settings_nonce = wp_create_nonce( 'wdm_settings_nonce' );
1100 if ( ! isset( $wdm_settings_nonce ) || ! wp_verify_nonce( $wdm_settings_nonce, 'wdm_settings_nonce' ) ) {
1101 wp_die( esc_html__( 'Nonce verification failed', 'wdm-ultimate-auction' ) );
1102 }
1103 if ( $this->auction_id != '' ) {
1104 $auction = get_post( $this->auction_id );
1105 $single_auction['title'] = $auction->post_title;
1106 $single_auction['content'] = $auction->post_content;
1107 $single_auction['excerpt'] = $auction->post_excerpt;
1108 return $single_auction;
1109 } elseif ( isset( $_POST['update_auction'] ) && ! empty( $_POST['update_auction'] ) ) {
1110 $auction = get_post( esc_attr( $_POST['update_auction'] ) );
1111 $single_auction['title'] = $auction->post_title;
1112 $single_auction['content'] = $auction->post_content;
1113 $single_auction['excerpt'] = $auction->post_excerpt;
1114 return $single_auction;
1115 } elseif ( isset( $_GET['edit_auction'] ) && ! empty( $_GET['edit_auction'] ) ) {
1116 $auction = get_post( esc_attr( $_GET['edit_auction'] ) );
1117 $single_auction['title'] = $auction->post_title;
1118 $single_auction['content'] = $auction->post_content;
1119 $single_auction['excerpt'] = $auction->post_excerpt;
1120 return $single_auction;
1121 }
1122
1123 $this->auction_id = '';
1124 $single_auction['title'] = '';
1125 $single_auction['content'] = '';
1126 $single_auction['excerpt'] = '';
1127 return $single_auction;
1128 }
1129 }
1130 }
1131 $wctest = new wdm_settings();
1132 ?>