| 1 |
<?php |
| 2 |
/** |
| 3 |
* Charitable Install class. |
| 4 |
* |
| 5 |
* The responsibility of this class is to manage the events that need to happen |
| 6 |
* when the plugin is activated. |
| 7 |
* |
| 8 |
* @package Charitable |
| 9 |
* @subpackage Charitable/Charitable Install |
| 10 |
* @copyright Copyright (c) 2015, Eric Daams |
| 11 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 12 |
* @since 1.0.0 |
| 13 |
*/ |
| 14 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 15 |
|
| 16 |
if ( ! class_exists( 'Charitable_Install' ) ) : |
| 17 |
|
| 18 |
/** |
| 19 |
* Charitable_Install |
| 20 |
* |
| 21 |
* @since 1.0.0 |
| 22 |
*/ |
| 23 |
class Charitable_Install { |
| 24 |
|
| 25 |
/** |
| 26 |
* Install the plugin. |
| 27 |
* |
| 28 |
* @access public |
| 29 |
* @since 1.0.0 |
| 30 |
*/ |
| 31 |
public function __construct() { |
| 32 |
$this->setup_roles(); |
| 33 |
$this->create_tables(); |
| 34 |
$this->setup_upgrade_log(); |
| 35 |
|
| 36 |
set_transient( 'charitable_install', 1, 0 ); |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Finish the plugin installation. |
| 41 |
* |
| 42 |
* @return void |
| 43 |
* @access public |
| 44 |
* @static |
| 45 |
* @since 1.3.4 |
| 46 |
*/ |
| 47 |
public static function finish_installing() { |
| 48 |
Charitable_Cron::schedule_events(); |
| 49 |
|
| 50 |
add_action( 'init', 'flush_rewrite_rules' ); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Create wp roles and assign capabilities |
| 55 |
* |
| 56 |
* @return void |
| 57 |
* @access protected |
| 58 |
* @since 1.0.0 |
| 59 |
*/ |
| 60 |
protected function setup_roles() { |
| 61 |
require_once( 'users/class-charitable-roles.php' ); |
| 62 |
$roles = new Charitable_Roles(); |
| 63 |
$roles->add_roles(); |
| 64 |
$roles->add_caps(); |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* Create database tables. |
| 69 |
* |
| 70 |
* @return void |
| 71 |
* @access protected |
| 72 |
* @since 1.0.0 |
| 73 |
*/ |
| 74 |
protected function create_tables() { |
| 75 |
require_once( 'db/abstract-class-charitable-db.php' ); |
| 76 |
|
| 77 |
require_once( 'db/class-charitable-campaign-donations-db.php' ); |
| 78 |
$table_helper = new Charitable_Campaign_Donations_DB(); |
| 79 |
$table_helper->create_table(); |
| 80 |
|
| 81 |
require_once( 'db/class-charitable-donors-db.php' ); |
| 82 |
$table_helper = new Charitable_Donors_DB(); |
| 83 |
$table_helper->create_table(); |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* Set up the upgrade log. |
| 88 |
* |
| 89 |
* @return void |
| 90 |
* @access protected |
| 91 |
* @since 1.3.0 |
| 92 |
*/ |
| 93 |
protected function setup_upgrade_log() { |
| 94 |
require_once( 'admin/upgrades/class-charitable-upgrade.php' ); |
| 95 |
Charitable_Upgrade::get_instance()->populate_upgrade_log_on_install(); |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
endif; |