Adding a Draggable/Sortable Multi-Checkbox Control to the WordPress Customizer

Justin Tadlock has made the world an offer: Come up with an idea for a new control in the WordPress customizer, and he’ll provide some help in coding it, or suggest a contact who perhaps can. Today, he blogged about a multi-checkbox control, which I have been working on lately as well. My example incorporates a sortable/draggable interaction that I’d like to add to the discussion via a brief tutorial.

When I say draggable/sortable, I am referring to the jQueryUI interaction. Here’s how it would look when we’re done:

drag

I have a text field showing after the checkbox group, storing the content and order of the checkboxes. That would be swapped to a hidden form input for production, but for now it’s helpful to see the values change in the text field. You’ll also note that some of the checkboxes contain <select> menus, a feature that bloats my code far beyond beyond what I was expecting.

This ended up being a lot of JavaScript, probably more than I am qualified to write, and definitely more than I’m qualified to write about, but if the worst thing that can happen is that someone explains why it’s a hack, I’ll learn from it. So, here it is:

And the php component:

There is a bit more work to do, to register settings that use this custom control, but there is robust documentation on that elsewhere:

WordPress Function for Performing a Plugin Update Routine — Or Not?

Today I was updating my Ecwid plugin such that the widgets load via ajax. One of the steps there involved creating a url that would respond to requests for widget markup, such that I could easily feed that url to jQuery’s excellent load() function. However, when I pushed this from my local to one of my test installs that’s actually on the web, I found that the url was 404’ing because I needed to flush the rewrite cache. I wouldn’t want my plugin users to have to do that themselves, so I added a class to my plugin to perform arbitrary functions upon plugin update.

more… WordPress Function for Performing a Plugin Update Routine — Or Not?

Dear Possible New Client…

I found myself spending quite a bit of time today outlining the options for getting online as a blogger/website owner. Some themes emerged from this that I think make for an interesting glance of what it is to “have a blog” on today’s web. Without further ado:

Hey Marcus,

Very nice, thanks for that information. Based on what you’ve told me, you have three options in front of you, and they all vary based on the following qualities:

  • Time required from you.
  • Money required from you.
  • The number of options at your disposal as the owner of this website.
  • The quality of the options at your disposal as the owner of this website.

Option #1: Stay on WordPress.com, but with some upgrades

  • Upgrade to a premium theme (maybe $80, one-time) that comes closest to meeting your goals, and also buy a proper domain name (maybe $20, annually).
  • Grab some of their free plugin functionality, which I see does seem include a twitter feed on your blog.
  • Understand that you are one animal in a very large herd of other animals, so you will have absolutely no recourse if you need custom work. Options are few.
  • Understand that if a solution is available on WordPress.com, it’s going to be extremely secure, performant, well-supported, accessible — only top-shelf stuff makes it onto wp.com. Options are high-quality.
  • You can pay me my hourly rate to help with any of this. Probably would not exceed 8 hours.
  • You would spend very little time on config/maintenance. It would be as ready as it’s ever going to be, really quickly.

Option #2: Leave WordPress.com, buy some internet real estate, host your own copy of WordPress, but rely on community tools.

  • Buy hosting and a domain name (I generally recommend BlueHost), maybe $90 per year.
  • Install a copy of WordPress, which you would download from WordPress.org — as opposed to WordPress.com.
  • Install free themes and plugins from WordPress.org, or paid themes and plugins (maybe $50 per pop) from ThemeForest. ThemeForest actually has a much lower barrier-to-entry when it comes to quality. You are generally better off with WP.org stuff since it gets so much community/peer-review. That said, themes and plugins from WP.org will still have more warts than what you’d find on WP.com.
  • There are something like 40,000 plugins available on WP.org. I happen to be the author of four of them, and also one theme. Given all of those options, you can probably meet most of your desirables from these community tools. Options are many, but options are lower/moderate in quality.
  • You can pay me my hourly rate to help with any of this. Probably would not exceed 21 hours.
  • You will spend some time doing maintenance at some point, although it’s hard to say how much. Maybe you need to click buttons to update a plugin, or maybe your site gets hacked and you have to get BlueHost to rollback to a saved copy.

Option #3: Buy some internet real estate, host your own copy of WordPress, and pay me to make you exactly what you want.

  • Buy hosting & domain, install WordPress (I can help with that), just like option 2.
  • You enter the process of being a client, kind of like if someone was building you a mountain bike to spec, to include welding the tubes together to make the frame, and assembling the spokes into the wheel (I am not a mountain-bike person, so forgive my vocab).
  • Options are moderate/high in both quality and quantity — If I can build it, you can have it, and I have been doing this for a very long time.
  • Everything would be at my hourly rate. Probably about 55 hours.
  • Maintenance burden on you is the same as #2.

Caveat: You spent a lot of time in your last email talking about integrations with third-party services such as Facebook and Twitter. Understand that if a solution works today, but Twitter changes their API tomorrow, your solution may not work tomorrow, and there is no guarantee that someone will repair your solution. That’s just how the internet works.

One thing you didn’t mention was email subscriptions to your blog. You’d want to work that in as well, and there are options for that at each of the three tiers I outlined above. Ditto for analytics — You’ll want a way of knowing more about your audience.

Names changed to protect the innocent, but the rest is based on a true story. I find myself taking on the role of more of a client-educator / WordPress ambassador, rather than just a programmer, which I think is a good thing.

New WordPress Plugin: Widgets Avalanche for Ecwid

For the past few weeks I have been working on a plugin to integrate the new Ecwid API with WordPress. It’s called Widgets Avalanche for Ecwid:

https://wordpress.org/plugins/ecwid-widgets-avalanche

This plugin does two things:

  • Gives you a UI for connecting your store to your WordPress install (AKA getting an authentication token).
  • Gives you a bunch of widgets for outputting your Ecwid products and categories in interesting ways.

Right now, it ships with three different widgets:

  • A popup.
  • A slider.
  • An accordion.

The plugin is very simple from an admin and visitor perspective, but it is packed with hooked and pluggable functions, making it 100% customizable from a developer perspective.

I think Ecwid is a phenomenal e-commerce platform and it’s my first choice when clients ask me about creating an online store. But until now, there have been very few options when it comes to showcasing your products beyond the Ecwid defaults.

Check it out!

Published on CSS-Tricks!

Much thanks to Chris Coyier for accepting me as a guest author on css-tricks today!

I wrote a brief article about altering the CSS classes that WordPress generates by default, giving them a more SMACCS-friendly naming scheme.

SMACCS-Press!