Skip to content

Commit

Permalink
JSON: add fallback to original slug approach
Browse files Browse the repository at this point in the history
If we can't get the cached plugin slug, let's try to infer that from the
path to the plugin file.
  • Loading branch information
Tony Kovanen committed Dec 12, 2014
1 parent c01db67 commit 5080f2e
Showing 1 changed file with 8 additions and 4 deletions.
Expand Up @@ -178,16 +178,20 @@ protected function get_plugin_slug( $plugin_file ) {
$slug = $update_plugins->no_update[ $plugin_file ]->slug;
}
}

if ( empty( $slug ) && isset( $update_plugins->response ) ) {
if ( isset( $update_plugins->response[ $plugin_file ] ) ) {
$slug = $update_plugins->response[ $plugin_file ]->slug;
}
}
if ( empty ( $slug) ) {
$slug = $plugin_file;
}

// Try to infer from the plugin file if not cached
if ( empty( $slug) ) {
$slug = dirname( $plugin_file );
if ( '.' === $slug ) {
$slug = preg_replace("/(.+)\.php$/", "$1", $plugin_file );
}
}
return $slug;
}

}

0 comments on commit 5080f2e

Please sign in to comment.