wp-includes/interactivity-api/class-wp-interactivity-api.php:1108Processes the data-wp-bind directive.
$pWP_Interactivity_API_Directives_Processor$modestring private function data_wp_bind_processor( WP_Interactivity_API_Directives_Processor $p, string $mode ): void { if ( 'enter' === $mode ) { $entries = $this->get_directive_entries( $p, 'bind' ); foreach ( $entries as $entry ) { if ( empty( $entry['suffix'] ) || null !== $entry['unique_id'] ) { continue; } // Skip if the suffix is an event handler. if ( str_starts_with( $entry['suffix'], 'on' ) ) { _doing_it_wrong( __METHOD__, sprintf( /* translators: %s: The directive, e.g. data-wp-on--click. */ __( 'Binding event handler attributes is not supported. Please use "%s" instead.' ), esc_attr( 'data-wp-on--' . substr( $entry['suffix'], 2 ) ) ), '6.9.2' ); continue; } $result = $this->evaluate( $entry ); /* * An object is resolved to whatever it serializes to. When the reference points to a value stored * in state or context, that is the value the client receives for it when the store is hydrated. * A derived state closure is never serialized, so there the client value comes from the derived * state's client-side implementation instead; the resolution is still applied so that both origins * behave the same. Round-tripping through the JSON encoder rather than calling * JsonSerializable::jsonSerialize() directly keeps this resolution identical to the client's, * including for an object which serializes to another serializable object. When the encoding fails * the object is left in place, to be reported as a usage error below. Note that it rarely does * fail: wp_json_encode() retries through _wp_json_sanity_check(), which rebuilds the object from * its public properties and so ignores jsonSerialize() altogether. An object whose serialized form * JSON cannot represent therefore resolves to whatever that rebuild encodes to, which is what the * client is sent for it as well. * * A throwing JsonSerializable::jsonSerialize() is caught for the same reason the value is checked * at all: a binding must not be able to abort the render. An exception escaping here would leave * `$context_stack` and `$namespace_stack` unrestored for every later `process_directives()` call * on this instance, so the object is treated as one which failed to encode. */ if ( is_object( $result ) ) { try { $encoded = wp_json_encode( $result ); } catch ( Throwable $e ) { $encoded = false; } if ( false !== $encoded ) { $result = json_decode( $encoded ); } } /* * Only a value which can be sent to the client may be stored in an attribute value. Strings and * booleans are passed in as-is, numbers are formatted, and everything else is rejected as a usage * error. * * An object which does not serialize to a scalar is rejected even when it defines `__toString()`, * which PHP would otherwise coerce for the string parameters of the escaping functions. Its string * representation is not what the client evaluates this reference to, whether that is the form * serialized into the store or the return value of a derived state's client-side implementation, * so the two could disagree once the directive is evaluated during hydration. */ if ( null !== $result ) { if ( ! is_scalar( $result ) ) { _doing_it_wrong( __METHOD__, sprintf( /* translators: %s: The attribute name. */ __( 'Attempted to bind a non-scalar value to the "%s" attribute. Ensure the state/context property or the derived state closure resolves to a string, number, or boolean.' ), esc_html( $entry['suffix'] ) ), '7.1.0' ); $result = null; } elseif ( is_int( $result ) || is_float( $result ) ) { /* * A number is formatted by the JSON encoder rather than cast to string, so that theIntroduced in 6.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/interactivity-api/class-wp-interactivity-api.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.