Muschamp Rd

New Year, New WordPress

January 10th, 2019
WordPress Upgrade Success

It has been over two years since I did a major upgrade to this WordPress blog. I managed to keep it online through a lot of trials and tribulations and although my job search is my number one priority and I bought my ticket back to Canada, I will be in China until the end of the month for “reasons” so putting off fixing all the flaws in this blog is not something I will be putting off anymore.

I still do not think the ROI for blogging has been worth it but I’m hopeful I can leverage this blog and social media more in my job search. And I’m definitely planning on improving my IT skills so Python is on the backburner as debugging PHP and JavaScript as well as even less savoury topics like .htaccess and mod_rewrite have become a necessity. I actually spent a lot of time working on my style.css file, I’m old school that way in using HTML and CSS over JavaScript to solve problems.

Before Upgrading WordPress

I finally removed Mint and I made my homepage run faster but this blog is a bigger beast with a lot of old code that needs upgrading or completely replacing. My next step will be getting rid of years of revisions to blog posts and cleaning up my MySQL database even further. Then I will take the plunge and upgrade to WordPress 5.something. Before I do that I will make a backup, maybe even two backups, one of the database and you can also export your posts as XML.

Before WP-Sweep

I used WP-Sweep to remove old blog post revisions of which there were a lot. This reduced the size of my MySQL database by 51 MB apparently. I never did a backup before I removed Mint because I didn’t want that data back, most of it is duplicated in Google Analytics.

Upgrading to WordPress 5.0.2 went really smoothly. My website is noticeably faster with all the plugins turned off and my call in functions.php to ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js commented out. I’m not sure what plugin required that, but considering how slow my blog was running from inside China as 2018 ended, some plugins are definitely no longer welcome on Muskblog.

Formerly Active Plugins

  • Blog Metrics
  • Bulk Delete
  • Disqus
  • Featured Images in RSS w/Size & Position
  • Google Analytics for WordPress
  • Google XML Site Maps
  • HeadSpace2
  • JetPack
  • Not-to-me
  • Ozh’ Spam Magnet Checker
  • Recent Post Widget with Thumbnails
  • Regenerate Thumbnails
  • Simple Tags
  • Simple Trackback Validation
  • WPtouch
  • WP-Sweep
  • YARPP

Sitting installed but inactive were the following plugins:

  • Dump Environment
  • Simple Random Quotation
  • Site Unavailable
  • User Spam Remover

WordPress 5.0.2 Successfully Installed

Minimal WordPress Plugins

The first thing I’m going to add back is likely Google Analytics, since I already left a plain Jane comment on a post. Many of these plugins may never be reactivated after how slow my blog got from inside China. I’m going to watch to see which ones hit against blocked services very carefully.

How my comments look with WP-TouchI added back the following plugins in the following order and only one gave me any grief at all. My website is running so much faster, but I fear the spam and brute force attacks will hit soon. I’m going to leave it running with just these six plugins for a few hours and work on the upgrade more in the morning.

  1. Google Analytics for WordPress
  2. Blog Metrics
  3. Ozh’ Spam Magnet Checker
  4. YARPP
  5. Recent Post Widget with Thumbnail
  6. WPtouch

With just those six plugins I got the dreaded deluge of spam, so I adjusted some options, then I added Akismet and still I get spam. I think I will be disabling trackbacks and pingbacks or at least not showing them. Years ago when I put this blog online I thought they were pretty cool, but now they just abused by spammers and for old posts they make the comment section look weird. Many advise removing them from your blog. I also will need to style my comments better, WP Touch did a much nicer job.

Here Be Spam

Here are some tutorials I used to improve how comments look on my blog, I think I was still doing things the WordPress 1.0 or 2.0 way.

I never quite got threaded comments to work, though I did make my existing threaded comments look better. I also discovered some duplicate comments, so cleaning that up is also going on my “to do” list but I want to get this post finished which means I must push on with slightly wonky comments at the moment. I did create two threads on StackExchange however:

  1. How best to check if a user is from China and hide content?
  2. Why are my threaded comments not quite working?

