-
Notifications
You must be signed in to change notification settings - Fork 2
Add news sitemap link to plugin list #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds a direct link to the news-sitemap.xml
file in the Plugins list for the Simple Google News Sitemap plugin, improving discoverability.
- Registers a
plugin_action_links
filter for the sitemap link. - Implements
sitemap_link
to append the link to the plugin actions.
Comments suppressed due to low confidence (2)
includes/classes/Core.php:292
- Add an @SInCE tag and update the docblock parameter/return types (e.g., array<string,string>) to clarify when this method was introduced and its signature.
public static function sitemap_link( $actions ) {
includes/classes/Core.php:289
- Add unit or integration tests to cover this filter and verify that the sitemap link appears correctly in the plugin actions list.
* @param string[] $actions
@@ -36,6 +36,8 @@ public function init() { | |||
add_action( 'transition_post_status', [ $this, 'purge_sitemap_data_on_status_change' ], 1000, 3 ); | |||
add_action( 'publish_post', [ $this, 'ping_google' ], 2000 ); | |||
add_action( 'delete_post', [ $this, 'purge_sitemap_data_on_delete' ], 1000, 2 ); | |||
|
|||
add_filter( 'plugin_action_links_simple-google-news-sitemap/simple-google-news-sitemap.php', [ __CLASS__, 'sitemap_link' ], 10, 1 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider generating the filter name dynamically using plugin_basename to avoid hardcoding the plugin path, e.g.: add_filter( 'plugin_action_links_' . plugin_basename( YOUR_PLUGIN_MAIN_FILE ), ... ).
add_filter( 'plugin_action_links_simple-google-news-sitemap/simple-google-news-sitemap.php', [ __CLASS__, 'sitemap_link' ], 10, 1 ); | |
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), [ __CLASS__, 'sitemap_link' ], 10, 1 ); |
Copilot uses AI. Check for mistakes.
'<a href="%1$s">news-sitemap.xml</a>', | ||
home_url( 'news-sitemap.xml' ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Escape the URL and link text to prevent XSS. E.g.: sprintf('%2$s', esc_url(home_url('news-sitemap.xml')), esc_html__('News Sitemap', 'simple-google-news-sitemap'));
'<a href="%1$s">news-sitemap.xml</a>', | |
home_url( 'news-sitemap.xml' ) | |
'<a href="%1$s">%2$s</a>', | |
esc_url( home_url( 'news-sitemap.xml' ) ), | |
esc_html( 'news-sitemap.xml' ) |
Copilot uses AI. Check for mistakes.
*/ | ||
public static function sitemap_link( $actions ) { | ||
$actions[] = sprintf( | ||
'<a href="%1$s">news-sitemap.xml</a>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider adding target="_blank" and rel="noopener noreferrer" to the link for better UX and security when opening in a new tab.
'<a href="%1$s">news-sitemap.xml</a>', | |
'<a href="%1$s" target="_blank" rel="noopener noreferrer">news-sitemap.xml</a>', |
Copilot uses AI. Check for mistakes.
Description of the Change
Adds a link to the News Sitemap to this plugin's plugin actions, to make it easier to find.
Closes #56
How to test the Change
news-sitemap.xml
Changelog Entry
Credits
Checklist: