<?php
require_once dirname( __DIR__ ) . '/core/bootstrap.php';

$dir = dirname( __DIR__ ) . '/src';
$files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $dir ) );
$calls = array();
foreach ( $files as $f ) {
	if ( $f->getExtension() !== 'php' ) {
		continue;
	}
	$c = file_get_contents( $f->getPathname() );
	preg_match_all( '/\b([a-z_][a-z0-9_]*)\s*\(/i', $c, $m );
	foreach ( $m[1] as $fn ) {
		if ( preg_match( '/^(wp_|get_|the_|is_|has_|esc_|__|_e|_n|add_|submit_|settings_|wpautop|number_format)/', $fn ) ) {
			$calls[ $fn ] = ( $calls[ $fn ] ?? 0 ) + 1;
		}
	}
}
$skip = array( 'echo', 'print', 'isset', 'empty', 'define', 'class_exists', 'function_exists' );
foreach ( array_keys( $calls ) as $fn ) {
	if ( ! function_exists( $fn ) && ! in_array( $fn, $skip, true ) ) {
		echo $fn . ' (' . $calls[ $fn ] . ")\n";
	}
}
