Skip to content

Instantly share code, notes, and snippets.

@kopepasah
Created September 27, 2013 14:52
Show Gist options
  • Save kopepasah/6729843 to your computer and use it in GitHub Desktop.
Save kopepasah/6729843 to your computer and use it in GitHub Desktop.
Much like the other lists I created here, this will list Exchange functions.
<?php
$GLOBALS['functions'] = array();
function list_theme_functions( $directory ) {
global $functions;
$files = array_diff( scandir( $directory ), array( '.', '..', '_list-files.php', '_list-hooks.php', '_get-contents.php', '.DS_Store', 'nonce.php', '_list-hooks-duplicates.php', '_list-functions.php' ) );
foreach ( $files as $file ) {
if ( dirname( __FILE__ ) == $directory ) {
if ( is_dir( $directory . '/' . $file ) ) {
$folder = $file . '.php';
}
if ( $folder != $file ) {
if ( is_dir( $file ) ) {
if ( preg_match_all( "|" . preg_quote( 'it_exchange(' ) . "(.*?)\)|", file_get_contents( dirname( __FILE__ ) . '/' . $file . '.php' ), $matches ) ) {
$actions = str_replace( ' ', '', str_replace( '<?php ', '', str_replace( ');', ')', $matches[0] ) ) );
foreach ( $actions as $action ) {
$action = explode( '\'', $action );
// echo '*[[Exchange_Theme_API:_' . $action[1] . '_(' . $action[3] . ')|it_exchange( \'' . $action[1] . '\', \'' . $action[3] . '\' )]]' . "\n";
$functions[$action[1]][$action[3]] = '*[[Exchange_Theme_API:_' . $action[1] . '_(' . $action[3] . ')|it_exchange( \'' . $action[1] . '\', \'' . $action[3] . '\' )]]';
}
}
} else {
if ( preg_match_all( "|" . preg_quote( 'it_exchange(' ) . "(.*?)\)|", file_get_contents( dirname( __FILE__ ) . '/' . $file ), $matches ) ) {
$actions = str_replace( ' ', '', str_replace( '<?php ', '', str_replace( ');', ')', $matches[0] ) ) );
foreach ( $actions as $action ) {
$action = explode( '\'', $action );
// echo '*[[Exchange_Theme_API:_' . $action[1] . '_(' . $action[3] . ')|it_exchange( \'' . $action[1] . '\', \'' . $action[3] . '\' )]]' . "\n";
$functions[$action[1]][$action[3]] = '*[[Exchange_Theme_API:_' . $action[1] . '_(' . $action[3] . ')|it_exchange( \'' . $action[1] . '\', \'' . $action[3] . '\' )]]';
}
}
}
}
} else {
if ( ! is_dir( $directory . '/' . $file ) ) {
if ( preg_match_all( "|" . preg_quote( 'it_exchange(' ) . "(.*?)\)|", file_get_contents( $directory . '/' . $file ), $matches ) ) {
$actions = str_replace( ' ', '', str_replace( '<?php ', '', str_replace( ');', ')', $matches[0] ) ) );
foreach ( $actions as $action ) {
$action = explode( '\'', $action );
// echo '*[[Exchange_Theme_API:_' . $action[1] . '_(' . $action[3] . ')|it_exchange( \'' . $action[1] . '\', \'' . $action[3] . '\' )]]' . "\n";
$functions[$action[1]][$action[3]] = '*[[Exchange_Theme_API:_' . $action[1] . '_(' . $action[3] . ')|it_exchange( \'' . $action[1] . '\', \'' . $action[3] . '\' )]]';
}
}
}
}
if ( is_dir( $directory . '/' . $file ) )
list_theme_functions( $directory . '/' . $file );
}
}
list_theme_functions( dirname( __FILE__ ) );
header('Content-Type: text/plain');
foreach ( $functions as $context => $tag ) {
echo "\n===" . ucwords( str_replace( '-', ' ', $context ) ) . "===\n";
foreach ( $tag as $link ) {
echo $link . "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment