Admin_Settings_Premium_Integrations::tab_output()

Outputs the content of the “Premium integrations” tab


Source Source

File: src/core/admin/admin-settings/tabs/premium-integrations.php

	public function tab_output() {
		// Get the tabs
		$integrations_tabs = $this->get_premium_integrations_tabs();

		// Get the current tab
		$current_integration = automator_filter_has_var( 'integration' ) ? sanitize_text_field( automator_filter_input( 'integration' ) ) : '';

		// Check if the user has access to the premium integrations
		// This will be true if the site is connected (Automator Free) or if the
		// user has Automator Pro activated
		$user_can_use_premium_integrations = Admin_Menu::is_automator_connected() || is_automator_pro_active();

		// Get the link to upgrade to Pro
		$upgrade_to_pro_url = add_query_arg(
			// UTM
			array(
				'utm_source' => 'uncanny_automator',
				'utm_medium' => 'settings',
				'utm_content' => 'premium_integrations_connect'
			),

			'https://automatorplugin.com/pricing/'
		);

		// Get the link to the article about credits
		$credits_article_url = add_query_arg(
			// UTM
			array(
				'utm_source' => 'uncanny_automator',
				'utm_medium' => 'settings',
				'utm_content' => 'premium_integrations_connect'
			),

			'https://automatorplugin.com/knowledge-base/what-are-credits/'
		);

		// Get the link to connect the site
		$connect_site_url = add_query_arg(
			array(
				'post_type' => 'uo-recipe',
				'page'      => 'uncanny-automator-setup-wizard',
			),
			admin_url( 'edit.php' )
		);

		// Check if the user is requesting the focus version
		$layout_version = automator_filter_has_var( 'automator_hide_settings_tabs' ) ? 'focus' : 'default';

		// Add the actions and get the selected tab
		foreach ( $integrations_tabs as $tab_key => $tab ) {
			if (
				// Check if the user can use the premium integrations before adding the content of the tabs
				$user_can_use_premium_integrations &&
				// Check if the function is defined
				isset( $tab->function )
			) {
				// Add action
				add_action( 'automator_settings_premium_integrations_' . $tab_key . '_tab', $tab->function );
			}

			// Check if this is the selected tab
			$tab->is_selected = $user_can_use_premium_integrations ? $tab_key === $current_integration : false;
		}

		// Load the view
		include Utilities::automator_get_view( 'admin-settings/tab/premium-integrations.php' );
	}