Skip to content

Instantly share code, notes, and snippets.

View tamw-wnet's full-sized avatar

William Tam (WNET) tamw-wnet

View GitHub Profile
function wnet_get_transient_remote_json($transientname, $url, $interval=1800) {
// those are the same arguments as 'set_transient()'
$stalecachename = 'stalecache_' . $transientname;
// we generate a consistent name for the backup data
if ( false === ( $json = get_transient($transientname) ) ) {
$response = wp_remote_get($url);
// get the remote data as before, but this time...
@tamw-wnet
tamw-wnet / foo-v2.php
Last active October 12, 2022 15:46
Foo oAuth plugin, version 2 with persistent logins
<?php
/*
* Plugin Name: Foo oAuth Demo
* Version: 2
* Plugin URI: http://ieg.wnet.org/
* Description: A simple Google oAuth demo plugin
* Author: William Tam
* Author URI: http://ieg.wnet.org/blog/author/tamw/
* Requires at least: 3.6
* Tested up to: 4.2.2
@tamw-wnet
tamw-wnet / foo-v1.php
Last active October 6, 2021 18:19
Foo oAuth plugin, version 1
<?php
/*
* Plugin Name: Foo oAuth Demo
* Version: 1
* Plugin URI: http://ieg.wnet.org/
* Description: A simple Google oAuth demo plugin
* Author: William Tam
* Author URI: http://ieg.wnet.org/blog/author/tamw/
* Requires at least: 3.6
* Tested up to: 4.2.2