If you use JSX in your code, then you need to build the script before using it on “standard” WordPress sites where JSX is not available.
So,
-
Either build the script..
-
Or (looking at your code, it’s probably easier to just) use (ES5 with)
wp.element.createElement()
and not JSX:var MyIcon = function () { var svg = createElement( 'svg', {}, createElement( 'path', { d: 'M5 4v3h5.5v12h3V7H19V4z' } ) ); return createElement( wp.components.Icon, { icon: svg } ); };
And that would replace the following part:
import { Icon } from '@wordpress/components'; const MyIcon = () => ( <Icon icon={ <svg><path d="M5 4v3h5.5v12h3V7H19V4z" /></svg> } /> );
Related Posts:
- Extending Genericons in WordPress
- Add custom SVG icons to Social Icon MENU in WordPress Twenty Seventeen Child Theme
- Remove apple-touch-icon link generated by WordPress
- How to edit original wordpress HTML source code and add icon?
- Font Awesome Icons only squares
- Hover a css icon width other color inside wp_get_attachment_image
- SVG icons in Twenty Nineteen
- Swap SVG icons in child themes
- Hide icon and rating when there is no rating entered
- social icons not showing
- Shown icon if old
- What is the `post-status` icon handle when using `@wordpress/icons`?
- SVG showing only in square ratio (using elementor) [closed]
- How do I change the my website icon in the search results page of a web browser?
- SVG center horizontal and vertical line
- Adding border to SVG image
- How to change the color of an svg element?
- SVG Fill Color Not Working
- D3 Appending Text to a SVG Rectangle
- How to add a tooltip to an svg graphic?
- How to use z-index in svg elements?
- SVG transparent background web
- SVG drop shadow using css3
- How to extract svg as file from web page
- How to set text color for my d3 chart title?
- How do I center an SVG in a div?
- Batch command for ImageMagick to convert all files in a directory and sub-directories on windows
- Disable emojicons introduced with WP 4.2
- SVG files not uploading since most recent WP update
- For what security reasons are svgs blocked in the media uploader?
- Ways to handle SVG rendering in wordpress?
- Escaping and sanitizing SVGs in metabox textarea
- How to upload SVG in WordPress 4.9.8?
- Can’t extract and set SVG dimensions
- how to change default icon of custom plugin?
- Replacing Icons in the Dashboard
- Issue with wp_get_attachment_image() and SVG file type
- Understanding SVG vulnerabilities in WordPress related to a specific fix
- How do I set up the defualt page icon for admin menu?
- Cant upload SVG files after updating WordPress 4.7.1 [duplicate]
- Tiny MCE editor stripping xlink:href parameter from SVG USE tag
- Escaping SVG with KSES
- How to Include SVG sprites icons into the body tag? [closed]
- How to use a WordPress’ existing admin icon?
- getting uploaded SVG dimensions on front-end
- How can I make my Admin Icon SVG color correctly? [closed]
- How do I enable the customize theme page to accept svg’s?
- Programmatically Add Font-Awesome Icons to Category Widget
- Adding extra SVGs to TwentyNineteen child theme using class TwentyNineteen_SVG_Icons
- Stylizing external SVG files with jQuery and CSS
- Why could I not change the icon of the default Add media button that I added into the toolbar of TinyMCE?
- use of tag into wordpress
- SVG image upload stopped working
- How to display an icon when a new post is published and then remove it when a specific time past?
- How to implement my own icons instead of using the svg icon system
- How to get Menu Navigation Labels to output HTML
- Replace Home with image link inside custom header menu
- Set media metadata (i.e. “dimensions” field) on SVG file after extracting it with a filter
- How to add iOS & fav icons to the theme?
- How can I use a different default admin menu icon for custom post type?
- Allowing SVG uploads in media uploader without plug-in
- How to use a svg as custom header?
- WordPress native “playlist” shortcode. Next and Prev there are but with no icons. How to fix?
- How to remove SVG Files inline code of WordPress Footer?
- How do I remove the eye icon that shows visibility on login screen and reset password screen
- Featured Image .svg height and width 1px only
- How can a default site icon be set in customizer?
- Add 32×32 icon to custom post type index page
- Why does SVG upload in Media Library fail if the file does not have an XML tag at the beginning?
- Plugin that inserts favicon next to links
- Disable automatig SVG tag from menu
- Icon font not working on subdomains of multisite
- How to show Home Page link in WordPress Menu and how to add an icon to this?
- Compact pingback list with favicons
- Font awesome Icon HTML in widgets disappear on save
- Font Awesome Icons Won’t Work
- How do i add edit shortcut icon in wordpress without using selective refresh
- Location of theme options page menu icon
- custom admin thumbnail for videos, not getting post’s id?
- How to add an RSS logo to my blogs header?
- How can I replace the text at the top of a custom column into a icon?
- Add icon/badge next to posttitle of specific category
- Insert SVG code (not img) in HTML block
- CSS to remove “comments count” icon from main page [closed]
- SVG Featured image not shown in twitter
- Jetpack social icons in other places on site
- How to insert icon in site title
- change video icons to selected thumbnail?
- Change via CSS the color of social menu icons
- Use Icomoon external svg file with
- Add other social networks to TwentyNineteen_SVG_Icons class in child theme?
- Set Site Icon programmatically (eg. using `wp cli`)
- How to Add Custom New Published Post Counter Icon on Top of the WordPress Site [closed]
- Dashicons and Pseudo :before
- Xili language plugin not showing language flag [closed]
- How to Change custom post type Dashicon Color
- Display an icon with get_post_meta?
- How to edit the default icon of Add Media button?
- Theming Using Bootstrap Glyphicons and WordPress Dashicons
- Get custom classes in WordPress Navigation Menu