/** * WordPress dependencies */ import { _x, sprintf } from '@safe-wordpress/i18n'; /** * External dependencies */ import { DefaultAlternative } from '@nab/components'; import type { ExperimentType } from '@nab/types'; /** * Internal dependencies */ import icon from './icon.svg'; import { Original } from './components/original'; import { ValuePreview } from './components/value-preview'; import type { ControlAttributes, AlternativeAttributes } from './types'; export const settings: ExperimentType< ControlAttributes, AlternativeAttributes > = { name: 'nab/php' as const, category: 'global', title: _x( 'PHP', 'text (experiment name)', 'nelio-ab-testing' ), description: _x( 'Load alternative content writing PHP code', 'user', 'nelio-ab-testing' ), labels: { create: _x( 'Add new A/B test using PHP', 'command', 'nelio-ab-testing' ), }, icon, supports: { alternativeEdition: { type: 'external' }, alternativePreviewDialog: ValuePreview, scope: 'urls-or-php', }, checks: { getControlError: () => false, getAlternativeError: ( alternative, letter ) => { if ( ! alternative.errorMessage ) { return false; } return sprintf( /* translators: %s: Letter of the variant. */ _x( 'Please review and fix the code in variant %s', 'user', 'nelio-ab-testing' ), letter ); }, }, help: { original: _x( 'PHP split tests help you to improve the conversion rate of your WordPress site. The control version (commonly known as the “A” version) is how your site currently looks.', 'user', 'nelio-ab-testing' ), alternative: _x( 'Here you can create one or more PHP snippets that will run during the plugins_loaded action (or the action you selected in the test scope). This way, you’ll be able to hook into WordPress actions and filters and change the content of pages in the test scope.', 'user', 'nelio-ab-testing' ), }, defaults: { original: {}, alternative: { name: '', snippet: '', }, }, views: { original: Original, alternative: DefaultAlternative, }, };