[oik] plugins.com

WordPress plugins and themes

  • Home
  • About
    • lazy shortcodes
    • smart shortcodes
    • oik base plugin
      • oik – donate
      • oik PayPal buttons
      • oik installation
      • oik Button Shortcode button
      • oik changelog
      • oik FAQ
      • oik plugins on SVN
      • oik plugins on GitHub
  • Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins
    • Bespoke oik plugins
  • Shortcodes
    • Shortcode examples
  • Blocks
    • Block examples
  • APIs
    • ALL action and filter hooks
  • Blog

oikai_apiref() – Implement the [bw_api] shortcode

Description

Implement the [bw_api] shortcode

When 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 HTML

Source

File name: oik-shortcodes/shortcodes/oik-api-importer.php
Lines:
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

      Call hooks

      1 to 1 of 1
      • bw_metadata – action
      Function name: oikai_apiref
      Plugin ref: oik block shortcode and API server
      Version: 1.41.5
      Sourcefile: shortcodes/oik-api-importer.php
      File ref: shortcodes/oik-api-importer.php
      API type: shortcode
      Deprecated?: No
      API Letters: A,O

      Published: March 11, 2017 | Last updated: March 11, 2017

      Information

      Function name: oikai_apiref
      Plugin ref: oik block shortcode and API server
      Version: 1.41.5
      Sourcefile: shortcodes/oik-api-importer.php
      File ref: shortcodes/oik-api-importer.php
      API type: shortcode
      Deprecated?: No
      API Letters: A,O

      Recent plugin updates

      oik-weight-zone-shipping v0.2.13 oik-weight-zone-shipping v0.2.13 has been tested with WooCommerce 10.1.2 and WordPress 6.8.2 ...
      SB Children Block v1.3.0 Upgrade to SB Children Block v1.3.0 for support for PHP 8.3 and PHP 8.4  ...
      oik v4.15.3 Update to oik v4.15.3 for a couple of security fixes. Tested with WordPress 6.8.2 ...
      oik-privacy-policy v1.4.9 Update to oik-privacy-policy v1.4.9 for a security fix. Tested with WordPress 6.8.2 and PHP 8.3 and PHP 8.4 ...
      oik-nivo-slider v1.17.0 oik-nivo-slider v1.17.0 introduces the Nivo slider block - oik-nivo-slider/nivo. ...

      Plugins

      • All Plugins
      • oik base plugin
      • FREE oik plugins
      • WordPress plugins
      • Premium oik plugins

      Themes

      • FREE themes
      • Bespoke themes
      • Premium themes

      Blocks

      • All Blocks
      • Block examples
      • About Blocks

      Shortcodes

      • All Shortcodes
      • Shortcode examples
      • About Shortcodes

      Reference

      • About APIs
      • All APIs
      • All Classes
      • All Files
      • All Hooks

      Support

      • Contact
      • Cookies policy
      • Get API key
      • Privacy
      • Request support
      • Sitemap
      • Stay informed
      • Terms and Conditions
      oik-plugins
      Email: herb@bobbingwide.com

      Weight shipping plugins

      Find out which cart weight shipping plugin you need for your WooCommerce site.
      Which cart weight based plugin do I need?

      Site:  www.oik-plugins.com
      © Copyright oik-plugins 2011-2025. All rights reserved.


      Website designed and developed by Herb Miller of Bobbing Wide
      Proudly powered by WordPress and oik-plugins

      WordPress version: 6.8.3

      Gutenberg version: 21.7.0

      PHP version: 8.2.29