A Bit of Character Counting Stupidity

When I’m using WordPress’ Status Post Format, I like to keep it to 140 characters, so it’s like a Tweet. But how many characters have I typed? Cos The Visual Editor only shows Word Count. So I took a look around and saw various ways of doing it, quite a few using regex to strip ‘unwanted characters’—but a space counts as a character! So I wrote my own, based loosely on what I’d been using for counting characters in the Excerpt, and from a few different plugins and bits of code. Turned out to be surprisingly easy and uncomplicated (I say that now, of course).

So, first I need a function to call a couple of files if I happen to be editing a Post or Page:

function supernaut_character_count( $charcount ) {
  if ( 'post.php' == $charcount || 'post-new.php' == $charcount ) {
    wp_enqueue_style( 'character-count-css', get_stylesheet_directory_uri() . '/css/char-count.css', array() );
    wp_enqueue_script( 'character-count-js', get_stylesheet_directory_uri() . '/js/char-count.js', array( 'jquery' ), '20160519', true );
  else return;
add_action( 'admin_enqueue_scripts', 'supernaut_character_count' );

Then I slap together some jQuery:

jQuery( document ).ready( function( $ ) {
  if( $( '.post-php' ).length || $( '.post-new-php' ).length ) {
    $( '#post-formats-select input' ).click( function() {
      if ( $('#post-format-status').is(':checked') ) {
        $( '#post-status-info tr:first-child' ).after( 'Character count: ' );
        $( '#content_ifr' ).ready( function () {
          setInterval( function() {
            var tinymcebody = $( '#content_ifr' ).contents().find( 'body' );
            $( '#postdivrich .character-count' ).html( tinymcebody.text().length );
          }, 500 )
      } else {
        $( '#post-status-info tr:first-child' ).nextAll().remove();

Then a miniscule bit of CSS:

.post-php #wp-character-count {
  font-size: 12px;
  line-height: 1;
  display: block;
  padding: 0 10px 4px;

It’s a little bodgy, and if I had more than the 45 minutes to a) work out how the Visual Editor can be fiddled with, and b) write something that worked and looked ok—the bare minimum really—I’d do it slightly nice and maybe consider for a minute throwing it into a plugin (where it officially belongs). But I won’t. It does what I want: live updating of how many characters I’ve written in the Visual Editor, and shows it in a line underneath the Word Count (also aided me in delaying writing a residency application on the day it’s due).

supernaut Character Count
supernaut Character Count


Unattached No More!

“Yeah, I know Frances, it’s awfully ‘precise’ of me. Can we just leave aside that conversation for now and enjoy some shit?” “Ok, Other Frances, we can, but I’m not sure what everyone else will think of you…” “I’m just gonna leave that ellipsis hanging.” “As you like. Your decision.”

On and off for months/years, I’ve been porting the first I dunno how many years of supernaut properly into WordPress. When I gave Moveable Type the boot—and later ecto, opting to work directly in WordPress rather than with a haha ‘blogging client’ (remember when blog software was so crap you needed a blogging client rather than suffer the web browser?) I had all those years of images to deal with, assimilating them, attaching them to post, blahwork. Weeks of blaaahwork. Done. Fucking finished right now. 6312 images are all unified and fuck me if I ever have to change to another blogging platform it’s gonna be a piece of piss compared to this. Or I will throw my arms up and walk the fuck out of the internet for ever.

This is archaeology. The remainder. The images that weren’t attached, had no home, were left to languish in the dim recesses of my server. Jacques Derrida would probably find these telling. Bin Lang girls from Taiwan, I think from an exhibition, or they might have been actual workers in Tainan or Taizhong. Genesis Breyer P-Orridge, I think from when I was in Taipei and was told about what Gen was up to—also introduced to the novels of China Miéville. A page from a comic called Dragnet? I think one of those mid- late-’00s types when tranny was a word we could still throw around without the Queer Police putting a fucking * on the end. That “Jesus Loves You” one … fuck knows. Maybe from Emile? Fuck Gender might even be a photo I took at some Queer* event in Berlin. Or Vienna. Dunno. Thought it was cool at the time (maybe, fuck knows, no memory here), enough to photograph, though not enough to blog. Don’t think it’s cool anymore. Lambs. Baaaaaaah! Was from Christmas 2008, with the mob all in Berlin, around the time I photographed a Nativity Scene. This is definitely one of my photos.

Finally I can remove that shitful “sorry things are broken” apology at the bottom of supernaut.

blog cleaning progresses


I’ve been avoiding doing the cleaning of several years of posts, but somehow fell into it a couple of days ago, trying a few different approaches to get through the task until I found one that’s methodical, quick, and requires very little brain use. The problem is supernaut existed in a couple of different platforms before WordPress, and there remains (currently from August 2005 to December 2010) a lot of mess and pretty much all the images not properly linked. So I’m working through that, one month at a time, and while it’s certainly not exciting, I am getting to read back over ten years of blogging and my life.


Last week I set another website loose (Voices of Transition, for the documentary filmmaker, Nils Aguilar), which in part was being shunted off another domain, with some very messed up urls requiring quite a stack of redirection. I started using a plugin to deal with this, which  then made me think about supernaut, and all its incarnations and thousands of posts, tags, hundreds of categories, tens of thousands of images, and what kind of mess almost ten years of blogging would leave.

Out of curiosity then, I installed the same plugin (in-between watching Person of Interest – which is another story) and turns out there are over 1000 404 Page not Found per day. A lot of these (around 3/4) are from Google’s Image Search trying to go directly from their site to the full-size image itself, bypassing the post the image lives in, which the server treats as hotlinking (due to the absence of a referrer) because of my anti-leeching rules. I’d love to be able to simply redirect those attempts to view the image to the actual post, but … prior to 2011 supernaut is a mess. Most of the remaining quarter are either weird errors trying to access images for the image viewer I need to deal with or spam searches looking for things that don’t exist (on the basis of “If image ‘n’ exists at path ‘p’, then ‘y’ is installed (plugin, theme, software, etc) that allows for hack ‘x’ to be tried). Which leaves real errors.

Which comprise wreckage from the days long ago when I used Movable Type instead of WordPress. Back in those days, all my images were in a folder called /images/ with subdirectories like 09dec for December, 2009. WordPress on the other hand has everything in /uploads/ with a year/month/ sub-directory structure, which I long ago imported all the images into (and which I am still very slowly dealing with). It also had a different url structure for posts, like post_name_truncated_somethi.html. Both of these are buried in search engine results, the former to quite a huge degree (about 5% of traffic is looking for those old images).

So I wrote (and am writing) a bunch of redirects – and a lot of regex. I could do this directly in .htaccess, but not knowing which urls are the problem, and having all of this logged by the plugin are both good reasons to do it directly in WordPress. It’s a bit messy and sometimes redirects for spam conflicted with genuine pages (like sub-pages of monthly archives), but probably useful for a while if people looking for something actually stand a good chance of finding it instead of “absence…”

Categories & Tags Mayhem (∴ SQL)


I was just about to write on a few things I’m reading – Michel Serres, Black Metal Theory mostly – and suddenly felt an urge to clean up, merge, rename, delete some of the 1300 tags on supernaut, when I noticed something dead weird: some of the tags were simultaneously categories. Much messing around and the inability to edit or change taxonomies caused me to have a look at the database, where I found, horribly, they indeed existed as both. I guess this is either a hangover from the Movable Type port some years ago, or a plugin that didn’t do its job properly around the same time. So I manually deleting 50 or so of these and their relationships. And then did some more merging and renaming. And now I must eat.

supernaut addendum


Oh grep! I spent some of my spare time the last days grepping the crud out of supernaut’s database. Much excitement, of course. The result is that now all the image file paths point to the default WordPress uploads folder, organized by year and month, and also all images are in the Media Library. So my slow task of disentangling supernaut from its previous years in Ecto and Movable Type, and hooking it properly into WordPress (which should mean if I ever decide to swap to another platform will mean less pain) proceeds slowly.

I decided for the manual path for coping with all the rubbish html surrounding the images as the thought of properly grepping all that caused my eyes to water, so currently I’m working my way through June, 2004. Shall take months, I’m sure.

supernaut wordpress

Six months ago, deliriously annoyed with Movable Type, and deeply envious of all those people using WordPress. I install WP, throw a theme framework on top and promptly run away, terrified of what harrowing coding ordeals would ensue when I tried to make new look like old.

I have an end of year list of things to do. Coding for some, editing for others, rsync, asr, and other delights of command line backups for still another. For me, one was to use the brilliant, entirely CSS 100% background image for francesdath.info. That took all of 40 minutes or so, mostly in cleaning out my old junk from when I decided to code that version in an afternoon.

The other, of course, forced me to look at supernaut once more.

I’ve been using WordPress for all my projects lately, and the more I fall into it, the more I love it. A while ago, after much looking around, thinking, reading, and even a couple of trials, I decided on Blueprint CSS as the typographic CSS framework to build sites upon. Rather than lose time that could be spent sleeping…

Blueprint is a CSS framework, which aims to cut down on your development time. It gives you a solid foundation to build your project on top of, with an easy-to-use grid, sensible typography, useful plugins, and even a stylesheet for printing.

— Blueprint

… and a Photoshop layout to build designs upon that then can be transferred ridiculously quickly into a real site.

Of course the limitations are firstly of setting up a WordPress theme with all the necessary IDs and classes. Lucky someone else did that for me. Combining the Sandbox theme framework with the WSB Child Theme

WSB is a Sandbox child theme that provides tight integration with the Blueprint CSS. This is the conclusion of the method of integration discussed here. Using WordPress functions file, Sandbox template files, and Blueprint CSS files creates a excellent minimalist theme that is a very strong starting point for further theme development and customization

— Nedsferatu.com

… I began this afternoon and lazily poked at some CSS, a little hackery in one or two of the functions.php, some shuffling of the Sandbox templates php (which I could have done in css and left all this untouched but I was feeling lazy – much cheese and chocolate). To be pedantic, I began around 18h and it’s now 2315-ish, and with a good hour or more break in that time, so perhaps 4 hours of actual conscious attention, supernaut went from before to after.


supernaut before
supernaut before
supernaut after
supernaut after