Gutenberg and Markdown

I’ve been playing around with Gutenberg a tiny bit recently and have realized that, at least in my case, it kind of eats the Jetpack Markdown module and doesn’t offer full markdown support.


I honestly know nothing about writing blocks for Gutenberg, but luckily GitHub user nuzzio does :)

This recent, but now closed PR to Jetpack was pretty much everything necessary to build a working block.

I’ve put my code up on GitHub as a WordPress plugin:



Like I said, I don’t know what I’m doing–so consider this plugin super beta.

Disabling plugin deactivation in WordPress

The problem came up recently about how to make sure plugins activated in the WordPress plugin UI don’t get deactivated if they are necessary for a site to function.  I thought that was an interesting thought puzzle worth spending 15 minutes on, so I came up with this function as a solution:

function dt_force_plugin_active( $plugin ) {
	add_filter( 'pre_update_option_active_plugins', function ( $active_plugins ) use ( $plugin ) {
		// Match if properly named: wp-plugin (wp-plugin/wp-plugin.php).
		$proper_plugin_name = $plugin . '/' . $plugin . '.php';

		if (
			file_exists( WP_PLUGIN_DIR . '/' . $proper_plugin_name )
			&& is_file( WP_PLUGIN_DIR . '/' . $proper_plugin_name )
			&& ! in_array( $proper_plugin_name, $active_plugins, true )
		) {
			$active_plugins[] = $proper_plugin_name;
			return array_unique( $active_plugins );

		// Match if improperly named: wp-plugin/cool-plugin.php.
		if (
			file_exists( WP_PLUGIN_DIR . '/' . $plugin )
			&& is_file( WP_PLUGIN_DIR . '/' . $plugin )
			&& ! in_array( $plugin, $active_plugins, true )
		) {
			$active_plugins[] = $plugin;
			return array_unique( $active_plugins );

		return array_unique( $active_plugins );
	}, 1000, 1 );

Which can be activated in your theme’s functions.php like so:

dt_force_plugin_active( 'akismet' ); or dt_force_plugin_active( 'wordpress-seo/wp-seo.php' );

The only downside that I’ve seen so far is that you still get the Plugin deactivated. message in the admin notices.

iPhone – Day 6

So recently I’ve been hard on the iPhone, with lots of complaints.  Truthfully, there are a lot of things that it’s doing right and I really like, such as:

  • Speed.  OMG it’s so fast and smooth!
  • Camera.  Slo-Mo, 4K, HDR, 60fps, and amazing speed and quality.
  • The app experience is much nicer.  Overall apps are higher quality and less buggy.  The sad part is this includes Google’s apps.  Gmail on the iPhone is very nice, with some cool features, for example.
  • Accessories.  With a single hardware design, accessories are normalized and very cheap and easy to find.
  • Apple Pay.  Finally, I can use an NFC payment system again, after Google deprecated Wallet with NFC.
  • Night Mode.  The Google giveth, and the Google taketh away.  I used to have Night Mode on my Nexus 6, but Google decided to remove it during an “update.”

I’m not saying that I’m in love yet.  There are still some big issues.  Somehow I turned off the sound for my text messages–still trying to figure out how to fix it :/

Auto-Upgrading users in WordPress

I made a small site recently where I wanted all newly registered users from a specific email domain to automatically be administrators (this is a terrible idea, don’t do it).  The user registration was restricted by Single-Sign-On and 2-Factor Authentication, so I felt relatively safe doing this, especially since it was only a “for fun” project.

The interesting bit of code that upgraded users to admins is as follows:


add_action( 'user_register', 'upgrade_email_to_admin', 10, 1 );
function upgrade_email_to_admin( $user_id ) {
	$user = get_user_by( 'ID', $user_id );
	if ( false !== $user ) {
		$email = $user->data->user_email;

		// Only please.
		if ( false === strpos( $email, '' ) ) {

		$roles = $user->roles;

		if ( ! in_array( 'administrator', $roles, true ) ) {
			$user_update = array();
			$user_update['ID'] = $user_id;
			$user_update['role'] = 'administrator';
			wp_update_user( $user_update );

This is 100% insecure, please do not do this :)

iPhone – Day 4

The big issue I’m having with iOS right now is the notification system.  I feel like I’ve stepped back in time years.  For a while now Android has had the ability to group similar notifications for an app.  This makes organizing and clearing notifications very easy.

android grouped notifications.jpg
via Lifehacker

Compare this to iOS where the notifications are all separate:


Along with this difference, clearing notifications takes more interactions.  You either have to swipe left and tap, or swipe left twice.  With Android, it’s one simple swipe and all of those unwanted notifications for a single app are gone.


I know this sounds like a silly detail to complain about, but there’s just so much more about the Android notification experience.  Many of the notifications are “rich” and provide more details when swiped down, such as image previews, more details, or the ability to reply to messages inline without opening an app.

It may be that iOS has these features as well, and I just don’t know how to use them since these features came to me organically on Android as they were added over the years.  Because of that, I won’t hold it against iOS too much, but it’s still points taken away.

iPhone – Dawn of The First Day

The first thing that I’ve learned during my transition to iOS is that the mobile keyboard experience is very subpar compared to Android. The stock iOS keyboard is bad, but even using a third party keyboard like Gboard doesn’t even come close to the experience on Android. The layout requires so many more taps to do simple things like numbers and punctuation.

Secondly, the down firing speakers of the iPhone 6s+ are absolutely terrible for consuming media–at least compared to the Nexus 6 and it’s stereo front firing speakers. Trying to watch a video on YouTube, I found myself having to hold the iPhone in an uncomfortable position to get even mediocre sound.

Now, that’s not to say that it’s all bad. The speed of this old iPhone, compared to my Nexus 6 is blazingly fast. All of the OS transitions are buttery smooth, there is absolutely no lag to be seen, and the camera can take pictures faster than I can tap!

The iOS experience doesn’t seem to be created for one-handed use, since I constantly have to stretch far to the top of the screen or exit lazy mode and get my second hand out to tap something at the top. Android’s bottom navigation bar is definitely a better user experience.

iPhone – The Prequel

Photo by Shritwod / CC-BY-SA

I have been a die-hard Android user since the Motorola Droid (OG Droid) came out in October 2007.  The Apple iOS software world has always felt too restrictive for me, since I am forever a tinkerer.

My current phone is a Google Nexus 6 developed by Motorola, released in November 2014.  Unfortunately, it’s showing its age.  Google no longer sends OTA updates, so I rely on LineageOS to keep me safe and happy.  Even with third-party software, the phone is plagued with problems.  From incredibly slow encryption to poor CPU throttling when the battery gets low.  The camera is also disgustingly slow, taking between 5-30 seconds to take and process a single picture, but at least the resulting images are beautiful.

Photo by / CC-BY

There are saving graces though, such as the dual front-facing stereo speakers, amazing 6.0 inch 1440×2560 AMOLED screen, optical image stabilization, HDR, Qi wireless charging, and headphone jack :)

Unfortunately, it’s time to put my Nexus 6 aside and find a new phone.  My wife has been using an iPhone for years now, after switching from Android (2014 Moto X).  Today she got a new iPhone 8+, so we’ve come to an agreement that I need to at least try to use iOS for a while.

So tonight, after she migrated all of her apps and data to the new iPhone, I spent some time setting up all of my apps and accounts on her old iPhone 6s+.  It’s already been a very alien experience, almost frightening–seeing how little I actually know about the software and hardware.

My plan is to use the iPhone for at least two weeks, and see how I feel about it.  This also coincides closely with the release of the new Google Pixel 2 phones, which I will also be looking at.  Last year I was very underwhelmed by the Google Pixel line, and felt that the hardware of the iPhone 7+ was much more advanced.  If I’m able to thrive, or at least survive, in iOS then perhaps it’s time for me to truly look at switching platforms.

I’m hoping to write about this experience every day or two so that I force myself to look back at how my transition is going.  I’m sure there will be many frustrations early on, but hopefully I’ll also have a good number of exciting moments when I get to experience some new and exciting software.

Logging Post Status Transitions in WordPress

Last week an interesting issue came up for a client. Somehow a few posts were moved from Published to Draft. Unfortunately, post status isn’t stored in revisions so it’s unlikely we’ll ever know who or how it happened. Luckily there’s a simple solution I found to log all post status transitions in post meta:

add_action( 'transition_post_status', 'log_post_transition', 10, 3 );
function log_post_transition( $new_status, $old_status, $post ) {
	if ( 'post' === $post->post_type ) {
		$current_user = wp_get_current_user();
		add_post_meta( $post->ID, '_post_status_log', sprintf( '%s %d, %s->%s', current_time( 'mysql' ), $current_user->ID, $old_status, $new_status ), false );