PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
← All changes | src/BetaFeatures/Repositories/FeatureFlagRepository.php +14 -1 4.16.34.16.9 View file →
@@ -1,8 +1,10 @@
1 1 <?php
2 2
3 3 namespace Give\BetaFeatures\Repositories;
4 4
5 +use Give\Framework\Permissions\Facades\UserPermissions;
6 +
5 7 class FeatureFlagRepository
6 8 {
7 9 /**
8 10 * @since 3.6.0
@@ -37,17 +39,28 @@
37 39 update_option('givewp_feature_flag_notifications_count', 0);
38 40 }
39 41
40 42 /**
43 + * @since 4.16.8.1 Only trust $_POST during a verified settings-save request, not any request.
41 44 * @since 3.6.0
42 45 */
43 46 public function enabled($feature, $default = false): bool
44 47 {
45 48 // Workaround so that the updated option is available at the start of the request.
46 - $option = isset($_POST["enable_$feature"])
49 + $option = ($this->isVerifiedSettingsSaveRequest() && isset($_POST["enable_$feature"]))
47 50 ? give_clean($_POST["enable_$feature"])
48 51 : give_get_option("enable_$feature", $default);
49 52
50 53 return give_is_setting_enabled($option);
51 54
55 + }
56 +
57 + /**
58 + * @since 4.16.8.1
59 + */
60 + private function isVerifiedSettingsSaveRequest(): bool
61 + {
62 + return UserPermissions::settings()->canManage()
63 + && class_exists('Give_Admin_Settings')
64 + && \Give_Admin_Settings::verify_nonce();
52 65 }
53 66 }