Skip to content

Conversation

@sapayth
Copy link
Member

@sapayth sapayth commented Oct 20, 2025

fixes #1178

In Post Forms > Field Options > Visibility, selecting the Subscription users only option will now let the user select the subscription pack. Only the selected subscription pack holder will see this field in the frontend.

CleanShot 2025-10-20 at 11 08 26

Summary by CodeRabbit

  • Refactor
    • Modernized internal class references to improve code organization and consistency. Subscription management functionality remains unchanged.

@coderabbitai
Copy link

coderabbitai bot commented Oct 20, 2025

Walkthrough

Two template files are updated to check for the namespaced WeDevs\Wpuf\Admin\Subscription class instead of the legacy WPUF_Subscription class when rendering subscription-related UI components.

Changes

Cohort / File(s) Summary
Subscription class reference updates
admin/form-builder/assets/js/components/field-visibility/template.php, assets/js-templates/form-components.php
Replace legacy WPUF_Subscription class checks with namespaced WeDevs\Wpuf\Admin\Subscription in conditional subscription rendering logic

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

The changes follow a consistent, repetitive pattern across two files—straightforward class reference replacements with no logic modifications or error-handling alterations.

Possibly related PRs

Suggested reviewers

  • Rubaiyat-E-Mohammad

Poem

🐰 A hop through the namespaces we go,
Legacy shadows fade to glow,
WPUF old, now WeDevs new,
Subscriptions clean—refactored true!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "fix: show subscription plan in field options" directly relates to the primary change described in the PR objectives. The objectives state that the PR adds functionality to allow users to select a specific subscription pack when the "Subscription users only" option is selected in field visibility settings. The title accurately identifies this feature as making subscription plans available in field options, which is clear and specific enough for developers reviewing the PR history to understand the main purpose of the change. The title is neither misleading nor overly vague, as it clearly references the subscription plan functionality being added to the field options component.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35fec8b and 3823fce.

📒 Files selected for processing (2)
  • admin/form-builder/assets/js/components/field-visibility/template.php (1 hunks)
  • assets/js-templates/form-components.php (1 hunks)
🔇 Additional comments (2)
admin/form-builder/assets/js/components/field-visibility/template.php (2)

742-742: Good consistency with the parallel template.

This change mirrors the update in admin/form-builder/assets/js/components/field-visibility/template.php at line 95. Both files now consistently check for the namespaced WeDevs\Wpuf\Admin\Subscription class instead of the legacy WPUF_Subscription.

Note: The same verification concerns mentioned in the other file apply here as well.


95-95: Migration verified: class check and instantiation are correct.

The new namespaced WeDevs\Wpuf\Admin\Subscription class exists and is properly registered in the service container at wpuf.php:173. The template's class_exists() check will pass, and wpuf()->subscription on line 96 correctly resolves to the instantiated service container object. The method get_subscription() is available in the new class, so the change will function correctly without breaking existing installations.

<?php

if ( class_exists( 'WPUF_Subscription' ) ) {
if ( class_exists( 'WeDevs\Wpuf\Admin\Subscription' ) ) {
Copy link

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

Verify the namespaced class is available.

The class name has been correctly updated to use the namespaced WeDevs\Wpuf\Admin\Subscription instead of the legacy WPUF_Subscription. This aligns with modernizing the codebase architecture.

Run the following script to verify the new class exists and is properly autoloaded:


🏁 Script executed:

#!/bin/bash
# Verify the namespaced Subscription class exists in the codebase

# Search for the class definition
rg -n "class\s+Subscription" --type=php -C3

# Search for namespace declaration
rg -n "namespace\s+WeDevs\\\\Wpuf\\\\Admin" --type=php -C2

# Verify there are no remaining references to the old class name in visibility contexts
rg -n "WPUF_Subscription" --type=php -C2

Length of output: 13571


Critical inconsistency detected: namespace migration is incomplete.

The template change at line 742 references the new WeDevs\Wpuf\Admin\Subscription class, but the codebase still heavily uses the legacy WPUF_Subscription class:

  • Frontend rendering code (includes/class-field-manager.php:311, includes/class-frontend-render-form.php:917, class/render-form.php:611) continues to call WPUF_Subscription::init()->get_user_pack()
  • The template attempts to call wpuf()->subscription->get_subscriptions() which must be properly registered in the service container for the new class

If the service container registration is missing or the new class isn't properly hooked into the plugin's initialization, this change will silently fail and subscriptions won't display in field visibility options.

Verify:

  1. That wpuf()->subscription is properly initialized with WeDevs\Wpuf\Admin\Subscription in the service container
  2. That the new class provides the same interface as the legacy WPUF_Subscription class (specifically the get_subscriptions() method)
  3. Whether the full namespace migration should be completed across all frontend code
🤖 Prompt for AI Agents
In assets/js-templates/form-components.php around line 742, the template now
references the namespaced WeDevs\Wpuf\Admin\Subscription but the codebase still
uses the legacy WPUF_Subscription and the service container may not register the
new class; ensure wpuf()->subscription is initialized to an instance of
WeDevs\Wpuf\Admin\Subscription (or register a service alias) in the plugin
bootstrap/service container, confirm the new class implements the same public
API used elsewhere (at least get_subscriptions()), and if necessary add an
adapter that exposes the legacy static methods or update all legacy calls (e.g.
WPUF_Subscription::init()->get_user_pack() and other frontend usages) to resolve
the subscription service from wpuf() so the template and frontend code
consistently use the same implementation.

@Rubaiyat-E-Mohammad Rubaiyat-E-Mohammad added QA Approved This PR is approved by the QA team and removed needs: testing labels Oct 23, 2025
@sapayth sapayth merged commit a551c61 into weDevsOfficial:develop Nov 3, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

QA Approved This PR is approved by the QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants