PHP code example of inc2734 / wp-google-fonts

1. Go to this page and download the library: Download inc2734/wp-google-fonts library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

inc2734 / wp-google-fonts example snippets



new \Inc2734\WP_Google_Fonts\Bootstrap();

// Enqueue Noto Sans JP
add_action( 'wp_enqueue_scripts', [ '\Inc2734\WP_Google_Fonts\Helper', 'enqueue_noto_sans_jp' ], 5 );
add_action( 'enqueue_block_editor_assets', [ '\Inc2734\WP_Google_Fonts\Helper', 'enqueue_noto_sans_jp' ] );

// Noto Serif JP
add_action( 'wp_enqueue_scripts', [ '\Inc2734\WP_Google_Fonts\Helper', 'enqueue_noto_serif_jp' ], 5 );
add_action( 'enqueue_block_editor_assets', [ '\Inc2734\WP_Google_Fonts\Helper', 'enqueue_noto_serif_jp' ] );

/**
 * @param string $weight 400:700
 * @return string
 */
add_filter(
  'inc2734_wp_google_fonts_font_weight',
  function( $weight ) {
    return $weight;
  }
);

/**
 * @param string $directory WP_CONTENT_DIR
 * @return string
 */
add_filter(
  'inc2734_wp_google_fonts_base_directory',
  function( $directory ) {
    return $directory;
  }
);