# taskbuilder/6.0.6/includes/wppm-install.php

Taskbuilder – Project Management &amp; Task Management Tool With Kanban Board, version 6.0.6. 639 lines.

- Page: https://pluginprobe.com/plugins/taskbuilder/6.0.6/code/includes/wppm-install.php
- Raw: https://pluginprobe.com/plugins/taskbuilder/6.0.6/raw/includes/wppm-install.php
- Modified: 2026-09-17T18:30:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/taskbuilder/6.0.6/code/includes/wppm-install.php#L10-L20`.

```php
<?php 
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

if ( ! class_exists( 'WPPM_Install' ) ) :

final class WPPM_Install {
	public function __construct() {
		$this->check_version();
	}
	/**
     * Check version of Taskbuilder
     */
    public function check_version(){
		$installed_version = get_option( 'wppm_version' );
        if( $installed_version != WPPM_VERSION ){
          	$this->create_db_tables();
			add_action( 'init', array($this,'upgrade'), 101 );
        }
	}
	/**** Create mysql tables****/
	public function create_db_tables() {
		global $wpdb;
		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_project (
			id integer NOT NULL AUTO_INCREMENT,
			created_by integer,
			project_name VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
			description LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
			start_date datetime,
			end_date datetime,
			status integer,
			cat_id integer,
			users VARCHAR( 200 ) NULL DEFAULT '0',
			date_created datetime,
			PRIMARY KEY  (id)
		);";
		dbDelta( $sql );

		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_project_meta (
			id integer NOT NULL AUTO_INCREMENT,
			project_id integer,
			meta_key LONGTEXT NULL DEFAULT NULL,
			meta_value LONGTEXT NULL DEFAULT NULL,
			PRIMARY KEY  (id)
		);";
		dbDelta( $sql );
			
		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_project_categories (
			id integer NOT NULL AUTO_INCREMENT,
			name TINYTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
			load_order int(11) NOT NULL DEFAULT '1',
			PRIMARY KEY  (id)
		);";
		dbDelta( $sql );

		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_project_statuses (
			id bigint(20) NOT NULL AUTO_INCREMENT,
			name varchar(200) COLLATE utf8mb4_unicode_520_ci NOT NULL,
			color varchar(50) COLLATE utf8mb4_unicode_520_ci NOT NULL,
			bg_color varchar(50) COLLATE utf8mb4_unicode_520_ci NOT NULL,
			load_order int(11) NOT NULL DEFAULT '1',
			PRIMARY KEY  (id)
		);";
		dbDelta( $sql );

		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_task_statuses (
			id bigint(20) NOT NULL AUTO_INCREMENT,
			name varchar(200) COLLATE utf8mb4_unicode_520_ci NOT NULL,
			color varchar(50) COLLATE utf8mb4_unicode_520_ci NOT NULL,
			bg_color varchar(50) COLLATE utf8mb4_unicode_520_ci NOT NULL,
			load_order int(11) NOT NULL DEFAULT '1',
			PRIMARY KEY  (id)
		);";
		dbDelta( $sql );

		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_task_priorities (
			id bigint(20) NOT NULL AUTO_INCREMENT,
			name varchar(200) COLLATE utf8mb4_unicode_520_ci NOT NULL,
			color varchar(50) COLLATE utf8mb4_unicode_520_ci NOT NULL,
			bg_color varchar(50) COLLATE utf8mb4_unicode_520_ci NOT NULL,
			load_order int(11) NOT NULL DEFAULT '1',
			PRIMARY KEY  (id)
		);";
		dbDelta( $sql );

		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_task (
			id integer NOT NULL AUTO_INCREMENT,
			created_by integer,
			task_name VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
			description LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
			project integer,
			start_date datetime,
			end_date datetime,
			status integer,
			priority integer,
			users VARCHAR( 200 ) NULL DEFAULT '0',
			date_created datetime,
			task_auth_code LONGTEXT NULL DEFAULT NULL,
			active int(11) DEFAULT 1,
			parent_task_id integer NOT NULL DEFAULT 0,
			PRIMARY KEY  (id)
		);";
		dbDelta( $sql );

		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_task_meta (
			id integer NOT NULL AUTO_INCREMENT,
			task_id integer,
			meta_key LONGTEXT NULL DEFAULT NULL,
			meta_value LONGTEXT NULL DEFAULT NULL,
			PRIMARY KEY  (id)
		);";
		dbDelta( $sql );

		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_checklist (
			id integer NOT NULL AUTO_INCREMENT,
			task_id integer,
			checklist_name VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
			created_by integer,
			PRIMARY KEY  (id)
		);";
		dbDelta( $sql );

		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_checklist_items (
			id integer NOT NULL AUTO_INCREMENT,
			checklist_id integer,
			item_name VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
			checked integer,
			members VARCHAR( 200 ) NULL DEFAULT '0',
			due_date datetime,
			PRIMARY KEY  (id)
		);";
		dbDelta( $sql );

		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_task_comment (
			id integer NOT NULL AUTO_INCREMENT,
			task_id integer,
			body LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
			attachment_ids TINYTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
			create_time datetime,
			created_by integer,
			PRIMARY KEY  (id)
		);";
		dbDelta( $sql );
		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_project_comment (
			id integer NOT NULL AUTO_INCREMENT,
			proj_id integer,
			body LONGTEXT NULL DEFAULT NULL,
			attachment_ids TINYTEXT NULL DEFAULT NULL,
			create_time datetime,
			created_by integer,
			PRIMARY KEY  (id)
		);";
		dbDelta( $sql );
		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_attachments (
			id BIGINT NOT NULL AUTO_INCREMENT,
			name VARCHAR(200) NOT NULL,
			file_name VARCHAR(200) NOT NULL,
			file_path VARCHAR(500) NOT NULL,
			is_image INT(1) NOT NULL DEFAULT 0,
			is_active INT(1) NOT NULL DEFAULT 0,
			is_uploaded INT(1) NOT NULL DEFAULT 0,
			date_created DATETIME NOT NULL,
			PRIMARY KEY (id)
		);";
		dbDelta( $sql );
		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_project_users (
			id BIGINT NOT NULL AUTO_INCREMENT,
			proj_id integer,
			user_id integer,
			role_id integer,
			assigned_by integer,
			PRIMARY KEY (id)
		);";
		dbDelta( $sql );
		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_project_comment_meta (
			id BIGINT NOT NULL AUTO_INCREMENT,
			proj_id integer,
			comment_id integer,
			comment_type VARCHAR(200) NOT NULL,
			PRIMARY KEY (id)
		);";
		dbDelta( $sql );
		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_task_comment_meta (
			id BIGINT NOT NULL AUTO_INCREMENT,
			task_id integer,
			comment_id integer,
			comment_type VARCHAR(200) NOT NULL,
			PRIMARY KEY (id)
		);";
		dbDelta( $sql );
		$sql = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}wppm_notifications (
			id BIGINT AUTO_INCREMENT PRIMARY KEY,
			user_id INT,
			message TEXT,
			link TEXT,
			is_read TINYINT DEFAULT 0,
			notification_type VARCHAR(200) NOT NULL,
			created_at DATETIME DEFAULT CURRENT_TIMESTAMP
			);";
		dbDelta( $sql );	
	}

	public function upgrade(){
		global $wpdb,$wppmfunction;
		$installed_version = get_option( 'wppm_version' );
		$installed_version = $installed_version ? $installed_version : 0;
		if($installed_version < '1.0.0'){
			//User Roles
			$user_role = get_option('wppm_user_role');
			if(empty($user_role)){
				$user_role = array(
					1 => array(
						'label' => esc_html__('manager','taskbuilder'),
					),
					2 => array(
						'label' => esc_html__('co-worker','taskbuilder'),
					)
				);
				update_option('wppm_user_role',$user_role);
			}

			$wppm_email_notificatins = get_option('wppm_email_notification');
			if(empty($wppm_email_notificatins)){
				$wppm_email_notificatins = array(
					1=>array(
						'type'=>'new_project',
						'subject'=>esc_html__('New project has been created:{project_name}','taskbuilder'),
						'body'=>esc_html__('<p><strong>{user_name}</strong> assigned project to you.</p> <p>Below are details of the project :</p><p><strong> Assign to:-</strong>{project_assigned_users}</p><p><strong> Start Date:-</strong>{project_start_date} </p><p> <strong> End Date:- </strong> {project_end_date} </p> <p><strong>Description:-</strong>{project_description}</p>','taskbuilder'),
						'recipients'=>array(1,2)
					),
					2=>array(
						'type'=>'new_task',
						'subject'=>esc_html__('New task has been created: {task_name}','taskbuilder'),
						'body'=>esc_html__('<p><strong>{user_name}</strong> assigned task to you.</p><p>Below are details of the task :</p> <p><strong>Assign to:-</strong>{task_assigned_users} </p><p><strong> Start Date:-</strong>{task_start_date}</p><p><strong>End Date:-</strong>{task_end_date} </p><p> <strong>Description:-</strong>{task_description}</p>','taskbuilder'),
						'recipients'=>array(1,2)
					),
					3=>array(
						'type'=>'change_project_status',
						'subject'=>esc_html__('{project_name} Project\'s status has been changed from {old_project_status} to {new_project_status}','taskbuilder'),
						'body'=>esc_html__('<p><strong>{user_name}</strong> changed project\'s status to <strong>{new_project_status}</strong> </p> <p>Below are details of the project:</p><p><strong>Assign to:- </strong> {project_assigned_users}</p><p><strong>Start Date:-</strong>{project_start_date} </p> <p><strong>End Date:-</strong>{project_end_date} </p> <p><strong>Description:-</strong>{project_description}</p>','taskbuilder'),
						'recipients'=>array(1,2)
					),
					4=>array(
						'type'=>'change_task_status',
						'subject'=>esc_html__('{task_name} Task\'s status has been changed from {old_task_status} to {new_task_status}','taskbuilder'),
						'body'=>esc_html__('<p><strong>{user_name}</strong> changed task status to <strong>{new_task_status} </strong><p> Below are details of the task:</p> <p><strong>Assign to:-</strong>{task_assigned_users} </p> <p><strong>Start Date:-</strong>{task_start_date}</p><p><strong>End Date:-</strong>{task_end_date} </p> <p><strong>Description:-</strong>{task_description}</p>','taskbuilder'),
						'recipients'=>array(1,2)
					),
					5=>array(
						'type'=>'change_project_assign_users',
						'subject'=>esc_html__('{project_name} Project\'s assigned users changed from {previously_assigned_project_users} to {project_assigned_users}','taskbuilder'),
						'body'=>esc_html__('<p><strong>{user_name}</strong> changed project\'s assign users to <strong> {project_assigned_users}</strong></p> <p>Below are details of the project :</p><p><strong> Assign to:-</strong>{project_assigned_users}</p><p><strong> Start Date:-</strong>{project_start_date} </p><p> <strong> End Date:- </strong> {project_end_date} </p> <p><strong>Description:-</strong>{project_description}</p>','taskbuilder'),
						'recipients'=>array(1,2)
					),
					6=>array(
						'type'=>'change_task_assign_users',
						'subject'=>esc_html__('{task_name} Task\'s assigned users change from {previously_assigned_task_users} to {task_assigned_users}','taskbuilder'),
						'body'=>esc_html__('<p><strong>{user_name}</strong> changed task\'s assign users to <strong>{task_assigned_users}</strong></p><p>Below are details of the task :</p> <p><strong>Assign to:-</strong>{task_assigned_users} </p><p><strong> Start Date:-</strong>{task_start_date}</p><p><strong>End Date:-</strong>{task_end_date} </p><p> <strong>Description:-</strong>{task_description}</p>','taskbuilder'),
						'recipients'=>array(1,2)
					),
					7=>array(
						'type'=>'new_discussion',
						'subject'=>esc_html__('[{project_name}][{task_name}] {last_comment_user_name} started new discussion:','taskbuilder'),
						'body'=>esc_html__('<p><strong>{last_comment_user_name}</strong> wrote:</p> <p>{comment_body}</p>','taskbuilder'),
						'recipients'=>array(1,2)
					)
				);
				update_option('wppm_email_notification',$wppm_email_notificatins);
			}

			update_option('wppm_default_task_list_view',1);

			$default_statuses = $wpdb->get_var("select count(*) from {$wpdb->prefix}wppm_project_statuses");
			if (empty($default_statuses)) {
				$wpdb->insert($wpdb->prefix . "wppm_project_statuses", array('id' => 1,'name' => esc_html__('New','taskbuilder'),'color'=>'#ffffff','bg_color'=>'#306EFF','load_order'=>1));
				$wpdb->insert($wpdb->prefix . "wppm_project_statuses", array('id' => 2,'name' => esc_html__('In Progress','taskbuilder'),'color'=>'#ffffff','bg_color'=>'#FCD12A','load_order'=>2));
				$wpdb->insert($wpdb->prefix . "wppm_project_statuses", array('id' => 3,'name' => esc_html__('Hold','taskbuilder'),'color'=>'#ffffff','bg_color'=>'#D3D3D3','load_order'=>3));
				$wpdb->insert($wpdb->prefix . "wppm_project_statuses", array('id' => 4,'name' => esc_html__('Completed','taskbuilder'),'color'=>'#ffffff','bg_color'=>'#5cb85c','load_order'=>4));
			}
			$wppm_default_project_status = get_option('wppm_default_project_status',true);
			if($wppm_default_project_status == ''){
				update_option('wppm_default_project_status',1);
			}
			$default_task_statuses = $wpdb->get_var("select count(*) from {$wpdb->prefix}wppm_task_statuses");
			if (empty($default_task_statuses)) {
				$wpdb->insert($wpdb->prefix . "wppm_task_statuses",array('id' => 1,'name' => esc_html__('Todo','taskbuilder'),'color'=>'#ffffff','bg_color'=>'#306EFF','load_order'=>1));
				$wpdb->insert($wpdb->prefix . "wppm_task_statuses",array('id' => 2,'name' => esc_html__('In Progress','taskbuilder'),'color'=>'#ffffff','bg_color'=>'#FCD12A','load_order'=>2));
				$wpdb->insert($wpdb->prefix . "wppm_task_statuses",array('id' => 3,'name' => esc_html__('Hold','taskbuilder'),'color'=>'#ffffff','bg_color'=>'#D3D3D3','load_order'=>3));
				$wpdb->insert($wpdb->prefix . "wppm_task_statuses",array('id' => 4,'name' => esc_html__('Completed','taskbuilder'),'color'=>'#ffffff','bg_color'=>'#5cb85c','load_order'=>4));
			}
			$wppm_default_task_status = get_option('wppm_default_task_status',true);
			if($wppm_default_task_status == ''){
				update_option('wppm_default_task_status',1);
			}
		}
		if($installed_version < '1.0.2'){
			update_option('wppm_project_time', 1);
		}
		if($installed_version < '2.0.0'){
			update_option('wppm_default_project_date', 1);
			update_option('wppm_default_task_date', 1);
		}
		if($installed_version < '2.0.2'){
			update_option('wppm_default_edit_tasks_permission', 0);
		}
		if($installed_version < '2.0.4'){
			update_option('wppm_public_projects_permission',0);
		}
		if($installed_version < '2.0.8'){
			update_option('wppm_task_time',1);
		}
		if($installed_version < '3.0.0'){
			$wppm_email_notificatins = get_option('wppm_email_notification');
			if(!empty($wppm_email_notificatins) && !isset($wppm_email_notificatins[8])){
				$wppm_email_notificatins[8] = array(
					'type'=>'new_proj_discussion',
					'subject'=>esc_html__('[{project_name}] {last_proj_comment_user_name} started new discussion:','taskbuilder'),
					'body'=>esc_html__('<p><strong>{last_proj_comment_user_name}</strong> wrote:</p> <p>{proj_comment_body}</p>','taskbuilder'),
					'recipients'=>array(1,2)
				);
				update_option('wppm_email_notification',$wppm_email_notificatins);
			}
			update_option(
				'wppm-ap-project-list',
				array(
					'list-header-button-background-color' => '#0052CC',
					'list-header-button-hover-color'      => '#0065ff',
					'list-header-button-text-color'       => '#fff',
					'list-header-background-color'     => '#304FFE',
					'list-header-text-color'           => '#fff',
					'list-item-odd-background-color'   => '#fff',
					'list-item-odd-text-color'         => '#2C3E50',
					'list-item-even-background-color'  => '#F2F2F2',
					'list-item-even-text-color'        => '#2C3E50',
					'list-item-hover-background-color' => '#F5F5F5',
					'list-item-hover-text-color'       => '#2C3E50'
				)
			);
			update_option(
				'wppm-ap-task-list',
				array(
					'list-header-button-background-color'=>'#0052CC',
					'list-header-button-hover-color'	=>'#0065ff',
					'list-header-button-text-color'		=>'#fff',
					'list-header-background-color'     => '#304FFE',
					'list-header-text-color'           => '#fff',
					'list-item-odd-background-color'   => '#fff',
					'list-item-odd-text-color'         => '#2C3E50',
					'list-item-even-background-color'  => '#F2F2F2',
					'list-item-even-text-color'        => '#2C3E50',
					'list-item-hover-background-color' => '#F5F5F5',
					'list-item-hover-text-color'       => '#2C3E50',
				)
			);
			update_option(
				'wppm-ap-individual-project',
				array(
					'menu-button-bg-color'		=>'#0052CC',
					'menu-button-hover-color'	=>'#0065ff',
					'menu-button-text-color'	=>'#fff',
					'comment-primary-color'      => '#000000',
					'comment-secondary-color'    => '#4e4e4e',
					'comment-date-color'         => '#a8aeb5',
					'comment-date-hover-color'   => '#000000',
					'comment-send-btn-bg-color'  => '#5067c5',
					'comment-send-btn-color'  =>	'#ffffff',
					'widget-header-bg-color'   => '#ffffff',
					'widget-header-text-color' => '#2C3E50',
					'widget-body-bg-color'     => '#ffffff',
					'widget-body-label-color'  => '#9c9c9c',
					'widget-body-text-color'   => '#2C3E50',
				)
			);
			update_option(
				'wppm-ap-individual-task',
				array(
					'comment-primary-color'      => '#000000',
					'comment-secondary-color'    => '#4e4e4e',
					'comment-date-color'         => '#a8aeb5',
					'comment-date-hover-color'   => '#000000',
					'comment-send-btn-bg-color'  => '#5067c5',
					'comment-send-btn-color'  =>	'#ffffff',
					'widget-header-bg-color'   => '#ffffff',
					'widget-header-text-color' => '#2C3E50',
					'widget-body-bg-color'     => '#ffffff',
					'widget-body-label-color'  => '#9c9c9c',
					'widget-body-text-color'   => '#2C3E50',
				)
			);
			update_option(
				'wppm-ap-modal',
				array(
					'header-bg-color'   => '#ffffff',
					'header-text-color' => '#3c434a',
					'body-bg-color'     => '#fff',
					'body-label-color'  => '#3c434a',
					'body-text-color'   => '#555',
					'footer-bg-color'   => '#F6F6F6',
					'action-btn-bg-color' =>'#306EFF',
					'action-btn-text-color'=>'#fff',
					'z-index'           => 900000000,
				)
			);
			update_option(
				'wppm-ap-grid-view',
				array(
					'menu-button-bg-color'		=>'#0052CC',
					'menu-button-hover-color'	=>'#0065ff',
					'menu-button-text-color'	=>'#fff',
					'grid-background-color'     => '#fff',
					'grid-header-text-color'    => '#2C3E50'
				)
			);
			update_option(
				'wppm-ap-settings',
				array(
					'tab-background-color'     => '#0052CC',
					'tab-text-color'    => '#fff',
					'add-new-button-bg-color'	=>'#0052CC',
					'add-new-button-text-color' =>'#fff',
					'add-new-button-hover-color'=>'#0065ff',
					'save-changes-button-bg-color'=>'#306EFF',
					'save-changes-button-text-color'=>'#fff'
				)
			);
		}
		if($installed_version < '3.0.1'){
			update_option('wppm_default_project_status', 1);
			update_option('wppm_default_task_status', 1);
		}
		if($installed_version < '3.0.5'){
			update_option('wppm_tinymce_visibility_open_task',0);
			update_option('wppm_tinymce_visibility_open_project',0);
			update_option('wppm_default_email_notification_to_current_user', 1);
		}
		if($installed_version < '3.0.6'){
			update_option('wppm_allow_coworkers_create_task',1);
			update_option('wppm_allow_coworkers_add_checklist',1);
			update_option('wppm_allow_coworkers_assign_users', 0);
			update_option('wppm_allow_coworkers_change_status', 1);
		}
		if($installed_version < '3.0.9'){
			update_option('wppm_rich_text_editor',1);
			update_option(
				'wppm_toolbar_actions',
				array(
					'bold'     => '1',
					'italic'    => '1',
					'underline'	=>'1',
					'blockquote' =>'1',
					'align'=>'1',
					'bullist'=>'1',
					'numlist'=>'1',
					'rtl'=>'1',
					'link'=>'1',
					'wppm_insert_editor_img'=>'1',
					'forecolor'=>'0',
					'backcolor' => '0',
					'strikethrough' => '0'
				)
			);
		}

		if($installed_version < '4.0.0'){
			update_option(
				'wppm-page-settings',
				array(
					'task-url-page'            => 0,
					'project-url-page'          => 0
				)
			);
		}

		if($installed_version < '4.0.4'){
			update_option('wppm_date_setting','Y-m-d h:i:sa');
		}

		if($installed_version < '4.0.5'){
			update_option('wppm_hide_completed_status_proj','1');
			update_option('wppm_hide_completed_status_task','1');
			update_option('wppm_hide_proj_statuses_from_frontend','0');
			update_option('wppm_hide_task_statuses_from_frontend','0');
			update_option('wppm_proj_hide_comment_section','1');
			update_option('wppm_task_hide_comment_section','1');
		}

		if($installed_version < '5.0.0'){
			$wppm_print_settings = array(
			'wppm_print_body_font_size' => 10);
			update_option('wppm_print_settings',$wppm_print_settings);
		}
		if($installed_version < '5.0.2'){
			$table_name  = $wpdb->prefix . 'wppm_checklist_items';
			$column_name = 'load_order';
			$column_type = 'INT(11) NOT NULL DEFAULT 1';

			$column_exists = $wpdb->get_var(
				$wpdb->prepare(
					"SHOW COLUMNS FROM `$table_name` LIKE %s",
					$column_name
				)
			);

			if ( null === $column_exists ) {

				// Column name and type are hardcoded, not user input.
				// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
				$wpdb->query(
					"ALTER TABLE `$table_name`
					ADD `$column_name` $column_type"
				);
			}
			$table_name = $wpdb->prefix . 'wppm_task';
			$cl_name    = 'is_archived';
			$cl_type    = 'TINYINT(1) DEFAULT 0';

			$cl_exists = $wpdb->get_var(
				$wpdb->prepare(
					"SHOW COLUMNS FROM `$table_name` LIKE %s",
					$cl_name
				)
			);

			if ( null === $cl_exists ) {

				$sql = sprintf(
					'ALTER TABLE `%s` ADD `%s` %s',
					$table_name,
					$cl_name,
					$cl_type
				);

				// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Safe: identifiers are hardcoded.
				$wpdb->query( $sql );
			}
		}
		if($installed_version < '5.0.3'){
			update_option('wppm_display_time_duration_project',0);
			update_option('wppm_display_time_duration_task',0);

		}
		if($installed_version < '5.0.6'){
			update_option('wppm_show_update_notice', 1);
			$user_role = get_option('wppm_user_role');
			if (!isset($user_role[3])) {
				$user_role[3] = array(
					'label' => esc_html__('Client', 'taskbuilder'),
				);
			}
			update_option('wppm_user_role', $user_role);
		}
		if($installed_version < '6.0.0'){
			$table_name  = $wpdb->prefix . 'wppm_project';
			$column_name = 'project_auth_code';
			$column_type = 'LONGTEXT NULL DEFAULT NULL';
			$column_exists = $wpdb->get_var(
				$wpdb->prepare(
					"SHOW COLUMNS FROM `$table_name` LIKE %s",
					$column_name
				)
			);
			if ( empty( $column_exists ) ) {
				// Column name and type are hardcoded, not user input.
				// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
				$wpdb->query(
					"ALTER TABLE `$table_name`
					ADD `$column_name` $column_type"
				);
			}
			$projects = $wpdb->get_results(
				"SELECT id FROM {$wpdb->prefix}wppm_project
				WHERE project_auth_code IS NULL OR project_auth_code = ''"
			);
			foreach ( $projects as $project ) {
				$wpdb->update(
					"{$wpdb->prefix}wppm_project",
					array(
						'project_auth_code' => $wppmfunction->getRandomString(10),
					),
					array(
						'id' => $project->id,
					),
					array('%s'),
					array('%d')
				);
			}
			$table_name = $wpdb->prefix . 'wppm_project';
			$cl_name    = 'is_archived';
			$cl_type    = 'TINYINT(1) DEFAULT 0';
			$cl_exists = $wpdb->get_var(
				$wpdb->prepare(
					"SHOW COLUMNS FROM `$table_name` LIKE %s",
					$cl_name
				)
			);
			if ( empty( $cl_exists ) ) {
				$sql = sprintf(
					'ALTER TABLE `%s` ADD `%s` %s',
					$table_name,
					$cl_name,
					$cl_type
				);
				// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Safe: identifiers are hardcoded.
				$wpdb->query( $sql );
			}
		}
		if($installed_version < '6.0.6'){
			update_option('wppm_default_global_mention_comment_notification', 1);
			$project_list_settings = get_option( 'wppm-ap-project-list', array() );
			$project_list_settings['list-header-button-background-color'] = '#0052CC';
			$project_list_settings['list-header-button-hover-color']      = '#0065ff';
			$project_list_settings['list-header-button-text-color']       = '#fff';
			update_option( 'wppm-ap-project-list', $project_list_settings );
			$table_name  = $wpdb->prefix . 'wppm_task';
			$column_name = 'parent_task_id';
			$column_type = 'INT(11) NOT NULL DEFAULT 0';
			$column_exists = $wpdb->get_var(
				$wpdb->prepare(
					"SHOW COLUMNS FROM `$table_name` LIKE %s",
					$column_name
				)
			);
			if ( empty( $column_exists ) ) {
				// Column name and type are hardcoded, not user input.
				// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
				$wpdb->query(
					"ALTER TABLE `$table_name`
					ADD `$column_name` $column_type"
				);
			}
		}
		// update wppm_version option to plugin version
		update_option( 'wppm_version', WPPM_VERSION );
	}
}

endif;

new WPPM_Install();
```
