Doing Things Wrong

Fixing WordPress' Back-End etc

WordPress' back-end administration interface is like a machine gun aimed at your foot. There are so many things that work badly, or create a giant mess behind your back. Here is a code snippet that you can put in your functions.php to disable some of the worst of WordPress' "features":

function override_admin_bar_css() {
?>

<style type="text/css">

/* override_admin_bar_css() */

/* disable stupid admin options */

#wpadminbar li#wp-admin-bar-wp-logo,
#wpadminbar li#wp-admin-bar-new-media,
#wpadminbar li#wp-admin-bar-dashboard,
#wpadminbar li#wp-admin-bar-view-site,
#wpadminbar li#wp-admin-bar-customize,
#wpadminbar li#wp-admin-bar-new-user,
#wpadminbar li#wp-admin-bar-themes,
#wpadminbar li#wp-admin-bar-widgets,
#wpadminbar li#wp-admin-bar-menus,
#wpadminbar li#wp-admin-bar-edit-profile,
#wpadminbar li#wp-admin-bar-user-info,
#wpadminbar li#wp-admin-bar-search,
.hide-if-no-customize,

/* disable image nonsense */

.attachment-actions .edit-attachment,
table.media div.row-actions span.edit,
table.media div.row-actions span.view,
table.media div.actions a.view-attachment,

/* disable 'Add to Any' plugin options */

#A2A_SHARE_SAVE_meta,
#A2A_SHARE_SAVE_meta button,

/* disable featured images */

.editor-post-featured-image__toggle,
.edit-post-last-revision__panel

{ display:none; !important }

</style>

<?php
}

if( get_option( 'simplify_interface' ) ) {	
	add_action( 'admin_head', 'simple_override_admin_bar_css' );
	add_action( 'wp_head', 'simple_override_admin_bar_css' );
	add_action( 'admin_head-media-upload-popup', 'simple_override_admin_bar_css' );
	}

What this does is insert css to hide buttons and links for all sorts of bad or simply useless options, like image editing. My goal is to make WordPress less of a minefield for users that are less adept. But I really like the streamlined interface myself, and use it most of the time. I can turn it on and off with the 'simplify_interface' option in a custom admin panel.

Note that all the WordPress crap is not actually disabled, it is merely hidden. Actually disabling parts of the system could have unintended effects. But you can't accidentally click on the wrong thing if it is not on your screen ! And the admin interface is so much nicer without all the junk !!!

I recently stripped out all the language translation functions in the theme that I inherited from TwentySixteen. I don't care about anything but English. English is spoken around the world, a form of it is even used in Australia. The code is now smaller and simpler and easier to maintain - that is hundreds of extra function calls and database accesses eliminated.

I also eliminated a lot of redundancy in the templates, so now almost everything is in header.php and footer.php. In fact, sidebar.php shrank down to a nub, so I folded it into footer.php, eliminating a file load. This also makes for much better consistency across the whole site. All of this has resulted in a definite decrease in page generation times on the server. Small pages are almost twice as fast. TwentySixteen is really very badly designed, as are most WordPress themes.

In fact, this is not just a theme any more, it's functionality goes far beyond any WordPress theme. Much of that could be incorporated as plugins, but I prefer to incorporate essential functionality ( like navigation menus ) directly into the theme so that it cannot be accidentally disabled.

Despite the vast increase in functionality, my theme is only 164 kB, compared to 1.05 MB of the original TwentySixteen, an 85% reduction in the amount of code.


If You're Going to Build a Guitar on Your Kitchen Table …

image
Sacrificial Work Surface

… you don't want to ruin the table !!!

Printed from luthierylabs.com