ey i'm blogging here a blog by alex daily

A simple sidebar word count widget for ClassicPress and WordPress, or, good lord, what have I done, or, perhaps Alex doth protest too much

Twice this past week it’s come up at school that writing a few hundred words has never been a huge issue for me.1Remember that the course I’m taking is aimed at or at least meant to be accessible to 19-year olds, which means the bar can occasionally be relatively low. Sure, often the process involves walking circles around my living room while I do it, but if there’s one thing I can do it’s put the words on the paper and get them in the inbox on time. Both times that came up I wanted to reference the existence of this blog; I wanted to say, “Well, I’ve written X words since this summer just on my blog, for fun, because I wanted to, so 1200 words about this subject shouldn’t be a problem.”

But ClassicPress, though it has the little word counter in the bottom of the editor, doesn’t really have any kind of overall word count statistics displayed anywhere, and so I kept it vague, and just said “thousands,” or “like fifteen thousand.” It doesn’t really matter, it got the point across. But it is good to be specific about these thing, I say, being the kind of person who likes to use their mouth to say sentences like “I’ve watched 1421 movies since the start of the pandemic” out loud to people.

At this point I can hear you thinking, wait, surely there exist many word count plugins for WordPress that are compatible with ClassicPress, and so I say to thee, local imaginary straw-person, alright, you try finding one that, one, actually does what I want, two, isn’t so over-featured as to demand a whole god-damned tab to itself on the admin panel, and, crucially, three, is actually compatible with and doesn’t break ClassicPress just by being five years newer than its codebase.

Look, I use ClassicPress because it does everything I need, because I can maintain it myself when I break it, because it’s familiar, but god, it being based on the now very old WordPress 4.9 sure does put some lines around how much of the wider WordPress world, which has long since moved on from 4.9, I can actually use — I had fun doing it, but, like, I had to make my own theme and everything.2Not because there aren’t hundreds of compatible WordPress themes out in the world, but because all of them turned out to suck eggs. The absolute state of these things. Sometimes this is frustrating, but more often than not running into those lines either makes me go “well, I don’t need that,” OR, I learn something new along the way. But I knew enough to know that doing the relatively simple thing I wanted would probably require a few hours of digging into documentation or existing plugins, and so I put it in the “well, I don’t need that” column. I didn’t need it, after all.

But it really bothered me that I couldn’t make the, again, relatively simple thing I wanted to do happen.

So I turned to the enemy: ChatGPT.

This is, I should say at this point, not a conversion post. I’m on the record as being very strongly against3I hate it. both the culture around large algorithmically generative models and against4I hate it a lot. the models themselves. Everyone involved, from dev to ev(angelist), seems like, and often just plain is, an absolute a-hole, the way people talk about these things is way overhyped and generally speaking unrealistic, and by definition the models are actively enabling large-scale creative plagiarism and academic fraud.5From the perspective of a teacher, though: If the essay assignments you give to your students can generally be written by or with the aid of ChatGPT, consider that that may be a failure on your own end and that you need to give more specific or more personal essay assignments.

But a concession I’ve often made is that the culture around them doesn’t match what these things actually are, which is tools. What ChatGPT is, to keep it focused on just the one thing, is a large database of text,6Stolen or otherwise. an algorithm through which those words can be rearranged into something that sounds plausible, and, on the front-end, a chat through which those prompts can be entered.7Not unlike Homestuck. What it’s not is intelligent, or creative, or, frankly, particularly apocalyptic.8Unlike Homestuck. There’s no knowledge there, no truth, no ideas, and if it ever plays a role in getting you killed there will always be a person, a person who made a choice, to blame. A lot of that baggage we put on it is external to the tool itself.9The plagiarism isn’t, obviously, and a lot of the rest, like how gender may be a construct but that construct still exists and influences the world, may still be a problem that needs to be solved. This isn’t about that.

None of this is ever going to come remotely close to writing a particularly compelling screenplay, right, I don’t think any version of this algorithm is ever going to write a great, good, or even particularly readable novel without substantial human involvement. Hell, even a believable essay is a stretch. This is, I could not be more clear, still not a conversion post; on a creative level, as an artist and writer, and now a teacher, I think all of this just kinda fucking sucks. But if you’re not trying to cheat at school or trying to get rid of your industry’s writers, having something generate plausible-sounding text — or code — can be pretty useful. (Again, I’ve always conceded this. Nothing has changed.)

Obvious examples include things that could be form letters you need to send for work, outlines for things you can totally write but that you just need the shape of, or writing prompts, or just the little push to the train of thought you need to get back to what you were doing. You don’t need to be creative or have ideas to write a letter asking the guy who’s in charge of that kind of thing and who needs a formal request letter on file to do so to make funds available to you to buy a second monitor for your workstation, but if you’ve never sent that kind of letter before it might be a real bottleneck to whatever the fuck else you were meant to do today. That, I think, may be what ChatGPT is for.

And the thing is, I don’t actually need to learn how to do this. I’m not a programmer, I’m not a web designer,10Have I been paid to do some website stuff a couple times, yes, but those are jobs you get because you’re the person somebody knows who can do the thing, not because you’re necessarily good at the thing. “Good at the thing” is secondary for those gigs. whatever skill I do have here I have because I wanted to do something else. I want to put a comic on the web, I build it a website. I want to blog, I build a blog. Heck, it’s not like I’ve never copied snippets of HTML and CSS before — that’s culturally central to programming in a way it obviously wouldn’t and couldn’t really be to creative fields. It’s a different equation, and so the solution can be different, too.

Which is how I’ve rationalised going to ChatGPT, which I hate, to generate some PHP to do a thing I could have but wouldn’t have bothered to figure out on my own. I’ve attached the code below the fold, feel free to use it or proofread it, or do literally anything you want with it — as far as I’m concerned, it’s as in the public domain as it can be. I’ve named it “Vaughn,” after Tobias Vaughn, who once made an alliance with evil as part of a plot to dominate Earth.

I promise I won’t dominate Earth.


/**
* Plugin Name: Vaughn
* Description: Count the blog's total word count and display it in a sidebar widget.
* Version: 0.1
* Author: None
*/

// Exit if accessed directly.
if (!defined('ABSPATH')) {
exit;
}

function get_total_word_count() {
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
);

$query = new WP_Query($args);
$total_word_count = 0;

if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
$content = get_post_field('post_content', get_the_ID());
$word_count = str_word_count(strip_tags($content));
$total_word_count += $word_count;
}
wp_reset_postdata();
}

return $total_word_count;
}

class Word_Count_Widget extends WP_Widget {
function __construct() {
parent::__construct('word_count_widget', 'Word Count Widget', array('description' => 'Displays the blog\'s total word count.'));
}

public function widget($args, $instance) {
echo $args['before_widget'];
echo $args['before_title'] . 'Total word count' . $args['after_title'];
echo '<p>' . get_total_word_count() . ' words</p>';
echo $args['after_widget'];
}
}

function register_word_count_widget() {
register_widget('Word_Count_Widget');
}

add_action('widgets_init', 'register_word_count_widget');
  • 1
    Remember that the course I’m taking is aimed at or at least meant to be accessible to 19-year olds, which means the bar can occasionally be relatively low.
  • 2
    Not because there aren’t hundreds of compatible WordPress themes out in the world, but because all of them turned out to suck eggs. The absolute state of these things.
  • 3
    I hate it.
  • 4
    I hate it a lot.
  • 5
    From the perspective of a teacher, though: If the essay assignments you give to your students can generally be written by or with the aid of ChatGPT, consider that that may be a failure on your own end and that you need to give more specific or more personal essay assignments.
  • 6
    Stolen or otherwise.
  • 7
    Not unlike Homestuck.
  • 8
    Unlike Homestuck.
  • 9
    The plagiarism isn’t, obviously, and a lot of the rest, like how gender may be a construct but that construct still exists and influences the world, may still be a problem that needs to be solved. This isn’t about that.
  • 10
    Have I been paid to do some website stuff a couple times, yes, but those are jobs you get because you’re the person somebody knows who can do the thing, not because you’re necessarily good at the thing. “Good at the thing” is secondary for those gigs.
© Alex Daily. Powered by ClassicPress. The theme is Blogging Here by me, Alex Daily. More information in the colophon.