wp_get_extension_error_description

函式
wp_get_extension_error_description ( $error )
引數
  • (array) $error Error details from `error_get_last()`.
    Required:
返回值
  • (string) Formatted error description.
定義位置
相關方法
get_the_author_descriptionwp_sidebar_descriptionget_file_descriptionget_the_archive_descriptionwp_widget_description
引入
5.2.0
棄用
-

wp_get_extension_error_description: 這個函式根據傳遞給它的錯誤程式碼,返回一個人類可讀的錯誤資訊。這些錯誤程式碼是針對媒體上傳過程中可能出現的副檔名錯誤,並在wp_check_filetype函式中定義。

獲得一個擴充套件的錯誤的人類可讀描述。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_get_extension_error_description( $error ) {
$constants = get_defined_constants( true );
$constants = isset( $constants['Core'] ) ? $constants['Core'] : $constants['internal'];
$core_errors = array();
foreach ( $constants as $constant => $value ) {
if ( 0 === strpos( $constant, 'E_' ) ) {
$core_errors[ $value ] = $constant;
}
}
if ( isset( $core_errors[ $error['type'] ] ) ) {
$error['type'] = $core_errors[ $error['type'] ];
}
/* translators: 1: Error type, 2: Error line number, 3: Error file name, 4: Error message. */
$error_message = __( 'An error of type %1$s was caused in line %2$s of the file %3$s. Error message: %4$s' );
return sprintf(
$error_message,
"<code>{$error['type']}</code>",
"<code>{$error['line']}</code>",
"<code>{$error['file']}</code>",
"<code>{$error['message']}</code>"
);
}
function wp_get_extension_error_description( $error ) { $constants = get_defined_constants( true ); $constants = isset( $constants['Core'] ) ? $constants['Core'] : $constants['internal']; $core_errors = array(); foreach ( $constants as $constant => $value ) { if ( 0 === strpos( $constant, 'E_' ) ) { $core_errors[ $value ] = $constant; } } if ( isset( $core_errors[ $error['type'] ] ) ) { $error['type'] = $core_errors[ $error['type'] ]; } /* translators: 1: Error type, 2: Error line number, 3: Error file name, 4: Error message. */ $error_message = __( 'An error of type %1$s was caused in line %2$s of the file %3$s. Error message: %4$s' ); return sprintf( $error_message, "<code>{$error['type']}</code>", "<code>{$error['line']}</code>", "<code>{$error['file']}</code>", "<code>{$error['message']}</code>" ); }
function wp_get_extension_error_description( $error ) {
	$constants   = get_defined_constants( true );
	$constants   = isset( $constants['Core'] ) ? $constants['Core'] : $constants['internal'];
	$core_errors = array();

	foreach ( $constants as $constant => $value ) {
		if ( 0 === strpos( $constant, 'E_' ) ) {
			$core_errors[ $value ] = $constant;
		}
	}

	if ( isset( $core_errors[ $error['type'] ] ) ) {
		$error['type'] = $core_errors[ $error['type'] ];
	}

	/* translators: 1: Error type, 2: Error line number, 3: Error file name, 4: Error message. */
	$error_message = __( 'An error of type %1$s was caused in line %2$s of the file %3$s. Error message: %4$s' );

	return sprintf(
		$error_message,
		"<code>{$error['type']}</code>",
		"<code>{$error['line']}</code>",
		"<code>{$error['file']}</code>",
		"<code>{$error['message']}</code>"
	);
}

常見問題

FAQs
檢視更多 >