Outil de recherche WordPress pour les développeurs et auteurs de thèmes



_wp_relative_upload_path ›

Depuis2.9.0
Dépréciéen/a
_wp_relative_upload_path ( $path )
Accès:
  • private
Paramètres:
  • (string) $path Full path to the file.
    Requis: Oui
Retourne:
  • (string) Relative path on success, unchanged path on failure.
Défini(e) dans:
Codex:

Return relative path to an uploaded file.

The path is relative to the current upload dir.



Source

function _wp_relative_upload_path( $path ) {
	$new_path = $path;

	$uploads = wp_get_upload_dir();
	if ( 0 === strpos( $new_path, $uploads['basedir'] ) ) {
			$new_path = str_replace( $uploads['basedir'], '', $new_path );
			$new_path = ltrim( $new_path, '/' );
	}

	/**
	 * Filters the relative path to an uploaded file.
	 *
	 * @since 2.9.0
	 *
	 * @param string $new_path Relative path to the file.
	 * @param string $path     Full path to the file.
	 */
	return apply_filters( '_wp_relative_upload_path', $new_path, $path );
}