Skip to content

Commit

Permalink
print debug data
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenedetto committed Jan 17, 2025
1 parent e306764 commit d74d9ed
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@ class Jetpack_Google_Font_Face {
*/
public function __construct() {
// Turns off hooks to print fonts
add_action( 'wp_loaded', array( $this, 'wp_loaded' ) );
add_action( 'current_screen', array( $this, 'current_screen' ), 10 );

// Collect and print fonts in use
add_action( 'wp_head', array( $this, 'print_font_faces' ), 10 );
add_action( 'wp_head', array( $this, 'print_font_faces' ), 50 );
add_filter( 'pre_render_block', array( $this, 'collect_block_fonts' ), 10, 2 );
}

/**
* Turn off hooks to print fonts on frontend
*/
public function wp_loaded() {
remove_action( 'wp_head', 'wp_print_fonts', 50 );
remove_action( 'wp_head', 'wp_print_font_faces', 50 );
}

/**
* Turn off hooks to print fonts on wp-admin, except for GB editor pages.
*/
Expand All @@ -45,8 +54,12 @@ public function current_screen() {
* Print fonts that are used in global styles or block-level settings.
*/
public function print_font_faces() {
echo '<h1>This is a test</h1>';
$fonts = WP_Font_Face_Resolver::get_fonts_from_theme_json();
$fonts = WP_Font_Face_Resolver::get_fonts_from_theme_json();
echo '<h1>DebugFonts</h1>';
echo '<pre>';
print_r( $fonts );

Check warning on line 60 in projects/plugins/jetpack/modules/google-fonts/current/class-jetpack-google-font-face.php

View workflow job for this annotation

GitHub Actions / PHP Code Sniffer (non-excluded files only)

print_r() found. Debug code should not normally be used in production. (WordPress.PHP.DevelopmentFunctions.error_log_print_r)
echo '</pre>';

$font_slug_aliases = $this->get_font_slug_aliases();
$fonts_to_print = array();

Expand Down

0 comments on commit d74d9ed

Please sign in to comment.