So sad to see that Bobby Ball has died after a Covid 19 diagnosis. He was up there with Tommy Cooper and Eric Morecambe in that you just had to look at him and started laughing. He didn't need to say anything as he just had that mischievous look about him and you knew what was coming.

29/10/2020, 10:50

I thought it was about time I updated the Join Me & Feeds pages to reflect that I recommend subscribing to the Daily Update rather than the more traditional "posts as they happen" option.

If you're unfamiliar with the concept of a /feeds page it's like /about or /now but for RSS feeds and was proposed by Marcus Herrmann back in May.

28/10/2020, 12:25

I've long maintained that doing the dishes is cathartic, almost a meditative experience so it was nice to see David Kanigan quote from "An ode to washing dishes" yesterday:

"Embrace this — the warm water, the pruned hands, the prismatic gleam of the bubbles and the steady passage from dish to dish to dish — and feel, however briefly, the breath of actual time, a reality that lies dormant and plausible under all the clutter we pile on top of it."

Thich Nhat Hanh always says that everything can be a meditation whether that's brushing your teeth or doing the dishes. Just focus on the task at hand and be truly in that moment, devote your whole self to it.

That's exactly how I've always been with doing the dishes, why I enjoy it: a perfect way to quieten the mind, to put the stress aside and just be - one task, one goal, one thought.

27/10/2020, 13:56

I know I wasn't impressed with iA Writer when I tested it before but that's because it didn't do what I expected with regards publishing direct to WordPress. As a straight Markdown editor it's fine.

In light of the calamitous failure of One Jotter I've decided to switch to another app. I don't really get on with Pure Writer anymore so have opted for iA Writer synced straight to Dropbox.

My subscription runs to August next year there's no issue on that front and, who knows, they may have improved the WordPress integration in that time.

I'll be treating iA Writer just as I have any other app: copying the text manually or sharing it to the WordPress app. I just want to ensure there won't be another issue like earlier today.

26/10/2020, 20:03

I suppose there are lessons to be learnt regarding always ensuring that backups are up to date (and working) and not relying solely on one thing, especially a mobile app.

To be fair, there was only one note that I wanted to hang on to: the planning and thoughts around something I've been working on for a while. I say working but I really mean putting off again and again, adding little bits to it here and there to convince myself I was still serious about it.

Maybe I just have to be pragmatic, anything else in the app was either an archive or very probably something I wasn't actually going to use or I would have by now. Perhaps an enforced clear out will cause me to refocus on something that I will work on.

26/10/2020, 16:53

It really is too much effort and I'm not entirely sure what I'm trying to achieve is possible without making some radical changes to the theme so I'll leave it as it is.

26/10/2020, 14:40

I've got a post updating via an AJAX call but it still requires a page reload. Besides being able to say I've done it, I think the work involved for something that only I will see is probably too much for any benefit it may provide - read almost none. Still, you know what I'm like. 😉

26/10/2020, 13:38

What would be pretty cool is if I could get the new post and edit forms working through AJAX so that the page didn't need to reload. I've done a few searches and got some basic ideas but it's a whole new area that I haven't touched on before.

Status

Another trip round the sun for our eldest daughter - it just seems mad that I have a "child" who is 22!

I remember being that age. I do, honest. I also vividly remember when Amy was born, the struggle my wife experienced because she suffered an M.E. relapse during childbirth and that Amy was almost blue because her airways were blocked and required suction.

I remember that the relapse left my wife unable to function so I had to do the first feeds and the first baths and it took a while for her to feel like a mum because she was out of it for so long.

Crazy times.

25/10/2020, 10:48

I previously detailed how the post form operates so thought I'd do the same for the inline editing. The two work on the same principles but there is an additional step involved with editing rather than just posting: you have to pull in the post content but it's easier than it sounds as it's all done within the loop.

First, I've contained the code within the loop inside a DIV, this is given a unique ID to be used later:

<?php while ( $today_query->have_posts() ) : $today_query->the_post(); ?>
  <div id="post<?php echo $post->ID; ?>"> // container div for post
    <?php
      // code in the loop to display the post
    ?>
</div>

Still within the loop, but after the code used to display the normal post, I have the form used to do the editing. It is in a hidden DIV by default which is, again, given a unique ID and is only visible if logged in and the current_user_can( 'edit_posts' ). The form contains a hidden input which holds the current post ID as its value and the textarea holds the original post content:

<?php
  if (current_user_can( 'edit_posts' )) {
?>
    <div id="edit<?php echo $post->ID; ?>" style="display: none;"> //container div for edit form

      <form id="form<?php echo $post->ID; ?>" name="form<?php echo $post->ID; ?>" action="" method="post">
        <input type="hidden" id="updatepost" name="updatepost" value="<?php echo $post->ID; ?>">
        <textarea id="newcontent" name="newcontent"><?php the_content();?></textarea>
    <?php
      echo '<a onclick="quit(' . $post->ID . ')"><span style="float:left;" class="dashicons dashicons-dismiss"></span></a>';
    ?>
    <input style="float:right;" type="submit" name="submit" id="submit" value="Update">
      </form>

    </div>
<?php } ?>

