[AUTOMATIQUE] Cet article a plus de 5 ans.
Il se peut donc que les informations qu'il fournit ne soient plus totalement exactes.

If you are a plugins developer, you may want to add some additional links (eg: donate link) to your plugins row in the plugins list page.

Add custom meta link on plugin list page

Here is a simple function which show you how to do that :

function bweb_plugin_meta_links( $links, $file ) {
	if ( $file === 'your-plugin-folder/your-main-plugin-file.php' ) {
		$links[] = '<a href="https://www.b-website.com/category/plugins" target="_blank" title="' . __( 'More bweb Plugins', 'texdomain' ) . '">' . __( 'More bweb Plugins', 'texdomain' ) . '</a>';
		$links[] = '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7Z6YVM63739Y8" target="_blank" title="' . __( 'Donate to this plugin &#187;' ) . '"><strong>' . __( 'Donate to this plugin &#187;' ) . '</strong></a>';
	}
	return $links;
}
add_filter( 'plugin_row_meta', 'bweb_plugin_meta_links', 10, 2 );

 

This filter is triggered for each plugin on the plugins page, so you have to make a test before inserting your custom links in the meta array. If we don’t, we’ll overload all the plugin custom meta… what’s not fair for other developers. The condition is based on the declaration file of your plugin. It will simply test whether the file called by the loop used to build the list of plugins is the PHP file in which we declared the informations of our plugin. So you have to edit this line:

your-plugin-folder/your-main-plugin-file.php

 

Please note that the string Donate to this plugin &#187; is already translated by WordPress itself, so no need to add you own texdomain.

Post written byBrice CAPOBIANCO

WordPress addict and self-taught. I love to learn and to create, then to share…
Founder of bweb.
Share this post

Your email address will not be published. Required fields are marked *