How to add single function for all WordPress hooks

There is a special action all that you can use. Be aware, this will be very slow, don’t do that in production.

Here is an example:

add_action( 'all', function() {

    static $hooks = [];

    $filter = current_filter();

    if ( isset ( $hooks[ $filter ] ) )
        return;

    $types  = array_map( function ( $arg ) {
        return gettype( $arg );
    }, func_get_args() );

    $hooks[ $filter ]  = count( $types ) . ' arguments: ' . join( ",\t", $types );

    if ( 'shutdown' !== $filter )
        return;

    $text = "\n\nFILE: " . $_SERVER['REQUEST_URI'] . ' ' . date( 'Y.m.d. H:i:s' ) . "\n\n";

    foreach ( $hooks as $hook => $args )
        $text .= str_pad( $hook, 50 ) . " => $args\n";

    $file = WP_CONTENT_DIR . '/hook.log';
    file_put_contents( $file, $text, FILE_APPEND | LOCK_EX );
});

Now you get all hooks listed in a file hooks.log. Sample output:

FILE: /wp-admin/admin-ajax.php 2015.03.29. 17:25:41

muplugins_loaded                                   => 1 arguments: string
pre_site_option_siteurl                            => 2 arguments: string,  boolean
site_option_siteurl                                => 2 arguments: string,  string
pre_option_siteurl                                 => 2 arguments: string,  boolean
option_siteurl                                     => 2 arguments: string,  string
gettext_with_context                               => 5 arguments: string,  string, string, string, string
gettext                                            => 4 arguments: string,  string, string, string
registered_taxonomy                                => 4 arguments: string,  string, string, array
sanitize_key                                       => 3 arguments: string,  string, string
post_type_labels_post                              => 2 arguments: string,  object
registered_post_type                               => 3 arguments: string,  string, object
post_type_labels_page                              => 2 arguments: string,  object
post_type_labels_attachment                        => 2 arguments: string,  object
post_type_labels_revision                          => 2 arguments: string,  object
post_type_labels_nav_menu_item                     => 2 arguments: string,  object
theme_root                                         => 2 arguments: string,  string
pre_option_active_plugins                          => 2 arguments: string,  boolean
…