WP_Plugins_List_Table::add_dependencies_to_dependent_plugin_row( string $dependent )

In this article

Prints a list of other plugins that the plugin depends on.

Parameters

$dependentstringrequired
The dependent plugin’s filepath, relative to the plugins directory.

Source

protected function add_dependencies_to_dependent_plugin_row( $dependent ) {
	$dependency_names = WP_Plugin_Dependencies::get_dependency_names( $dependent );

	if ( array() === $dependency_names ) {
		return;
	}

	$links = array();
	foreach ( $dependency_names as $slug => $name ) {
		$links[] = $this->get_dependency_view_details_link( $name, $slug );
	}

	$is_active = is_multisite() ? is_plugin_active_for_network( $dependent ) : is_plugin_active( $dependent );
	$comma     = wp_get_list_item_separator();
	$requires  = sprintf(
		/* translators: %s: List of dependency names. */
		__( '<strong>Requires:</strong> %s' ),
		implode( $comma, $links )
	);

	$notice        = '';
	$error_message = '';
	if ( WP_Plugin_Dependencies::has_unmet_dependencies( $dependent ) ) {
		if ( $is_active ) {
			$error_message = __( 'This plugin is active but may not function correctly because required plugins are missing or inactive.' );
		} else {
			$error_message = __( 'This plugin cannot be activated because required plugins are missing or inactive.' );
		}
		$notice = wp_get_admin_notice(
			$error_message,
			array(
				'type'               => 'error',
				'additional_classes' => array( 'inline', 'notice-alt' ),
			)
		);
	}

	printf(
		'<div class="requires"><p>%1$s</p>%2$s</div>',
		$requires,
		$notice
	);
}

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.