Skip to content

Instantly share code, notes, and snippets.

@gbissland
Created March 8, 2025 04:16
Show Gist options
  • Save gbissland/46cb144498e651188fb4a737cad3b6d9 to your computer and use it in GitHub Desktop.
Save gbissland/46cb144498e651188fb4a737cad3b6d9 to your computer and use it in GitHub Desktop.
Configure DevKit error logs for Nginx Error logs on Gridpane
<?php
/**
* DevKit related tweaks
* https://dplugins.com/downloads/devkit/
*
* Must be included in functions.php
*
* @package GenerateChild
*/
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Configure DevKit error logs for Nginx Error logs on GridPane
*/
function configure_devkit_error_logs() {
// Only run if DevKit plugin is active
if (!function_exists('is_plugin_active')) {
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
}
// Check if DevKit is active using the main plugin file
if (!is_plugin_active('devkit/devkit.php')) {
return;
}
// For the path, set a special marker that won't be interpreted as a URL part
update_option('dpdevkit_epath', '###NGINX_LOGS###', true);
// Set the log filename based on domain
$domain = parse_url(site_url(), PHP_URL_HOST);
update_option('dpdevkit_ename', $domain . '.error.log', true);
}
add_action('init', 'configure_devkit_error_logs', 9);
/**
* Convert our special marker to the actual Nginx logs path
*/
function custom_convert_path_marker($path) {
if ($path === '###NGINX_LOGS###' || strpos($path, '###NGINX_LOGS###') !== false) {
return '/var/log/nginx';
}
return $path;
}
add_filter('dpdevkit_epath', 'custom_convert_path_marker');
require get_stylesheet_directory() . '/inc/devkit.php';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment