예제 #1
0
function pmpro_checkForUpgrades()
{
	$pmpro_db_version = pmpro_getOption("db_version");
	
	//if we can't find the DB tables, reset db_version to 0
	global $wpdb, $table_prefix;
	$wpdb->hide_errors();
	$wpdb->pmpro_membership_levels = $table_prefix . 'pmpro_membership_levels';
	$table_exists = $wpdb->query("SHOW TABLES LIKE '" . $wpdb->pmpro_membership_levels . "'");	
	if(!$table_exists)		
		$pmpro_db_version = 0;
	
	if(!$pmpro_db_version)
		$pmpro_db_version = pmpro_upgrade_1();	
	
	if($pmpro_db_version < 1.115)
		$pmpro_db_version = pmpro_upgrade_1_1_15();		
	
	if($pmpro_db_version < 1.23)
		$pmpro_db_version = pmpro_upgrade_1_2_3();	
	
	if($pmpro_db_version < 1.318)
		$pmpro_db_version = pmpro_upgrade_1_3_18();
	
	if($pmpro_db_version < 1.4)
		$pmpro_db_version = pmpro_upgrade_1_4();
		
	if($pmpro_db_version < 1.42)
		$pmpro_db_version = pmpro_upgrade_1_4_2();
		
	if($pmpro_db_version < 1.48)
		$pmpro_db_version = pmpro_upgrade_1_4_8();

	if($pmpro_db_version < 1.5)
		$pmpro_db_version = pmpro_upgrade_1_5();
		
	if($pmpro_db_version < 1.59)
		$pmpro_db_version = pmpro_upgrade_1_5_9();
		
	if($pmpro_db_version < 1.6)
		$pmpro_db_version = pmpro_upgrade_1_6();
}
function pmpro_checkForUpgrades()
{
    $pmpro_db_version = pmpro_getOption("db_version");
    //if we can't find the DB tables, reset db_version to 0
    global $wpdb, $table_prefix;
    $wpdb->hide_errors();
    $wpdb->pmpro_membership_levels = $table_prefix . 'pmpro_membership_levels';
    $table_exists = $wpdb->query("SHOW TABLES LIKE '" . $wpdb->pmpro_membership_levels . "'");
    if (!$table_exists) {
        $pmpro_db_version = 0;
    }
    if (!$pmpro_db_version) {
        $pmpro_db_version = pmpro_upgrade_1();
    }
    if ($pmpro_db_version < 1.115) {
        $pmpro_db_version = pmpro_upgrade_1_1_15();
    }
    if ($pmpro_db_version < 1.23) {
        $pmpro_db_version = pmpro_upgrade_1_2_3();
    }
    if ($pmpro_db_version < 1.318) {
        $pmpro_db_version = pmpro_upgrade_1_3_18();
    }
    if ($pmpro_db_version < 1.4) {
        $pmpro_db_version = pmpro_upgrade_1_4();
    }
    if ($pmpro_db_version < 1.42) {
        $pmpro_db_version = pmpro_upgrade_1_4_2();
    }
    if ($pmpro_db_version < 1.48) {
        $pmpro_db_version = pmpro_upgrade_1_4_8();
    }
    if ($pmpro_db_version < 1.5) {
        $pmpro_db_version = pmpro_upgrade_1_5();
    }
    if ($pmpro_db_version < 1.59) {
        $pmpro_db_version = pmpro_upgrade_1_5_9();
    }
    if ($pmpro_db_version < 1.6) {
        $pmpro_db_version = pmpro_upgrade_1_6();
    }
    //fix for fresh 1.7 installs
    if ($pmpro_db_version == 1.7) {
        //check if we have an id column in the memberships_users table
        $wpdb->pmpro_memberships_users = $table_prefix . 'pmpro_memberships_users';
        $col = $wpdb->get_var("SELECT id FROM {$wpdb->pmpro_memberships_users} LIMIT 1");
        if ($wpdb->last_error == "Unknown column 'id' in 'field list'") {
            //redo 1.5 fix
            pmpro_upgrade_1_5();
        }
        pmpro_db_delta();
        pmpro_setOption("db_version", "1.703");
        $pmpro_db_version = 1.703;
    }
    //updates from this point on should be like this if DB only
    if ($pmpro_db_version < 1.71) {
        pmpro_db_delta();
        pmpro_setOption("db_version", "1.71");
        $pmpro_db_version = 1.71;
    }
}
function pmpro_checkForUpgrades()
{
    $pmpro_db_version = pmpro_getOption("db_version");
    //if we can't find the DB tables, reset db_version to 0
    global $wpdb;
    $wpdb->hide_errors();
    $wpdb->pmpro_membership_levels = $wpdb->prefix . 'pmpro_membership_levels';
    $table_exists = $wpdb->query("SHOW TABLES LIKE '" . $wpdb->pmpro_membership_levels . "'");
    if (!$table_exists) {
        $pmpro_db_version = 0;
    }
    if (!$pmpro_db_version) {
        $pmpro_db_version = pmpro_upgrade_1();
    }
    if ($pmpro_db_version < 1.115) {
        $pmpro_db_version = pmpro_upgrade_1_1_15();
    }
    if ($pmpro_db_version < 1.23) {
        $pmpro_db_version = pmpro_upgrade_1_2_3();
    }
    if ($pmpro_db_version < 1.318) {
        $pmpro_db_version = pmpro_upgrade_1_3_18();
    }
    if ($pmpro_db_version < 1.4) {
        $pmpro_db_version = pmpro_upgrade_1_4();
    }
    if ($pmpro_db_version < 1.42) {
        $pmpro_db_version = pmpro_upgrade_1_4_2();
    }
    if ($pmpro_db_version < 1.48) {
        $pmpro_db_version = pmpro_upgrade_1_4_8();
    }
    if ($pmpro_db_version < 1.5) {
        $pmpro_db_version = pmpro_upgrade_1_5();
    }
    if ($pmpro_db_version < 1.59) {
        $pmpro_db_version = pmpro_upgrade_1_5_9();
    }
    if ($pmpro_db_version < 1.6) {
        $pmpro_db_version = pmpro_upgrade_1_6();
    }
    //fix for fresh 1.7 installs
    if ($pmpro_db_version == 1.7) {
        //check if we have an id column in the memberships_users table
        $wpdb->pmpro_memberships_users = $wpdb->prefix . 'pmpro_memberships_users';
        $col = $wpdb->get_var("SELECT id FROM {$wpdb->pmpro_memberships_users} LIMIT 1");
        if ($wpdb->last_error == "Unknown column 'id' in 'field list'") {
            //redo 1.5 fix
            pmpro_upgrade_1_5();
        }
        pmpro_db_delta();
        pmpro_setOption("db_version", "1.703");
        $pmpro_db_version = 1.703;
    }
    //updates from this point on should be like this if DB only
    if ($pmpro_db_version < 1.71) {
        pmpro_db_delta();
        pmpro_setOption("db_version", "1.71");
        $pmpro_db_version = 1.71;
    }
    if ($pmpro_db_version < 1.72) {
        //schedule the credit card expiring cron
        wp_schedule_event(current_time('timestamp'), 'monthly', 'pmpro_cron_credit_card_expiring_warnings');
        pmpro_setOption("db_version", "1.72");
        $pmpro_db_version = 1.72;
    }
    /*
    	1.7.3
    	- default Stripe Billing Fields to true
    	- unless Stripe Lite is activated, then deactivate Stripe Lite and set Stripe Billing Fields to false
    */
    if ($pmpro_db_version < 1.79) {
        //need to register caps for menu
        pmpro_activation();
        pmpro_setOption("db_version", "1.79");
        $pmpro_db_version = 1.79;
    }
    //set default filter_queries setting
    if ($pmpro_db_version < 1.791) {
        if (!pmpro_getOption("showexcerpts")) {
            pmpro_setOption("filterqueries", 1);
        } else {
            pmpro_SetOption("filterqueries", 0);
        }
        pmpro_setOption("db_version", "1.791");
        $pmpro_db_version = 1.791;
    }
}
function pmpro_checkForUpgrades()
{
    $pmpro_db_version = pmpro_getOption("db_version");
    //if we can't find the DB tables, reset db_version to 0
    global $wpdb;
    $wpdb->hide_errors();
    $wpdb->pmpro_membership_levels = $wpdb->prefix . 'pmpro_membership_levels';
    $table_exists = $wpdb->query("SHOW TABLES LIKE '" . $wpdb->pmpro_membership_levels . "'");
    if (!$table_exists) {
        $pmpro_db_version = 0;
    }
    //default options
    if (!$pmpro_db_version) {
        require_once PMPRO_DIR . "/includes/updates/upgrade_1.php";
        $pmpro_db_version = pmpro_upgrade_1();
    }
    //upgrading from early early versions of PMPro
    if ($pmpro_db_version < 1.115) {
        require_once PMPRO_DIR . "/includes/updates/upgrade_1_1_15.php";
        $pmpro_db_version = pmpro_upgrade_1_1_15();
    }
    //upgrading from early early versions of PMPro
    if ($pmpro_db_version < 1.23) {
        require_once PMPRO_DIR . "/includes/updates/upgrade_1_2_3.php";
        $pmpro_db_version = pmpro_upgrade_1_2_3();
    }
    //upgrading from early early versions of PMPro
    if ($pmpro_db_version < 1.318) {
        require_once PMPRO_DIR . "/includes/updates/upgrade_1_3_18.php";
        $pmpro_db_version = pmpro_upgrade_1_3_18();
    }
    //upgrading from early early versions of PMPro
    if ($pmpro_db_version < 1.4) {
        require_once PMPRO_DIR . "/includes/updates/upgrade_1_4.php";
        $pmpro_db_version = pmpro_upgrade_1_4();
    }
    //upgrading from early early versions of PMPro
    if ($pmpro_db_version < 1.42) {
        require_once PMPRO_DIR . "/includes/updates/upgrade_1_4_2.php";
        $pmpro_db_version = pmpro_upgrade_1_4_2();
    }
    //upgrading from early early versions of PMPro
    if ($pmpro_db_version < 1.48) {
        require_once PMPRO_DIR . "/includes/updates/upgrade_1_4_8.php";
        $pmpro_db_version = pmpro_upgrade_1_4_8();
    }
    //upgrading from early early versions of PMPro
    if ($pmpro_db_version < 1.5) {
        require_once PMPRO_DIR . "/includes/updates/upgrade_1_5.php";
        $pmpro_db_version = pmpro_upgrade_1_5();
    }
    //upgrading from early early versions of PMPro
    if ($pmpro_db_version < 1.59) {
        require_once PMPRO_DIR . "/includes/updates/upgrade_1_5_9.php";
        $pmpro_db_version = pmpro_upgrade_1_5_9();
    }
    //upgrading from early early versions of PMPro
    if ($pmpro_db_version < 1.6) {
        require_once PMPRO_DIR . "/includes/updates/upgrade_1_6.php";
        $pmpro_db_version = pmpro_upgrade_1_6();
    }
    //fix for fresh 1.7 installs
    if ($pmpro_db_version == 1.7) {
        //check if we have an id column in the memberships_users table
        $wpdb->pmpro_memberships_users = $wpdb->prefix . 'pmpro_memberships_users';
        $col = $wpdb->get_var("SELECT id FROM {$wpdb->pmpro_memberships_users} LIMIT 1");
        if ($wpdb->last_error == "Unknown column 'id' in 'field list'") {
            //redo 1.5 fix
            require_once PMPRO_DIR . "/includes/updates/upgrade_1_5.php";
            pmpro_upgrade_1_5();
        }
        pmpro_db_delta();
        pmpro_setOption("db_version", "1.703");
        $pmpro_db_version = 1.703;
    }
    //updates from this point on should be like this if DB only
    if ($pmpro_db_version < 1.71) {
        pmpro_db_delta();
        pmpro_setOption("db_version", "1.71");
        $pmpro_db_version = 1.71;
    }
    //schedule the credit card expiring cron
    if ($pmpro_db_version < 1.72) {
        //schedule the credit card expiring cron
        pmpro_maybe_schedule_event(current_time('timestamp'), 'monthly', 'pmpro_cron_credit_card_expiring_warnings');
        pmpro_setOption("db_version", "1.72");
        $pmpro_db_version = 1.72;
    }
    //register capabilities required for menus now
    if ($pmpro_db_version < 1.79) {
        //need to register caps for menu
        pmpro_activation();
        pmpro_setOption("db_version", "1.79");
        $pmpro_db_version = 1.79;
    }
    //set default filter_queries setting
    if ($pmpro_db_version < 1.791) {
        if (!pmpro_getOption("showexcerpts")) {
            pmpro_setOption("filterqueries", 1);
        } else {
            pmpro_SetOption("filterqueries", 0);
        }
        pmpro_setOption("db_version", "1.791");
        $pmpro_db_version = 1.791;
    }
    //fix subscription ids on stripe orders
    require_once PMPRO_DIR . "/includes/updates/upgrade_1_8_6_9.php";
    //need to include this for AJAX calls
    if ($pmpro_db_version < 1.869) {
        $pmpro_db_version = pmpro_upgrade_1_8_6_9();
    }
    //Remove extra cron jobs inserted in version 1.8.7 and 1.8.7.1
    if ($pmpro_db_version < 1.87) {
        require_once PMPRO_DIR . "/includes/updates/upgrade_1_8_7.php";
        $pmpro_db_version = pmpro_upgrade_1_8_7();
    }
    /*
    	v1.8.8
    	* Running the cron job cleanup again.
    	* Fixing old $0 Stripe orders.
    	* Fixing old Authorize.net orders with empty status.
    */
    require_once PMPRO_DIR . "/includes/updates/upgrade_1_8_8.php";
    if ($pmpro_db_version < 1.88) {
        $pmpro_db_version = pmpro_upgrade_1_8_8();
    }
    /*
    	v1.8.9.1
    	* Fixing Stripe orders where user_id/membership_id = 0		
    */
    require_once PMPRO_DIR . "/includes/updates/upgrade_1_8_9_1.php";
    if ($pmpro_db_version < 1.891) {
        $pmpro_db_version = pmpro_upgrade_1_8_9_1();
    }
    /*
    	v1.8.9.2 (db v1.9)
    	* Changed 'code' column of pmpro_membership_orders table to 32 characters.
    */
    if ($pmpro_db_version < 1.892) {
        pmpro_db_delta();
        $pmpro_db_version = 1.892;
        pmpro_setOption("db_version", "1.892");
    }
    /*
    	v1.8.9.3 (db v1.91)
    	* Fixing incorrect start and end dates.	
    */
    require_once PMPRO_DIR . "/includes/updates/upgrade_1_8_9_3.php";
    if ($pmpro_db_version < 1.91) {
        $pmpro_db_version = pmpro_upgrade_1_8_9_3();
    }
    /*
    	v1.8.10 (db v1.92)
    
    	Added checkout_id column to pmpro_membership_orders
    */
    if ($pmpro_db_version < 1.92) {
        pmpro_db_delta();
        $pmpro_db_version = 1.92;
        pmpro_setOption("db_version", "1.92");
    }
    /*
    	v1.8.10.2 (db v1.93)
    
    	Run dbDelta again to fix broken/missing orders tables.
    */
    if ($pmpro_db_version < 1.93) {
        pmpro_db_delta();
        $pmpro_db_version = 1.93;
        pmpro_setOption("db_version", "1.93");
    }
}