-
-
Save tommcfarlin/f368f8d7ab6e0ce3c25b00995ccf319e to your computer and use it in GitHub Desktop.
[WordPress] Adding a Plugin Settings Link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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