<?php
defined( 'ABSPATH' ) || die();
/**
 * Tasks to show in the admin area.
 * Condition: [
 *          type: serverside, clientside, activation (if task should be added on activation)
 *          function returning a boolean
 * ]
 * status: open, completed, premium
 */
return [
	[
		'id'                  => 'bf_notice',
		'condition'           => [
			'type'     => 'serverside',
			'function' => 'Burst\Admin\Admin::is_bf()',

		],
		'msg'                 => __( 'Black Friday', 'burst-statistics' ) . ': ' . __( 'Get 40% Off Burst Pro!', 'burst-statistics' ) . ' — ' . __( 'Limited time offer!', 'burst-statistics' ),
		'icon'                => 'sale',
		'url'                 => 'pricing/',
		'dismissible'         => true,
		'plusone'             => true,
		'dismiss_permanently' => true,
	],
	[
		'id'                  => 'cm_notice',
		'condition'           => [
			'type'     => 'serverside',
			'function' => 'Burst\Admin\Admin::is_cm()',
		],
		'msg'                 => __( 'Cyber Monday', 'burst-statistics' ) . ': ' . __( 'Get 40% Off Burst Pro!', 'burst-statistics' ) . ' — ' . __( 'Last chance!', 'burst-statistics' ),
		'icon'                => 'sale',
		'url'                 => 'pricing/',
		'dismissible'         => true,
		'plusone'             => true,
		'dismiss_permanently' => true,
	],
	[
		'id'          => 'leave-feedback',
		'condition'   => [
			'type' => 'activation',
		],
		// @phpstan-ignore-next-line
		'msg'         => $this->sprintf(
		// translators: 1: opening anchor tag to support thread, 2: closing anchor tag.
			__( 'If you have any suggestions to improve our plugin, feel free to %1$sopen a support thread%2$s.', 'burst-statistics' ),
			'<a href="https://wordpress.org/support/plugin/burst-statistics/" target="_blank">',
			'</a>'
		),
		'icon'        => 'completed',
		'dismissible' => true,
	],
	[
		'id'          => 'join-discord',
		'condition'   => [
			'type' => 'activation',
		],
		'msg'         => __( 'Join the Burst community on Team Updraft Discord to discuss features, get help, and shape the future of Burst.', 'burst-statistics' ),
		'url'         => 'https://discord.gg/jCC7GD59nS',
		'icon'        => 'completed',
		'dismissible' => true,
	],
	[
		'id'          => 'ecommerce_integration',
		'msg'         => __( 'New in Burst Pro: dedicated sales dashboard for WooCommerce and Easy Digital Downloads.', 'burst-statistics' ),
		'icon'        => 'new',
		'url'         => 'new-feature-woocommerce-insights/',
		'dismissible' => true,
		'plusone'     => false,
	],
	[
		'id'          => 'search_console_integration',
		'msg'         => __( 'New: connect Google Search Console to Burst and see which search queries bring visitors to your site, right in your dashboard.', 'burst-statistics' ),
		'icon'        => 'new',
		'url'         => '#/settings/integrations',
		'dismissible' => true,
		'plusone'     => true,
	],
	[
		// no condition on this task, as when this issue happens, cron is not working to add the task.
		'id'          => 'cron',
		'msg'         => __( 'Your WordPress cron hasn’t been triggered for over 24 hours. As a result, Burst can’t update first visit and bounce data until it runs again.', 'burst-statistics' ),
		'icon'        => 'warning',
		'url'         => 'instructions/cron-error/',
		'dismissible' => false,
	],
	[
		'id'          => 'malicious_data_removal',
		'condition'   => [
			'type'     => 'serverside',
			'function' => 'wp_option_burst_cleanup_uid_visits',
		],
		// translators: %d is the number of visits detected from a single user in 24 hours.
		'msg'         => sprintf( __( 'Burst has detected an anomalous number of visits (%1$d in 24 hours) from one user with UID %2$s. You can consider removing these hits by using the "fix" button, but if you\'re sure these are valid visits, you can dismiss this notice.', 'burst-statistics' ), (int) get_option( 'burst_cleanup_uid_visits', 0 ), esc_html( (string) get_option( 'burst_cleanup_uid', '' ) ) ),
		'icon'        => 'warning',
		'url'         => 'why-burst-removes-anomalous-visits-and-how-you-can-customize-it/',
		'dismissible' => true,
		'fix'         => 'burst_clean_data',
	],
	[
		'id'          => 'php_error_detected',
		'condition'   => [
			'type'     => 'serverside',
			'function' => 'wp_option_burst_php_error_detected',
		],
		// translators: %d: error count, %s time of error.
		'msg'         => sprintf( __( 'Burst has detected %1$d PHP errors, the last one on %2$s. Detected errors:', 'burst-statistics' ) . ' ' . substr( esc_html( get_option( 'burst_php_error_detected', '' ) ), 0, 500 ), (int) get_option( 'burst_php_error_count', 0 ), date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), get_option( 'burst_php_error_time' ) ) ),
		'icon'        => 'warning',
		'dismissible' => true,
		'url'         => 'how-to-enable-debugging-in-wordpress',
	],
	[
		'id'          => 'missing_tables',
		'condition'   => [
			'type'     => 'serverside',
			'function' => 'wp_option_burst_missing_tables',
		],
		// translators: %d: error count, %s time of error.
		'msg'         => sprintf( __( 'Burst has detecting missing database tables: %s.', 'burst-statistics' ), get_option( 'burst_missing_tables' ) ) . ' ' . __( 'Please deactivate Burst (keep the data!), then activate again, to trigger a database upgrade.', 'burst-statistics' ),
		'icon'        => 'warning',
		'dismissible' => true,
	],
	[
		'id'          => 'pageviews_milestone',
		'condition'   => [
			'type'     => 'serverside',
			'function' => 'Burst\Admin\Milestones::pageviews_milestone_reached()',
		],
		'msg'         => sprintf(
			// translators: %s is the milestone number (compact, e.g. 1k, 10k, 1M).
			__( 'You’ve hit %s pageviews this month!', 'burst-statistics' ),
			( new \Burst\Admin\Milestones() )->format_milestone( get_option( 'burst_current_pageviews_milestone', 0 ) )
		),
		'icon'        => 'milestone',
		'dismissible' => true,
		'plusone'     => false,
	],
	[
		'id'          => 'live_visitors',
		'condition'   => [
			'type' => 'clientside',
		],
		'icon'        => 'insight',
		'dismissible' => false,
		'plusone'     => false,
	],
	[
		'id'                  => 'multi_domain_setup_detected',
		'condition'           => [
			'type'     => 'serverside',
			'function' => 'wp_option_burst_is_multi_domain',
		],
		'msg'                 => __( 'Burst detected multiple domains being used to visit the website. If you want to be able to differentiate between domains, you can enable filtering by domain in the settings.', 'burst-statistics' ),
		'icon'                => 'warning',
		'dismissible'         => true,
		'plusone'             => false,
		'url'                 => 'filtering-by-domain/',
		'dismiss_permanently' => true,
	],
	[
		'id'          => 'filters_in_url',
		'msg'         => __( 'New: save or share your filtered view by simply copying the URL or bookmarking it.', 'burst-statistics' ),
		'icon'        => 'new',
		'dismissible' => true,
		'plusone'     => false,
	],
	[
		'id'          => 'external_links_tracking',
		'msg'         => __( 'New: external link click tracking is now enabled. You can manage this in Settings > General.', 'burst-statistics' ),
		'icon'        => 'new',
		'dismissible' => true,
		'plusone'     => false,
	],
	[
		'id'                  => 'enable_ai_chat',
		'condition'           => [
			'type'     => 'serverside',
			'function' => 'Burst\Admin\Abilities_Api\Abilities_Api::should_show_enable_notice()',
		],
		'msg'                 => __( 'New: Burst AI chat can answer analytics questions and use Burst abilities for you. Enable the Abilities API to try it.', 'burst-statistics' ),
		'icon'                => 'new',
		'fix'                 => 'burst_option_enable_abilities_api',
		'dismissible'         => true,
		'plusone'             => true,
		'dismiss_permanently' => true,
		'url'                 => 'guides/ask-burst-anything-setting-up-the-ai-chat-for-your-analytics',

	],
	[
		'id'          => 'opt-in-sharing',
		'msg'         => __( 'Help us build better features, prioritize integrations, and improve recommendations by sharing anonymous usage data. We never collect personal information, your site URL, or IP addresses. Everything stays completely anonymous.', 'burst-statistics' ),
		'icon'        => 'new',
		'fix'         => 'burst_option_anonymous_usage_data',
		'dismissible' => true,
		'plusone'     => false,
	],
	[
		'id'          => 'turbo_mode_recommended',
		'msg'         => __( 'You have cookieless tracking enabled, but Turbo mode is not enabled on your site. For best performance results, we recommend to enable Turbo mode.', 'burst-statistics' ),
		'icon'        => 'warning',
		'dismissible' => true,
		'plusone'     => false,
		'url'         => 'definition/turbo-mode/',
		'fix'         => 'burst_option_enable_turbo_mode',
	],
	[
		'id'                  => 'mainwp_integration_disabled',
		'condition'           => [
			'type'     => 'serverside',
			'function' => 'Burst\\Admin\\Tasks::should_show_mainwp_integration_task()',
		],
		'msg'                 => __( 'MainWP Child is active on this site, but Burst MainWP integration is disabled. Enable it in settings to allow MainWP Dashboard statistics.', 'burst-statistics' ),
		'icon'                => 'warning',
		'url'                 => 'guides/manage-burst-statistics-across-all-your-sites-with-mainwp/',
		'fix'                 => 'burst_option_enable_mainwp_integration',
		'dismissible'         => true,
		'plusone'             => true,
		'dismiss_permanently' => true,
	],
	[
		'id'                  => 'persistent_object_cache_recommended',
		'condition'           => [
			'type'     => 'serverside',
			'function' => 'Burst\Admin\Statistics\Statistics::should_recommend_object_cache()',
		],
		'msg'                 => __( 'Burst detected very slow analytics queries. To reduce repeated heavy database load, we recommend enabling a persistent object cache (Redis or Memcached).', 'burst-statistics' ),
		'icon'                => 'warning',
		'dismissible'         => true,
		'plusone'             => false,
		'dismiss_permanently' => true,
	],
	[
		'id'                  => 'wp_consent_api_notice',
		'condition'           => [
			'type'     => 'serverside',
			'function' => 'Burst\Admin\Tasks::is_wp_consent_api_active()',
		],
		'msg'                 => __( 'If you have configured a cookiebanner to ask consent for statistics, this will cause Burst not to track any user who is not flagged by the cookie banner as having consent for statistics.', 'burst-statistics' ),
		'icon'                => 'warning',
		'url'                 => 'wp-consent-api-integration',
		'dismissible'         => true,
		'plusone'             => true,
		'dismiss_permanently' => true,
	],
];
