Automattic\WooCommerce\Blocks\AI

Connection::get_site_id()publicWC 1.0

Return the site ID.

Method of the class: Connection{}

No Hooks.

Return

Int|\WP_Error. The site ID or a WP_Error object.

Usage

$Connection = new Connection();
$Connection->get_site_id();

Connection::get_site_id() code WC 9.3.3

public function get_site_id() {
	if ( ! class_exists( Jetpack_Options::class ) ) {
		return new \WP_Error( 'site-id-error', esc_html__( 'Failed to fetch the site ID: try again later.', 'woocommerce' ) );
	}

	$site_id = Jetpack_Options::get_option( 'id' );

	if ( ! $site_id ) {
		return new \WP_Error( 'site-id-error', esc_html__( 'Failed to fetch the site ID: The site is not registered.', 'woocommerce' ) );
	}

	return $site_id;
}