如果您得到所有的短代码,则在全局$shortcode_tags
. 您可以循环使用此短代码,并通过标记或函数进行过滤。
foreach( $shortcode_tags as $tag => $function ) {
}
如果
$function
是一个数组,那么也可以读取参数。请参阅以下来源。我认为源代码比我的英语更容易理解;)
/**
* Get all shortocdes and his data
*
* @return String
*/
function get_shortcodes() {
global $shortcode_tags;
$style = \'\';
$output = \'<h4>Total Shortcodes: \' . count( $shortcode_tags ) . \'</h4>\';
$output .= \'<ol>\';
foreach( $shortcode_tags as $tag => $function ) {
$style = ( \' class="alternate"\' == $style ) ? \'\' : \' class="alternate"\';
if ( is_string( $function ) ) {
$function = \'<code>\' . $function . \'</code>\';
} else if ( is_array( $function ) ) {
$object = \'\';
$parameters = \'\';
if ( is_string( $function[0] ) ) {
$object = $function[0];
} else if ( is_object( $function[0] ) ) {
$object = get_class( $function[0] );
foreach ( $function[0] as $parameter => $value ) {
// if the array is empty
if ( empty( $value ) )
$value = __( \'The Array is empty\' );
$parameters .= \'<li><code>\' . $parameter . \'</code> => <code>\' . $value . \'</code></li>\';
}
}
if ( ! empty( $parameters ) )
$parameters = \'<br><strong>Parameters of class:</strong><ul>\' . $parameters . \'</ul>\';
$function = \'<code>\' . $object . \'::\' . $function[1] . \'</code>\' . $parameters;
}
else {
$function = \'empty\';
}
$output .= "<li$style><strong>Shortcode: </strong><code>$tag</code> <strong>Function: </strong>$function</li>";
}
$output .= \'</ol>\';
echo $output;
}