Instantly share code, notes, and snippets.

Embed
What would you like to do?
[WordPress] Adding a Plugin Settings Link
<?php
add_filter('plugin_action_links_' . plugin_basename(__FILE__), __NAMESPACE__ . '\\acme_settings_link' );
/**
* Creates a Settings link that links the users directly to the Settings page from the admin
* screen.
*
* @param array $links The list of links to appear under the plugin title.
* @return array $links The updated array of links including the 'Settings' link.
*/
function acme_settings_link($links) {
// Build the URL.
$url = add_query_arg(
'page',
'acme-plugin',
get_admin_url() . 'admin.php'
);
// Create the link.
$settings_link = "<a href='$url'>" . __( 'Settings' ) . '</a>';
// Adds the link to the end of the array.
array_push(
$links,
$settings_link
);
return $links;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment