@elementor/editor-audits 4.4.0-1076 → 4.4.0-1078

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-audits",
3
- "version": "4.4.0-1076",
3
+ "version": "4.4.0-1078",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,19 +39,19 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor": "4.4.0-1076",
43
- "@elementor/editor-mcp": "4.4.0-1076",
44
- "@elementor/editor-app-bar": "4.4.0-1076",
45
- "@elementor/editor-elements": "4.4.0-1076",
46
- "@elementor/editor-floating-panels": "4.4.0-1076",
47
- "@elementor/editor-notifications": "4.4.0-1076",
48
- "@elementor/editor-v1-adapters": "4.4.0-1076",
49
- "@elementor/events": "4.4.0-1076",
50
- "@elementor/http-client": "4.4.0-1076",
42
+ "@elementor/editor": "4.4.0-1078",
43
+ "@elementor/editor-mcp": "4.4.0-1078",
44
+ "@elementor/editor-app-bar": "4.4.0-1078",
45
+ "@elementor/editor-elements": "4.4.0-1078",
46
+ "@elementor/editor-floating-panels": "4.4.0-1078",
47
+ "@elementor/editor-notifications": "4.4.0-1078",
48
+ "@elementor/editor-v1-adapters": "4.4.0-1078",
49
+ "@elementor/events": "4.4.0-1078",
50
+ "@elementor/http-client": "4.4.0-1078",
51
51
  "@elementor/icons": "~1.77.0",
52
- "@elementor/locations": "4.4.0-1076",
53
- "@elementor/session": "4.4.0-1076",
54
- "@elementor/store": "4.4.0-1076",
52
+ "@elementor/locations": "4.4.0-1078",
53
+ "@elementor/session": "4.4.0-1078",
54
+ "@elementor/store": "4.4.0-1078",
55
55
  "@elementor/ui": "1.37.5"
56
56
  },
57
57
  "peerDependencies": {
@@ -0,0 +1,30 @@
1
+ import { __ } from '@wordpress/i18n';
2
+
3
+ import { type Audit } from '../types';
4
+
5
+ export const audit: Audit = {
6
+ id: 'audits/scan-for-cookies',
7
+ title: __( 'Scan for cookies', 'elementor' ),
8
+ description: __(
9
+ "Your site may be setting cookies you haven't disclosed. Some countries require a banner even without a full consent policy. Scan to see what needs disclosure.",
10
+ 'elementor'
11
+ ),
12
+ fixHint: __( 'Run a Cookiez scan on this page to see which cookies need disclosure.', 'elementor' ),
13
+ categories: [ 'compliance' ],
14
+ severity: 'info',
15
+ weight: 0,
16
+ evaluate: ( ctx ) => {
17
+ const isReady = ctx.pageContext.cookiez_plugin_installed && ctx.pageContext.cookiez_plugin_active;
18
+
19
+ return {
20
+ status: 'fail',
21
+ violations: [
22
+ {
23
+ auditId: audit.id,
24
+ label: __( 'This page has not been scanned for cookies yet.', 'elementor' ),
25
+ externalUrl: isReady ? ctx.pageContext.cookiez_scan_url : ctx.pageContext.cookiez_plugin_action_url,
26
+ },
27
+ ],
28
+ };
29
+ },
30
+ };
@@ -15,7 +15,7 @@ type Props = {
15
15
  export default function StatusSection( { label, count, color = 'default', defaultExpanded = false, children }: Props ) {
16
16
  const [ expanded, setExpanded ] = useState( defaultExpanded );
17
17
 
18
- if ( count === 0 ) {
18
+ if ( React.Children.count( children ) === 0 ) {
19
19
  return null;
20
20
  }
21
21
 
@@ -8,6 +8,7 @@ import { __ } from '@wordpress/i18n';
8
8
  import { focusViolation } from '../hooks/focus-violation';
9
9
  import { type AuditMeta, type AuditViolation } from '../types';
10
10
  import { buildAngiePrompt } from '../utils/build-angie-prompt';
11
+ import { isScoredAudit } from '../utils/is-scored-audit';
11
12
  import { onKeyboardClick } from '../utils/keyboard-click';
12
13
  import FixViolationWithAngie from './fix-violation-with-angie';
13
14
  import SeverityIcon from './severity-icons';
@@ -34,9 +35,11 @@ function StatusIndicator( { audit, violations }: Pick< Props, 'audit' | 'violati
34
35
  if ( violations ) {
35
36
  return (
36
37
  <>
37
- <Typography variant="caption" color="text.secondary" fontWeight="bold">
38
- { violations.length }
39
- </Typography>
38
+ { isScoredAudit( audit ) && (
39
+ <Typography variant="caption" color="text.secondary" fontWeight="bold">
40
+ { violations.length }
41
+ </Typography>
42
+ ) }
40
43
  <SeverityIcon severity={ audit.severity } />
41
44
  </>
42
45
  );
@@ -15,6 +15,7 @@ import * as preferGlobalColors from './audits/prefer-global-colors';
15
15
  import * as preferGlobalFonts from './audits/prefer-global-fonts';
16
16
  import * as privacyPolicy from './audits/privacy-policy';
17
17
  import * as robotsNoindex from './audits/robots-noindex';
18
+ import * as scanForCookies from './audits/scan-for-cookies';
18
19
  import * as sectionsAndColumns from './audits/sections-and-columns';
19
20
  import * as siteIdentity from './audits/site-identity';
20
21
  import * as tooManyWidgets from './audits/too-many-widgets';
@@ -47,6 +48,7 @@ const AUDITS: Audit[] = [
47
48
  privacyPolicy.audit,
48
49
  accessibilityPolicy.audit,
49
50
  cookiePolicy.audit,
51
+ scanForCookies.audit,
50
52
  ];
51
53
 
52
54
  export function registerAllAudits(): void {
@@ -49,6 +49,14 @@ export const PROMOTIONS: PromotionConfig[] = [
49
49
  run.result.status === 'fail' ? __( 'Generate cookie policy', 'elementor' ) : null,
50
50
  getCtaUrl: firstFailExternalUrl,
51
51
  },
52
+ {
53
+ auditId: 'audits/scan-for-cookies',
54
+ icon: ElementorCookieIcon,
55
+ ctaLabel: __( 'Scan', 'elementor' ),
56
+ formatSubtitle: ( run ) =>
57
+ run.result.status === 'fail' ? __( 'Scan this page for cookies', 'elementor' ) : null,
58
+ getCtaUrl: firstFailExternalUrl,
59
+ },
52
60
  {
53
61
  auditId: 'audits/images-too-large',
54
62
  icon: ShieldHalfFilledIcon,
package/src/types.ts CHANGED
@@ -66,6 +66,9 @@ export type PageContextResponse = {
66
66
  ally_plugin_url: string;
67
67
  cookiez_plugin_active: boolean;
68
68
  cookiez_plugin_url: string;
69
+ cookiez_plugin_installed: boolean;
70
+ cookiez_plugin_action_url: string;
71
+ cookiez_scan_url: string;
69
72
  image_optimization_plugin_active: boolean;
70
73
  image_optimization_plugin_url: string;
71
74
  site_identity: {
@@ -2,6 +2,7 @@ import { type ChipProps } from '@elementor/ui';
2
2
  import { __ } from '@wordpress/i18n';
3
3
 
4
4
  import { type AuditCategory, type AuditResult, type AuditRun, type PageAuditReport } from '../types';
5
+ import { isScoredAudit } from './is-scored-audit';
5
6
  import { sortFailedAuditResults } from './sort-failed-audits';
6
7
 
7
8
  export type AuditStatusGroup = 'fail' | 'pass' | 'skipped';
@@ -37,7 +38,11 @@ export function partitionAuditResults(
37
38
  switch ( run.result.status ) {
38
39
  case 'fail':
39
40
  failed.push( { ...run, result: run.result } );
40
- totalViolations += run.result.violations.length;
41
+
42
+ if ( isScoredAudit( run.audit ) ) {
43
+ totalViolations += run.result.violations.length;
44
+ }
45
+
41
46
  break;
42
47
  case 'pass':
43
48
  passed.push( { ...run, result: run.result } );
@@ -61,7 +66,11 @@ export function auditStatusDisplayCounts( report: PageAuditReport ): Record< Aud
61
66
  let skipped = 0;
62
67
  let totalViolations = 0;
63
68
 
64
- for ( const { result } of report.auditResults ) {
69
+ for ( const { audit, result } of report.auditResults ) {
70
+ if ( ! isScoredAudit( audit ) ) {
71
+ continue;
72
+ }
73
+
65
74
  switch ( result.status ) {
66
75
  case 'fail':
67
76
  totalViolations += result.violations.length;
@@ -0,0 +1,5 @@
1
+ import { type AuditMeta } from '../types';
2
+
3
+ export function isScoredAudit( audit: AuditMeta ): boolean {
4
+ return audit.weight > 0;
5
+ }
@@ -1,6 +1,7 @@
1
1
  import { __, sprintf } from '@wordpress/i18n';
2
2
 
3
3
  import { type AuditCategory, type AuditSeverity, type PageAuditReport } from '../types';
4
+ import { isScoredAudit } from './is-scored-audit';
4
5
 
5
6
  export type SeverityCounts = Record< AuditSeverity, number >;
6
7
 
@@ -18,6 +19,10 @@ export function countSeverities( report: PageAuditReport, category?: AuditCatego
18
19
  continue;
19
20
  }
20
21
 
22
+ if ( ! isScoredAudit( audit ) ) {
23
+ continue;
24
+ }
25
+
21
26
  counts[ audit.severity ] += result.violations.length;
22
27
  }
23
28