Skip to content

Commit

Permalink
Improved wc_get_current_admin_url()
Browse files Browse the repository at this point in the history
- Replace "/wp-admin" with regex like on WP core.
- Remove "wc-hide-notice" from query args.
  • Loading branch information
claudiosanches committed Jul 30, 2020
1 parent c9f52a4 commit a464b7a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions includes/admin/wc-admin-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,11 @@ function wc_render_invalid_variation_notice( $product_object ) {
*/
function wc_get_current_admin_url() {
$uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
$uri = str_replace( '/wp-admin', '', $uri );
$uri = preg_replace( '|^.*/wp-admin/|i', '', $uri );

if ( ! $uri ) {
return '';
}

return remove_query_arg( array( '_wpnonce', '_wc_notice_nonce', 'wc_db_update', 'wc_db_update_nonce' ), admin_url( $uri ) );
return remove_query_arg( array( '_wpnonce', '_wc_notice_nonce', 'wc_db_update', 'wc_db_update_nonce', 'wc-hide-notice' ), admin_url( $uri ) );
}

0 comments on commit a464b7a

Please sign in to comment.