public static function output_filename( $text, $file, $line = 0, $is_filename = false ) {

		if ( empty( $file ) ) {
			if ( $is_filename ) {
				return esc_html( $text );
			} else {
				return '<code>' . esc_html( $text ) . '</code>';
			}
		}

		$link_line = ( $line ) ? $line : 1;

		if ( ! self::has_clickable_links() ) {
			$fallback = QM_Util::standard_dir( $file, '' );
			if ( $line ) {
				$fallback .= ':' . $line;
			}
			if ( $is_filename ) {
				$return = esc_html( $text );
			} else {
				$return = '<code>' . esc_html( $text ) . '</code>';
			}
			if ( $fallback !== $text ) {
				$return .= '<br><span class="qm-info qm-supplemental">' . esc_html( $fallback ) . '</span>';
			}
			return $return;
		}

		$map = self::get_file_path_map();

		if ( ! empty( $map ) ) {
			foreach ( $map as $from => $to ) {
				$file = str_replace( $from, $to, $file );
			}
		}

		$link = sprintf( self::get_file_link_format(), rawurlencode( $file ), intval( $link_line ) );

		if ( $is_filename ) {
			$format = '<a href="%s" class="qm-edit-link">%s</a>';
		} else {
			$format = '<a href="%s" class="qm-edit-link"><code>%s</code></a>';
		}

		return sprintf(
			$format,
			esc_attr( $link ),
			esc_html( $text )
		);
	}
public static function output_filename( $text, $file, $line = 0, $is_filename = false ) {

		if ( empty( $file ) ) {
			if ( $is_filename ) {
				return esc_html( $text );
			} else {
				return '<code>' . esc_html( $text ) . '</code>';
			}
		}

		$link_line = ( $line ) ? $line : 1;

		if ( ! self::has_clickable_links() ) {
			$fallback = QM_Util::standard_dir( $file, '' );
			if ( $line ) {
				$fallback .= ':' . $line;
			}
			if ( $is_filename ) {
				$return = esc_html( $text );
			} else {
				$return = '<code>' . esc_html( $text ) . '</code>';
			}
			if ( $fallback !== $text ) {
				$return .= '<br><span class="qm-info qm-supplemental">' . esc_html( $fallback ) . '</span>';
			}
			return $return;
		}

		$map = self::get_file_path_map();

		if ( ! empty( $map ) ) {
			foreach ( $map as $from => $to ) {
				$file = str_replace( $from, $to, $file );
			}
		}

		$link = sprintf( self::get_file_link_format(), rawurlencode( $file ), intval( $link_line ) );

		if ( $is_filename ) {
			$format = '<a href="%s" class="qm-edit-link">%s</a>';
		} else {
			$format = '<a href="%s" class="qm-edit-link"><code>%s</code></a>';
		}

		return sprintf(
			$format,
			esc_attr( $link ),
			esc_html( $text )
		);
	}
public static function output_filename ( $ text , $ file , $ line = 0 , $ is_filename = false ) { if ( empty ( $ file ) ) { if ( $ is_filename ) { return esc_html ( $ text ) ; } else { return '<code>' . esc_html ( $ text ) . '</code>' ; } } $ link_line = ( $ line ) ? $ line : 1 ; if ( ! self :: has_clickable_links ( ) ) { $ fallback = QM_Util :: standard_dir ( $ file , '' ) ; if ( $ line ) { $ fallback .= ':' . $ line ; } if ( $ is_filename ) { $ return = esc_html ( $ text ) ; } else { $ return = '<code>' . esc_html ( $ text ) . '</code>' ; } if ( $ fallback !== $ text ) { $ return .= '<br><span class="qm-info qm-supplemental">' . esc_html ( $ fallback ) . '</span>' ; } return $ return ; } $ map = self :: get_file_path_map ( ) ; if ( ! empty ( $ map ) ) { foreach ( $ map as $ from => $ to ) { $ file = str_replace ( $ from , $ to , $ file ) ; } } $ link = sprintf ( self :: get_file_link_format ( ) , rawurlencode ( $ file ) , intval ( $ link_line ) ) ; if ( $ is_filename ) { $ format = '<a href="%s" class="qm-edit-link">%s</a>' ; } else { $ format = '<a href="%s" class="qm-edit-link"><code>%s</code></a>' ; } return sprintf ( $ format , esc_attr ( $ link ) , esc_html ( $ text ) ) ; }
Returns a file path, name, and line number, or a clickable link to the file. Safe for output.

@link https://querymonitor.com/blog/2019/02/clickable-stack-traces-and-function-names-in-query-monitor/

@param  string $text        The display text, such as a function name or file name.
@param  string $file        The full file path and name.
@param  int    $line        Optional. A line number, if appropriate.
@param  bool   $is_filename Optional. Is the text a plain file name? Default false.
@return string The fully formatted file link or file name, safe for output.
Returns a file path name and line number or a clickable link to the file . Safe for output .