Permalink
Browse files

Cache plugin data in a transient for a day to avoid a remote get on e…

…very page load.
  • Loading branch information...
1 parent 048be08 commit f12c956000ee7f229c4a7f68a0914472e5b33e3a @willmot willmot committed Mar 15, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 admin.menus.php
View
@@ -43,13 +43,20 @@ function hmbkp_plugin_action_link( $links, $file ) {
*
* Help is pulled from the readme FAQ.
*
- * @todo get plugin info from local readme and use plugin_updates cache to check if we are running the latest version so we don't have to do a wp_remote_get on every page load.
* @return null
*/
function hmbkp_contextual_help() {
require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
- $plugin = plugins_api( 'plugin_information', array( 'slug' => 'backupwordpress' ) );
+
+ if ( ! $plugin = get_transient( 'hmbkp_plugin_data' ) ) {
+
+ $plugin = plugins_api( 'plugin_information', array( 'slug' => 'backupwordpress' ) );
+
+ // Cache for one day
+ set_transient( 'hmbkp_plugin_data', $plugin, 86400 );
+
+ }
$warning = '';

0 comments on commit f12c956

Please sign in to comment.