├── LICENSE ├── README.markdown ├── goatcounter.php └── readme.txt /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2020 Martin Tournoij 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to 7 | deal in the Software without restriction, including without limitation the 8 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9 | sell copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | The software is provided "as is", without warranty of any kind, express or 16 | implied, including but not limited to the warranties of merchantability, 17 | fitness for a particular purpose and noninfringement. In no event shall the 18 | authors or copyright holders be liable for any claim, damages or other 19 | liability, whether in an action of contract, tort or otherwise, arising 20 | from, out of or in connection with the software or the use or other dealings 21 | in the software. 22 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | Wordpress plugin for [GoatCounter](https://www.goatcounter.com). Can be used 2 | with either the hosted goatcounter.com service or when self-hosting GoatCounter. 3 | 4 | It's compatible with any version of GoatCounter. 5 | 6 | The current status is very basic; more options will be added in later versions. 7 | 8 | Installation instructions: clone this repo in the `wp-content/plugins/` 9 | directory and activate it in the WordPress admin panel. 10 | 11 | This should give you a "GoatCounter" menu item in the sidebar; you'll need to 12 | fill in you site's URL on the settings page before it works. 13 | -------------------------------------------------------------------------------- /goatcounter.php: -------------------------------------------------------------------------------- 1 | ', 29 | esc_attr($opts['goatcounter_field_endpoint'])); 30 | } 31 | 32 | // Add top level menu page. 33 | add_action('admin_menu', 'goatcounter_options_page'); 34 | function goatcounter_options_page() { 35 | add_menu_page('GoatCounter', 'GoatCounter', 'manage_options', 36 | 'goatcounter', 'goatcounter_options_page_html'); 37 | } 38 | 39 | // Add settings page. 40 | add_action('admin_init', 'goatcounter_settings'); 41 | function goatcounter_settings() { 42 | register_setting('goatcounter', 'goatcounter_options'); 43 | 44 | add_settings_section('goatcounter_section_developers', 45 | __('Settings for GoatCounter analytics', 'goatcounter'), 46 | 'goatcounter_section_developers', 47 | 'goatcounter'); 48 | 49 | add_settings_field('goatcounter_field_endpoint', __('Endpoint', 'goatcounter'), 50 | 'goatcounter_field_endpoint', 'goatcounter', 51 | 'goatcounter_section_developers', [ 52 | 'label_for' => 'goatcounter_field_endpoint', 53 | 'class' => 'goatcounter_row', 54 | 'description' => __('e.g. https://mycode.goatcounter.com/count', 'goatcounter'), 55 | ]); 56 | 57 | add_settings_field('goatcounter_field_custom', __('Custom integration', 'goatcounter'), 58 | 'goatcounter_field_custom', 'goatcounter', 59 | 'goatcounter_section_developers', [ 60 | 'label_for' => 'goatcounter_field_custom', 61 | 'class' => 'goatcounter_row', 62 | 'description' => __('When filled in the above fields will be ignored, and this JS will be inserted as-is. See ‘site code’ in your GoatCounter menu for documentation. This should include the script tags etc.', 'goatcounter'), 63 | ]); 64 | } 65 | 66 | // Generate settings page HTML. 67 | function goatcounter_options_page_html() { 68 | if (!current_user_can('manage_options')) 69 | return; 70 | 71 | if (isset($_GET['settings-updated'])) 72 | add_settings_error('goatcounter_messages', 'goatcounter_message', __('Settings Saved', 'goatcounter'), 'updated'); 73 | 74 | settings_errors('goatcounter_messages'); 75 | 76 | print('
See https://www.goatcounter.com/contact on how to get support, report bugs, etc.
', 89 | esc_attr($args['id'])); 90 | } 91 | 92 | function goatcounter_field_endpoint($args) { 93 | $opts = get_option('goatcounter_options'); 94 | printf(' 95 |%s
', 96 | esc_attr($args['label_for']), 97 | esc_attr($opts['goatcounter_field_endpoint']), 98 | esc_html($args['description'])); 99 | } 100 | 101 | function goatcounter_field_custom($args) { 102 | $opts = get_option('goatcounter_options'); 103 | printf(' 104 |%s
', 105 | esc_attr($args['label_for']), 106 | esc_html($opts['goatcounter_field_custom']), 107 | esc_html($args['description'])); 108 | } 109 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === goatcounter === 2 | Contributors: arp242 3 | Stable tag: trunk 4 | Tested up to: 5.4.1 5 | Tags: analytics 6 | Donate link: https://www.goatcounter.com/contribute 7 | License: MIT 8 | 9 | Wordpress plugin for GoatCounter; can be used with either the hosted goatcounter.com service or when self-hosting GoatCounter. 10 | 11 | == Description == 12 | Wordpress plugin for GoatCounter (https://www.goatcounter.com); can be used with either the hosted goatcounter.com service or when self-hosting GoatCounter. 13 | 14 | It\'s compatible with any version of GoatCounter. 15 | 16 | The current status is very basic; more options will be added in later versions. 17 | --------------------------------------------------------------------------------