PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.12.2
GiveWP – Donation Plugin and Fundraising Platform v2.12.2
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 5 years ago Helpers 5 years ago Routes 4 years ago Setup 5 years ago Wizard 4 years ago DefaultFormFactory.php 5 years ago FormRepository.php 5 years ago LocaleCollection.php 5 years ago SettingsRepository.php 5 years ago SettingsRepositoryFactory.php 5 years ago
DefaultFormFactory.php
191 lines
1 <?php
2
3 namespace Give\Onboarding;
4
5 use Give\Form\Template\Options as TempalteOptions;
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.8.0
110 */
111 public function getTemplateConfig() {
112 return [
113 'introduction' => [
114 'enabled' => 'enabled',
115 'headline' => __( 'Support Our Cause', 'give' ),
116 'description' => __( 'Help our organization by donating today! All donations go directly to making a difference for our cause.', 'give' ),
117 'image' => GIVE_PLUGIN_URL . 'assets/dist/images/onboarding-preview-form-image.min.jpg',
118 'primary_color' => $this->primaryColor,
119 'donate_label' => __( 'Donate Now', 'give' ),
120 ],
121 'payment_amount' => [
122 'header_label' => __( 'Choose Amount', 'give' ),
123 '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' ) ),
124 'next_label' => __( 'Continue', 'give' ),
125 ],
126 'payment_information' => [
127 'header_label' => __( 'Add Your Information', 'give' ),
128 'headline' => __( "Who's giving today?", 'give' ),
129 'description' => __( 'We’ll never share this information with anyone.', 'give' ),
130 TempalteOptions::getCheckoutLabelField(),
131 ],
132 'thank-you' => [
133 'image' => '',
134 'headline' => __( 'A great big thank you!', 'give' ),
135 'description' => __( '{name}, your contribution means a lot and will be put to good use making a difference. We’ve sent your donation receipt to {donor_email}. ', 'give' ),
136 'sharing' => 'enabled',
137 'sharing_instruction' => __( 'Help us out by sharing with friends and followers that you supported the cause!', 'give' ),
138 'twitter_message' => __( "I just gave to this cause. Who's next?", 'give' ),
139 ],
140 ];
141 }
142
143 /**
144 * Default values forked from includes/admin/forms/class-metabox-form-data.php
145 *
146 * @return array
147 *
148 * @since 2.8.0
149 */
150 public function getDonationLevels() {
151 return [
152 [
153 '_give_id' =>
154 [
155 'level_id' => 0,
156 ],
157 '_give_amount' => 10,
158 ],
159 [
160 '_give_id' =>
161 [
162 'level_id' => 1,
163 ],
164 '_give_amount' => 25,
165 ],
166 [
167 '_give_id' =>
168 [
169 'level_id' => 2,
170 ],
171 '_give_amount' => 50,
172 ],
173 [
174 '_give_id' =>
175 [
176 'level_id' => 3,
177 ],
178 '_give_amount' => 100,
179 '_give_default' => 'default',
180 ],
181 [
182 '_give_id' =>
183 [
184 'level_id' => 5,
185 ],
186 '_give_amount' => 250,
187 ],
188 ];
189 }
190 }
191