WC_Notes_Run_Db_Update::update_done_notice
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 );
- $note(Note) (обязательный)
- Note to update.
Код WC_Notes_Run_Db_Update::update_done_notice() WC Notes Run Db Update::update done notice WC 10.3.5
private static function update_done_notice( Note $note ) {
$hide_notices_url = html_entity_decode( // to convert &s to normal &, otherwise produces invalid link.
add_query_arg(
array(
'wc-hide-notice' => 'update',
),
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',
),
);
// 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->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();
}