Skip to content

Conversation

@rbcorrales
Copy link
Member

All Submissions:

Changes proposed in this Pull Request:

This PR adds some logic to make CTA links automatically open external links, attachments, and file downloads in new tabs while keeping internal navigation in the same tab.

Links that will open in a new tab:

  • All attachment type CTAs (type: attachment)
  • External links (different domain from current site)
  • PDF files and other document formats (configurable via filter)

Links that will keep loading in the current tab:

  • Internal links (same domain)
  • Relative URLs
  • Non-HTTP(S) schemes (mailto, tel, etc.)

The logic includes three filters for customization:

  • newspack_collections_new_tab_file_extensions: For adding custom file extensions
  • newspack_collections_new_tab_internal_hosts: For adding custom hosts that would be considered internal
  • newspack_collections_should_cta_open_in_new_tab: For complete behavior override

Links that open in new tabs include rel="noopener noreferrer" for security.

Closes NPPD-871.

How to test the changes in this Pull Request:

  1. Create a Collection with mixed CTA types: Add CTAs with external URLs (e.g., https://example.com), internal links (e.g., /about), attachments, links with a PDF extension and relative URLs to test the different behaviors.
  2. Verify that the new tab behavior matches the expected behavior from the PR details above.
  3. Verify the new filters work as expected and allow you to override the existing behavior.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@rbcorrales rbcorrales requested a review from a team as a code owner September 8, 2025 20:01
@rbcorrales rbcorrales added the [Status] Needs Review The issue or pull request needs to be reviewed label Sep 8, 2025
@dkoo dkoo added [Status] Approved The pull request has been reviewed and is ready to merge and removed [Status] Needs Review The issue or pull request needs to be reviewed labels Sep 11, 2025
@rbcorrales rbcorrales merged commit 07a5545 into trunk Sep 11, 2025
9 of 10 checks passed
@rbcorrales rbcorrales deleted the feat/collections-open-new-tab branch September 11, 2025 23:01
@github-actions
Copy link

Hey @rbcorrales, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label.

If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label.

Thank you! ❤️

matticbot pushed a commit that referenced this pull request Sep 18, 2025
# [6.19.0-alpha.4](v6.19.0-alpha.3...v6.19.0-alpha.4) (2025-09-18)

### Features

* **collections:** add Collections block ([#4166](#4166)) ([ea0917b](ea0917b))
* **collections:** add logic for opening links in new tabs ([#4174](#4174)) ([ab71461](ab71461))
* **collections:** collections block feedback ([#4185](#4185)) ([2f203c1](2f203c1))
* **collections:** replace archive grid with collections block ([#4178](#4178)) ([d601445](d601445))
matticbot pushed a commit that referenced this pull request Sep 22, 2025
# [6.19.0](v6.18.3...v6.19.0) (2025-09-22)

### Bug Fixes

* **indesign-export:** remove feature flag ([#4180](#4180)) ([e3c5c7e](e3c5c7e))
* **my-account:** missing variable and template hook priority ([#4150](#4150)) ([9886618](9886618))
* **newspack-ui:** border radius and padding for buttons, modals, and segmented controls ([#4162](#4162)) ([be750ef](be750ef))
* register with empty name fields ([#4175](#4175)) ([7d6680c](7d6680c))

### Features

* **collections:** add Collections block ([#4166](#4166)) ([ea0917b](ea0917b))
* **collections:** add logic for opening links in new tabs ([#4174](#4174)) ([ab71461](ab71461))
* **collections:** collections block feedback ([#4185](#4185)) ([2f203c1](2f203c1))
* **collections:** replace archive grid with collections block ([#4178](#4178)) ([d601445](d601445))
* **newspack-ui:** add standalone dropdown button; reorganise dropdown box; add generic spacing ([#4169](#4169)) ([863da1e](863da1e))
* **woocommerce:** add custom currency symbol option ([#4155](#4155)) ([8811a7e](8811a7e))
matticbot pushed a commit that referenced this pull request Sep 25, 2025
# [6.20.0-alpha.1](v6.19.0...v6.20.0-alpha.1) (2025-09-25)

### Bug Fixes

* Improve help text for Guest Contributor checkbox ([#4187](#4187)) ([5790f3d](5790f3d))
* newspack-plugin delay ([#4184](#4184)) ([22e8dc2](22e8dc2))
* update download URL for db.php ([#4193](#4193)) ([4d363db](4d363db))

### Features

* **collections:** add Collections block ([#4166](#4166)) ([1185157](1185157))
* **collections:** add logic for opening links in new tabs ([#4174](#4174)) ([07a5545](07a5545))
* **collections:** collections block feedback ([#4185](#4185)) ([0d0210c](0d0210c))
* **collections:** remove feature flag ([#4195](#4195)) ([b1619ef](b1619ef))
* **collections:** replace archive grid with collections block ([#4178](#4178)) ([d0cbadd](d0cbadd))
* **content-gate:** add countdown block ([#4176](#4176)) ([f8fe757](f8fe757))
* **my-account:** subscription switch modal ([#4177](#4177)) ([28c26e7](28c26e7))
* subscription tier modal ([#4164](#4164)) ([4d6ebe2](4d6ebe2))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 6.20.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Oct 6, 2025
# [6.20.0](v6.19.0...v6.20.0) (2025-10-06)

### Bug Fixes

* ga4 events for gate interactions and tiered modal ([#4209](#4209)) ([2d35768](2d35768))
* Improve help text for Guest Contributor checkbox ([#4187](#4187)) ([5790f3d](5790f3d))
* newspack-plugin delay ([#4184](#4184)) ([22e8dc2](22e8dc2))
* remove content gate countdown block ([0204e58](0204e58))
* update download URL for db.php ([#4193](#4193)) ([4d363db](4d363db))

### Features

* **collections:** add archive link in settings page ([#4203](#4203)) ([42694ec](42694ec))
* **collections:** add Collections block ([#4166](#4166)) ([1185157](1185157))
* **collections:** add css classes to meta elements ([#4208](#4208)) ([7fbf7e9](7fbf7e9))
* **collections:** add logic for opening links in new tabs ([#4174](#4174)) ([07a5545](07a5545))
* **collections:** collections block feedback ([#4185](#4185)) ([0d0210c](0d0210c))
* **collections:** remove feature flag ([#4195](#4195)) ([b1619ef](b1619ef))
* **collections:** replace archive grid with collections block ([#4178](#4178)) ([d0cbadd](d0cbadd))
* **content-gate:** add countdown block ([#4176](#4176)) ([f8fe757](f8fe757))
* **my-account:** subscription switch modal ([#4177](#4177)) ([28c26e7](28c26e7))
* subscription tier modal ([#4164](#4164)) ([4d6ebe2](4d6ebe2))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 6.20.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

released on @alpha released [Status] Approved The pull request has been reviewed and is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants