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 to add a tooltip to an svg graphic?
- How to use z-index in svg elements?
- SVG transparent background web
- 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
- 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?
- 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 use a WordPress’ existing admin icon?
- getting uploaded SVG dimensions on front-end
- 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
- SVG image upload stopped working
- 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?
- 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?
- 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
- 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?
- Font awesome Icon HTML in widgets disappear on save
- 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
- 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
- Add other social networks to TwentyNineteen_SVG_Icons class in child theme?
- Set Site Icon programmatically (eg. using `wp cli`)
- 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?
- Get custom classes in WordPress Navigation Menu
- How to upload and style svg logo?
- How do I include SVG file used as featured image?
- Upload Custom Mime Types in WordPress (SVG, WebP)
- How to use Illustrator AI file to design a WordPress website
- wp_trim_words strips dashicons
- SVG in list-style-image breaks when adding fill
- Can you change the color of svg icons to the global color I choose from WordPress
- Can wp_get_image_editor convert to icon?
- Icon over thumbnail according to post format
- Allow SVG in WP step by step
- Custom Fields Question
- Replacing WordPress Icons (menu,icons32, etc)?
- download svg to png size image
- SVG upload does not work
- Whitelist a single SVG for use in post_content
- Widget Style – Icon Type
- Completely remove SVG icon load in child theme of Twenty Twenty-one theme
- How to remove the icons corresponding to “by” (author) and “date” from posts?
- Placing Lock Icon on WooCommmerce “Place Order” Checkout Button (WordPress ‘ignoring’ Changes…)
- SVG Upload to WordPress Issue
- How can I change this SVG shape that’s generated?
- WordPress Block.js SVG createElement
- import svg-files from wxr – (upload works, import not)
- jQuery for Fade Preload Causes My Site Favicon to Disappear from Tab of Browser
- Add a svg and show some text on the parts of that view when the user hover or click on that part in WordPress
- Custom Icon assigned to menu items not working for multi-site networks
- Where to place a svg chevron down in my custom walker?
- Enable CORS for getting an inline SVG by URL
- How to delay display of page elements until enqueued script has injected html
- Issue on adding Icons to Custom Post Type
- WordPress search form and input type=”image”
- Why plugin’s icon for the menu not found?
- How To Add Class To Style Search Box
- How to replace plugin icon?
- Why are some SVG-images not visible in my footer?
- Icon not shown in Dropdown menus in Twenty Seventeen Theme
- Can’t upload svg files in WordPress
- How to change mobile menu (toggle) icon in WordPress – Full Site Editing?
- Why isn’t my SVG path rotating on scroll on iPhones?