Skip to content

Instantly share code, notes, and snippets.

@mustardBees
Created July 23, 2023 09:36
Show Gist options
  • Select an option

  • Save mustardBees/b117477abe642ca3516d2a50e228df6b to your computer and use it in GitHub Desktop.

Select an option

Save mustardBees/b117477abe642ca3516d2a50e228df6b to your computer and use it in GitHub Desktop.

Revisions

  1. mustardBees created this gist Jul 23, 2023.
    27 changes: 27 additions & 0 deletions functions.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    <?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 );
    }