How to update Google fonts for OnePress Plus

1. Install and activate the child theme by following this documentation https://docs.famethemes.com/article/139-sample-child-theme.

2. Copy the file google-fonts.php from the plugin's folder /wp-content/plugins/onepress-plus/inc/typography/ to the child theme folder.

3. Go to Google Fonts API page to get the newest fonts https://developers.google.com/fonts/docs/developer_api, click on the EXECUTE button to get the object.

4. Edit the file google-fonts.php in the child theme folder, replace the font object with the new one from the Google Fonts API

$google_fonts = '
{
  "kind": "webfonts#webfontList",
  "items": [
	{
   	 "family": "ABeeZee",
    	"variants": [
      		"regular",
      		"italic"
    	],
    	"subsets": [
      		"latin"
    	],
    	"version": "v14",
    	"lastModified": "2020-09-02",
    	"files": {
      		"regular": "http://fonts.gstatic.com/s/abeezee/v14/esDR31xSG-6AGleN6tKukbcHCpE.ttf",
      		"italic": "http://fonts.gstatic.com/s/abeezee/v14/esDT31xSG-6AGleN2tCklZUCGpG-GQ.ttf"
    	},
    	"category": "sans-serif",
    	"kind": "webfonts#webfont"
  	},
      ...	
  ]
}

';

5. Add this code to the file functions.php in the child theme folder to load the new fonts

add_filter( 'onepress_typography_get_google_fonts', 'onepress_update_google_fonts' );

function onepress_update_google_fonts( $fonts ) {
	//delete_transient( 'wp_typography_fonts' ); // for debug
	$font_output  = include get_stylesheet_directory() .'/google-fonts.php';

    $fonts = array();

    $scheme = is_ssl() ? 'https' : 'http';
    if ( is_array( $font_output ) ) {
        foreach ( $font_output['items'] as $item ) {

            $name = str_replace(' ', '+', $item['family']);

            $url = $scheme . "://fonts.googleapis.com/css?family={$name}:" . join($item['variants'], ',');
            if ( isset( $item['subsets'] ) ) {
                $url .= '&subset=' . join(',', $item['subsets']);
            }

            $atts = array(
                'name'          => $item['family'],
                'category'      => $item['category'],
                'font_type'     => 'google',
                'font_weights'  => $item['variants'],
                'subsets'       => $item['subsets'],
                'url'           => $url
            );

            // Add this font to the fonts array
            $id = sanitize_title( $item['family'] );
            $fonts[$id] = $atts;
        }
    }
	return $fonts;
}

* Note: You might not see the new fonts in the customizer due to the OnePress Plus plugin caches the old fonts. Uncomment the code

	delete_transient( 'wp_typography_fonts' ); // for debug

for the first time to delete the cache and remove it in the next run.