diff --git a/json-endpoints/jetpack/class.jetpack-json-api-plugins-endpoint.php b/json-endpoints/jetpack/class.jetpack-json-api-plugins-endpoint.php index 56d1b30e9355a..9fb4fc2898ad3 100644 --- a/json-endpoints/jetpack/class.jetpack-json-api-plugins-endpoint.php +++ b/json-endpoints/jetpack/class.jetpack-json-api-plugins-endpoint.php @@ -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; } - }