Shared utilities for the Hypercart plugin suite. Provides centralized time handling (UTC storage, local display), structured file-based logging, a reusable chart helper, and a safe Markdown viewer.
Version: 1.1.13
Author: Neochrome
Requires at least: WordPress 6.0
Requires PHP: 7.4
- Hypercart_Time: UTC-first time storage with site-timezone display helpers.
- Hypercart_Logger: Structured, daily-rotated log files with context redaction and retention cleanup.
- Hypercart_Charts: Lightweight Chart.js helper with normalized time-series payloads.
- Hypercart_Markdown_Viewer: Safe Markdown rendering with shortcode and file allowlists.
- Admin Tools: Settings page with tabs (Self Test, Demo, Changelog) and a Security Guide viewer.
- Upload the plugin folder to
wp-content/plugins/. - Activate Hypercart Helper in the Plugins screen.
- Visit Settings → Hypercart Helper to run Self Tests or view the demo chart.
$now = Hypercart_Time::now(); // UTC timestamp
$utc = Hypercart_Time::utc_format( 'Y-m-d H:i:s', $now );
$local = Hypercart_Time::format( 'F j, Y g:i A', $now );
$iso = Hypercart_Time::iso8601( $now );Hypercart_Logger::info( 'my-plugin', 'Worker started', array(
'job_id' => 123,
'user_id' => get_current_user_id(),
) );
$files = Hypercart_Logger::get_log_files();
$tail = Hypercart_Logger::read_log( null, -100 );add_action( 'admin_enqueue_scripts', function( $hook ) {
if ( 'settings_page_hypercart-helper' === $hook ) {
Hypercart_Charts::enqueue( array( 'context' => 'admin' ) );
}
} );
$chart = array(
'id' => 'my-chart',
'title' => 'Requests',
'datasets' => array(
array(
'key' => 'requests',
'label' => 'Requests',
'color' => '#2271b1',
'points' => array(
array( 'x' => time() - 3600, 'y' => 12 ),
array( 'x' => time(), 'y' => 30 ),
),
),
),
);
echo Hypercart_Charts::render_canvas( $chart, array( 'height' => 280 ) );// Shortcode
[hypercart_markdown file="plugins/my-plugin/README.md" title="Docs"]
// PHP
echo Hypercart_Markdown_Viewer::render_file( 'plugins/my-plugin/README.md' );- Self Test: Validates time handling, logging, charts, and Markdown rendering.
- Demo: Renders a sample chart if Chart.js assets are available.
- Changelog: Renders
CHANGELOG.mdvia the Markdown Viewer. - Security Guide: Renders
README-SECURITY.mdfrom a dedicated admin page.
- Log files are stored under
WP_CONTENT_DIR/hypercart-logsby default. Move them outside the web root if possible by filteringhypercart_log_dir. - The Markdown Viewer only renders
.md/.markdownfiles underWP_CONTENT_DIRby default. Use the allowlist filters if you need to restrict or expand access. - Logging context is partially redacted for common sensitive keys (token, password, api_key, etc.).
hypercart_log_dirhypercart_min_log_levelhypercart_log_files_include_sizeshypercart_log_files_cache_ttlhypercart_log_read_max_lineshypercart_log_read_max_byteshypercart_log_retention_dayshypercart_charts_use_chartjshypercart_charts_datasetshypercart_charts_default_confighypercart_charts_tooltip_callbackshypercart_markdown_viewer_allowed_base_dirshypercart_markdown_viewer_allow_filehypercart_markdown_viewer_allowed_tagshypercart_markdown_viewer_markdownhypercart_markdown_viewer_html- Action:
hypercart_log
README-SECURITY.md- Security guidance for log storage and server configuration.CHANGELOG.md- Version history.HH-INTEGRATION-GUIDE.md- Integration notes for other Hypercart plugins.
GPL-2.0-or-later. See LICENSE.md.