Beta Tester: Do not run code in tracks debug unless WC_ABSPATH is defined. (#39486)

* Do not run code in tracks debug unless WC_ABSPTAH is defined.

* Add changefile(s) from automation for the following project(s): woocommerce-beta-tester

* Also avoid registering scripts if Woo is not installed.

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Sam Seay 2023-08-04 12:29:07 +08:00 committed by GitHub
parent b14653ede0
commit d64e1c24dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View File

@ -42,7 +42,7 @@ class Tracks_Debug_Log {
*/
public function __construct() {
// WooCommerce might not be installed/activated between installs of WC versions.
if ( class_exists( 'WooCommerce' ) ) {
if ( defined( 'WC_ABSPATH' ) ) {
include_once WC_ABSPATH . 'includes/tracks/class-wc-tracks-client.php';
include_once WC_ABSPATH . 'includes/tracks/class-wc-tracks-footer-pixel.php';

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix a bug where WC_ABSPATH is used when the WooCommerce instance might not have defined it yet.

View File

@ -15,10 +15,23 @@ class WC_Beta_Tester_Live_Branches {
* Constructor.
*/
public function __construct() {
if ( ! $this->woocommerce_is_installed() ) {
return;
}
add_action( 'admin_menu', array( $this, 'register_page' ) );
add_action( 'admin_init', array( $this, 'register_scripts' ) );
}
/**
* Check if WooCommerce is installed.
*
* @return bool - True if WooCommerce is installed, false otherwise.
*/
private function woocommerce_is_installed() {
return class_exists( 'WooCommerce' );
}
/**
* Register live branches scripts.
*/