Skip to content

Commit

Permalink
Take multisite into account
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath authored Sep 28, 2020
1 parent 2a99194 commit 4496f03
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions wptt-webfont-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function get_local_font_styles( $css ) {
*/
public function get_local_files_from_css( $css ) {
$font_files = $this->get_files_from_css( $css );
$stored = get_option( 'downloaded_font_files', array() );
$stored = get_site_option( 'downloaded_font_files', array() );
$change = false; // If in the end this is true, we need to update the cache option.

// If the fonts folder don't exist, create it.
Expand Down Expand Up @@ -152,7 +152,7 @@ public function get_local_files_from_css( $css ) {

// If there were changes, update the option.
if ( $change ) {
update_option( 'downloaded_font_files', $stored );
update_site_option( 'downloaded_font_files', $stored );
}

return $stored;
Expand All @@ -179,7 +179,7 @@ public function get_cached_url_contents( $url = '' ) {
// Try to retrieved cached response from the gfonts API.
$contents = false;
$transient_name = 'url_contents_' . md5( $url );
$contents = get_transient( $transient_name );
$contents = get_site_transient( $transient_name );

// If the transient is empty we need to get contents from the remote URL.
if ( ! $contents ) {
Expand All @@ -191,7 +191,7 @@ public function get_cached_url_contents( $url = '' ) {
// We're using a transient and not an option because fonts get updated
// so we want to be able to get the latest version weekly.
if ( $contents ) {
set_transient( $transient_name, $contents, WEEK_IN_SECONDS );
set_site_transient( $transient_name, $contents, WEEK_IN_SECONDS );
}
}

Expand Down

0 comments on commit 4496f03

Please sign in to comment.