Automattic\WooCommerce\Admin\RemoteSpecs

DataSourcePoller::read_specs_from_data_sources()publicWC 1.0

Reads the data sources for specs and persists those specs.

Метод класса: DataSourcePoller{}

Хуки из метода

Возвращает

true|false. Whether any specs were read.

Использование

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

Код DataSourcePoller::read_specs_from_data_sources() WC 8.9.0

public function read_specs_from_data_sources() {
	$specs = array();

	/**
	 * Filter data sources.
	 *
	 * @param array      $this->data_sources List of data sources.
	 * @param string     $this->id Spec identifier.
	 *
	 * @since 8.8.0
	 */
	$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;
}