Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Question regarding storing JSON feed locally

I'm a little confused regarding the following function that is used to retrieve the JSON data:

function wptreehouse_get_badges_profile( $wptreehouse_username ) {
    $usernameUrl = 'http://www.teamtreehouse.com/' . $wptreehouse_username . '.json';
    $args = array('timeout' => 120);
    $wptreehouse_userinfo = wp_remote_get($usernameUrl, $args);
    return json_decode($wptreehouse_userinfo['body']);
}

This function is then being called and stored in a variable $wptreehouse_profile that is inside the main wptreehouse_badges_options_page().

In this case, isn't the api being called every time the user fills in the input with a username and submits the form?

How is this storing the JSON data locally?