Automattic\WooCommerce\Blocks\Assets
AssetDataRegistry::add_data()
See self::add() for docs.
Метод класса: AssetDataRegistry{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->add_data( $key, $data );
- $key(строка) (обязательный)
- Key for the data.
- $data(разное) (обязательный)
- Value for the data.
Код AssetDataRegistry::add_data() AssetDataRegistry::add data WC 9.7.1
protected function add_data( $key, $data ) { if ( ! is_string( $key ) ) { // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error trigger_error( esc_html__( 'Key for the data being registered must be a string', 'woocommerce' ), E_USER_WARNING ); return; } if ( $this->exists( $key ) ) { return; } if ( isset( $this->data[ $key ] ) ) { // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error trigger_error( esc_html__( 'Overriding existing data with an already registered key is not allowed', 'woocommerce' ), E_USER_WARNING ); return; } if ( \is_callable( $data ) ) { $this->lazy_data[ $key ] = $data; return; } $this->data[ $key ] = $data; }