Created
July 25, 2024 18:00
-
-
Save raftaar1191/72bca3508634da4739c2b346e7ce7bb6 to your computer and use it in GitHub Desktop.
Add settings button into the plugins
This file contains hidden or 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
/** | |
* 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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will put this function into the Wordpress_Plugin_Boilerplate_Admin class and hook inside the define_admin_hooks method