WooCommerce Code Reference

WC_Notes_Run_Db_Update
in package

WC_Notes_Run_Db_Update.

Table of Contents

NOTE_NAME  = 'wc-update-db-reminder'
__construct()  : mixed
Attach hooks.
set_notice_actioned()  : mixed
Set this notice to an actioned one, so that it's no longer displayed.
show_reminder()  : mixed
Prepare the correct content of the db update note to be displayed by WC Admin.
get_current_notice()  : int|void
Get current notice id from the database.
note_up_to_date()  : bool
Check whether the note is up to date for a fresh display.
update_done_notice()  : mixed
Update the existing note with $note_id with information that db upgrade is done.
update_in_progress_notice()  : mixed
Update the existing note with $note_id with information about the db upgrade being in progress.
update_needed_notice()  : int
Create and set up the first (out of 3) 'Database update needed' notice and store it in the database.

Constants

Methods

show_reminder()

Prepare the correct content of the db update note to be displayed by WC Admin.

public static show_reminder() : mixed

This one gets called on each page load, so try to bail quickly.

If the db needs an update, the notice should be always shown. If the db does not need an update, but the notice has not been actioned (i.e. after the db update, when store owner hasn't acknowledged the successful db update), still show the Thanks notice. If the db does not need an update, and the notice has been actioned, then notice should not be shown. The notice should also be hidden if the db does not need an update and the notice does not exist.

Return values
mixed

get_current_notice()

Get current notice id from the database.

private static get_current_notice() : int|void

Retrieves the first notice of this type.

Return values
int|voidNote id or null in case no note was found.

note_up_to_date()

Check whether the note is up to date for a fresh display.

private static note_up_to_date(Note $note, string $update_url, array<int, string> $current_actions) : bool

The check tests if

  • actions are set up for the first 'Update database' notice, and
  • URL for note's action is equal to the given URL (to check for potential nonce update).
Parameters
$note : Note

Note to check.

$update_url : string

URL to check the note against.

$current_actions : array<int, string>

List of actions to check for.

Return values
bool

update_done_notice()

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

private static update_done_notice(int $note_id) : mixed

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

Parameters
$note_id : int

Note id to update.

Return values
mixed

update_in_progress_notice()

Update the existing note with $note_id with information about the db upgrade being in progress.

private static update_in_progress_notice(int $note_id) : mixed

This is the second out of 3 notices displayed to the user.

Parameters
$note_id : int

Note id to update.

Return values
mixed

update_needed_notice()

Create and set up the first (out of 3) 'Database update needed' notice and store it in the database.

private static update_needed_notice([int $note_id = null ]) : int

If a $note_id is given, the method updates the note instead of creating a new one.

Parameters
$note_id : int = null

Note db record to update.

Return values
intCreated/Updated note id