Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent auto-updater from running when activated #30

Merged
merged 1 commit into from
Dec 13, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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