Plugin Directory

Changeset 2721834


Ignore:
Timestamp:
05/11/2022 09:05:03 AM (4 years ago)
Author:
rolandfarkas
Message:

Update to v1.0.2

Location:
amp-google-analytics-4-support/trunk
Files:
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • amp-google-analytics-4-support/trunk/ampanalyticssupport.php

    r2721826 r2721834  
    22/*
    33* Plugin Name: AMP Google Analytics 4 Support
    4 * Plugin URI: https:/github.com
     4* Plugin URI: https://github.com/rolandfarkasCOM/ampanalyticssupport/
    55* Description: Google Analytics 4 (GA4) AMP support plugin.
    6 * Version: 1.0.1
     6* Version: 1.0.2
    77* Author: Roland Farkas
    88* Author URI: https://rolandfarkas.com
     
    3636            add_filter( "plugin_action_links_$this->plugin", array( $this, 'settings_link' ) );
    3737            add_action( 'admin_menu', array( $this, 'add_admin_pages' ) );
     38           
    3839         
    3940        }
     
    7172            $ampanalyticssupportActivate = new ampanalyticssupportActivate();
    7273            $ampanalyticssupportActivate->activate();
    73         }
    74 
    75         function insert() {
    76             require_once plugin_dir_path( __FILE__ ) . 'inc/ampanalyticssupport-plugin-insert.php';
    77             $ampanalyticssupportInsert = new ampanalyticssupportInsert();
    78             $ampanalyticssupportInsert->ampanalyticssupport();
     74           
    7975        }
    8076
     
    8379    $ampanalyticssupportPlugin = new ampanalyticssupportPlugin();
    8480    $ampanalyticssupportPlugin->register();
    85     $ampanalyticssupportPlugin->insert();
    86 
     81   
    8782    // activation
    8883    register_activation_hook( __FILE__, array( $ampanalyticssupportPlugin, 'activate' ) );
    89 
    90     // deactivation
    91     require_once plugin_dir_path( __FILE__ ) . 'inc/ampanalyticssupport-plugin-deactivate.php';
    92     register_deactivation_hook( __FILE__, array( 'ampanalyticssupportPluginDeactivate', 'deactivate' ) );
    9384
    9485    register_setting( 'ampanalyticssupport-settings', 'ampanalyticssupport' );
    9586}
    9687
     88function page_is_amp() {
     89    if ( function_exists( 'amp_is_request' ) ):
     90      return amp_is_request();
     91    else :
     92      return false;
     93    endif;
     94  }
    9795
     96// Check if the request is amp and if the amp plugin is active and insert analytics if required.
     97function ampanalyticssupport() {
     98
     99    include_once ABSPATH . 'wp-admin/includes/plugin.php';
     100 
     101    if ( is_plugin_active( 'amp/amp.php' ) && page_is_amp()) {
     102        //plugin is activated
     103
     104     echo '<amp-analytics type="googleanalytics" config="/wp-content/plugins/ampanalyticssupport/ga4.json" data-credentials="include">
     105            <script type="application/json">
     106            {
     107                "vars": {
     108                            "GA4_MEASUREMENT_ID": "'.get_option('ampanalyticssupport').'",
     109                            "GA4_ENDPOINT_HOSTNAME": "www.google-analytics.com",
     110                            "DEFAULT_PAGEVIEW_ENABLED": true,   
     111                            "GOOGLE_CONSENT_ENABLED": false,
     112                            "WEBVITALS_TRACKING": false,
     113                            "PERFORMANCE_TIMING_TRACKING": false
     114                }
     115            }
     116            </script>
     117            </amp-analytics>';   
     118      }
     119}
     120add_action('wp_footer', 'ampanalyticssupport');
    98121
    99122
  • amp-google-analytics-4-support/trunk/readme.txt

    r2721826 r2721834  
    44Requires at least: 4.9
    55Tested up to: 5.9
    6 Stable tag: 1.0.1
     6Stable tag: 1.0.2
    77License: GPLv3 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3939* Updated Uninstall Process to purge data.
    4040* Corrected a file name.
     41= 1.0.2 =
     42* Updated deactivate and insert
    4143
    4244== Credits ==
Note: See TracChangeset for help on using the changeset viewer.