I finally got threaded commenting working, the answer was a line of code in header.php and a few other changes to comments.php as detailed by Ottodestruct. Apparently my theme was never completely updated after WordPress 2.7 as I was likely running Disqus or some other plugin and never tested threaded comments just that I could leave a comment with all plugins turned off.

Replacing WordPress Plugins

I then started replacing plugins, the first to go was HeadSpace2 which has not been updated in six years apparently. I used it to add exactly one metatag. It will be replaced by Yoast SEO. That is another big plugin which is actively under development and should preserve my data. The other two plugins which are on the way out are JetPack and Disqus. JetPack is just too big in my opinion and seems to do a lot in my wp_header and wp_footer. It has two main features I am using: metatags for Facebook and Twitter and the social sharing buttons. It does more and it might be fighting spam and malicious login attempts too, but supposedly upgrading WordPress will help with security and speed.

You can spend a lot of time following search engine optimization advice from Yoast and others. I really, really want to get this post published before the end of 2019.

209 bad internal linksUpdate: I’m not sure if it is a big issue in SEO anymore but in the olden days having busted links on your homepage was considered a negative signal as far as quality, but as the web has gotten bigger and personal homepages have gotten bigger, regularly running a link checker on your content has gone the way of the dodo. Domain squatters pass the automated link checkers, but they can be a much bigger problem to your search engine optimization efforts than a busted link. As part of my new year, new WordPress upgrade I fixed 100s of bad links, most of them were pingbacks making them even less desirable in my eyes. I also discovered more duplicate comments, after thinking I’d deleted them all before I got around to checking links.

Disqus seems to have become blocked in China. It adds another Twitter and Facebook button and it does miscellaneous unwanted tracking, it will even advertise on my site, if I let it. It definitely slows my whole blog down in China and hardly anyone comments on what I post. My fear like removing JetPack is suddenly a host of spammers will descend on me, but again WordPress out of the box has more resiliency and features than it did originally.

I really want my blog to run better in China so people who are still in China or who travel to China can make use of it. I can’t unblock Instagram or Pinterest so images embedded from Flickr or self-hosted images are clearly the way to go. I will hide or remove as much social media and calls to blocked services as I can. JetPack does not give me a way to hide the social media buttons from Chinese web surfers so I may add them to my post the old fashion way assuming Yoast SEO will take care of the metadata. I could even try getting Professional Share to work again but it didn’t support Pinterest and I believe conflicted with WPtouch which although very JavaScript heavy, seems to function in China well.

More Blogging Difficulties

This was a long and thorough upgrade and while deleting duplicate comments by hand I discovered my website slowing way down and seeing as speed was the reason behind this upgrade I viewed source and discovered something is inserting a coinhive mining script. Is this in the WordPress source, a plugin on this list, is it from public WiFi in China, needless to say I’m going to try and find out.

How did this get into my blog or browser?

I haven’t seen this injection attack again so this was likely caused by being on public WiFi in China. I was in a cafe where I’ve spent too much time studying and looking for a new job. The cafe in question was a Wagas near Dashijie metro station, so beware using public WiFi in China as if that truly needed stating. Update: I caught them again inserting this mining script while I was debugging my blog theme in their cafe.

Beware the WiFi at Wagas is inserting Coinhive mining scripts into your browser

Improving my WordPress Theme

There are still at least two outstanding issues I haven’t fixed plus I need to tweak and debug the CSS more, but this post has got to be published. Yoast SEO doesn’t seem to think it is particularly well written and I’m not looking forward to going through old blog posts and improving them to make a plugin happy, but at least the metadata and sitemaps seem to be working. I decided on a sitemap for categories but not for tags. I did include a tag cloud when you look at a tag archive but I did not use a plugin. This blog was much leaner and meaner until I discovered the Coinhive issue.

