0cdf8634 by Marty Penner

Format Analytics.php

1 parent ef4a1033
...@@ -9,54 +9,70 @@ const OPTION_NAME = 'tz_analytics'; ...@@ -9,54 +9,70 @@ const OPTION_NAME = 'tz_analytics';
9 const OPTION_GROUP = 'reading'; 9 const OPTION_GROUP = 'reading';
10 const OPTION_SECTION = 'tz_analytics_main'; 10 const OPTION_SECTION = 'tz_analytics_main';
11 11
12 call_user_func(function() { 12 call_user_func(
13 function () {
13 Vars::$options = new Tools\WP_Option(OPTION_NAME); 14 Vars::$options = new Tools\WP_Option(OPTION_NAME);
14 15
15 Tools\add_actions(__NAMESPACE__ . '\Actions'); 16 Tools\add_actions(__NAMESPACE__.'\Actions');
16 }); 17 }
18 );
17 19
18 function validate($data) { 20 function validate($data)
21 {
19 return $data; 22 return $data;
20 } 23 }
21 24
22 class Actions { 25 class Actions
23 public static function admin_init() { 26 {
24 register_setting(OPTION_GROUP, OPTION_NAME, __NAMESPACE__ . '\validate'); 27 public static function admin_init()
25 add_settings_section(OPTION_SECTION, 'Google Analytics', function() {}, OPTION_GROUP); 28 {
29 register_setting(OPTION_GROUP, OPTION_NAME, __NAMESPACE__.'\validate');
30 add_settings_section(
31 OPTION_SECTION,
32 'Google Analytics',
33 function () {
34 },
35 OPTION_GROUP
36 );
26 37
27 Tools\add_settings_fields(__NAMESPACE__ . '\Fields', OPTION_GROUP, OPTION_SECTION); 38 Tools\add_settings_fields(__NAMESPACE__.'\Fields', OPTION_GROUP, OPTION_SECTION);
28 } 39 }
29 40
30 public static function wp_print_scripts() { 41 public static function wp_print_scripts()
42 {
31 if (Tz\LIVE !== 1 || empty(Vars::$options['api_key'])) { 43 if (Tz\LIVE !== 1 || empty(Vars::$options['api_key'])) {
32 return; 44 return;
33 } 45 }
34 ?> 46 ?>
35 <script type="text/javascript"> 47 <script>
36 var _gaq = _gaq || []; 48 var _gaq = _gaq || [];
37 _gaq.push(['_setAccount', '<?php echo Vars::$options['api_key']; ?>']); 49 _gaq.push(['_setAccount', '<?php echo Vars::$options['api_key']; ?>']);
38 _gaq.push(['_trackPageview']); 50 _gaq.push(['_trackPageview']);
39 51
40 // _gaq.push(['_trackEvent', 'download', 'Membership', 'sub category?']); 52 // _gaq.push(['_trackEvent', 'download', 'Membership', 'sub category?']);
41 53
42 (function() { 54 (function () {
43 var ga = document.createElement('script'); ga.type = 'text/javascript'; 55 var ga = document.createElement('script');
44 ga.async = true; 56 ga.type = 'text/javascript';
45 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 57 ga.async = true;
46 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); 58 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
47 })(); 59 var s = document.getElementsByTagName('script')[0];
48 </script> 60 s.parentNode.insertBefore(ga, s);
49 <?php 61 })();
62 </script>
63 <?php
50 } 64 }
51 } 65 }
52 66
53 class Fields { 67 class Fields
54 public static function api_key() { 68 {
55 echo '<input type="text" name="' . OPTION_NAME . '[' . __FUNCTION__ . ']" id="' . __FUNCTION__ . '" value="' . Vars::$options[__FUNCTION__] . '" />'; 69 public static function api_key()
70 {
71 echo '<input type="text" name="'.OPTION_NAME.'['.__FUNCTION__.']" id="'.__FUNCTION__.'" value="'.Vars::$options[__FUNCTION__].'" />';
56 } 72 }
57 } 73 }
58 74
59 class Vars { 75 class Vars
76 {
60 public static $options; 77 public static $options;
61 } 78 }
62 ?>
...\ No newline at end of file ...\ No newline at end of file
......