Make the table headers all white, show any custom post task so long it has a title attached, post_type=task 

Properly map all of the acf fields, 

When clicking on a task, goto the post id, 

Only show categories tags and taxamonies for post type task only too, 

Ensure pagination is entirely fixed

# DO NOT ADD THE ACF, JUST MAP THE FIELDS, THE POST TYPE AND ACF EXIST AUTOSYNC WITH ACF EXTENDED #

add_action( 'acf/include_fields', function() {
	if ( ! function_exists( 'acf_add_local_field_group' ) ) {
		return;
	}

	acf_add_local_field_group( array(
	'key' => 'group_67327f24ea789',
	'title' => 'TaskSys',
	'fields' => array(
		array(
			'key' => 'field_67327f2718d73',
			'label' => 'Task Type',
			'name' => 'task_type',
			'aria-label' => '',
			'type' => 'select',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'choices' => array(
				'Email' => 'Email',
				'Call' => 'Call',
				'Todo' => 'Todo',
				'Meeting' => 'Meeting',
				'Followup' => 'Followup',
			),
			'default_value' => array(
			),
			'return_format' => 'value',
			'multiple' => 1,
			'min' => '',
			'max' => '',
			'prepend' => '',
			'append' => '',
			'allow_null' => 0,
			'ui' => 0,
			'ajax' => 0,
			'placeholder' => '',
			'allow_custom' => 0,
			'search_placeholder' => '',
		),
		array(
			'key' => 'field_67327fa818d74',
			'label' => 'Due Date or Time',
			'name' => 'due_date_or_time',
			'aria-label' => '',
			'type' => 'date_time_picker',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'display_format' => 'd/m/Y g:i a',
			'return_format' => 'Y-m-d H:i:s',
			'first_day' => 1,
			'placeholder' => '',
			'min_date' => '',
			'max_date' => '',
			'min_time' => '',
			'max_time' => '',
			'no_weekends' => 0,
			'min_hour' => '',
			'max_hour' => '',
			'min_min' => '',
			'max_min' => '',
			'min_sec' => '',
			'max_sec' => '',
		),
		array(
			'key' => 'field_67327fc118d76',
			'label' => 'Priority',
			'name' => 'priority',
			'aria-label' => '',
			'type' => 'select',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'choices' => array(
				'None' => 'None',
				'Low' => 'Low',
				'Medium' => 'Medium',
				'High' => 'High',
				'Urgent' => 'Urgent',
			),
			'default_value' => false,
			'return_format' => 'value',
			'multiple' => 0,
			'max' => '',
			'prepend' => '',
			'append' => '',
			'allow_null' => 0,
			'ui' => 0,
			'ajax' => 0,
			'placeholder' => '',
			'allow_custom' => 0,
			'search_placeholder' => '',
			'min' => '',
		),
		array(
			'key' => 'field_67327fd618d77',
			'label' => 'Assignee',
			'name' => 'assignee',
			'aria-label' => '',
			'type' => 'user',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'role' => '',
			'return_format' => 'array',
			'multiple' => 0,
			'max' => '',
			'acfe_bidirectional' => array(
				'acfe_bidirectional_enabled' => '0',
			),
			'allow_null' => 0,
			'bidirectional' => 0,
			'bidirectional_target' => array(
			),
			'min' => '',
		),
		array(
			'key' => 'field_67327fee18d78',
			'label' => 'Task Status',
			'name' => 'task_status',
			'aria-label' => '',
			'type' => 'select',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'choices' => array(
				'All' => 'All',
				'Assigned' => 'Assigned',
				'Completed' => 'Completed',
				'In Progress' => 'In Progress',
				'Not Started' => 'Not Started',
				'Overdue' => 'Overdue',
				'Due Today' => 'Due Today',
				'Upcoming' => 'Upcoming',
				'Waiting' => 'Waiting',
				'On Hold' => 'On Hold',
				'Cancelled' => 'Cancelled',
				'Transferred' => 'Transferred',
			),
			'default_value' => false,
			'return_format' => 'array',
			'multiple' => 0,
			'max' => '',
			'prepend' => '',
			'append' => '',
			'allow_null' => 0,
			'ui' => 0,
			'ajax' => 0,
			'placeholder' => '',
			'allow_custom' => 0,
			'search_placeholder' => '',
			'min' => '',
		),
		array(
			'key' => 'field_6732800f18d79',
			'label' => 'Task History',
			'name' => 'task_history',
			'aria-label' => '',
			'type' => 'repeater',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'acfe_repeater_stylised_button' => 0,
			'layout' => 'table',
			'pagination' => 0,
			'min' => 0,
			'max' => 0,
			'collapsed' => '',
			'button_label' => 'Add Row',
			'rows_per_page' => 20,
			'sub_fields' => array(
				array(
					'key' => 'field_6732801818d7a',
					'label' => 'Task History Date',
					'name' => 'task_history_date',
					'aria-label' => '',
					'type' => 'date_time_picker',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'display_format' => 'd/m/Y g:i a',
					'return_format' => 'Y-m-d H:i:s',
					'first_day' => 1,
					'placeholder' => '',
					'min_date' => '',
					'max_date' => '',
					'min_time' => '',
					'max_time' => '',
					'no_weekends' => 0,
					'min_hour' => '',
					'max_hour' => '',
					'min_min' => '',
					'max_min' => '',
					'min_sec' => '',
					'max_sec' => '',
					'parent_repeater' => 'field_6732800f18d79',
				),
				array(
					'key' => 'field_6732802718d7b',
					'label' => 'Task History Action',
					'name' => 'task_history_action',
					'aria-label' => '',
					'type' => 'select',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'choices' => array(
						'All' => 'All',
						'Assigned' => 'Assigned',
						'Completed' => 'Completed',
						'In Progress' => 'In Progress',
						'Not Started' => 'Not Started',
						'Overdue' => 'Overdue',
						'Due Today' => 'Due Today',
						'Upcoming' => 'Upcoming',
						'Waiting' => 'Waiting',
						'On Hold' => 'On Hold',
						'Cancelled' => 'Cancelled',
						'Transferred' => 'Transferred',
					),
					'default_value' => false,
					'return_format' => 'value',
					'multiple' => 0,
					'max' => '',
					'prepend' => '',
					'append' => '',
					'allow_null' => 0,
					'ui' => 0,
					'ajax' => 0,
					'placeholder' => '',
					'allow_custom' => 0,
					'search_placeholder' => '',
					'min' => '',
					'parent_repeater' => 'field_6732800f18d79',
				),
				array(
					'key' => 'field_673282b88b70c',
					'label' => 'Task History User',
					'name' => 'task_history_user',
					'aria-label' => '',
					'type' => 'user',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'role' => '',
					'return_format' => 'id',
					'multiple' => 0,
					'max' => '',
					'acfe_bidirectional' => array(
						'acfe_bidirectional_enabled' => '0',
					),
					'allow_null' => 0,
					'bidirectional' => 0,
					'bidirectional_target' => array(
					),
					'min' => '',
					'parent_repeater' => 'field_6732800f18d79',
				),
				array(
					'key' => 'field_673282c98b70d',
					'label' => 'Task History Notes',
					'name' => 'task_history_notes',
					'aria-label' => '',
					'type' => 'wysiwyg',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'default_value' => '',
					'acfe_wysiwyg_auto_init' => 0,
					'acfe_wysiwyg_height' => 300,
					'acfe_wysiwyg_max_height' => '',
					'acfe_wysiwyg_valid_elements' => '',
					'acfe_wysiwyg_custom_style' => '',
					'acfe_wysiwyg_disable_wp_style' => 0,
					'acfe_wysiwyg_autoresize' => 0,
					'acfe_wysiwyg_disable_resize' => 0,
					'acfe_wysiwyg_remove_path' => 0,
					'acfe_wysiwyg_menubar' => 0,
					'acfe_wysiwyg_transparent' => 0,
					'acfe_wysiwyg_merge_toolbar' => 0,
					'acfe_wysiwyg_custom_toolbar' => 0,
					'tabs' => 'all',
					'toolbar' => 'full',
					'media_upload' => 1,
					'delay' => 0,
					'acfe_wysiwyg_min_height' => 300,
					'acfe_wysiwyg_toolbar_buttons' => array(
					),
					'parent_repeater' => 'field_6732800f18d79',
				),
			),
		),
		array(
			'key' => 'field_673283134af91',
			'label' => 'Task Category',
			'name' => 'task_category',
			'aria-label' => '',
			'type' => 'taxonomy',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'taxonomy' => 'category',
			'add_term' => 1,
			'save_terms' => 0,
			'load_terms' => 1,
			'return_format' => 'id',
			'field_type' => 'checkbox',
			'min' => '',
			'max' => '',
			'acfe_bidirectional' => array(
				'acfe_bidirectional_enabled' => '0',
			),
			'bidirectional' => 0,
			'multiple' => 0,
			'allow_null' => 0,
			'bidirectional_target' => array(
			),
		),
		array(
			'key' => 'field_673283324af92',
			'label' => 'Task Tag',
			'name' => 'task_tag',
			'aria-label' => '',
			'type' => 'taxonomy',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'taxonomy' => 'post_tag',
			'add_term' => 1,
			'save_terms' => 0,
			'load_terms' => 1,
			'return_format' => 'id',
			'field_type' => 'checkbox',
			'min' => '',
			'max' => '',
			'acfe_bidirectional' => array(
				'acfe_bidirectional_enabled' => '0',
			),
			'bidirectional' => 0,
			'multiple' => 0,
			'allow_null' => 0,
			'bidirectional_target' => array(
			),
		),
		array(
			'key' => 'field_673283514af93',
			'label' => 'Associated Contact',
			'name' => 'associated_contact',
			'aria-label' => '',
			'type' => 'user',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'role' => '',
			'return_format' => 'array',
			'multiple' => 1,
			'min' => '',
			'max' => '',
			'acfe_bidirectional' => array(
				'acfe_bidirectional_enabled' => '0',
			),
			'allow_null' => 0,
			'bidirectional' => 0,
			'bidirectional_target' => array(
			),
		),
		array(
			'key' => 'field_673283a84af94',
			'label' => 'Associated Company',
			'name' => 'associated_company',
			'aria-label' => '',
			'type' => 'user',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'role' => '',
			'return_format' => 'array',
			'multiple' => 1,
			'min' => '',
			'max' => '',
			'acfe_bidirectional' => array(
				'acfe_bidirectional_enabled' => '0',
			),
			'allow_null' => 0,
			'bidirectional' => 0,
			'bidirectional_target' => array(
			),
		),
		array(
			'key' => 'field_673283fd4af95',
			'label' => 'Last Contacted',
			'name' => 'last_contacted',
			'aria-label' => '',
			'type' => 'date_time_picker',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'display_format' => 'd/m/Y g:i a',
			'return_format' => 'Y-m-d H:i:s',
			'first_day' => 1,
			'placeholder' => '',
			'min_date' => '',
			'max_date' => '',
			'min_time' => '',
			'max_time' => '',
			'no_weekends' => 0,
			'min_hour' => '',
			'max_hour' => '',
			'min_min' => '',
			'max_min' => '',
			'min_sec' => '',
			'max_sec' => '',
		),
		array(
			'key' => 'field_6732840a4af96',
			'label' => 'Last Engagement',
			'name' => 'last_engagement',
			'aria-label' => '',
			'type' => 'date_time_picker',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'display_format' => 'd/m/Y g:i a',
			'return_format' => 'Y-m-d H:i:s',
			'first_day' => 1,
			'placeholder' => '',
			'min_date' => '',
			'max_date' => '',
			'min_time' => '',
			'max_time' => '',
			'no_weekends' => 0,
			'min_hour' => '',
			'max_hour' => '',
			'min_min' => '',
			'max_min' => '',
			'min_sec' => '',
			'max_sec' => '',
		),
		array(
			'key' => 'field_673284444af97',
			'label' => 'Multi-Step Task',
			'name' => 'multi-step_task',
			'aria-label' => '',
			'type' => 'repeater',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'acfe_repeater_stylised_button' => 0,
			'layout' => 'table',
			'pagination' => 0,
			'min' => 0,
			'max' => 0,
			'collapsed' => '',
			'button_label' => 'Add Row',
			'rows_per_page' => 20,
			'sub_fields' => array(
				array(
					'key' => 'field_673284524af98',
					'label' => 'Step Description',
					'name' => 'step_description',
					'aria-label' => '',
					'type' => 'textarea',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'default_value' => '',
					'acfe_textarea_code' => 0,
					'maxlength' => '',
					'rows' => '',
					'placeholder' => '',
					'new_lines' => '',
					'parent_repeater' => 'field_673284444af97',
				),
				array(
					'key' => 'field_6732845b4af99',
					'label' => 'Step Due Date',
					'name' => 'step_due_date',
					'aria-label' => '',
					'type' => 'date_time_picker',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'display_format' => 'd/m/Y g:i a',
					'return_format' => 'Y-m-d H:i:s',
					'first_day' => 1,
					'placeholder' => '',
					'min_date' => '',
					'max_date' => '',
					'min_time' => '',
					'max_time' => '',
					'no_weekends' => 0,
					'min_hour' => '',
					'max_hour' => '',
					'min_min' => '',
					'max_min' => '',
					'min_sec' => '',
					'max_sec' => '',
					'parent_repeater' => 'field_673284444af97',
				),
				array(
					'key' => 'field_6732846b4af9a',
					'label' => 'Step Status',
					'name' => 'Step_Status',
					'aria-label' => '',
					'type' => 'select',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'choices' => array(
						'None' => 'None',
						'Low' => 'Low',
						'Medium' => 'Medium',
						'High' => 'High',
						'Urgent' => 'Urgent',
					),
					'default_value' => false,
					'return_format' => 'value',
					'multiple' => 0,
					'max' => '',
					'prepend' => '',
					'append' => '',
					'allow_null' => 0,
					'ui' => 0,
					'ajax' => 0,
					'placeholder' => '',
					'allow_custom' => 0,
					'search_placeholder' => '',
					'min' => '',
					'parent_repeater' => 'field_673284444af97',
				),
				array(
					'key' => 'field_6732863f4af9b',
					'label' => 'Step Notes',
					'name' => 'step_notes',
					'aria-label' => '',
					'type' => 'textarea',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'default_value' => '',
					'acfe_textarea_code' => 0,
					'maxlength' => '',
					'rows' => '',
					'placeholder' => '',
					'new_lines' => '',
					'parent_repeater' => 'field_673284444af97',
				),
			),
		),
		array(
			'key' => 'field_6732867a1ddb2',
			'label' => 'Follow-up Tasks',
			'name' => 'follow-up_tasks',
			'aria-label' => '',
			'type' => 'true_false',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'message' => '',
			'default_value' => 0,
			'ui' => 0,
			'ui_on_text' => '',
			'ui_off_text' => '',
			'style' => '',
		),
		array(
			'key' => 'field_673286841ddb3',
			'label' => 'Follow-up Date',
			'name' => 'follow-up_date',
			'aria-label' => '',
			'type' => 'date_time_picker',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'display_format' => 'd/m/Y g:i a',
			'return_format' => 'Y-m-d H:i:s',
			'first_day' => 1,
			'placeholder' => '',
			'min_date' => '',
			'max_date' => '',
			'min_time' => '',
			'max_time' => '',
			'no_weekends' => 0,
			'min_hour' => '',
			'max_hour' => '',
			'min_min' => '',
			'max_min' => '',
			'min_sec' => '',
			'max_sec' => '',
		),
		array(
			'key' => 'field_6732868f1ddb4',
			'label' => 'Reminder Time',
			'name' => 'reminder_time',
			'aria-label' => '',
			'type' => 'date_time_picker',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'display_format' => 'd/m/Y g:i a',
			'return_format' => 'Y-m-d H:i:s',
			'first_day' => 1,
			'placeholder' => '',
			'min_date' => '',
			'max_date' => '',
			'min_time' => '',
			'max_time' => '',
			'no_weekends' => 0,
			'min_hour' => '',
			'max_hour' => '',
			'min_min' => '',
			'max_min' => '',
			'min_sec' => '',
			'max_sec' => '',
		),
		array(
			'key' => 'field_6732869d1ddb5',
			'label' => 'Reminder Email',
			'name' => 'reminder_email',
			'aria-label' => '',
			'type' => 'email',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'default_value' => '',
			'placeholder' => '',
			'prepend' => '',
			'append' => '',
		),
		array(
			'key' => 'field_673286ac1ddb6',
			'label' => 'Reminder Notification',
			'name' => 'reminder_notification',
			'aria-label' => '',
			'type' => 'select',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'choices' => array(
				'Email' => 'Email',
				'Dashboard Notification' => 'Dashboard Notification',
				'None' => 'None',
			),
			'default_value' => false,
			'return_format' => 'value',
			'multiple' => 0,
			'max' => '',
			'prepend' => '',
			'append' => '',
			'allow_null' => 0,
			'ui' => 0,
			'ajax' => 0,
			'placeholder' => '',
			'allow_custom' => 0,
			'search_placeholder' => '',
			'min' => '',
		),
		array(
			'key' => 'field_673286c31ddb7',
			'label' => 'Reminder Tag',
			'name' => 'reminder_tag',
			'aria-label' => '',
			'type' => 'text',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'default_value' => '',
			'maxlength' => '',
			'placeholder' => '',
			'prepend' => '',
			'append' => '',
		),
		array(
			'key' => 'field_673286ce1ddb8',
			'label' => 'Assigned User Transfer',
			'name' => 'assigned_user_transfer',
			'aria-label' => '',
			'type' => 'repeater',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'acfe_repeater_stylised_button' => 0,
			'layout' => 'table',
			'pagination' => 0,
			'min' => 0,
			'max' => 0,
			'collapsed' => '',
			'button_label' => 'Add Row',
			'rows_per_page' => 20,
			'sub_fields' => array(
				array(
					'key' => 'field_673286d31ddb9',
					'label' => 'Assigned User Transfer Name',
					'name' => 'assigned_user_transfer_name',
					'aria-label' => '',
					'type' => 'user',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'role' => '',
					'return_format' => 'array',
					'multiple' => 0,
					'max' => '',
					'acfe_bidirectional' => array(
						'acfe_bidirectional_enabled' => '0',
					),
					'allow_null' => 0,
					'bidirectional' => 0,
					'bidirectional_target' => array(
					),
					'min' => '',
					'parent_repeater' => 'field_673286ce1ddb8',
				),
				array(
					'key' => 'field_673286e81ddba',
					'label' => 'Previous Assignee',
					'name' => 'previous_assignee',
					'aria-label' => '',
					'type' => 'user',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'role' => '',
					'return_format' => 'array',
					'multiple' => 0,
					'acfe_bidirectional' => array(
						'acfe_bidirectional_enabled' => '0',
					),
					'allow_null' => 0,
					'bidirectional' => 0,
					'bidirectional_target' => array(
					),
					'min' => '',
					'max' => '',
					'parent_repeater' => 'field_673286ce1ddb8',
				),
				array(
					'key' => 'field_673286fc1ddbb',
					'label' => 'New Assignee',
					'name' => 'new_assignee',
					'aria-label' => '',
					'type' => 'user',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'role' => '',
					'return_format' => 'array',
					'multiple' => 0,
					'acfe_bidirectional' => array(
						'acfe_bidirectional_enabled' => '0',
					),
					'allow_null' => 0,
					'bidirectional' => 0,
					'bidirectional_target' => array(
					),
					'min' => '',
					'max' => '',
					'parent_repeater' => 'field_673286ce1ddb8',
				),
				array(
					'key' => 'field_673287031ddbc',
					'label' => 'Reason for Transfer',
					'name' => 'reason_for_transfer',
					'aria-label' => '',
					'type' => 'textarea',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'default_value' => '',
					'acfe_textarea_code' => 0,
					'maxlength' => '',
					'rows' => '',
					'placeholder' => '',
					'new_lines' => '',
					'parent_repeater' => 'field_673286ce1ddb8',
				),
				array(
					'key' => 'field_6732870c1ddbd',
					'label' => 'Transfer Date',
					'name' => 'transfer_date',
					'aria-label' => '',
					'type' => 'date_time_picker',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'display_format' => 'd/m/Y g:i a',
					'return_format' => 'd/m/Y g:i a',
					'first_day' => 1,
					'placeholder' => '',
					'min_date' => '',
					'max_date' => '',
					'min_time' => '',
					'max_time' => '',
					'no_weekends' => 0,
					'min_hour' => '',
					'max_hour' => '',
					'min_min' => '',
					'max_min' => '',
					'min_sec' => '',
					'max_sec' => '',
					'parent_repeater' => 'field_673286ce1ddb8',
				),
			),
		),
		array(
			'key' => 'field_673287191ddbe',
			'label' => 'Transfer History',
			'name' => 'transfer_history',
			'aria-label' => '',
			'type' => 'repeater',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'acfe_repeater_stylised_button' => 0,
			'layout' => 'table',
			'pagination' => 0,
			'min' => 0,
			'max' => 0,
			'collapsed' => '',
			'button_label' => 'Add Row',
			'rows_per_page' => 20,
			'sub_fields' => array(
				array(
					'key' => 'field_673287211ddbf',
					'label' => 'Transfer History Old Assignee',
					'name' => 'transfer_history_old_assignee',
					'aria-label' => '',
					'type' => 'user',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'role' => '',
					'return_format' => 'array',
					'multiple' => 0,
					'max' => '',
					'acfe_bidirectional' => array(
						'acfe_bidirectional_enabled' => '0',
					),
					'allow_null' => 0,
					'bidirectional' => 0,
					'bidirectional_target' => array(
					),
					'min' => '',
					'parent_repeater' => 'field_673287191ddbe',
				),
				array(
					'key' => 'field_6732872c1ddc0',
					'label' => 'Transfer History New Assignee',
					'name' => 'transfer_history_new_assignee',
					'aria-label' => '',
					'type' => 'user',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'role' => '',
					'return_format' => 'array',
					'multiple' => 0,
					'acfe_bidirectional' => array(
						'acfe_bidirectional_enabled' => '0',
					),
					'allow_null' => 0,
					'bidirectional' => 0,
					'bidirectional_target' => array(
					),
					'min' => '',
					'max' => '',
					'parent_repeater' => 'field_673287191ddbe',
				),
				array(
					'key' => 'field_673287351ddc1',
					'label' => 'Transfer History Date',
					'name' => 'transfer_history_date',
					'aria-label' => '',
					'type' => 'date_time_picker',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'display_format' => 'd/m/Y g:i a',
					'return_format' => 'Y-m-d H:i:s',
					'first_day' => 1,
					'placeholder' => '',
					'min_date' => '',
					'max_date' => '',
					'min_time' => '',
					'max_time' => '',
					'no_weekends' => 0,
					'min_hour' => '',
					'max_hour' => '',
					'min_min' => '',
					'max_min' => '',
					'min_sec' => '',
					'max_sec' => '',
					'parent_repeater' => 'field_673287191ddbe',
				),
				array(
					'key' => 'field_673287471ddc2',
					'label' => 'Transfer History Reason for Transfer',
					'name' => 'transfer_history_reason_for_transfer',
					'aria-label' => '',
					'type' => 'textarea',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'default_value' => '',
					'acfe_textarea_code' => 0,
					'maxlength' => '',
					'rows' => '',
					'placeholder' => '',
					'new_lines' => '',
					'parent_repeater' => 'field_673287191ddbe',
				),
				array(
					'key' => 'field_673287621ddc3',
					'label' => 'Transfer History Comments',
					'name' => 'transfer_history_old_assignee',
					'aria-label' => '',
					'type' => 'textarea',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'default_value' => '',
					'acfe_textarea_code' => 0,
					'maxlength' => '',
					'rows' => '',
					'placeholder' => '',
					'new_lines' => '',
					'parent_repeater' => 'field_673287191ddbe',
				),
			),
		),
		array(
			'key' => 'field_6732877850d07',
			'label' => 'Task Attachments',
			'name' => 'task_attachments',
			'aria-label' => '',
			'type' => 'repeater',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'acfe_repeater_stylised_button' => 0,
			'layout' => 'table',
			'pagination' => 0,
			'min' => 0,
			'max' => 0,
			'collapsed' => '',
			'button_label' => 'Add Row',
			'rows_per_page' => 20,
			'sub_fields' => array(
				array(
					'key' => 'field_6732878450d08',
					'label' => 'Task Attachments Template',
					'name' => 'task_attachments_template',
					'aria-label' => '',
					'type' => 'wysiwyg',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'default_value' => '',
					'acfe_wysiwyg_height' => 300,
					'acfe_wysiwyg_max_height' => '',
					'acfe_wysiwyg_valid_elements' => '',
					'acfe_wysiwyg_custom_style' => '',
					'acfe_wysiwyg_disable_wp_style' => 0,
					'acfe_wysiwyg_autoresize' => 0,
					'acfe_wysiwyg_disable_resize' => 0,
					'acfe_wysiwyg_remove_path' => 0,
					'acfe_wysiwyg_menubar' => 0,
					'acfe_wysiwyg_transparent' => 0,
					'acfe_wysiwyg_merge_toolbar' => 0,
					'acfe_wysiwyg_custom_toolbar' => 0,
					'tabs' => 'all',
					'toolbar' => 'full',
					'media_upload' => 1,
					'delay' => 0,
					'acfe_wysiwyg_auto_init' => 0,
					'acfe_wysiwyg_min_height' => 300,
					'acfe_wysiwyg_toolbar_buttons' => array(
					),
					'parent_repeater' => 'field_6732877850d07',
				),
				array(
					'key' => 'field_6732879f50d09',
					'label' => 'Task Attachments File',
					'name' => 'task_attachments_file',
					'aria-label' => '',
					'type' => 'file',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'uploader' => '',
					'return_format' => 'array',
					'upload_folder' => '',
					'multiple' => 0,
					'max' => '',
					'min_size' => '',
					'max_size' => '',
					'mime_types' => '',
					'library' => 'all',
					'preview_style' => 'default',
					'placeholder' => 'Select',
					'button_label' => 'Add File',
					'stylised_button' => 0,
					'file_count' => 0,
					'min' => '',
					'parent_repeater' => 'field_6732877850d07',
				),
				array(
					'key' => 'field_673287c850d0b',
					'label' => 'Task Attachments Text',
					'name' => 'task_attachments_text',
					'aria-label' => '',
					'type' => 'textarea',
					'instructions' => '',
					'required' => 0,
					'conditional_logic' => 0,
					'wrapper' => array(
						'width' => '',
						'class' => '',
						'id' => '',
					),
					'default_value' => '',
					'acfe_textarea_code' => 0,
					'maxlength' => '',
					'rows' => '',
					'placeholder' => '',
					'new_lines' => '',
					'parent_repeater' => 'field_6732877850d07',
				),
			),
		),
		array(
			'key' => 'field_6732883159a8e',
			'label' => 'Task Dependencies',
			'name' => 'task_dependencies',
			'aria-label' => '',
			'type' => 'relationship',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'post_type' => array(
				0 => 'task',
			),
			'post_status' => '',
			'taxonomy' => '',
			'filters' => array(
				0 => 'search',
				1 => 'post_type',
				2 => 'taxonomy',
			),
			'return_format' => 'object',
			'acfe_add_post' => 0,
			'acfe_edit_post' => 0,
			'acfe_bidirectional' => array(
				'acfe_bidirectional_enabled' => '0',
			),
			'min' => '',
			'max' => '',
			'elements' => '',
			'bidirectional' => 0,
			'bidirectional_target' => array(
			),
		),
		array(
			'key' => 'field_6732886059a8f',
			'label' => 'Task Description',
			'name' => 'task_description',
			'aria-label' => '',
			'type' => 'wysiwyg',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'default_value' => '',
			'acfe_wysiwyg_height' => 300,
			'acfe_wysiwyg_max_height' => '',
			'acfe_wysiwyg_valid_elements' => '',
			'acfe_wysiwyg_custom_style' => '',
			'acfe_wysiwyg_disable_wp_style' => 0,
			'acfe_wysiwyg_autoresize' => 0,
			'acfe_wysiwyg_disable_resize' => 0,
			'acfe_wysiwyg_remove_path' => 0,
			'acfe_wysiwyg_menubar' => 0,
			'acfe_wysiwyg_transparent' => 0,
			'acfe_wysiwyg_merge_toolbar' => 0,
			'acfe_wysiwyg_custom_toolbar' => 0,
			'tabs' => 'all',
			'toolbar' => 'full',
			'media_upload' => 1,
			'delay' => 0,
			'acfe_wysiwyg_auto_init' => 0,
			'acfe_wysiwyg_min_height' => 300,
			'acfe_wysiwyg_toolbar_buttons' => array(
			),
		),
		array(
			'key' => 'field_6732886d59a90',
			'label' => 'Task Location',
			'name' => 'task_location',
			'aria-label' => '',
			'type' => 'text',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'default_value' => '',
			'maxlength' => '',
			'placeholder' => '',
			'prepend' => '',
			'append' => '',
		),
		array(
			'key' => 'field_6732887859a91',
			'label' => 'Custom Task Fields',
			'name' => 'custom_task_fields',
			'aria-label' => '',
			'type' => 'flexible_content',
			'instructions' => '',
			'required' => 0,
			'conditional_logic' => 0,
			'wrapper' => array(
				'width' => '',
				'class' => '',
				'id' => '',
			),
			'acfe_flexible_advanced' => 0,
			'layouts' => array(
				'layout_6732887c6ef6b' => array(
					'key' => 'layout_6732887c6ef6b',
					'name' => '',
					'label' => '',
					'display' => 'block',
					'sub_fields' => array(
					),
					'min' => '',
					'max' => '',
					'acfe_flexible_render_template' => false,
					'acfe_flexible_render_style' => false,
					'acfe_flexible_render_script' => false,
					'acfe_flexible_thumbnail' => false,
					'acfe_flexible_settings' => false,
					'acfe_flexible_settings_size' => 'medium',
					'acfe_layout_locations' => array(
					),
					'acfe_flexible_modal_edit_size' => false,
					'acfe_flexible_category' => false,
					'acfe_layout_col' => 'auto',
					'acfe_layout_allowed_col' => false,
				),
			),
			'min' => '',
			'max' => '',
			'button_label' => 'Add Row',
			'acfe_flexible_stylised_button' => false,
			'acfe_flexible_hide_empty_message' => false,
			'acfe_flexible_empty_message' => '',
			'acfe_flexible_layouts_templates' => false,
			'acfe_flexible_layouts_previews' => false,
			'acfe_flexible_layouts_placeholder' => false,
			'acfe_flexible_layouts_thumbnails' => false,
			'acfe_flexible_layouts_settings' => false,
			'acfe_flexible_layouts_locations' => false,
			'acfe_flexible_async' => array(
			),
			'acfe_flexible_add_actions' => array(
			),
			'acfe_flexible_remove_button' => array(
			),
			'acfe_flexible_layouts_state' => false,
			'acfe_flexible_modal_edit' => array(
				'acfe_flexible_modal_edit_enabled' => false,
				'acfe_flexible_modal_edit_size' => 'large',
			),
			'acfe_flexible_modal' => array(
				'acfe_flexible_modal_enabled' => false,
				'acfe_flexible_modal_title' => false,
				'acfe_flexible_modal_size' => 'full',
				'acfe_flexible_modal_col' => '4',
				'acfe_flexible_modal_categories' => false,
			),
			'acfe_flexible_grid' => array(
				'acfe_flexible_grid_enabled' => false,
				'acfe_flexible_grid_align' => 'center',
				'acfe_flexible_grid_valign' => 'stretch',
				'acfe_flexible_grid_wrap' => false,
			),
			'acfe_flexible_grid_container' => false,
		),
	),
	'location' => array(
		array(
			array(
				'param' => 'post_type',
				'operator' => '==',
				'value' => 'task',
			),
		),
	),
	'menu_order' => 0,
	'position' => 'normal',
	'style' => 'default',
	'label_placement' => 'left',
	'instruction_placement' => 'label',
	'hide_on_screen' => '',
	'active' => true,
	'description' => '',
	'show_in_rest' => 0,
	'acfe_autosync' => array(
		0 => 'php',
		1 => 'json',
	),
	'acfe_form' => 0,
	'acfe_display_title' => '',
	'acfe_meta' => '',
	'acfe_note' => '',
) );
} );

add_action( 'init', function() {
	register_post_type( 'task', array(
	'labels' => array(
		'name' => 'Tasks',
		'singular_name' => 'Task',
		'menu_name' => 'Tasks',
		'all_items' => 'All Tasks',
		'edit_item' => 'Edit Task',
		'view_item' => 'View Task',
		'view_items' => 'View Tasks',
		'add_new_item' => 'Add New Task',
		'add_new' => 'Add New Task',
		'new_item' => 'New Task',
		'parent_item_colon' => 'Parent Task:',
		'search_items' => 'Search Tasks',
		'not_found' => 'No tasks found',
		'not_found_in_trash' => 'No tasks found in Trash',
		'archives' => 'Task Archives',
		'attributes' => 'Task Attributes',
		'insert_into_item' => 'Insert into task',
		'uploaded_to_this_item' => 'Uploaded to this task',
		'filter_items_list' => 'Filter tasks list',
		'filter_by_date' => 'Filter tasks by date',
		'items_list_navigation' => 'Tasks list navigation',
		'items_list' => 'Tasks list',
		'item_published' => 'Task published.',
		'item_published_privately' => 'Task published privately.',
		'item_reverted_to_draft' => 'Task reverted to draft.',
		'item_scheduled' => 'Task scheduled.',
		'item_updated' => 'Task updated.',
		'item_link' => 'Task Link',
		'item_link_description' => 'A link to a task.',
	),
	'public' => false,
	'exclude_from_search' => false,
	'publicly_queryable' => true,
	'show_ui' => true,
	'show_in_nav_menus' => true,
	'show_in_rest' => true,
	'menu_icon' => 'dashicons-edit-page',
	'supports' => array(
		0 => 'title',
		1 => 'editor',
		2 => 'thumbnail',
		3 => 'custom-fields',
	),
	'taxonomies' => array(
		0 => 'category',
		1 => 'post_tag',
	),
	'delete_with_user' => false,
) );
} );

