Skip to content

Commit

Permalink
Fix: Make the "Check for updates" link work properly in Multisite.
Browse files Browse the repository at this point in the history
Essentially, the library just switches to using /wp-admin/network/plugins.php instead of /wp-admin/plugins.php as necessary. Also, the "all_admin_notices" action runs in both normal and Network admin, so it's a better choice for displaying the update check result than either "admin_notices" or "network_admin_notices".
  • Loading branch information
YahnisElsts committed Jan 7, 2013
1 parent e2ddd78 commit 1fa2770
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions plugin-update-checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected function installHooks(){

add_filter('plugin_row_meta', array($this, 'addCheckForUpdatesLink'), 10, 4);
add_action('admin_init', array($this, 'handleManualCheck'));
add_action('admin_notices', array($this, 'displayManualCheckResult'));
add_action('all_admin_notices', array($this, 'displayManualCheckResult'));

//Set up the periodic update checks
$this->cronHook = 'check_plugin_updates-' . $this->slug;
Expand Down Expand Up @@ -424,22 +424,23 @@ public function getUpdate() {
* @param array $pluginMeta Array of meta links.
* @param string $pluginFile
* @param array|null $pluginData Currently ignored.
* @param string|null $status Currently ignored/
* @param string|null $status Currently ignored.
* @return array
*/
public function addCheckForUpdatesLink($pluginMeta, $pluginFile, $pluginData = null, $status = null) {
if ( $pluginFile == $this->pluginFile && current_user_can('update_plugins') ) {
$linkText = apply_filters('puc_manual_check_link-' . $this->slug, 'Check for updates');
$linkUrl = wp_nonce_url(
add_query_arg(
array(
'puc_check_for_updates' => 1,
'puc_slug' => $this->slug,
),
admin_url('plugins.php')
is_network_admin() ? network_admin_url('plugins.php') : admin_url('plugins.php')
),
'puc_check_for_updates'
);

$linkText = apply_filters('puc_manual_check_link-' . $this->slug, 'Check for updates');
if ( !empty($linkText) ) {
$pluginMeta[] = sprintf('<a href="%s">%s</a>', esc_attr($linkUrl), $linkText);
}
Expand Down Expand Up @@ -468,7 +469,7 @@ public function handleManualCheck() {
'puc_update_check_result' => $status,
'puc_slug' => $this->slug,
),
admin_url('plugins.php')
is_network_admin() ? network_admin_url('plugins.php') : admin_url('plugins.php')
));
}
}
Expand Down

0 comments on commit 1fa2770

Please sign in to comment.