Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Created December 21, 2018 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommcfarlin/f368f8d7ab6e0ce3c25b00995ccf319e to your computer and use it in GitHub Desktop.
Save tommcfarlin/f368f8d7ab6e0ce3c25b00995ccf319e to your computer and use it in GitHub Desktop.
[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