Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
WC_Notes_Run_Db_Update::update_needed_notice( integer $note_id = null )
Create and set up the first (out of 3) ‘Database update needed’ notice and store it in the database.
Description Description
If a $note_id is given, the method updates the note instead of creating a new one.
Parameters Parameters
- $note_id
-
(Optional) Note db record to update.
Default value: null
Return Return
(int) Created/Updated note id
Source Source
File: includes/admin/notes/class-wc-notes-run-db-update.php
private static function update_needed_notice( $note_id = null ) { $update_url = html_entity_decode( wp_nonce_url( add_query_arg( 'do_update_woocommerce', 'true', admin_url( 'admin.php?page=wc-settings' ) ), 'wc_db_update', 'wc_db_update_nonce' ) ); $note_actions = array( array( 'name' => 'update-db_run', 'label' => __( 'Update WooCommerce Database', 'woocommerce' ), 'url' => $update_url, 'status' => 'unactioned', 'primary' => true, ), array( 'name' => 'update-db_learn-more', 'label' => __( 'Learn more about updates', 'woocommerce' ), 'url' => 'https://docs.woocommerce.com/document/how-to-update-woocommerce/', 'status' => 'unactioned', 'primary' => false, ), ); if ( $note_id ) { $note = new WC_Admin_Note( $note_id ); } else { $note = new WC_Admin_Note(); } // 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, $update_url, wp_list_pluck( $note_actions, 'name' ) ) ) { return $note_id; } $note->set_title( __( 'WooCommerce database update required', 'woocommerce' ) ); $note->set_content( __( 'WooCommerce has been updated! To keep things running smoothly, we have to update your database to the newest version.', 'woocommerce' ) /* translators: %1$s: opening <a> tag %2$s: closing </a> tag*/ . sprintf( ' ' . esc_html__( 'The database update process runs in the background and may take a little while, so please be patient. Advanced users can alternatively update via %1$sWP CLI%2$s.', 'woocommerce' ), '<a href="https://github.com/woocommerce/woocommerce/wiki/Upgrading-the-database-using-WP-CLI">', '</a>' ) ); $note->set_type( WC_Admin_Note::E_WC_ADMIN_NOTE_UPDATE ); $note->set_name( self::NOTE_NAME ); $note->set_content_data( (object) array() ); $note->set_source( 'woocommerce-core' ); // In case db version is out of sync with WC version or during the next update, the notice needs to show up again, // so set it to unactioned. $note->set_status( WC_Admin_Note::E_WC_ADMIN_NOTE_UNACTIONED ); // Set new actions. $note->clear_actions(); foreach ( $note_actions as $note_action ) { $note->add_action( ...array_values( $note_action ) ); } return $note->save(); }