Series Plugin Test for Illustrative Purposes Only

The only purpose for this post is to serve as a reference for a more interesting and useful post.

Software Development with LLMs
  1. Series Plugin Test for Illustrative Purposes Only
  2. ChatGPT WordPress Plugins
  3. Coding with an LLM Sidekick
Software Development with LLMs
  1. Series Plugin Test for Illustrative Purposes Only
  2. ChatGPT WordPress Plugins
  3. Coding with an LLM Sidekick

[custom_pdf_generator visitor_data=“John Doe”]

 

OCD Plugin Stats and the WordPress.org Statistics API

What you get when you don't use an API

What you get when you don’t use an API

The current version of my WordPress OCD Plugin Stats plugin, is somewhat… clunky.1 When I wrote it I didn’t know that WordPress.org had an API for it’s plugin statistics.2 Thus, the current version essentially scrapes particular WordPress.org plugin pages for information and drops it into the WordPress dashboard.

After poking into the stats on one of my plugin pages the other day I discovered that the source code for the page included several calls to a WordPress.org API.  Why should I bother scraping and interpreting a page of HTML when I can just ask WordPress.org to deliver the exact data I need in a nifty JSON format?!  I’m very much looking forward to adjusting this plugin to use a more direct and simple call to the WordPress API rather than scraping plugin pages.

In any case, if you’re looking for documentation on this, I found a page in the WordPress Codex and a site with a page devoted to documenting the WordPress.org API.

Default Series Title
  1. Photo courtesy of peasap []
  2. Apparently they have more statistics than just on plugins []

CompFight plugin, with 100% more awesome

Heart

Heart

I cannot express to you how much I just love this new CompFight plugin1  Snagging images off of CompFight/Flickr and dropping them into a post is so freaking easy now.  This is definitely going to become one of my stock-plugins for a fresh WordPress installation.  I’m happy to say that I contributed a small bit of code to this very very awesome plugin.  Since that comment, my modification of their code was merged into the main plugin.  I’ve also added a few small tweaks to my version of this plugin.  By modifying the javascript file very slightly, my copy of this plugin also:

  • Adds a caption, that includes the same text as the original photo on Flickr
  • Centers the image, using WordPress’s tags
  • Makes the photo credit part of the text.  I like to include the photo credit using slightly different language.  At some point I’ll get around to modifying the plugin so that I can save my format as a setting.

Admittedly, these implementations are just a little bit buggy – I just hacked those bits in without really doing any serious testing on them.  Once I have kicked the tires on this code a little, I’ll post it to the plugin’s page.  If you want to take a look at it before then, just drop me a line.

Sometimes the right post just needs the right picture – I’ve actually had a lack of a good photo hold up a post before.  I’m happy

  1. Photo Credit: seyed mostafa zamani via Compfight []

Articles on writing WordPress Plugins

Looking back at one’s code from years prior is like looking back at a junior high school picture of one’s self.  I’m looking back at the code for my quick-and-dirty pie chart plugin and think, man, why did I write things THAT way?

In the 1,000 years since I wrote that plugin in 2009, I’ve been trying to learn and comply with best programming practices for WordPress plugins.  As a result my current plugins tend to be stripped down, simple, don’t create unnecessary options, don’t create unnecessary tables, taxonomies, special post types, or those kinds of things. 1  Learning some Object Oriented programming along the way has been super helpful.  By encapsulating your WordPress plugin code into a chunk of objected oriented programming, you reduce the likelihood that your plugins’ function and variable names will collide with those from WordPress or other potential plugins.

If you’re getting started or need to brush up on your WordPress plugin development skillz, you should definitely check out these awesome articles:2

I’d also recommend tinkering with jQuery and JSON, if you haven’t already. 3  I don’t know of any really good JSON tutorials, so if you do, please let me know so I can add it to this list.

  1. Admittedly, I’m not really shooting for super ambitious plugins either. []
  2. Mostly stolen from the WordPress Codex! []
  3. I only use JSON for passing data from the browser to the server via AJAX and then decoding into a PHP object. []

My first published WordPress plugin! Simple Series!

This may seem silly, but I’m really happy with having published my very first plugin on WordPress.org.

