/googleanalytics.php

  1. <?php 
  2. /** 
  3. * @package GoogleAnalytics 
  4. * @subpackage Main 
  5. */ 
  6.  
  7. /** 
  8. * Plugin Name: Google Analytics by Yoast 
  9. * Plugin URI: https://yoast.com/wordpress/plugins/google-analytics/#utm_source=wordpress&utm_medium=plugin&utm_campaign=wpgaplugin&utm_content=v504 
  10. * Description: This plugin makes it simple to add Google Analytics to your WordPress site, adding lots of features, e.g. error page, search result and automatic outgoing links and download tracking. 
  11. * Author: Team Yoast 
  12. * Version: 5.4.6 
  13. * Requires at least: 3.9 
  14. * Author URI: https://yoast.com/ 
  15. * License: GPL v3 
  16. * Text Domain: google-analytics-for-wordpress 
  17. * Domain Path: /languages 
  18. * 
  19. * Google Analytics for WordPress 
  20. * Copyright (C) 2008-2015, Team Yoast, support@yoast.com 
  21. * 
  22. * This program is free software: you can redistribute it and/or modify 
  23. * it under the terms of the GNU General Public License as published by 
  24. * the Free Software Foundation, either version 3 of the License, or 
  25. * (at your option) any later version. 
  26. * 
  27. * This program is distributed in the hope that it will be useful,  
  28. * but WITHOUT ANY WARRANTY; without even the implied warranty of 
  29. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
  30. * GNU General Public License for more details. 
  31. * 
  32. * You should have received a copy of the GNU General Public License 
  33. * along with this program. If not, see <http://www.gnu.org/licenses/>. 
  34. */ 
  35.  
  36. // This plugin was originally based on Rich Boakes' Analytics plugin: http://boakes.org/analytics, but has since been rewritten and refactored multiple times. 
  37.  
  38. define( 'GAWP_VERSION', '5.4.6' ); 
  39.  
  40. define( 'GAWP_FILE', __FILE__ ); 
  41.  
  42. define( 'GAWP_PATH', plugin_basename( __FILE__ ) ); 
  43.  
  44. define( 'GAWP_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) ); 
  45.  
  46. if ( file_exists( dirname( GAWP_FILE ) . '/vendor/autoload_52.php' ) ) { 
  47. require dirname( GAWP_FILE ) . '/vendor/autoload_52.php'; 
  48.  
  49. // Only require the needed classes 
  50. if ( is_admin() ) { 
  51. global $yoast_ga_admin; 
  52. $yoast_ga_admin = new Yoast_GA_Admin; 
  53.  
  54. else { 
  55. global $yoast_ga_frontend; 
  56. $yoast_ga_frontend = new Yoast_GA_Frontend; 
  57.  
  58. /** ***************************** BOOTSTRAP / HOOK INTO WP *************************** */ 
  59. $spl_autoload_exists = function_exists( 'spl_autoload_register' ); 
  60. $filter_input_exists = function_exists( 'filter_input' ); 
  61. if ( ! $spl_autoload_exists ) { 
  62. add_action( 'admin_init', 'yoast_wpseo_self_deactivate_spl', 1 ); 
  63. if ( ! $filter_input_exists ) { 
  64. add_action( 'admin_init', 'yoast_wpseo_self_deactivate_filter_input', 1 ); 
  65.  
  66. /** 
  67. * Throw an error if the PHP SPL extension is disabled (prevent white screens) and self-deactivate plugin 
  68. * 
  69. * @since 5.3.3 
  70. */ 
  71. function yoast_ga_self_deactivate_spl() { 
  72. if ( is_admin() ) { 
  73. yoast_ga_extenstion_notice( 
  74. esc_html__( 'The Standard PHP Library (SPL) extension seem to be unavailable. Please ask your web host to enable it.', 'google-analytics-for-wordpress' ) 
  75. ); 
  76.  
  77. /** 
  78. * Throw an error if the filter extension is disabled (prevent white screens) and self-deactivate plugin 
  79. * 
  80. * @since 5.3.3 
  81. */ 
  82. function yoast_ga_self_deactivate_filter_input() { 
  83. if ( is_admin() ) { 
  84. yoast_ga_extenstion_notice( 
  85. esc_html__( 'The (standard) PHP filter extension seem to be unavailable. Please ask your web host to enable it.', 'google-analytics-for-wordpress' ) 
  86. ); 
  87.  
  88. /** 
  89. * Show a notice in the admin 
  90. * 
  91. * @param string $message 
  92. * 
  93. * @since 5.3.3 
  94. */ 
  95. function yoast_ga_extenstion_notice( $message ) { 
  96. add_action( 'admin_notices', create_function( $message, 'echo \'<div class="error"><p>\' . __( \'Activation failed:\', \'google-analytics-for-wordpress\' ) . \' \' . $message . \'</p></div>\';' ) ); 
  97. deactivate_plugins( plugin_basename( GAWP_FILE ) ); 
  98. if ( isset( $_GET['activate'] ) ) { 
  99. unset( $_GET['activate'] ); 
  100.  
  101. register_deactivation_hook( __FILE__, array( 'Yoast_GA_Admin', 'ga_deactivation_hook' ) ); 
.