From 9df9b807b7729a67a48249d61a538c28aa91a8be Mon Sep 17 00:00:00 2001 From: Matthew Reishus Date: Fri, 19 Apr 2024 02:53:33 -0500 Subject: [PATCH] Jetpack Google Fonts: Add filter to conditionally skip loading (#36980) * Jetpack Google Fonts: Add filter to conditionally skip loading * changelog * Update projects/plugins/jetpack/modules/google-fonts/load.php --------- Co-authored-by: Jeremy Herve --- .../jetpack/changelog/update-google-fonts-skip | 4 ++++ .../jetpack/modules/google-fonts/load.php | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 projects/plugins/jetpack/changelog/update-google-fonts-skip diff --git a/projects/plugins/jetpack/changelog/update-google-fonts-skip b/projects/plugins/jetpack/changelog/update-google-fonts-skip new file mode 100644 index 0000000000000..10248f6516b0d --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-google-fonts-skip @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Jetpack Google Fonts: Add filter to conditionally skip loading diff --git a/projects/plugins/jetpack/modules/google-fonts/load.php b/projects/plugins/jetpack/modules/google-fonts/load.php index ca69f5a5cdde8..c4011d1998cbf 100644 --- a/projects/plugins/jetpack/modules/google-fonts/load.php +++ b/projects/plugins/jetpack/modules/google-fonts/load.php @@ -8,6 +8,23 @@ add_action( 'plugins_loaded', function () { + /** + * Filters whether to skip loading the Jetpack Google Fonts module. + * + * This filter allows skipping the loading of the Jetpack Google Fonts module + * based on specific conditions or requirements. By default, the module will + * load normally. If the filter returns true, the module will be skipped. + * + * @module google-fonts + * + * @since $$next-version$$ + * + * @param bool $skip Whether to skip loading the Jetpack Google Fonts module. Default false. + */ + if ( apply_filters( 'jetpack_google_fonts_skip_load', false ) ) { + return; + } + if ( class_exists( 'WP_Font_Face' ) ) { // WordPress 6.5 or above with the new Font Library. require_once __DIR__ . '/current/load-google-fonts.php';