function affiliate_wp_install() { // Create affiliate caps $roles = new Affiliate_WP_Capabilities(); $roles->add_caps(); $affiliate_wp_install = new stdClass(); $affiliate_wp_install->affiliates = new Affiliate_WP_DB_Affiliates(); $affiliate_wp_install->affiliate_meta = new Affiliate_WP_Affiliate_Meta_DB(); $affiliate_wp_install->referrals = new Affiliate_WP_Referrals_DB(); $affiliate_wp_install->visits = new Affiliate_WP_Visits_DB(); $affiliate_wp_install->creatives = new Affiliate_WP_Creatives_DB(); $affiliate_wp_install->settings = new Affiliate_WP_Settings(); $affiliate_wp_install->affiliates->create_table(); $affiliate_wp_install->affiliate_meta->create_table(); $affiliate_wp_install->referrals->create_table(); $affiliate_wp_install->visits->create_table(); $affiliate_wp_install->creatives->create_table(); if (!get_option('affwp_is_installed')) { $affiliate_area = wp_insert_post(array('post_title' => __('Affiliate Area', 'affiliate-wp'), 'post_content' => '[affiliate_area]', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page', 'comment_status' => 'closed')); $options = $affiliate_wp_install->settings->get_all(); $options['affiliates_page'] = $affiliate_area; update_option('affwp_settings', $options); } update_option('affwp_is_installed', '1'); update_option('affwp_version', AFFILIATEWP_VERSION); // Clear rewrite rules flush_rewrite_rules(); // Bail if activating from network, or bulk if (is_network_admin() || isset($_GET['activate-multi'])) { return; } // Add the transient to redirect set_transient('_affwp_activation_redirect', true, 30); }
function test_admin_has_caps() { $this->markTestIncomplete('Fails 50% of the time. No idea why'); $roles = new Affiliate_WP_Capabilities(); $roles->add_caps(); $user = new WP_User($this->_user_id); $this->assertTrue($user->has_cap('view_affiliate_reports')); $this->assertTrue($user->has_cap('export_affiliate_data')); $this->assertTrue($user->has_cap('manage_affiliate_options')); $this->assertTrue($user->has_cap('manage_affiliates')); $this->assertTrue($user->has_cap('manage_referrals')); $this->assertTrue($user->has_cap('manage_visits')); $this->assertTrue($user->has_cap('manage_creatives')); }
* Uninstall AffiliateWP * * @package AffiliateWP * @subpackage Uninstall * @copyright Copyright (c) 2014, Pippin Williamson * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License * @since 1.0 */ // Exit if accessed directly if (!defined('WP_UNINSTALL_PLUGIN')) { exit; } // Load AffiliateWP file include_once 'affiliate-wp.php'; global $wpdb, $wp_roles; $affiliate_wp_settings = new Affiliate_WP_Settings(); if ($affiliate_wp_settings->get('uninstall_on_delete')) { // Remove the affiliate area page wp_delete_post($affiliate_wp_settings->get('affiliates_page')); // Remove all plugin settings delete_option('affwp_settings'); // Remove all capabilities and roles $caps = new Affiliate_WP_Capabilities(); $caps->remove_caps(); // Remove all database tables $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "affiliate_wp_affiliates"); $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "affiliate_wp_referrals"); $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "affiliate_wp_visits"); $wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "affiliate_wp_creatives"); $wpdb->query("DROP VIEW " . $wpdb->prefix . "affiliate_wp_campaigns"); }