WordPress internal functions : why not use them?

Internal/private functions (their names are prefixed with an underscore) can be subject to changes without a warning and break backward compatibility unlike the public functions in general. This makes the core developement move faster being able to change part of the code without having to take deprecation steps over multiple versions of core. Many internal … Read more

Display related posts randomly that match “any” existing tags?

Some of the code in OP is a bit old and depreciated, like caller_get_posts which was depreciated years ago. The correct parameter to use now is ignore_sticky_posts. Your query is also really inefficient and not good for performance. Here is how I would tackle this issue Use get_queried_object_id() to get the current post ID instead … Read more

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