Automattic\WooCommerce\Admin

DataSourcePoller::read_specs_from_data_sources()publicWC 1.0

Reads the data sources for specs and persists those specs.

Method of the class: DataSourcePoller{}

Hooks from the method

Return

true|false. Whether any specs were read.

Usage

$DataSourcePoller = new DataSourcePoller();
$DataSourcePoller->read_specs_from_data_sources();

DataSourcePoller::read_specs_from_data_sources() code WC 8.7.0

public function read_specs_from_data_sources() {
	$specs        = array();
	$data_sources = apply_filters( self::FILTER_NAME, $this->data_sources, $this->id );

	// Note that this merges the specs from the data sources based on the
	// id - last one wins.
	foreach ( $data_sources as $url ) {
		$specs_from_data_source = self::read_data_source( $url );
		$this->merge_specs( $specs_from_data_source, $specs, $url );
	}

	$specs_group            = get_transient( $this->args['transient_name'] );
	$specs_group            = is_array( $specs_group ) ? $specs_group : array();
	$locale                 = get_user_locale();
	$specs_group[ $locale ] = $specs;
	// Persist the specs as a transient.
	$this->set_specs_transient(
		$specs_group,
		$this->args['transient_expiry']
	);
	return count( $specs ) !== 0;
}