πŸ”— LinkSelector Component Demo

Interactive demonstration of the LinkSelector component for linking translated content.

ℹ️ Note

This is a demo page. In production, the component would be integrated into WordPress admin with a real REST API endpoint. For this demo, we'll use mock data.

1. Basic Usage

Simple link selector with minimal configuration.

Console Output:

Initializing...

2. With Pre-selected Links

Initialize with existing translations already selected.

Console Output:

Initializing with 2 pre-selected links...

3. Custom Post Types

Include custom post types (product, portfolio) in search.

Console Output:

Initializing with custom post types...

4. Programmatic Control

Control the component programmatically using its API.

Console Output:

Ready for programmatic control...

πŸ“š API Reference

Constructor Options

container (required): Container element or selector
sourcePostId (required): Source post ID
targetLanguage (required): Target language code
sourceLanguage (optional): Source language (default: 'en')
postTypes (optional): Array of post types (default: ['post', 'page'])
selectedLinks (optional): Pre-selected links
onChange (optional): Callback when selection changes
apiEndpoint (optional): Custom REST API endpoint

Methods

getSelectedLinks(): Get currently selected links
setSelectedLinks(links): Programmatically set selected links
destroy(): Destroy the component and clean up

Features