Automattic\WooCommerce\Blocks

Installer::add_create_table_notice()protectedWC 1.0

Add a notice if table creation fails.

Method of the class: Installer{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->add_create_table_notice( $table_name );
$table_name(string) (required)
Name of the missing table.

Installer::add_create_table_notice() code WC 8.7.0

protected function add_create_table_notice( $table_name ) {
	add_action(
		'admin_notices',
		function() use ( $table_name ) {
			echo '<div class="error"><p>';
			printf(
				/* translators: %1$s table name, %2$s database user, %3$s database name. */
				esc_html__( 'WooCommerce %1$s table creation failed. Does the %2$s user have CREATE privileges on the %3$s database?', 'woocommerce' ),
				'<code>' . esc_html( $table_name ) . '</code>',
				'<code>' . esc_html( DB_USER ) . '</code>',
				'<code>' . esc_html( DB_NAME ) . '</code>'
			);
			echo '</p></div>';
		}
	);
}