| @@ -1,14 +1,15 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /* |
| 3 | 3 | * Plugin Name: Simple Analytics Official |
| 4 | - * Version: 1.27 | |
| 4 | + * Version: 1.109 | |
| 5 | 5 | * Plugin URI: https://docs.simpleanalytics.com/install-simple-analytics-on-wordpress |
| 6 | 6 | * Description: Embed Simple Analytics script in your WordPress website |
| 7 | 7 | * Author: Simple Analytics |
| 8 | 8 | * Author URI: https://simpleanalytics.com/ |
| 9 | - * Requires at least: 5.2.0 | |
| 10 | - * Tested up to: 6.7 | |
| 9 | + * Requires at least: 6.9.4 | |
| 10 | + * Requires PHP: 7.2.0 | |
| 11 | + * Tested up to: 7.0.2 | |
| 11 | 12 | * |
| 12 | 13 | * Text Domain: simple-analytics |
| 13 | 14 | * Domain Path: /lang/ |
| 14 | 15 | * |
| @@ -28,14 +29,15 @@ | ||
| 28 | 29 | * @note Manual loading rather than Composer to avoid potential conflict with plugins/themes that ship older autoloader. |
| 29 | 30 | */ |
| 30 | 31 | require __DIR__ . '/src/Support/SvgIcon.php'; |
| 31 | 32 | require __DIR__ . '/helpers.php'; |
| 32 | -require __DIR__ . '/src/PluginLifecycle.php'; | |
| 33 | 33 | require __DIR__ . '/src/Plugin.php'; |
| 34 | +require __DIR__ . '/src/WordPressHooks.php'; | |
| 35 | +require __DIR__ . '/src/WordPressSettings.php'; | |
| 34 | 36 | require __DIR__ . '/src/Setting.php'; |
| 35 | 37 | require __DIR__ . '/src/SettingName.php'; |
| 36 | -require __DIR__ . '/src/TrackingPolicy.php'; | |
| 37 | -require __DIR__ . '/src/ScriptManager.php'; | |
| 38 | +require __DIR__ . '/src/TrackingRules.php'; | |
| 39 | +require __DIR__ . '/src/ScriptRegistry.php'; | |
| 38 | 40 | require __DIR__ . '/src/Scripts/Contracts/Script.php'; |
| 39 | 41 | require __DIR__ . '/src/Scripts/Contracts/HideScriptId.php'; |
| 40 | 42 | require __DIR__ . '/src/Scripts/Contracts/HasAttributes.php'; |
| 41 | 43 | require __DIR__ . '/src/Scripts/AnalyticsScript.php'; |
| @@ -51,9 +53,9 @@ | ||
| 51 | 53 | require __DIR__ . '/src/Settings/Concerns/HasDocs.php'; |
| 52 | 54 | require __DIR__ . '/src/Settings/Concerns/HasPlaceholder.php'; |
| 53 | 55 | require __DIR__ . '/src/Settings/Concerns/ManagesBlocks.php'; |
| 54 | 56 | require __DIR__ . '/src/Settings/Concerns/WordPressPageIntegration.php'; |
| 55 | -require __DIR__ . '/src/Settings/Page.php'; | |
| 57 | +require __DIR__ . '/src/Settings/AdminPage.php'; | |
| 56 | 58 | require __DIR__ . '/src/Settings/Blocks/Fields/Field.php'; |
| 57 | 59 | require __DIR__ . '/src/Settings/Blocks/Fields/Input.php'; |
| 58 | 60 | require __DIR__ . '/src/Settings/Blocks/Fields/Checkboxes.php'; |
| 59 | 61 | require __DIR__ . '/src/Settings/Blocks/Fields/Checkbox.php'; |
| @@ -62,7 +64,108 @@ | ||
| 62 | 64 | require __DIR__ . '/src/UI/LabelComponent.php'; |
| 63 | 65 | require __DIR__ . '/src/UI/TabListComponent.php'; |
| 64 | 66 | require __DIR__ . '/src/UI/PageLayoutComponent.php'; |
| 65 | 67 | |
| 66 | -use SimpleAnalytics\Plugin; | |
| 68 | +use SimpleAnalytics\SettingName; | |
| 69 | +use SimpleAnalytics\Settings\Tab; | |
| 70 | +use function SimpleAnalytics\get_icon; | |
| 67 | 71 | |
| 68 | -(new Plugin)->boot(); | |
| 72 | +$settings = new SimpleAnalytics\WordPressSettings(); | |
| 73 | +$hooks = new SimpleAnalytics\WordPressHooks(); | |
| 74 | +$rules = new SimpleAnalytics\TrackingRules($settings); | |
| 75 | +$scripts = new SimpleAnalytics\ScriptRegistry(/*TODO TAKE $hooks WordPressHooks as arg/dependency*/); | |
| 76 | + | |
| 77 | +$adminPage = SimpleAnalytics\Settings\AdminPage::title('Simple Analytics') | |
| 78 | + ->slug('simpleanalytics') | |
| 79 | + ->tab('General', function (Tab $tab) { | |
| 80 | + }) | |
| 81 | + ->tab('Ignore Rules', function (Tab $tab) { | |
| 82 | + $tab->icon(get_icon('eye-slash')); | |
| 83 | + | |
| 84 | + $tab->input(SettingName::IGNORE_PAGES, 'Ignore Pages') | |
| 85 | + ->description('Comma separated list of pages to ignore. E.g. /contact, /about') | |
| 86 | + ->placeholder('Example: /page1, /page2, /category/*') | |
| 87 | + ->docs('https://docs.simpleanalytics.com/ignore-pages'); | |
| 88 | + | |
| 89 | + $tab->callout('IP and role exclusion only works when there is no page caching.'); | |
| 90 | + | |
| 91 | + $tab->multiCheckbox(SettingName::EXCLUDED_ROLES, 'Specific User Roles to Exclude') | |
| 92 | + ->description('When none selected, all authenticated users will be excluded from tracking.') | |
| 93 | + ->options(function () { | |
| 94 | + return wp_roles()->get_names(); | |
| 95 | + }); | |
| 96 | + | |
| 97 | + $tab->ipList(SettingName::EXCLUDED_IP_ADDRESSES, 'Exclude IP Addresses') | |
| 98 | + ->placeholder("127.0.0.1\n192.168.0.1") | |
| 99 | + ->description('IP addresses to exclude from tracking.'); | |
| 100 | + }) | |
| 101 | + ->tab('Advanced', function (Tab $tab) { | |
| 102 | + $tab->icon(get_icon('cog')); | |
| 103 | + | |
| 104 | + $tab->input(SettingName::CUSTOM_DOMAIN, 'Custom Domain') | |
| 105 | + ->placeholder('Enter your custom domain or leave it empty.') | |
| 106 | + ->description('E.g. api.example.com. Leave empty to use the default domain (most users).') | |
| 107 | + ->docs('https://docs.simpleanalytics.com/bypass-ad-blockers'); | |
| 108 | + | |
| 109 | + $tab->checkbox(SettingName::COLLECT_DNT, 'Collect Do Not Track') | |
| 110 | + ->description('If you want to collect visitors with Do Not Track enabled, turn this on.') | |
| 111 | + ->docs('https://docs.simpleanalytics.com/dnt'); | |
| 112 | + | |
| 113 | + $tab->checkbox(SettingName::HASH_MODE, 'Hash mode') | |
| 114 | + ->description('If your website uses hash (#) navigation, turn this on. On most WordPress websites this is not relevant.') | |
| 115 | + ->docs('https://docs.simpleanalytics.com/hash-mode'); | |
| 116 | + | |
| 117 | + $tab->checkbox(SettingName::MANUAL_COLLECT, 'Manually collect page views') | |
| 118 | + ->description('In case you don’t want to auto collect page views, but via `sa_pageview` function in JavaScript.') | |
| 119 | + ->docs('https://docs.simpleanalytics.com/trigger-custom-page-views#use-custom-collection-anyway'); | |
| 120 | + | |
| 121 | + $tab->checkbox(SettingName::NOSCRIPT, 'Support no JavaScript mode') | |
| 122 | + ->description('Collect analytics from visitors with disabled or no JavaScript.'); | |
| 123 | + | |
| 124 | + $tab->input(SettingName::ONLOAD_CALLBACK, 'Onload Callback') | |
| 125 | + ->description('JavaScript function to call when the script is loaded.') | |
| 126 | + ->placeholder('Example: sa_event("My event")') | |
| 127 | + ->docs('https://docs.simpleanalytics.com/trigger-custom-page-views#use-custom-collection-anyway'); | |
| 128 | + | |
| 129 | + $tab->input(SettingName::HOSTNAME, 'Overwrite domain name') | |
| 130 | + ->description('Override the domain that is sent to Simple Analytics. Useful for multi-domain setups.') | |
| 131 | + ->placeholder('Example: example.com') | |
| 132 | + ->docs('https://docs.simpleanalytics.com/overwrite-domain-name'); | |
| 133 | + | |
| 134 | + $tab->input(SettingName::SA_GLOBAL, 'Global variable name') | |
| 135 | + ->description('Change the global variable name of Simple Analytics. Default is `sa_event`.') | |
| 136 | + ->placeholder('Example: ba_event') | |
| 137 | + ->docs('https://docs.simpleanalytics.com/events#the-variable-sa_event-is-already-used'); | |
| 138 | + }) | |
| 139 | + ->tab('Events', function (Tab $tab) { | |
| 140 | + $tab->title('Automated events') | |
| 141 | + ->icon(get_icon('events')) | |
| 142 | + ->description("It will track outbound links, email addresses clicks, | |
| 143 | + and amount of downloads for common files (pdf, csv, docx, xIsx). | |
| 144 | + Events will appear on your events page on simpleanalytics.com"); | |
| 145 | + | |
| 146 | + $tab->checkbox(SettingName::AUTOMATED_EVENTS, 'Collect automated events'); | |
| 147 | + | |
| 148 | + $tab->input(SettingName::EVENT_COLLECT_DOWNLOADS, 'Auto collect downloads') | |
| 149 | + ->placeholder('Example: outbound,emails,downloads') | |
| 150 | + ->docs('https://docs.simpleanalytics.com/automated-events'); | |
| 151 | + | |
| 152 | + $tab->input(SettingName::EVENT_EXTENSIONS, 'Download file extensions') | |
| 153 | + ->description('Comma separated list of file extensions to track as downloads. E.g. pdf, zip') | |
| 154 | + ->placeholder('Example: pdf, zip') | |
| 155 | + ->docs('https://docs.simpleanalytics.com/automated-events'); | |
| 156 | + | |
| 157 | + $tab->checkbox(SettingName::EVENT_USE_TITLE, 'Use titles of page') | |
| 158 | + ->description('Use the title of the page as the event name. Default is the URL.') | |
| 159 | + ->docs('https://docs.simpleanalytics.com/automated-events'); | |
| 160 | + | |
| 161 | + $tab->checkbox(SettingName::EVENT_FULL_URLS, 'Use full URLs') | |
| 162 | + ->description('Use full URLs instead of the path. Default is the path.') | |
| 163 | + ->docs('https://docs.simpleanalytics.com/automated-events'); | |
| 164 | + | |
| 165 | + $tab->input(SettingName::EVENT_SA_GLOBAL, 'Override global') | |
| 166 | + ->description('Override the global variable name of Simple Analytics. Default is `sa_event`.') | |
| 167 | + ->placeholder('Example: ba_event') | |
| 168 | + ->docs('https://docs.simpleanalytics.com/events#the-variable-sa_event-is-already-used'); | |
| 169 | + }); | |
| 170 | + | |
| 171 | +(new SimpleAnalytics\Plugin($hooks, $settings, $rules, $scripts, $adminPage))->boot(); | |