Easy Digital Downloads
  • Package
  • Function
  • Tree

Packages

  • EDD
    • Admin
      • Actions
      • Add-ons
      • Dashboard
      • Discounts
      • Downloads
      • Export
      • Notices
      • Pages
      • Payments
      • Reports
      • Settings
      • System
      • Upgrades
      • Upload
      • Welcome
    • Cart
    • Checkout
    • Classes
      • API
      • Fees
      • HTML
      • Roles
      • Session
    • Emails
    • Functions
      • AJAX
      • Compatibility
      • Errors
      • Formatting
      • Install
      • Login
      • Taxes
      • Templates
    • Gateways
    • Logging
    • Payments
    • Shortcodes
    • Widgets

Functions

  • edd_install
  1 <?php
  2 /**
  3  * Install Function
  4  *
  5  * @package     EDD
  6  * @subpackage  Functions/Install
  7  * @copyright   Copyright (c) 2013, Pippin Williamson
  8  * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
  9  * @since       1.0
 10 */
 11 
 12 // Exit if accessed directly
 13 if ( ! defined( 'ABSPATH' ) ) exit;
 14 
 15 /**
 16  * Install
 17  *
 18  * Runs on plugin install by setting up the post types, custom taxonomies,
 19  * flushing rewrite rules to initiate the new 'downloads' slug and also
 20  * creates the plugin and populates the settings fields for those plugin
 21  * pages. After successfull install, the user is redirected to the EDD Welcome
 22  * screen.
 23  *
 24  * @since 1.0
 25  * @global $wpdb
 26  * @global $edd_options
 27  * @global $wp_version
 28  * @return void
 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     // Setup the Downloads Custom Post Type
 39     edd_setup_edd_post_types();
 40 
 41     // Setup the Download Taxonomies
 42     edd_setup_download_taxonomies();
 43 
 44     // Clear the permalinks
 45     flush_rewrite_rules();
 46 
 47     // Checks if the purchase page option exists
 48     if ( ! isset( $edd_options['purchase_page'] ) ) {
 49         // Checkout Page
 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         // Purchase Confirmation (Success) Page
 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         // Failed Purchase Page
 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         // Purchase History (History) Page
 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         // Store our page IDs
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     // Bail if activating from network, or bulk
111     if ( is_network_admin() || isset( $_GET['activate-multi'] ) )
112 
113     // Add the transient to redirect
114     set_transient( '_edd_activation_redirect', true, 30 );
115 }
116 register_activation_hook( EDD_PLUGIN_FILE, 'edd_install' );
Easy Digital Downloads API documentation generated by ApiGen 2.8.0