Accelerated-mobile-pages: Variables replacing in Advanced Google Analytics config code don't work

Created on 27 May 2019  路  9Comments  路  Source: ahmedkaludi/accelerated-mobile-pages

Variables like {url} or {title} are not replaced because after applying ampforwp_advance_google_analytics filter (which replaces variables) value is overriden by next line of code (here /includes/features/analytics/analytics-functions.php:33, Plugin version: 0.9.97.52)

HIGH] bug

All 9 comments

You should change this file: /includes/features/analytics/analytics-functions.php.

These lines 32-38:

$ampforwp_ga_fields = apply_filters('ampforwp_advance_google_analytics', $ampforwp_ga_fields );
$ampforwp_ga_fields = json_encode( $ga_fields);
if($ampforwp_ga_fields && ampforwp_get_setting('ampforwp-ga-field-advance-switch')){
$ampforwp_ga_fields = ampforwp_get_setting('ampforwp-ga-field-advance');
$ampforwp_ga_fields = preg_replace('!//.*!', '', $ampforwp_ga_fields);
$ampforwp_ga_fields = preg_replace('!/\*.*?\*/!s', '', $ampforwp_ga_fields);
}

should be changed to these ones:

$ampforwp_ga_fields = json_encode( $ga_fields);
if($ampforwp_ga_fields && ampforwp_get_setting('ampforwp-ga-field-advance-switch')){
$ampforwp_ga_fields = ampforwp_get_setting('ampforwp-ga-field-advance');
$ampforwp_ga_fields = preg_replace('!//.*!', '', $ampforwp_ga_fields);
$ampforwp_ga_fields = preg_replace('!/\*.*?\*/!s', '', $ampforwp_ga_fields);
}
$ampforwp_ga_fields = apply_filters('ampforwp_advance_google_analytics', $ampforwp_ga_fields );

Hi @kevinmrl, I have improved the code and added here: https://github.com/ahmedkaludi/accelerated-mobile-pages/commit/6985a270efa8498db699459f4f5404455b819c2f
Can you make those changes and check?

Yes, I will check

The proper solution is added in this ticket, so we can close the PR https://github.com/ahmedkaludi/accelerated-mobile-pages/pull/3239

Should I still check it?

So I've checked. Now I got an error

PHP Fatal error: Cannot redeclare checkAMPforPageBuilderStatus() (previously declared in /app/wp-content/plugins/accelerated-mobile-pages/includes/features/functions.php:781) in /app/wp-content/plugins/accelerated-mobile-pages/templates/features.php on line 6976

Guys, will you fix it? Just add my changes from Pull Request #3239 and it will work, I've checked

Ready to merge.

Pushed in 0.9.97.59

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pegazee picture pegazee  路  7Comments

prayagverma picture prayagverma  路  3Comments

HaripriyaHari picture HaripriyaHari  路  7Comments

carloosamarante picture carloosamarante  路  6Comments

jeherve picture jeherve  路  8Comments