After adding my website to a new server, I keep getting a unexpected end of file error, but the file is identitcal to it’s original source

So the issue has already been resolved via the comments and the current state of the question already includes the corrected code. But I thought I should post this answer as a reminder for you, me and everyone reading this. 🙂 So first off, here’s a helpful excerpt from an article on WP Engine: The … Read more

get_template_directory_uri() generates wrong path

Do your URL change up in phpMyAdmin with SQL language: # Change website url UPDATE wp_options SET option_value = replace(option_value, ‘http://www.old-site.com’,’http://www.new-site.com’) WHERE option_name=”home” OR option_name=”siteurl”; # Change GUID URL UPDATE wp_posts SET guid = REPLACE (guid, ‘http://www.old-site.com’,’http://www.new-site.com’); # Change url of medias, post, page, etc. UPDATE wp_posts SET post_content = REPLACE (post_content, ‘http://www.old-site.com’,’http://www.new-site.com’); # Change … 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

Disable Cloudflare Rocket Loader for jQuery javascript and make it load first

jQuery is loaded by WordPress with wp_enqueue_script. The problem is WordPress also use the below code to change the handle public function localize( $handle, $object_name, $l10n ) { if ( ‘jquery’ === $handle ) { $handle=”jquery-core”; } The solution is to use the function function wpse_script_loader_tag( $tag, $handle ) { if ( ‘jquery-core’ !== $handle … 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

How to use wordpress function wp_enqueue_script() in php?

I am wondering if that is the right way to use wp_enqueue_script() function in php. Do I need to place wp_enqueue_script() somewhere else ? Not really, here’s what the official docs say in the notes: https://developer.wordpress.org/reference/functions/wp_enqueue_script/ The function should be called using the wp_enqueue_scripts action hook if you want to call it on the front-end … Read more