316 posts
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Has been part of the Envato Community for over 3 years
+2 more
SyamilMJ says

Try sticking to the api whenever possible

//get webfonts json
//http://codex.wordpress.org/Function_API/wp_remote_post
$fonts = wp_remote_post('https://www.googleapis.com/webfonts/v1/webfonts');

//cache to theme for faster access
//http://codex.wordpress.org/Filesystem_API
$url = wp_nonce_url('foo','bar');
$creds = request_filesystem_credentials($url, '', false, false, null);
if(!WP_Filesystem($creds)) {
    return true;
} else {
    global $wp_filesystem;
    if ( ! $wp_filesystem->put_contents( get_template_directory() . '/cache/fonts.json', $fonts, FS_CHMOD_FILE) ) {
        return true;
    }
}
by
by
by
by
by
by