Sharing varible between two add_actions

First of all, the order in which you use add_action is not relevant. The only thing it does is keep a tab of actions to undertake once the hook is encountered. Only when there are several functions on the same hook, the priority of the added action becomes relevant (read more). So, if your global … Read more

The function called on the wp head hook becomes null

As an alternative you could try declaring it with $GLOBALS[‘a3’] in file2 to make sure it becomes a global: $GLOBALS[‘a3′] = Sample_Class::instance(); I’d guess the current $a3 declaration in file2’s top level scope doesn’t count as global because it gets inluded inside the test_loaded() scope. From the ‘include’ docs (which cover require and require_once too): … Read more

Where do I hook to have the server do something in PHP on block attribute change?

I’m not sure that I understood exactly your goal, but check if hooking to render_block does what you want, as it will modify the block’s output before it gets rendered in the frontend. Usage example: add_filter( ‘render_block’, ‘my_dynamic_data’, 10, 2 ); function my_dynamic_data( $block_content, $block ) { if(‘my_value’ === $block[‘attrs’][‘myAttribute’] ) { // Do something … Read more

do_action won’t work in ajax callback

Note: OP and me resolved the question/issue via chat — and despite the actual problem source is not known for sure, in the actual AJAX callback used by OP, there was actually no (or maybe OP had forgotten to make the) do_action() call. 🙂 Original Revised Answer (for reference): If you have something like so … Read more