Return ‘X-WP-Total’ from headers in response

Ideally, you can access those headers with response.header, but not all headers are available publicly unless exposed manually. In your case, to access X-WP-Total by the client, you need to set the Access-Control-Expose-Headers header on your server: Access-Control-Expose-Headers: X-WP-Total

Install GTM in pure javascript through functions.php

The problem is that your code is inside the <head> element, but the code is trying to access document.body which won’t exist at the time that your script is run. If I recall correctly you’re supposed to place this code immediately after the opening <body> tag. To do this from functions.php your theme needs to … Read more

How to inherit custom javascript from parent to child pages?

Just define the function in its own separate JS file, and load that file alongside the page-specific files. The “WordPress way” would be to register the script containing the shared function(s) and then set it as a dependency of the other scripts: wp_register_script( ‘my-functions’, get_theme_file_uri( ‘js/functions.js’ ) ); if ( is_page( 1 ) ) { … Read more

Malware gdjfgjfgj235f [closed]

YOu need to do a full cleanup of your site, including changing all credentials (hosting, FTP, admin users) updating everything (WP, themes, plugins); perhaps even installing via FTP check every file for inserted code: index.php, wp-settings.php, wp-config.php change credentials on the database (strong passwords!) look at htaccess file, and any hidden files. My procedure is … Read more

Suddenly extra hex string in tags

It was Cloudflare Rocket Loader option which caused this. I disabled Rocket Loader and it has gone. Edit: In the Cloudflare support page is this very clear note and it explains all: So, before I validate the page I disable it in order to avoid useless warnings and then I turn it on again.

Gutenberg dependencies in package.json

Yes and no, it depends… The WP Scripts package depends on the @wordpress/dependency-extraction-webpack-plugin package at: https://github.com/WordPress/gutenberg/tree/master/packages/dependency-extraction-webpack-plugin What this will do is search for packages from @wordpress and list them in a file to make it easy for you to load the list of dependencies when enqueuing. It also adjusts webpack so that it knows not … Read more

Why WordPress not using JSON_UNESCAPED_UNICODE by default?

Because until relatively recently WordPress supported PHP 5.2+, but that constant was only added in PHP 5.4. Given that wp_json_encode is meant to encapsulate and account for the differing behaviour of json_encode across multiple PHP versions, it doesn’t make sense to deliberatly change its behaviour for PHP 5.4+ Now that WordPress has raised its minimum … Read more