Skip to content

Conversation

matty0501
Copy link
Contributor

Context

⛑️ Ticket(s): https://secure.helpscout.net/conversation/3078299767/89409?viewId=7627047

Summary

This snippet will set the allowed countries in GPAPF to All for a specific form/field. Useful for if a user has locked down the countries in the plugin settings, but wants to allow all countries for a specific form.

Copy link

coderabbitai bot commented Sep 17, 2025

Walkthrough

Adds a new PHP snippet that registers a form/field-specific gpapf_init_args_<form>_<field> filter which sets countriesAction to "all" so the Advanced Phone Field flag picker shows all countries.

Changes

Cohort / File(s) Summary
Gravity Perks APF snippet
gp-advanced-phone-field/gpapf-show-all-countries.php
Adds a snippet registering the gpapf_init_args_123_4 filter (closure) that sets $args['countriesAction'] = 'all' and returns $args. Includes header comment and usage note to replace form/field IDs.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User
    participant WP as WordPress
    participant GP as Gravity Perks APF
    participant Snippet as gpapf-show-all-countries.php

    User->>WP: Load page with form
    WP->>GP: Initialize APF for form/field (IDs 123/4)
    GP->>Snippet: apply filter gpapf_init_args_123_4($args)
    Note right of Snippet: set args.countriesAction = "all"
    Snippet-->>GP: return modified $args
    GP-->>WP: initialize phone field with updated args
    WP-->>User: render phone field with all countries in picker
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • claygriffiths

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly identifies the primary change—adding the new snippet file gpapf-show-all-countries.php—and directly reflects the changeset, so it is concise and relevant. It could be slightly improved by removing the backticks and using an active phrasing like "Add GPAPF snippet to show all countries" for clearer repository history.
Description Check ✅ Passed The PR description follows the provided template by including a Context section with the ticket link and a clear Summary that explains the snippet's purpose and rationale, so it contains the essential information reviewers need. Non-critical template fields (Notion/Slack) were omitted, which is acceptable, though adding a brief usage example or explicit form/field IDs in the description would improve clarity for reviewers and users.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch matty0501-patch-2

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1205895 and 491d477.

📒 Files selected for processing (1)
  • gp-advanced-phone-field/gpapf-show-all-countries.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • gp-advanced-phone-field/gpapf-show-all-countries.php

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 (2)
gp-advanced-phone-field/gpapf-show-all-countries.php (2)

6-7: Tighten docblock phrasing

Minor grammar/clarity improvement.

- * This snippet will show all countries in the flag picker for a specific form/field. It is useful if you have limited to specific countries
- * on the plugin settings, but want to allow all countries on a specific form/field.
+ * This snippet shows all countries in the flag picker for a specific form/field. Useful when the plugin settings restrict countries globally,
+ * but a specific form/field should allow all countries.

13-13: Optionally declare accepted args for self‑documentation

Not required (defaults are fine), but explicit args can improve readability.

-} );
+}, 10, 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 c75fe1d and 1205895.

📒 Files selected for processing (1)
  • gp-advanced-phone-field/gpapf-show-all-countries.php (1 hunks)
🧰 Additional context used
🪛 GitHub Check: PHPCS (Files Changed)
gp-advanced-phone-field/gpapf-show-all-countries.php

[failure] 12-12:
Line indented incorrectly; expected at least 1 tabs, found 2 spaces


[failure] 12-12:
Multi-line function call not indented correctly; expected 4 spaces but found 2


[warning] 12-12:
Found precision alignment of 2 spaces.


[failure] 11-11:
Line indented incorrectly; expected at least 1 tabs, found 2 spaces


[failure] 11-11:
Multi-line function call not indented correctly; expected 4 spaces but found 2


[warning] 11-11:
Found precision alignment of 2 spaces.

🪛 GitHub Actions: PHP Lint (PR)
gp-advanced-phone-field/gpapf-show-all-countries.php

[warning] 11-11: PHPCS (thenabeel/action-phpcs@v8): WordPress.WhiteSpace.PrecisionAlignment.Found - Found precision alignment of 2 spaces.


[error] 11-11: PHPCS (thenabeel/action-phpcs@v8): PEAR.Functions.FunctionCallSignature.Indent - Multi-line function call not indented correctly; expected 4 spaces but found 2.

🔇 Additional comments (1)
gp-advanced-phone-field/gpapf-show-all-countries.php (1)

1-5: LGTM — filter signature verified.
Use gpapf_init_args_{FORMID}_{FIELDID} (e.g., gpapf_init_args_123_4).

Copy link
Contributor

@saifsultanc saifsultanc left a comment

Choose a reason for hiding this comment

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

Nice!

@saifsultanc saifsultanc merged commit b1c4d9f into master Sep 20, 2025
3 of 4 checks passed
@saifsultanc saifsultanc deleted the matty0501-patch-2 branch September 20, 2025 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants