WC_Notes_Run_Db_Update::update_done_notice()private staticWC 1.0

Update the existing note with $note_id with information that db upgrade is done.

This is the last notice (3 out of 3 notices) displayed to the user.

Метод класса: WC_Notes_Run_Db_Update{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = WC_Notes_Run_Db_Update::update_done_notice( $note_id );
$note_id(int) (обязательный)
Note id to update.

Код WC_Notes_Run_Db_Update::update_done_notice() WC 8.7.0

private static function update_done_notice( $note_id ) {
	$hide_notices_url = html_entity_decode( // to convert &s to normal &, otherwise produces invalid link.
		add_query_arg(
			array(
				'wc-hide-notice' => 'update',
			),
			wc_get_current_admin_url() ? remove_query_arg( 'do_update_woocommerce', wc_get_current_admin_url() ) : admin_url( 'admin.php?page=wc-settings' )
		)
	);

	$note_actions = array(
		array(
			'name'         => 'update-db_done',
			'label'        => __( 'Thanks!', 'woocommerce' ),
			'url'          => $hide_notices_url,
			'status'       => 'actioned',
			'primary'      => true,
			'nonce_action' => 'woocommerce_hide_notices_nonce',
			'nonce_name'   => '_wc_notice_nonce',
		),
	);

	$note = new Note( $note_id );

	// Check if the note needs to be updated (e.g. expired nonce or different note type stored in the previous run).
	if ( self::note_up_to_date( $note, $hide_notices_url, wp_list_pluck( $note_actions, 'name' ) ) ) {
		return $note_id;
	}

	$note->set_title( __( 'WooCommerce database update done', 'woocommerce' ) );
	$note->set_content( __( 'WooCommerce database update complete. Thank you for updating to the latest version!', 'woocommerce' ) );

	$note->clear_actions();
	foreach ( $note_actions as $note_action ) {
		$note->add_action( ...array_values( $note_action ) );

		if ( isset( $note_action['nonce_action'] ) ) {
			$note->add_nonce_to_action( $note_action['name'], $note_action['nonce_action'], $note_action['nonce_name'] );
		}
	}

	$note->save();
}