Skip to content

Add user directory page creation to installer and tools#1684

Open
sapayth wants to merge 1 commit intoweDevsOfficial:developfrom
sapayth:enhance/add_ud_page_if_module_active
Open

Add user directory page creation to installer and tools#1684
sapayth wants to merge 1 commit intoweDevsOfficial:developfrom
sapayth:enhance/add_ud_page_if_module_active

Conversation

@sapayth
Copy link
Member

@sapayth sapayth commented Aug 22, 2025

depends on #988

Added User Directory page creation if User Directory module is active.
CleanShot 2025-08-22 at 12 21 14

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

  • New Features
    • Automatically creates a "User Directory" page when the user-listing feature is available, with a ready-made Gutenberg layout (directory grid, user cards with avatar/name/contact/social, and a two-column profile view).
  • Style
    • Removed legacy "What's New" styling assets, cleaning up obsolete notice and changelog CSS.

@coderabbitai
Copy link

coderabbitai bot commented Aug 22, 2025

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 85fe7970-cea2-434d-9ad1-15cac328e91a

📥 Commits

Reviewing files that changed from the base of the PR and between c0964bf and 1b40a22.

📒 Files selected for processing (2)
  • assets/css/admin/whats-new.css
  • assets/less/whats-new.less
💤 Files with no reviewable changes (2)
  • assets/css/admin/whats-new.css
  • assets/less/whats-new.less

Walkthrough

Adds a conditional "User Directory" page creation in the admin installer (when WPUF_User_Listing exists), implements a private helper returning Gutenberg block markup for the directory/profile layout, and removes the "What's New" CSS/LESS assets.

Changes

Cohort / File(s) Summary
Admin installer: user directory page support
includes/Admin/Admin_Installer.php
Added conditional creation of a "User Directory" page guarded by WPUF_User_Listing; introduced private function get_user_directory_page_content() that returns Gutenberg block markup for directory and profile layouts; wired the content into init_pages.
Removed what's-new styles
assets/css/admin/whats-new.css, assets/less/whats-new.less
Deleted styling files for the "What's New" notice and changelog UI (all CSS/LESS rules removed).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I hop through blocks with a happy squeak,
I stitch user pages, bold not meek,
Styles gave way and markup grew,
A directory blooms — a fresh, new view! 🥕🐇

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add user directory page creation to installer and tools' accurately reflects the main change: adding conditional User Directory page creation to the Admin installer based on module availability.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link

@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

🧹 Nitpick comments (3)
includes/Admin/Admin_Installer.php (3)

89-93: Guard against duplicate "User Directory" pages on re-runs

Creation looks correct behind class_exists, but init_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_SINCE with a real version before release

Docblock 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 PHP

Long 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 2199d22 and 32b6d15.

📒 Files selected for processing (1)
  • includes/Admin/Admin_Installer.php (2 hunks)

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

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/profile renders correctly with default attributes (no userId).
  • Confirm no unintended links are produced to non-site domains.

@Rubaiyat-E-Mohammad
Copy link
Contributor

WPUF page is creating the page but all the blocks incomplete. @sapayth vai

Screen.Recording.2025-09-03.at.3.33.25.PM.mov

@Rubaiyat-E-Mohammad Rubaiyat-E-Mohammad added bug needs: testing needs: dev review This PR needs review by a developer and removed needs: testing labels Sep 3, 2025
@sapayth sapayth added needs: testing and removed bug needs: dev review This PR needs review by a developer labels Sep 30, 2025
@Rubaiyat-E-Mohammad
Copy link
Contributor

Rubaiyat-E-Mohammad commented Jan 13, 2026

Install WPUF Pages is not creating ant user directory pages @sapayth vai

Screen.Recording.2026-01-13.at.1.27.18.PM.mov

@sapayth sapayth force-pushed the enhance/add_ud_page_if_module_active branch from 1b40a22 to e37ebd3 Compare March 10, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants