From f86c8e0c8f5c9dba09d035716de3a16e357f4bee Mon Sep 17 00:00:00 2001 From: Daine Mawer Date: Mon, 6 Jun 2022 06:00:06 +0200 Subject: [PATCH] Add Web Vitals to Scaffold --- themes/10up-theme/functions.php | 7 +- themes/10up-theme/includes/web-vitals.php | 119 ++++++++++++++++++++++ 2 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 themes/10up-theme/includes/web-vitals.php diff --git a/themes/10up-theme/functions.php b/themes/10up-theme/functions.php index c4be4e37..92079615 100755 --- a/themes/10up-theme/functions.php +++ b/themes/10up-theme/functions.php @@ -13,13 +13,17 @@ define( 'TENUP_THEME_DIST_URL', TENUP_THEME_TEMPLATE_URL . '/dist/' ); define( 'TENUP_THEME_INC', TENUP_THEME_PATH . 'includes/' ); define( 'TENUP_THEME_BLOCK_DIR', TENUP_THEME_INC . 'blocks/' ); - +define( 'TENUP_WEB_VITAL_TRACKING', false ); if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG && file_exists( __DIR__ . '/dist/fast-refresh.php' ) ) { require_once __DIR__ . '/dist/fast-refresh.php'; TenUpToolkit\set_dist_url_path( basename( __DIR__ ), TENUP_THEME_DIST_URL, TENUP_THEME_DIST_PATH ); } +if ( defined( 'TENUP_WEB_VITAL_TRACKING' ) && TENUP_WEB_VITAL_TRACKING ) { + require_once TENUP_THEME_INC . 'web-vitals.php'; + TenUpTheme\WebVitals\setup(); +} require_once TENUP_THEME_INC . 'core.php'; require_once TENUP_THEME_INC . 'overrides.php'; @@ -31,6 +35,7 @@ TenUpTheme\Core\setup(); TenUpTheme\Blocks\setup(); + // Require Composer autoloader if it exists. if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { require_once __DIR__ . '/vendor/autoload.php'; diff --git a/themes/10up-theme/includes/web-vitals.php b/themes/10up-theme/includes/web-vitals.php new file mode 100644 index 00000000..55154605 --- /dev/null +++ b/themes/10up-theme/includes/web-vitals.php @@ -0,0 +1,119 @@ + + + + + + + + + + + + +