Skip to content

Fix PHP notice related to script registering in Styles settings#3103

Closed
truongwp wants to merge 1 commit into
masterfrom
pro-issue-6338
Closed

Fix PHP notice related to script registering in Styles settings#3103
truongwp wants to merge 1 commit into
masterfrom
pro-issue-6338

Conversation

@truongwp
Copy link
Copy Markdown
Contributor

@truongwp truongwp commented May 26, 2026

Fixes https://github.com/Strategy11/formidable-pro/issues/6338

Summary by CodeRabbit

  • Refactor
    • Improved internal script and style registration logic in the form controller system, optimizing how dependencies are initialized for the form builder and Visual Styler components.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 206ee8d8-7e9f-43c9-8e61-fb662471baa1

📥 Commits

Reviewing files that changed from the base of the PR and between f60adf4 and 2149215.

📒 Files selected for processing (2)
  • classes/controllers/FrmFormsController.php
  • classes/controllers/FrmStylesController.php

📝 Walkthrough

Walkthrough

FrmFormsController extracts frontend formidable script registration into a dedicated public method. FrmStylesController adds a parallel method for style editor script and stylesheet registration, with both registration methods called early during style editor initialization to make dependency handles available before enqueueing operations.

Changes

Script Registration Refactoring

Layer / File(s) Summary
Frontend script registration extraction
classes/controllers/FrmFormsController.php
New register_formidable_script() method centralizes formidable frontend script registration logic. front_head() is refactored to call this method instead of containing registration inline.
Style editor script and style registration
classes/controllers/FrmStylesController.php
New register_style_script() method registers formidable_style admin script and stylesheet with conditional Pro-based datepicker dependency. admin_init() calls both registration methods during initialization. setup_styles_and_scripts_for_styler() calls the new registration method first to ensure handles exist before later enqueueing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A script's refrain, now neatly tucked,
Registration calls where dependencies stuck,
No more inline, just methods that glow,
Dependencies ready, they're first in the flow!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: extracting script registration logic into dedicated methods to fix a PHP notice issue in Styles settings, which aligns with the PR objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pro-issue-6338

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.

@deepsource-io
Copy link
Copy Markdown

deepsource-io Bot commented May 26, 2026

DeepSource Code Review

We reviewed changes in f60adf4...2149215 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP May 26, 2026 6:20p.m. Review ↗
JavaScript May 26, 2026 6:20p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@truongwp truongwp requested a review from Crabcyborg May 26, 2026 18:26
}

FrmStyleComponent::register_assets();
FrmFormsController::register_formidable_script();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@truongwp I think we might want to fix this in a different way.

We don't want the front end scripts loading in the styler. Those are off intentionally.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In FrmProFormsController::admin_footer(), we have a call to enqueue_footer_js(), which enqueues the Pro JS.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hm, I think we'll want to fix this in Pro then. It sounds like Pro shouldn't be doing that either.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do we need to load the frontend JS on the Styles page?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@truongwp No, the front end JS is only meant for the front end, and the entry editing page (which uses front end forms).

Pages like the styler, builder, and form settings, should never load the front end JS.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok. I will dequeue the frontend JS on the Styles page.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I created PR https://github.com/Strategy11/formidable-pro/pull/6487 in Pro to fix this issue. We can close this for now.

@Crabcyborg
Copy link
Copy Markdown
Contributor

Thank you @truongwp!

@Crabcyborg Crabcyborg closed this Jun 4, 2026
@Crabcyborg Crabcyborg deleted the pro-issue-6338 branch June 4, 2026 19:08
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