check if post_type exists (#34501)

* check if post_type exists

* Changelog.

Co-authored-by: barryhughes <3594411+barryhughes@users.noreply.github.com>
This commit is contained in:
justasdobrovolskis 2022-11-30 20:13:31 +02:00 committed by GitHub
parent ec5092bd5a
commit d4f2212c8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: tweak
Resolve an error in the product tracking code by testing to see if the `post_type` query var is set before checking its value.

View File

@ -317,6 +317,7 @@ class WC_Products_Tracking {
if (
'post-new.php' === $hook &&
isset( $_GET['post_type'] ) &&
'product' === wp_unslash( $_GET['post_type'] )
) {
return 'new';