PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 2.17.0
GiveWP – Donation Plugin and Fundraising Platform v2.17.0
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 / Onboarding / DefaultFormFactory.php
DefaultFormFactory.php
201 lines 7.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 * Green to match the Onboarding Wizard.
14 *
15 * @var string;
16 *
17 * @since 2.8.0
18 */
19 protected $primaryColor = '#4fa651';
20
21 /**
22 * @return int $formID
23 *
24 * @since 2.8.0
25 */
26 public function make() {
27 $formID = wp_insert_post(
28 [
29 'post_title' => 'Donation Form',
30 'post_type' => 'give_forms',
31 'post_status' => 'publish', // @TODO: Preview needs to work with Draft status.
32 'meta_input' => [
33 '_give_onboarding_default_form' => 1,
34 '_give_levels_minimum_amount' => 10,
35 '_give_levels_maximim_amount' => 250,
36 '_give_form_template' => 'sequoia',
37 '_give_form_status' => 'open',
38 '_give_sequoia_form_template_settings' => $this->getTemplateConfig(),
39 '_give_checkout_label' => __( 'Donate Now', 'give' ),
40 '_give_display_style' => 'buttons',
41 '_give_payment_display' => 'button',
42 '_give_form_floating_labels' => 'disabled',
43 '_give_reveal_label' => __( 'Donate Now', 'give' ),
44 '_give_display_content' => 'disabled',
45 '_give_content_placement' => '',
46 '_give_form_content' => '',
47 '_give_price_option' => 'multi',
48 '_give_set_price' => 1,
49 '_give_custom_amount' => 'enabled',
50 '_give_donation_levels' => $this->getDonationLevels(),
51 '_give_default_gateway' => 'global',
52 '_give_name_title_prefix' => 'global',
53 '_give_title_prefixes' => '',
54 '_give_company_field' => 'global',
55 '_give_anonymous_donation' => 'global',
56 '_give_donor_comment' => 'global',
57 '_give_logged_in_only' => 'enabled',
58 '_give_show_register_form' => 'none',
59 '_give_goal_option' => 'disabled',
60 '_give_goal_format' => 'amount',
61 '_give_set_goal' => 10000,
62 '_give_number_of_donor_goal' => 100,
63 '_give_goal_color' => $this->primaryColor,
64 '_give_close_form_when_goal_achieved' => 'disabled',
65 '_give_form_goal_achieved_message' => __( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ),
66 '_give_terms_option' => 'global',
67 '_give_agree_label' => __( 'Agree to terms?', 'give' ),
68 '_give_agree_text' => __( 'The terms can be customized in the donation form settings.', 'give' ),
69 'give_stripe_per_form_accounts' => 'disabled', // Note: Doesn't use underscore prefix.
70 '_give_default_stripe_account' => '',
71 '_give_email_options' => 'global',
72 '_give_email_template' => 'default',
73 '_give_email_logo' => '',
74 '_give_from_name' => get_bloginfo( 'name' ),
75 '_give_from_email' => get_bloginfo( 'admin_email' ),
76 '_give_new-donation_notification' => 'global',
77 '_give_new-donation_email_subject' => sprintf( '%s - #{payment_id}', __( 'New Donation', 'give' ) ),
78 '_give_new-donation_email_header' => __( 'New Donation!', 'give' ),
79 '_give_new-donation_email_message' => give_get_default_donation_notification_email(),
80 '_give_new-donation_email_content_type' => 'text/html',
81 '_give_new-donation_recipient' => [
82 'email' => get_bloginfo( 'admin_email' ),
83 ],
84 '_give_donation-receipt_notification' => 'global',
85 '_give_donation-receipt_email_subject' => __( 'Donation Receipt', 'give' ),
86 '_give_donation-receipt_email_header' => __( 'Donation Receipt', 'give' ),
87 '_give_donation-receipt_email_mesage' => give_get_default_donation_receipt_email(),
88 '_give_donation-receipt_email_content_type' => 'text/html',
89 '_give_form_goal_progress' => -1,
90 '_give_offline_checkout_notes' => '<em>You can customize instructions in the forms settings.</em>'
91 . '<br /><br />'
92 . '<strong>Please make checks payable to "{sitename}".</strong>'
93 . '<br /><br />'
94 . 'Your donation is greatly appreciated!',
95 ],
96 ]
97 );
98
99 return $formID;
100 }
101
102 /**
103 * Default values extracted from src/Views/Form/Templates/Sequoia/optionConfig.php
104 *
105 * Updates the default primary_color to match the Onboarding Wizard.
106 *
107 * @return array
108 *
109 * @since 2.16.2 add new visual appearance settings
110 * @since 2.8.0
111 */
112 public function getTemplateConfig() {
113 return [
114 'introduction' => [
115 'enabled' => 'enabled',
116 'headline' => __( 'Support Our Cause', 'give' ),
117 'description' => __( 'Help our organization by donating today! All donations go directly to making a difference for our cause.', 'give' ),
118 'image' => GIVE_PLUGIN_URL . 'assets/dist/images/onboarding-preview-form-image.min.jpg',
119 'primary_color' => $this->primaryColor,
120 'donate_label' => __( 'Donate Now', 'give' ),
121 ],
122 'payment_amount' => [
123 'header_label' => __( 'Choose Amount', 'give' ),
124 'content' => sprintf( __( 'How much would you like to donate? As a contributor to %s we make sure your donation goes directly to supporting our cause.', 'give' ), get_bloginfo( 'sitename' ) ),
125 'next_label' => __( 'Continue', 'give' ),
126 ],
127 'visual_appearance' => [
128 'decimals_enabled' => 'disabled',
129 'primary_color' => '#28C77B',
130 'google-fonts' => 'enabled'
131 ],
132 'payment_information' => [
133 'header_label' => __( 'Add Your Information', 'give' ),
134 'headline' => __( "Who's giving today?", 'give' ),
135 'description' => __( 'We’ll never share this information with anyone.', 'give' ),
136 'donation_summary_enabled' => 'enabled',
137 'donation_summary_heading' => __( 'Here\'s what you\'re about to donate:', 'give' ),
138 'donation_summary_location' => 'give_donation_form_before_submit',
139 TemplateOptions::getCheckoutLabelField(),
140 ],
141 'thank-you' => [
142 'image' => '',
143 'headline' => __( 'A great big thank you!', 'give' ),
144 'description' => __( '{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}. ', 'give' ),
145 'sharing' => 'enabled',
146 'sharing_instruction' => __( 'Help spread the word by sharing your support with your friends and followers!', 'give' ),
147 'twitter_message' => __( "I just gave to this cause. Who's next?", 'give' ),
148 ],
149 ];
150 }
151
152 /**
153 * Default values forked from includes/admin/forms/class-metabox-form-data.php
154 *
155 * @return array
156 *
157 * @since 2.8.0
158 * @since 2.13.3 Donation level id and amount value changed to string
159 */
160 public function getDonationLevels() {
161 return [
162 [
163 '_give_id' =>
164 [
165 'level_id' => '0',
166 ],
167 '_give_amount' => give_sanitize_amount_for_db( 10 ),
168 ],
169 [
170 '_give_id' =>
171 [
172 'level_id' => '1',
173 ],
174 '_give_amount' => give_sanitize_amount_for_db( 25 ),
175 ],
176 [
177 '_give_id' =>
178 [
179 'level_id' => '2',
180 ],
181 '_give_amount' => give_sanitize_amount_for_db( 50 ),
182 ],
183 [
184 '_give_id' =>
185 [
186 'level_id' => '3',
187 ],
188 '_give_amount' => give_sanitize_amount_for_db( 100 ),
189 '_give_default' => 'default',
190 ],
191 [
192 '_give_id' =>
193 [
194 'level_id' => '5',
195 ],
196 '_give_amount' => give_sanitize_amount_for_db( 250 ),
197 ],
198 ];
199 }
200 }
201