Request for DB settings hook in installer
-
Hello, great plugin.
We are using on a Kinsta hosted site, and the problem we run into that when migrating plugin updates from one environment to another, using the built in tools, the Database settings which are hardcoded from the environment into the
ajax-handler.php
file for theadvanced-ads-tracking
addon are not accurate anymore.The Kinsta server provides DB constants which work regardless of environment, but everytime the plugin is updated, these get overwritten:
$mysqli = @mysqli_connect( SERVER_SECRET_DB_HOST, SERVER_SECRET_DB_USER, SERVER_SECRET_DB_PASSWORD, SERVER_SECRET_DB_NAME, ‘0’, ” );
I wonder if you would please add a filter hook to your function in
wp-content/plugins/advanced-ads-tracking/classes/installer.php
so that these can be modified without having to adjust your code?private function gather_variables() {
// ... existing code ...
// Apply filter to allow modification of variables
$vars = apply_filters( 'advanced_ads_tracking_gather_variables', $vars );
return $vars;
}With that hook in place, we could then create a simple mu module to integrate our DB settings that would then work on any site environment – EG:
<?php
/**
* Plugin Name: Advanced Ads Tracking Constants
* Description: Replaces Advanced Ads Tracking variables with constants
* Version: 1.0.0
* Author: Earthman Media
*/
add_filter( 'advanced_ads_tracking_gather_variables', 'replace_advanced_ads_tracking_variables' );
function replace_advanced_ads_tracking_variables( $vars ) {
// Replace database connection variables with constants
if ( defined( 'SERVER_SECRET_DB_HOST' ) ) {
$vars['db_host'] = SERVER_SECRET_DB_HOST;
}
if ( defined( 'SERVER_SECRET_DB_USER' ) ) {
$vars['db_user'] = SERVER_SECRET_DB_USER;
}
if ( defined( 'SERVER_SECRET_DB_PASSWORD' ) ) {
$vars['db_password'] = SERVER_SECRET_DB_PASSWORD;
}
if ( defined( 'SERVER_SECRET_DB_NAME' ) ) {
$vars['db_name'] = SERVER_SECRET_DB_NAME;
}
// You can add more replacements here if needed
return $vars;
}My client would be most appreciative, as this would keep the ads tracking plugin from ‘breaking’ every time we update.
Regardless of hosting, this change would benefit any user who is managing multiple versions of their site where updates are pushed via git or other processes, rather than managing updates on each environment, separately.
I eagerly await your response to this pressing matter.
- The topic ‘Request for DB settings hook in installer’ is closed to new replies.