wphooks.info - pre_upload_error

pre_upload_error

(trunk - 5.1-alpha-44286)

The hook occurs in the following file:

wp-includes/class-wp-xmlrpc-server.php:
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
		/**
		 * Filters whether to preempt the XML-RPC media upload.
		 *
		 * Passing a truthy value will effectively short-circuit the media upload,
		 * returning that value as a 500 error instead.
		 *
		 * @since 2.1.0
		 *
		 * @param bool $error Whether to pre-empt the media upload. Default false.
		 */
		if ( $upload_err = apply_filters( 'pre_upload_error', false ) ) {
			return new IXR_Error( 500, $upload_err );
		}

		$upload = wp_upload_bits( $name, null, $bits );
		if ( ! empty( $upload['error'] ) ) {
			/* translators: 1: file name, 2: error message */
			$errorString = sprintf( __( 'Could not write file %1$s (%2$s).' ), $name, $upload['error'] );
			return new IXR_Error( 500, $errorString );
		}