Fix broken db update button on homescreen (#47608)

* Add handling of return url

* Use base admin URL and redirect to current page

* Update plugins/woocommerce/includes/admin/notes/class-wc-notes-run-db-update.php

Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com>

* Update plugins/woocommerce/includes/class-wc-install.php

Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com>

* Changelog

---------

Co-authored-by: Ilyas Foo <foo.ilyas@gmail.com>
Co-authored-by: Chi-Hsuan Huang <chihsuan.tw@gmail.com>
This commit is contained in:
Adrian Duffell 2024-05-22 20:09:47 +08:00 committed by GitHub
parent 544c843b67
commit da57287c56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix broken db update button on homescreen

View File

@ -113,8 +113,9 @@ class WC_Notes_Run_Db_Update {
add_query_arg(
array(
'do_update_woocommerce' => 'true',
'return_url' => wc_get_current_admin_url() ? wc_get_current_admin_url() : admin_url( 'admin.php?page=wc-settings' ),
),
wc_get_current_admin_url() ? wc_get_current_admin_url() : admin_url( 'admin.php?page=wc-settings' )
admin_url()
);
$note_actions = array(

View File

@ -424,6 +424,10 @@ class WC_Install {
self::update();
WC_Admin_Notices::add_notice( 'update', true );
}
if ( ! empty( $_GET['return_url'] ) ) { // WPCS: input var ok.
$return_url = esc_url_raw( wp_unslash( $_GET['return_url'] ) );
wp_safe_redirect( $return_url ); // WPCS: input var ok.
}
}
/**