Thanks for the additional info / feedback.
We took a look at modifying our plugin, but there are two challenges:
- The version of Kint that we’re using (4.0) is newer than the one in the Kint Debugger plugin, so we can’t just drop back to using the old version without running into other additional issues
- Additionally, we’re using Composer for bundling and autoloading dependencies which makes conditional loading non-trivial
So, here’s an alternative solution that instead adapts the Kint Debugger to use the newer version of Kint in NS Cloner and take things forward, rather than the other way around and pulling everything backward to the older version. Tested this with both plugins installed plus Debug Bar, and using d() to output things to the Debug Bar, and seems to be successful.
You’d drop this in a file (I named it kint-deconflict.php but could be anything) inside your mu-plugins directory:
<?php
/**
* Plugin Name: Kint Debugger Deconflicter
* Description: Allows the Kint Debugger plugin to use the newer version of Kint contained in another plugin like NS Cloner.
*/
/**
* Stop loading older version of Kint in kint-debugger, if another plugin is already loading it.
*/
if ( class_exists( 'Kint' ) ) {
remove_action( 'plugins_loaded', 'kint_debug_load_kint' );
}
/**
* This overrides the d() function defined in kint-debugger.
* It is changed to avoid calling the Kint::enabled() method that does not exist in newer versions of the library.
*/
if ( ! defined( 'KINT_TO_DEBUG_BAR' ) || KINT_TO_DEBUG_BAR ) {
/* An mu-plugin can still override the function. */
if ( ! function_exists( 'd' ) ) {
/**
* Alias of Kint::dump()
*
* This sends Kint output to Debug Bar if active.
*
* @return string
*/
function d() {
$_ = func_get_args();
if ( class_exists( 'Debug_Bar' ) ) {
ob_start( 'kint_debug_ob' );
echo call_user_func_array( array( 'Kint', 'dump' ), $_ );
ob_end_flush();
} else {
return call_user_func_array( array( 'Kint', 'dump' ), $_ );
}
return '';
}
}
}