PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.3.0
GiveWP – Donation Plugin and Fundraising Platform v2.3.0
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 / includes / install.php
give / includes Last commit date
admin 7 years ago api 7 years ago deprecated 7 years ago donors 7 years ago emails 7 years ago forms 7 years ago gateways 7 years ago libraries 7 years ago payments 7 years ago actions.php 7 years ago ajax-functions.php 7 years ago class-give-async-process.php 8 years ago class-give-background-updater.php 7 years ago class-give-cache.php 7 years ago class-give-cli-commands.php 8 years ago class-give-comment.php 7 years ago class-give-cron.php 8 years ago class-give-db-comments-meta.php 7 years ago class-give-db-comments.php 7 years ago class-give-db-donor-meta.php 8 years ago class-give-db-donors.php 7 years ago class-give-db-form-meta.php 8 years ago class-give-db-logs-meta.php 8 years ago class-give-db-logs.php 7 years ago class-give-db-meta.php 7 years ago class-give-db-payment-meta.php 7 years ago class-give-db-sequential-ordering.php 7 years ago class-give-db-sessions.php 7 years ago class-give-db.php 7 years ago class-give-donate-form.php 8 years ago class-give-donor-wall-widget.php 7 years ago class-give-donor.php 7 years ago class-give-email-access.php 7 years ago class-give-html-elements.php 7 years ago class-give-license-handler.php 7 years ago class-give-logging.php 8 years ago class-give-readme-parser.php 8 years ago class-give-roles.php 8 years ago class-give-scripts.php 7 years ago class-give-session.php 7 years ago class-give-stats.php 8 years ago class-give-template-loader.php 8 years ago class-give-tooltips.php 8 years ago class-give-translation.php 8 years ago class-notices.php 7 years ago country-functions.php 7 years ago currency-functions.php 7 years ago error-tracking.php 8 years ago filters.php 7 years ago formatting.php 7 years ago import-functions.php 7 years ago install.php 7 years ago login-register.php 8 years ago misc-functions.php 7 years ago plugin-compatibility.php 8 years ago post-types.php 7 years ago price-functions.php 7 years ago process-donation.php 7 years ago shortcodes.php 7 years ago template-functions.php 8 years ago user-functions.php 7 years ago
install.php
514 lines
1 <?php
2 /**
3 * Install Function
4 *
5 * @package Give
6 * @subpackage Functions/Install
7 * @copyright Copyright (c) 2016, WordImpress
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 * @since 1.0
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Install
19 *
20 * Runs on plugin install by setting up the post types, custom taxonomies, flushing rewrite rules to initiate the new
21 * 'donations' slug and also creates the plugin and populates the settings fields for those plugin pages. After
22 * successful install, the user is redirected to the Give Welcome screen.
23 *
24 * @since 1.0
25 *
26 * @param bool $network_wide
27 *
28 * @global $wpdb
29 * @return void
30 */
31 function give_install( $network_wide = false ) {
32
33 global $wpdb;
34
35 if ( is_multisite() && $network_wide ) {
36
37 foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
38
39 switch_to_blog( $blog_id );
40 give_run_install();
41 restore_current_blog();
42
43 }
44
45 } else {
46
47 give_run_install();
48
49 }
50
51 }
52
53 /**
54 * Run the Give Install process.
55 *
56 * @since 1.5
57 * @return void
58 */
59 function give_run_install() {
60 $give_options = give_get_settings();
61
62 // Setup the Give Custom Post Types.
63 give_setup_post_types();
64
65 // Add Upgraded From Option.
66 $current_version = get_option( 'give_version' );
67 if ( $current_version ) {
68 update_option( 'give_version_upgraded_from', $current_version, false );
69 }
70
71 // Setup some default options.
72 $options = array();
73
74 //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency.
75 if ( empty( $current_version ) ) {
76 $options = array_merge( $options, give_get_default_settings() );
77 }
78
79 // Populate the default values.
80 update_option( 'give_settings', array_merge( $give_options, $options ), false );
81
82 /**
83 * Run plugin upgrades.
84 *
85 * @since 1.8
86 */
87 do_action( 'give_upgrades' );
88
89 if ( GIVE_VERSION !== get_option( 'give_version' ) ) {
90 update_option( 'give_version', GIVE_VERSION, false );
91 }
92
93 // Create Give roles.
94 $roles = new Give_Roles();
95 $roles->add_roles();
96 $roles->add_caps();
97
98 // Set api version, end point and refresh permalink.
99 $api = new Give_API();
100 $api->add_endpoint();
101 update_option( 'give_default_api_version', 'v' . $api->get_version(), false );
102
103 flush_rewrite_rules();
104
105 // Create the donor databases.
106 $donors_db = new Give_DB_Donors();
107 $donors_db->create_table();
108 $donor_meta = new Give_DB_Donor_Meta();
109 $donor_meta->create_table();
110
111 // Add a temporary option to note that Give pages have been created.
112 Give_Cache::set( '_give_installed', $options, 30, true );
113
114 if ( ! $current_version ) {
115
116 require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
117
118 // When new upgrade routines are added, mark them as complete on fresh install.
119 $upgrade_routines = array(
120 'upgrade_give_user_caps_cleanup',
121 'upgrade_give_payment_customer_id',
122 'upgrade_give_offline_status',
123 'v18_upgrades_core_setting',
124 'v18_upgrades_form_metadata',
125 'v189_upgrades_levels_post_meta',
126 'v1812_update_amount_values',
127 'v1812_update_donor_purchase_values',
128 'v1813_update_user_roles',
129 'v1813_update_donor_user_roles',
130 'v1817_update_donation_iranian_currency_code',
131 'v1817_cleanup_user_roles',
132 'v1818_assign_custom_amount_set_donation',
133 'v1818_give_worker_role_cleanup',
134 'v20_upgrades_form_metadata',
135 'v20_logs_upgrades',
136 'v20_move_metadata_into_new_table',
137 'v20_rename_donor_tables',
138 'v20_upgrades_donor_name',
139 'v20_upgrades_user_address',
140 'v20_upgrades_payment_metadata',
141 'v201_upgrades_payment_metadata',
142 'v201_add_missing_donors',
143 'v201_move_metadata_into_new_table',
144 'v201_logs_upgrades',
145 'v210_verify_form_status_upgrades',
146 'v213_delete_donation_meta',
147 'v215_update_donor_user_roles',
148 'v220_rename_donation_meta_type',
149 'v224_update_donor_meta',
150 'v224_update_donor_meta_forms_id',
151 'v230_move_donor_note',
152 'v230_move_donation_note',
153 'v230_delete_donor_wall_related_donor_data',
154 'v230_delete_donor_wall_related_comment_data'
155 );
156
157 foreach ( $upgrade_routines as $upgrade ) {
158 give_set_upgrade_complete( $upgrade );
159 }
160 }
161
162 // Bail if activating from network, or bulk.
163 if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
164 return;
165 }
166
167 // Add the transient to redirect.
168 Give_Cache::set( '_give_activation_redirect', true, 30, true );
169 }
170
171 /**
172 * Network Activated New Site Setup.
173 *
174 * When a new site is created when Give is network activated this function runs the appropriate install function to set
175 * up the site for Give.
176 *
177 * @since 1.3.5
178 *
179 * @param int $blog_id The Blog ID created.
180 * @param int $user_id The User ID set as the admin.
181 * @param string $domain The URL.
182 * @param string $path Site Path.
183 * @param int $site_id The Site ID.
184 * @param array $meta Blog Meta.
185 */
186 function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
187
188 if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) {
189
190 switch_to_blog( $blog_id );
191 give_install();
192 restore_current_blog();
193
194 }
195
196 }
197
198 add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 );
199
200
201 /**
202 * Drop Give's custom tables when a mu site is deleted.
203 *
204 * @since 1.4.3
205 *
206 * @param array $tables The tables to drop.
207 * @param int $blog_id The Blog ID being deleted.
208 *
209 * @return array The tables to drop.
210 */
211 function give_wpmu_drop_tables( $tables, $blog_id ) {
212
213 switch_to_blog( $blog_id );
214 $donors_db = new Give_DB_Donors();
215 $donor_meta_db = new Give_DB_Donor_Meta();
216 $comment_db = new Give_DB_Comments();
217 $comment_db_meta = new Give_DB_Comment_Meta();
218 $give_session = new Give_DB_Sessions();
219 $log_db = new Give_DB_Logs();
220 $logmeta_db = new Give_DB_Log_Meta();
221 $formmeta_db = new Give_DB_Form_Meta();
222 $sequential_db = new Give_DB_Sequential_Ordering();
223 $payment_meta = new Give_DB_Payment_Meta();
224
225 if ( $donors_db->installed() ) {
226 $tables[] = $donors_db->table_name;
227 $tables[] = $donor_meta_db->table_name;
228 }
229 if ( $comment_db->installed() ) {
230 $tables[] = $comment_db->table_name;
231 $tables[] = $comment_db_meta->table_name;
232 }
233 if ( $give_session->installed() ) {
234 $tables[] = $give_session->table_name;
235 }
236 if ( $log_db->installed() ) {
237 $tables[] = $log_db->table_name;
238 $tables[] = $logmeta_db->table_name;
239 }
240 if ( $formmeta_db->installed() ) {
241 $tables[] = $formmeta_db->table_name;
242 }
243 if ( $sequential_db->installed() ) {
244 $tables[] = $sequential_db->table_name;
245 }
246 if ( $payment_meta->installed() ) {
247 $tables[] = $payment_meta->table_name;
248 }
249 restore_current_blog();
250
251 return $tables;
252
253 }
254
255 add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 );
256
257 /**
258 * Post-installation
259 *
260 * Runs just after plugin installation and exposes the give_after_install hook.
261 *
262 * @since 1.0
263 * @return void
264 */
265 function give_after_install() {
266
267 if ( ! is_admin() ) {
268 return;
269 }
270
271 $give_options = Give_Cache::get( '_give_installed', true );
272 $give_table_check = get_option( '_give_table_check', false );
273
274 if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) {
275
276 if ( ! @Give()->donor_meta->installed() ) {
277
278 // Create the donor meta database.
279 // (this ensures it creates it on multisite instances where it is network activated).
280 @Give()->donor_meta->create_table();
281
282 }
283
284 if ( ! @Give()->donors->installed() ) {
285 // Create the donor database.
286 // (this ensures it creates it on multisite instances where it is network activated).
287 @Give()->donors->create_table();
288
289 /**
290 * Fires after plugin installation.
291 *
292 * @since 1.0
293 *
294 * @param array $give_options Give plugin options.
295 */
296 do_action( 'give_after_install', $give_options );
297 }
298
299 update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ), false );
300
301 }
302
303 // Delete the transient
304 if ( false !== $give_options ) {
305 Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) );
306 }
307
308
309 }
310
311 add_action( 'admin_init', 'give_after_install' );
312
313
314 /**
315 * Install user roles on sub-sites of a network
316 *
317 * Roles do not get created when Give is network activation so we need to create them during admin_init
318 *
319 * @since 1.0
320 * @return void
321 */
322 function give_install_roles_on_network() {
323
324 global $wp_roles;
325
326 if ( ! is_object( $wp_roles ) ) {
327 return;
328 }
329
330 if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) {
331
332 // Create Give plugin roles
333 $roles = new Give_Roles();
334 $roles->add_roles();
335 $roles->add_caps();
336
337 }
338
339 }
340
341 add_action( 'admin_init', 'give_install_roles_on_network' );
342
343 /**
344 * Default core setting values.
345 *
346 * @since 1.8
347 * @return array
348 */
349 function give_get_default_settings() {
350
351 $options = array(
352 // General.
353 'base_country' => 'US',
354 'test_mode' => 'enabled',
355 'currency' => 'USD',
356 'currency_position' => 'before',
357 'session_lifetime' => '604800',
358 'email_access' => 'enabled',
359 'thousands_separator' => ',',
360 'decimal_separator' => '.',
361 'number_decimals' => 2,
362 'sequential-ordering_status' => 'enabled',
363
364 // Display options.
365 'css' => 'enabled',
366 'floatlabels' => 'disabled',
367 'welcome' => 'enabled',
368 'company_field' => 'disabled',
369 'name_title_prefix' => 'disabled',
370 'forms_singular' => 'enabled',
371 'forms_archives' => 'enabled',
372 'forms_excerpt' => 'enabled',
373 'form_featured_img' => 'enabled',
374 'form_sidebar' => 'enabled',
375 'categories' => 'disabled',
376 'tags' => 'disabled',
377 'terms' => 'disabled',
378 'admin_notices' => 'enabled',
379 'cache' => 'enabled',
380 'uninstall_on_delete' => 'disabled',
381 'the_content_filter' => 'enabled',
382 'scripts_footer' => 'disabled',
383 'agree_to_terms_label' => __( 'Agree to Terms?', 'give' ),
384 'agreement_text' => give_get_default_agreement_text(),
385
386 // Paypal IPN verification.
387 'paypal_verification' => 'enabled',
388
389 // Default is manual gateway.
390 'gateways' => array( 'manual' => 1, 'offline' => 1 ),
391 'default_gateway' => 'manual',
392
393 // Offline gateway setup.
394 'global_offline_donation_content' => give_get_default_offline_donation_content(),
395 'global_offline_donation_email' => give_get_default_offline_donation_content(),
396
397 // Billing address.
398 'give_offline_donation_enable_billing_fields' => 'disabled',
399
400 // Default donation notification email.
401 'donation_notification' => give_get_default_donation_notification_email(),
402
403 // Default email receipt message.
404 'donation_receipt' => give_get_default_donation_receipt_email(),
405
406 'donor_default_user_role' => 'give_donor',
407
408 );
409
410 return $options;
411 }
412
413 /**
414 * Default terms and conditions.
415 */
416 function give_get_default_agreement_text() {
417
418 $org_name = get_bloginfo( 'name' );
419
420 $agreement = sprintf(
421 '<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the %1$s.</p>
422 <p>No irrevocable gift, whether outright or life-income in character, will be accepted if under any reasonable set of circumstances the gift would jeopardize the donor’s financial security.</p>
423 <p>The %1$s will refrain from providing advice about the tax or other treatment of gifts and will encourage donors to seek guidance from their own professional advisers to assist them in the process of making their donation.</p>
424 <p>The %1$s will accept donations of cash or publicly traded securities. Gifts of in-kind services will be accepted at the discretion of the %1$s.</p>
425 <p>Certain other gifts, real property, personal property, in-kind gifts, non-liquid securities, and contributions whose sources are not transparent or whose use is restricted in some manner, must be reviewed prior to acceptance due to the special obligations raised or liabilities they may pose for %1$s.</p>
426 <p>The %1$s will provide acknowledgments to donors meeting tax requirements for property received by the charity as a gift. However, except for gifts of cash and publicly traded securities, no value shall be ascribed to any receipt or other form of substantiation of a gift received by %1$s.</p>
427 <p>The %1$s will respect the intent of the donor relating to gifts for restricted purposes and those relating to the desire to remain anonymous. With respect to anonymous gifts, the %1$s will restrict information about the donor to only those staff members with a need to know.</p>
428 <p>The %1$s will not compensate, whether through commissions, finders\' fees, or other means, any third party for directing a gift or a donor to the %1$s.</p>',
429 $org_name
430 );
431
432 return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name );
433 }
434
435
436 /**
437 * This function will install give related page which is not created already.
438 *
439 * @since 1.8.11
440 *
441 * @return void
442 */
443 function give_create_pages() {
444
445 // Bailout if pages already created.
446 if ( get_option( 'give_install_pages_created' ) ) {
447 return false;
448 }
449
450 $options = array();
451
452 // Checks if the Success Page option exists AND that the page exists.
453 if ( ! get_post( give_get_option( 'success_page' ) ) ) {
454
455 // Donation Confirmation (Success) Page
456 $success = wp_insert_post(
457 array(
458 'post_title' => esc_html__( 'Donation Confirmation', 'give' ),
459 'post_content' => '[give_receipt]',
460 'post_status' => 'publish',
461 'post_author' => 1,
462 'post_type' => 'page',
463 'comment_status' => 'closed'
464 )
465 );
466
467 // Store our page IDs
468 $options['success_page'] = $success;
469 }
470
471 // Checks if the Failure Page option exists AND that the page exists.
472 if ( ! get_post( give_get_option( 'failure_page' ) ) ) {
473
474 // Failed Donation Page
475 $failed = wp_insert_post(
476 array(
477 'post_title' => esc_html__( 'Donation Failed', 'give' ),
478 'post_content' => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ),
479 'post_status' => 'publish',
480 'post_author' => 1,
481 'post_type' => 'page',
482 'comment_status' => 'closed'
483 )
484 );
485
486 $options['failure_page'] = $failed;
487 }
488
489 // Checks if the History Page option exists AND that the page exists.
490 if ( ! get_post( give_get_option( 'history_page' ) ) ) {
491 // Donation History Page
492 $history = wp_insert_post(
493 array(
494 'post_title' => esc_html__( 'Donation History', 'give' ),
495 'post_content' => '[donation_history]',
496 'post_status' => 'publish',
497 'post_author' => 1,
498 'post_type' => 'page',
499 'comment_status' => 'closed'
500 )
501 );
502
503 $options['history_page'] = $history;
504 }
505
506 if ( ! empty( $options ) ) {
507 update_option( 'give_settings', array_merge( give_get_settings(), $options ), false );
508 }
509
510 add_option( 'give_install_pages_created', 1, '', false );
511 }
512
513 add_action( 'admin_init', 'give_create_pages', - 1 );
514