PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 4.7.1
GiveWP – Donation Plugin and Fundraising Platform v4.7.1
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 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / src / Onboarding / DefaultFormFactory.php
give / src / Onboarding Last commit date
Config 4 years ago Helpers 4 years ago Migrations 4 years ago Routes 1 year ago Setup 11 months ago Wizard 1 year ago BlockFactory.php 1 year ago DefaultFormFactory.php 1 year ago FormRepository.php 1 year ago LocaleCollection.php 4 years ago SettingsRepository.php 4 years ago SettingsRepositoryFactory.php 4 years ago
DefaultFormFactory.php
223 lines
1 <?php
2
3 namespace Give\Onboarding;
4
5 use Give\Form\Template\Options as TemplateOptions;
6
7 /**
8 * @since 2.8.0
9 */
10 class DefaultFormFactory
11 {
12
13 /**
14 * Green to match the Onboarding Wizard.
15 *
16 * @since 2.8.0
17 * @var string;
18 *
19 */
20 protected $primaryColor = '#4fa651';
21
22 /**
23 * @since 2.8.0
24 * @return int $formID
25 *
26 */
27 public function make()
28 {
29 $formID = wp_insert_post(
30 [
31 'post_title' => 'Donation Form',
32 'post_type' => 'give_forms',
33 'post_status' => 'publish', // @TODO: Preview needs to work with Draft status.
34 'meta_input' => [
35 '_give_onboarding_default_form' => 1,
36 '_give_levels_minimum_amount' => 10,
37 '_give_levels_maximim_amount' => 250,
38 '_give_form_template' => 'sequoia',
39 '_give_form_status' => 'open',
40 '_give_sequoia_form_template_settings' => $this->getTemplateConfig(),
41 '_give_checkout_label' => __('Donate Now', 'give'),
42 '_give_display_style' => 'buttons',
43 '_give_payment_display' => 'button',
44 '_give_form_floating_labels' => 'disabled',
45 '_give_reveal_label' => __('Donate Now', 'give'),
46 '_give_display_content' => 'disabled',
47 '_give_content_placement' => '',
48 '_give_form_content' => '',
49 '_give_price_option' => 'multi',
50 '_give_set_price' => 1,
51 '_give_custom_amount' => 'enabled',
52 '_give_donation_levels' => $this->getDonationLevels(),
53 '_give_default_gateway' => 'global',
54 '_give_name_title_prefix' => 'global',
55 '_give_title_prefixes' => '',
56 '_give_company_field' => 'global',
57 '_give_anonymous_donation' => 'global',
58 '_give_donor_comment' => 'global',
59 '_give_logged_in_only' => 'enabled',
60 '_give_show_register_form' => 'none',
61 '_give_goal_option' => 'disabled',
62 '_give_goal_format' => 'amount',
63 '_give_set_goal' => 10000,
64 '_give_number_of_donor_goal' => 100,
65 '_give_goal_color' => $this->primaryColor,
66 '_give_close_form_when_goal_achieved' => 'disabled',
67 '_give_form_goal_achieved_message' => __(
68 'Thank you to all our donors, we have met our fundraising goal.',
69 'give'
70 ),
71 '_give_terms_option' => 'global',
72 '_give_agree_label' => __('Agree to terms?', 'give'),
73 '_give_agree_text' => __('The terms can be customized in the donation form settings.', 'give'),
74 'give_stripe_per_form_accounts' => 'disabled', // Note: Doesn't use underscore prefix.
75 '_give_default_stripe_account' => '',
76 '_give_email_options' => 'global',
77 '_give_email_template' => 'default',
78 '_give_email_logo' => '',
79 '_give_from_name' => get_bloginfo('name'),
80 '_give_from_email' => get_bloginfo('admin_email'),
81 '_give_new-donation_notification' => 'global',
82 '_give_new-donation_email_subject' => sprintf('%s - #{payment_id}', __('New Donation', 'give')),
83 '_give_new-donation_email_header' => __('New Donation!', 'give'),
84 '_give_new-donation_email_message' => give_get_default_donation_notification_email(),
85 '_give_new-donation_email_content_type' => 'text/html',
86 '_give_new-donation_recipient' => [
87 'email' => get_bloginfo('admin_email'),
88 ],
89 '_give_donation-receipt_notification' => 'global',
90 '_give_donation-receipt_email_subject' => __('Donation Receipt', 'give'),
91 '_give_donation-receipt_email_header' => __('Donation Receipt', 'give'),
92 '_give_donation-receipt_email_mesage' => give_get_default_donation_receipt_email(),
93 '_give_donation-receipt_email_content_type' => 'text/html',
94 '_give_form_goal_progress' => -1,
95 '_give_offline_checkout_notes' => '<em>You can customize instructions in the forms settings.</em>'
96 . '<br /><br />'
97 . '<strong>Please make checks payable to "{sitename}".</strong>'
98 . '<br /><br />'
99 . 'Your donation is greatly appreciated!',
100 ],
101 ]
102 );
103
104 return $formID;
105 }
106
107 /**
108 * Default values extracted from src/Views/Form/Templates/Sequoia/optionConfig.php
109 *
110 * Updates the default primary_color to match the Onboarding Wizard.
111 *
112 * @since 2.16.2 add new visual appearance settings
113 * @since 2.8.0
114 * @return array
115 *
116 */
117 public function getTemplateConfig()
118 {
119 return [
120 'introduction' => [
121 'enabled' => 'enabled',
122 'headline' => __('Support Our Cause', 'give'),
123 'description' => __(
124 'Help our organization by donating today! All donations go directly to making a difference for our cause.',
125 'give'
126 ),
127 'image' => GIVE_PLUGIN_URL . 'build/assets/dist/images/onboarding-preview-form-image.min.jpg',
128 'primary_color' => $this->primaryColor,
129 'donate_label' => __('Donate Now', 'give'),
130 ],
131 'payment_amount' => [
132 'header_label' => __('Choose Amount', 'give'),
133 'content' => sprintf(
134 __(
135 'How much would you like to donate? As a contributor to %s we make sure your donation goes directly to supporting our cause.',
136 'give'
137 ),
138 get_bloginfo('sitename')
139 ),
140 'next_label' => __('Continue', 'give'),
141 ],
142 'visual_appearance' => [
143 'decimals_enabled' => 'disabled',
144 'primary_color' => '#28C77B',
145 'google-fonts' => 'enabled',
146 ],
147 'payment_information' => [
148 'header_label' => __('Add Your Information', 'give'),
149 'headline' => __("Who's giving today?", 'give'),
150 'description' => __('We’ll never share this information with anyone.', 'give'),
151 'donation_summary_enabled' => 'enabled',
152 'donation_summary_heading' => __('Here\'s what you\'re about to donate:', 'give'),
153 'donation_summary_location' => 'give_donation_form_before_submit',
154 TemplateOptions::getCheckoutLabelField(),
155 ],
156 'thank-you' => [
157 'image' => '',
158 'headline' => __('A great big thank you!', 'give'),
159 'description' => __(
160 '{name}, your contribution means a lot and will be put to good use in making a difference. We’ve sent your donation receipt to {donor_email}. ',
161 'give'
162 ),
163 'sharing' => 'enabled',
164 'sharing_instruction' => __(
165 'Help spread the word by sharing your support with your friends and followers!',
166 'give'
167 ),
168 'twitter_message' => __("I just gave to this cause. Who's next?", 'give'),
169 ],
170 ];
171 }
172
173 /**
174 * Default values forked from includes/admin/forms/class-metabox-form-data.php
175 *
176 * @since 2.8.0
177 * @since 2.13.3 Donation level id and amount value changed to string
178 * @return array
179 *
180 */
181 public function getDonationLevels()
182 {
183 return [
184 [
185 '_give_id' =>
186 [
187 'level_id' => '0',
188 ],
189 '_give_amount' => give_sanitize_amount_for_db(10),
190 ],
191 [
192 '_give_id' =>
193 [
194 'level_id' => '1',
195 ],
196 '_give_amount' => give_sanitize_amount_for_db(25),
197 ],
198 [
199 '_give_id' =>
200 [
201 'level_id' => '2',
202 ],
203 '_give_amount' => give_sanitize_amount_for_db(50),
204 ],
205 [
206 '_give_id' =>
207 [
208 'level_id' => '3',
209 ],
210 '_give_amount' => give_sanitize_amount_for_db(100),
211 '_give_default' => 'default',
212 ],
213 [
214 '_give_id' =>
215 [
216 'level_id' => '5',
217 ],
218 '_give_amount' => give_sanitize_amount_for_db(250),
219 ],
220 ];
221 }
222 }
223