wp_doc_link_parse

The WordPress Core wp doc link parse function.

Description

(array) wp_doc_link_parse( (string) $content ); 

Returns (array)

Parameters (1)

0. $content (string)
The content.

Usage

  1. if ( !function_exists( 'wp_doc_link_parse' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/misc.php'; 
  3.  
  4. // The content. 
  5. $content = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_doc_link_parse($content); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/misc.php  
  1. function wp_doc_link_parse( $content ) { 
  2. if ( !is_string( $content ) || empty( $content ) ) 
  3. return array(); 
  4.  
  5. if ( !function_exists('token_get_all') ) 
  6. return array(); 
  7.  
  8. $tokens = token_get_all( $content ); 
  9. $count = count( $tokens ); 
  10. $functions = array(); 
  11. $ignore_functions = array(); 
  12. for ( $t = 0; $t < $count - 2; $t++ ) { 
  13. if ( ! is_array( $tokens[ $t ] ) ) { 
  14. continue; 
  15.  
  16. if ( T_STRING == $tokens[ $t ][0] && ( '(' == $tokens[ $t + 1 ] || '(' == $tokens[ $t + 2 ] ) ) { 
  17. // If it's a function or class defined locally, there's not going to be any docs available 
  18. if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ) ) ) || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) ) { 
  19. $ignore_functions[] = $tokens[$t][1]; 
  20. // Add this to our stack of unique references 
  21. $functions[] = $tokens[$t][1]; 
  22.  
  23. $functions = array_unique( $functions ); 
  24. sort( $functions ); 
  25.  
  26. /** 
  27. * Filters the list of functions and classes to be ignored from the documentation lookup. 
  28. * @since 2.8.0 
  29. * @param array $ignore_functions Functions and classes to be ignored. 
  30. */ 
  31. $ignore_functions = apply_filters( 'documentation_ignore_functions', $ignore_functions ); 
  32.  
  33. $ignore_functions = array_unique( $ignore_functions ); 
  34.  
  35. $out = array(); 
  36. foreach ( $functions as $function ) { 
  37. if ( in_array( $function, $ignore_functions ) ) 
  38. continue; 
  39. $out[] = $function; 
  40.  
  41. return $out;