######################## 

<?php
/**
 * Plugin Name: Taskly Dashboard Pro
 * Description: An advanced dashboard for managing tasks with real-time filtering, pagination, and dynamic notifications.
 * Version: 1.1
 * Author: Your Name
 * Text Domain: taskly-dashboard-pro
 */

if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly.
}

class Taskly_Dashboard_Pro {

    private $nonce_action = 'taskly_dashboard_pro_nonce_action';
    private $nonce_name = 'taskly_dashboard_pro_nonce';

    public function __construct() {
        // Register shortcode
        add_shortcode('taskly_dashboard', array($this, 'render_dashboard'));

        // Enqueue scripts and styles
        add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));

        // AJAX handlers
        add_action('wp_ajax_taskly_fetch_tasks', array($this, 'fetch_tasks'));
        add_action('wp_ajax_nopriv_taskly_fetch_tasks', array($this, 'fetch_tasks'));
    }

    /**
     * Enqueue and embed all necessary CSS and JS.
     */
    public function enqueue_scripts() {
        // Register and enqueue inline Bootstrap CSS
        wp_register_style('taskly-bootstrap-css', false);
        wp_enqueue_style('taskly-bootstrap-css');
        wp_add_inline_style('taskly-bootstrap-css', $this->get_bootstrap_css());

        // Register and enqueue inline Bootstrap Icons CSS
        wp_register_style('taskly-bootstrap-icons-css', false);
        wp_enqueue_style('taskly-bootstrap-icons-css');
        wp_add_inline_style('taskly-bootstrap-icons-css', $this->get_bootstrap_icons_css());

        // Register and enqueue inline Select2 CSS
        wp_register_style('taskly-select2-css', false);
        wp_enqueue_style('taskly-select2-css');
        wp_add_inline_style('taskly-select2-css', $this->get_select2_css());

        // Register and enqueue inline Date Range Picker CSS
        wp_register_style('taskly-daterangepicker-css', false);
        wp_enqueue_style('taskly-daterangepicker-css');
        wp_add_inline_style('taskly-daterangepicker-css', $this->get_daterangepicker_css());

        // Register and enqueue inline Custom CSS
        wp_register_style('taskly-custom-css', false);
        wp_enqueue_style('taskly-custom-css');
        wp_add_inline_style('taskly-custom-css', $this->get_custom_css());

        // Enqueue jQuery
        wp_enqueue_script('jquery');

        // Register and enqueue inline Bootstrap JS
        wp_register_script('taskly-bootstrap-js', '', [], false, true);
        wp_enqueue_script('taskly-bootstrap-js');
        wp_add_inline_script('taskly-bootstrap-js', $this->get_bootstrap_js());

        // Register and enqueue inline Select2 JS
        wp_register_script('taskly-select2-js', '', [], false, true);
        wp_enqueue_script('taskly-select2-js');
        wp_add_inline_script('taskly-select2-js', $this->get_select2_js());

        // Register and enqueue inline Moment.js
        wp_register_script('taskly-moment-js', '', [], false, true);
        wp_enqueue_script('taskly-moment-js');
        wp_add_inline_script('taskly-moment-js', $this->get_moment_js());

        // Register and enqueue inline Date Range Picker JS
        wp_register_script('taskly-daterangepicker-js', '', [], false, true);
        wp_enqueue_script('taskly-daterangepicker-js');
        wp_add_inline_script('taskly-daterangepicker-js', $this->get_daterangepicker_js());

        // Register and enqueue inline Custom JS
        wp_register_script('taskly-custom-js', '', [], false, true);
        wp_enqueue_script('taskly-custom-js');
        wp_add_inline_script('taskly-custom-js', $this->get_custom_js());

        // Localize script for AJAX
        wp_localize_script('taskly-custom-js', 'taskly_ajax_obj', array(
            'ajax_url' => admin_url('admin-ajax.php'),
            'nonce' => wp_create_nonce($this->nonce_action),
        ));
    }

    /**
     * Render the dashboard via shortcode.
     */
    public function render_dashboard() {
        ob_start();
        ?>
        <div class="tskr-app container-fluid mt-4">
            <div class="row mb-4">
                <div class="col-12">
                    <div class="d-flex search-clear-container">
                        <div class="tskr-search-bar flex-grow-1">
                            <input type="text" class="form-control" placeholder="Search Tasks..." id="tskrSearch">
                        </div>
                        <button class="btn tskr-primary btn-clear-filters" id="tskrClearFilters"><i class="bi bi-x-circle"></i> Clear</button>
                    </div>
                </div>
            </div>
            <div class="row mb-4">
                <div class="col-12">
                    <div class="tskr-filter-section">
                        <!-- Assignee Filter -->
                        <div class="dropdown">
                            <button class="btn btn-secondary dropdown-toggle tskr-filter-btn" type="button" id="assigneeFilter" data-bs-toggle="dropdown" aria-expanded="false">
                                Assignee
                            </button>
                            <ul class="dropdown-menu p-3" aria-labelledby="assigneeFilter">
                                <select class="form-select tskr-assignee-select" multiple>
                                    <?php
                                    $users = get_users(array('orderby' => 'display_name', 'fields' => array('display_name')));
                                    foreach ($users as $user) {
                                        echo '<option value="' . esc_attr($user->display_name) . '">' . esc_html($user->display_name) . '</option>';
                                    }
                                    ?>
                                </select>
                            </ul>
                        </div>
                        <!-- Task Type Filter -->
                        <div class="dropdown">
                            <button class="btn btn-secondary dropdown-toggle tskr-filter-btn" type="button" id="taskTypeFilter" data-bs-toggle="dropdown" aria-expanded="false">
                                Task Type
                            </button>
                            <ul class="dropdown-menu p-3" aria-labelledby="taskTypeFilter">
                                <select class="form-select tskr-tasktype-select" multiple>
                                    <?php
                                    $task_types = get_field_object('task_type')['choices'];
                                    foreach ($task_types as $value) {
                                        echo '<option value="' . esc_attr($value) . '">' . esc_html($value) . '</option>';
                                    }
                                    ?>
                                </select>
                            </ul>
                        </div>
                        <!-- Due Date Filter -->
                        <div class="dropdown">
                            <button class="btn btn-secondary dropdown-toggle tskr-filter-btn" type="button" id="dueDateFilter" data-bs-toggle="dropdown" aria-expanded="false">
                                Due Date
                            </button>
                            <ul class="dropdown-menu p-3" aria-labelledby="dueDateFilter">
                                <button class="btn btn-outline-primary btn-sm me-2 mb-2 tskr-date-range-btn" data-range="7">Last 7 Days</button>
                                <button class="btn btn-outline-primary btn-sm me-2 mb-2 tskr-date-range-btn" data-range="14">Last 14 Days</button>
                                <button class="btn btn-outline-primary btn-sm me-2 mb-2 tskr-date-range-btn" data-range="31">Last 31 Days</button>
                                <button class="btn btn-outline-primary btn-sm me-2 mb-2 tskr-date-range-btn" data-range="1-month">Last 1 Month</button>
                                <button class="btn btn-outline-primary btn-sm me-2 mb-2 tskr-date-range-btn" data-range="2-month">Last 2 Months</button>
                                <button class="btn btn-outline-primary btn-sm me-2 mb-2 tskr-date-range-btn" data-range="3-month">Last 3 Months</button>
                                <hr>
                                <input type="text" class="form-control" id="customDateRange" placeholder="Custom Range">
                            </ul>
                        </div>
                        <!-- Priority Filter -->
                        <div class="dropdown">
                            <button class="btn btn-secondary dropdown-toggle tskr-filter-btn" type="button" id="priorityFilter" data-bs-toggle="dropdown" aria-expanded="false">
                                Priority
                            </button>
                            <ul class="dropdown-menu p-3" aria-labelledby="priorityFilter">
                                <select class="form-select tskr-priority-select" multiple>
                                    <?php
                                    $priorities = get_field_object('priority')['choices'];
                                    foreach ($priorities as $value) {
                                        echo '<option value="' . esc_attr($value) . '">' . esc_html($value) . '</option>';
                                    }
                                    ?>
                                </select>
                            </ul>
                        </div>
                        <!-- Task Status Filter -->
                        <div class="dropdown">
                            <button class="btn btn-secondary dropdown-toggle tskr-filter-btn" type="button" id="taskStatusFilter" data-bs-toggle="dropdown" aria-expanded="false">
                                Task Status
                            </button>
                            <ul class="dropdown-menu p-3" aria-labelledby="taskStatusFilter">
                                <select class="form-select tskr-taskstatus-select" multiple>
                                    <?php
                                    $statuses = get_field_object('task_status')['choices'];
                                    foreach ($statuses as $value) {
                                        echo '<option value="' . esc_attr($value) . '">' . esc_html($value) . '</option>';
                                    }
                                    ?>
                                </select>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Tabs -->
            <div class="row">
                <div class="col-12">
                    <ul class="nav nav-tabs mb-3 nav-fill" id="tskrTab" role="tablist">
                        <!-- Dynamically generate tabs -->
                        <?php
                        $tabs = array(
                            'all' => 'All',
                            'due-today' => 'Due Today',
                            'overdue' => 'Overdue',
                            'upcoming' => 'Upcoming',
                            'completed' => 'Completed',
                            'notifications' => 'Notifications',
                        );

                        foreach ($tabs as $tab_id => $tab_name) {
                            $active = ($tab_id === 'all') ? 'active' : '';
                            echo '<li class="nav-item" role="presentation">
                                    <button class="nav-link ' . esc_attr($active) . ' tskr-tab-button" id="' . esc_attr($tab_id) . '-tab" data-bs-toggle="tab" data-bs-target="#' . esc_attr($tab_id) . '" type="button" role="tab" aria-controls="' . esc_attr($tab_id) . '" aria-selected="' . ($active ? 'true' : 'false') . '">
                                        ' . esc_html($tab_name) . ' <span class="badge" id="' . esc_attr($tab_id) . 'Count">0</span>
                                    </button>
                                  </li>';
                        }
                        ?>
                    </ul>
                    <div class="tab-content" id="tskrTabContent">
                        <!-- Dynamically generate tab panes -->
                        <?php
                        foreach ($tabs as $tab_id => $tab_name) {
                            $active = ($tab_id === 'all') ? 'show active' : 'fade';
                            // Define table headers based on tab
                            if ($tab_id === 'notifications') {
                                $headers = array(
                                    'select' => '',
                                    'notification_type' => 'Notification Type',
                                    'message' => 'Message',
                                    'recipient' => 'Recipient',
                                    'status' => 'Status',
                                    'sent_date' => 'Sent Date',
                                    'action' => 'Action',
                                );
                            } else {
                                $headers = array(
                                    'select' => '',
                                    'status' => 'Status',
                                    'title' => 'Title',
                                    'associated_contact' => 'Associated Contact',
                                    'associated_company' => 'Associated Company',
                                    'last_contacted' => 'Last Contacted',
                                    'last_engagement' => 'Last Engagement',
                                    'task_type' => 'Task Type',
                                    'due_date' => 'Due Date',
                                );
                            }
                            
                            echo '<div class="tab-pane ' . esc_attr($active) . '" id="' . esc_attr($tab_id) . '" role="tabpanel" aria-labelledby="' . esc_attr($tab_id) . '-tab">
                                    <div class="table-responsive">
                                        <table class="table table-bordered tskr-table" data-tab="' . esc_attr($tab_id) . '">
                                            <thead class="tskr-primary text-white">
                                                <tr>';
                            foreach ($headers as $key => $label) {
                                echo '<th scope="col" class="select-header">';
                                if ($key === 'select') {
                                    echo '<input type="checkbox" id="selectAll_' . esc_attr($tab_id) . '">';
                                } else {
                                    echo esc_html($label);
                                }
                                echo '</th>';
                            }
                            echo '</tr>
                                            </thead>
                                            <tbody>
                                                <!-- Task rows will be populated via AJAX -->
                                                <tr class="empty-row"><td colspan="' . count($headers) . '" class="text-center">Empty Right Now, Import or Create Some Tasks</td></tr>
                                            </tbody>
                                        </table>
                                    </div>
                                    <nav aria-label="Page navigation example">
                                        <ul class="pagination tskr-pagination"></ul>
                                    </nav>
                                  </div>';
                        }
                        ?>
                    </div>
                </div>
            </div>
        </div>

        <!-- Scripts -->
        <script>
            jQuery(document).ready(function($) {
                // Initialize Select2
                $('.tskr-assignee-select, .tskr-tasktype-select, .tskr-priority-select, .tskr-taskstatus-select').select2({
                    placeholder: 'Select options',
                    width: '100%'
                });

                // Initialize Date Range Picker
                $('#customDateRange').daterangepicker({
                    opens: 'left',
                    locale: {
                        format: 'YYYY-MM-DD'
                    },
                    autoUpdateInput: false
                }, function(start, end) {
                    $('#customDateRange').val(start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));
                    fetchTasks($('.tskr-tab-button.active').attr('id').split('-tab')[0]);
                });

                $('.tskr-date-range-btn').on('click', function(e) {
                    e.preventDefault();
                    var range = $(this).data('range');
                    var start, end;
                    var today = moment();

                    switch(range) {
                        case '7':
                            start = moment().subtract(6, 'days');
                            end = today;
                            break;
                        case '14':
                            start = moment().subtract(13, 'days');
                            end = today;
                            break;
                        case '31':
                            start = moment().subtract(30, 'days');
                            end = today;
                            break;
                        case '1-month':
                            start = moment().subtract(1, 'months');
                            end = today;
                            break;
                        case '2-month':
                            start = moment().subtract(2, 'months');
                            end = today;
                            break;
                        case '3-month':
                            start = moment().subtract(3, 'months');
                            end = today;
                            break;
                        default:
                            start = null;
                            end = null;
                    }

                    if(start && end){
                        $('#customDateRange').data('daterangepicker').setStartDate(start);
                        $('#customDateRange').data('daterangepicker').setEndDate(end);
                        $('#customDateRange').val(start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));
                        fetchTasks($('.tskr-tab-button.active').attr('id').split('-tab')[0]);
                    }
                });

                $('#tskrClearFilters').on('click', function() {
                    $('#tskrSearch').val('');
                    $('.select2').val(null).trigger('change');
                    $('#customDateRange').val('');
                    $('input[type="checkbox"]').prop('checked', false);
                    $('#customDateRange').data('daterangepicker').setStartDate(moment());
                    $('#customDateRange').data('daterangepicker').setEndDate(moment());
                    $('.tskr-tab-button#all-tab').tab('show');
                    fetchTasks('all');
                });

                // Handle row clicks
                $('.tskr-app').on('click', '.tskr-table tbody tr', function(e) {
                    if($(e.target).is('input[type="checkbox"]') || $(e.target).closest('a').length > 0){
                        return;
                    }
                    var link = $(this).find('a').attr('href');
                    if(link){
                        window.location.href = link;
                    }
                });

                // Handle checkbox selection
                $('.tskr-app').on('change', 'input[id^="selectAll_"]', function() {
                    var tab = $(this).attr('id').split('_')[1];
                    $('table[data-tab="' + tab + '"] tbody input[type="checkbox"]').prop('checked', this.checked);
                });

                // Fetch tasks on filter change
                $('#tskrSearch, .tskr-assignee-select, .tskr-tasktype-select, .tskr-priority-select, .tskr-taskstatus-select').on('change keyup', function() {
                    fetchTasks($('.tskr-tab-button.active').attr('id').split('-tab')[0]);
                });

                let debounceTimer;
                $('#tskrSearch').on('keyup', function() {
                    clearTimeout(debounceTimer);
                    debounceTimer = setTimeout(function() {
                        fetchTasks($('.tskr-tab-button.active').attr('id').split('-tab')[0]);
                    }, 300);
                });

                // Handle tab clicks
                $('.tskr-tab-button').on('click', function() {
                    var tab = $(this).attr('id').split('-tab')[0];
                    fetchTasks(tab);
                });

                // Fetch tasks function
                function fetchTasks(tab = 'all', page = 1) {
                    var search = $('#tskrSearch').val();
                    var assignees = $('.tskr-assignee-select').val();
                    var task_types = $('.tskr-tasktype-select').val();
                    var priorities = $('.tskr-priority-select').val();
                    var task_statuses = $('.tskr-taskstatus-select').val();
                    var date_range = $('#customDateRange').val();

                    $.ajax({
                        url: taskly_ajax_obj.ajax_url,
                        type: 'POST',
                        dataType: 'json',
                        data: {
                            action: 'taskly_fetch_tasks',
                            nonce: taskly_ajax_obj.nonce,
                            search: search,
                            assignees: assignees,
                            task_types: task_types,
                            priorities: priorities,
                            task_statuses: task_statuses,
                            date_range: date_range,
                            tab: tab,
                            page: page
                        },
                        beforeSend: function() {
                            $('.tskr-app').find('.update-notification').remove();
                            $('.tskr-app').prepend('<div class="update-notification alert alert-info" role="alert">Updating...</div>');
                        },
                        success: function(response) {
                            if(response.success) {
                                updateTable(tab, response.data.tasks);
                                updateCounts(response.data.counts);
                                setupPagination(tab, response.data.total_pages);
                                $('.tskr-app').find('.update-notification').remove();
                            } else {
                                $('.tskr-app').find('.update-notification').remove();
                                $('.tskr-app').prepend('<div class="update-notification alert alert-warning" role="alert">Failed to update tasks.</div>');
                            }
                        },
                        error: function() {
                            $('.tskr-app').find('.update-notification').remove();
                            $('.tskr-app').prepend('<div class="update-notification alert alert-danger" role="alert">An error occurred while updating tasks.</div>');
                        }
                    });
                }

                // Update table with fetched tasks
                function updateTable(tab, tasks) {
                    var tbody = $('table[data-tab="' + tab + '"] tbody');
                    tbody.empty();
                    if(tasks.length > 0) {
                        tasks.forEach(function(task) {
                            var status_class = getStatusClass(task.status);
                            var row = '';
                            if(tab === 'notifications'){
                                // Define table structure for Notifications tab
                                row = '<tr>' +
                                    '<td class="select-column"><input type="checkbox" class="tskr-checkbox"></td>' +
                                    '<td data-label="Notification Type">' + (task.notification_type ? task.notification_type : 'N/A') + '</td>' +
                                    '<td data-label="Message">' + (task.message ? task.message : 'N/A') + '</td>' +
                                    '<td data-label="Recipient">' + (task.recipient ? task.recipient : 'N/A') + '</td>' +
                                    '<td data-label="Status"><span class="tskr-badge ' + status_class + '">' + capitalizeFirstLetter(task.status) + '</span></td>' +
                                    '<td data-label="Sent Date">' + (task.sent_date ? task.sent_date : 'N/A') + '</td>' +
                                    '<td data-label="Action">' + (task.action ? task.action : 'N/A') + '</td>' +
                                    '</tr>';
                            } else {
                                // Define table structure for Task tabs
                                row = '<tr>' +
                                    '<td class="select-column"><input type="checkbox" class="tskr-checkbox"></td>' +
                                    '<td data-label="Status"><span class="tskr-badge ' + status_class + '">' + capitalizeFirstLetter(task.status) + '</span></td>' +
                                    '<td data-label="Title"><a href="' + task.permalink + '">' + task.title + '</a></td>' +
                                    '<td data-label="Associated Contact">' + (task.associated_contact ? task.associated_contact : 'N/A') + '</td>' +
                                    '<td data-label="Associated Company">' + (task.associated_company ? task.associated_company : 'N/A') + '</td>' +
                                    '<td data-label="Last Contacted">' + (task.last_contacted ? task.last_contacted : 'N/A') + '</td>' +
                                    '<td data-label="Last Engagement">' + (task.last_engagement ? task.last_engagement : 'N/A') + '</td>' +
                                    '<td data-label="Task Type">' + (task.task_type ? task.task_type : 'N/A') + '</td>' +
                                    '<td data-label="Due Date">' + (task.due_date ? task.due_date : 'N/A') + '</td>' +
                                    '</tr>';
                            }
                            tbody.append(row);
                        });

                        // Bind row click again after AJAX
                        $('.tskr-app .tskr-table tbody tr').on('click', function(e) {
                            if($(e.target).is('input[type="checkbox"]') || $(e.target).closest('a').length > 0){
                                e.stopPropagation();
                                return;
                            }
                            var link = $(this).find('a').attr('href');
                            if(link){
                                window.location.href = link;
                            }
                        });
                    } else {
                        var message = (tab === 'all') ? 'No tasks found.' : 'Empty Right Now, Import or Create Some Tasks';
                        var colspan = (tab === 'notifications') ? 7 : 9;
                        var noDataRow = '<tr><td colspan="' + colspan + '" class="text-center">' + message + '</td></tr>';
                        tbody.append(noDataRow);
                    }
                }

                // Update counts
                function updateCounts(counts) {
                    for(var key in counts) {
                        if(counts.hasOwnProperty(key)){
                            var badgeCount = counts[key];
                            $('#' + key + 'Count').text(badgeCount > 0 ? badgeCount : '-');
                            var badge = $('#' + key + 'Count');
                            if(badgeCount > 0){
                                badge.addClass('has-count');
                            } else {
                                badge.removeClass('has-count');
                            }
                        }
                    }
                }

                // Setup pagination
                function setupPagination(tab, total_pages) {
                    var pagination = $('table[data-tab="' + tab + '"]').closest('.tab-pane').find('.tskr-pagination');
                    pagination.empty();

                    if(total_pages > 1){
                        // Previous Button
                        var prevPage = (currentPage > 1) ? currentPage - 1 : 1;
                        pagination.append('<li class="page-item"><a class="page-link tskr-primary" href="#" data-page="' + prevPage + '">Previous</a></li>');

                        // Page Numbers
                        for(var i=1; i<=total_pages; i++) {
                            var activeClass = (i === 1) ? 'active' : '';
                            pagination.append('<li class="page-item ' + activeClass + '"><a class="page-link" href="#" data-page="' + i + '">' + i + '</a></li>');
                        }

                        // Next Button
                        var nextPage = (currentPage < total_pages) ? currentPage + 1 : total_pages;
                        pagination.append('<li class="page-item"><a class="page-link tskr-primary" href="#" data-page="' + nextPage + '">Next</a></li>');
                    }
                }

                // Handle pagination clicks
                $('.tskr-app').on('click', '.tskr-pagination .page-link', function(e) {
                    e.preventDefault();
                    var page = parseInt($(this).data('page'));
                    var tab = $(this).closest('.tab-pane').find('table').data('tab');
                    fetchTasks(tab, page);
                });

                // Utility Functions
                function capitalizeFirstLetter(string) {
                    return string.charAt(0).toUpperCase() + string.slice(1);
                }

                function getStatusClass(status) {
                    switch(status) {
                        case 'assigned':
                            return 'assigned';
                        case 'completed':
                            return 'completed';
                        case 'in progress':
                            return 'in-progress';
                        case 'not started':
                            return 'not-started';
                        case 'overdue':
                            return 'overdue';
                        case 'due today':
                            return 'due-today';
                        case 'upcoming':
                            return 'upcoming';
                        case 'waiting':
                            return 'waiting';
                        case 'on hold':
                            return 'on-hold';
                        case 'cancelled':
                            return 'cancelled';
                        case 'transferred':
                            return 'transferred';
                        case 'sent':
                            return 'completed'; // For notifications status
                        case 'pending':
                            return 'in-progress'; // For notifications status
                        default:
                            return '';
                    }
                }

                // Start Sync Timer
                function startTaskSyncTimer() {
                    setInterval(function() {
                        fetchTasks($('.tskr-tab-button.active').attr('id').split('-tab')[0]);
                        $('.tskr-app').find('.update-notification').remove();
                        $('.tskr-app').prepend('<div class="update-notification alert alert-info" role="alert">Updating...</div>');
                        setTimeout(function() {
                            $('.tskr-app').find('.update-notification').remove();
                        }, 3000);
                    }, 30000);
                }

                // Initial fetch
                fetchTasks('all');

                // Start the sync timer
                startTaskSyncTimer();
            });
        </script>
        <?php
        return ob_get_clean();
    }

    /**
     * Fetch tasks via AJAX based on filters and pagination.
     */
    public function fetch_tasks() {
        check_ajax_referer($this->nonce_action, 'nonce');

        // Get parameters
        $search = isset($_POST['search']) ? sanitize_text_field($_POST['search']) : '';
        $assignees = isset($_POST['assignees']) ? array_map('sanitize_text_field', $_POST['assignees']) : array();
        $task_types = isset($_POST['task_types']) ? array_map('sanitize_text_field', $_POST['task_types']) : array();
        $priorities = isset($_POST['priorities']) ? array_map('sanitize_text_field', $_POST['priorities']) : array();
        $task_statuses = isset($_POST['task_statuses']) ? array_map('sanitize_text_field', $_POST['task_statuses']) : array();
        $date_range = isset($_POST['date_range']) ? sanitize_text_field($_POST['date_range']) : '';
        $tab = isset($_POST['tab']) ? sanitize_text_field($_POST['tab']) : 'all';
        $page = isset($_POST['page']) ? intval($_POST['page']) : 1;

        // Prepare meta queries
        $meta_query = array('relation' => 'AND');

        if (!empty($search)) {
            $meta_query[] = array(
                'relation' => 'OR',
                array(
                    'key' => 'task_description',
                    'value' => $search,
                    'compare' => 'LIKE',
                ),
                array(
                    'key' => 'task_location',
                    'value' => $search,
                    'compare' => 'LIKE',
                ),
                array(
                    'key' => 'task_tag',
                    'value' => $search,
                    'compare' => 'LIKE',
                ),
                array(
                    'key' => 'task_title',
                    'value' => $search,
                    'compare' => 'LIKE',
                ),
            );
        }

        if (!empty($assignees)) {
            $meta_query[] = array(
                'key' => 'assignee',
                'value' => $assignees,
                'compare' => 'IN',
            );
        }

        if (!empty($task_types)) {
            $meta_query[] = array(
                'key' => 'task_type',
                'value' => $task_types,
                'compare' => 'IN',
            );
        }

        if (!empty($priorities)) {
            $meta_query[] = array(
                'key' => 'priority',
                'value' => $priorities,
                'compare' => 'IN',
            );
        }

        if (!empty($task_statuses)) {
            if (!in_array('all', array_map('strtolower', $task_statuses))) {
                $meta_query[] = array(
                    'key' => 'task_status',
                    'value' => $task_statuses,
                    'compare' => 'IN',
                );
            }
        }

        if (!empty($date_range)) {
            if ($tab !== 'notifications') { // Assuming date range is for task due dates
                $dates = explode(' to ', $date_range);
                if (count($dates) === 2) {
                    $meta_query[] = array(
                        'key' => 'due_date_or_time',
                        'value' => array($dates[0] . ' 00:00:00', $dates[1] . ' 23:59:59'),
                        'type' => 'DATETIME',
                        'compare' => 'BETWEEN',
                    );
                }
            }
        }

        // Additional tab-specific queries
        if ($tab === 'notifications') {
            // Fetch tasks with reminders or specific notification flags
            $meta_query[] = array(
                'key' => 'reminder_notification',
                'value' => array('Email', 'SMS'), // Adjust based on actual notification types
                'compare' => 'IN',
            );
        } else {
            switch ($tab) {
                case 'due-today':
                    $today = date('Y-m-d');
                    $meta_query[] = array(
                        'key' => 'due_date_or_time',
                        'value' => array($today . ' 00:00:00', $today . ' 23:59:59'),
                        'type' => 'DATETIME',
                        'compare' => 'BETWEEN',
                    );
                    break;
                case 'overdue':
                    $today = date('Y-m-d');
                    $meta_query[] = array(
                        'key' => 'due_date_or_time',
                        'value' => $today . ' 23:59:59',
                        'type' => 'DATETIME',
                        'compare' => '<',
                    );
                    $meta_query[] = array(
                        'key' => 'task_status',
                        'value' => 'Completed',
                        'compare' => '!=',
                    );
                    break;
                case 'upcoming':
                    $future = date('Y-m-d', strtotime('+30 days'));
                    $meta_query[] = array(
                        'key' => 'due_date_or_time',
                        'value' => array($future . ' 00:00:00', '2100-01-01 00:00:00'),
                        'type' => 'DATETIME',
                        'compare' => 'BETWEEN',
                    );
                    break;
                case 'completed':
                    $meta_query[] = array(
                        'key' => 'task_status',
                        'value' => 'Completed',
                        'compare' => '=',
                    );
                    break;
            }
        }

        // Ensure tasks have a title
        $meta_query[] = array(
            'key' => 'task_title',
            'value' => '',
            'compare' => '!=',
        );

        // WP_Query arguments
        $args = array(
            'post_type' => 'task',
            'posts_per_page' => 10,
            'paged' => $page,
            'meta_query' => $meta_query,
        );

        // Execute query
        $query = new WP_Query($args);

        // Prepare response
        $tasks = array();
        if ($query->have_posts()) {
            while ($query->have_posts()) {
                $query->the_post();
                $task_id = get_the_ID();
                $status = strtolower(get_field('task_status', $task_id));
                $task_title = get_field('task_title', $task_id);
                if (!$task_title) {
                    continue; // Skip tasks without a title
                }
                $tasks[] = array(
                    'ID' => $task_id,
                    'status' => $status,
                    'title' => $task_title,
                    'permalink' => get_permalink(),
                    'associated_contact' => $this->get_associated_users('associated_contact', $task_id),
                    'associated_company' => $this->get_associated_users('associated_company', $task_id),
                    'last_contacted' => $this->format_datetime(get_field('last_contacted', $task_id)),
                    'last_engagement' => $this->format_datetime(get_field('last_engagement', $task_id)),
                    'task_type' => get_field('task_type', $task_id),
                    'due_date' => $this->format_datetime(get_field('due_date_or_time', $task_id), 'date'),
                    // Additional fields for notifications
                    'notification_type' => get_field('reminder_notification', $task_id),
                    'message' => get_field('reminder_email', $task_id), // Assuming this is the message field
                    'recipient' => $this->get_associated_users('assigned_user_transfer', $task_id), // Adjust based on actual ACF
                    'sent_date' => $this->format_datetime(get_field('sent_date', $task_id), 'date'), // Adjust based on actual ACF
                    'action' => '<a href="' . get_permalink($task_id) . '">View</a>', // Action link
                );
            }
            wp_reset_postdata();
        }

        // Get total pages
        $total_pages = $query->max_num_pages;

        // Get badge counts
        $counts = $this->get_badge_counts();

        // Default to 'all' tab if no tasks and not already on 'all'
        if (empty($tasks) && $tab !== 'all') {
            $args['meta_query'] = array_merge($meta_query, array(
                array(
                    'key' => 'task_title',
                    'value' => '',
                    'compare' => '!=',
                ),
            ));
            $args['meta_query'][0]['relation'] = 'AND';
            $args['meta_query'] = array('relation' => 'AND', $args['meta_query'][0]);

            $all_query = new WP_Query($args);
            if ($all_query->have_posts()) {
                $tasks = array();
                while ($all_query->have_posts()) {
                    $all_query->the_post();
                    $task_id = get_the_ID();
                    $status = strtolower(get_field('task_status', $task_id));
                    $task_title = get_field('task_title', $task_id);
                    if (!$task_title) {
                        continue; // Skip tasks without a title
                    }
                    $tasks[] = array(
                        'ID' => $task_id,
                        'status' => $status,
                        'title' => $task_title,
                        'permalink' => get_permalink(),
                        'associated_contact' => $this->get_associated_users('associated_contact', $task_id),
                        'associated_company' => $this->get_associated_users('associated_company', $task_id),
                        'last_contacted' => $this->format_datetime(get_field('last_contacted', $task_id)),
                        'last_engagement' => $this->format_datetime(get_field('last_engagement', $task_id)),
                        'task_type' => get_field('task_type', $task_id),
                        'due_date' => $this->format_datetime(get_field('due_date_or_time', $task_id), 'date'),
                        // Additional fields for notifications
                        'notification_type' => get_field('reminder_notification', $task_id),
                        'message' => get_field('reminder_email', $task_id), // Assuming this is the message field
                        'recipient' => $this->get_associated_users('assigned_user_transfer', $task_id), // Adjust based on actual ACF
                        'sent_date' => $this->format_datetime(get_field('sent_date', $task_id), 'date'), // Adjust based on actual ACF
                        'action' => '<a href="' . get_permalink($task_id) . '">View</a>', // Action link
                    );
                }
                wp_reset_postdata();
                if (!empty($tasks)) {
                    $tab = 'all';
                    $total_pages = $all_query->max_num_pages;
                }
            }
        }

        // Send response
        wp_send_json_success(array(
            'tasks' => $tasks,
            'total_pages' => $total_pages,
            'counts' => $counts,
        ));
    }

    /**
     * Helper function to get associated user names.
     */
    private function get_associated_users($field_name, $task_id) {
        $users = get_field($field_name, $task_id);
        if (is_array($users)) {
            return implode(', ', wp_list_pluck($users, 'display_name'));
        }
        return '';
    }

    /**
     * Helper function to format datetime.
     */
    private function format_datetime($datetime, $format = 'datetime') {
        if (!$datetime) return '-';
        $dt = new DateTime($datetime);
        if ($format === 'date') {
            return $dt->format('Y-m-d');
        }
        return $dt->format('Y-m-d H:i:s');
    }

    /**
     * Helper function to get badge counts for all tabs.
     */
    private function get_badge_counts() {
        $counts = array(
            'all' => 0,
            'due-today' => 0,
            'overdue' => 0,
            'upcoming' => 0,
            'completed' => 0,
            'notifications' => 0,
        );

        // All
        $counts['all'] = wp_count_posts('task')->publish;

        // Due Today
        $today = date('Y-m-d');
        $due_today_args = array(
            'post_type' => 'task',
            'post_status' => 'publish',
            'meta_query' => array(
                array(
                    'key' => 'due_date_or_time',
                    'value' => array($today . ' 00:00:00', $today . ' 23:59:59'),
                    'type' => 'DATETIME',
                    'compare' => 'BETWEEN',
                ),
            ),
            'fields' => 'ids',
        );
        $due_today_query = new WP_Query($due_today_args);
        $counts['due-today'] = $due_today_query->found_posts;

        // Overdue
        $overdue_args = array(
            'post_type' => 'task',
            'post_status' => 'publish',
            'meta_query' => array(
                array(
                    'key' => 'due_date_or_time',
                    'value' => date('Y-m-d') . ' 23:59:59',
                    'type' => 'DATETIME',
                    'compare' => '<',
                ),
                array(
                    'key' => 'task_status',
                    'value' => 'Completed',
                    'compare' => '!=',
                ),
            ),
            'fields' => 'ids',
        );
        $overdue_query = new WP_Query($overdue_args);
        $counts['overdue'] = $overdue_query->found_posts;

        // Upcoming (Next 30 days)
        $future = date('Y-m-d', strtotime('+30 days'));
        $upcoming_args = array(
            'post_type' => 'task',
            'post_status' => 'publish',
            'meta_query' => array(
                array(
                    'key' => 'due_date_or_time',
                    'value' => array($future . ' 00:00:00', '2100-01-01 00:00:00'),
                    'type' => 'DATETIME',
                    'compare' => 'BETWEEN',
                ),
            ),
            'fields' => 'ids',
        );
        $upcoming_query = new WP_Query($upcoming_args);
        $counts['upcoming'] = $upcoming_query->found_posts;

        // Completed
        $completed_args = array(
            'post_type' => 'task',
            'post_status' => 'publish',
            'meta_query' => array(
                array(
                    'key' => 'task_status',
                    'value' => 'Completed',
                    'compare' => '=',
                ),
            ),
            'fields' => 'ids',
        );
        $completed_query = new WP_Query($completed_args);
        $counts['completed'] = $completed_query->found_posts;

        // Notifications
        $notifications_args = array(
            'post_type' => 'task',
            'post_status' => 'publish',
            'meta_query' => array(
                array(
                    'key' => 'reminder_notification',
                    'value' => array('Email', 'SMS'), // Adjust based on actual notification types
                    'compare' => 'IN',
                ),
            ),
            'fields' => 'ids',
        );
        $notifications_query = new WP_Query($notifications_args);
        $counts['notifications'] = $notifications_query->found_posts;

        return $counts;
    }

    /**
     * Get Bootstrap CSS (minimized).
     */
    private function get_bootstrap_css() {
        // Replace this placeholder with the actual minified Bootstrap CSS content.
        // For demonstration purposes, only minimal styles are included.
        return <<<CSS
/* Bootstrap 5.3.0 Minimal CSS */
body { font-family: Arial, sans-serif; }
.btn-primary { background-color: #00cc77; border-color: #00cc77; }
.btn-primary:hover { background-color: #00b366; border-color: #00b366; }
.nav-tabs .nav-link.active { border-color: #dee2e6 #dee2e6 #00cc77; }
CSS;
    }

    /**
     * Get Bootstrap Icons CSS (minimized).
     */
    private function get_bootstrap_icons_css() {
        // Replace this placeholder with the actual Bootstrap Icons CSS content.
        // For demonstration purposes, only minimal styles are included.
        return <<<CSS
/* Bootstrap Icons 1.10.5 Minimal CSS */
.bi { display: inline-block; vertical-align: middle; }
CSS;
    }

    /**
     * Get Select2 CSS (minimized).
     */
    private function get_select2_css() {
        // Replace this placeholder with the actual minified Select2 CSS content.
        return <<<CSS
/* Select2 4.1.0-rc.0 Minimal CSS */
.select2-container { width: 100% !important; }
.select2-selection--multiple .select2-selection__choice { background-color: #00cc77; border: none; color: white; padding: 2px 8px; margin-top: 5px; margin-right: 2px; border-radius: 12px; }
CSS;
    }

    /**
     * Get Date Range Picker CSS (minimized).
     */
    private function get_daterangepicker_css() {
        // Replace this placeholder with the actual minified Date Range Picker CSS content.
        return <<<CSS
/* Date Range Picker Minimal CSS */
.daterangepicker { z-index: 2000 !important; }
CSS;
    }

    /**
     * Get Custom CSS.
     */
    private function get_custom_css() {
        return <<<CSS
/* Custom Taskly Dashboard CSS */
.tskr-app .tskr-primary {
    background-color: #00cc77;
    color: #fff;
}
.tskr-app .tskr-primary:hover {
    background-color: #00b366;
    color: #fff;
}
.tskr-app .tskr-table {
    border: 1px solid #dee2e6;
    border-collapse: collapse;
    width: 100%;
}
.tskr-app .tskr-table th, .tskr-app .tskr-table td {
    vertical-align: middle;
    border: 1px solid #dee2e6;
    padding: 0.75rem;
}
.tskr-app .tskr-checkbox {
    width: 20px;
    height: 20px;
}
.tskr-app .tskr-tab-button {
    color: #000;
    border: none;
    background: none;
    padding: 10px 15px;
    cursor: pointer;
    font-weight: 500;
    flex: 1 1 auto;
    text-align: center;
    position: relative;
}
.tskr-app .tskr-tab-button.active {
    border-bottom: 3px solid #00cc77;
    font-weight: bold;
}
/* Updated Filter Section */
.tskr-app .tskr-filter-section {
    display: flex;
    gap: 10px;
    width: 100%;
    flex-wrap: nowrap;
    margin-bottom: 20px;
}
.tskr-app .dropdown {
    flex: 1;
    min-width: 0;
}
.tskr-app .tskr-filter-btn {
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    padding: 8px 24px 8px 12px;
    position: relative;
}
/* Badge Styles */
.tskr-app .badge {
    position: relative;
    margin-left: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 8px;
    background-color: var(--badge-bg, #6c757d);
    color: #fff;
    border-radius: 12px;
}
.tskr-app .badge::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 8px;
    background-color: #ff0000;
    border-radius: 50%;
    display: none;
}
.tskr-app .badge.has-count::after {
    display: block;
}
/* Specific Badge Colors */
.tskr-app #allCount { background-color: #6c757d !important; }
.tskr-app #due-todayCount { background-color: #fd7e14 !important; }
.tskr-app #overdueCount { background-color: #dc3545 !important; }
.tskr-app #upcomingCount { background-color: #17a2b8 !important; }
.tskr-app #completedCount { background-color: #28a745 !important; }
.tskr-app #notificationsCount { background-color: #6610f2 !important; }
/* Task Badge Styles */
.tskr-app .tskr-badge {
    padding: 5px 10px;
    border-radius: 12px;
    color: #fff;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    margin: 0 5px;
}
.tskr-app .tskr-badge.assigned { background-color: #007bff; }
.tskr-app .tskr-badge.completed { background-color: #28a745; }
.tskr-app .tskr-badge.in-progress { background-color: #ffc107; color: #212529; }
.tskr-app .tskr-badge.not-started { background-color: #6c757d; }
.tskr-app .tskr-badge.overdue { background-color: #dc3545; }
.tskr-app .tskr-badge.due-today { background-color: #fd7e14; }
.tskr-app .tskr-badge.upcoming { background-color: #17a2b8; }
.tskr-app .tskr-badge.waiting { background-color: #6610f2; }
.tskr-app .tskr-badge.on-hold { background-color: #6f42c1; }
.tskr-app .tskr-badge.cancelled { background-color: #343a40; }
.tskr-app .tskr-badge.transferred { background-color: #20c997; }
/* Table Styles */
.tskr-app .tskr-table tbody tr {
    cursor: pointer;
}
.tskr-app .tskr-table tbody tr:hover {
    background-color: #f1f1f1;
}
/* Dropdown and Select2 Styles */
.tskr-app .dropdown-menu {
    padding: 15px;
    min-width: 200px;
    max-width: 300px;
    width: 100%;
}
.tskr-app .select2-container .select2-selection--multiple {
    height: auto !important;
    min-height: 38px;
}
.tskr-app .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: #00cc77;
    border: none;
    color: white;
    padding: 2px 8px;
    margin-top: 5px;
    margin-right: 2px;
    border-radius: 12px;
}
/* Pagination and DateRangePicker */
.tskr-app .tskr-pagination {
    justify-content: center;
    margin-top: 20px;
}
.tskr-app .daterangepicker {
    z-index: 2000 !important;
}
/* Link Styles */
.tskr-app a {
    color: #000;
    text-decoration: none;
}
.tskr-app a:hover {
    color: #00cc77;
    text-decoration: underline;
}
/* Updated Search and Clear Container */
.tskr-app .search-clear-container {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-bottom: 20px;
}

@media (min-width: 701px) {
    .tskr-app .search-clear-container {
        flex-direction: row;
    }
    .tskr-app .tskr-search-bar {
        flex: 0 0 70%;
    }
    .tskr-app .btn-clear-filters {
        flex: 0 0 30%;
    }
}

/* Responsive Styles */
@media (max-width: 700px) {
    .tskr-app .tskr-table thead {
        display: none;
    }
    .tskr-app .tskr-table, .tskr-app .tskr-table tbody, .tskr-app .tskr-table tr, .tskr-app .tskr-table td {
        display: block;
        width: 100%;
    }
    .tskr-app .tskr-table tr {
        margin-bottom: 15px;
        border: 1px solid #ddd;
        padding: 10px;
        border-radius: 5px;
        background-color: #fff;
    }
    .tskr-app .tskr-table td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border: none;
        border-bottom: 1px solid #dee2e6;
        word-wrap: break-word;
    }
    .tskr-app .tskr-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
    }
    .tskr-app .search-clear-container {
        flex-direction: column;
    }
    .tskr-app .tskr-search-bar,
    .tskr-app .btn-clear-filters {
        width: 100%;
    }
    .tskr-app .tskr-filter-section {
        flex-direction: column;
        gap: 10px;
    }
    .tskr-app .dropdown {
        width: 100%;
    }
    .tskr-app .tskr-filter-btn {
        width: 100%;
    }
    .tskr-app .dropdown-menu {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 15px;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) !important;
        max-height: 80vh;
        overflow-y: auto;
    }
    .tskr-app .nav-tabs .nav-item {
        flex: 1 1 100%;
    }
    .tskr-app .nav-tabs .nav-link {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}
CSS;
    }

    /**
     * Get Bootstrap JS (minimized).
     */
    private function get_bootstrap_js() {
        // Replace this placeholder with the actual minified Bootstrap JS content.
        // For demonstration purposes, only minimal scripts are included.
        return <<<JS
/* Bootstrap 5.3.0 Minimal JS */
document.addEventListener('DOMContentLoaded', function () {
    // Bootstrap's JS functionalities are primarily handled via data attributes.
});
JS;
    }

    /**
     * Get Select2 JS (minimized).
     */
    private function get_select2_js() {
        // Replace this placeholder with the actual minified Select2 JS content.
        // For demonstration purposes, initializing Select2 is handled in the inline script.
        return '';
    }

    /**
     * Get Moment.js (minimized).
     */
    private function get_moment_js() {
        // Replace this placeholder with the actual minified Moment.js content.
        // For demonstration purposes, it's assumed to be included via CDN.
        return '';
    }

    /**
     * Get Date Range Picker JS (minimized).
     */
    private function get_daterangepicker_js() {
        // Replace this placeholder with the actual minified Date Range Picker JS content.
        // For demonstration purposes, it's assumed to be included via CDN.
        return '';
    }

    /**
     * Get Custom JS.
     */
    private function get_custom_js() {
        // Include the JavaScript from your provided HTML here, integrated with AJAX.
        return <<<JS
jQuery(document).ready(function($) {
    // Initialize Select2
    $('.tskr-assignee-select, .tskr-tasktype-select, .tskr-priority-select, .tskr-taskstatus-select').select2({
        placeholder: 'Select options',
        width: '100%'
    });

    // Initialize Date Range Picker
    $('#customDateRange').daterangepicker({
        opens: 'left',
        locale: {
            format: 'YYYY-MM-DD'
        },
        autoUpdateInput: false
    }, function(start, end) {
        $('#customDateRange').val(start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));
        fetchTasks($('.tskr-tab-button.active').attr('id').split('-tab')[0]);
    });

    $('.tskr-date-range-btn').on('click', function(e) {
        e.preventDefault();
        var range = $(this).data('range');
        var start, end;
        var today = moment();

        switch(range) {
            case '7':
                start = moment().subtract(6, 'days');
                end = today;
                break;
            case '14':
                start = moment().subtract(13, 'days');
                end = today;
                break;
            case '31':
                start = moment().subtract(30, 'days');
                end = today;
                break;
            case '1-month':
                start = moment().subtract(1, 'months');
                end = today;
                break;
            case '2-month':
                start = moment().subtract(2, 'months');
                end = today;
                break;
            case '3-month':
                start = moment().subtract(3, 'months');
                end = today;
                break;
            default:
                start = null;
                end = null;
        }

        if(start && end){
            $('#customDateRange').data('daterangepicker').setStartDate(start);
            $('#customDateRange').data('daterangepicker').setEndDate(end);
            $('#customDateRange').val(start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD'));
            fetchTasks($('.tskr-tab-button.active').attr('id').split('-tab')[0]);
        }
    });

    $('#tskrClearFilters').on('click', function() {
        $('#tskrSearch').val('');
        $('.select2').val(null).trigger('change');
        $('#customDateRange').val('');
        $('input[type="checkbox"]').prop('checked', false);
        $('#customDateRange').data('daterangepicker').setStartDate(moment());
        $('#customDateRange').data('daterangepicker').setEndDate(moment());
        $('.tskr-tab-button#all-tab').tab('show');
        fetchTasks('all');
    });

    // Handle row clicks
    $('.tskr-app').on('click', '.tskr-table tbody tr', function(e) {
        if($(e.target).is('input[type="checkbox"]') || $(e.target).closest('a').length > 0){
            return;
        }
        var link = $(this).find('a').attr('href');
        if(link){
            window.location.href = link;
        }
    });

    // Handle checkbox selection
    $('.tskr-app').on('change', 'input[id^="selectAll_"]', function() {
        var tab = $(this).attr('id').split('_')[1];
        $('table[data-tab="' + tab + '"] tbody input[type="checkbox"]').prop('checked', this.checked);
    });

    // Fetch tasks on filter change
    $('#tskrSearch, .tskr-assignee-select, .tskr-tasktype-select, .tskr-priority-select, .tskr-taskstatus-select').on('change keyup', function() {
        fetchTasks($('.tskr-tab-button.active').attr('id').split('-tab')[0]);
    });

    let debounceTimer;
    $('#tskrSearch').on('keyup', function() {
        clearTimeout(debounceTimer);
        debounceTimer = setTimeout(function() {
            fetchTasks($('.tskr-tab-button.active').attr('id').split('-tab')[0]);
        }, 300);
    });

    // Handle tab clicks
    $('.tskr-tab-button').on('click', function() {
        var tab = $(this).attr('id').split('-tab')[0];
        fetchTasks(tab);
    });

    // Fetch tasks function
    function fetchTasks(tab = 'all', page = 1) {
        var search = $('#tskrSearch').val();
        var assignees = $('.tskr-assignee-select').val();
        var task_types = $('.tskr-tasktype-select').val();
        var priorities = $('.tskr-priority-select').val();
        var task_statuses = $('.tskr-taskstatus-select').val();
        var date_range = $('#customDateRange').val();

        $.ajax({
            url: taskly_ajax_obj.ajax_url,
            type: 'POST',
            dataType: 'json',
            data: {
                action: 'taskly_fetch_tasks',
                nonce: taskly_ajax_obj.nonce,
                search: search,
                assignees: assignees,
                task_types: task_types,
                priorities: priorities,
                task_statuses: task_statuses,
                date_range: date_range,
                tab: tab,
                page: page
            },
            beforeSend: function() {
                $('.tskr-app').find('.update-notification').remove();
                $('.tskr-app').prepend('<div class="update-notification alert alert-info" role="alert">Updating...</div>');
            },
            success: function(response) {
                if(response.success) {
                    updateTable(tab, response.data.tasks);
                    updateCounts(response.data.counts);
                    setupPagination(tab, response.data.total_pages);
                    $('.tskr-app').find('.update-notification').remove();
                } else {
                    $('.tskr-app').find('.update-notification').remove();
                    $('.tskr-app').prepend('<div class="update-notification alert alert-warning" role="alert">Failed to update tasks.</div>');
                }
            },
            error: function() {
                $('.tskr-app').find('.update-notification').remove();
                $('.tskr-app').prepend('<div class="update-notification alert alert-danger" role="alert">An error occurred while updating tasks.</div>');
            }
        });
    }

    // Update table with fetched tasks
    function updateTable(tab, tasks) {
        var tbody = $('table[data-tab="' + tab + '"] tbody');
        tbody.empty();
        if(tasks.length > 0) {
            tasks.forEach(function(task) {
                var status_class = getStatusClass(task.status);
                var row = '';
                if(tab === 'notifications'){
                    // Define table structure for Notifications tab
                    row = '<tr>' +
                        '<td class="select-column"><input type="checkbox" class="tskr-checkbox"></td>' +
                        '<td data-label="Notification Type">' + (task.notification_type ? task.notification_type : 'N/A') + '</td>' +
                        '<td data-label="Message">' + (task.message ? task.message : 'N/A') + '</td>' +
                        '<td data-label="Recipient">' + (task.recipient ? task.recipient : 'N/A') + '</td>' +
                        '<td data-label="Status"><span class="tskr-badge ' + status_class + '">' + capitalizeFirstLetter(task.status) + '</span></td>' +
                        '<td data-label="Sent Date">' + (task.sent_date ? task.sent_date : 'N/A') + '</td>' +
                        '<td data-label="Action">' + (task.action ? task.action : 'N/A') + '</td>' +
                        '</tr>';
                } else {
                    // Define table structure for Task tabs
                    row = '<tr>' +
                        '<td class="select-column"><input type="checkbox" class="tskr-checkbox"></td>' +
                        '<td data-label="Status"><span class="tskr-badge ' + status_class + '">' + capitalizeFirstLetter(task.status) + '</span></td>' +
                        '<td data-label="Title"><a href="' + task.permalink + '">' + task.title + '</a></td>' +
                        '<td data-label="Associated Contact">' + (task.associated_contact ? task.associated_contact : 'N/A') + '</td>' +
                        '<td data-label="Associated Company">' + (task.associated_company ? task.associated_company : 'N/A') + '</td>' +
                        '<td data-label="Last Contacted">' + (task.last_contacted ? task.last_contacted : 'N/A') + '</td>' +
                        '<td data-label="Last Engagement">' + (task.last_engagement ? task.last_engagement : 'N/A') + '</td>' +
                        '<td data-label="Task Type">' + (task.task_type ? task.task_type : 'N/A') + '</td>' +
                        '<td data-label="Due Date">' + (task.due_date ? task.due_date : 'N/A') + '</td>' +
                        '</tr>';
                }
                tbody.append(row);
            });

            // Bind row click again after AJAX
            $('.tskr-app .tskr-table tbody tr').on('click', function(e) {
                if($(e.target).is('input[type="checkbox"]') || $(e.target).closest('a').length > 0){
                    e.stopPropagation();
                    return;
                }
                var link = $(this).find('a').attr('href');
                if(link){
                    window.location.href = link;
                }
            });
        } else {
            var message = (tab === 'all') ? 'No tasks found.' : 'Empty Right Now, Import or Create Some Tasks';
            var colspan = (tab === 'notifications') ? 7 : 9;
            var noDataRow = '<tr><td colspan="' + colspan + '" class="text-center">' + message + '</td></tr>';
            tbody.append(noDataRow);
        }
    }

    // Update counts
    function updateCounts(counts) {
        for(var key in counts) {
            if(counts.hasOwnProperty(key)){
                var badgeCount = counts[key];
                $('#' + key + 'Count').text(badgeCount > 0 ? badgeCount : '-');
                var badge = $('#' + key + 'Count');
                if(badgeCount > 0){
                    badge.addClass('has-count');
                } else {
                    badge.removeClass('has-count');
                }
            }
        }
    }

    // Setup pagination
    function setupPagination(tab, total_pages) {
        var pagination = $('table[data-tab="' + tab + '"] tbody').closest('.tab-pane').find('.tskr-pagination');
        pagination.empty();

        if(total_pages > 1){
            // Previous Button
            var prevPage = (currentPage > 1) ? currentPage - 1 : 1;
            pagination.append('<li class="page-item"><a class="page-link tskr-primary" href="#" data-page="' + prevPage + '">Previous</a></li>');

            // Page Numbers
            for(var i=1; i<=total_pages; i++) {
                var activeClass = (i === 1) ? 'active' : '';
                pagination.append('<li class="page-item ' + activeClass + '"><a class="page-link" href="#" data-page="' + i + '">' + i + '</a></li>');
            }

            // Next Button
            var nextPage = (currentPage < total_pages) ? currentPage + 1 : total_pages;
            pagination.append('<li class="page-item"><a class="page-link tskr-primary" href="#" data-page="' + nextPage + '">Next</a></li>');
        }
    }

    // Handle pagination clicks
    $('.tskr-app').on('click', '.tskr-pagination .page-link', function(e) {
        e.preventDefault();
        var page = parseInt($(this).data('page'));
        var tab = $(this).closest('.tab-pane').find('table').data('tab');
        fetchTasks(tab, page);
    });

    // Utility Functions
    function capitalizeFirstLetter(string) {
        return string.charAt(0).toUpperCase() + string.slice(1);
    }

    function getStatusClass(status) {
        switch(status) {
            case 'assigned':
                return 'assigned';
            case 'completed':
                return 'completed';
            case 'in progress':
                return 'in-progress';
            case 'not started':
                return 'not-started';
            case 'overdue':
                return 'overdue';
            case 'due today':
                return 'due-today';
            case 'upcoming':
                return 'upcoming';
            case 'waiting':
                return 'waiting';
            case 'on hold':
                return 'on-hold';
            case 'cancelled':
                return 'cancelled';
            case 'transferred':
                return 'transferred';
            case 'sent':
                return 'completed'; // For notifications status
            case 'pending':
                return 'in-progress'; // For notifications status
            default:
                return '';
        }
    }

    // Start Sync Timer
    function startTaskSyncTimer() {
        setInterval(function() {
            fetchTasks($('.tskr-tab-button.active').attr('id').split('-tab')[0]);
            $('.tskr-app').find('.update-notification').remove();
            $('.tskr-app').prepend('<div class="update-notification alert alert-info" role="alert">Updating...</div>');
            setTimeout(function() {
                $('.tskr-app').find('.update-notification').remove();
            }, 3000);
        }, 30000);
    }

    // Initial fetch
    fetchTasks('all');

    // Start the sync timer
    startTaskSyncTimer();
});
JS;
    }

}

new Taskly_Dashboard_Pro();
?>