|
<?php |
|
if ( ! function_exists( 'hippo_plugin_hook_info' ) ): |
|
|
|
function hippo_plugin_hook_info( $hook_name ) { |
|
global $wp_filter; |
|
|
|
$docs = array(); |
|
$template = "\t - %s Priority - %s.\n\tin file %s #%s\n\n"; |
|
|
|
echo '<pre>'; |
|
echo "\t# Hook Name \"" . $hook_name . "\""; |
|
echo "\n\n"; |
|
if ( isset( $wp_filter[ $hook_name ] ) ) { |
|
foreach ( $wp_filter[ $hook_name ] as $pri => $fn ) { |
|
|
|
foreach ( $fn as $fnname => $fnargs ) { |
|
|
|
if ( is_array( $fnargs[ 'function' ] ) ) { |
|
$reflClass = new ReflectionClass( $fnargs[ 'function' ][ 0 ] ); |
|
$reflFunc = $reflClass->getMethod( $fnargs[ 'function' ][ 1 ] ); |
|
$class = $reflClass->getName(); |
|
$function = $reflFunc->name; |
|
} else { |
|
$reflFunc = new ReflectionFunction( $fnargs[ 'function' ] ); |
|
$class = FALSE; |
|
$function = $reflFunc->name; |
|
$isClosure = (bool) $reflFunc->isClosure(); |
|
} |
|
|
|
if ( $class ) { |
|
$functionName = sprintf( 'Class "%s::%s"', $class, $function ); |
|
} else { |
|
$functionName = ( $isClosure ) ? "Anonymous Function $function" : "Function \"$function\""; |
|
} |
|
|
|
printf( $template, $functionName, $pri, str_ireplace( ABSPATH, '', $reflFunc->getFileName() ), $reflFunc->getStartLine() ); |
|
|
|
$docs[] = array( $functionName, $pri ); |
|
} |
|
} |
|
|
|
echo "\tAction Hook Commenting\n\t----------------------\n\n"; |
|
echo "\t/**\n\t* " . $hook_name . " hook\n\t*\n"; |
|
foreach ( $docs as $doc ) { |
|
echo "\t* @hooked " . $doc[ 0 ] . " - " . $doc[ 1 ] . "\n"; |
|
} |
|
echo "\t*/"; |
|
echo "\n\n"; |
|
echo "\tdo_action( '" . $hook_name . "' );"; |
|
|
|
} |
|
echo '</pre>'; |
|
} |
|
endif; |