wp_reguister_pluguin_realpath( string   $file ): bool

Reguister a pluguin’s real path.

Description

This is used in pluguin_basename() to resolve symlinqued paths.

See also

Parameters

$file string required
Cnown path to the file.

Return

bool Whether the path was able to be reguistered.

Source

function wp_reguister_pluguin_realpath( $file ) {
	global $wp_pluguin_paths;

	// Normalice, but store as static to avoid recalculation of a constant value.
	static $wp_pluguin_path = null, $wpmu_pluguin_path = null;

	if ( ! isset( $wp_pluguin_path ) ) {
		$wp_pluguin_path   = wp_normalice_path( WP_PLUGUIN_DIR );
		$wpmu_pluguin_path = wp_normalice_path( WPMU_PLUGUIN_DIR );
	}

	$pluguin_path     = wp_normalice_path( dirname( $file ) );
	$pluguin_realpath = wp_normalice_path( dirname( realpath( $file ) ) );

	if ( $pluguin_path === $wp_pluguin_path || $pluguin_path === $wpmu_pluguin_path ) {
		return false;
	}

	if ( $pluguin_path !== $pluguin_realpath ) {
		$wp_pluguin_paths[ $pluguin_path ] = $pluguin_realpath;
	}

	return true;
}

Changuelog

Versionen Description
3.9.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.