- Timestamp:
- 06/04/2024 07:16:48 AM (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/interactivity-api/class-wp-interactivity-api.php
r58320 r58321 273 273 * 274 274 * @since 6.5.0 275 * @since 6.6.0 The function displays a warning message when the HTML contains unbalanced tags or a directive appears in a MATH or SVG tag. 275 276 * 276 277 * @param string $html The HTML content to process. … … 296 297 */ 297 298 if ( 'SVG' === $tag_name || 'MATH' === $tag_name ) { 299 if ( $p->get_attribute_names_with_prefix( 'data-wp-' ) ) { 300 /* translators: 1: SVG or MATH HTML tag, 2: Namespace of the interactive block. */ 301 $message = sprintf( __( 'Interactivity directives were detected on an incompatible %1$s tag when processing "%2$s". These directives will be ignored in the server side render.' ), $tag_name, end( $namespace_stack ) ); 302 _doing_it_wrong( __METHOD__, $message, '6.6.0' ); 303 } 298 304 $p->skip_to_tag_closer(); 299 305 continue; … … 383 389 } 384 390 } 385 386 391 /* 387 392 * It returns null if the HTML is unbalanced because unbalanced HTML is 388 393 * not safe to process. In that case, the Interactivity API runtime will 389 * update the HTML on the client side during the hydration. 394 * update the HTML on the client side during the hydration. It will also 395 * display a notice to the developer to inform them about the issue. 390 396 */ 391 return $unbalanced || 0 < count( $tag_stack ) ? null : $p->get_updated_html(); 397 if ( $unbalanced || 0 < count( $tag_stack ) ) { 398 $tag_errored = 0 < count( $tag_stack ) ? end( $tag_stack )[0] : $tag_name; 399 /* translators: %1s: Namespace processed, %2s: The tag that caused the error; could be any HTML tag. */ 400 $message = sprintf( __( 'Interactivity directives failed to process in "%1$s" due to a missing "%2$s" end tag.' ), end( $namespace_stack ), $tag_errored ); 401 _doing_it_wrong( __METHOD__, $message, '6.6.0' ); 402 return null; 403 } 404 405 return $p->get_updated_html(); 392 406 } 393 407 … … 397 411 * 398 412 * @since 6.5.0 413 * @since 6.6.0 The function now adds a warning when the namespace is null, falsy, or the directive value is empty. 399 414 * 400 415 * @param string|true $directive_value The directive attribute value string or `true` when it's a boolean attribute. … … 403 418 * @param array|false $context The current context for evaluating the directive or false if there is no 404 419 * context. 405 * @return mixed|null The result of the evaluation. Null if the reference path doesn't exist .420 * @return mixed|null The result of the evaluation. Null if the reference path doesn't exist or the namespace is falsy. 406 421 */ 407 422 private function evaluate( $directive_value, string $default_namespace, $context = false ) { 408 423 list( $ns, $path ) = $this->extract_directive_value( $directive_value, $default_namespace ); 409 if ( empty( $path ) ) { 424 if ( ! $ns || ! $path ) { 425 /* translators: %s: The directive value referenced. */ 426 $message = sprintf( __( 'Namespace or reference path cannot be empty. Directive value referenced: %s' ), $directive_value ); 427 _doing_it_wrong( __METHOD__, $message, '6.6.0' ); 410 428 return null; 411 429 }
Note: See TracChangeset
for help on using the changeset viewer.