# So that I can keep track of what I'm writing I've added word counts to the garden pages using the PHP function str_word_count(). While editing a page I have a JavaScript function to return the count on the fly in response to the oninput event.

The two methods return slightly different values but it gives me a rough idea.

# A few tweaks to the JavaScript have gotten them a bit closer.

19/11/2020, 22:44

# I had a really good conversation with my wife yesterday, in it she hit hard with a number of home truths. Sounds bad but it was actually the opposite: it made me see some things for what they truly were and gave me the impetus to get on with something I've been putting off for far too long.

19/11/2020, 18:25

# Liked ten recent thoughts – rebeccatoh.co...

I couldn't help but think of "Fear is the path to the dark side. Fear leads to anger. Anger leads to hate. Hate leads to suffering" when reading number 6 as Rebecca originally wrote "Circumstances trigger thoughts. Thoughts lead to emotions. Emotions influence our actions."


# I found and (hopefully) fixed a couple of bugs:

# My replacement for fragmentions was incorrectly highlighting the first paragraph of posts thanks to me forgetting an if statement and, therefore, not properly parsing the URL.

# The glitch that removed commas from the list of email addresses signed up to the muse-letter should now be fixed - it appears that a blank email address was sometimes getting passed through so I have added some additional checks.

If you have unsubbed from the muse-letter recently and are still getting mails please accept my apologies and try again - it should now remove you correctly. Incorrect form submissions should also now not mess up the list; they shouldn't get through.

18/11/2020, 15:50

# Why do I insist on keeping archives in my note apps? Months and months of posts, no matter how small or inconsequential; if it started life in a notes app it will invariably be archived. I always ensure I have the required folder structure in place as one of the first tasks when switching apps - it's habitual.

Part of me wonders if this propensity contributed to 'the crash', whether I was holding too much in One Jotter's database and caused it to become corrupted.

Almost everything I write (eventually) goes on the blog or in the muse-letter and is always available online so why do I always feel I need a permanent local copy? I never go back and refer to it; if I need to find something I'll search the blog.

The blog itself - and now with the addition of the Garden - is one big archive so why do I need another?

# And, to make matters worse, I've built an archive into the Garden itself.

16/11/2020, 16:09

# My Colophon page is very out of date and not just because of the inline posting/editing changes. I'm not sure if it's something I want to retain.

Update: I've made a few quick changes regarding public facing features but will think about long term use of the page.

16/11/2020, 11:12

# The last few leaves cling for dear life to the tree at the back of our house, a last bastion of autumn. Whilst sitting in the office I have watched as the colours changed and the leaves fell, it seems only a few weeks ago that it was full, green, vibrant, but I know it is longer and that I am remembering through the current Covid induced skewing of time.

Surprisingly, the weekend seemed longer than usual, it feels like more than two days since I have set at this desk. Weekends normally disappear in a flash leaving me resenting Monday morning, not just for having to return to work but for stealing all too precious time.

This morning, this Monday, is the most bearable I've had in a long time. I actually feel ready to get on and get things done, things that I have been putting off for weeks; almost since before the tree had begun to acknowledge the changing of the seasons.

16/11/2020, 09:05

# I don't know why it didn't occur to me before that I could apply filters to the_content_feed as well as the_content. This means that the display time changes should also be reflected in the RSS & JSON feeds.

So here's a test: [[Test garden page]]

When I couldn't sleep last night I also started working on something else which may change the way the blog operates in future if I decide to see it through to its conclusion.

15/11/2020, 11:28

# It appears that in JavaScript document.execCommand("copy") can only occur after a user-initiated event so I have to have a "copy" button.

14/11/2020, 17:17

# Uploading a file within WordPress is actually pretty simple, you start by creating a form with the correct attribute to allow it to process files: enctype="multipart/form-data" and an input of type="file".

When the form is posted an array $_FILES is populated with all the file properties stored and access using the format $_FILES['filename']['name'] - where 'filename' is the name of the file input in the form.

To actually perform the upload you use the built in function wp_upload_bits() - here's my code:

$new_file = $_FILES['fileToUpload'];
    wp_upload_bits($new_file['name'], null, file_get_contents($new_file['tmp_name']));  

