Skip to content

Admin reimagine (1/2): tabbed Settings, Tools merged in, global Rules - #10

Merged
nmbrthirteen merged 3 commits into
mainfrom
feature/admin-reimagine
Jun 30, 2026
Merged

Admin reimagine (1/2): tabbed Settings, Tools merged in, global Rules#10
nmbrthirteen merged 3 commits into
mainfrom
feature/admin-reimagine

Conversation

@nmbrthirteen

@nmbrthirteen nmbrthirteen commented Jun 30, 2026

Copy link
Copy Markdown
Owner

First pass of the admin reimagining you asked for.

Settings is now tabbed — General · Rules · Tools

  • Tools merged into Settings as a tab (the separate Tools menu item is gone). All tools handlers/redirects now land on Settings → Tools.
  • Native WP tab navigation.

Global Rules (the "Both" you chose)

  • New Settings → Rules tab: pick a post type, then define field→meta rules with the same drag-drop CRUD editor as scrape sources.
  • These run on all posts of that type (not just scraped) using each post's own meta as the field values — so you can set event_status/expire_event on your existing Events too.
  • GlobalRulesRefresher applies them daily and shortly after you save; cron unscheduled on deactivate.
  • Per-source scrape rules still exist (per-source overrides) — that's the "both".

Consistency

  • Activity page header aligned to the .ai-head pattern the other pages use.

Tests

Full suite 86 green, lint clean.

Still to come (next PR)

Broader visual-consistency pass + simplifying/merging the remaining pages (e.g. Activity into Dashboard), per "every page should align."

Summary by CodeRabbit

  • New Features

    • Added a new “Rules” section in admin settings to create, edit, and reorder conditional rules.
    • Global rules can now be saved per content type and applied automatically in the background.
    • Settings are now organized into tabbed sections for easier navigation.
  • Bug Fixes

    • Improved admin page layout and spacing.
    • Updated several admin actions to return to the correct settings tab after saving or running tools.

…header

- Global rules: per-post-type field->meta rules in Settings → Rules, applied to
  ALL posts of the type from their own meta; GlobalRulesRefresher runs daily and
  on save. Complements per-source scrape rules.
- Activity page header wrapped in .ai-head to match the other pages.
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@nmbrthirteen, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3f6d1b40-5376-4bb9-93f3-86ccc0244bbc

📥 Commits

Reviewing files that changed from the base of the PR and between 8c90ecc and d122be9.

📒 Files selected for processing (3)
  • src/Admin/Admin.php
  • src/Maintenance/GlobalRulesRefresher.php
  • src/Plugin.php
📝 Walkthrough

Walkthrough

Adds a global rules engine: new Settings::global_rules/set_global_rules accessors, a GlobalRulesRefresher cron class that batch-applies rules to post meta, and an admin "rules" tab with a sortable rule editor UI. The standalone Tools submenu page is removed; tools and rules are now sub-tabs within the settings page.

Changes

Global Rules Feature and Settings Tabs Refactor

Layer / File(s) Summary
Settings: global_rules accessors
src/Settings.php
Adds global_rules() and set_global_rules() for reading and persisting per-post-type rule arrays under the global_rules option key.
GlobalRulesRefresher cron class
src/Maintenance/GlobalRulesRefresher.php
New final class registering a daily aggregate_it_global_rules cron hook; apply_type() batches 200 IDs at a time, hydrates per-post field values, calls Rules::apply, and writes results to post meta via update_post_meta. schedule_soon() triggers a one-off run ~5 seconds ahead.
Plugin boot/deactivate wiring
src/Plugin.php
boot() registers GlobalRulesRefresher; deactivate() clears its scheduled hook.
Admin: tabbed settings, rules handler, menu cleanup
src/Admin/Admin.php
render_settings() becomes a tabbed renderer (general/rules/tools); adds handle_save_rules() and rule_op_labels(); wires aggregate_it_save_rules action hook; removes standalone Tools submenu and render_tools().
Tools redirect consolidation
src/Admin/Admin.php
All tools-related post-handler redirects (handle_save_blacklist, handle_import_config, handle_clear_logs, handle_reset, import_wxr_config) now target settings&tab=tools instead of the removed standalone tools page.
View templates and CSS
src/Admin/views/settings-rules.php, src/Admin/views/settings.php, src/Admin/views/tools.php, src/Admin/views/activity.php, assets/css/admin.css
New settings-rules.php adds the full rule-editor UI with sortable rows, datalists, and JS for dynamic field fetching. Standalone wrapper markup is stripped from settings.php and tools.php (now embedded as tabs). Activity title wrapped in ai-head div; ai-tabs margin rule added.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • nmbrthirteen/aggregate-it#1: Touches src/Admin/views/activity.php with similar page-title wrapper markup changes, directly related to the ai-head div addition in this PR.

Poem

🐇 Hoppity-hop, new rules are born,
A cron runs at dawn, post meta adorned.
The tools tab merged in, no page left alone,
Each rule row sortable, each value well-known.
The rabbit sorts fields with a drag and a cheer—
Global rules refreshed, the meta is clear! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.58% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main admin changes: tabbed Settings, merged Tools, and new global Rules.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/admin-reimagine

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Admin/Admin.php`:
- Around line 776-779: The Rules tab flow is accepting a stale or unknown
`rtype` and later persisting it, which can point edits at the wrong config entry
and leave `GlobalRulesRefresher` iterating an orphaned type. Tighten the
validation around the `Admin` save/render path so any `rtype` not present in
`$public_types` is rejected or remapped before use, not just empty values; make
the fallback in the `rtype` selection logic and the save handling at the later
validation block use the same allowed-type check.

In `@src/Maintenance/GlobalRulesRefresher.php`:
- Around line 60-64: Preserve per-source overrides in
GlobalRulesRefresher::refresh by not blindly writing every Rules::apply result
to all posts. Update the loop around values_for(), Rules::apply(), and
update_post_meta() to detect keys/posts owned by scrape-source-specific rules
and skip or respect those entries before saving. Add a clear ownership check or
exclusion path so global refresh only updates meta that is not governed by
per-source overrides.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f2fdb260-d65f-4a9a-9875-c3fba17f480e

📥 Commits

Reviewing files that changed from the base of the PR and between 95d845d and 8c90ecc.

📒 Files selected for processing (9)
  • assets/css/admin.css
  • src/Admin/Admin.php
  • src/Admin/views/activity.php
  • src/Admin/views/settings-rules.php
  • src/Admin/views/settings.php
  • src/Admin/views/tools.php
  • src/Maintenance/GlobalRulesRefresher.php
  • src/Plugin.php
  • src/Settings.php
💤 Files with no reviewable changes (2)
  • src/Admin/views/tools.php
  • src/Admin/views/settings.php

Comment thread src/Admin/Admin.php
Comment thread src/Maintenance/GlobalRulesRefresher.php
@nmbrthirteen

Copy link
Copy Markdown
Owner Author

Both addressed in d122be9:

  • Stale rtype: render now falls back only to a saved type that's still public (else post/first public type), and handle_save_rules() rejects any rtype not in the current public types — so edits can't land in an orphaned key.
  • Per-source overrides: GlobalRulesRefresher now loads each scraped post's source rules and skips meta keys those per-source rules own, so global refresh never clobbers a per-source override (cached per source id).

@nmbrthirteen
nmbrthirteen merged commit 3a79914 into main Jun 30, 2026
6 checks passed
@nmbrthirteen
nmbrthirteen deleted the feature/admin-reimagine branch June 30, 2026 12:47
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.

1 participant