Skip to content
This repository was archived by the owner on Jul 28, 2023. It is now read-only.
This repository was archived by the owner on Jul 28, 2023. It is now read-only.

SSR: Audit usage of wp_process_directives #148

@ockham

Description

@ockham

@DAreRodz shared the following feedback with me in Slack:

I have a couple of questions regarding directives evaluation and wp-context:

I see that directives run inside wp_process_directives(), a callback added to the render_block hook—dispatched every time a block has rendered—, and uses WP_HTML_Tag_Processor to iterate over the HTML content, find the directives, and execute them.

The questions are:

  1. Isn’t that callback running several times for the same HTML?. E.g., if you have a block A and a block B inside A, both blocks will dispatch render_block when rendered. Won’t B's directives run twice, one when render_block is dispatched for B and a second one for A (that would include B in its $block_content)?
  2. WP_Directive_Context is instantiated for each render_block execution. Doesn’t it create a different context stack for each block? I guess it works in the end because we run directives inside inner blocks again (as mentioned in question 1.)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions