PHP code example of wp-hooks / wordpress-core

1. Go to this page and download the library: Download wp-hooks/wordpress-core library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wp-hooks / wordpress-core example snippets


// Get hooks as JSON:
$actions_json = file_get_contents( 'vendor/wp-hooks/wordpress-core/hooks/actions.json' );
$filters_json = file_get_contents( 'vendor/wp-hooks/wordpress-core/hooks/filters.json' );

// Convert hooks to PHP:
$actions = json_decode( $actions_json, true )['hooks'];
$filters = json_decode( $filters_json, true )['hooks'];

// Search for filters matching a string:
$search = 'permalink';
$results = array_filter( $filters, function( array $hook ) use ( $search ) {
    return ( false !== strpos( $hook['name'], $search ) );
} );

var_dump( $results );