PHP code example of franciscoblancojn / wordpress_utils

1. Go to this page and download the library: Download franciscoblancojn/wordpress_utils library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

franciscoblancojn / wordpress_utils example snippets




use franciscoblancojn\wordpress_utils\FWUSystemLog;

FWUSystemLog::init("MY_PLUGIN_SLUG");

FWUSystemLog::add("MY_PLUGIN_SLUG", [
    "type"    => "API",
    "message" => "Solicitud enviada correctamente",
    "data"    => ["id" => 123]
]);

FWUSystemLog::init("PAYMENTS");
FWUSystemLog::init("ORDERS");

FWUSystemLog::add("MY_PLUGIN_SLUG", [
    "type"    => "ERROR",
    "message" => "Falló conexión"
]);

define("MY_PLUGIN_SLUG_LOG",       true);          // activar/desactivar logs
define("MY_PLUGIN_SLUG_LOG_COUNT", 50);            // cantidad máxima por tipo
define("MY_PLUGIN_SLUG_LOG_KEY",   "custom_key");  // clave en la DB

use franciscoblancojn\wordpress_utils\FWUSystemLog;

// Inicializar
FWUSystemLog::init("MY_PLUGIN_SLUG");

// Agregar log
FWUSystemLog::add("MY_PLUGIN_SLUG", [
    "type"    => "DEBUG",
    "message" => "Plugin cargado",
    "data"    => ["user" => get_current_user_id()]
]);