1 <?php
2 3 4 5 6 7 8 9 10
11
12
13 if ( ! defined( 'ABSPATH' ) ) exit;
14
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
30 function edd_install() {
31 global $wpdb, $edd_options, $wp_version;
32
33 if ( (float) $wp_version < 3.3 ) {
34 deactivate_plugins( plugin_basename( __FILE__ ) );
35 wp_die( __( 'Looks like you\'re running an older version of WordPress, you need to be running at least WordPress 3.3 to use Easy Digital Downloads.', 'edd' ), __( 'Easy Digital Downloads is not compatible with this version of WordPress.', 'edd' ), array( 'back_link' => true ) );
36 }
37
38
39 edd_setup_edd_post_types();
40
41
42 edd_setup_download_taxonomies();
43
44
45 flush_rewrite_rules();
46
47
48 if ( ! isset( $edd_options['purchase_page'] ) ) {
49
50 $checkout = wp_insert_post(
51 array(
52 'post_title' => __( 'Checkout', 'edd' ),
53 'post_content' => '[download_checkout]',
54 'post_status' => 'publish',
55 'post_author' => 1,
56 'post_type' => 'page',
57 'comment_status' => 'closed'
58 )
59 );
60
61
62 $success = wp_insert_post(
63 array(
64 'post_title' => __( 'Purchase Confirmation', 'edd' ),
65 'post_content' => __( 'Thank you for your purchase! [edd_receipt]', 'edd' ),
66 'post_status' => 'publish',
67 'post_author' => 1,
68 'post_type' => 'page',
69 'comment_status' => 'closed'
70 )
71 );
72
73
74 $failed = wp_insert_post(
75 array(
76 'post_title' => __( 'Transaction Failed', 'edd' ),
77 'post_content' => __( 'Your transaction failed, please try again or contact site support.', 'edd' ),
78 'post_status' => 'publish',
79 'post_author' => 1,
80 'post_type' => 'page',
81 'post_parent' => $checkout,
82 'comment_status' => 'closed'
83 )
84 );
85
86
87 $history = wp_insert_post(
88 array(
89 'post_title' => __( 'Purchase History', 'edd' ),
90 'post_content' => '[download_history]',
91 'post_status' => 'publish',
92 'post_author' => 1,
93 'post_type' => 'page',
94 'post_parent' => $checkout,
95 'comment_status' => 'closed'
96 )
97 );
98
99
100 $options = array(
101 'purchase_page' => $checkout,
102 'success_page' => $success,
103 'failure_page' => $failed
104 );
105
106 update_option( 'edd_settings_general', $options );
107 update_option( 'edd_version', EDD_VERSION );
108 }
109
110
111 if ( is_network_admin() || isset( $_GET['activate-multi'] ) )
112
113
114 set_transient( '_edd_activation_redirect', true, 30 );
115 }
116 register_activation_hook( EDD_PLUGIN_FILE, 'edd_install' );