Description
Determine the api typeDetermine if the function implements an action, filter, shortcode OR other dynamic API type such as shortcode help, shortcode syntax, shortcode example AND if so the value(s) that it implements Note: It's not expected to implement more than one type BUT can implement it for more than one of them. e.g. filter and action If an API implements a filter and an action then it should be classified as a filter. We use the following methods to detect the API type:
- docblock short description: Implements "name" type for etc where type is "action", "filter" or "shortcode" and name is the name
- parms are $atts, $content, $tag then it's a "shortcode"
- funcname contains end's with "__blah" then it's a "hook"
- funcname starts with _ – suggests it's private
- $funcname
- ( mixed ) required –
- $refFunc
- ( mixed ) required –
- $docblock
- ( mixed ) required –
- oikai_choose_desc() – Decide what to use for the "Description"
- oikai_funcname_analysis() – Detect "hook" type functions that end with a hook suffix e.g. __help
- oikai_function_implements() – Return information about the function implementing something
- oikai_parm_match() – Attempt to determine the API type based on the parameters
Usage
oikai_api_type( $funcname, $refFunc, $docblock );Parameters
Returns
voidSource
File name: oik-shortcodes/admin/oik-apitype.phpLines:
1 to 18 of 18
function oikai_api_type( $funcname, $refFunc, $docblock ) { $type = null; $desc = oikai_choose_desc( $docblock, $funcname ); if ( $type = oikai_function_implements( $desc ) ) { // We've determined the type from the Description and it's already in an array } elseif ( $type[0] = oikai_parm_match( $funcname, $refFunc, $docblock ) ) { // We've determined the type from the parameters } elseif ( $type[0] = oikai_funcname_analysis( $funcname ) ) { // We've determined the type from the funcname } elseif ( $funcname[0] == '_' ) { $type[0] = "private"; } else { $type[0] = ""; } $type[2] = $desc; return( $type ); }View on GitHub
Called by
1 to 1 of 1
Invoked by
Calls
1 to 4 of 4
