Skip to content

Instantly share code, notes, and snippets.

@mustardBees
Created July 23, 2023 09:36
Show Gist options
  • Save mustardBees/b117477abe642ca3516d2a50e228df6b to your computer and use it in GitHub Desktop.
Save mustardBees/b117477abe642ca3516d2a50e228df6b to your computer and use it in GitHub Desktop.
<?php
/**
* Write a log entry.
*
* Helper function to write a log entry with a given title, category, and any
* log data. Relies on the Maintenance Functionality mu-plugin being present.
*
* Usage:
*
* kanuka_log( 'Data Import', 'import', array(
* 'status' => 'success',
* 'data' => $data,
* ) );
*
* @param string $title The title of the log entry.
* @param string|null $category The category of the log entry (optional).
* @param mixed|null $data The log data to be saved (optional).
*/
function kanuka_log( $title, $category = null, $data = null ) {
// Bail if our mu-plugin isn't present.
if ( ! class_exists( 'Kanuka_Maintenance_Functionality' ) ) {
return;
}
Kanuka_Maintenance_Functionality::log( $title, $category, $data );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment