PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.13.1
GiveWP – Donation Plugin and Fundraising Platform v2.13.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 2.31.0 2.31.1 All 253 releases
give / src / Tracking / TrackingData / GivePluginSettingsData.php
GivePluginSettingsData.php
85 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Give\Tracking\TrackingData;
3
4 use Give\Tracking\Contracts\TrackData;
5 use Give\Tracking\AdminSettings;
6 use Give\Tracking\Repositories\Settings;
7
8 /**
9 * Class GivePluginSettingsData
10 *
11 * This class represents Give plugin data.
12 *
13 * @since 2.10.0
14 * @package Give\Tracking\TrackingData
15 */
16 class GivePluginSettingsData implements TrackData {
17 /**
18 * Return Give plugin settings data.
19 *
20 * @since 2.10.0
21 * @return array
22 */
23 public function get() {
24 return $this->getGlobalSettings();
25 }
26
27 /**
28 * Returns plugin global settings.
29 *
30 * @since 2.10.0
31 * @return array
32 */
33 private function getGlobalSettings() {
34 $generalSettings = [
35 'currency',
36 'base_country',
37 'base_state',
38 'currency',
39 'user_type',
40 'cause_type',
41 ];
42
43 $trueFalseSettings = [
44 'is_name_title' => 'name_title_prefix',
45 'is_company' => 'company_field',
46 'is_anonymous_donation' => 'anonymous_donation',
47 'is_donor_comment' => 'donor_comment',
48 'is_anonymous_tracking' => Settings::USAGE_TRACKING_OPTION_KEY,
49 ];
50
51 $data = [];
52 $settings = get_option( 'give_settings', give_get_default_settings() );
53 foreach ( $generalSettings as $setting ) {
54 $data[ $setting ] = isset( $settings[ $setting ] ) ? $settings[ $setting ] : '';
55 }
56
57 foreach ( $trueFalseSettings as $key => $setting ) {
58 $value = isset( $settings[ $setting ] ) ? $settings[ $setting ] : 'disabled';
59 $data[ $key ] = absint( give_is_setting_enabled( $value ) );
60 }
61
62 $data['active_payment_gateways'] = $this->getGatewaysLabels();
63
64 return $data;
65 }
66
67 /**
68 * Return active gateways labels.
69 *
70 * @since 2.10.2
71 * @return array
72 */
73 private function getGatewaysLabels() {
74 $gateways = give_get_enabled_payment_gateways();
75 $labels = [];
76
77 foreach ( $gateways as $id => $data ) {
78 $labels[ $id ]['admin_label'] = $data['admin_label'];
79 $labels[ $id ]['checkout_label'] = $data['checkout_label'];
80 }
81
82 return $labels;
83 }
84 }
85