Javascript localization doesn’t load. How to Internationalize javascript without plugin?

Good News after 2 days! I resolved my issue, but I believe that wp i18n make-json does not generate the json file correctly. Why? Because it uses the ISO codes and not the locale (get_locale()) from the browser/user. So it isn’t “en_GB” that should be used but “en” in the .json file. This : “locale_data”: … Read more

Setting “Open in New Tab” for Link Control to be checked by default

You have to watch editor changes, you can hook the js to ‘enqueue_block_editor_assets’. your-child-theme/js/default-open-in-new-tab.js wp.domReady(() => { //console.log(“Custom script loaded”); const { subscribe } = wp.data; //we want to subscribe to changes of the editor // Helper function to determine if a URL is external const isExternalLink = (url) => { try { const domain … Read more

How do I display a PDF thumbnail as a link to the PDF without uploading the image

The PDF images created by wordpress are stored within the PDF attachment object metadata. [ { “id”: 121, “media_type”: “file”, “mime_type”: “application/pdf”, … “media_details”: { “sizes”: { “full”: { … “source_url”: “<domain>/wp-content/uploads/document-name-pdf.jpg” } } ] Extracting the image from the PDF Adding an image block or adding a featured image to a post requires an … Read more

Copy all media from one WordPress site to another

I understand your hesitation to use a plugin that doesn’t have granular options to avoid overwriting existing content when what you’re actually doing is a merge more than a restore. You could simply use phpMyAdmin perform a search & replace on the incorrect links via a SQL query. I’d suggest cloning what you have now … Read more

Webpack configuration for multiblock plugins behaves unexpectedly

Okay I found a quick and dirty solution for the viewScript. My webpack.config.js: /** * `@wordpress/scripts` path-based name multi-block Webpack configuration. * @see https://wordpress.stackexchange.com/questions/390282 */ // Native Depedencies. const path = require(“path”); // Third-Party Dependencies. const CopyPlugin = require(“copy-webpack-plugin”); const config = require(“@wordpress/scripts/config/webpack.config.js”); /** * Resolve a series of path parts relative to `./src`. * … Read more