HEX
Server: nginx
System: Linux pool195-106-36.bur.atomicsites.net 6.12.57+deb12-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.57-1~bpo12+1 (2025-11-17) x86_64
User: (0)
PHP: 8.3.32
Disabled: pcntl_fork
Upload Files
File: //wordpress/plugins/jetpack/latest/_inc/content-guidelines-ai.js
/**
 * Content Guidelines AI — Entry point.
 *
 * Injects Jetpack AI-powered generate/improve buttons into the
 * Content Guidelines admin page (Gutenberg experimental feature).
 */
import { mapAiFeatureResponseToAiFeatureProps } from '@automattic/jetpack-shared-stores';
import '@automattic/jetpack-shared-extension-utils/store/wordpress-com';
import { dispatch } from '@wordpress/data';
import './content-guidelines-ai/store';
import './content-guidelines-ai/style.scss';
import { startInjection } from './content-guidelines-ai/lib/inject';

// The AI feature state is resolved server-side and preloaded into the page
// (see _inc/content-guidelines-ai.php), so components render the correct
// locked/unlocked state on first paint with no client-side plan fetch.
// Without the preload (server-side lookup failed) render no AI UI at all —
// the store's optimistic hasFeature default would show unlocked buttons
// whose requests are destined to fail.
const aiFeature = window.jetpackContentGuidelinesAi?.aiFeature;

if ( aiFeature ) {
	const plansDispatch = dispatch( 'wordpress-com/plans' );
	plansDispatch.storeAiAssistantFeature( mapAiFeatureResponseToAiFeatureProps( aiFeature ) );
	// Mark the selector resolved so its resolver never fires a redundant
	// fetch when components select getAiAssistantFeature.
	plansDispatch.finishResolution( 'getAiAssistantFeature', [] );

	if ( document.readyState === 'loading' ) {
		document.addEventListener( 'DOMContentLoaded', startInjection );
	} else {
		startInjection();
	}
}