Context
As a Wikipedia Preview partner
I want to use shortcode
So I can enable Wikipedia Preview on my WordPress site
Acceptance Criteria
- The shortcode [wikipediapreview] exists
- It translates into <span data-wikipediapreview>content</span>
- It accepts the following arguments
- title: the value is transferred to the data-wp-title attribute on the <span>
- lang: the value is transferred to the data-wp-lang attribute on the <span>
- It transcludes inner shortcodes
- When the shortcode is used on a page (or always, if that conditional is not possible) the plugin loads the wikipediaPreview.production.js file and initializes it with the following options
- root: document.querySelector('.entry-content')
- lang: Configured site language
- When the shortcode is used on a page (or always, if that conditional is not possible) the plugin loads the wikipedia-preview.css file to style the <span>s with previews
Examples
shortcode | HTML |
---|---|
[wikipediapreview]Cat[/wikipediapreview] | <span data-wikipediapreview>Cat</span> |
[wikipediapreview title="Cat"]feline[/wikipediapreview] | <span data-wikipediapreview data-wp-title="Cat">feline</span> |
[wikipediapreview lang="fr"]chat[/wikipediapreview] | <span data-wikipediapreview data-wp-lang="fr">chat</span> |
[wikipediapreview]the [bold]black[/bold] cat[/wikipediapreview] | <span data-wikipediapreview>the <b>black</b> cat</span> |