My Simple Series plugin lets you easily create and helps you automatically maintain a list of posts.  I started writing this plugin because all of the existing ones seemed really clunky and over-engineered.  There’s no need for extra tables in WordPress, brand new taxonomies, or special system requirements.  If you can fire up any recent version of WordPress, you should be able to use this plugin without a problem. 1

As much of a WordPress fanboy as I am, I’ve never actually shared a plugin on the WordPress.org repository.  It was simultaneously easier and more difficult than I thought it would be.  The page that discusses how you can contribute your plugin and talks about “checking out” files makes absolutely no mention of how you’re supposed to do this!

Apparently you require a program to connect to the WordPress SVN to check out the file and commit changes.  On the advice of Schmarty I’m using TortoiseSVN.  Once that was installed and a sub-directory selected, it was relatively easy to commit changes.  If you haven’t tried it before, this whole SVN thing feels like a clunky slow version of FTP.

Default Series Title
  1. Of course, now people are going to start e-mailing me with problems… []

A nifty little WordPress plugin…

The idea for this little plugin has been rattling around in my head for a little while now.  It clocks in at less than 60 lines of code, including comments, and makes it easy to create a “series” for posts.

As I’ve been blogging about my (mis)adventures in building a DrawBot, I’ve been updating each post to contain a link back to all of the prior posts in the series.  However, if someone were to find one of the first posts – they wouldn’t see a link to a later post.  That is, unless I update all the posts.  That’s not really much of an option, since I’ve racked up 23 posts in less than 19 days. 12

This plugin is actually super simple.  Here’s what it does:

  1. Add a “post meta” tag for the current post with the same key as whatever you want to name the post series
  2. Query the database for all posts with the same post meta key as the one for the current post
  3. Output an ordered chronological list of all posts in with the same post meta key as the one for the current post

The simplicity of this plugin are actually some of it’s strongest features.  Unlike a lot of other series plugins out there, it doesn’t create any unnecessary tables in your WordPress database.  There are no settings to mess with, no CSS to fiddle with, no ugly standard formatting to overcome.

The only downside I can perceive is that if you delete the shortcode from a plugin, it will still leave the post-meta attached to the post and the post will still appear in the series.  If you leave the shortcode in and don’t specify a series title, it will delete the post-meta.  I suppose I could include a little button in the interface to delete the post from the series, but really, it’s just not going to be used that often.

Anyhow, this is something that I’ve wanted to have for a long time – I just hadn’t gotten around to building it yet.

Default Series Title
  1. I’ve got a lot to say. []
  2. And, actually, that’s just 23 posts on this one topic.  I’ve probably blogged an equal amount over on the MakerBot blog, with a few totally random additional posts here. []

WordPress Plugin Writing Resources

WordPress is easily my favorite open source software project.  I love it for it’s functionality, flexibility, and extensibility.  When it comes to writing a plugin, these are my favorite resources.  Don’t write a plugin without them!

  1. WordPress.org Codex for Writing a Plugin
    1. If you’re just getting started, this is the place to begin
  2. WordPress.org Codex Plugin API
    1. a great overview of the WordPress plugin API
  3. WordPress Action Reference
    • When WordPress displays a post, page, or the administrative pages it has to run through a number of functions and actions.  Your plugin will need to be activated at one of these points, and it is very helpful to know the order in which things happen.
  4. WordPress Filter Reference
    • The WordPress filter reference is a list of WordPress filters.  Each one will be able to deliver a little piece of the website for your to manipulate in your plugins.
  5. WordPress PHP Cross-Reference
    • The WordPress codex is pretty good – but it is not comprehensive.  If you want to know how some of the more obscure functions, variables, or constants work, you’ll just need to dive into the source code itself.  PHPXRef is, hands down, the best way to do this.  It let’s you search and read the the source code from their website.
  6. Top 10 Most Common Coding Mistakes in WordPress Plugins
    • This is quite possibly the best blog post about writing WordPress plugins.  Applying these guidelines will make you a better WordPress developer and your plugins faster, more efficient, and more awesome. :)
  7. How to Design and Style Your WordPress Plugin Admin Panel
    • In a lot of ways, a program is only as good as its user interface.  Build a good friendly and powerful interface and people will use your program.  Build a bad one and no one will use it, no matter how awesome it is.  This one blog post gives numerous little ways to make your WordPress plugin administrative interface look better.