Returns a notice containing a list of dependencies required by the plugin.
Parameters
$plugin_data
arrayrequired- An array of plugin data. See plugins_api() for the list of possible values.
Source
protected function get_dependencies_notice( $plugin_data ) {
if ( empty( $plugin_data['requires_plugins'] ) ) {
return '';
}
$no_name_markup = '<div class="plugin-dependency"><span class="plugin-dependency-name">%s</span></div>';
$has_name_markup = '<div class="plugin-dependency"><span class="plugin-dependency-name">%s</span> %s</div>';
$dependencies_list = '';
foreach ( $plugin_data['requires_plugins'] as $dependency ) {
$dependency_data = WP_Plugin_Dependencies::get_dependency_data( $dependency );
if (
false !== $dependency_data &&
! empty( $dependency_data['name'] ) &&
! empty( $dependency_data['slug'] ) &&
! empty( $dependency_data['version'] )
) {
$more_details_link = $this->get_more_details_link( $dependency_data['name'], $dependency_data['slug'] );
$dependencies_list .= sprintf( $has_name_markup, esc_html( $dependency_data['name'] ), $more_details_link );
continue;
}
$result = plugins_api( 'plugin_information', array( 'slug' => $dependency ) );
if ( ! empty( $result->name ) ) {
$more_details_link = $this->get_more_details_link( $result->name, $result->slug );
$dependencies_list .= sprintf( $has_name_markup, esc_html( $result->name ), $more_details_link );
continue;
}
$dependencies_list .= sprintf( $no_name_markup, esc_html( $dependency ) );
}
$dependencies_notice = sprintf(
'<div class="plugin-dependencies notice notice-alt notice-info inline"><p class="plugin-dependencies-explainer-text">%s</p> %s</div>',
'<strong>' . __( 'Additional plugins are required' ) . '</strong>',
$dependencies_list
);
return $dependencies_notice;
}
Changelog
Version | Description |
---|---|
6.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.