Fix some PHP notices when accessing WC Settings screen (https://github.com/woocommerce/woocommerce-admin/pull/828)

* Fix some PHP notices when accessing WC Settings screen

* Add sanitization
This commit is contained in:
Boro Sitnikovski 2018-11-13 20:08:01 +01:00 committed by Jonathan Belcher
parent 1d5364f6a6
commit 83fdaf6cd6
1 changed files with 4 additions and 3 deletions

View File

@ -66,10 +66,11 @@ function wc_admin_get_embed_breadcrumbs() {
'wc-status' => 'status',
);
$tab = '';
$get_tab = isset( $_GET['tab'] ) && sanitize_text_field( wp_unslash( $_GET['tab'] ) );
$get_tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : '';
if ( isset( $_GET['page'] ) ) {
if ( in_array( wp_unslash( $_GET['page'] ), array_keys( $pages_with_tabs ) ) ) {
$tab = ! empty( $get_tab ) ? $get_tab . '-' : $pages_with_tabs[ $get_page ] . '-';
$page = sanitize_text_field( wp_unslash( $_GET['page'] ) );
if ( in_array( $page, array_keys( $pages_with_tabs ) ) ) {
$tab = ! empty( $get_tab ) ? $get_tab . '-' : $pages_with_tabs[ $page ] . '-';
}
}