add_action( 'wp', 'custom_add_shortcodes' ); function custom_add_shortcodes() { add_shortcode( 'custom_auctions_recent_bids', 'custom_auctions_recent_bids' ); } function custom_auctions_recent_bids( $atts ) { global $wpdb; extract( shortcode_atts( array( 'limit' => 20, 'show_usernames' => 'yes', ), $atts ) ); $user_id = get_current_user_id(); $auction_activity = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'simple_auction_log ORDER BY date DESC limit %d ', $limit ) ); if ( $auction_activity ) { echo ''; echo ''; echo ''; echo ''; if ( 'yes' === $show_usernames ) { echo ''; } echo ''; echo ''; echo ''; foreach ( $auction_activity as $key => $value ) { if ( get_post_status( $value->auction_id ) === 'publish' ) { $class = ''; $product = wc_get_product( $value->auction_id ); if ( $product && $product->is_type( 'auction' ) ) { if ( $product->is_closed() ) { $class .= 'closed '; } if ( $product->get_auction_current_bider() === $user_id && ! $product->is_sealed() ) { $class .= 'winning '; } if ( $product->get_auction_current_bider() === $user_id && ! $product->is_reserve_met() ) { $class .= 'reserved '; } if ( strtotime( $product->get_auction_relisted() ) > strtotime( $value->date ) ) { $class .= 'relisted '; } echo ''; echo ''; echo ''; if ( 'yes' === $show_usernames ) { echo ''; } echo ''; echo ''; echo ''; } } } echo '
' . esc_html__( 'Date', 'wc_simple_auctions' ) . '' . esc_html__( 'Auction', 'wc_simple_auctions' ) . '' . esc_html__( 'Username', 'wc_simple_auctions' ) . '' . esc_html__( 'Bid', 'wc_simple_auctions' ) . '' . esc_html__( 'Status', 'wc_simple_auctions' ) . '
' . esc_html( date_i18n( get_option( 'date_format' ), strtotime( $value->date ) ) . ' ' . date_i18n( get_option( 'time_format' ), strtotime( $value->date ) ) ) . '' . esc_html( get_the_title( $value->auction_id ) ) . ''; $userdata = get_userdata( $value->userid ); if ( $userdata ) { echo esc_attr( $userdata->user_nicename ); } else { esc_html_e( 'n/a', 'wc_simple_auctions' ); } echo '' . wc_price( $value->bid ) . '' . $product->get_price_html() . '
'; } else { echo '

' . esc_html__( 'There is not any bids at the moment!.', 'wc_simple_auctions' ) . '

'; } }