src/Modules/Endpoint.php
function checksum( \WP_REST_Request $data ) {
		$products = Loader::get_products();
		if ( self::PRODUCT_SPECIFIC ) {
			$params = $this->validate_params( $data, array( 'slug' ) );
			foreach ( $products as $product ) {
				if ( $params['slug'] === $product->get_slug() ) {
					$products = array( $product );
					break;
				}
			}
		}
		$response   = array();
		$custom_css = $this->has_custom_css();
		if ( is_bool( $custom_css ) ) {
			$response['custom_css'] = $custom_css;
		}

		$response['child_theme'] = $this->get_theme_properties();

		foreach ( $products as $product ) {
			$files = array();
			switch ( $product->get_type() ) {
				case 'plugin':
					$files = array();
					break;
				case 'theme':
					$files = array( 'style.css', 'functions.php' );
					break;
			}

			$error = '';

			// if any element in the $files array contains a '/', this would imply recursion is required.
			$diff = $this->generate_diff(
				$product,
				$files,
				array_reduce(
					$files,
					array(
						$this,
						'is_recursion_required',
					),
					false
				)
			);
			if ( is_wp_error( $diff ) ) {
				/**
				 * Error returner by the diff checker method.
				 *
				 * @var \WP_Error $diff Error returned.
				 */
				$error = $diff->get_error_message();
				$diff  = array();
			}

			$response['products'][] = array(
				'slug'    => $product->get_slug(),
				'version' => $product->get_version(),
				'diffs'   => $diff,
				'error'   => $error,
			);
		}

		return new \WP_REST_Response( array( 'checksum' => $response ) );
	}
function checksum( \WP_REST_Request $data ) {
		$products = Loader::get_products();
		if ( self::PRODUCT_SPECIFIC ) {
			$params = $this->validate_params( $data, array( 'slug' ) );
			foreach ( $products as $product ) {
				if ( $params['slug'] === $product->get_slug() ) {
					$products = array( $product );
					break;
				}
			}
		}
		$response   = array();
		$custom_css = $this->has_custom_css();
		if ( is_bool( $custom_css ) ) {
			$response['custom_css'] = $custom_css;
		}

		$response['child_theme'] = $this->get_theme_properties();

		foreach ( $products as $product ) {
			$files = array();
			switch ( $product->get_type() ) {
				case 'plugin':
					$files = array();
					break;
				case 'theme':
					$files = array( 'style.css', 'functions.php' );
					break;
			}

			$error = '';

			// if any element in the $files array contains a '/', this would imply recursion is required.
			$diff = $this->generate_diff(
				$product,
				$files,
				array_reduce(
					$files,
					array(
						$this,
						'is_recursion_required',
					),
					false
				)
			);
			if ( is_wp_error( $diff ) ) {
				/**
				 * Error returner by the diff checker method.
				 *
				 * @var \WP_Error $diff Error returned.
				 */
				$error = $diff->get_error_message();
				$diff  = array();
			}

			$response['products'][] = array(
				'slug'    => $product->get_slug(),
				'version' => $product->get_version(),
				'diffs'   => $diff,
				'error'   => $error,
			);
		}

		return new \WP_REST_Response( array( 'checksum' => $response ) );
	}
function checksum ( \ WP_REST_Request $ data ) { $ products = Loader :: get_products ( ) ; if ( self :: PRODUCT_SPECIFIC ) { $ params = $ this -> validate_params ( $ data , array ( 'slug' ) ) ; foreach ( $ products as $ product ) { if ( $ params [ 'slug' ] === $ product -> get_slug ( ) ) { $ products = array ( $ product ) ; break ; } } } $ response = array ( ) ; $ custom_css = $ this -> has_custom_css ( ) ; if ( is_bool ( $ custom_css ) ) { $ response [ 'custom_css' ] = $ custom_css ; } $ response [ 'child_theme' ] = $ this -> get_theme_properties ( ) ; foreach ( $ products as $ product ) { $ files = array ( ) ; switch ( $ product -> get_type ( ) ) { case 'plugin' : $ files = array ( ) ; break ; case 'theme' : $ files = array ( 'style.css' , 'functions.php' ) ; break ; } $ error = '' ; // if any element in the $files array contains a '/', this would imply recursion is required. $ diff = $ this -> generate_diff ( $ product , $ files , array_reduce ( $ files , array ( $ this , 'is_recursion_required' , ) , false ) ) ; if ( is_wp_error ( $ diff ) ) { /**
				 * Error returner by the diff checker method.
				 *
				 * @var \WP_Error $diff Error returned.
				 */ $ error = $ diff -> get_error_message ( ) ; $ diff = array ( ) ; } $ response [ 'products' ] [ ] = array ( 'slug' => $ product -> get_slug ( ) , 'version' => $ product -> get_version ( ) , 'diffs' => $ diff , 'error' => $ error , ) ; } return new \ WP_REST_Response ( array ( 'checksum' => $ response ) ) ; }
The checksum endpoint.

@param \WP_REST_Request $data the request.

@return \WP_REST_Response Response or the error
The checksum endpoint .