PHP saves file uploads to a temporary location (hence $new_file['tmp_name']) before moving them to their final location - in the case of WordPress that's the upload directory. The above code is all that's required to get the file in place but it will not show up in your media library because it is not referenced in the database. To fix that you use wp_update_attachment_metadata( ) and pass it the required information.

I found a great post from Misha Rudrastyh that explained exactly how to do it. I omitted a few of the checks such as mime type and size, I also don't need to check if there is no file uploaded as I have the required attribute on the file input within the form.

Misha's code performs a check to ensure the file has been properly moved from the temp location to the final location - if( move_uploaded_file(...) ) - before creating an array and adding those details to the database using wp_update_attachment_metadata( ).

Once all that is done I then display the full file path so that I can copy it into a post. The next thing I want to figure out is how to automatically place that path on the clipboard to automate things even further.

14/11/2020, 10:54

# In the interests of keeping everything 'front end' I've added a new toggle to my 'new post' form:

Upload Image

Clicking/tapping this reveals a new form (held in an iframe) that lets me upload a file to the WordPress media library and returns the full path so I can copy/paste straight into a post - as I've done with the screenshot above.

The original version performed the upload okay but that was it, I then had to find out how to add the proper metadata so that the image actually appeared in the library.


# It completely escaped my attention that it was Friday the 13th. I'm not superstitious about it anyway.

Some believe the origin of 'unlucky 13' comes from the Bible as Judas was the 13th guest and betrayed Jesus. In Norse mythology, Loki ruined a dinner party of the gods and plunged the world into darkness; yep, he was the 13th guest.

An interesting parallel there.

Friday has long been considered the unluckiest day of the week. Put the two together and you've got a perfect storm.

13/11/2020, 15:58

# It's Friday again and another week feels like it's disappeared in the blink of an eye. People talk about 2020 being a lost year, stolen by Covid, and I suppose in some senses that's right. But it all depends on context.

Covid and lockdown have certainly meant that some things we take for granted have not been available to us. There have, however, been other opportunities that we might have overlooked.

I'll be the first to admit that I have let 2020 slip by, not taken advantage of things in the way I could have. My mental health problems have been compounded causing me to retreat into my own head. Despite this, as a family, we made the decision to take a leap of faith and move half way across the country in search of a better life.

Things aren't final and I still haven't found a new job but taking that initial step is often the hardest part.

Things are different and will remain different for some time to come but that doesn't mean everything stops. I'm starting to realise how much time I've wasted, how much I've let life pass me by over recent months, and how much better things could be.

It's hard to admit that and even harder to do anything about it.

Current circumstances mean that life is very uncertain and there is an underlying anxiety pervading just about everything. What's so special about now? Life is always uncertain, it's just the degree of uncertainty that throws us, the extra angst over not being in control - or, at least, not as much control.

From a work perspective I have relished lockdown, I'm not exactly the most sociable of people and can experience anxiety over crowded spaces. Not having to commute and deal with people on a face-to-face basis has been a blessing. Still, living with a constant background sense of FUD takes its toll and amplifies the effects of my already fragile state of mind.

This is probably why I become so immersed in things like building the digital garden: they are opportunities to hide in plain sight, to appear as though I'm doing something while avoiding what I should be doing.

The challenge is in emerging from these safe spaces, accepting that I am not in control and making the most of what I have available to me. Not an easy task at the best of times.

13/11/2020, 14:47

# Finally got round to watching the first series of The Mandalorian - I had been getting stick from a colleague for not having seen it, being the biggest geek on the team. (Who are you and what have you done with Colin?)

I had heard very good things so felt a bit disappointed after the first two episodes; it didn't seem to be as good as everyone was making out. I was too quick to judge. Episode 3 and on the story really takes off and becomes hugely enjoyable. I just wish the episodes were longer as I could watch so much more of this and still feel it wasn't enough.

The production values are immense and it's just like watching a movie. The way the backgrounds are generated with Unreal Engine and displayed on a full 360 degree screen (no green screen here) makes it all the more immersive and believable, not to mention being absolutely fantastic.

12/11/2020, 15:23

# I've just realised that I could possibly have used the built-in post_parent attribute rather than building a custom post_meta solution from scratch but this would only account for pages marked as children when created and not those manually marked up as such. It could, however, be worth looking at.

11/11/2020, 16:16