{"id":268,"date":"2026-08-14T14:01:42","date_gmt":"2026-08-14T12:01:42","guid":{"rendered":"https:\/\/helloblog.io\/de\/eigene-svg-icons-wordpress-7-1\/"},"modified":"2026-08-14T14:01:42","modified_gmt":"2026-08-14T12:01:42","slug":"eigene-svg-icons-wordpress-7-1","status":"publish","type":"post","link":"https:\/\/helloblog.io\/de\/eigene-svg-icons-wordpress-7-1\/","title":{"rendered":"Eigene SVG-Icons in WordPress 7.1 registrieren"},"content":{"rendered":"\n<p>Eigene SVG-Icons im Block-Editor einzubinden, erforderte lange JavaScript, einen Build-Schritt oder unzuverl\u00e4ssige Behelfsl\u00f6sungen. WordPress 7.1 f\u00fchrt daf\u00fcr eine \u00f6ffentliche API ein: Du registrierst Icons in einem Plugin und verwendest sie im <code>core\/icon<\/code>-Block, in PHP und \u00fcber die REST-API \u2013 ohne JavaScript-Build-Schritt.<\/p>\n\n\n\n<p>WordPress 7.1 soll am 19. August 2026 erscheinen. F\u00fcr die Entwicklung funktioniert auch der Release Candidate von WordPress 7.1. In dieser Anleitung baust du ein kleines Plugin mit einer Icon-Collection, drei Beispiel-Icons, einer automatischen Registrierung f\u00fcr einen ganzen Ordner und einem Shortcode.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Das Plugin und seine Voraussetzungen<\/h2>\n\n\n\n<p>Am Ende enth\u00e4lt dein Plugin die Collection <code>myplugin<\/code>, ein inline registriertes Herz sowie Stern und Lesezeichen aus SVG-Dateien. Au\u00dferdem kannst du jedes SVG in einem Ordner automatisch registrieren, Icons im Inhalt per Shortcode ausgeben und ein Icon als Symbol eines eigenen Blocks einsetzen.<\/p>\n\n\n\n<p>Du brauchst daf\u00fcr WordPress 7.1 oder neuer, einige SVG-Dateien, eine lokale Entwicklungsumgebung wie LocalWP, WordPress Studio oder wp-env sowie grundlegende PHP-Kenntnisse. Das vollst\u00e4ndige Beispiel-Plugin mit SVG-Dateien, README und der Registrierung f\u00fcr ganze Ordner steht auf <a href=\"https:\/\/github.com\/webtechhardik\/wpviibes-custom-icons\">GitHub<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Die API: Collections registrieren, Icons ausgeben<\/h2>\n\n\n\n<p>Die API besteht aus drei Funktionen und Collections als Ordnungsprinzip. Eine Collection ist eine benannte Gruppe von Icons. Jedes Icon muss zu genau einer Collection geh\u00f6ren; deren Name bildet den Pr\u00e4fix des vollst\u00e4ndigen Icon-Namens. Dadurch kollidieren etwa <code>core\/plus<\/code> und <code>myplugin\/plus<\/code> nicht miteinander.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Die drei Funktionen<\/h3>\n\n\n\n<p><code>wp_register_icon_collection( $name, $args )<\/code> registriert eine Collection. Mit <code>wp_register_icon( $name, $args )<\/code> legst du ein einzelnes Icon an. <code>wp_get_icon( $name, $args )<\/code> rendert ein Icon in PHP und gibt dessen SVG als String zur\u00fcck.<\/p>\n\n\n\n<p>Beim Registrieren eines Icons \u00fcbergibst du das SVG auf eine von zwei Arten: <code>content<\/code> enth\u00e4lt den SVG-Markup direkt als String in PHP, <code>file_path<\/code> verweist auf den absoluten Pfad einer <code>.svg<\/code>-Datei. Verwende pro Icon nur eine dieser Varianten. <code>content<\/code> eignet sich f\u00fcr ein oder zwei Icons, <code>file_path<\/code> skaliert besser f\u00fcr umfangreiche Icon-Bibliotheken in einem Ordner.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Plugin anlegen und Collection zuerst registrieren<\/h2>\n\n\n\n<p>Lege im Verzeichnis <code>wp-content\/plugins\/<\/code> folgende Struktur an. Die Collection muss bereits existieren, bevor du ihr Icons hinzuf\u00fcgst. Registrierst du ein Icon vorher, erscheint es nicht im Picker, ohne dass WordPress einen sichtbaren Fehler ausgibt.<\/p>\n\n\n<a href=\"https:\/\/github.com\/webtechhardik\/wpviibes-custom-icons\" class=\"download-card\" download>\n                <span class=\"download-icon\"><i class=\"fa-duotone fa-file-arrow-down\"><\/i><\/span>\n                <span class=\"download-info\">\n                    <span class=\"download-title\">Plugin-Struktur<\/span>\n                    <span class=\"download-meta\"><span class=\"download-filename\">Verzeichnisstruktur<\/span><span class=\"download-size\">.<\/span><\/span>\n                <\/span>\n                <span class=\"download-action\"><i class=\"fa-duotone fa-arrow-down-to-line\"><\/i><\/span>\n            <\/a>\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>myplugin-custom-icons\/\n\u251c\u2500\u2500 myplugin-custom-icons.php\n\u2514\u2500\u2500 icons\/\n    \u251c\u2500\u2500 star.svg\n    \u2514\u2500\u2500 bookmark.svg\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span>myplugin-custom-icons\/<\/span><\/span>\n<span class=\"line\"><span>\u251c\u2500\u2500 myplugin-custom-icons.php<\/span><\/span>\n<span class=\"line\"><span>\u2514\u2500\u2500 icons\/<\/span><\/span>\n<span class=\"line\"><span>    \u251c\u2500\u2500 star.svg<\/span><\/span>\n<span class=\"line\"><span>    \u2514\u2500\u2500 bookmark.svg<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Erstelle anschlie\u00dfend die Plugin-Datei. Die Action f\u00fcr die Collection nutzt die Standard-Priorit\u00e4t <code>10<\/code> auf <code>init<\/code>. Der Name <code>myplugin<\/code> wird sp\u00e4ter zum Pr\u00e4fix aller enthaltenen Icons, etwa <code>myplugin\/heart<\/code> oder <code>myplugin\/star<\/code>. Das Label erscheint als \u00dcberschrift des jeweiligen Bereichs im Icon-Picker.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;?php\n\/**\n * Plugin Name: MyPlugin Custom Icons\n * Description: Registriert eigene SVG-Icons f\u00fcr WordPress 7.1+.\n * Version:     1.0.0\n * Requires at least: 7.1\n * Requires PHP: 7.4\n *\/\n\nif ( ! defined( 'ABSPATH' ) ) {\n    exit;\n}\n\ndefine( 'MYPLUGIN_ICONS_PATH', plugin_dir_path( __FILE__ ) );\n\n\/**\n * Zuerst die Icon-Collection registrieren.\n *\/\nadd_action( 'init', 'myplugin_register_icon_collection' );\n\nfunction myplugin_register_icon_collection() {\n    wp_register_icon_collection(\n        'myplugin',\n        array(\n            'label' =&gt; __( 'MyPlugin', 'myplugin-icons' ),\n        )\n    );\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#F97583\">&#x3C;?<\/span><span style=\"color:#79B8FF\">php<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">\/**<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"> * Plugin Name: MyPlugin Custom Icons<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"> * Description: Registriert eigene SVG-Icons f\u00fcr WordPress 7.1+.<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"> * Version:     1.0.0<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"> * Requires at least: 7.1<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"> * Requires PHP: 7.4<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"> *\/<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">if<\/span><span style=\"color:#E1E4E8\"> ( <\/span><span style=\"color:#F97583\">!<\/span><span style=\"color:#79B8FF\"> defined<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'ABSPATH'<\/span><span style=\"color:#E1E4E8\"> ) ) {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">    exit<\/span><span style=\"color:#E1E4E8\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">define<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'MYPLUGIN_ICONS_PATH'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#B392F0\">plugin_dir_path<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#79B8FF\">__FILE__<\/span><span style=\"color:#E1E4E8\"> ) );<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">\/**<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"> * Zuerst die Icon-Collection registrieren.<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"> *\/<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">add_action<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'init'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#9ECBFF\">'myplugin_register_icon_collection'<\/span><span style=\"color:#E1E4E8\"> );<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">function<\/span><span style=\"color:#B392F0\"> myplugin_register_icon_collection<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">    wp_register_icon_collection<\/span><span style=\"color:#E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">        'myplugin'<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">        array<\/span><span style=\"color:#E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">            'label'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#B392F0\"> __<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'MyPlugin'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#9ECBFF\">'myplugin-icons'<\/span><span style=\"color:#E1E4E8\"> ),<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">        )<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    );<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Aktiviere das Plugin unter <strong>Plugins \u2192 Installierte Plugins<\/strong>. Eine leere Collection rendert noch nichts; erst registrierte Icons machen sie im Picker sichtbar.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Icons inline und aus Dateien registrieren<\/h2>\n\n\n\n<p>WordPress unterst\u00fctzt beide Eingabeformen auch innerhalb derselben Collection. Das Herz bleibt im PHP-Code, w\u00e4hrend Stern und Lesezeichen aus Dateien im Ordner <code>icons\/<\/code> kommen.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Herz mit inline-SVG \u00fcber <code>content<\/code> anlegen<\/h3>\n\n\n\n<p>H\u00e4nge diese Funktion mit Priorit\u00e4t <code>20<\/code> an <code>init<\/code>. Sie l\u00e4uft damit nach der Collection-Registrierung. Der Name folgt dem Muster <code>collection\/icon-slug<\/code>, das Label beschreibt das Icon im Picker und <code>content<\/code> enth\u00e4lt den SVG-Markup. <code>stroke=&quot;currentColor&quot;<\/code> sorgt daf\u00fcr, dass das Icon die Textfarbe seiner Umgebung \u00fcbernimmt, statt eine feste F\u00fcllfarbe zu erzwingen.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>add_action( 'init', 'myplugin_register_inline_icons', 20 );\n\nfunction myplugin_register_inline_icons() {\n    wp_register_icon(\n        'myplugin\/heart',\n        array(\n            'label'   =&gt; __( 'Heart', 'myplugin-icons' ),\n            'content' =&gt; '&lt;svg xmlns=&quot;http:\/\/www.w3.org\/2000\/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;&lt;path d=&quot;M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z&quot;\/&gt;&lt;\/svg&gt;',\n        )\n    );\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#B392F0\">add_action<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'init'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#9ECBFF\">'myplugin_register_inline_icons'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#79B8FF\">20<\/span><span style=\"color:#E1E4E8\"> );<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">function<\/span><span style=\"color:#B392F0\"> myplugin_register_inline_icons<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">    wp_register_icon<\/span><span style=\"color:#E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">        'myplugin\/heart'<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">        array<\/span><span style=\"color:#E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">            'label'<\/span><span style=\"color:#F97583\">   =><\/span><span style=\"color:#B392F0\"> __<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'Heart'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#9ECBFF\">'myplugin-icons'<\/span><span style=\"color:#E1E4E8\"> ),<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">            'content'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#9ECBFF\"> '&#x3C;svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">&#x3C;path d=\"M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z\"\/>&#x3C;\/svg>'<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">        )<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    );<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Stern und Lesezeichen per <code>file_path<\/code> laden<\/h3>\n\n\n\n<p>Speichere zun\u00e4chst diese Dateien im Unterordner <code>icons\/<\/code>. Bei der dateibasierten Variante liest WordPress die jeweilige SVG-Datei bei Bedarf ein.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;svg xmlns=&quot;http:\/\/www.w3.org\/2000\/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;\n    &lt;polygon points=&quot;12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2&quot;\/&gt;\n&lt;\/svg&gt;\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#E1E4E8\">&#x3C;<\/span><span style=\"color:#85E89D\">svg<\/span><span style=\"color:#B392F0\"> xmlns<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"http:\/\/www.w3.org\/2000\/svg\"<\/span><span style=\"color:#B392F0\"> viewBox<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"0 0 24 24\"<\/span><span style=\"color:#B392F0\"> fill<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"none\"<\/span><span style=\"color:#B392F0\"> stroke<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"currentColor\"<\/span><span style=\"color:#B392F0\"> stroke-width<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"2\"<\/span><span style=\"color:#B392F0\"> stroke-linecap<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"round\"<\/span><span style=\"color:#B392F0\"> stroke-linejoin<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"round\"<\/span><span style=\"color:#E1E4E8\">><\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    &#x3C;<\/span><span style=\"color:#85E89D\">polygon<\/span><span style=\"color:#B392F0\"> points<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2\"<\/span><span style=\"color:#E1E4E8\">\/><\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">&#x3C;\/<\/span><span style=\"color:#85E89D\">svg<\/span><span style=\"color:#E1E4E8\">><\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;svg xmlns=&quot;http:\/\/www.w3.org\/2000\/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;none&quot; stroke=&quot;currentColor&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot;&gt;\n    &lt;path d=&quot;M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z&quot;\/&gt;\n&lt;\/svg&gt;\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#E1E4E8\">&#x3C;<\/span><span style=\"color:#85E89D\">svg<\/span><span style=\"color:#B392F0\"> xmlns<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"http:\/\/www.w3.org\/2000\/svg\"<\/span><span style=\"color:#B392F0\"> viewBox<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"0 0 24 24\"<\/span><span style=\"color:#B392F0\"> fill<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"none\"<\/span><span style=\"color:#B392F0\"> stroke<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"currentColor\"<\/span><span style=\"color:#B392F0\"> stroke-width<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"2\"<\/span><span style=\"color:#B392F0\"> stroke-linecap<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"round\"<\/span><span style=\"color:#B392F0\"> stroke-linejoin<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"round\"<\/span><span style=\"color:#E1E4E8\">><\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    &#x3C;<\/span><span style=\"color:#85E89D\">path<\/span><span style=\"color:#B392F0\"> d<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z\"<\/span><span style=\"color:#E1E4E8\">\/><\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">&#x3C;\/<\/span><span style=\"color:#85E89D\">svg<\/span><span style=\"color:#E1E4E8\">><\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>add_action( 'init', 'myplugin_register_file_icons', 20 );\n\nfunction myplugin_register_file_icons() {\n    wp_register_icon(\n        'myplugin\/star',\n        array(\n            'label'     =&gt; __( 'Star', 'myplugin-icons' ),\n            'file_path' =&gt; MYPLUGIN_ICONS_PATH . 'icons\/star.svg',\n        )\n    );\n\n    wp_register_icon(\n        'myplugin\/bookmark',\n        array(\n            'label'     =&gt; __( 'Bookmark', 'myplugin-icons' ),\n            'file_path' =&gt; MYPLUGIN_ICONS_PATH . 'icons\/bookmark.svg',\n        )\n    );\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#B392F0\">add_action<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'init'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#9ECBFF\">'myplugin_register_file_icons'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#79B8FF\">20<\/span><span style=\"color:#E1E4E8\"> );<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">function<\/span><span style=\"color:#B392F0\"> myplugin_register_file_icons<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">    wp_register_icon<\/span><span style=\"color:#E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">        'myplugin\/star'<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">        array<\/span><span style=\"color:#E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">            'label'<\/span><span style=\"color:#F97583\">     =><\/span><span style=\"color:#B392F0\"> __<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'Star'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#9ECBFF\">'myplugin-icons'<\/span><span style=\"color:#E1E4E8\"> ),<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">            'file_path'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#79B8FF\"> MYPLUGIN_ICONS_PATH<\/span><span style=\"color:#F97583\"> .<\/span><span style=\"color:#9ECBFF\"> 'icons\/star.svg'<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">        )<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    );<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">    wp_register_icon<\/span><span style=\"color:#E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">        'myplugin\/bookmark'<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">        array<\/span><span style=\"color:#E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">            'label'<\/span><span style=\"color:#F97583\">     =><\/span><span style=\"color:#B392F0\"> __<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'Bookmark'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#9ECBFF\">'myplugin-icons'<\/span><span style=\"color:#E1E4E8\"> ),<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">            'file_path'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#79B8FF\"> MYPLUGIN_ICONS_PATH<\/span><span style=\"color:#F97583\"> .<\/span><span style=\"color:#9ECBFF\"> 'icons\/bookmark.svg'<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">        )<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    );<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u00d6ffne jetzt einen <code>core\/icon<\/code>-Block im Editor. Der Picker zeigt die neue Collection <strong>MyPlugin<\/strong> mit Heart, Star und Bookmark. Falls ein Icon fehlt, pr\u00fcfe zuerst die Reihenfolge: Die Collection muss mit Standard-Priorit\u00e4t registriert werden, die Icons danach, beispielsweise mit Priorit\u00e4t <code>20<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1712\" height=\"602\" src=\"https:\/\/helloblog.io\/app\/uploads\/sites\/3\/2026\/08\/custom-icons-added-tab-in-wordpress.webp\" alt=\"Eigene Icons im Picker des WordPress-Icon-Blocks\" class=\"wp-image-266\" srcset=\"https:\/\/helloblog.io\/app\/uploads\/sites\/3\/2026\/08\/custom-icons-added-tab-in-wordpress.webp 1712w, https:\/\/helloblog.io\/app\/uploads\/sites\/3\/2026\/08\/custom-icons-added-tab-in-wordpress-300x105.webp 300w, https:\/\/helloblog.io\/app\/uploads\/sites\/3\/2026\/08\/custom-icons-added-tab-in-wordpress-1024x360.webp 1024w, https:\/\/helloblog.io\/app\/uploads\/sites\/3\/2026\/08\/custom-icons-added-tab-in-wordpress-768x270.webp 768w, https:\/\/helloblog.io\/app\/uploads\/sites\/3\/2026\/08\/custom-icons-added-tab-in-wordpress-1536x540.webp 1536w, https:\/\/helloblog.io\/app\/uploads\/sites\/3\/2026\/08\/custom-icons-added-tab-in-wordpress-400x141.webp 400w\" sizes=\"auto, (max-width: 1712px) 100vw, 1712px\" \/><figcaption class=\"wp-element-caption\">Der Picker gruppiert die registrierten Icons in einer eigenen Collection. \u2014 <em>Forr\u00e1s: WPVibes<\/em><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">3. Alle SVG-Dateien eines Ordners automatisch registrieren<\/h2>\n\n\n\n<p>Bei einer echten Icon-Bibliothek sind einzelne Aufrufe von <code>wp_register_icon()<\/code> nicht wartbar. Ersetze die Funktion <code>myplugin_register_file_icons()<\/code> durch diese Variante. Sie findet bei jedem Request s\u00e4mtliche SVG-Dateien im Ordner und registriert sie automatisch.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>add_action( 'init', 'myplugin_register_all_file_icons', 20 );\n\nfunction myplugin_register_all_file_icons() {\n    $icons_dir = MYPLUGIN_ICONS_PATH . 'icons\/';\n    $svg_files = glob( $icons_dir . '*.svg' );\n\n    if ( empty( $svg_files ) ) {\n        return;\n    }\n\n    foreach ( $svg_files as $file_path ) {\n        $slug  = basename( $file_path, '.svg' );\n        $label = ucwords( str_replace( '-', ' ', $slug ) );\n\n        wp_register_icon(\n            'myplugin\/' . $slug,\n            array(\n                'label'     =&gt; $label,\n                'file_path' =&gt; $file_path,\n            )\n        );\n    }\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#B392F0\">add_action<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'init'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#9ECBFF\">'myplugin_register_all_file_icons'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#79B8FF\">20<\/span><span style=\"color:#E1E4E8\"> );<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">function<\/span><span style=\"color:#B392F0\"> myplugin_register_all_file_icons<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    $icons_dir <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#79B8FF\"> MYPLUGIN_ICONS_PATH<\/span><span style=\"color:#F97583\"> .<\/span><span style=\"color:#9ECBFF\"> 'icons\/'<\/span><span style=\"color:#E1E4E8\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    $svg_files <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#79B8FF\"> glob<\/span><span style=\"color:#E1E4E8\">( $icons_dir <\/span><span style=\"color:#F97583\">.<\/span><span style=\"color:#9ECBFF\"> '*.svg'<\/span><span style=\"color:#E1E4E8\"> );<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">    if<\/span><span style=\"color:#E1E4E8\"> ( <\/span><span style=\"color:#79B8FF\">empty<\/span><span style=\"color:#E1E4E8\">( $svg_files ) ) {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">        return<\/span><span style=\"color:#E1E4E8\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">    foreach<\/span><span style=\"color:#E1E4E8\"> ( $svg_files <\/span><span style=\"color:#F97583\">as<\/span><span style=\"color:#E1E4E8\"> $file_path ) {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">        $slug  <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#79B8FF\"> basename<\/span><span style=\"color:#E1E4E8\">( $file_path, <\/span><span style=\"color:#9ECBFF\">'.svg'<\/span><span style=\"color:#E1E4E8\"> );<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">        $label <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#79B8FF\"> ucwords<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#79B8FF\">str_replace<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'-'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#9ECBFF\">' '<\/span><span style=\"color:#E1E4E8\">, $slug ) );<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">        wp_register_icon<\/span><span style=\"color:#E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">            'myplugin\/'<\/span><span style=\"color:#F97583\"> .<\/span><span style=\"color:#E1E4E8\"> $slug,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">            array<\/span><span style=\"color:#E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">                'label'<\/span><span style=\"color:#F97583\">     =><\/span><span style=\"color:#E1E4E8\"> $label,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">                'file_path'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#E1E4E8\"> $file_path,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">            )<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">        );<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p><code>glob( $icons_dir . '*.svg' )<\/code> liefert alle <code>.svg<\/code>-Dateien im Zielordner. <code>basename( $file_path, '.svg' )<\/code> entfernt Pfad und Erweiterung, aus <code>advanced-button.svg<\/code> wird also <code>advanced-button<\/code>. <code>ucwords( str_replace( '-', ' ', $slug ) )<\/code> erzeugt daraus das lesbare Picker-Label \u201eAdvanced Button\u201c. Die Schleife registriert jedes Ergebnis unter <code>myplugin\/<\/code>.<\/p>\n\n\n\n<p>Lege neue SVG-Dateien in <code>icons\/<\/code> ab und aktualisiere den Editor. Sie erscheinen ohne weitere Code-\u00c4nderung im Picker. Das Muster skaliert von drei Icons auf Hunderte: Das Herz registrierst du weiterhin inline, Stern, Lesezeichen und alle zus\u00e4tzlich abgelegten Dateien kommen aus dem Ordner.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1207\" height=\"341\" src=\"https:\/\/helloblog.io\/app\/uploads\/sites\/3\/2026\/08\/multiple-custom-icons-added-wordpress.webp\" alt=\"Mehrere eigene SVG-Icons in einer WordPress-Collection\" class=\"wp-image-267\" srcset=\"https:\/\/helloblog.io\/app\/uploads\/sites\/3\/2026\/08\/multiple-custom-icons-added-wordpress.webp 1207w, https:\/\/helloblog.io\/app\/uploads\/sites\/3\/2026\/08\/multiple-custom-icons-added-wordpress-300x85.webp 300w, https:\/\/helloblog.io\/app\/uploads\/sites\/3\/2026\/08\/multiple-custom-icons-added-wordpress-1024x289.webp 1024w, https:\/\/helloblog.io\/app\/uploads\/sites\/3\/2026\/08\/multiple-custom-icons-added-wordpress-768x217.webp 768w, https:\/\/helloblog.io\/app\/uploads\/sites\/3\/2026\/08\/multiple-custom-icons-added-wordpress-400x113.webp 400w\" sizes=\"auto, (max-width: 1207px) 100vw, 1207px\" \/><figcaption class=\"wp-element-caption\">Die automatische Registrierung f\u00fcgt alle SVG-Dateien eines Ordners zur Collection hinzu. \u2014 <em>Forr\u00e1s: WPVibes<\/em><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">4. Icons im Editor, in PHP und \u00fcber REST verwenden<\/h2>\n\n\n\n<p>Eine Registrierung versorgt drei Nutzungskontexte. Der <code>core\/icon<\/code>-Block liest jede registrierte Collection automatisch aus. Externe Tools k\u00f6nnen Icons \u00fcber <code>\/wp-json\/wp\/v2\/icons<\/code> abfragen; f\u00fcr Collections gibt es zus\u00e4tzlich <code>\/wp-json\/wp\/v2\/icon-collections<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">SVG in PHP mit <code>wp_get_icon()<\/code> ausgeben<\/h3>\n\n\n\n<p><code>wp_get_icon()<\/code> liefert das SVG als String zur\u00fcck. Du kannst es direkt ausgeben oder in eigenen HTML-Markup einbetten.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>echo wp_get_icon( 'myplugin\/heart' );\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#79B8FF\">echo<\/span><span style=\"color:#B392F0\"> wp_get_icon<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'myplugin\/heart'<\/span><span style=\"color:#E1E4E8\"> );<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>F\u00fcr Templates steuerst du Pixelgr\u00f6\u00dfe, CSS-Klasse und Barrierefreiheit \u00fcber das zweite Argument. <code>size<\/code> setzt <code>width<\/code> und <code>height<\/code> des SVG in Pixeln, <code>class<\/code> erg\u00e4nzt eine CSS-Klasse am SVG-Element und <code>label<\/code> setzt <code>aria-label<\/code> f\u00fcr Screenreader.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>echo wp_get_icon(\n    'myplugin\/star',\n    array(\n        'size'  =&gt; 32,\n        'class' =&gt; 'featured-icon',\n        'label' =&gt; __( 'Featured', 'myplugin-icons' ),\n    )\n);\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#79B8FF\">echo<\/span><span style=\"color:#B392F0\"> wp_get_icon<\/span><span style=\"color:#E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">    'myplugin\/star'<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">    array<\/span><span style=\"color:#E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">        'size'<\/span><span style=\"color:#F97583\">  =><\/span><span style=\"color:#79B8FF\"> 32<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">        'class'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#9ECBFF\"> 'featured-icon'<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">        'label'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#B392F0\"> __<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'Featured'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#9ECBFF\">'myplugin-icons'<\/span><span style=\"color:#E1E4E8\"> ),<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    )<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">);<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Icons per Shortcode in Beitr\u00e4ge und Seiten einf\u00fcgen<\/h3>\n\n\n\n<p>Mit dem Shortcode <code>[myplugin_icon]<\/code> k\u00f6nnen Redakteure ein registriertes Icon in Beitr\u00e4gen, Seiten oder Widgets verwenden. Die Funktion bereinigt den Icon-Namen, die Gr\u00f6\u00dfe und die Klasse. Liefert <code>wp_get_icon()<\/code> kein Icon, gibt der Shortcode einen leeren String zur\u00fcck.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>add_shortcode( 'myplugin_icon', 'myplugin_icon_shortcode' );\n\nfunction myplugin_icon_shortcode( $atts ) {\n    $atts = shortcode_atts(\n        array(\n            'name'  =&gt; 'heart',\n            'text'  =&gt; '',\n            'size'  =&gt; 24,\n            'class' =&gt; '',\n        ),\n        $atts\n    );\n\n    $icon = wp_get_icon(\n        'myplugin\/' . sanitize_key( $atts['name'] ),\n        array(\n            'size'  =&gt; absint( $atts['size'] ),\n            'class' =&gt; sanitize_html_class( $atts['class'] ),\n        )\n    );\n\n    if ( ! $icon ) {\n        return '';\n    }\n\n    return sprintf(\n        '&lt;span&gt;%s %s&lt;\/span&gt;',\n        $icon,\n        esc_html( $atts['text'] )\n    );\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#B392F0\">add_shortcode<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'myplugin_icon'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#9ECBFF\">'myplugin_icon_shortcode'<\/span><span style=\"color:#E1E4E8\"> );<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">function<\/span><span style=\"color:#B392F0\"> myplugin_icon_shortcode<\/span><span style=\"color:#E1E4E8\">( $atts ) {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    $atts <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#B392F0\"> shortcode_atts<\/span><span style=\"color:#E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">        array<\/span><span style=\"color:#E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">            'name'<\/span><span style=\"color:#F97583\">  =><\/span><span style=\"color:#9ECBFF\"> 'heart'<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">            'text'<\/span><span style=\"color:#F97583\">  =><\/span><span style=\"color:#9ECBFF\"> ''<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">            'size'<\/span><span style=\"color:#F97583\">  =><\/span><span style=\"color:#79B8FF\"> 24<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">            'class'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#9ECBFF\"> ''<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">        ),<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">        $atts<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    );<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    $icon <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#B392F0\"> wp_get_icon<\/span><span style=\"color:#E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">        'myplugin\/'<\/span><span style=\"color:#F97583\"> .<\/span><span style=\"color:#B392F0\"> sanitize_key<\/span><span style=\"color:#E1E4E8\">( $atts[<\/span><span style=\"color:#9ECBFF\">'name'<\/span><span style=\"color:#E1E4E8\">] ),<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">        array<\/span><span style=\"color:#E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">            'size'<\/span><span style=\"color:#F97583\">  =><\/span><span style=\"color:#B392F0\"> absint<\/span><span style=\"color:#E1E4E8\">( $atts[<\/span><span style=\"color:#9ECBFF\">'size'<\/span><span style=\"color:#E1E4E8\">] ),<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">            'class'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#B392F0\"> sanitize_html_class<\/span><span style=\"color:#E1E4E8\">( $atts[<\/span><span style=\"color:#9ECBFF\">'class'<\/span><span style=\"color:#E1E4E8\">] ),<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">        )<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    );<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">    if<\/span><span style=\"color:#E1E4E8\"> ( <\/span><span style=\"color:#F97583\">!<\/span><span style=\"color:#E1E4E8\"> $icon ) {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">        return<\/span><span style=\"color:#9ECBFF\"> ''<\/span><span style=\"color:#E1E4E8\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">    return<\/span><span style=\"color:#79B8FF\"> sprintf<\/span><span style=\"color:#E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">        '&#x3C;span>%s %s&#x3C;\/span>'<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">        $icon,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">        esc_html<\/span><span style=\"color:#E1E4E8\">( $atts[<\/span><span style=\"color:#9ECBFF\">'text'<\/span><span style=\"color:#E1E4E8\">] )<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    );<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>[myplugin_icon name=&quot;heart&quot; text=&quot;Hello World&quot;]\n\n[myplugin_icon name=&quot;star&quot; text=&quot;Featured post&quot; size=&quot;32&quot;]\n\n[myplugin_icon name=&quot;bookmark&quot; text=&quot;Save for later&quot; size=&quot;20&quot;]\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#E1E4E8\">[myplugin_icon name=\"heart\" text=\"Hello World\"]<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">[myplugin_icon name=\"star\" text=\"Featured post\" size=\"32\"]<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">[myplugin_icon name=\"bookmark\" text=\"Save for later\" size=\"20\"]<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Das Icon steht jeweils neben dem Text und \u00fcbernimmt die \u00fcber <code>size<\/code> angegebene Gr\u00f6\u00dfe. Wegen <code>currentColor<\/code> passt es sich automatisch an die umgebende Textfarbe an.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Eigenes Icon f\u00fcr einen Block registrieren<\/h3>\n\n\n\n<p>Du kannst ein registriertes Icon auch als Block-Symbol an <code>register_block_type()<\/code> \u00fcbergeben. Statt eines Dashicons wie <code>warning<\/code> tr\u00e4gst du den vollst\u00e4ndigen Namen des Custom Icons ein. Der Block-Inserter zeigt dann das eigene SVG; das funktioniert bei JavaScript-registrierten und bei reinen PHP-Bl\u00f6cken.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>'icon' =&gt; 'warning', \/\/ Verwendet ein Dashicon\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#9ECBFF\">'icon'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#9ECBFF\"> 'warning'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#6A737D\">\/\/ Verwendet ein Dashicon<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>'icon' =&gt; 'myplugin\/star', \/\/ Verwendet ein registriertes eigenes Icon\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#9ECBFF\">'icon'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#9ECBFF\"> 'myplugin\/star'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#6A737D\">\/\/ Verwendet ein registriertes eigenes Icon<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">5. SVG-Icons mit CSS anpassen<\/h2>\n\n\n\n<p>Gut integrierte Icons \u00fcbernehmen die Textfarbe, skalieren passend zur Umgebung und k\u00f6nnen auf Interaktionen reagieren. Die \u00fcber <code>wp_get_icon()<\/code> gesetzte <code>class<\/code> liefert daf\u00fcr einen CSS-Hook. Im Block-Editor steht dieses Argument nicht zur Verf\u00fcgung; die folgenden SVG- und CSS-Muster funktionieren jedoch \u00fcberall, wo das Icon erscheint.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>currentColor<\/code> statt fester Farben verwenden<\/h3>\n\n\n\n<p>Nutze im SVG <code>stroke=&quot;currentColor&quot;<\/code> oder <code>fill=&quot;currentColor&quot;<\/code>, nicht fest codierte Farben. So verh\u00e4lt sich das SVG wie Text: In rotem Text wird es rot, in einem dunklen Theme dunkel und in einem Link \u00fcbernimmt es die Linkfarbe.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;!-- Nicht verwenden: Das Icon bleibt immer rot. --&gt;\n&lt;svg viewBox=&quot;0 0 24 24&quot; stroke=&quot;#dc2626&quot; stroke-width=&quot;2&quot;&gt;\n    &lt;path d=&quot;...&quot;\/&gt;\n&lt;\/svg&gt;\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#6A737D\">&#x3C;!-- Nicht verwenden: Das Icon bleibt immer rot. --><\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">&#x3C;<\/span><span style=\"color:#85E89D\">svg<\/span><span style=\"color:#B392F0\"> viewBox<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"0 0 24 24\"<\/span><span style=\"color:#B392F0\"> stroke<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"#dc2626\"<\/span><span style=\"color:#B392F0\"> stroke-width<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"2\"<\/span><span style=\"color:#E1E4E8\">><\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    &#x3C;<\/span><span style=\"color:#85E89D\">path<\/span><span style=\"color:#B392F0\"> d<\/span><span style=\"color:#E1E4E8\">=<\/span><span style=\"color:#9ECBFF\">\"...\"<\/span><span style=\"color:#E1E4E8\">\/><\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">&#x3C;\/<\/span><span style=\"color:#85E89D\">svg<\/span><span style=\"color:#E1E4E8\">><\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>SVGs ohne feste Farben passen zu jedem Theme deutlich besser. Wenn ein Marken- oder Status-Icon trotzdem zwingend eine Farbe braucht, setzt du diese \u00fcber CSS auf dem SVG. Da das Icon <code>currentColor<\/code> nutzt, wandert der Wert in <code>stroke<\/code> oder <code>fill<\/code> weiter.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>.featured-icon {\n    color: #f59e0b; \/* Amber, unabh\u00e4ngig von der Textfarbe *\/\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#B392F0\">.featured-icon<\/span><span style=\"color:#E1E4E8\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">    color<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#79B8FF\">#f59e0b<\/span><span style=\"color:#E1E4E8\">; <\/span><span style=\"color:#6A737D\">\/* Amber, unabh\u00e4ngig von der Textfarbe *\/<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Gr\u00f6\u00dfe und Hover-Zust\u00e4nde steuern<\/h3>\n\n\n\n<p>F\u00fcr ein einzelnes Icon setzt du die exakte Pixelgr\u00f6\u00dfe direkt mit <code>size<\/code> in <code>wp_get_icon()<\/code>. Sollen mehrere Icons konsistent aussehen oder auf Hover, Focus, Active und ihren Kontext reagieren, nutze CSS-Klassen am SVG oder an einem umschlie\u00dfenden Element.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>.myplugin-icon-inline svg {\n    transition: transform 0.15s ease-in-out;\n}\n\n.myplugin-icon-inline:hover svg {\n    transform: scale(1.1);\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#B392F0\">.myplugin-icon-inline<\/span><span style=\"color:#85E89D\"> svg<\/span><span style=\"color:#E1E4E8\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">    transition<\/span><span style=\"color:#E1E4E8\">: transform <\/span><span style=\"color:#79B8FF\">0.15<\/span><span style=\"color:#F97583\">s<\/span><span style=\"color:#79B8FF\"> ease-in-out<\/span><span style=\"color:#E1E4E8\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">.myplugin-icon-inline:hover<\/span><span style=\"color:#85E89D\"> svg<\/span><span style=\"color:#E1E4E8\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">    transform<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#79B8FF\">scale<\/span><span style=\"color:#E1E4E8\">(<\/span><span style=\"color:#79B8FF\">1.1<\/span><span style=\"color:#E1E4E8\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Im Shortcode-Beispiel eignen sich <code>size<\/code>-Attribute f\u00fcr kleine Einzelfall-Anpassungen. F\u00fcr ein einheitliches Erscheinungsbild auf der gesamten Website setzt du Regeln auf <code>.myplugin-icon-inline svg<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6. Icons und Collections wieder entfernen<\/h2>\n\n\n\n<p>WordPress 7.1 stellt passende Funktionen bereit, um einzelne Icons oder eine komplette Collection zu entfernen. Das ist w\u00e4hrend der Entwicklung n\u00fctzlich oder wenn ein Plugin-Update ein Icon aus dem Sortiment nimmt.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Ein einzelnes Icon entfernen<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>wp_unregister_icon( 'myplugin\/bookmark' );\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#B392F0\">wp_unregister_icon<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'myplugin\/bookmark'<\/span><span style=\"color:#E1E4E8\"> );<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Beim n\u00e4chsten Request verschwindet das Icon aus dem Picker. Bereits gespeicherte <code>core\/icon<\/code>-Bl\u00f6cke, die dieses Icon enthalten, rendert WordPress dann leer; der Inhalt bestehender Beitr\u00e4ge wird nicht umgeschrieben.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Beim Deaktivieren die ganze Collection entfernen<\/h3>\n\n\n\n<p>Deaktivierst du das Plugin, sollten seine Icons nicht mehr im Picker auftauchen. <code>wp_unregister_icon_collection()<\/code> entfernt alle enthaltenen Icons in einem Aufruf; du musst nicht \u00fcber jedes einzelne Icon iterieren.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>register_deactivation_hook( __FILE__, 'myplugin_unregister_icons' );\n\nfunction myplugin_unregister_icons() {\n    wp_unregister_icon_collection( 'myplugin' );\n}\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#B392F0\">register_deactivation_hook<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#79B8FF\">__FILE__<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#9ECBFF\">'myplugin_unregister_icons'<\/span><span style=\"color:#E1E4E8\"> );<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">function<\/span><span style=\"color:#B392F0\"> myplugin_unregister_icons<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">    wp_unregister_icon_collection<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'myplugin'<\/span><span style=\"color:#E1E4E8\"> );<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">H\u00e4ufige Fragen zur Custom-Icons-API<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Muss die Collection vor den Icons registriert werden?<\/h3>\n\n\n\n<p>Ja. Icons ben\u00f6tigen eine vorhandene Collection, sonst erscheinen sie nicht im Picker. Registriere die Collection auf <code>init<\/code> mit der Standard-Priorit\u00e4t und die Icons danach, etwa mit Priorit\u00e4t <code>20<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Darf eine Collection <code>content<\/code>&#8211; und <code>file_path<\/code>-Icons mischen?<\/h3>\n\n\n\n<p>Ja. Jeder Aufruf von <code>wp_register_icon()<\/code> ist unabh\u00e4ngig. Verwende <code>content<\/code> f\u00fcr ein oder zwei Icons und <code>file_path<\/code> f\u00fcr die \u00fcbrigen. Nach der Registrierung behandelt WordPress beide Varianten gleich.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Funktionieren Custom Icons als Block-Icons in <code>register_block_type()<\/code>?<\/h3>\n\n\n\n<p>Ja. \u00dcbergib dem Schl\u00fcssel <code>icon<\/code> den registrierten Namen wie <code>'myplugin\/star'<\/code>. Der Block-Inserter zeigt dann das eigene SVG statt eines Dashicons \u2013 sowohl f\u00fcr JavaScript-registrierte als auch f\u00fcr reine PHP-Bl\u00f6cke.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Liefert <code>wp_get_icon()<\/code> HTML oder einen String?<\/h3>\n\n\n\n<p>Die Funktion gibt das SVG als String zur\u00fcck. Du kannst den Wert direkt mit <code>echo<\/code> ausgeben oder in eigenen HTML-Markup einschlie\u00dfen. Das zweite Array <code>$args<\/code> akzeptiert <code>size<\/code>, <code>class<\/code>, <code>label<\/code> f\u00fcr <code>aria-label<\/code> und <code>title<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Welche SVG-Attribute solltest du vor der Registrierung entfernen?<\/h3>\n\n\n\n<p>Entferne fest codierte <code>fill<\/code>&#8211; und <code>stroke<\/code>-Farben, <code>width<\/code> und <code>height<\/code> am root-<code>&lt;svg&gt;<\/code> sowie alle <code>&lt;style&gt;<\/code>-Bl\u00f6cke und Scripts. Behalte <code>viewBox<\/code> und strukturelle Attribute. Verwende <code>currentColor<\/code> f\u00fcr Farbangaben.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Kannst du Icons in einem Theme statt in einem Plugin registrieren?<\/h3>\n\n\n\n<p>Ja. Derselbe Aufruf von <code>wp_register_icon()<\/code> funktioniert in der <code>functions.php<\/code> eines Themes; f\u00fcr den Dateipfad verwendest du <code>get_stylesheet_directory()<\/code>. Beachte jedoch den Nachteil: Wechselst du das Theme, verschwinden auch dessen registrierte Icons.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Was passiert bei gleichem Icon-Namen in zwei Collections?<\/h3>\n\n\n\n<p>Collections bilden Namespaces. <code>myplugin\/heart<\/code> und <code>anotherplugin\/heart<\/code> k\u00f6nnen deshalb ohne Konflikt nebeneinander existieren. Erst der vollst\u00e4ndige Name inklusive Collection-Pr\u00e4fix ist eindeutig.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Bereinigt WordPress SVGs bei der Registrierung?<\/h3>\n\n\n\n<p>Nein. WordPress ver\u00e4ndert beim Registrieren weder den String in <code>content<\/code> noch den Inhalt einer Datei aus <code>file_path<\/code>. Bereinige SVGs vor dem Ausliefern selbst und entferne Scripts, externe Referenzen sowie alles Unn\u00f6tige.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">N\u00e4chste Schritte<\/h2>\n\n\n\n<p>Registriere zuerst deine Collection, w\u00e4hle anschlie\u00dfend pro Icon <code>content<\/code> oder <code>file_path<\/code> und verwende f\u00fcr gr\u00f6\u00dfere Sammlungen die <code>glob()<\/code>-Variante. Setze in deinen SVGs <code>currentColor<\/code>, damit sie sich in Themes, Links und Textfarben einf\u00fcgen. Danach kannst du dieselbe Registrierung ohne zus\u00e4tzlichen Build-Schritt im Editor, in PHP-Templates, \u00fcber REST und als Block-Symbol nutzen.<\/p>\n\n\n<div class=\"references-section\">\n                <h2>Referenzen \/ Quellen<\/h2>\n                <ul class=\"references-list\"><li><a href=\"https:\/\/wpvibes.com\/blog\/wordpress-custom-icons\/\" target=\"_blank\" rel=\"noopener noreferrer\">Custom SVG Icons: An Exciting WordPress 7.1 Feature<\/a><\/li><\/ul>\n            <\/div>","protected":false},"excerpt":{"rendered":"<p>Mit WordPress 7.1 registrierst du eigene SVG-Icons ohne JavaScript-Build-Schritt. So erscheinen sie im Block-Editor, in PHP-Templates, per REST-API und als Block-Icons.<\/p>\n","protected":false},"author":11,"featured_media":265,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[126,28,136,64,134],"class_list":["post-268","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","tag-block-editor","tag-php","tag-plugin-entwicklung","tag-svg","tag-wordpress-7-1"],"_links":{"self":[{"href":"https:\/\/helloblog.io\/de\/wp-json\/wp\/v2\/posts\/268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/helloblog.io\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/helloblog.io\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/helloblog.io\/de\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/helloblog.io\/de\/wp-json\/wp\/v2\/comments?post=268"}],"version-history":[{"count":0,"href":"https:\/\/helloblog.io\/de\/wp-json\/wp\/v2\/posts\/268\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/helloblog.io\/de\/wp-json\/wp\/v2\/media\/265"}],"wp:attachment":[{"href":"https:\/\/helloblog.io\/de\/wp-json\/wp\/v2\/media?parent=268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/helloblog.io\/de\/wp-json\/wp\/v2\/categories?post=268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/helloblog.io\/de\/wp-json\/wp\/v2\/tags?post=268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}