/** * WordPress dependencies */ import { _x, sprintf } from '@safe-wordpress/i18n'; /** * External dependencies */ import type { ExperimentType } from '@nab/types'; /** * Internal dependencies */ import icon from './icon.svg'; import { Original } from './components/original'; import { Alternative } from './components/alternative'; import type { ControlAttributes, AlternativeAttributes } from './types'; export const settings: ExperimentType< ControlAttributes, AlternativeAttributes > = { name: 'nab/popup' as const, category: 'global', title: _x( 'Popup', 'text (experiment name)', 'nelio-ab-testing' ), description: _x( 'Test alternative versions of your popups', 'user', 'nelio-ab-testing' ), labels: { create: _x( 'Add new A/B test of popups', 'command', 'nelio-ab-testing' ), }, icon, supports: { postTypes: [ 'nab_elementor_popup', 'nelio_popup' ], }, checks: { getControlError: ( control ) => { if ( ! control.postId ) { return _x( 'Please select the popup you want to test', 'user', 'nelio-ab-testing' ); } return false; }, getAlternativeError: ( alternative, letter ) => { if ( ! alternative.postId ) { return sprintf( /* translators: %s: Letter of the variant. */ _x( 'Please select a popup in variant %s', 'user', 'nelio-ab-testing' ), letter ); } return false; }, }, help: { original: _x( 'Split tests of popups help you to improve the conversion rate of your WordPress site by testing popups against each other. The control version (commonly known as the “A” version) is a popup you’re currently using on your site.', 'user', 'nelio-ab-testing' ), alternative: _x( 'You can select one or more alternative popups to test them against your control popup.', 'user', 'nelio-ab-testing' ), }, defaults: { original: { postType: '', postId: 0, }, alternative: { postId: 0, }, }, views: { original: Original, alternative: Alternative, }, };