Skip to content

Conversation

@superdav42
Copy link
Collaborator

@superdav42 superdav42 commented Jan 1, 2026

Summary by CodeRabbit

  • New Features

    • Added new extension point for page widget registration, enabling enhanced customization options.
  • Refactor

    • Optimized site query handling for improved performance when retrieving site counts.
    • Enhanced bulk actions system with new filter support for better customization control.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 1, 2026

📝 Walkthrough

Walkthrough

Three modifications across the admin pages, site query logic, and site list tables: a new widget registration hook method, early-return optimization for count queries, and bulk actions filter application for extensibility.

Changes

Cohort / File(s) Summary
Admin Page Widget Registration
inc/admin-pages/class-base-admin-page.php
Adds fire_register_widgets_hook() method that fires a dynamic wu_page_{id}_register_widgets action at page load (priority 21), enabling external registration of page-specific widgets.
Site Query Optimization
inc/functions/site.php
Introduces early-return path in wu_get_sites(): when query['count'] is present, returns a count query directly via Site::query(), bypassing domain-search merge logic that would normally run for search-enabled queries.
List Table Extension
inc/list-tables/class-site-list-table.php
Wraps get_bulk_actions() return value with wu_site_list_get_bulk_actions filter, allowing external code to modify bulk actions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A hook fires bright on widget's page,
Count queries skip the merging stage,
Bulk actions bloom through filters' grace—
Extension points in every place! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'support multinetwork' is vague and generic, failing to describe the specific changes made to the codebase. Provide a more specific title describing the actual changes, such as 'Add fire_register_widgets_hook for widget registration' or 'Add multinetwork support for site queries and bulk actions'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings

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 and usage tips.

@github-actions
Copy link

github-actions bot commented Jan 1, 2026

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1ddcfc1 and d2a85b7.

📒 Files selected for processing (3)
  • inc/admin-pages/class-base-admin-page.php
  • inc/functions/site.php
  • inc/list-tables/class-site-list-table.php
🧰 Additional context used
🧬 Code graph analysis (1)
inc/functions/site.php (1)
inc/models/class-site.php (1)
  • Site (26-1942)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: PHP 8.1
  • GitHub Check: PHP 8.0
  • GitHub Check: Build Plugin for Testing
  • GitHub Check: cypress (8.1, chrome)
  • GitHub Check: cypress (8.2, chrome)
🔇 Additional comments (3)
inc/list-tables/class-site-list-table.php (1)

380-388: LGTM! Good extensibility addition.

The filter wu_site_list_get_bulk_actions is well-documented and allows external modification of bulk actions, improving extensibility for plugins and themes.

inc/admin-pages/class-base-admin-page.php (2)

626-626: LGTM! New hook provides extensibility for widget registration.

The new action hook at priority 21 enables addons to register widgets after the core registration completes.


734-756: LGTM! Well-documented extensibility method.

The fire_register_widgets_hook() method is properly documented and provides a clean extension point for page-specific widget registration via the dynamic action wu_page_{$this->id}_register_widgets.

Comment on lines +68 to +72
// If we're just counting, skip the domain search merge logic
// and do a simple count query.
if ( ! empty($query['count'])) {
return \WP_Ultimo\Models\Site::query($query);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# First, let's examine the file and the specific lines mentioned
cat -n inc/functions/site.php | head -120

Repository: Multisite-Ultimate/ultimate-multisite

Length of output: 3644


🏁 Script executed:

# Search for wu_get_sites calls with both count and search parameters
rg -n 'wu_get_sites\s*\(' --type=php -A 10 | head -100

Repository: Multisite-Ultimate/ultimate-multisite

Length of output: 4799


🏁 Script executed:

# More targeted search for count + search combination
rg -n "wu_get_sites" --type=php -B 2 -A 5 | rg -A 5 -B 2 "count|search"

Repository: Multisite-Ultimate/ultimate-multisite

Length of output: 408


🏁 Script executed:

# Examine the list table implementation around the wu_get_sites call
cat -n inc/list-tables/class-site-list-table.php | sed -n '60,120p'

Repository: Multisite-Ultimate/ultimate-multisite

Length of output: 2097


🏁 Script executed:

# Search specifically for cases where 'count' and 'search' appear together in query construction
rg -n "'count'|'search'" --type=php -B 3 -A 3 | grep -B 5 -A 5 "count.*search|search.*count"

Repository: Multisite-Ultimate/ultimate-multisite

Length of output: 63


🏁 Script executed:

# Look at prepare_items method to see the full query construction
ast-grep --pattern $'function prepare_items() {
  $$$
}'

Repository: Multisite-Ultimate/ultimate-multisite

Length of output: 63


🏁 Script executed:

# Search for prepare_items method and how get_items is called
rg -n "prepare_items|get_items" inc/list-tables/class-site-list-table.php -B 2 -A 10

Repository: Multisite-Ultimate/ultimate-multisite

Length of output: 735


🏁 Script executed:

# Check parent class to understand list table pagination
rg -n "class.*List_Table|prepare_items" inc/list-tables/class-site-list-table.php -A 20 | head -50

Repository: Multisite-Ultimate/ultimate-multisite

Length of output: 586


🏁 Script executed:

# Check the Base_List_Table to understand how pagination uses the count parameter
fd "class-base-list-table" --type=php

Repository: Multisite-Ultimate/ultimate-multisite

Length of output: 251


🏁 Script executed:

# Search for pagination or prepare_items in the base class
rg -n "prepare_items|total_items|get_items" inc/list-tables/class-base-list-table.php -A 5

Repository: Multisite-Ultimate/ultimate-multisite

Length of output: 2616


🏁 Script executed:

# Check how record_count is used in prepare_items
rg -n "record_count" inc/list-tables/class-base-list-table.php -B 5 -A 5

Repository: Multisite-Ultimate/ultimate-multisite

Length of output: 1415


🏁 Script executed:

# Verify the full flow: check if search parameter is indeed passed during count
rg -n "wu_request.*'s'|search.*wu_request" inc/list-tables/ -B 2 -A 2

Repository: Multisite-Ultimate/ultimate-multisite

Length of output: 2000


Fix count queries to include mapped domain matches when search filters are applied.

The list table pagination relies on record_count() which calls wu_get_sites() with both count=true and a search parameter (line 79 in class-site-list-table.php). However, the count query early returns at line 70-71 in inc/functions/site.php, bypassing the domain-search merge logic (lines 74-106). This causes pagination to report an incorrect total when searching text that matches mapped domains—the pagination count excludes those matches while the actual result set includes them.

The mismatch occurs because:

  • record_count()get_items(..., true)wu_get_sites(['count' => true, 'search' => ...]) skips the domain merge
  • prepare_items()get_items(..., false)wu_get_sites(['count' => false, 'search' => ...]) includes the domain merge

Apply the domain-search merge logic before returning the count so pagination totals remain consistent with actual result sets.

🤖 Prompt for AI Agents
In inc/functions/site.php around lines 68 to 72, the early return for count
queries skips the mapped-domain search merge logic, causing pagination totals to
differ from actual result sets when a search term matches mapped domains; move
or duplicate the domain-search merge logic so it runs even when $query['count']
is true (i.e., perform the mapped-domain lookup/merge into $query prior to
returning the count), ensuring the count query includes the same domain-based
filters as the non-count path and returns the correct total.

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.

2 participants