Software Engineering in WordPress, PHP, and Backend Development

Author: Tom (Page 372 of 423)

The Problem of No Coding Standards For JavaScript in WordPress

This is the first post in the series JavaScript in WordPress. Be sure to read the final article, too!

JavaScript in WordPress

One of the challenges of building projects on top of WordPress is that there are well-defined coding standards specifically for PHP-based components. There are even some guidelines for HTML, and the CSS guide is under construction, but there appears to be very little in way of coding standards for JavaScript in WordPress.

I’m certainly not going to be defining those standards here – that belongs in the Core Contributor Handbook, right? – but I am doing to be sharing my thoughts on JavaScript in WordPress and some of the things that I do in order to make sure that my projects and that my team’s projects are maintainable over time.

Continue reading

Introducing #notes For Capturing Blogging Notes

Occasionally, I share some of the work that my team at 8BIT has been working on. Up until recently, we were focused heavily on Standard for both self-hosted blogs and for WordPress.com.

The thing is, we’re not trying to be another theme shop. In fact, our ultimate goal is to try to make the best products possible for people who consider themselves to be or who are aspiring to be digital publishers.

This may include developers and designers, but more often than not, this includes people who care about sharing their thoughts, opinions, views, and general words about any given topic.

And we want to empower them.

The challenge, though, is that we don’t always have our digital devices with us, but for anyone who has blogged for a significant amount of time realizes that inspiration or ideas can hit at any time.

To that end, we saw a need to help others take blogging notes. Friday, we officially announced, released, and began shipping #notes. Continue reading

How To Use WP_User_Query For WordPress User Queries

Earlier this week, I published a post on how to find users in WordPress by using meta data. In short, I have a collection of users each of which have unique meta data and I needed to locate a user based on said meta data.

In the comments, Curtis of @WPThemeTut recommended I check out WP_User_Query as opposed to way that I was doing it (which I’ll cover momentarily).

Because the WordPress API has a tendency to introduce new functions for querying specific data in later releases, and because I try to be a proponent of using the newer methods, I wanted to cover WP_User_Query in a bit more detail.

Continue reading

How To Find a User By Meta Data in WordPress

Thanks to Curtis for giving a heads up to WP_User_Query - it's a nicer alternative to the original post.

One of my favorite things about the WordPress API is the ability to store custom meta data with objects such as pages and users. I’ve been working on an application where this scenario has presented itself:

  • The end user is able to create a company
  • Each company can have an administrator based on users in the system

To do this, I’m creating a relationship between the company and user by associating the company’s ID as part of the user’s meta data.

Later in the application, I need to retrieve each administrator for each company which has required the use of a helper function to get a user by meta data.

The details of how I’m doing this are aren’t exactly interesting for this post, but I figured that this was a common enough issue and easy enough to generalize that I’d share how to programmatically get a user by meta data in WordPress:

Continue reading

« Older posts Newer posts »

© 2024 Tom McFarlin

Theme by Anders NorenUp ↑