wp_doc_link_parse

The timeline below displays how wordpress function wp_doc_link_parse has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * @since 2.8.0
 *
 * @param string $content
 * @return array
 */
function wp_doc_link_parse($content)
{
    if (!is_string($content) || empty($content)) {
        return array();
    }
    if (!function_exists('token_get_all')) {
        return array();
    }
    $tokens = token_get_all($content);
    $count = count($tokens);
    $functions = array();
    $ignore_functions = array();
    for ($t = 0; $t < $count - 2; $t++) {
        if (!is_array($tokens[$t])) {
            continue;
        }
        if (T_STRING === $tokens[$t][0] && ('(' === $tokens[$t + 1] || '(' === $tokens[$t + 2])) {
            // If it's a function or class defined locally, there's not going to be any docs available.
            if (isset($tokens[$t - 2][1]) && in_array($tokens[$t - 2][1], array('function', 'class'), true) || isset($tokens[$t - 2][0]) && T_OBJECT_OPERATOR === $tokens[$t - 1][0]) {
                $ignore_functions[] = $tokens[$t][1];
            }
            // Add this to our stack of unique references.
            $functions[] = $tokens[$t][1];
        }
    }
    $functions = array_unique($functions);
    sort($functions);
    /**
     * Filters the list of functions and classes to be ignored from the documentation lookup.
     *
     * @since 2.8.0
     *
     * @param string[] $ignore_functions Array of names of functions and classes to be ignored.
     */
    $ignore_functions = apply_filters('documentation_ignore_functions', $ignore_functions);
    $ignore_functions = array_unique($ignore_functions);
    $output = array();
    foreach ($functions as $function) {
        if (in_array($function, $ignore_functions, true)) {
            continue;
        }
        $output[] = $function;
    }
    return $output;
}

WordPress Version: 5.5

/**
 * @since 2.8.0
 *
 * @param string $content
 * @return array
 */
function wp_doc_link_parse($content)
{
    if (!is_string($content) || empty($content)) {
        return array();
    }
    if (!function_exists('token_get_all')) {
        return array();
    }
    $tokens = token_get_all($content);
    $count = count($tokens);
    $functions = array();
    $ignore_functions = array();
    for ($t = 0; $t < $count - 2; $t++) {
        if (!is_array($tokens[$t])) {
            continue;
        }
        if (T_STRING == $tokens[$t][0] && ('(' === $tokens[$t + 1] || '(' === $tokens[$t + 2])) {
            // If it's a function or class defined locally, there's not going to be any docs available.
            if (isset($tokens[$t - 2][1]) && in_array($tokens[$t - 2][1], array('function', 'class'), true) || isset($tokens[$t - 2][0]) && T_OBJECT_OPERATOR == $tokens[$t - 1][0]) {
                $ignore_functions[] = $tokens[$t][1];
            }
            // Add this to our stack of unique references.
            $functions[] = $tokens[$t][1];
        }
    }
    $functions = array_unique($functions);
    sort($functions);
    /**
     * Filters the list of functions and classes to be ignored from the documentation lookup.
     *
     * @since 2.8.0
     *
     * @param string[] $ignore_functions Array of names of functions and classes to be ignored.
     */
    $ignore_functions = apply_filters('documentation_ignore_functions', $ignore_functions);
    $ignore_functions = array_unique($ignore_functions);
    $out = array();
    foreach ($functions as $function) {
        if (in_array($function, $ignore_functions, true)) {
            continue;
        }
        $out[] = $function;
    }
    return $out;
}

WordPress Version: 5.4

/**
 * @since 2.8.0
 *
 * @param string $content
 * @return array
 */
function wp_doc_link_parse($content)
{
    if (!is_string($content) || empty($content)) {
        return array();
    }
    if (!function_exists('token_get_all')) {
        return array();
    }
    $tokens = token_get_all($content);
    $count = count($tokens);
    $functions = array();
    $ignore_functions = array();
    for ($t = 0; $t < $count - 2; $t++) {
        if (!is_array($tokens[$t])) {
            continue;
        }
        if (T_STRING == $tokens[$t][0] && ('(' == $tokens[$t + 1] || '(' == $tokens[$t + 2])) {
            // If it's a function or class defined locally, there's not going to be any docs available.
            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]) {
                $ignore_functions[] = $tokens[$t][1];
            }
            // Add this to our stack of unique references.
            $functions[] = $tokens[$t][1];
        }
    }
    $functions = array_unique($functions);
    sort($functions);
    /**
     * Filters the list of functions and classes to be ignored from the documentation lookup.
     *
     * @since 2.8.0
     *
     * @param string[] $ignore_functions Array of names of functions and classes to be ignored.
     */
    $ignore_functions = apply_filters('documentation_ignore_functions', $ignore_functions);
    $ignore_functions = array_unique($ignore_functions);
    $out = array();
    foreach ($functions as $function) {
        if (in_array($function, $ignore_functions)) {
            continue;
        }
        $out[] = $function;
    }
    return $out;
}

