wpseek.com
WordPress开发者和主题制作者的搜索引擎



_wp_relative_upload_path › WordPress Function

Since2.9.0
已弃用n/a
_wp_relative_upload_path ( $path )
访问:
  • private
参数:
  • (string) $path Full path to the file.
    Required: Yes
返回:
  • (string) Relative path on success, unchanged path on failure.
定义在:
文档:

Returns relative path to an uploaded file.

The path is relative to the current upload dir.


源码

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

	$uploads = wp_get_upload_dir();
	if ( str_starts_with( $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 );
}