Inserted within the first DIV, just before the post content, is a WordPress dashicon used to toggle to 'edit mode' - for my theme this is a separate template called content.php. In the editing form, I have another dashicon to switch back and dismiss the form.

// toggle inserted before each post - within loop code

if (current_user_can( 'edit_posts' )) {
  echo '<a style="display: none;" class="editicon" onclick="toggleEdit(' . $post->ID . ')"><span class="dashicons dashicons-edit"></span></a>';
}

Both dashicons have an onclick event which triggers a simple JavaScript function to toggle the display states of the normal post content and edit form:

<script>
function toggleEdit(e) {
  let post = "post" + e;
  let edit = "edit" + e;
  document.getElementById(post).style.display='none';
  document.getElementById(edit).style.display='block';
}

function quit(e) {
  let post = "post" + e;
  let edit = "edit" + e;
  document.getElementById(post).style.display='block';
  document.getElementById(edit).style.display='none';
}
</script>

I could have used a single function with an if...else statement but kept it separate on this occasion.

The edit form method is post and there is no action specified so it reload the same page. This means I need to process the form output so, at the start of the page is the code to do that:

<?php

// Update post

if ( isset($_POST['updatepost']) && ($_POST['newcontent'] !='') ) {
  $body = stripslashes($_POST['newcontent']);
  $ID = $_POST['updatepost'];

  $update_post = array(
    'ID'           => $ID,
    'post_content' => $body,
  );

  wp_update_post($update_post);
}

?>

After a quick check to ensure that the post content isn't empty and that a post ID has been passed it's a simple matter of creating a post array and updating the specified post. It is recommended to use stripslashes() when dealing with HTML form content via $_POST just in case of any issues.

And that's it. Inline post editing without having to go to wp-admin.

Status

It's that time again when we have to submit our annual self-assessment for the "end of year" process.

What to write about in a year that's been dominated by Covid and started with what I thought was an eye infection but turned out to be a recurrent case of scleritis and macular edema.

It almost doesn't seem possible that tomorrow will be seven months to the day since I started working from home.

I think this year has largely been about keeping the lights on and hitting targets while I still look for other opportunities. Nothing spectacular.

Lockdown and continuing restrictions have been both a blessing and a curse. In one sense it's been good not to have to worry about commuting and the risk associated with it, an attack vector for some anxiety is removed, but the timelessness caused by living within the confines of your home is not good for you and I continue to have ups and downs on the mental health front.

Considering that a lot of my mental health issues stem from self-esteem problems, the ability to adequately sell myself and any accomplishments has always been difficult. End of year reviews are hard enough at the best of times without the added complication of a global pandemic and everything it brings with it.

Those little voices in my head telling me I'm not good enough become almost overpowering in the isolation of lockdown and restrictions.

Still, I know I'm not alone, it's been a hard year for everyone and I take comfort in the fact that the lights are still on and I'm still able to function - it hasn't beaten me even though it's been hard. At times, really hard.

You just have to keep on surviving, appreciating the small wins whenever and wherever you can get them.

23/10/2020, 18:39

Liked MJD 59,143 - Venkatesh Rao...

"You’ll be pivoting towards either greater engagement or greater detachment. You’ll either help invent the future, or retreat with the declining age and turn into a producer of nostalgia."

Status

I should do a better job of documenting what I do here for my own reference as much as for sharing with others. I go through phases where I implement or change a number of things in quick succession but then have gaps and often can't remember how I did things.

The theme is a bit of a mess and could do with tidying up/sorting out as there are bits all over the place with repeated code in different templates when I could/should write once, use many.

I'll post snippets here and there detailing how I've done certain things but, unlike the plug-ins uploaded to GitHub, there normally isn't enough to re-implement it elsewhere.

21/10/2020, 18:14

A slight update: I could already toggle the posting form on and off so thought I'd incorporate the post edit icons into this action. Now I have them off by default and they toggle on if I hide the new post form. It's more a way to save space on screen than anything but also keeps things a little tidier.

21/10/2020, 11:52

Following on from the simple posting form I thought about making it easier to edit posts inline from the Daily page.

Now, when logged in each item has a pencil I can click/tap to switch to "edit mode" for that post:

This will load a form with the post contents ready to edit:

Hit update and that's it!

If I need to add something or spot a typo (more likely) I can do it without going to the back end.

Status

I'm not sure if it's just because MacOS Big Sur is still in beta or because my MacBook Pro is starting to show its age a little but it seems to be running hotter with the battery life dropping off.

To counter this I've just paid for Turbo Boost Switcher Pro, after using the free version for a while, which will counter both these issues.

There's not really anything I do on the MacBook that pushes it so I should be able to run it with turbo boost off most of the time.

Status
Colin Walker
Colophon. Content: CC BY-NC 2.0 UK, Code: GPLv3