Skip to content

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Conversation

benlk
Copy link

@benlk benlk commented Jun 20, 2025

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

  1. Open Dashboard > Plugins
  2. Find the Simple Google News Sitemap entry
  3. Check that there's an action for news-sitemap.xml
  4. Click the link. It should load the sitemap.

Screenshot 2025-06-20 at 17 50 02

Changelog Entry

Added - Link to news-sitemap.xml from Plugin list entry.

Credits

Checklist:

@benlk benlk self-assigned this Jun 20, 2025
@jeffpaul jeffpaul added this to the 1.2.0 milestone Jun 20, 2025
@jeffpaul jeffpaul requested a review from Copilot June 20, 2025 22:00
Copy link

@Copilot Copilot AI left a 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 );
Copy link
Preview

Copilot AI Jun 20, 2025

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 ), ... ).

Suggested change
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.

Comment on lines +294 to +295
'<a href="%1$s">news-sitemap.xml</a>',
home_url( 'news-sitemap.xml' )
Copy link
Preview

Copilot AI Jun 20, 2025

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'));

Suggested change
'<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>',
Copy link
Preview

Copilot AI Jun 20, 2025

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.

Suggested change
'<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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Put a sitemap link in the Plugins list.
2 participants