How can I obtain an option (get_option) inside a block viewScript?
So, if I want to add any custom styles or scripts in a block’s CSS or JS file, I usually add them in the PHP file associated with the block (the render property in block.json). Add the following code to the PHP file at the end – $beautiful_option = get_option(‘beautiful’); wp_add_inline_script(‘some-script’, ‘const BEAUTIFUL_OPTION=’ .$beautiful_option, ‘before’); … Read more