Software Engineering in WordPress, PHP, and Backend Development

Tag: JavaScript (Page 4 of 12)

Articles, tips, and resources for JavaScript-based development.

It’s Not About Finding the Perfect JavaScript Templating Engine

We’re currently working on a project that communicates with a third-party API. The response data is returned in JSON format, so we’ve opted to take the response and pipe it into a JavaScript templating engine.

The challenge: Finding the perfect JavaScript templating engine.

Well, sort of. The thing is, finding a templating engine is pretty easy. There are plenty of them. And many of them work the same way. I’m not sure I’m in a place where I could say I have a “favorite.”

Continue reading

Manipulating WP Admin Bar Styles with Events

I’ve mixed feelings about the WordPress admin bar, but that has to do with how third-party solutions add their options to it (plus, it can be disabled if you’re not a big fan of it).

Recently, I published a small plugin – meant primarily for developers – that allows users to toggle admin notices whenever they are working with WordPress (ideally in their local environment, though it can be installed anywhere WordPress is installed).

WP Admin Bar Styles: Toggling with Events

The plugin is simple:

  • It introduces an item into the WP admin bar,
  • When you click on an item, it will toggle any notices or messages that are displayed,
  • When you click on it again, it will toggle their visibility.

But there’s a small nuance that I think is worth covering and that has to do with manipulating the WP admin bar styles using client-side code.

All of this is covered in the initial post, but one aspect of the code that I think is worth sharing for those working with the admin bar and those working with JavaScript.

Continue reading

Learning JavaScript in 30 Days (Or Less!)

When it comes to writing about learning JavaScript in 30 days or sharing a link to a resource that I know almost everyone else in the web development industry has likely heard of, it causes me to pause when writing a post about it.

Learning JavaScript in 30 Days

I mean, why bother, right? I’ve heard of it. You’ve heard of it. So what’s the point of reiterating something we’ve already heard?

Two reasons:

  1. We’re one month into 2017 and, if you’re like me, you’ve adjusted some of the goals you’ve set for yourself.
  2. The start of a month is always a good time to begin a, ahem, month-long journey.

And with that, I’m thinking that I’m going to be going through Wes Bos#JavaScript30 course throughout the month of February. (A 30-day course in the shortest month of the year. 😁 I know, right?)

Continue reading

Learn “WordPress JavaScript” (And What That Means)

Now and then, I’ll stumble across a blog post, question, or comment that talks about WordPress JavaScript as if it’s a different type of or variant of JavaScript that exists solely within the WordPress application.

For those who have been working in web development for a long time, this seems like a silly statement, but if you’re brand new to web development (regardless of your age), then this is something that might be a bit confusing.

After all, it’s not like the JavaScript standard is cut and dry right now, right? But I digress.

Furthermore, WordPress includes jQuery, jQuery UI, Backbone, and so on. So when someone wants to work with JavaScript within the context of WordPress, what are they actually talking about?

And the answer is, unfortunately, “it depends.” But it does: It depends on the type of work you’re doing and where you’re focusing your efforts.

But this brings us back to the original problem: How do you learn “WordPress JavaScript” if you’ve never even touched JavaScript?

Continue reading

IIFE For JavaScript in WordPress Development

IIFE, or an immediately-invoked function expression, is something that’s been a relatively common way of writing code in JavaScript.

It’s something that I think anyone doing any type of client-side development with WordPress should be using, but first I think it’s important to grasp the concept. Wikipedia provides a definition of IIFE:

An immediately-invoked function expression (or IIFE, pronounced “iffy) is a JavaScript programming language idiom which produces a lexical scope using JavaScript’s function scoping.

If you’re new to JavaScript, that just sounds kind of intense, right? So perhaps a better definition might be:

An “iffy” defines how variable names are related to the functions in which they are contained. Inner functions maintain the scope of their parent functions.

And finally, these functions are invoked anonymously because the function that fires literally has no name. It’s fired when the browser loads, parses, and runs the script.

So how does this all relate to WordPress?

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