Enable CORS for getting an inline SVG by URL

By using custom rewrite_url, I was able to hijack the request and set its CORS-friendly headers. class Cors_Media { const QUERY_VAR = ‘cors_media_id’; public function init() { add_action(‘init’, [$this, ‘add_rewrite_rule’]); add_filter(‘query_vars’, [$this, ‘query_vars’]); add_action(‘template_redirect’, [$this, ‘template_redirect’]); } public function query_vars(array $qs) { $qs[] = ‘cors_media_id’; return $qs; } public function add_rewrite_rule() { add_rewrite_rule( ‘^cors_media_id/([0-9]+)/?’, ‘index.php?cors_media_id=$matches[1]’, … Read more

import svg-files from wxr – (upload works, import not)

Found my solution after a little more digging. The problem lies in wordpress-importer Found this from jan 30 on github: https://github.com/WordPress/wordpress-importer/issues/47?_pjax=%23js-repo-pjax-container Then later the solution here: https://www.playnicetogether.com/2015/11/07/wordpress-importer-plugin-content-length-problem-solved/ “the WordPress Importer plugin is not compatible with remote servers that use HTTP compression.” For WordPress v4.6 and above, please use the following: add_filter( ‘http_request_args’, function( $r, $url … Read more

Expected an identifier and instead saw ‘

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 … Read more

WordPress Block.js SVG createElement

Basically, when using wp.element.createElement(), For attribute names having special characters like a hypen/-, the name should be put in single/double quotes: e.g. ‘data-name’ and not simply data-name. createElement( ‘svg’, { ‘data-name’: ‘Layer 1’ // like this data-name: ‘Layer 1’ // not this } ); The same also goes to attribute names like class which is … Read more

Swap SVG icons in child themes

I see that both icon arrays ($ui_icons and $social_icons) in Twenty Nineteen can be accessed publicly, so I managed to replace any icon via the init hook in a child theme. An example: function child_init() { TwentyNineteen_SVG_Icons::$social_icons[‘instagram’] = ‘<svg>… Insert new Instagram icon SVG code here …</svg>’; } add_action( ‘init’, ‘child_init’ );