Add user directory page creation to installer and tools#1684
Add user directory page creation to installer and tools#1684sapayth wants to merge 3 commits intoweDevsOfficial:developfrom
Conversation
The installer now creates a 'User Directory' page with predefined block content if the WPUF_User_Listing class exists. This adds support for automatic setup of user directory features during installation.
WalkthroughAdds conditional creation of a "User Directory" page during admin installation when Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
includes/Admin/Admin_Installer.php (3)
89-93: Guard against duplicate "User Directory" pages on re-runsCreation looks correct behind
class_exists, butinit_pages()can be re-triggered (tools/rehydration). Add an existence check to avoid multiple pages and optionally persist the created page ID for later reference in settings/UIs.- if ( class_exists( 'WPUF_User_Listing' ) ) { - $this->create_page( __( 'User Directory', 'wp-user-frontend' ), $this->get_user_directory_page_content() ); - } + if ( class_exists( 'WPUF_User_Listing' ) ) { + $existing = get_page_by_title( __( 'User Directory', 'wp-user-frontend' ) ); + if ( ! $existing ) { + $directory_page_id = $this->create_page( + __( 'User Directory', 'wp-user-frontend' ), + $this->get_user_directory_page_content() + ); + // Optionally persist for admin links or future checks: + // update_option( 'wpuf_user_directory_page', $directory_page_id ); + } + }
197-199: Replace placeholder@since WPUF_SINCEwith a real version before releaseDocblock still carries a template token. Update to the actual plugin version or the appropriate constant used by your release tooling.
201-245: Consider registering a block pattern instead of embedding large markup in PHPLong inline block HTML is hard to maintain and review. A named block pattern (registered on
init) would let editors reinsert/update it easily and keeps this installer lean; the installer would then create a page that references the pattern or just inject the pattern content at creation time.I can sketch a
register_block_pattern( 'wpuf/user-directory', ... )with the same markup and update the installer to use it—want me to draft that?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
includes/Admin/Admin_Installer.php(2 hunks)
includes/Admin/Admin_Installer.php
Outdated
There was a problem hiding this comment.
Remove hard-coded user data (admin101, wpuf.test) and ephemeral block attributes
The block attributes embed a real username, userId=1, and dev-domain links. This will leak environment-specific/PII-ish data into customer sites and may render incorrect links. Also attributes like block_instance_id, hasSelectedLayout, and hasSelectedPattern are editor-state noise that make content brittle. Replace with a minimal, portable layout; localize visible text (e.g., “Bio”).
- private function get_user_directory_page_content() {
- return '<!-- wp:wpuf-ud/directory {"directory_layout":"roundGrids","hasSelectedLayout":true,"selectedLayout":"roundGrids"} -->
+ private function get_user_directory_page_content() {
+ $bio = esc_html__( 'Bio', 'wp-user-frontend' );
+ return <<<HTML
+<!-- wp:wpuf-ud/directory {"directory_layout":"roundGrids"} -->
<div class="wp-block-wpuf-ud-directory"><!-- wp:wpuf-ud/directory-item -->
<div class="wp-block-wpuf-ud-directory-item"><!-- wp:group {"className":"is-style-default","style":{"border":{"radius":"8px","color":"#d1d5db","width":"1px"},"spacing":{"margin":{"top":"0","bottom":"0"},"blockGap":"0","padding":{"top":"var:preset|spacing|30","bottom":"var:preset|spacing|30","left":"0","right":"0"}}},"layout":{"type":"flex","orientation":"vertical","justifyContent":"center"}} -->
<div class="wp-block-group is-style-default has-border-color" style="border-color:#d1d5db;border-width:1px;border-radius:8px;margin-top:0;margin-bottom:0;padding-top:var(--wp--preset--spacing--30);padding-right:0;padding-bottom:var(--wp--preset--spacing--30);padding-left:0"><!-- wp:wpuf-ud/avatar {"avatarSize":"custom","fallbackType":"gravatar","customSize":128} /-->
<!-- wp:wpuf-ud/name {"textAlign":"center","style":{"color":"#0F172A","fontWeight":"bold","typography":{"fontWeight":"600","fontSize":"20px","lineHeight":"2"}}} /-->
<!-- wp:wpuf-ud/contact {"showIcons":false,"iconSize":"small","showLabels":false,"className":"wpuf-user-contact-info wpuf-contact-layout-inline"} /-->
<!-- wp:wpuf-ud/social {"iconSize":"medium"} -->
<div class="wp-block-wpuf-ud-social"><div class="wpuf-social-fields"></div></div>
<!-- /wp:wpuf-ud/social -->
<!-- wp:wpuf-ud/button {"textColor":"base","fontSize":"medium","style":{"color":{"background":"#7c3aed"},"border":{"radius":"6px"}}} /--></div>
<!-- /wp:group --></div>
<!-- /wp:wpuf-ud/directory-item --></div>
-<!-- /wp:wpuf-ud/directory -->
-
-<!-- wp:wpuf-ud/profile {"block_instance_id":"e111db80-9c50-4642-aaa7-b56a8ebc54b1","userId":1,"userObject":{"id":1,"user_login":"admin101","display_name":"admin101","user_email":"","user_url":"https://wpuf.test","bio":"","avatar":"","first_name":"","last_name":"","nickname":"","name":"admin101","url":"https://wpuf.test","description":"","link":"https://wpuf.test/author/admin101/","slug":"admin101","avatar_urls":{"24":"https://secure.gravatar.com/avatar/74a43f5a2491b706609180d3059d0b4269b25d859801497ec0d248fe75f37ac4?s=24\\u0026d=mm\\u0026r=g","48":"https://secure.gravatar.com/avatar/74a43f5a2491b706609180d3059d0b4269b25d859801497ec0d248fe75f37ac4?s=48\\u0026d=mm\\u0026r=g","96":"https://secure.gravatar.com/avatar/74a43f5a2491b706609180d3059d0b4269b25d859801497ec0d248fe75f37ac4?s=96\\u0026d=mm\\u0026r=g"},"meta":[],"_links":{"self":[{"href":"https://wpuf.test/wp-json/wp/v2/users/1","targetHints":{"allow":["GET","POST","PUT","PATCH","DELETE"]}}],"collection":[{"href":"https://wpuf.test/wp-json/wp/v2/users"}]}},"canEdit":"1","hasSelectedPattern":true} -->
+<!-- /wp:wpuf-ud/directory -->
+
+<!-- wp:wpuf-ud/profile -->
<div class="wp-block-wpuf-ud-profile wpuf-user-profile"><!-- wp:columns {"className":"wpuf-flex wpuf-flex-row wpuf-gap-8 wpuf-border wpuf-border-gray-200 wpuf-rounded-lg wpuf-p-8"} -->
<div class="wp-block-columns wpuf-flex wpuf-flex-row wpuf-gap-8 wpuf-border wpuf-border-gray-200 wpuf-rounded-lg wpuf-p-8"><!-- wp:column {"width":"33%","className":"wpuf-profile-sidebar","style":{"border":{"width":"0 1px 0 0","style":"solid","color":"#E5E7EB"}}} -->
<div class="wp-block-column wpuf-profile-sidebar has-border-color" style="border-color:#E5E7EB;border-style:solid;border-width:0 1px 0 0;flex-basis:33%"><!-- wp:wpuf-ud/avatar {"avatarSize":"custom","customSize":100} /-->
<!-- wp:wpuf-ud/name {"headingLevel":"h2","showRole":true} /-->
<!-- wp:wpuf-ud/contact {"showFields":["display_name","user_email","user_url"],"layoutStyle":"vertical","showLabels":false,"style":{"spacing":{"margin":{"top":"1rem","bottom":"1rem"}}}} /-->
<!-- wp:group {"className":"wpuf-mt-8","style":{"spacing":{"margin":{"top":"2rem"}}}} -->
-<div class="wp-block-group wpuf-mt-8" style="margin-top:2rem"><!-- wp:heading {"level":4,"style":{"spacing":{"margin":{"top":"2rem"}}}} -->
-<h4 class="wp-block-heading" style="margin-top:2rem">Bio</h4>
+<div class="wp-block-group wpuf-mt-8" style="margin-top:2rem"><!-- wp:heading {"level":4,"style":{"spacing":{"margin":{"top":"2rem"}}}} -->
+<h4 class="wp-block-heading" style="margin-top:2rem">{$bio}</h4>
<!-- /wp:heading -->
<!-- wp:wpuf-ud/bio {"characterLimit":100,"style":{"spacing":{"margin":{"top":".75rem"}}}} /--></div>
<!-- /wp:group --></div>
<!-- /wp:column -->
<!-- wp:column {"width":"67%","className":"wpuf-profile-content"} -->
<div class="wp-block-column wpuf-profile-content" style="flex-basis:67%"><!-- wp:wpuf-ud/tabs -->
<div class="wpuf-user-tabs" data-about-content="[]"></div>
<!-- /wp:wpuf-ud/tabs --></div>
<!-- /wp:column --></div>
<!-- /wp:columns --></div>
-<!-- /wp:wpuf-ud/profile -->';
+<!-- /wp:wpuf-ud/profile -->
+HTML;
}Follow-ups:
- Validate that
wpuf-ud/profilerenders correctly with default attributes (nouserId). - Confirm no unintended links are produced to non-site domains.
|
WPUF page is creating the page but all the blocks incomplete. @sapayth vai Screen.Recording.2025-09-03.at.3.33.25.PM.mov |
|
Screen.Recording.2026-01-13.at.1.27.18.PM.mov |
depends on #988
Added User Directory page creation if User Directory module is active.

Also the installer now creates a 'User Directory' page with predefined block content if the WPUF_User_Listing class exists. This adds support for automatic setup of user directory features during installation.
Summary by CodeRabbit