WordPress Version: 5.1

/**
 * @since 2.8.0
 *
 * @param string $content
 * @return array
 */
function wp_doc_link_parse($content)
{
    if (!is_string($content) || empty($content)) {
        return array();
    }
    if (!function_exists('token_get_all')) {
        return array();
    }
    $tokens = token_get_all($content);
    $count = count($tokens);
    $functions = array();
    $ignore_functions = array();
    for ($t = 0; $t < $count - 2; $t++) {
        if (!is_array($tokens[$t])) {
            continue;
        }
        if (T_STRING == $tokens[$t][0] && ('(' == $tokens[$t + 1] || '(' == $tokens[$t + 2])) {
            // If it's a function or class defined locally, there's not going to be any docs available
            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]) {
                $ignore_functions[] = $tokens[$t][1];
            }
            // Add this to our stack of unique references
            $functions[] = $tokens[$t][1];
        }
    }
    $functions = array_unique($functions);
    sort($functions);
    /**
     * Filters the list of functions and classes to be ignored from the documentation lookup.
     *
     * @since 2.8.0
     *
     * @param string[] $ignore_functions Array of names of functions and classes to be ignored.
     */
    $ignore_functions = apply_filters('documentation_ignore_functions', $ignore_functions);
    $ignore_functions = array_unique($ignore_functions);
    $out = array();
    foreach ($functions as $function) {
        if (in_array($function, $ignore_functions)) {
            continue;
        }
        $out[] = $function;
    }
    return $out;
}

WordPress Version: 4.6

/**
 * @since 2.8.0
 *
 * @param string $content
 * @return array
 */
function wp_doc_link_parse($content)
{
    if (!is_string($content) || empty($content)) {
        return array();
    }
    if (!function_exists('token_get_all')) {
        return array();
    }
    $tokens = token_get_all($content);
    $count = count($tokens);
    $functions = array();
    $ignore_functions = array();
    for ($t = 0; $t < $count - 2; $t++) {
        if (!is_array($tokens[$t])) {
            continue;
        }
        if (T_STRING == $tokens[$t][0] && ('(' == $tokens[$t + 1] || '(' == $tokens[$t + 2])) {
            // If it's a function or class defined locally, there's not going to be any docs available
            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]) {
                $ignore_functions[] = $tokens[$t][1];
            }
            // Add this to our stack of unique references
            $functions[] = $tokens[$t][1];
        }
    }
    $functions = array_unique($functions);
    sort($functions);
    /**
     * Filters the list of functions and classes to be ignored from the documentation lookup.
     *
     * @since 2.8.0
     *
     * @param array $ignore_functions Functions and classes to be ignored.
     */
    $ignore_functions = apply_filters('documentation_ignore_functions', $ignore_functions);
    $ignore_functions = array_unique($ignore_functions);
    $out = array();
    foreach ($functions as $function) {
        if (in_array($function, $ignore_functions)) {
            continue;
        }
        $out[] = $function;
    }
    return $out;
}

WordPress Version: 4.3

/**
 * @since 2.8.0
 *
 * @param string $content
 * @return array
 */
function wp_doc_link_parse($content)
{
    if (!is_string($content) || empty($content)) {
        return array();
    }
    if (!function_exists('token_get_all')) {
        return array();
    }
    $tokens = token_get_all($content);
    $count = count($tokens);
    $functions = array();
    $ignore_functions = array();
    for ($t = 0; $t < $count - 2; $t++) {
        if (!is_array($tokens[$t])) {
            continue;
        }
        if (T_STRING == $tokens[$t][0] && ('(' == $tokens[$t + 1] || '(' == $tokens[$t + 2])) {
            // If it's a function or class defined locally, there's not going to be any docs available
            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]) {
                $ignore_functions[] = $tokens[$t][1];
            }
            // Add this to our stack of unique references
            $functions[] = $tokens[$t][1];
        }
    }
    $functions = array_unique($functions);
    sort($functions);
    /**
     * Filter the list of functions and classes to be ignored from the documentation lookup.
     *
     * @since 2.8.0
     *
     * @param array $ignore_functions Functions and classes to be ignored.
     */
    $ignore_functions = apply_filters('documentation_ignore_functions', $ignore_functions);
    $ignore_functions = array_unique($ignore_functions);
    $out = array();
    foreach ($functions as $function) {
        if (in_array($function, $ignore_functions)) {
            continue;
        }
        $out[] = $function;
    }
    return $out;
}

WordPress Version: 4.0

function wp_doc_link_parse($content)
{
    if (!is_string($content) || empty($content)) {
        return array();
    }
    if (!function_exists('token_get_all')) {
        return array();
    }
    $tokens = token_get_all($content);
    $count = count($tokens);
    $functions = array();
    $ignore_functions = array();
    for ($t = 0; $t < $count - 2; $t++) {
        if (!is_array($tokens[$t])) {
            continue;
        }
        if (T_STRING == $tokens[$t][0] && ('(' == $tokens[$t + 1] || '(' == $tokens[$t + 2])) {
            // If it's a function or class defined locally, there's not going to be any docs available
            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]) {
                $ignore_functions[] = $tokens[$t][1];
            }
            // Add this to our stack of unique references
            $functions[] = $tokens[$t][1];
        }
    }
    $functions = array_unique($functions);
    sort($functions);
    /**
     * Filter the list of functions and classes to be ignored from the documentation lookup.
     *
     * @since 2.8.0
     *
     * @param array $ignore_functions Functions and classes to be ignored.
     */
    $ignore_functions = apply_filters('documentation_ignore_functions', $ignore_functions);
    $ignore_functions = array_unique($ignore_functions);
    $out = array();
    foreach ($functions as $function) {
        if (in_array($function, $ignore_functions)) {
            continue;
        }
        $out[] = $function;
    }
    return $out;
}

WordPress Version: 3.9

function wp_doc_link_parse($content)
{
    if (!is_string($content) || empty($content)) {
        return array();
    }
    if (!function_exists('token_get_all')) {
        return array();
    }
    $tokens = token_get_all($content);
    $count = count($tokens);
    $functions = array();
    $ignore_functions = array();
    for ($t = 0; $t < $count - 2; $t++) {
        if (!is_array($tokens[$t])) {
            continue;
        }
        if (T_STRING == $tokens[$t][0] && ('(' == $tokens[$t + 1] || '(' == $tokens[$t + 2])) {
            // If it's a function or class defined locally, there's not going to be any docs available
            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]) {
                $ignore_functions[] = $tokens[$t][1];
            }
            // Add this to our stack of unique references
            $functions[] = $tokens[$t][1];
        }
    }
    $functions = array_unique($functions);
    sort($functions);
    /**
     * Filter the list of functions/classes to be ignored from the documentation lookup.
     *
     * @since 2.8.0
     *
     * @param array $ignore_functions Functions/Classes to be ignored.
     */
    $ignore_functions = apply_filters('documentation_ignore_functions', $ignore_functions);
    $ignore_functions = array_unique($ignore_functions);
    $out = array();
    foreach ($functions as $function) {
        if (in_array($function, $ignore_functions)) {
            continue;
        }
        $out[] = $function;
    }
    return $out;
}

WordPress Version: 3.7

function wp_doc_link_parse($content)
{
    if (!is_string($content) || empty($content)) {
        return array();
    }
    if (!function_exists('token_get_all')) {
        return array();
    }
    $tokens = token_get_all($content);
    $functions = array();
    $ignore_functions = array();
    for ($t = 0, $count = count($tokens); $t < $count; $t++) {
        if (!is_array($tokens[$t])) {
            continue;
        }
        if (T_STRING == $tokens[$t][0] && ('(' == $tokens[$t + 1] || '(' == $tokens[$t + 2])) {
            // If it's a function or class defined locally, there's not going to be any docs available
            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]) {
                $ignore_functions[] = $tokens[$t][1];
            }
            // Add this to our stack of unique references
            $functions[] = $tokens[$t][1];
        }
    }
    $functions = array_unique($functions);
    sort($functions);
    $ignore_functions = apply_filters('documentation_ignore_functions', $ignore_functions);
    $ignore_functions = array_unique($ignore_functions);
    $out = array();
    foreach ($functions as $function) {
        if (in_array($function, $ignore_functions)) {
            continue;
        }
        $out[] = $function;
    }
    return $out;
}