WP_Plugin_Install_List_Table::get_dependencies_notice()
Returns a notice containing a list of dependencies required by the plugin.
Method of the class: WP_Plugin_Install_List_Table{}
No Hooks.
Returns
String
. A notice containing a list of dependencies required by the plugin, or an empty string if none is required.
Usage
// protected - for code of main (parent) or child class $result = $this->get_dependencies_notice( $plugin_data );
- $plugin_data(array) (required)
- An array of plugin data. See plugins_api() for the list of possible values.
Changelog
Since 6.5.0 | Introduced. |
WP_Plugin_Install_List_Table::get_dependencies_notice() WP Plugin Install List Table::get dependencies notice code WP 6.8.1
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; }