Skip to content

Commit

Permalink
Merge pull request #30 from xwp/feature/disable-auto-updates
Browse files Browse the repository at this point in the history
Prevent auto-updater from running when activated
  • Loading branch information
norcross committed Dec 13, 2014
2 parents f69c424 + aa82d5a commit 512d498
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions airplane-mode.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private function __construct() {
add_action( 'wp_default_scripts', array( $this, 'block_script_load' ), 100 );
add_filter( 'embed_oembed_html', array( $this, 'block_oembed_html' ), 1, 4 );
add_filter( 'get_avatar', array( $this, 'replace_gravatar' ), 1, 5 );
add_filter( 'map_meta_cap', array( $this, 'prevent_auto_updates' ), 10, 2 );

// kill all the http requests
add_filter( 'pre_http_request', array( $this, 'disable_http_reqs' ), 10, 3 );
Expand Down Expand Up @@ -382,6 +383,20 @@ public function admin_bar_toggle( WP_Admin_Bar $wp_admin_bar ) {
);
}

/**
* Filter a user's meta capabilities to prevent auto-updates from being attempted.
*
* @param array $caps Returns the user's actual capabilities.
* @param string $cap Capability name.
* @return array
*/
function prevent_auto_updates( $caps, $cap ) {
if ( in_array( $cap, array( 'update_plugins', 'update_themes', 'update_core' ) ) ) {
$caps[] = 'do_not_allow';
}
return $caps;
}

/// end class
}

Expand Down

0 comments on commit 512d498

Please sign in to comment.