Skip to content

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.
    • Provides a ready-made Gutenberg layout: directory grid with user cards (avatar, name, contact, social links) and a detailed profile section with a two-column design.
    • Adds the page content only when supported, avoiding unnecessary pages in unsupported environments.

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.
@coderabbitai
Copy link

coderabbitai bot commented Aug 22, 2025

Walkthrough

Adds conditional creation of a "User Directory" page during admin installation when WPUF_User_Listing exists, adds a private helper that returns Gutenberg block markup for the directory/profile layout, and plugs that content into page initialization.

Changes

Cohort / File(s) Summary of Changes
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() returning Gutenberg block markup for directory and profile layouts; wired this content into init_pages.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nibble code beneath moonbeams bright,
A directory page springs into light.
Blocks in rows and profiles neat,
I hop, I stitch, make layouts sweet.
Carrot cheers—deploy tonight! 🥕🐇


📜 Recent 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 32b6d15 and c585357.

📒 Files selected for processing (1)
  • includes/Admin/Admin_Installer.php (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • includes/Admin/Admin_Installer.php
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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