class-tracking-preview.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * Tracking debug class.
  4. *
  5. * @since 6.0.0
  6. *
  7. * @package MonsterInsights
  8. * @author Chris Christoff
  9. */
  10. // Exit if accessed directly
  11. if ( ! defined( 'ABSPATH' ) ) {
  12. exit;
  13. }
  14. class MonsterInsights_Tracking_Preview extends MonsterInsights_Tracking_Abstract {
  15. /**
  16. * Holds the name of the tracking type.
  17. *
  18. * @since 6.0.0
  19. * @access public
  20. *
  21. * @var string $name Name of the tracking type.
  22. */
  23. public $name = 'preview';
  24. /**
  25. * Version of the tracking class.
  26. *
  27. * @since 6.0.0
  28. * @access public
  29. *
  30. * @var string $version Version of the tracking class.
  31. */
  32. public $version = '1.0.0';
  33. /**
  34. * Primary class constructor.
  35. *
  36. * @since 6.0.0
  37. * @access public
  38. */
  39. public function __construct() {
  40. }
  41. /**
  42. * Get frontend tracking options.
  43. *
  44. * This function is used to return an array of parameters
  45. * for the frontend_output() function to output. These are
  46. * generally dimensions and turned on GA features.
  47. *
  48. * @since 6.0.0
  49. * @access public
  50. *
  51. * @return array Array of the options to use.
  52. */
  53. public function frontend_tracking_options( ) {
  54. return array();
  55. }
  56. /**
  57. * Get frontend output.
  58. *
  59. * This function is used to return the Javascript
  60. * to output in the head of the page for the given
  61. * tracking method.
  62. *
  63. * @since 6.0.0
  64. * @access public
  65. *
  66. * @return string Javascript to output.
  67. */
  68. public function frontend_output( ) {
  69. $output = '<!-- This site uses the Google Analytics by MonsterInsights plugin v ' . MONSTERINSIGHTS_VERSION .' - https://www.monsterinsights.com/ -->';
  70. $output .= '<!-- ' . esc_html__( "You are currently in a preview window. MonsterInsights doesn't track preview window traffic to avoid false visit reports.", 'google-analytics-for-wordpress' ) . ' -->';
  71. $output .= '<!-- / Google Analytics by MonsterInsights -->';
  72. return $output;
  73. }
  74. }