Software Engineering in WordPress, PHP, and Backend Development

Category: Notes (Page 16 of 50)

Notes on programming-related problems that I’ve encountered while working on various projects.

Get The Post Type of the Current Post with JavaScript

Whenever you need to get the post type for a given post, there are a couple of ways to do this:

  • If you’re in the dashboard, then you can use `get_current_screen()` and then access the `id` property of the object that’s returned. You can read more about this in the Codex.
  • If you’re on the front-end (or even in the dashboard, really), you can use `get_post_type`. This is also covered in the Codex.

But what if you want to grab the post type of the post that’s currently being edited on the client-side (read: via JavaScript)?

Continue reading

How To Remove WordPress Meta Boxes

Out-of-the-box, the meta boxes that WordPress displays on the dashboard aren’t exactly overkill. I mean, if you’re a blogger, then I think the chances are strong that you’ll need:

  • Publish
  • Categories
  • Tags
  • Comments
  • And maybe the Excerpt feature (depending on your theme)

But if you’re building a solution for someone else where that information is irrelevant, wouldn’t it be worth removing the WordPress meta boxes to make the dashboard a little bit cleaner with less irrelevant options?

Continue reading

Adding a TinyMCE Button to WordPress: The Button

Throughout this series, I’ve been talking through the process of how go about adding a TinyMCE button to WordPress – specifically, adding a custom button to the post editor.

Up to this point, I’ve covered a number of different things. Namely:

The thing is, we haven’t actually made anything happen in the editor let alone even introduce a button into the actual editor yet.

In this post, we’ll do exactly that.

Continue reading

Adding TinyMCE Dependencies in WordPress

If you’ve been following along with previous articles you know that over the last few days I’ve been working through a series on adding a TinyMCE button to WordPress.

Though this post isn’t exactly part of that series, it’s tangentially related and I thought it was something worth covering in case someone else stumbles across their problem in their work or if the code that shows up later in said series shows what’s up but doesn’t do a great job explaining it.

In short, when you have a JavaScript file that is a dependency on the core plugin, there’s another way of adding the dependency that does not include wp_enqueue_script.

Continue reading

Adding a TinyMCE Button to WordPress: The Plugin

If you’re interested in adding a TinyMCE button to WordPress, then this series of articles aims to do just that. In the first post of the series, I walked through some of the basic things that need to be done in order to get started with adding a custom button.

My very own copy TinyMCE Editor. Show spectacular.

My very own copy TinyMCE Editor. So spectacular.

I laid out the file organization, the basic plugin structure, some of the foundational JavaScript, and started working on the hooks that are necessary for adding a custom button.

As it stands right now, the functions responsible for adding a new button aren’t actually defined within the context of a class much less hooked into the plugin itself. So in this post, we’ll take a look at exactly how to do exactly that.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