WP_Interactivity_API::data_wp_bind_processor( WP_Interactivity_API_Directives_Processor $p, string $mode, array $context_stack, array $namespace_stack )

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Processes the data-wp-bind directive.

Description

It updates or removes the bound attributes based on the evaluation of its associated reference.

Parameters

$pWP_Interactivity_API_Directives_Processorrequired
The directives processor instance.
$modestringrequired
Whether the processing is entering or exiting the tag.
$context_stackarrayrequired
The reference to the context stack.
$namespace_stackarrayrequired
The reference to the store namespace stack.

Source

			try {
				$current = $current();
			} catch ( Throwable $e ) {
				_doing_it_wrong(
					__METHOD__,
					sprintf(
						/* translators: 1: Path pointing to an Interactivity API state property, 2: Namespace for an Interactivity API store. */
						__( 'Uncaught error executing a derived state callback with path "%1$s" and namespace "%2$s".' ),
						$path,
						$ns
					),
					'6.6.0'
				);
				return null;
			} finally {
				// Remove the property's namespace from the stack.
				array_pop( $this->namespace_stack );
			}
		}
	}

	// Returns the opposite if it contains a negation operator (!).
	return $should_negate_value ? ! $current : $current;
}

/**
 * Extracts the directive attribute name to separate and return the directive
 * prefix and an optional suffix.
 *
 * The suffix is the string after the first double hyphen and the prefix is
 * everything that comes before the suffix.
 *
 * Example:
 *
 *     extract_prefix_and_suffix( 'data-wp-interactive' )   => array( 'data-wp-interactive', null )
 *     extract_prefix_and_suffix( 'data-wp-bind--src' )     => array( 'data-wp-bind', 'src' )
 *     extract_prefix_and_suffix( 'data-wp-foo--and--bar' ) => array( 'data-wp-foo', 'and--bar' )
 *
 * @since 6.5.0
 *

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.