Admin_Menu::dashboard_menu_page_output()

Create Dashboard view


Source

File: src/core/admin/class-admin-menu.php

	public function dashboard_menu_page_output() {

		// Check connect and credits
		$is_connected = $this->automator_connect;

		$website      = preg_replace( '(^https?://)', '', get_home_url() );
		$redirect_url = site_url( 'wp-admin/edit.php?post_type=uo-recipe&page=uncanny-automator-dashboard' );
		$connect_url  = self::$automator_connect_url . self::$automator_connect_page . '?redirect_url=' . urlencode( $redirect_url );

		$license_data = false;
		if ( $is_connected ) {
			$license_data = get_option( 'uap_automator_free_license_data' );
		}

		$is_pro_active = false;

		if ( isset( $is_connected['item_name'] ) ) {
			if ( defined( 'AUTOMATOR_PRO_ITEM_NAME' ) && $is_connected['item_name'] === AUTOMATOR_PRO_ITEM_NAME ) {
				$is_pro_active = true;
			}
		}

		$user      = wp_get_current_user();
		$dashboard = (object) array(
			// Check if the user is using Automator Pro
			'is_pro'             => $is_pro_active,
			// Is Pro connected
			'is_pro_installed'   => defined( 'AUTOMATOR_PRO_FILE' ) ? true : false,
			'pro_activate_link'  => site_url( 'wp-admin/edit.php?post_type=uo-recipe&page=uncanny-automator-license-activation' ),
			// Check if this site is connected to an automatorplugin.com account
			'has_site_connected' => $is_connected ? true : false,
			// Get data about the CONNECTED user (automatorplugin.com)
			// If no user is connected, "connected_user" should be NULL
			'connected_user'     => (object) array(
				// First name.
				// If first name is not available, then Display name
				'first_name' => $is_connected ? $is_connected['customer_name'] : 'Guest',
				// Gravatar
				'avatar'     => $is_connected ? $is_connected['user_avatar'] : esc_url( get_avatar_url( $user->ID ) ),
				'url'        => (object) array(
					// automatorplugin.com link to edit profile
					'edit_profile'       => self::$automator_connect_url . 'my-account/',
					// automatorplugin.com link to manage connected sites under this account
					'connected_sites'    => $is_connected ? self::$automator_connect_url . 'checkout/purchase-history/?license_id=' . $is_connected['license_id'] . '&action=manage_licenses&payment_id=' . $is_connected['payment_id'] : '#',
					// URL to disconnect current site from the account
					'disconnect_account' => add_query_arg( [ 'action' => 'discount_automator_connect' ] ),
				),
			),
			'connect_url'        => $connect_url,
			'miscellaneous'      => (object) array(
				'free_credits'              => $is_connected ? ( $is_connected['usage_limit'] - $is_connected['paid_usage_count'] ) : 1000,
				'site_url_without_protocol' => preg_replace( '(^https?://)', '', get_site_url() ),
			),
		);

		?>

		<div class="wrap uap">
			<?php include UA_ABSPATH . 'src/core/views/admin-dashboard.php'; ?>
		</div>

		<?php
	}