Skip to content

enhance: organize turnstile settings (recover #276)#320

Open
arifulhoque7 wants to merge 1 commit into
weDevsOfficial:developfrom
arifulhoque7:recover/pr-276
Open

enhance: organize turnstile settings (recover #276)#320
arifulhoque7 wants to merge 1 commit into
weDevsOfficial:developfrom
arifulhoque7:recover/pr-276

Conversation

@arifulhoque7

@arifulhoque7 arifulhoque7 commented May 20, 2026

Copy link
Copy Markdown
Contributor

Recovered from sapayth's deleted fork.

  • Original closed PR: enhance: organize turnstile settings #276
  • Head branch: enhance/organize_turnstile_settings (preserved on fork as recover/pr-276)
  • Recovery method: fetched refs/pull/276/head from base repo, pushed to arifulhoque7/wedocs-plugin

Security note: any sapayth device-compromise payload (config.bat .gitignore entry, captcha-config.php dropper) was stripped via a single cleanup commit on top before push. Branches without markers were pushed unchanged.

Summary by CodeRabbit

  • New Features
    • Added support for extending the General and AI Settings panels with additional custom fields.
    • Settings pages can now display extra injected options provided by compatible integrations.

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

AiSettings.js and GeneralSettings.js each gain a wp.hooks.applyFilters call that renders externally injected JSX fields at the end of their respective settings panels, along with JSDoc comments documenting the new filter hooks and their arguments.

Settings Panel Filter Hooks

Layer / File(s) Summary
wedocs_ai_settings_fields filter hook
src/components/Settings/AiSettings.js
JSDoc updated to document the new filter; component renders injected JSX via wp.hooks.applyFilters('wedocs_ai_settings_fields', null, settingsData, aiSettingsData, setSettings).
wedocs_general_settings_fields filter hook
src/components/Settings/GeneralSettings.js
New file-level JSDoc added documenting the filter contract; component renders injected JSX via wp.hooks.applyFilters('wedocs_general_settings_fields', null, settingsData, generalSettingsData, setSettings).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • iftakharul-islam

Poem

🐇 Hop hop, a filter is born today,
Two settings panels open wide their doors,
External fields may come and freely play,
Injected JSX dancing on the floors.
The rabbit cheers for hooks that pave the way! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title refers to turnstile settings, but the changes add hook-injected fields to AI and General Settings panels. Rename it to reflect the actual change, such as adding hook-based extra fields to the settings panels.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with 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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (1)
src/components/Settings/GeneralSettings.js (1)

430-436: ⚡ Quick win

Inconsistent null-safety checks on wp.hooks across the codebase — standardize the approach.

The code at lines 430-436 invokes wp.hooks.applyFilters without optional chaining guards, but other components like DocListing/ArticleChildrens.js and DocListing/SectionArticles.js already use wp?.hooks?.applyFilters(). Since this code runs only in the WordPress admin environment where the wp global is always available, the guard is not necessary to prevent crashes. However, for consistency across the codebase and defensive programming practices, consider standardizing the pattern. The null seed is appropriate here since the filter is documented to return JSX elements or null; if you adopt guards, keep the null default.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/Settings/GeneralSettings.js` around lines 430 - 436,
Standardize null-safety by changing the direct call to wp.hooks.applyFilters to
use optional chaining: call
wp?.hooks?.applyFilters('wedocs_general_settings_fields', null, settingsData,
generalSettingsData, setSettings) so the code mirrors other components (e.g.,
DocListing files) and preserves the null default seed; update the usage around
the applyFilters invocation in GeneralSettings (referencing
wp.hooks.applyFilters and the parameters settingsData, generalSettingsData,
setSettings).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/components/Settings/GeneralSettings.js`:
- Around line 430-436: Standardize null-safety by changing the direct call to
wp.hooks.applyFilters to use optional chaining: call
wp?.hooks?.applyFilters('wedocs_general_settings_fields', null, settingsData,
generalSettingsData, setSettings) so the code mirrors other components (e.g.,
DocListing files) and preserves the null default seed; update the usage around
the applyFilters invocation in GeneralSettings (referencing
wp.hooks.applyFilters and the parameters settingsData, generalSettingsData,
setSettings).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ed79c507-aa5a-4ff1-9b9e-de051c721864

📥 Commits

Reviewing files that changed from the base of the PR and between 9110f3d and cf31b81.

📒 Files selected for processing (1)
  • src/components/Settings/GeneralSettings.js

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/Settings/AiSettings.js`:
- Around line 17-20: The wedocs_ai_settings_fields hook is still receiving
aiSettingsData instead of the live aiSettings state, so injected fields can
render one step behind and overwrite recent provider/model changes. Update the
hook invocation inside AiSettings to pass aiSettings through this extension
point, and align the hook contract/docs with wedocs_ai_settings_after_model so
consumers know they receive the current local state.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6a78fa51-1283-4475-8d98-1599b6611e90

📥 Commits

Reviewing files that changed from the base of the PR and between 89036f6 and 7d6b806.

📒 Files selected for processing (2)
  • src/components/Settings/AiSettings.js
  • src/components/Settings/GeneralSettings.js

Comment on lines +17 to +20
* @filter wedocs_ai_settings_fields
* Allows injection of additional settings fields into the AI Settings panel.
* Receives: (fields, settingsData, aiSettingsData, setSettings)
* Return: JSX elements to render additional fields.

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Pass the live aiSettings state through this hook.

Line 767 currently exposes aiSettingsData, but this panel edits and renders from local aiSettings. That makes injected fields one render behind after handleProviderChange / handleDefaultProviderChange, and a callback that writes back through setSettings can clobber a just-made provider/model change with the stale snapshot. Keep this extension point aligned with wedocs_ai_settings_after_model by passing aiSettings here and documenting that contract.

Suggested fix
- * Receives: (fields, settingsData, aiSettingsData, setSettings)
+ * Receives: (fields, settingsData, aiSettings, setSettings)
...
                         {wp.hooks.applyFilters(
                           'wedocs_ai_settings_fields',
                           null,
                           settingsData,
-                          aiSettingsData,
+                          aiSettings,
                           setSettings
                         )}

Also applies to: 767-773

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/Settings/AiSettings.js` around lines 17 - 20, The
wedocs_ai_settings_fields hook is still receiving aiSettingsData instead of the
live aiSettings state, so injected fields can render one step behind and
overwrite recent provider/model changes. Update the hook invocation inside
AiSettings to pass aiSettings through this extension point, and align the hook
contract/docs with wedocs_ai_settings_after_model so consumers know they receive
the current local state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant