php/commands/src/Help_Command.php
private static function parse_reference_links( $longdesc ) {
		$description = '';
		foreach ( explode( "\n", $longdesc ) as $line ) {
			if ( 0 === strpos( $line, '#' ) ) {
				break;
			}
			$description .= $line . "\n";
		}

		// Fires if it has description text at the head of `$longdesc`.
		if ( $description ) {
			$links   = array(); // An array of URLs from the description.
			$pattern = '/\[.+?\]\((https?:\/\/.+?)\)/';
			$newdesc = preg_replace_callback(
				$pattern,
				function( $matches ) use ( &$links ) {
					static $count = 0;
					$count++;
					$links[] = $matches[1];
					return str_replace( '(' . $matches[1] . ')', '[' . $count . ']', $matches[0] );
				},
				$description
			);

			$footnote   = '';
			$link_count = count( $links );
			for ( $i = 0; $i < $link_count; $i++ ) {
				$n         = $i + 1;
				$footnote .= '[' . $n . '] ' . $links[ $i ] . "\n";
			}

			if ( $footnote ) {
				$newdesc  = trim( $newdesc ) . "\n\n---\n" . $footnote;
				$longdesc = str_replace( trim( $description ), trim( $newdesc ), $longdesc );
			}
		}

		return $longdesc;
	}
private static function parse_reference_links( $longdesc ) {
		$description = '';
		foreach ( explode( "\n", $longdesc ) as $line ) {
			if ( 0 === strpos( $line, '#' ) ) {
				break;
			}
			$description .= $line . "\n";
		}

		// Fires if it has description text at the head of `$longdesc`.
		if ( $description ) {
			$links   = array(); // An array of URLs from the description.
			$pattern = '/\[.+?\]\((https?:\/\/.+?)\)/';
			$newdesc = preg_replace_callback(
				$pattern,
				function( $matches ) use ( &$links ) {
					static $count = 0;
					$count++;
					$links[] = $matches[1];
					return str_replace( '(' . $matches[1] . ')', '[' . $count . ']', $matches[0] );
				},
				$description
			);

			$footnote   = '';
			$link_count = count( $links );
			for ( $i = 0; $i < $link_count; $i++ ) {
				$n         = $i + 1;
				$footnote .= '[' . $n . '] ' . $links[ $i ] . "\n";
			}

			if ( $footnote ) {
				$newdesc  = trim( $newdesc ) . "\n\n---\n" . $footnote;
				$longdesc = str_replace( trim( $description ), trim( $newdesc ), $longdesc );
			}
		}

		return $longdesc;
	}
private static function parse_reference_links ( $ longdesc ) { $ description = '' ; foreach ( explode ( "\n" , $ longdesc ) as $ line ) { if ( 0 === strpos ( $ line , '#' ) ) { break ; } $ description .= $ line . "\n" ; } // Fires if it has description text at the head of `$longdesc`. if ( $ description ) { $ links = array ( ) ; // An array of URLs from the description. $ pattern = '/\[.+?\]\((https?:\/\/.+?)\)/' ; $ newdesc = preg_replace_callback ( $ pattern , function ( $ matches ) use ( & $ links ) { static $ count = 0 ; $ count ++ ; $ links [ ] = $ matches [ 1 ] ; return str_replace ( '(' . $ matches [ 1 ] . ')' , '[' . $ count . ']' , $ matches [ 0 ] ) ; } , $ description ) ; $ footnote = '' ; $ link_count = count ( $ links ) ; for ( $ i = 0 ; $ i < $ link_count ; $ i ++ ) { $ n = $ i + 1 ; $ footnote .= '[' . $ n . '] ' . $ links [ $ i ] . "\n" ; } if ( $ footnote ) { $ newdesc = trim ( $ newdesc ) . "\n\n---\n" . $ footnote ; $ longdesc = str_replace ( trim ( $ description ) , trim ( $ newdesc ) , $ longdesc ) ; } } return $ longdesc ; }
Parse reference links from longdescription.

@param  string $longdesc The longdescription from the `$command->get_longdesc()`.
@return string The longdescription which has links as footnote.
Parse reference links from longdescription .