Skip to content

Instantly share code, notes, and snippets.

@JodiWarren
Last active December 2, 2015 11:53
Show Gist options
  • Select an option

  • Save JodiWarren/01065d36f0ac38c56c7f to your computer and use it in GitHub Desktop.

Select an option

Save JodiWarren/01065d36f0ac38c56c7f to your computer and use it in GitHub Desktop.
Use this snippet to move all hooked actions from one hook to another. Very useful for moving hooked items to the footer. Use carefully.
<?php
global $wp_filter;
$hook_to_check = 'nameOfHook';
$destination_hook = 'wp_footer';
$acf_front_end_scripts = $wp_filter[$hook_to_check];
foreach ( $acf_front_end_scripts as $scripts ) {
foreach ( $scripts as $script ) {
remove_action( $hook_to_check, $script['function'] );
add_action( $destination_hook, $script['function'], $script['accepted_args'] );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment