WC_Install::install_actions
Install actions when a update button is clicked within the admin area.
This function is hooked into admin_init to affect admin only.
Method of the class: WC_Install{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = WC_Install::install_actions();
WC_Install::install_actions() WC Install::install actions code WC 10.3.3
public static function install_actions() {
if ( ! empty( $_GET['do_update_woocommerce'] ) ) { // WPCS: input var ok.
check_admin_referer( 'wc_db_update', 'wc_db_update_nonce' );
wc_get_logger()->info( 'Manual database update triggered.', array( 'source' => 'wc-updater' ) );
self::update();
self::add_update_db_notice();
$return_url = $_GET['return_url'] ?? ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- sanitized below before use.
if ( ! empty( $return_url ) ) {
// Try to go back to the previous page.
if ( 'wc-admin-referer' === $return_url ) {
$return_url = preg_replace( '/^' . preg_quote( untrailingslashit( admin_url() ), '/' ) . '\/?/i', '', wp_get_referer() ? wp_get_referer() : '' );
if ( $return_url && false === strpos( $return_url, 'do_update_woocommerce' ) ) {
$return_url = remove_query_arg(
array( '_wpnonce', '_wc_notice_nonce', 'wc_db_update', 'wc_db_update_nonce', 'wc-hide-notice' ),
admin_url( $return_url )
);
} else {
$return_url = admin_url( 'admin.php?page=wc-settings' );
}
}
$return_url = esc_url_raw( wp_unslash( $return_url ) );
wp_safe_redirect( $return_url ); // WPCS: input var ok.
exit;
}
}
}