Update: Apparently I know how to code a webpage so that it loads fast, WordPress along with gee-whiz plugins are slower. I will continue to optimize including finally trying a caching plugin, that might be enough. The other things I can do for speed is get rid of YARPP, which I’ve discovered has been removed from the WordPress.org repository. It was a lot of effort to get good related posts to work and look good on my blog. I’m not sure what to do with this new tidbit of information. There are alternatives and there is data that shows JetPack is quicker I already had to add back Akismet maybe I have to go back to using JetPack.

Google thinks my homepage is fast

The recent post plugin could also go, but again I think that is a good feature for end users as is WPtouch, switching to a new mobile friendly theme is the ultimate major overhaul replacing all the static HTML and PHP pages. I still do not have social media buttons, but they may return, further changes to my comments such as removing pingbacks may help with speed as well. I also think I can update my plugins and clean my database further.

Google thinks my blog is less fast

Google provides a lot more tools than they used to for developers and browsers also provide developer tools now. I’ve updated websites using the most primitive of toolsets so it isn’t a surprise that my hand-coded content runs quicker than a modern content management systems, but if you have a lot of content or plan to produce more and more content you need some sort of CMS.

Search Engine Optimization Efforts

I made a long advocated change to my WordPress theme changing single.php to use H1 for the blog post title. On a category archive I was using H1, H2, and H3 logically. This necessitated a lot of trial and error changes to my style.css file and the adding of a single break tag as I could not quite get it to work just using CSS. I may switch to a clear div and I’ve moved breadcrumbs to header.php but I also seem to have introduced a bug into my pager styling. I’ve also updated and optimized a lot of text in older blog posts strategically. Replacing YARPP with the Yuzo Related Post plugin is still to come.

While updating this post on January 24th I discovered Bing has now been blocked in China, this pretty much leaves Baidu as the only major search engine besides Yandex. Most everyone has a VPN but they are not reliable and Baidu does not return much useful information for the searches I conducted today. The Chinese Communist Party must really want to drive expats, sea turtles and foreign businesses from China. I can’t see how this helps their trade war or Huawei is innocent arguments. Yandex works better than Baidu for English searches from inside China.

Update: I started writing my first new post in WordPress 5, this post was started in a previous version of WordPress and did not use the new editor. I’m not sure how having to click a button every time I want to add a new paragraph is faster than just hitting the “return key”. Same goes if you want to add an image or anything else you must first add a “block”. I also turned off YARPP but what I really want to get rid of are self-pingbacks. I’ve been interlinking my blog for over a decade and on some posts there are a lot. There appears to be a way to do this built into wp_list_comments(), just set ‘type’=>’comment’.

In WPtouch they do not show up by default, but in both cases are included in the count of total comments. They are nofollow’ed by default anyway, the time of pingbacks and trackbacks has passed, it is all about social sharing and I don’t have any of those buttons at the moment for speed. Most people know how to share on their phone and computer by now. WPtouch really controls the speed of my blog on mobile, updating to the latest version helped, turning off YARPP didn’t make much of a difference to mobile page speed according to Google, but it must be replaced due to being widely banned. However, I’ve been spending the majority of my time tweaking my CSS and updating old posts to be “better”. Alas I turned on some new features in WPtouch too, if I removed the slider and social media I could probably get it to run quicker, but I have already selected my new five pieces of cornerstone content.

I encountered difficulties floating a tall skinny image to the right of my text in Gutenberg something I had adopted doing as they share best in Pinterest. I searched the Internet but eventually created another StackExchange question for this problem. Although my latest greatest post about China clearly was not quite ready for prime time and I obviously need to upgrade my theme more, I need to publish so people could see the HTML in the wild and try to figure out what CSS rule or whatever is my problem. I’d already spent hours debugging it.

If you have thoughts, fixes, insights, tips, or snide comments please leave them below. Social sharing buttons may make a return but not right away. I think this mining script being injected into my blog is a much bigger problem.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Posts on Muskblog © Andrew "Muskie" McKay.
CFA Institute does not endorse, promote or warrant the accuracy or quality of Muskblog. CFA® and Chartered Financial Analyst® are registered trademarks owned by CFA Institute.