target=”_blank” for all downloads links
-
Hi
There is a filter available: woocommerce_available_download_link() and this filter is used in this template file: my-downloads.php but this file is deprecated and seems to be replaced by order-downloads.php
In my-downloads.php the code was:
echo apply_filters( 'woocommerce_available_download_link', '<a href="' . esc_url( $download['download_url'] ) . '">' . $download['download_name'] . '</a>', $download );
In order-downloads.php the code is:
echo '<a href="' . esc_url( $download['download_url'] ) . '" class="woocommerce-MyAccount-downloads-file button alt">' . esc_html( $download['download_name'] ) . '</a>';
>> There is no more filter available !So how can we now add a target=”_blank” to this href tag?!
Before it was easy:
add_filter( 'woocommerce_available_download_link', 'download_links_new_tab',10,2 ); function download_links_new_tab( $link, $download ) { $link = '<a target="_blank" href="' . esc_url( $download['download_url'] ) . '" class="woocommerce-MyAccount-downloads-file button alt">' . esc_html( $download['download_name'] ) . '</a>'; return $link; }
but now? Of course I can overide order-downloads.php within my own theme but it is nos a good practice when you do updates…
Can this filter be back?
Thanks
- The topic ‘target=”_blank” for all downloads links’ is closed to new replies.