";
echo "
";
printf( __( "Page %d of %d", 'advanced-classifieds-and-directory-pro' ), $paged, $numpages );
echo "
";
echo "";
echo "
";
}
}
/**
* Removes an item or list from the query string.
*
* @since 1.0.0
*
* @param string|array $key Query key or keys to remove.
* @param bool|string $query Optional. When false uses the $_SERVER value. Default false.
* @return string New URL query string.
*/
function acadp_remove_query_arg( $key, $query = false ) {
if( is_array( $key ) ) { // removing multiple keys
foreach( $key as $k ) {
$query = str_replace( '#038;', '&', $query );
$query = add_query_arg( $k, false, $query );
}
return $query;
}
return add_query_arg( $key, false, $query );
}
/**
* Verify the captcha answer.
*
* @since 1.0.0
*
* @param string $form ACADP Form Name.
* @return bool True if not a bot, false if bot.
*/
function acadp_is_human( $form ) {
$recaptcha_settings = get_option( 'acadp_recaptcha_settings' );
$has_captcha = false;
if( isset( $recaptcha_settings['forms'] ) && '' !== $recaptcha_settings['site_key'] && '' !== $recaptcha_settings['secret_key'] ) {
if( in_array( $form, $recaptcha_settings['forms'] ) ) {
$has_captcha = true;
}
}
if( $has_captcha ) {
$response = isset( $_POST['g-recaptcha-response'] ) ? esc_attr( $_POST['g-recaptcha-response'] ) : '';
if( '' !== $response ) {
// make a GET request to the Google reCAPTCHA Server
$request = wp_remote_get( 'https://www.google.com/recaptcha/api/siteverify?secret=' . $recaptcha_settings['secret_key'] . '&response=' . $response . '&remoteip=' . $_SERVER["REMOTE_ADDR"] );
// get the request response body
$response_body = wp_remote_retrieve_body( $request );
$result = json_decode( $response_body, true );
// return true or false, based on users input
return ( true == $result['success'] ) ? true : false;
} else {
return false;
}
}
return true;
}
/**
* Get payment gateways.
*
* @since 1.0.0
*
* @return array $gateways A list of the available gateways.
*/
function acadp_get_payment_gateways() {
$gateways = apply_filters( 'acadp_payment_gateways', array( 'offline' => __( 'Offline Payment', 'advanced-classifieds-and-directory-pro' ) ) );
return $gateways;
}
/**
* Update Order details. Send emails to site and listing owners
* when order completed.
*
* @since 1.0.0
*
* $param array $order Order details.
*/
function acadp_order_completed( $order ) {
// update order details
update_post_meta( $order['id'], 'payment_status', 'completed' );
update_post_meta( $order['id'], 'transaction_id', $order['transaction_id'] );
// If the order has featured
$featured = get_post_meta( $order['id'], 'featured', true );
if( isset( $featured ) ) {
$post_id = get_post_meta( $order['id'], 'listing_id', true );
update_post_meta( $post_id, 'featured', 1 );
}
// Hook for developers
do_action( 'acadp_order_completed', $order['id'] );
// send emails
acadp_email_listing_owner_order_completed( $order['id'] );
acadp_email_admin_payment_received( $order['id'] );
}