Description
Implement the [bw_api] shortcodeWhen coded as [bw_api]some php code[/bw_api] then this shortcode produces dynamic API documentation When the funcname parameter is not specified then we assume this is being invoked for current post – which is an API If we find the funcname (and sourcefile and plugin) then we can build the apiref including the callers and callees
Usage
$string = oikai_apiref( $atts, $content, $tag );Parameters
- $atts
- ( array ) optional – { shortcode parameters
- $funcname
- ( string ) optional – the API function name which may be class::method ?
- $sourcefile
- ( string ) optional – the implementing sourcefile
- $plugin
- ( string ) optional – the implementing plugin }
- $content
- ( string ) optional – PHP source to be dynamically documented
- $tag
- ( string ) optional – the shortcode name
Returns
string generated HTMLSource
File name: oik-shortcodes/shortcodes/oik-api-importer.phpLines:
1 to 65 of 65
function oikai_apiref( $atts=null, $content=null, $tag=null ) { $is_bot_maybe = oiksc_is_bot_maybe(); if ( $is_bot_maybe ) { p( "You appear to be a bot. Output may be restricted" ); } oiksc_autoload(); $funcname = bw_array_get( $atts, "funcname", null ); $sourcefile = bw_array_get( $atts, "sourcefile", null ); $plugin = bw_array_get( $atts, "plugin", null ); $classname = null; $post_id = null; if ( $content ) { oikai_build_dynamic_docs( $content ); } else { if ( !$funcname ) { oik_require( "includes/bw_posts.php" ); $post_id = bw_global_post_id(); bw_trace2( $post_id, "post_id", true, BW_TRACE_VERBOSE ); $sourcefile = get_post_meta( $post_id, "_oik_api_source", true ); if ( $sourcefile ) { $plugin_id = get_post_meta( $post_id, "_oik_api_plugin", true ); if ( $plugin_id ) { $plugin = get_post_meta( $plugin_id, "_oikp_slug", true ); // It may be a theme so try for _oikth_slug if ( !$plugin ) { $plugin = get_post_meta( $plugin_id, "_oikth_slug", true ); } if ( $plugin ) { $funcname = get_post_meta( $post_id, "_oik_api_name", true ); $classname = oikai_get_noderef_value( $post_id, "_oik_api_class", "_oik_class_name" ); //$title = get_the_title(); //$title = str_replace( "(", " ", $title ); //$title = str_replace( ")", " ", $title ); //$title = str_replace( array( "(",")","-"), " ", $title ); //list( $funcname, $rest) = explode( " ", $title. " .", 2 ); } else { e( "Plugin not found for oik_api" ); } } else { e( "Plugin not defined for this API" ); } } else { e( "Sourcefile not defined for $post_id" ); } } if ( $funcname ) { oikai_build_apiref( $funcname, $sourcefile, $plugin, $classname, $post_id, true, $plugin_id ); if ( $post_id ) { oik_require( "shortcodes/oik-apilink.php", "oik-shortcodes" ); if ( !$is_bot_maybe ) { oikai_list_callers_callees( $post_id ); do_action( "bw_metadata", $post_id ); } } } else { e( "bw_api cannot determine the funcname" ); } } return( bw_ret() ); }View on GitHub
Called by
Invoked by
Calls
1 to 8 of 8
- bw_array_get() – Return the array[index] or array->index (for an object) or a default value if not set
- bw_ret() – Use bw_ret() to return the contents of $bwecho, leaving the global value as NULL
- bw_trace2() – Trace $value to the trace log file if tracing is active
- oikai_build_apiref() – Automatically create the API reference
- oikai_build_dynamic_docs() – Build some dynamic documentation from the embedded content
- oikai_get_noderef_value() – Get the string value for a noderef
- oikai_list_callers_callees() – List the callers and callees for the selected oik_api including information about hooks
- oiksc_autoload() – Enable autoloading
