Skip to content

Instantly share code, notes, and snippets.

@raftaar1191
Created July 25, 2024 18:00
Show Gist options
  • Save raftaar1191/72bca3508634da4739c2b346e7ce7bb6 to your computer and use it in GitHub Desktop.
Save raftaar1191/72bca3508634da4739c2b346e7ce7bb6 to your computer and use it in GitHub Desktop.
Add settings button into the plugins
/**
* Add Settings link to plugins area.
*
* @since 1.0.0
*
* @param array $links Links array in which we would prepend our link.
* @param string $file Current plugin basename.
* @return array Processed links.
*/
function modify_plugin_action_links( $links, $file ) {
// Return normal links if not BuddyPress.
if ( WORDPRESS_PLUGIN_BOILERPLATE_PLUGIN_BASENAME !== $file ) {
return $links;
}
// Add a few links to the existing links array.
return array_merge(
$links,
array(
'settings' => '<a href="' . esc_url( admin_url( 'admin.php?page=bp-settings' ) ) . '">' . esc_html__( 'Settings', 'wordpress-plugin-boilerplate' ) . '</a>',
)
);
}
$this->loader->add_action( 'plugin_action_links', $plugin_admin, 'modify_plugin_action_links', 10, 2 );
@raftaar1191
Copy link
Author

Will put this function into the Wordpress_Plugin_Boilerplate_Admin class and hook inside the define_admin_hooks method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment