Skip to content

Commit

Permalink
tweak for namespaced plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Sep 21, 2021
1 parent 8948025 commit 1d795d8
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions src/wp-admin/includes/class-wp-plugin-dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,40 @@ protected function maybe_process_plugin_dependencies( $file ) {
*/
public function get_plugin_dependencies( $file ) {
if ( ! isset( $this->plugin_dependencies[ $file ] ) ) {
$this->plugin_dependencies[ $file ] = array();
$plugin_dependencies = get_plugin_data( WP_PLUGIN_DIR . '/' . $file )['RequiresPlugins'];
$dependencies = array();
$plugin_dependencies = get_plugin_data( WP_PLUGIN_DIR . '/' . $file )['RequiresPlugins'];
if ( empty( $plugin_dependencies ) ) {
$this->plugin_dependencies[ $file ] = array();
$dependencies = array();
return array();
}

$plugin_dependencies = str_getcsv( $plugin_dependencies );
foreach ( $plugin_dependencies as $dependency ) {
$this->plugin_dependencies[ $file ][] = array( 'slug' => trim( $dependency ) );
if ( false !== strpos( $dependency, ':' ) ) {
$dependency_parts = explode( ':', $dependency );
$dependencies[] = array(
'namespace' => $dependency_parts[0],
'slug' => $dependency_parts[1],
);
continue;
}
$dependencies[] = array(
'namespace' => '',
'slug' => trim( $dependency )
);
}

/**
* Filter the array of dependencies.
*
* @since 5.9.0
*
* @param array $dependencies Array of dependencies.
* @param string $file The plugin file.
*
* @return array
*/
$this->plugin_dependencies[ $file ] = apply_filters( 'wp_plugin_dependencies', $dependencies, $file );
}

return $this->plugin_dependencies[ $file ];
Expand Down

0 comments on commit 1d795d8

Please sign in to comment.