Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(settings): get_setting method #1242

Merged
merged 2 commits into from
Nov 17, 2023
Merged

fix(settings): get_setting method #1242

merged 2 commits into from
Nov 17, 2023

Conversation

dkoo
Copy link
Contributor

@dkoo dkoo commented Nov 16, 2023

All Submissions:

Changes proposed in this Pull Request:

Fixes a logical error in the Newspack_Popups_Settings::get_setting method. If getting an invalid setting key or a setting key that doesn't have a saved option, it would always return true instead of the setting's default value. This PR validates the key and also returns the default value if a value hasn't been saved before.

How to test the changes in this Pull Request:

  1. On a fresh site, install Campaigns from master.
  2. Run wp shell, then Newspack_Popups_Settings::get_setting( 'newspack_popups_mc_donor_merge_field' ). Observe that it returns true.
  3. Check out this branch and repeat step 2 in a new wp shell session. Confirm it now returns DONAT.
  4. Update the settings in Newspack > Campaigns > Settings and repeat with various keys (see here for keys to check).

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@dkoo dkoo added bug Something isn't working [Status] Needs Review labels Nov 16, 2023
@dkoo dkoo self-assigned this Nov 16, 2023
@dkoo dkoo requested a review from a team as a code owner November 16, 2023 01:36
@dkoo dkoo changed the title Hotfix/settings @dkoo fix(settings): get_setting method Nov 16, 2023
@dkoo dkoo changed the title @dkoo fix(settings): get_setting method fix(settings): get_setting method Nov 16, 2023
@dkoo dkoo merged commit e058644 into release Nov 17, 2023
9 checks passed
@dkoo dkoo deleted the hotfix/settings branch November 17, 2023 18:05
matticbot pushed a commit that referenced this pull request Nov 17, 2023
## [2.26.1](v2.26.0...v2.26.1) (2023-11-17)

### Bug Fixes

* **settings:** get_setting method ([#1242](#1242)) ([e058644](e058644))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 2.26.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants