Jonnie Grieve Digital Media: Blog

Home
by on 30th April, 2021 - 4:49pm (0)

Blog: R7D10: #100DaysOfCode (More Posts)

Today I attempted to write my first WordPress Plugin, the goal of which was to move control of my blog posts custom post type in this very blog to the whim of said plugin.

I moved back sole local development for this into its own WordPress installation to do this.  It took a lot of work to just study what it takes to make a customizable plugin file I would be sure would work. But to summarise what I’ve achieved today.

  • Understood and written the comment header for the plugin file and understood the ways that the comment block is used to customise the plugin and differentiate itself from other plugins.
  • Setup the standard Plugin lifecycle hooks for preparing actions when the plugin is installed, activated, and uninstalled.
  • Written my first plugin that makes a material change to the admin area

So, having written code that registers a new post type I managed to successfully create that post type and assign it to the same menu area as you get with the CPTUI and advanced custom field plugins. And the plugin works but up to a point.  I’m afraid that there are error messages relating to an invalid JSON response when trying to add images and post the blog content. But it’s not that the images are prevented from being uploaded or the blogs from being submitted. They’re very much there but there’s some sort of incompatibility in the plugin code that is preventing the GUI from working properly, which is of course far from ideal.

But it is progress.

Further to this, I’ve echoed a message that pops in the dashboard when the plugin is activated.

It shows that I can write plugins but I still have so much more to learn about plugin stability, security, and functionality.  And still, a way to go yet in doing what I wanted to do in the first place, which is to fix my WordPress pagination links.

Future Goal: Write a plugin for my WordPress Starter Repository that adds a custom menu to the admin area with a message printed to that screen.

This post has been assigned to the following categories

    Leave a Reply

    Your email address will not be published. Required fields are marked *