From e1f490f20bef6e4c61254e025e74f0122c9ba87f Mon Sep 17 00:00:00 2001 From: Erick Hitter <services@ethitter.com> Date: Sun, 21 Feb 2016 20:52:40 -0800 Subject: [PATCH] Better building of settings output, also giving others all the freedom they need to add per the spec --- eth-amp-analytics-wp.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/eth-amp-analytics-wp.php b/eth-amp-analytics-wp.php index 86f89b0..747ed07 100644 --- a/eth-amp-analytics-wp.php +++ b/eth-amp-analytics-wp.php @@ -108,25 +108,23 @@ class ETH_AMP_Analytics_WP { * */ public function action_amp_post_template_footer( $amp_template ) { - $triggers = array( - 'trackPageview' => array( - 'on' => 'visible', - 'request' => 'pageview', + $output = array( + 'vars' => array( + 'account' => $this->get_option( 'property_id' ), + ), + 'triggers' => array( + 'trackPageview' => array( + 'on' => 'visible', + 'request' => 'pageview', + ), ), ); - $triggers = apply_filters( 'eth_amp_analytics_wp_ga_triggers', $triggers, $amp_template ); + $output = apply_filters( 'eth_amp_analytics_wp_ga_settings_js', $output ); ?> <amp-analytics type="googleanalytics" id="analytics1"> - <script type="application/json"> - { - "vars": { - "account": "<?php echo esc_js( $this->options['property_id'] ); ?>" - }, - "triggers": <?php wp_json_encode( $triggers ); ?> - } - </script> + <script type="application/json"><?php echo wp_json_encode( $output ); ?></script> </amp-analytics> <?php } -- GitLab