_wp_relative_upload_path

函数
_wp_relative_upload_path ( $path )
Access
Private
参数
  • (string) $path Full path to the file.
    Required:
返回值
  • (string) Relative path on success, unchanged path on failure.
定义位置
相关方法
_wp_translate_postdatawp_resolve_post_date_wp_handle_uploadwp_get_upload_dir_wp_get_attachment_relative_path
引入
2.9.0
弃用
-

_wp_relative_upload_path: 这个函数返回WordPress安装的上传目录的相对路径。它用于在wp-config.php文件中设置上传目录。

返回上传文件的相对路径。

该路径是相对于当前上传目录的。

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 );
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 19:32:59

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: