Automattic\WooCommerce\Blocks\Assets

AssetDataRegistry::get_core_dataprotectedWC 1.0

Exposes core data via the wcSettings global. This data is shared throughout the client.

Settings that are used by various components or multiple blocks should be added here. Note, that settings here are global so be sure not to add anything heavy if possible.

Method of the class: AssetDataRegistry{}

No Hooks.

Returns

Array. An array containing core data.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_core_data();

AssetDataRegistry::get_core_data() code WC 10.7.0

protected function get_core_data() {
	return [
		'adminUrl'               => admin_url(),
		'countries'              => WC()->countries->get_countries(),
		'currency'               => $this->get_currency_data(),
		'currentUserId'          => get_current_user_id(),
		'currentUserIsAdmin'     => current_user_can( 'manage_woocommerce' ),
		'currentThemeIsFSETheme' => wp_is_block_theme(),
		'dateFormat'             => wc_date_format(),
		'homeUrl'                => esc_url( home_url( '/' ) ),
		'locale'                 => $this->get_locale_data(),
		'isRemoteLoggingEnabled' => wc_get_container()->get( RemoteLogger::class )->is_remote_logging_allowed(),
		'dashboardUrl'           => wc_get_account_endpoint_url( 'dashboard' ),
		'orderStatuses'          => $this->get_order_statuses(),
		'placeholderImgSrc'      => wc_placeholder_img_src(),
		'productsSettings'       => $this->get_products_settings(),
		'siteTitle'              => wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ),
		'storePages'             => $this->get_store_pages(),
		'wcAssetUrl'             => plugins_url( 'assets/', WC_PLUGIN_FILE ),
		'wcVersion'              => defined( 'WC_VERSION' ) ? WC_VERSION : '',
		'wpLoginUrl'             => wp_login_url(),
		'wpVersion'              => get_bloginfo( 'version' ),
	];
}