settings: added/fixed link to settings in plugin page

This commit is contained in:
ruru4143 2024-07-18 16:24:05 +02:00
parent 098b1f578b
commit d1088756c8
2 changed files with 18 additions and 4 deletions

View file

@ -46,13 +46,26 @@ class Settings_Page {
'Activitypub Event Extension',
'Activitypub Events',
'manage_options',
'activitypub-events',
self::settings_slug,
array( self::static, 'settings_page' )
);
}
/**
* Adds Link to the settings page in the plugin page.
* It's called via apply_filter('plugin_action_links_' . PLUGIN_NAME).
*
* @param links already added links
* @return array original links but with link to setting page added
*/
public static function settings_link( $links ) {
return array_merge(
$links,
array(
'<a href="' . admin_url( 'options-general.php?page=' . self::settings_slug ) . '">Settings</a>',
)
);
}
public static function settings_page() {
if ( empty( $_GET['tab'] ) ) {

View file

@ -142,7 +142,8 @@ class Setup {
}
add_action( 'admin_menu', array( Settings_Page::static, 'admin_menu' ) );
add_filter( 'plugin_action_links_Activitypub_Event_Extensions', array( Settings_Page::static, 'settings_links' ) );
add_filter( 'plugin_action_links_' . ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_BASENAME,
array( Settings_Page::static, 'settings_link' ) );
add_filter( 'activitypub_transformer', array( $this, 'register_activitypub_event_transformer' ), 10, 3 );
}