As per my previous submission for making the IP addresses clickable to ipinfo.io on the download logs, the same should be applied to the view payment details IP addresses. However this should be filterable to allow people to override with providers of their choice, by default using ipinfo.io maintains congruency.
I will submit PR for this.
Submitted PR for this: #6219 and #6220.
I created a new function edd_payment_get_ip_address_url, which felt like it should be in misc-functions.php. I am open to suggestions/feedback regarding this, however.
I like this a lot. It reduces the friction on a common, though minor, pain point. :+1:
I would like to see a few adjustments on the PR; please see my coded change requests there.
Made the required changes @pippinsplugins!
@davidsherlock thinking on this a bit more I think it should be adjusted a little further.
The edd_payment_details_ip_address filter is unneeded. Instead just call $payment->get_ip(). That already has a filter called edd_payment_user_ip.
In view order details, the IP should be output with the new edd_payment_get_ip_address_url() function. That way the function is called directly instead of applied via a filter.
Let me know if any of that is unknown!
Done @pippinsplugins, let me know if that works!
One thing, however, the payment_id feels a bit redundant now as a function parameter (and within the filter), do you want me to remove it?
@davidsherlock let's adjust the edd_payment_get_ip_address_url() to take the payment ID as the parameter instead of the IP. Then the function can setup $payment = new EDD_Payment( $payment_id ) an retrieve the IP from the object instead of passing the IP into the function.
That will make it more consistent with the other helper functions.
@pippinsplugins, for clarity - you are happy with this?
/**
* Given a Payment ID, generate a link to IP address provider (ipinfo.io)
*
* @since 2.8.15
* @param int $payment_id The Payment ID
* @return string A link to the IP details provider
*/
function edd_payment_get_ip_address_url( $payment_id ) {
$payment = new EDD_Payment( $payment_id );
$ip_address = $payment->get_ip();
$base_url = 'https://ipinfo.io/';
$provider_url = '<a href="' . esc_url( $base_url ) . esc_attr( $ip_address ) . '" target="_blank">' . esc_attr( $ip_address ) . '</a>';
return apply_filters( 'edd_payment_get_ip_address_url', $provider_url, $ip_address, $payment_id );
}
Ignore the spacing, messed up on copy/paste.
$ip_address = $payment->get_ip(); can be replaced with $payment->ip but otherwise yes!
Ooops, silly mistake on my part! Will submit PR.
Done!
@davidsherlock we'll get this included in the next point release, 2.8.17.