No hay ningún script o complemento que yo sepa para hacer lo que quieres. Como ha indicado, hay scripts ( incluso variables globales ) que puede usar para imprimir filtros y acciones que se están utilizando actualmente.
En cuanto a los filtros y acciones latentes, escribí dos funciones muy básicas ( con algo de ayuda aquí y allá ) que encuentran todas las instancias apply_filters
y do_action
en un archivo y luego las imprimen fuera
BÁSICOS
-
Usaremos las clases PHP RecursiveDirectoryIterator
, RecursiveIteratorIterator
y RegexIterator
para obtener todos los archivos PHP dentro de un directorio. Como ejemplo, en mi host local, he usado E:\xammp\htdocs\wordpress\wp-includes
-
Luego recorreremos los archivos y buscaremos y devolveremos ( preg_match_all
) todas las instancias de apply_filters
y do_action
. Lo he configurado para que coincida con las instancias anidadas de paréntesis y también para que coincida con espacios en blanco posibles entre apply_filters
/ do_action
y el primer paréntesis
Simplemente crearemos una matriz con todos los filtros y acciones y luego recorreremos la matriz y emitiremos el nombre del archivo, los filtros y las acciones. Vamos a saltar archivos sin filtros / acciones
NOTAS IMPORTANTES
-
Estas funciones son muy caras. Ejecutarlos solo en una instalación de prueba local.
-
Modifique las funciones según sea necesario. Puede decidir escribir la salida en un archivo, crear una página especial para eso, las opciones son ilimitadas
OPCIÓN 1
La primera función de opciones es muy simple, devolveremos el contenido de un archivo como una cadena usando file_get_contents
, buscaremos las instancias apply_filters
/ do_action
y simplemente mostraremos el nombre de archivo y los nombres de filtro / acción
He comentado el código para un fácil seguimiento
function get_all_filters_and_actions( $path = '' )
{
//Check if we have a path, if not, return false
if ( !$path )
return false;
// Validate and sanitize path
$path = filter_var( $path, FILTER_SANITIZE_URL );
/**
* If valiadtion fails, return false
*
* You can add an error message of something here to tell
* the user that the URL validation failed
*/
if ( !$path )
return false;
// Get each php file from the directory or URL
$dir = new RecursiveDirectoryIterator( $path );
$flat = new RecursiveIteratorIterator( $dir );
$files = new RegexIterator( $flat, '/\.php$/i' );
if ( $files ) {
$output = '';
foreach($files as $name=>$file) {
/**
* Match and return all instances of apply_filters(**) or do_action(**)
* The regex will match the following
* - Any depth of nesting of parentheses, so apply_filters( 'filter_name', parameter( 1,2 ) ) will be matched
* - Whitespaces that might exist between apply_filters or do_action and the first parentheses
*/
// Use file_get_contents to get contents of the php file
$get_file_content = file_get_contents( $file );
// Use htmlspecialchars() to avoid HTML in filters from rendering in page
$save_content = htmlspecialchars( $get_file_content );
preg_match_all( '/(apply_filters|do_action)\s*(\([^()]*(?:(?-1)[^()]*)*+\))/', $save_content, $matches );
// Build an array to hold the file name as key and apply_filters/do_action values as value
if ( $matches[0] )
$array[$name] = $matches[0];
}
foreach ( $array as $file_name=>$value ) {
$output .= '<ul>';
$output .= '<strong>File Path: ' . $file_name .'</strong></br>';
$output .= 'The following filters and/or actions are available';
foreach ( $value as $k=>$v ) {
$output .= '<li>' . $v . '</li>';
}
$output .= '</ul>';
}
return $output;
}
return false;
}
Puede utilizar en follow en una plantilla, frontend o backend
echo get_all_filters_and_actions( 'E:\xammp\htdocs\wordpress\wp-includes' );
Esto se imprimirá

OPCIÓN2
Estaopciónesunpocomáscaradeejecutar.Estafuncióndevuelveelnúmerodelíneadondesepuedeencontrarelfiltro/acción.
Aquíusamosfile
paraexplotarelarchivoenunamatriz,luegobuscamosydevolvemoselfiltro/acciónyelnúmerodelínea
functionget_all_filters_and_actions2($path=''){//Checkifwehaveapath,ifnot,returnfalseif(!$path)returnfalse;//Validateandsanitizepath$path=filter_var($path,FILTER_SANITIZE_URL);/***Ifvaliadtionfails,returnfalse**Youcanaddanerrormessageofsomethingheretotell*theuserthattheURLvalidationfailed*/if(!$path)returnfalse;//GeteachphpfilefromthedirectoryorURL$dir=newRecursiveDirectoryIterator($path);$flat=newRecursiveIteratorIterator($dir);$files=newRegexIterator($flat,'/\.php$/i');if($files){$output='';$array=[];foreach($filesas$name=>$file){/***Matchandreturnallinstancesofapply_filters(**)ordo_action(**)*Theregexwillmatchthefollowing*-Anydepthofnestingofparentheses,soapply_filters('filter_name',parameter(1,2))willbematched*-Whitespacesthatmightexistbetweenapply_filtersordo_actionandthefirstparentheses*///Usefile_get_contentstogetcontentsofthephpfile$get_file_contents=file($file);foreach($get_file_contentsas$key=>$get_file_content){preg_match_all('/(apply_filters|do_action)\s*(\([^()]*(?:(?-1)[^()]*)*+\))/',$get_file_content,$matches);if($matches[0])$array[$name][$key+1]=$matches[0];}}if($array){foreach($arrayas$file_name=>$values){$output.='<ul>';$output.='<strong>FilePath:'.$file_name.'</strong></br>';$output.='Thefollowingfiltersand/oractionsareavailable';foreach($valuesas$line_number=>$string){$whitespaces=' ';$output.='<li>Linereference'.$line_number.$whitespaces.$string[0].'</li>';}$output.='</ul>';}}return$output;}returnfalse;}
Puedeutilizarenfollowenunaplantilla,frontendobackend
echoget_all_filters_and_actions2('E:\xammp\htdocs\wordpress\wp-includes');
Estoseimprimirá
EDITAR
Esto es básicamente todo lo que puedo hacer sin que los scripts se agoten o se queden sin memoria. Con el código en la opción 2, es tan fácil como ir a dicho archivo y dicha línea en el código fuente y luego obtener todos los valores de los parámetros válidos del filtro / acción, además de obtener la función y el contexto adicional en el que Se utiliza el filtro / acción