Changeset 3753881
- Timestamp:
- 10/19/2026 03:15:28 AM (5 weeks ago)
- Location:
- onlygrow-analytics/trunk
- Files:
-
- 3 added
- 29 edited
-
backend/app/extensions/analytics/handlers/DiagnoseHandler.php (modified) (1 diff)
-
backend/app/extensions/analytics/helpers/SettingsHelper.php (modified) (7 diffs)
-
backend/app/extensions/analytics/routes/settings.php (modified) (1 diff)
-
backend/app/extensions/analytics/wordpress.php (modified) (1 diff)
-
backend/app/extensions/analytics/wordpress/changelog.php (modified) (2 diffs)
-
backend/app/extensions/analytics/wordpress/dashboard-widget.php (modified) (1 diff)
-
backend/app/extensions/analytics/wordpress/editor-panel.php (modified) (3 diffs)
-
backend/app/extensions/analytics/wordpress/optimizers.php (added)
-
backend/framework/version.php (modified) (1 diff)
-
onlygrow-analytics.php (modified) (1 diff)
-
public/app/extensions/analytics/assets/css/build/times.css (modified) (1 diff)
-
public/app/extensions/analytics/assets/css/main.css (modified) (1 diff)
-
public/app/extensions/analytics/assets/css/print.css (modified) (1 diff)
-
public/app/extensions/analytics/assets/css/tools/diagnose.css (modified) (1 diff)
-
public/app/extensions/analytics/assets/js/build/times.js (modified) (3 diffs)
-
public/app/extensions/analytics/assets/js/dashboard/health.js (modified) (1 diff)
-
public/app/extensions/analytics/assets/js/settings/track.js (modified) (1 diff)
-
public/app/extensions/analytics/assets/js/tools/diagnose.js (modified) (1 diff)
-
public/app/extensions/analytics/assets/js/wp-editor/classic-panel.js (added)
-
public/app/extensions/analytics/assets/js/wp-editor/post-chart.js (added)
-
public/app/extensions/analytics/assets/js/wp-editor/post-panel.js (modified) (5 diffs)
-
public/app/extensions/analytics/assets/js/wp-widget/dashboard-widget.js (modified) (2 diffs)
-
public/app/extensions/analytics/index.json (modified) (1 diff)
-
public/app/extensions/analytics/lang/en.json (modified) (4 diffs)
-
public/app/extensions/analytics/lang/es.json (modified) (4 diffs)
-
public/app/extensions/analytics/views/settings/track.json (modified) (1 diff)
-
public/app/extensions/analytics/views/settings/tracking.json (modified) (1 diff)
-
public/framework/css/base.css (modified) (1 diff)
-
public/framework/css/themes/brutal/theme.css (modified) (1 diff)
-
public/framework/css/themes/cobalt/theme.css (modified) (1 diff)
-
public/framework/icons/set.js (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
onlygrow-analytics/trunk/backend/app/extensions/analytics/handlers/DiagnoseHandler.php
r3753515 r3753881 100 100 $served = html_entity_decode($src[1]); 101 101 $now = $this->og->helper('analytics:ghost')->scriptUrl($this->og->dir($this->og->slug() . '.php'), 'public/app/analytics/js/tracker'); 102 if ($bare($served) !== $bare($now)) { 102 $ours = (bool) preg_match('#/[a-z0-9]{8}/a\.js|/' . preg_quote($this->og->slug(), '#') . '/public/app/analytics/js/tracker#', $served); 103 if ($ours && $bare($served) !== $bare($now)) { 103 104 $js = $this->get($served); 104 105 $old[] = ['kind' => 'script', 'url' => $served, 'alive' => $js !== null && $js[0] === 200]; -
onlygrow-analytics/trunk/backend/app/extensions/analytics/helpers/SettingsHelper.php
r3753515 r3753881 310 310 'exclude_comment_spam' => (bool) $this->get('exclude_comment_spam'), 311 311 'exclude_flagged' => (bool) $this->get('exclude_flagged'), 312 'tracking_paused' => (bool) $this->get('tracking_paused'),313 312 'count_logged_in' => (bool) $this->get('count_logged_in'), 314 313 'exclude_roles' => (object) array_fill_keys(array_map('strval', (array) $this->get('exclude_roles')), ['enabled' => true]), … … 375 374 'exclude_comment_spam' => !empty($input['exclude_comment_spam']), 376 375 'exclude_flagged' => !empty($input['exclude_flagged']), 377 'tracking_paused' => !empty($input['tracking_paused']),378 376 ]; 379 377 $this->set($own + $this->addonSection('save', 'tracking', $own, $input)); 380 378 $this->og->handler('analytics:comment-spam')->run(); 381 $this->og->cache->forget('analytics:health');382 379 return $this->tracking() + ['dropped' => $dropped]; 383 380 } … … 414 411 'tracking' => $this->tracking(), 415 412 'data' => ['anonymize_ip' => (bool) $this->get('anonymize_ip')], 416 'track' => ['ghost_mode' => (bool) $this->get('ghost_mode'), 'visitor_mode' => (string) $this->get('visitor_mode')], 413 'track' => ['ghost_mode' => (bool) $this->get('ghost_mode'), 'visitor_mode' => (string) $this->get('visitor_mode'), 414 'tracking_paused' => (bool) $this->get('tracking_paused')], 417 415 ]; 418 416 } … … 460 458 'exclude_comment_spam' => !empty($t['exclude_comment_spam']), 461 459 'exclude_flagged' => !empty($t['exclude_flagged']), 462 'tracking_paused' => !empty($t['tracking_paused']),463 460 'count_logged_in' => !empty($t['count_logged_in']), 464 461 'exclude_roles' => is_array($t['exclude_roles'] ?? null) ? $t['exclude_roles'] : [], … … 477 474 } 478 475 if (($k = $sec('track')) !== null) { 476 $legacy = is_array($in['tracking'] ?? null) && array_key_exists('tracking_paused', $in['tracking']) ? !empty($in['tracking']['tracking_paused']) : null; 479 477 $this->saveTrack([ 480 478 'ghost_mode' => array_key_exists('ghost_mode', $k) ? !empty($k['ghost_mode']) : (bool) $this->get('ghost_mode'), 481 479 'visitor_mode' => is_scalar($k['visitor_mode'] ?? null) ? (string) $k['visitor_mode'] : (string) $this->get('visitor_mode'), 480 'tracking_paused' => array_key_exists('tracking_paused', $k) ? !empty($k['tracking_paused']) : ($legacy ?? (bool) $this->get('tracking_paused')), 482 481 ], $pluginFile); 483 482 $done[] = 'track'; … … 490 489 'ghost_mode' => (bool) $this->get('ghost_mode'), 491 490 'visitor_mode' => (string) $this->get('visitor_mode'), 491 'tracking_paused' => (bool) $this->get('tracking_paused'), 492 492 'endpoint' => Og::isWordPress() ? $this->og->helper('analytics:endpoint')->url() : '', 493 493 ]; … … 499 499 'ghost_mode' => !empty($input['ghost_mode']), 500 500 'visitor_mode' => in_array($mode, self::VISITOR_MODES, true) ? $mode : (string) self::DEFAULTS['visitor_mode'], 501 ] );501 ] + (array_key_exists('tracking_paused', $input) ? ['tracking_paused' => !empty($input['tracking_paused'])] : [])); 502 502 if (Og::isWordPress() && $pluginFile !== '') { 503 503 $this->og->helper('analytics:ghost')->ensure($pluginFile); 504 504 } 505 $this->og->cache->forget('analytics:health'); 505 506 return $this->track(); 506 507 } -
onlygrow-analytics/trunk/backend/app/extensions/analytics/routes/settings.php
r3753515 r3753881 186 186 return OgResponse::json(['error' => 'forbidden'], 403); 187 187 } 188 return $og->helper('analytics:settings')->saveTrack(['ghost_mode' => $req->bool('ghost_mode'), 'visitor_mode' => (string) $req->input('visitor_mode', '')], $og->dir($og->slug() . '.php')); 188 return $og->helper('analytics:settings')->saveTrack(['ghost_mode' => $req->bool('ghost_mode'), 'visitor_mode' => (string) $req->input('visitor_mode', ''), 189 'tracking_paused' => $req->bool('tracking_paused')], $og->dir($og->slug() . '.php')); 189 190 }); 190 191 -
onlygrow-analytics/trunk/backend/app/extensions/analytics/wordpress.php
r3752543 r3753881 3 3 defined('ABSPATH') || exit; 4 4 5 foreach (['functions', 'icons', 'tracker', 'processing', 'admin-page', 'columns', 'editor-panel', 'admin-bar', 'dashboard-widget', 'rest-fallback', 'counter', 'comment-spam', 'changelog' ] as $onlygrow_analytics_part) {5 foreach (['functions', 'icons', 'tracker', 'processing', 'admin-page', 'columns', 'editor-panel', 'admin-bar', 'dashboard-widget', 'rest-fallback', 'counter', 'comment-spam', 'changelog', 'optimizers'] as $onlygrow_analytics_part) { 6 6 require __DIR__ . '/wordpress/' . $onlygrow_analytics_part . '.php'; 7 7 } -
onlygrow-analytics/trunk/backend/app/extensions/analytics/wordpress/changelog.php
r3753515 r3753881 21 21 } 22 22 $badges = onlygrow_analytics_changelog_badges(); 23 $html = onlygrow_analytics_changelog_text((string) $res->sections['changelog']); 23 24 $res->sections['changelog'] = preg_replace_callback('/\[\[\s*([a-z]+)\s*\]\]/i', static function (array $m) use ($badges): string { 24 25 $key = strtolower($m[1]); 25 26 return isset($badges[$key]) ? '<span class="og-cl og-cl-' . $key . '">' . esc_html($badges[$key]) . '</span>' : $m[0]; 26 }, (string) $res->sections['changelog']);27 }, $html); 27 28 return $res; 28 29 }, 10, 2); 30 31 function onlygrow_analytics_changelog_text(string $html): string { 32 $word = "[A-Z][\\w'’-]*"; 33 $seg = "{$word}(?:\\s(?:{$word}|[\\/&]))*(?:\\s[a-z][\\w-]*(?=[.,;:)]|\\s*$))?"; 34 $menu = "/(?<![\\w>]){$seg}(?:\\s*(?:→|→)\\s*{$seg})+/u"; 35 $html = (string) preg_replace('#<span\b[^>]*\bwp-exclude-emoji\b[^>]*>\s*(→|→|&\#8594;)\s*</span>#u', '→', $html); 36 $parts = preg_split('/(<[^>]+>)/', $html, -1, PREG_SPLIT_DELIM_CAPTURE) ?: [$html]; 37 $inCode = 0; 38 foreach ($parts as $i => $part) { 39 if ($part !== '' && $part[0] === '<') { 40 $inCode += preg_match('#^<code\b#i', $part) ? 1 : (preg_match('#^</code>#i', $part) ? -1 : 0); 41 continue; 42 } 43 if ($inCode > 0 || trim($part) === '') { 44 continue; 45 } 46 $part = (string) preg_replace($menu, '<code>$0</code>', $part); 47 $parts[$i] = (string) preg_replace('/\(([^()<>]+)\)/u', '<em>($1)</em>', $part); 48 } 49 return implode('', $parts); 50 } 29 51 30 52 add_action('admin_enqueue_scripts', static function (string $hook) use ($instance) { … … 40 62 . 'background:transparent;font-size:9px;font-weight:600;line-height:1.6;text-align:center;text-transform:uppercase;' 41 63 . 'letter-spacing:.04em;vertical-align:1px;color:#646970}' 42 . '#section-changelog li{font-size:.98em;line-height:1.4}' 64 . '#section-changelog li{font-size:.97em;line-height:1.2;margin-bottom:10px}' 65 . '#section-changelog li code{padding:1px 2px;background:#f2f2f2;font-size:.7rem}' 66 . '#plugin-information .section ul{list-style-type:none;margin-left:0}' 43 67 . '.og-cl-new{color:#008a20}.og-cl-added{color:#2271b1}.og-cl-improved{color:#3858e9}.og-cl-changed{color:#7b46b8}' 44 68 . '.og-cl-fixed{color:#a36b00}.og-cl-removed{color:#d63638}.og-cl-security{color:#8a2424}' -
onlygrow-analytics/trunk/backend/app/extensions/analytics/wordpress/dashboard-widget.php
r3752543 r3753881 47 47 wp_enqueue_script('og-analytics-visits-chart', $url('js/dashboard/visits-chart.js'), ['og-analytics-bars3d'], $version, ['in_footer' => true]); 48 48 wp_enqueue_script('og-analytics-wp-widget', $url('js/wp-widget/dashboard-widget.js'), ['og-analytics-visits-chart'], $version, ['in_footer' => true]); 49 $series = array_values(array_intersect(['views', 'visits', 'first'], 50 (array) apply_filters('onlygrow_analytics_widget_series', ['visits']))); 49 51 wp_add_inline_script('og-analytics-wp-widget', 'window.ogAnalyticsWidget = ' . wp_json_encode([ 50 52 'api' => trailingslashit(rest_url($instance->restNamespace())), 53 'series' => $series ?: ['visits'], 51 54 'nonce' => wp_create_nonce('wp_rest'), 52 55 'locale' => str_starts_with(get_user_locale(), 'es') ? 'es' : 'en', -
onlygrow-analytics/trunk/backend/app/extensions/analytics/wordpress/editor-panel.php
r3748857 r3753881 3 3 defined('ABSPATH') || exit; 4 4 5 add_action('enqueue_block_editor_assets', static function () use ($instance, $og) { 6 $screen = function_exists('get_current_screen') ? get_current_screen() : null; 7 $type = $screen && $screen->post_type ? $screen->post_type : ''; 8 if ($type === '' || !is_post_type_viewable($type) || !onlygrow_analytics_can_read() 9 || !$instance->helper('analytics:settings')->get('editor_panel')) { 10 return; 11 } 5 function onlygrow_analytics_post_panel_on(Og $instance, string $type): bool { 6 return $type !== '' && is_post_type_viewable($type) && onlygrow_analytics_can_read() 7 && (bool) $instance->helper('analytics:settings')->get('editor_panel'); 8 } 9 10 function onlygrow_analytics_post_panel_assets(Og $instance, array $og, string $script, array $deps = []): void { 12 11 $version = get_file_data($og['file'], ['version' => 'Version'], 'plugin')['version']; 13 12 $url = static fn (string $path) => plugins_url('public/app/extensions/analytics/assets/' . $path, $og['file']); … … 17 16 wp_enqueue_script('og-analytics-bars3d', $url('js/charts/bars3d.js'), [], $version, ['in_footer' => true]); 18 17 wp_enqueue_script('og-analytics-visits-chart', $url('js/dashboard/visits-chart.js'), ['og-analytics-bars3d'], $version, ['in_footer' => true]); 19 wp_enqueue_script('og-analytics-post-panel', $url('js/wp-editor/post-panel.js'), 20 ['og-analytics-visits-chart', 'wp-plugins', 'wp-element', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-edit-post'], $version, ['in_footer' => true]); 21 wp_add_inline_script('og-analytics-post-panel', 'window.ogAnalyticsPostPanel = ' . wp_json_encode([ 18 wp_enqueue_script('og-analytics-post-chart', $url('js/wp-editor/post-chart.js'), ['og-analytics-visits-chart'], $version, ['in_footer' => true]); 19 $handle = 'og-analytics-' . basename($script, '.js'); 20 wp_enqueue_script($handle, $url('js/wp-editor/' . $script), array_merge(['og-analytics-post-chart'], $deps), $version, ['in_footer' => true]); 21 wp_add_inline_script('og-analytics-post-chart', 'window.ogAnalyticsPostPanel = ' . wp_json_encode([ 22 22 'api' => trailingslashit(rest_url($instance->restNamespace())), 23 23 'nonce' => wp_create_nonce('wp_rest'), … … 38 38 ], 39 39 ]) . ';', 'before'); 40 } 41 42 add_action('enqueue_block_editor_assets', static function () use ($instance, $og) { 43 $screen = function_exists('get_current_screen') ? get_current_screen() : null; 44 if (!onlygrow_analytics_post_panel_on($instance, $screen && $screen->post_type ? (string) $screen->post_type : '')) { 45 return; 46 } 47 onlygrow_analytics_post_panel_assets($instance, $og, 'post-panel.js', 48 ['wp-plugins', 'wp-element', 'wp-data', 'wp-dom-ready', 'wp-editor', 'wp-edit-post']); 40 49 }); 41 50 51 add_action('add_meta_boxes', static function (string $type, $post) use ($instance, $og) { 52 if (!$post instanceof WP_Post || !onlygrow_analytics_post_panel_on($instance, $type) 53 || (function_exists('use_block_editor_for_post') && use_block_editor_for_post($post))) { 54 return; 55 } 56 add_meta_box('onlygrow-analytics-stats', __('OG Analytics', 'onlygrow-analytics'), static function (WP_Post $p) use ($instance) { 57 printf( 58 '<div class="og-analytics-app oga-pp is-loading" data-oga-classic-panel data-post="%1$d"><p class="oga-pp-total" data-oga-pp-total></p>' 59 . '<div data-oga-pp-body></div><a class="oga-pp-open" href="%2$s">%3$s →</a></div>', 60 (int) $p->ID, 61 esc_url(admin_url('admin.php?page=' . $instance->slug())), 62 esc_html__('Open dashboard', 'onlygrow-analytics') 63 ); 64 }, $type, 'side', 'default'); 65 onlygrow_analytics_post_panel_assets($instance, $og, 'classic-panel.js'); 66 }, 10, 2); 67 -
onlygrow-analytics/trunk/backend/framework/version.php
r3753515 r3753881 3 3 defined('ABSPATH') || exit; 4 4 5 return '0.1.21 1';5 return '0.1.212'; -
onlygrow-analytics/trunk/onlygrow-analytics.php
r3753515 r3753881 4 4 * Plugin URI: https://wordpress.org/plugins/onlygrow-analytics/ 5 5 * Description: See every visit the second it happens — fast even with millions of views, and stored only in your own database. 6 * Version: 0.2. 096 * Version: 0.2.10 7 7 * Requires at least: 6.5 8 8 * Requires PHP: 8.1 -
onlygrow-analytics/trunk/public/app/extensions/analytics/assets/css/build/times.css
r3753515 r3753881 4 4 .oga-times.is-loading { opacity: .5; } 5 5 .oga-times-title { display: flex; align-items: center; justify-content: space-between; gap: var(--og-space-sm); flex-wrap: wrap; 6 .oga-times-tools { display: inline-flex; align-items: center; gap: var(--og-space-sm); } 7 .oga-times-dl { all: unset; cursor: pointer; display: inline-flex; color: var(--og-muted); line-height: 0; 8 & svg { width: 15px; height: 15px; } &:hover { color: var(--og-ink, inherit); } &:focus-visible { outline: 2px solid var(--og-primary); border-radius: 3px; } } 6 9 margin: 0 0 var(--og-space-sm); font-size: .8em; text-transform: uppercase; letter-spacing: .04em; color: var(--og-muted); font-weight: 600; } 7 10 .oga-times-legend { display: inline-flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; font-weight: 400; } -
onlygrow-analytics/trunk/public/app/extensions/analytics/assets/css/main.css
r3753515 r3753881 1 @import url('theme.css ');2 @import url('layout.css ');3 @import url('fonts.css ');4 @import url('charts/bars3d.css ');5 @import url('charts/lines.css ');6 @import url('dashboard/dashboard.css ');7 @import url('dashboard/health.css ');8 @import url('dashboard/online-visitors.css ');9 @import url('dashboard/online-dot.css ');10 @import url('dashboard/visits-chart.css ');11 @import url('dashboard/list-widget.css ');12 @import url('dashboard/geo.css ');13 @import url('details/details.css ');14 @import url('settings/tracking.css ');15 @import url('settings/data.css ');16 @import url('settings/info.css ');17 @import url('settings/spam-list.css ');18 @import url('reports/reports.css ');19 @import url('reports/visitors.css ');20 @import url('reports/report-filters.css ');21 @import url('reports/pages.css ');22 @import url('reports/list-table.css ');23 @import url('reports/device-cards.css ');24 @import url('reports/build.css ');25 @import url('build/times.css ');26 @import url('print.css ');27 @import url('tools/export.css ');28 @import url('tools/diagnose.css ');1 @import url('theme.css?ver=0.2.10'); 2 @import url('layout.css?ver=0.2.10'); 3 @import url('fonts.css?ver=0.2.10'); 4 @import url('charts/bars3d.css?ver=0.2.10'); 5 @import url('charts/lines.css?ver=0.2.10'); 6 @import url('dashboard/dashboard.css?ver=0.2.10'); 7 @import url('dashboard/health.css?ver=0.2.10'); 8 @import url('dashboard/online-visitors.css?ver=0.2.10'); 9 @import url('dashboard/online-dot.css?ver=0.2.10'); 10 @import url('dashboard/visits-chart.css?ver=0.2.10'); 11 @import url('dashboard/list-widget.css?ver=0.2.10'); 12 @import url('dashboard/geo.css?ver=0.2.10'); 13 @import url('details/details.css?ver=0.2.10'); 14 @import url('settings/tracking.css?ver=0.2.10'); 15 @import url('settings/data.css?ver=0.2.10'); 16 @import url('settings/info.css?ver=0.2.10'); 17 @import url('settings/spam-list.css?ver=0.2.10'); 18 @import url('reports/reports.css?ver=0.2.10'); 19 @import url('reports/visitors.css?ver=0.2.10'); 20 @import url('reports/report-filters.css?ver=0.2.10'); 21 @import url('reports/pages.css?ver=0.2.10'); 22 @import url('reports/list-table.css?ver=0.2.10'); 23 @import url('reports/device-cards.css?ver=0.2.10'); 24 @import url('reports/build.css?ver=0.2.10'); 25 @import url('build/times.css?ver=0.2.10'); 26 @import url('print.css?ver=0.2.10'); 27 @import url('tools/export.css?ver=0.2.10'); 28 @import url('tools/diagnose.css?ver=0.2.10'); -
onlygrow-analytics/trunk/public/app/extensions/analytics/assets/css/print.css
r3753515 r3753881 28 28 & .oga-build-bar .og-toolbar, & .oga-report-filters .og-filter-add, & .oga-report-filters .og-filter-pin, 29 29 & .oga-report-filters .og-filter-clear, & .oga-report-filters .og-filter-panel, & .oga-report-filters .og-filter-chip-x, 30 & .oga-report-filters .og-filter-replace { display: none !important; }30 & .oga-report-filters .og-filter-replace, & .oga-times-dl { display: none !important; } 31 31 & .oga-report-filters:not(:has(.og-filter-chip)) { display: none !important; } 32 32 & .og-builder-field { margin-left: 0 !important; } -
onlygrow-analytics/trunk/public/app/extensions/analytics/assets/css/tools/diagnose.css
r3753515 r3753881 22 22 & .is-error .oga-diag-tag { color: var(--og-red, #c62828); } 23 23 & .oga-diag-ex h3 { margin: 0 0 4px; font-size: .8em; text-transform: uppercase; letter-spacing: .04em; color: var(--og-muted); } 24 & .oga-diag-ex table { width: 100%; margin-top: var(--og-space-sm); } 24 & .oga-diag-ex .og-table-wrap { margin-top: var(--og-space-sm); } 25 & .oga-diag-ex table { width: 100%; } 26 & .oga-diag-ex td:first-child { white-space: normal; } 25 27 & .oga-diag-ex td:not(:first-child), & .oga-diag-ex th:not(:first-child) { text-align: right; width: 80px; } 26 28 & .oga-diag-note { margin: var(--og-space-sm) 0 0; font-size: .85em; color: var(--og-muted); } -
onlygrow-analytics/trunk/public/app/extensions/analytics/assets/js/build/times.js
r3753515 r3753881 27 27 28 28 const legend = view === 'grid' ? '' : `<span class="oga-times-legend"><i class="is-visits"></i>${esc(t('visits'))}<i class="is-views"></i>${esc(t('views'))}</span>`; 29 el.innerHTML = `<div class="og-card og-card-static oga-times"><h3 class="oga-times-title"><span>${esc(t('title_' + view))}</span>${legend}</h3>` 29 const dl = `<button type="button" class="oga-times-dl" data-oga-times-dl title="${esc(t('download'))}" aria-label="${esc(t('download'))}">` 30 + `${(window.OG && OG.icons && OG.icons.get('download')) || '⬇'}</button>`; 31 el.innerHTML = `<div class="og-card og-card-static oga-times"><h3 class="oga-times-title"><span>${esc(t('title_' + view))}</span>` 32 + `<span class="oga-times-tools">${legend}${dl}</span></h3>` 30 33 + `<div class="oga-times-body" data-oga-times></div><p class="oga-status" data-oga-status hidden></p></div>`; 31 34 const card = el.firstChild; … … 54 57 const fill = (str, args) => { let i = 0; return String(str).replace(/%(\d+)\$s|%s/g, (m, n) => String(args[n ? n - 1 : i++] ?? '')); }; 55 58 59 let data = null; 60 function csv() { 61 if (!data) return; 62 const cell = v => { const s = String(v == null ? '' : v); return /[",\r\n]/.test(s) ? '"' + s.replace(/"/g, '""') + '"' : s; }; 63 const line = cells => cells.map(cell).join(',') + '\r\n'; 64 const r1 = v => Math.round((Number(v) || 0) * 10) / 10; 65 let out = ''; 66 if (view === 'hours') { 67 out = line(['hour', 'visits_per_day', 'views_per_day']) + data.hours.map((x, h) => line([hh(h), r1(x.visits), r1(x.views)])).join(''); 68 } else if (view === 'weekdays') { 69 out = line(['weekday', 'visits_per_day', 'views_per_day', 'days']) + order.map(day => { 70 const x = data.weekdays[day] || {}; 71 return line([dayName(day, dayLong), r1(x.visits), r1(x.views), x.days || 0]); 72 }).join(''); 73 } else { 74 out = line(['weekday', ...Array.from({ length: 24 }, (_, h) => hh(h))]) + order.map(day => line([dayName(day, dayLong), ...data.grid[day]])).join(''); 75 } 76 const url = URL.createObjectURL(new Blob(['\ufeff' + out], { type: 'text/csv;charset=utf-8' })); 77 const a = Object.assign(document.createElement('a'), { href: url, download: 'og-analytics-times-' + view + '-' + String(period).replace(/[^\w-]+/g, '_') + '.csv' }); 78 document.body.appendChild(a); a.click(); a.remove(); 79 setTimeout(() => URL.revokeObjectURL(url), 1000); 80 } 81 card.querySelector('[data-oga-times-dl]').addEventListener('click', csv); 82 56 83 let period = null; 57 84 async function load(p, fresh) { … … 61 88 const d = await fetchTimes(inst, period, fresh); 62 89 if (!card.isConnected) return; 90 data = d; 63 91 status.hidden = true; 64 92 if (view === 'grid') grid(d); -
onlygrow-analytics/trunk/public/app/extensions/analytics/assets/js/dashboard/health.js
r3753515 r3753881 12 12 : h.state === 'stopped' ? fill(t('stopped'), [dur(h.quiet_minutes * 60), num.format(Math.round(h.expected))]) 13 13 : fill(t('behind'), [num.format(h.oldest_queue_hours)]); 14 const link = h.state === 'paused' ? ['#/track ing', t('action_paused')] : ['#/diagnose', t('action')];14 const link = h.state === 'paused' ? ['#/track', t('action_paused')] : ['#/diagnose', t('action')]; 15 15 const esc = s => String(s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c])); 16 16 box.innerHTML = `<div class="og-alert og-alert-${h.state === 'stopped' ? 'error' : 'warning'} oga-health" role="alert">` -
onlygrow-analytics/trunk/public/app/extensions/analytics/assets/js/settings/track.js
r3753515 r3753881 40 40 try { 41 41 const data = OG.form.collect(form); 42 const saved = await window.ogAnalyticsApi.post(inst, 'settings/track', { ghost_mode: !!data.ghost_mode, visitor_mode: data.visitor_mode });42 const saved = await window.ogAnalyticsApi.post(inst, 'settings/track', { ghost_mode: !!data.ghost_mode, visitor_mode: data.visitor_mode, tracking_paused: !!data.tracking_paused }); 43 43 window.ogAnalyticsTrack.endpoint(inst, saved.endpoint); 44 44 OG.toast.success(t('saved')); -
onlygrow-analytics/trunk/public/app/extensions/analytics/assets/js/tools/diagnose.js
r3753515 r3753881 80 80 + `<td>${num.format(r.d7)}</td><td>${num.format(r.d30)}</td></tr>`).join(''); 81 81 const exTable = exRows 82 ? `< table class="og-table og-table-flat"><thead><tr><th>${esc(t('ex_reason'))}</th><th>${esc(t('ex_today'))}</th><th>${esc(t('ex_7'))}</th>`83 + `<th>${esc(t('ex_30'))}</th></tr></thead><tbody>${exRows}</tbody></table> `82 ? `<div class="og-table-wrap"><table class="og-table og-table-flat"><thead><tr><th>${esc(t('ex_reason'))}</th><th>${esc(t('ex_today'))}</th><th>${esc(t('ex_7'))}</th>` 83 + `<th>${esc(t('ex_30'))}</th></tr></thead><tbody>${exRows}</tbody></table></div>` 84 84 : `<p class="og-text-muted">${esc(t('ex_none'))}</p>`; 85 85 -
onlygrow-analytics/trunk/public/app/extensions/analytics/assets/js/wp-editor/post-panel.js
r3753515 r3753881 2 2 const cfg = window.ogAnalyticsPostPanel; 3 3 const wp = window.wp; 4 if (!cfg || !wp || !wp.plugins || !wp.element || !window.ogAnalytics Bars3d || !window.ogAnalyticsVisitsChart) return;4 if (!cfg || !wp || !wp.plugins || !wp.element || !window.ogAnalyticsPostChart || !window.ogAnalyticsBars3d || !window.ogAnalyticsVisitsChart) return; 5 5 6 6 const Panel = (wp.editor && wp.editor.PluginDocumentSettingPanel) || (wp.editPost && wp.editPost.PluginDocumentSettingPanel); … … 8 8 9 9 const { createElement: h, useEffect, useRef, useState } = wp.element; 10 const THEME = 'classic'; 11 const PALETTE = 'wordpress'; 12 const HEIGHT = 150; 13 const SERIES = [['views', 2], ['visits', 1], ['first', 0]]; 14 15 let tz = 'UTC'; 16 try { tz = Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC'; } catch (e) { } 17 const memo = {}; 18 const nf = new Intl.NumberFormat(cfg.locale); 19 20 async function fetchPost(id) { 21 if (memo[id]) return memo[id]; 22 const res = await fetch(cfg.api + 'stats/post?post=' + encodeURIComponent(id), { 23 credentials: 'same-origin', 24 headers: { 'X-WP-Nonce': cfg.nonce, 'X-User-Timezone': tz }, 25 }); 26 if (!res.ok) throw new Error('HTTP ' + res.status); 27 return (memo[id] = await res.json()); 28 } 29 30 function mountChart(box, legend, data) { 31 const { palette, config } = window.ogAnalyticsVisitsChart.theme({ chart_theme: THEME, chart_palette: PALETTE }); 32 const chart = window.ogAnalyticsBars3d.create(box, { 33 locale: cfg.locale, 34 labels: { today: cfg.t.today }, 35 config: { ...config, height: HEIGHT, plotLeft: 26, weekendColor: palette.weekend }, 36 series: SERIES.map(([key, z]) => { 37 const [top, bottom, edge] = palette[key]; 38 return { key, z, top, bottom, edge, label: cfg.t[key] }; 39 }), 40 }); 41 legend.innerHTML = ''; 42 chart.series.slice().sort((a, b) => a.z - b.z).forEach(s => { 43 const b = document.createElement('button'); 44 b.type = 'button'; 45 b.innerHTML = '<i></i><span></span>'; 46 b.querySelector('i').style.background = s.top; 47 b.querySelector('span').textContent = s.label; 48 b.addEventListener('click', () => b.classList.toggle('is-off', !chart.toggle(s.key))); 49 legend.appendChild(b); 50 }); 51 chart.setData(data.points.map(p => { 52 const [y, m, d] = p.t.split('-').map(Number); 53 return { date: new Date(y, m - 1, d), views: p.views, visits: p.visits, first: p.first }; 54 }), data.unit || 'day'); 55 } 10 const PC = window.ogAnalyticsPostChart; 11 const nf = new Intl.NumberFormat(cfg.locale); 56 12 57 13 function ChartBox({ data }) { … … 61 17 if (box.current && legend.current) { 62 18 box.current.innerHTML = ''; 63 mountChart(box.current, legend.current, data);19 PC.mount(cfg, box.current, legend.current, data); 64 20 } 65 21 }, [data]); … … 75 31 useEffect(() => { 76 32 let alive = true; 77 fetchPost(postId)33 PC.load(cfg, postId) 78 34 .then(data => { if (alive) setState({ status: 'ok', data }); }) 79 35 .catch(() => { if (alive) setState({ status: 'error', data: null }); }); … … 82 38 83 39 const data = state.data; 84 const empty = data && !data.total && !data.points.some(p => p.views);40 const empty = PC.empty(data); 85 41 return h(Panel, { name: 'onlygrow-analytics-stats', title: cfg.t.title, className: 'oga-post-panel' }, 86 42 h('div', { className: 'og-analytics-app oga-pp' + (state.status === 'loading' ? ' is-loading' : '') }, -
onlygrow-analytics/trunk/public/app/extensions/analytics/assets/js/wp-widget/dashboard-widget.js
r3753515 r3753881 3 3 const PALETTE = 'wordpress'; 4 4 const HEIGHT = 200; 5 const SERIES= [['views', 2], ['visits', 1], ['first', 0]];5 const ALL = [['views', 2], ['visits', 1], ['first', 0]]; 6 6 7 7 const cfg = window.ogAnalyticsWidget; 8 const SERIES = ALL.filter(([key]) => !cfg || !Array.isArray(cfg.series) || cfg.series.includes(key)); 8 9 const root = document.querySelector('[data-oga-wpw]'); 9 10 if (!cfg || !root || !window.ogAnalyticsBars3d || !window.ogAnalyticsVisitsChart) return; … … 48 49 const nf = new Intl.NumberFormat(cfg.locale); 49 50 const pf = new Intl.NumberFormat(cfg.locale, { maximumFractionDigits: 1 }); 51 if (SERIES.length < 2) totals.remove(); 50 52 function renderTotals(sum) { 53 if (SERIES.length < 2) return; 51 54 const color = Object.fromEntries(chart.series.map(s => [s.key, s.top])); 52 55 totals.innerHTML = ''; 53 for (const key of ['views', 'visits', 'first']) {56 for (const [key] of ALL.filter(([k]) => SERIES.some(([s]) => s === k))) { 54 57 const box = document.createElement('div'); 55 58 box.className = 'oga-wpw-total'; -
onlygrow-analytics/trunk/public/app/extensions/analytics/index.json
r3752543 r3753881 78 78 "id": "tools", 79 79 "label": "{{analytics.nav.tools}}", 80 "icon": " key",80 "icon": "hammer", 81 81 "zone": "foot", 82 82 "can": "analytics.manage", -
onlygrow-analytics/trunk/public/app/extensions/analytics/lang/en.json
r3753515 r3753881 255 255 "browser_hint": "A user who is not counted leaves a mark in their browser (local storage, no cookie), so their visits keep being ignored when they are not logged in.", 256 256 "comment_spam": "Don't count comment spammers", 257 "comment_spam_hint": "Visits from the IP addresses of comments marked as spam, and from the IPs and domains in Settings → Discussion → Disallowed Comment Keys, are not counted. They show up in Tools → Diagnose.", 258 "paused": "Pause tracking", 259 "paused_hint": "While it is on, no visit is recorded: the tracking script is not loaded on your site. Your statistics stay as they are. Useful during maintenance, a migration or on a test copy of the site." 257 "comment_spam_hint": "Visits from the IP addresses of comments marked as spam, and from the IPs and domains in Settings → Discussion → Disallowed Comment Keys, are not counted. They show up in Tools → Diagnose." 260 258 }, 261 259 "data": { … … 302 300 "track": { 303 301 "title": "Track", 302 "paused": "Pause tracking", 303 "paused_hint": "While it is on, no visit is recorded: the tracking script is not loaded on your site. Your statistics stay as they are. Useful during maintenance, a migration or on a test copy of the site.", 304 304 "ghost_title": "Ghost mode", 305 305 "ghost": "Keep counting visitors who use an ad blocker", … … 751 751 "reason_comment_spam": "Comment spam (WordPress spam comments and Disallowed Comment Keys)", 752 752 "paused_label": "Tracking", 753 "paused_error": "Tracking is PAUSED (Settings → Exclusions→ Pause tracking): no visit is recorded until you turn it off."753 "paused_error": "Tracking is PAUSED (Settings → Track → Pause tracking): no visit is recorded until you turn it off." 754 754 }, 755 755 "defaults": { … … 861 861 }, 862 862 "times": { 863 "download": "Download CSV", 863 864 "title_hours": "By hour of the day", 864 865 "title_weekdays": "By day of the week", -
onlygrow-analytics/trunk/public/app/extensions/analytics/lang/es.json
r3753515 r3753881 255 255 "browser_hint": "Un usuario que no cuenta deja una marca en su navegador (almacenamiento local, sin cookie), así sus visitas siguen sin contar cuando no ha iniciado sesión.", 256 256 "comment_spam": "No contar a quien deja spam en comentarios", 257 "comment_spam_hint": "Las visitas desde las IPs de comentarios marcados como spam, y desde las IPs y dominios de Ajustes → Comentarios → Claves de comentarios no permitidas, no cuentan. Salen en Herramientas → Diagnóstico.", 258 "paused": "Pausar el registro", 259 "paused_hint": "Mientras esté encendido no se registra ninguna visita: el script de seguimiento no se carga en tu sitio. Tus estadísticas se quedan como están. Útil en un mantenimiento, una migración o en una copia de pruebas del sitio." 257 "comment_spam_hint": "Las visitas desde las IPs de comentarios marcados como spam, y desde las IPs y dominios de Ajustes → Comentarios → Claves de comentarios no permitidas, no cuentan. Salen en Herramientas → Diagnóstico." 260 258 }, 261 259 "data": { … … 302 300 "track": { 303 301 "title": "Medición", 302 "paused": "Pausar el registro", 303 "paused_hint": "Mientras esté encendido no se registra ninguna visita: el script de seguimiento no se carga en tu sitio. Tus estadísticas se quedan como están. Útil en un mantenimiento, una migración o en una copia de pruebas del sitio.", 304 304 "ghost_title": "Modo fantasma", 305 305 "ghost": "Seguir contando a quien usa un bloqueador de anuncios", … … 751 751 "reason_comment_spam": "Spam de comentarios (comentarios spam de WordPress y claves no permitidas)", 752 752 "paused_label": "Registro", 753 "paused_error": "El registro está EN PAUSA (Ajustes → Exclusiones→ Pausar el registro): no se guarda ninguna visita hasta que lo apagues."753 "paused_error": "El registro está EN PAUSA (Ajustes → Medición → Pausar el registro): no se guarda ninguna visita hasta que lo apagues." 754 754 }, 755 755 "defaults": { … … 861 861 }, 862 862 "times": { 863 "download": "Descargar CSV", 863 864 "title_hours": "Por hora del día", 864 865 "title_weekdays": "Por día de la semana", -
onlygrow-analytics/trunk/public/app/extensions/analytics/views/settings/track.json
r3748857 r3753881 45 45 }, 46 46 { 47 "type": "checkbox", 48 "name": "tracking_paused", 49 "switch": true, 50 "label": "{{analytics.settings.track.paused}}", 51 "hint": "{{analytics.settings.track.paused_hint}}" 52 }, 53 { 47 54 "type": "toolbar", 48 55 "right": [ -
onlygrow-analytics/trunk/public/app/extensions/analytics/views/settings/tracking.json
r3752543 r3753881 165 165 }, 166 166 { 167 "type": "checkbox",168 "name": "tracking_paused",169 "switch": true,170 "label": "{{analytics.settings.tracking.paused}}",171 "hint": "{{analytics.settings.tracking.paused_hint}}",172 "order": 90173 },174 {175 167 "type": "toolbar", 176 168 "right": [ -
onlygrow-analytics/trunk/public/framework/css/base.css
r3753515 r3753881 1 @import url('base/tokens.css ');2 @import url('base/table.css ');3 @import url('base/card.css ');4 @import url('base/button.css ');5 @import url('base/input.css ');6 @import url('base/responsive.css ');7 @import url('base/alert.css ');8 @import url('base/badge.css ');9 @import url('base/section.css ');10 @import url('base/icon.css ');1 @import url('base/tokens.css?ver=0.2.10'); 2 @import url('base/table.css?ver=0.2.10'); 3 @import url('base/card.css?ver=0.2.10'); 4 @import url('base/button.css?ver=0.2.10'); 5 @import url('base/input.css?ver=0.2.10'); 6 @import url('base/responsive.css?ver=0.2.10'); 7 @import url('base/alert.css?ver=0.2.10'); 8 @import url('base/badge.css?ver=0.2.10'); 9 @import url('base/section.css?ver=0.2.10'); 10 @import url('base/icon.css?ver=0.2.10'); 11 11 12 12 -
onlygrow-analytics/trunk/public/framework/css/themes/brutal/theme.css
r3753515 r3753881 1 @import url('fonts.css ');1 @import url('fonts.css?ver=0.2.10'); 2 2 3 3 .og-instance[data-theme="brutal"] { -
onlygrow-analytics/trunk/public/framework/css/themes/cobalt/theme.css
r3753515 r3753881 1 @import url('fonts.css ');1 @import url('fonts.css?ver=0.2.10'); 2 2 3 3 .og-instance[data-theme="cobalt"] { -
onlygrow-analytics/trunk/public/framework/icons/set.js
r3753515 r3753881 13 13 plus: '<path d="M12 5v14M5 12h14"/>', 14 14 key: '<path d="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"/>', 15 hammer: '<path d="m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9"/><path d="m18 15 4-4"/><path d="m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5"/>', 15 16 refresh: '<path d="M23 4v6h-6M1 20v-6h6"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/>', 16 17 trash: '<path d="M3 6h18"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M10 11v6M14 11v6"/>', -
onlygrow-analytics/trunk/readme.txt
r3753515 r3753881 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.1 7 Stable tag: 0.2. 097 Stable tag: 0.2.10 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 50 50 51 51 == Changelog == 52 53 = 0.2.10 = 54 * [[new]] The classic editor shows the chart of each post too, in a box on the side. 55 * [[new]] Reports → Times: download each chart as CSV (by hour, by day of the week and the day × hour grid). 56 * [[improved]] Works with WP Rocket and Autoptimize without excluding anything by hand: the tracking script is left as it is. 57 * [[improved]] Clearer "View details" window: menu paths and notes are easier to read. 58 * [[changed]] Pause tracking moved to Settings → Track. 59 * [[changed]] The dashboard widget shows only visits, and a new icon for Tools. 60 * [[fixed]] With WP Rocket's "Delay JavaScript execution", visitors who did not touch the page were not counted. 61 * [[fixed]] After an update, the plugin screens could keep old styles until the browser cache was cleared. 62 * [[fixed]] Tools → Diagnose no longer warns when an optimization plugin serves its own copy of the tracking script. 63 * [[fixed]] The table in Tools → Diagnose no longer overflows its card. 52 64 53 65 = 0.2.09 =
Note:
See TracChangeset
for help on using the changeset viewer.