Make WordPress Core


Ignore:
Timestamp:
06/04/2024 07:16:48 AM (20 months ago)
Author:
gziolo
Message:

Interactivity API: Print debug warning when server directives processing encounters errors

Aims to improve the developer experience of the Interactivity API server directives processing.

Props cbravobernal, jonsurrell, westonruter, darerodz, czapla, gziolo.
Fixes #61044.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php

    r58233 r58321  
    199199        $depth    = 1;
    200200        $tag_name = $this->get_tag();
    201         while ( $depth > 0 && $this->next_tag(
    202             array(
    203                 'tag_name'    => $tag_name,
    204                 'tag_closers' => 'visit',
    205             )
    206         ) ) {
    207             if ( $this->has_self_closing_flag() ) {
    208                 continue;
    209             }
    210             $depth += $this->is_tag_closer() ? -1 : 1;
     201
     202        while ( $depth > 0 && $this->next_tag( array( 'tag_closers' => 'visit' ) ) ) {
     203            if ( ! $this->is_tag_closer() && $this->get_attribute_names_with_prefix( 'data-wp-' ) ) {
     204                /* translators: 1: SVG or MATH HTML tag. */
     205                $message = sprintf( __( 'Interactivity directives were detected inside an incompatible %1$s tag. These directives will be ignored in the server side render.' ), $tag_name );
     206                _doing_it_wrong( __METHOD__, $message, '6.6.0' );
     207            }
     208            if ( $this->get_tag() === $tag_name ) {
     209                if ( $this->has_self_closing_flag() ) {
     210                    continue;
     211                }
     212                $depth += $this->is_tag_closer() ? -1 : 1;
     213            }
    211214        }
    212215
Note: See TracChangeset for help on using the changeset viewer.