• Basically, I want to load some data in the block editor that is responsible for rendering the block’s HTML, through REST API which I was previously loading through a Localized variable.

    But, I want the REST API to load the data working before any blocks load.

    When I was sending that data from a localize variable then it was working fine, but it is not very memory efficient.

    Can someone please help me with this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    There is no PHP hook just before blocks are loaded because it’s all done via client side scripting. You could use a hook that fires just before the editor is loaded. Look through /wp-admin/edit-form-blocks.php source code for likely candidates.

    I suppose you could use the ‘filter_block_editor_meta_boxes’ filter like an action hook. Except return the passed meta boxes array unchanged. You can still do whatever you need done just before the the editor is loaded. The current post object is available as global $post.

    Thread Starter Rajkiran Bagal

    (@rajkiranb)

    Hey @bcworkz,

    I want a JS action or hook that gets called before blocks are loaded in the editor.

    Can you suggest any?

    Moderator bcworkz

    (@bcworkz)

    Sorry, I’m not familiar with the inner workings of the editor. The source code is freely available. Dig in and see what you can find ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Is there any action that runs on load of editor before the blocks are loaded?’ is closed to new replies.