block attributes into the block. * * @param string $content HTML content to inject into. * @param array $attributes Key value pairs of attributes. * @return string Rendered block with data attributes. */ protected function inject_html_data_attributes( $content, array $attributes ) { return preg_replace( '/
get_html_data_attributes( $attributes ) . ' ', $content, 1 ); } /** * Converts block attributes to HTML data attributes. * * @param array $attributes Key value pairs of attributes. * @return string Rendered HTML attributes. */ protected function get_html_data_attributes( array $attributes ) { $data = []; foreach ( $attributes as $key => $value ) { if ( is_bool( $value ) ) { $value = $value ? 'true' : 'false'; } if ( ! is_scalar( $value ) ) { $value = wp_json_encode( $value ); } $data[] = 'data-' . esc_attr( strtolower( preg_replace( '/(?integration_registry->get_all_registered_script_data(); foreach ( $registered_script_data as $asset_data_key => $asset_data_value ) { if ( ! $this->asset_data_registry->exists( $asset_data_key ) ) { $this->asset_data_registry->add( $asset_data_key, $asset_data_value ); } } } /** * Register/enqueue scripts used for this block on the frontend, during render. * * @param array $attributes Any attributes that currently are available from the block. */ protected function enqueue_scripts( array $attributes = [] ) { if ( null !== $this->get_block_type_script() ) { wp_enqueue_script( $this->get_block_type_script( 'handle' ) ); } } /** * Script to append the correct sizing class to a block skeleton. * * @return string */ protected function get_skeleton_inline_script() { return ""; } }