Skip to content

refactor: SeoPress capabilities for Redirections and Broken links#70

Open
mvdhoek1 wants to merge 1 commit into
mainfrom
refactor/seopress-capabilities-redirection-and-broken-links
Open

refactor: SeoPress capabilities for Redirections and Broken links#70
mvdhoek1 wants to merge 1 commit into
mainfrom
refactor/seopress-capabilities-redirection-and-broken-links

Conversation

@mvdhoek1

@mvdhoek1 mvdhoek1 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

The 'edit_broken_links' and 'edit_redirections' capability needs to be added to the 'wpseo' cap group for this to work inside the user-roles config.
Screenshot 2026-06-08 at 17 20 00

The following functionalities are still missing from this PR:

  • Adding a new redirection (editing an existing redirection works correctly)
  • Export of broken links

Copilot AI review requested due to automatic review settings June 8, 2026 15:22
@mvdhoek1 mvdhoek1 requested a review from a team as a code owner June 8, 2026 15:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts how SEOPress Pro admin access is gated so non-admin roles can access Redirections and Broken Links screens via the edit_redirections / edit_broken_links capabilities (instead of requiring manage_options).

Changes:

  • Lowers the SEOPress main menu capability from manage_options to edit_redirections (admin-only context).
  • Removes SEOPress Dashboard/License submenu pages for users who don’t have manage_options.
  • Remaps the seopress_bot CPT list capability to edit_broken_links and ensures the seopress_404 CPT is registered early enough on relevant admin requests.
Comments suppressed due to low confidence (1)

src/SEOPress.php:13

  • The PR description mentions adding edit_broken_links / edit_redirections to the wpseo cap group, but this change set only touches SEOPress hooks (seopress_capability, CPT args, menu adjustments). If the goal is specifically about a wpseo group in the user-roles config, either update the PR description to match the implemented SEOPress approach, or add the missing wpseo-group change (if that’s still required).
#[Plugin('wp-seopress-pro/seopress-pro.php')]
class SEOPress
{

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/SEOPress.php
Comment thread src/SEOPress.php Outdated
Comment on lines +113 to +123
$redirectionPages = ['edit.php', 'post.php', 'post-new.php'];

if (
! is_admin()
|| ! in_array($pagenow, $redirectionPages, true)
|| ('edit.php' === $pagenow && isset($_GET['post_type']) && 'seopress_404' !== $_GET['post_type'])
|| post_type_exists('seopress_404')
|| ! function_exists('seopress_404_fn')
) {
return;
}
@mvdhoek1 mvdhoek1 force-pushed the refactor/seopress-capabilities-redirection-and-broken-links branch 2 times, most recently from 041787d to 30ca8e8 Compare June 9, 2026 04:41
@mvdhoek1 mvdhoek1 requested a review from Copilot June 9, 2026 14:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread src/SEOPress.php
Comment thread src/SEOPress.php
Comment on lines +49 to 52
// Lower the main SEO menu cap from manage_options to edit_redirections so roles without manage_options can access it.
if ('menu' === $context && 'manage_options' === $cap) {
return 'edit_redirections';
}
@mvdhoek1 mvdhoek1 force-pushed the refactor/seopress-capabilities-redirection-and-broken-links branch from 30ca8e8 to 13cf673 Compare June 10, 2026 07:57
@mvdhoek1 mvdhoek1 force-pushed the refactor/seopress-capabilities-redirection-and-broken-links branch from 13cf673 to 520dd50 Compare June 10, 2026 09:57
Comment thread src/SEOPress.php
return;
}

if (post_type_exists('seopress_404') || ! function_exists('seopress_404_fn')) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

|| ! function_exists('seopress_404_fn') kan evt aan de if statement hierboven toegevoegd worden toch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ik vind de 2 if statements nu goed verdeeld, eerst de admin checks en daarna die van SeoPress.

@YvetteNikolov

Copy link
Copy Markdown
Contributor

Voordat je merget, ik heb deze change doorgevoerd #76

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.

5 participants