33Plugin Name: Fathom Analytics
44Description: A simple plugin to add the Fathom tracking snippet to your WordPress site.
55Author: Fathom Team
6- Version: 1.0.0
6+ Version: 1.0.1
77
88Fathom Analytics for WordPress
99Copyright (C) 2018 Danny van Kooten
2525const FATHOM_URL_OPTION_NAME = 'fathom_url ' ;
2626const FATHOM_SITE_ID_OPTION_NAME = 'fathom_site_id ' ;
2727
28+ /**
29+ * @since 1.0.0
30+ */
2831function fathom_get_url () {
2932 $ fathom_url = get_option ( FATHOM_URL_OPTION_NAME , '' );
3033
@@ -42,10 +45,16 @@ function fathom_get_url() {
4245 return $ fathom_url ;
4346}
4447
48+ /**
49+ * @since 1.0.1
50+ */
4551function fathom_get_site_id () {
4652 return get_option ( FATHOM_SITE_ID_OPTION_NAME , '' );
4753}
4854
55+ /**
56+ * @since 1.0.0
57+ */
4958function fathom_print_js_snippet () {
5059 $ url = fathom_get_url ();
5160
@@ -57,7 +66,7 @@ function fathom_print_js_snippet() {
5766 $ site_id = fathom_get_site_id ();
5867
5968 ?>
60- <!-- Fathom - simple website analytics - https://github .com/usefathom/fathom -->
69+ <!-- Fathom - simple website analytics - https://usefathom .com/ -->
6170 <script>
6271 (function(f, a, t, h, o, m){
6372 a[h]=a[h]||function(){
@@ -76,23 +85,29 @@ function fathom_print_js_snippet() {
7685 <?php
7786}
7887
88+ /**
89+ * @since 1.0.0
90+ */
7991function fathom_register_settings () {
8092 $ fathom_logo_html = sprintf ( '<a href="https://usefathom.com/" style="margin-left: 6px;"><img src="%s" width=16 height=16 style="vertical-align: bottom;"></a> ' , plugins_url ( 'fathom.svg ' , __FILE__ ) );
93+
94+ // register page + section
8195 add_options_page ( 'Fathom Analytics ' , 'Fathom Analytics ' , 'manage_options ' , 'fathom-analytics ' , 'fathom_print_settings_page ' );
8296 add_settings_section ( 'default ' , "Fathom Analytics {$ fathom_logo_html }" , '__return_true ' , 'fathom-analytics ' );
8397
84- // register option
98+ // register options
8599 register_setting ( 'fathom ' , FATHOM_URL_OPTION_NAME , array ( 'type ' => 'string ' ) );
86100 register_setting ( 'fathom ' , FATHOM_SITE_ID_OPTION_NAME , array ( 'type ' => 'string ' ) );
87101
88102 // register settings fields
89- $ title = __ ( 'Dashboard URL ' , 'fathom-analytics ' );
90- add_settings_field ( FATHOM_URL_OPTION_NAME , $ title , 'fathom_print_url_setting_field ' , 'fathom-analytics ' , 'default ' );
103+ add_settings_field ( FATHOM_URL_OPTION_NAME , __ ( 'Dashboard URL ' , 'fathom-analytics ' ), 'fathom_print_url_setting_field ' , 'fathom-analytics ' , 'default ' );
91104
92- $ title = __ ( 'Site ID ' , 'fathom-analytics ' );
93- add_settings_field ( FATHOM_SITE_ID_OPTION_NAME , $ title , 'fathom_print_site_id_setting_field ' , 'fathom-analytics ' , 'default ' );
105+ add_settings_field ( FATHOM_SITE_ID_OPTION_NAME , __ ( 'Site ID ' , 'fathom-analytics ' ), 'fathom_print_site_id_setting_field ' , 'fathom-analytics ' , 'default ' );
94106}
95107
108+ /**
109+ * @since 1.0.1
110+ */
96111function fathom_print_settings_page () {
97112 echo '<div class="wrap"> ' ;
98113 echo sprintf ( '<form method="POST" action="%s"> ' , esc_attr ( admin_url ( 'options.php ' ) ) );
@@ -103,13 +118,19 @@ function fathom_print_settings_page() {
103118 echo '</div> ' ;
104119}
105120
121+ /**
122+ * @since 1.0.0
123+ */
106124function fathom_print_url_setting_field ( $ args = array () ) {
107125 $ value = get_option ( FATHOM_URL_OPTION_NAME );
108126 $ placeholder = 'https://my-stats.usefathom.com/ ' ;
109127 echo sprintf ( '<input type="text" name="%s" id="%s" class="regular-text" value="%s" placeholder="%s" /> ' , FATHOM_URL_OPTION_NAME , FATHOM_URL_OPTION_NAME , esc_attr ( $ value ), esc_attr ( $ placeholder ) );
110128 echo '<p class="description"> ' . __ ( 'Enter the full URL to your Fathom instance here. ' , 'fathom-analytics ' ) . '</p> ' ;
111129}
112130
131+ /**
132+ * @since 1.0.1
133+ */
113134function fathom_print_site_id_setting_field ( $ args = array () ) {
114135 $ value = get_option ( FATHOM_SITE_ID_OPTION_NAME );
115136 $ placeholder = 'ABCDEF ' ;
0 commit comments