import React from 'react'; import { __ } from '@wordpress/i18n'; const PREVIEW_LABELS = { max_snippet: { label: __('Max snippet length', 'ai-rank-suite'), hint: __('How many characters Google may quote. −1 = no limit, 0 = no snippet at all.', 'ai-rank-suite'), names: { '-1': __('No limit', 'ai-rank-suite'), 0: __('No snippet', 'ai-rank-suite'), 50: __('50 characters', 'ai-rank-suite'), 100: __('100 characters', 'ai-rank-suite'), 160: __('160 characters', 'ai-rank-suite'), 200: __('200 characters', 'ai-rank-suite') }, }, max_image_preview: { label: __('Max image preview', 'ai-rank-suite'), hint: __('Size of the image Google may show next to this result.', 'ai-rank-suite'), names: { none: 'No image', standard: 'Standard', large: 'Large' }, }, max_video_preview: { label: __('Max video preview', 'ai-rank-suite'), hint: __('Seconds of video Google may play in the result. −1 = no limit.', 'ai-rank-suite'), names: { '-1': 'No limit', 0: 'No preview', 15: '15 seconds', 30: '30 seconds' }, }, }; const SOCIAL_FIELDS = [ { key: 'og_title', label: __('Facebook title', 'ai-rank-suite'), type: 'text' }, { key: 'og_desc', label: __('Facebook description', 'ai-rank-suite'), type: 'textarea' }, { key: 'og_image', label: __('Facebook image URL', 'ai-rank-suite'), type: 'text' }, { key: 'tw_title', label: __('X title', 'ai-rank-suite'), type: 'text' }, { key: 'tw_desc', label: __('X description', 'ai-rank-suite'), type: 'textarea' }, { key: 'tw_image', label: __('X image URL', 'ai-rank-suite'), type: 'text' }, ]; export default function AdvancedSeo({ item, onChange }) { const previews = item.previews || {}; const social = item.social || {}; const options = item.preview_options || {}; const setPreview = (key, value) => onChange({ previews: { ...previews, [key]: value } }); const setSocial = (key, value) => onChange({ social: { ...social, [key]: value } }); const warn = item.social_card?.image_warn; const meta = item.social_card?.image_meta; return (
{warn === 'none' && (
{__('No share image — set a featured image, a social override below, or a site-wide default under Social & sharing. Links shared without an image get far fewer clicks.', 'ai-rank-suite')}
)} {(warn === 'small' || warn === 'too_small') && meta && (
The share image is {meta.width}×{meta.height}px —{' '} {warn === 'too_small' ? 'below the 600×315 minimum, some platforms will drop it entirely.' : 'sharp previews need 1200×630 or larger.'}
)}
onChange({ slug: e.target.value })} placeholder={item.slug} />
{__('The last part of the address. Change it and this plugin writes a redirect from the old one, so existing links keep working.', 'ai-rank-suite')}
onChange({ canonical: e.target.value })} />
{__('Leave empty to point at this page itself. Set it only when this page duplicates another one — a wrong canonical removes the page from search entirely.', 'ai-rank-suite')}
onChange({ breadcrumb_title: e.target.value })} />
{__('A shorter label for the breadcrumb trail and the BreadcrumbList schema.', 'ai-rank-suite')}
{Object.entries(PREVIEW_LABELS).map(([key, meta]) => (
{meta.hint}
))}
{__('Social overrides', 'ai-rank-suite')}

{__('Empty fields fall back to the SEO title, the meta description and the featured image.', 'ai-rank-suite')}

{SOCIAL_FIELDS.map((f) => (
{f.type === 'textarea' ? (