oikai_handle_token_T_STRING() – Handle a T_STRING token

You appear to be a bot. Output may be restricted

Description

Handle a T_STRING token

Identifiers, e.g. keywords like parent and self, function names, class names and more are matched as T_STRING tokens. We treat just about every string as a possible function name. So first of all we concoct the name that it could be using recently handled tokens. We use oikai_determine_function_type() to find out if the API is a PHP function ( "internal" ) or one we might recognise or one of WordPress'es. If it's one of ours then we'll also record the fact that this function calls this API.

Usage

$ID = oikai_handle_token_T_STRING( $key, $token, $tokens, $doaction );

Parameters

$key
( mixed ) required
$token
( mixed ) required
$tokens
( mixed ) required
$doaction
( bool ) optional default: 1 – whether or not to invoke the action that adds this as a called function.

Returns

ID post_id of the API if it's one of ours, or null

TO DO

But should this alter the context? $value = $post_id; ? At the end of processing we reset the context.

Source

File name: oik-shortcodes/shortcodes/oik-api-importer.php
Lines:

1 to 41 of 41
function oikai_handle_token_T_STRING( $key, $token, &$tokens, $doaction=true  ) {
  bw_trace2( null, null, true, BW_TRACE_VERBOSE );
  $post_id = null;
  if ( is_array( $token ) ) {
    $value = $token[1];
  } else { 
    $value = $token;
  } 
  oik_require( "shortcodes/oik-apilink.php", "oik-shortcodes" );
  $api_name = oikai_concoct_api_name( $value );
  //br( "handle T_STRING,$value,$key,$api_name," ); 
  $type = oikai_determine_function_type( $api_name );
  switch ( $type ) {
    case 'internal':
      $tokens[$key][3] = oikai_link_to_php( $api_name );
      $post_id = null;
      break;

    case 'oik_api':
    case 'oik_class':
    case 'oik_file':
    case 'oik_hook':
      $wordpress_cache = oiksc_load_wordpress_cache();
      $tokens[$key][3] = $wordpress_cache->get_wordpress_link( $api_name );
      break;

    default:

    if ( is_multisite() ) {
      $post_id = oikai_pragmatic_link_to_api( $key, $tokens, $api_name, $doaction, $type );
    } else {
      $post_id = oikai_link_to_local_site( $key, $tokens, $api_name, $doaction, $type, $value );
    }

  }
  if ( $doaction ) {
    //br( "calling set_context with !$value! !$post_id!" );      
    oikai_set_context( $value ); 
  }  
  return( $post_id ); 
}