{ __( 'Place it', 'streamsera' ) }
setPosition( v as any )
}
options={ [
{
value: 'append',
label: __( 'At the end', 'streamsera' ),
},
{
value: 'prepend',
label: __( 'At the top', 'streamsera' ),
},
] }
/>
{ __(
'Added as an “StreamSera Player” block — you can move it in the editor later.',
'streamsera'
) }
{ attrs ? (
) : null }
>
);
}
/* ----------------------------------------------------------------- modal */
interface TabDef {
name: string;
label: string;
hint: string;
icon: string;
heading: string;
description: string;
action?: ReactNode;
}
export default function EmbedModal( {
playerId,
title,
onClose,
}: {
playerId: Id;
title?: string;
onClose: () => void;
} ) {
// Add-ons register extra tabs; re-render when they arrive.
const [ , bump ] = useState( 0 );
useEffect( () => onExtensionsChange( () => bump( ( n ) => n + 1 ) ), [] );
const [ tab, setTab ] = useState(
config.canEditPages === false ? 'block' : 'page'
);
const [ themeLang, setThemeLang ] = useState< 'php' | 'js' >( 'php' );
const extra = getEmbedTabs();
const tabs: TabDef[] = useMemo(
() =>
[
{
name: 'preview',
label: __( 'Preview', 'streamsera' ),
hint: __( 'Open on a blank page', 'streamsera' ),
icon: 'eye',
heading: __( 'Preview on a blank page', 'streamsera' ),
description: __(
'Opens the last saved version exactly as the frontend renders it — outside the builder, in a new tab. Drafts included; only logged-in editors can open it.',
'streamsera'
),
},
{
name: 'page',
label: __( 'Add to page', 'streamsera' ),
hint: __( 'Insert into a page', 'streamsera' ),
icon: 'pages',
heading: __( 'Add to a page', 'streamsera' ),
description: __(
'Insert the player into a page you already have, or create a new page with the player on it.',
'streamsera'
),
},
{
name: 'block',
label: __( 'Block', 'streamsera' ),
hint: __( 'Block editor', 'streamsera' ),
icon: 'block',
heading: __( 'Use the block', 'streamsera' ),
description: __(
'In the block editor, add the “StreamSera Player” block and pick this player. Layout, skin and theme can be overridden per block.',
'streamsera'
),
},
{
name: 'shortcode',
label: __( 'Shortcode', 'streamsera' ),
hint: __( 'Classic editor & builders', 'streamsera' ),
icon: 'code',
heading: __( 'Shortcode', 'streamsera' ),
description: __(
'Paste anywhere shortcodes work — the classic editor, widgets, page builders and theme options.',
'streamsera'
),
},
{
name: 'php',
label: __( 'Theme code', 'streamsera' ),
hint: __( 'PHP & JavaScript', 'streamsera' ),
icon: 'php',
heading: __( 'Theme code', 'streamsera' ),
description: __(
'For theme templates, custom PHP and JavaScript-rendered markup — when you need full control.',
'streamsera'
),
},
...extra.map( ( t ) => ( {
name: `ext:${ t.id }`,
label: t.label,
hint: t.hint || '',
icon: t.icon || 'external',
heading: t.heading || t.label,
description: t.description || '',
} ) ),
].filter(
// "Add to page" edits or creates pages: only for users who can edit pages.
( t ) => t.name !== 'page' || config.canEditPages !== false
),
// eslint-disable-next-line react-hooks/exhaustive-deps
[ extra.length ]
);
const current = tabs.find( ( t ) => t.name === tab ) || tabs[ 1 ];
const body = () => {
if ( tab.startsWith( 'ext:' ) ) {
const ext = extra.find( ( t ) => `ext:${ t.id }` === tab );
return ext ? (
) : null;
}
switch ( tab ) {
case 'preview':
return ;
case 'page':
return (
);
case 'block':
return ;
case 'shortcode':
return ;
default:
return (
);
}
};
const headAction =
tab === 'block' ? (
{ __( 'Open the editor', 'streamsera' ) }
) : tab === 'php' ? (
setThemeLang( v as any ) }
options={ [
{ value: 'php', label: 'PHP' },
{ value: 'js', label: 'JavaScript' },
] }
/>
) : null;
return (
{ `${ __( 'Embed', 'streamsera' ) } · ${
title || `#${ playerId }`
}` }
{ __(
'Put this player on a page, in a block or shortcode, on another site or in theme code.',
'streamsera'
) }
{ current.heading }
{ current.description ? (
{ current.description }
) : null }
{ headAction }
{ body() }
);
}
function ThemeCodeBody( {
playerId,
lang,
}: {
playerId: Id;
lang: 'php' | 'js';
} ) {
const docs = ( config as any ).docsUrl as string | undefined;
return (
<>
{ lang === 'php' ? (
<>
` }
large
/>
{ __( 'Capture the markup', 'streamsera' ) }
{ __(
'Returns the player HTML instead of printing it — for caching layers or custom wrappers.',
'streamsera'
) }