September 8, 2014
WordPress 4.0 was released on Thursday of last week and includes some really excellent improvements. In this episode we discuss the changes in WP 4.0 as well as what we have both been working on recently, including updates for WP Migrate DB Pro and Easy Digital Downloads.
This episode was sponsored by Sprout Apps, a suite of applications powered by WordPress for freelancers and small businesses.
Show Notes:
- Sponsored by Sprout Apps
- WP Migrate DB Pro v1.4.2
- Plugin build script
- Easy Digital Downloads v2.1
- WordPress 4.0 under the hood
- Big Snow Tiny Conf
PIPPIN: Welcome back to Apply Filters for Episode 25. I’m Pippin Williamson, along with my cohost Brad Touesnard.
Today’s episode is sponsored by Sprout Apps, which is a suite of business apps for WordPress built specifically for freelancers and small businesses, starting with invoices, estimates, and payments. If you want to learn more, go to SproutApps.co. We actually had Dan Cameron, the developer behind Sprout Apps, on Apply Filters last week, so if you want to learn more about the business, the product, etc., go to SproutApps.co and also listen to last week’s episode.
BRAD: Awesome!
PIPPIN: Today, we want to talk about WordPress 4.0. But before we do that, Brad, why don’t you jump in and tell us what you’ve been doing recently?
BRAD: Sure thing. We actually just released 1.4.2 of Migrate DB Pro. It’s a minor release, but it actually included a ton of code changes because it’s the first release since we re-factored everything to merge the free version and the pro version together, so there was a lot of code reorganization that went on.
PIPPIN: Mostly just like code cleanup?
BRAD: Yeah, not too much cleanup. It was mostly restructuring and just putting the glue in there that kind of binds the two together somehow.
PIPPIN: Was there any specific bugs or feature improvements that users should know about?
BRAD: Yeah, there is. Let me bring up the change log here. But before I get to that, I mentioned, I think it was last week or last episode or the one before, I mentioned about the build script we have.
PIPPIN: Yep.
BRAD: I just released that. People were interested in it, so I released it. It’s just a PHP script that basically includes certain files and excludes certain files from the building of the zip file automatically, so you don’t have to — you know, before we built this, we were manually deleting files and then zipping it up. And so it wasn’t ideal, right, because you might end up with, you know, you might forget to delete some files, or you might delete the wrong file. It’s just prone to error, right, when it’s not scripted.
PIPPIN: Right.
BRAD: Yeah, I’ve released that. We can put —
PIPPIN: This is a build script for taking the plugin folder, getting rid of any temporary files or things like Git files, and then deleting those, zipping it, renaming it, etc., and basically giving you a final zip file that you upload to your site.
BRAD: Yeah.
PIPPIN: Is that right?
BRAD: Yeah, well, yeah, I mean that’s the zip file that we release, right?
PIPPIN: Right.
BRAD: That’s the one that people end up downloading to upgrade. Yeah, that’s basically what it does. Depending on the edition, so if you’re building the free edition, I’ll remove certain files. Then if you’re building the pro edition of Migrate DB, then it’ll delete different files.
PIPPIN: This also has, for the lite edition, which would be your free version, DB Migrate DB, you also have something in your script to actually publish it directly to .org and GitHub.
BRAD: Oh, yeah, yeah.
PIPPIN: That’s cool.
BRAD: Yeah.
PIPPIN: That definitely makes pushing out that release a lot easier.
BRAD: Oh, yeah. It’s great. What happens is, when you build the free version, it asks you. It prompts you, yes/no, if you want to publish to .org, and then if you want to publish it to GitHub, because we have a private repo for the majority of the code, but we could also push some of the code to GitHub for the free version.
PIPPIN: That’s cool.
BRAD: Yeah, and it actually builds it all and gets it ready to push to a sub-version on .org and then stops. It pauses and said, “Do you want to continue?” so that you can actually go in and poke around to make sure everything looks all right before.
PIPPIN: Yeah, that’s awesome.
BRAD: Before you hit the switch and everything flows up there.
PIPPIN: Where can people find this build script? You have it on GitHub?
BRAD: Yeah, yeah, we can link it up in the show notes. You can find it through GitHub.com/DeliciousBrains, so if you go there.
PIPPIN: That’s really cool. I found that using a deployment script — so since I host all of my plugins on GitHub, both in public and private repos, having a deployment script to push them to .org any time I’m done with a release, that alone saves so much time.
BRAD: Yeah, definitely.
PIPPIN: I have a script that I use that Paul Clark wrote or that Paul Clark, I think, updated after he forked it from someone else, and it’s a huge help.
BRAD: Yeah, awesome.
PIPPIN: For sure. If anybody who is listening is interested in a deployment script, but doesn’t have one, leave a comment. I’m happy to share and walk through that.
BRAD: Yeah. Someone commented on Twitter. When I released it, I tweeted about it, and someone commented that they were using Grunt for most of their stuff. But then they said that they think they would prefer PHP just because of their code is in PHP already, right? I just kind of default to using PHP for scripts because I’m just so familiar with it, and I can do a lot with it already.
PIPPIN: Yeah, definitely.
BRAD: I know Grunt is pretty popular nowadays, and we use it for building or minifying and all that stuff. Do you guys use Grunt for EDD?
PIPPIN: We’re not using it for EDD at the moment, though we probably will in the near future, mostly for doing script and CSS minification because, at the moment, I’m lazy, and I still do that manually.
BRAD: What do you mean manually? How do you do it?
PIPPIN: I have some tools that I use to minify scripts in CSS, and so I just take the files and manually dump them through there.
BRAD: Oh, okay. Gotcha.
PIPPIN: Any time I’m ready to push out a release. But I really should do it using Grunt and just do it on commit because it’d be a lot faster and more reliable.
BRAD: Yeah.
PIPPIN: Because there have definitely been times when I’ve pushed out a release and then I realize, CRAP, I totally forgot to minify things, which is okay sometimes. But in our case we actually keep separate versions of the files.
BRAD: Yes.
PIPPIN: And we load the non-minified version automatically if you have WP Script Debug enabled.
BRAD: Yeah.
PIPPIN: But if you don’t have Script Debug, it uses the minified version. In my development environment, I’m always using Script Debug set to true in WP Config.
BRAD: Right.
PIPPIN: And so sometimes I forget and then push out a release and realize that users have an outdated version of the JavaScript or CSS.
BRAD: Right.
PIPPIN: Oops!
BRAD: Yeah. We’ve actually, because we instituted this new build script and everything, when we do our final testing before release we actually run the build and then install the zip and test it that way.
PIPPIN: Yeah, that’s probably smart.
BRAD: For that very reason because there might be files missing that shouldn’t be or whatever, so yeah. But in version 1.4.2, it’s mostly just bug fixes and really, really small improvements. But like I said, lots of re-factoring.
PIPPIN: Very cool.
BRAD: Yeah, so what have you been up to?
PIPPIN: Also doing releases. I feel like that’s kind of our general thing is either you or I am doing a release about every week.
BRAD: Yeah.
PIPPIN: Large or small. This was a pretty large release for me. We did EDD version 2.1, which we’ve been slowly working on since June. We got it pushed out on Wednesday of last week, and it was a pretty smooth release. We had a few hiccups here and there. We’ve done two minor point releases since then, but they were both to fix pretty minor issues. It had three big things in it. One was transaction ID tracking, so we’ve always tracked transaction IDs for purchases from a payment process.
BRAD: Right.
PIPPIN: But we never had a formal API that every single payment gateway would use.
BRAD: Okay.
PIPPIN: We have what are called payment notes, which are just notes on the payment records.
BRAD: Ah!
PIPPIN: And so transaction IDs would get stored there, but we never had a specific way they were stored in the database, which meant that if a payment gateway wanted to implement automatic refunds or something like that, there was not an official API to set and retrieve transaction IDs.
BRAD: Right.
PIPPIN: And so we’ve done that, and we’ve implemented that new API, and we’ve added in a way to retroactively retrieve transaction IDs from old payment records. That was pretty fun getting that.
BRAD: Yeah.
PIPPIN: We implemented a new email templating system and a new, actually, entire email class that takes care of sending purchase receipts and sending any email through EDD. Before, we had it so that purchase receipts would get a nice HTML template applied to them, but any other email sent out, either from extensions or a custom email that you built, was not able to use those HTML templates. Any email that was sent out would be sent as plain text.
For example, we have a software licensing extension that will send out renewal notices when a license key is about to expire. Well, we wanted to be able to have those emails sent out in the same template that the purchase receipts come so that everything looks consistent. Pre-EDD 2.1, it was technically possible, but really difficult. Now it’s as simple as one function call. Basically the same way you would call WP Mail, you would just call EDD email, send, and it sends everything in the template, and it also provides the API to register new template files, to modify template files, and the actual emails themselves, like the templates for them exist as an actual template file that can be tweaked any way you want.
BRAD: That’s cool. Is there a UI component to the email templates where you can–?
PIPPIN: There’s not one for the template themselves, but you can — the purchase receipt and admin sale notifications that go out, the actual message that’s sent is in a UI, so you can go and write out the message to say anything that you want, and then it has template tags built in that then get replaced with the actual data from the purchase when a purchase is made.
BRAD: Cool.
PIPPIN: At some point we may implement more of a UI for tweaking those emails, but we’re not really sure.
BRAD: Right.
PIPPIN: But that was an enhancement that I was really happy to get out because it was supposed to go in EDD 2.0, and it’s been on the books since EDD 1.9, probably, or 1.8, so it’s been kind of in the back of my head for a while. I’d been working on it for quite a while now.
BRAD: Cool.
PIPPIN: I was pretty happy with how it turned out, especially because we managed to avoid any breaking changes. Even with the preexisting templating system for emails, like we have an email templates extension that we sell that registers ten new email templates, but it uses the old API, and those still work 100%, even with the new API.
BRAD: That’s awesome. There’s nothing better to hear then when people take into account backwards compatibility.
PIPPIN: When we were building it —
BRAD: If I was using EDD, and I upgraded, and then all my custom emails broke, I’d be pretty pissed. Right?
PIPPIN: Yeah, absolutely, and as it should be. While we were building it, we were actually thinking of making it the first truly breaking change that we’d ever intentionally implemented, and we were going to try and break it gracefully, but still break it. Then once I got it finished, I decided that I didn’t like that, and I wanted to have that mindset of there is a way to do this in a backwards compatible way that will not break. I took the time, figured it out, and it ended up working perfectly.
BRAD: Awesome!
PIPPIN: Yeah. Then we had a new customer’s API, but I won’t go into too much detail. Basically we just implemented a new database layer for customers.
BRAD: Oh, okay, so it’s not like a public API where I can query customers.
PIPPIN: It is. It’s actually kind of both at the same time. It’s a new database layer for customer records that also provides all of the necessary methods for pulling customer details out, like for extension developers.
BRAD: Right.
PIPPIN: It’s actually one in the same thing.
BRAD: Right. Did you tell me you created a custom table for this as well?
PIPPIN: Yes. This is actually the first custom table EDD has used.
BRAD: Ooh!
PIPPIN: I am really thrilled to have it in a custom table finally. Early on, I was proud of the fact that EDD didn’t use any custom tables, and now I regret that decision.
BRAD: Right.
PIPPIN: I’m really glad to be slowly moving —
BRAD: Because people that have 20,000 orders are emailing you saying – performance.
PIPPIN: It doesn’t work in the default WordPress tables very well.
BRAD: Yeah.
PIPPIN: We’re slowly extracting that out and moving stuff into custom tables so that it actually queries a lot more efficient, organization makes a lot more sense. It’s easier to move data around. And so customers was the first one that that happened with. That also means that anybody who upgrades to EDD 2.1 from a previous version actually goes through an upgrade routine, and it will go through every single purchase record on the site and update that customer’s data, which could be 10 sales; it could be 10,000 sales.
BRAD: Did you use some kind of ajax to make sure that doesn’t time out?
PIPPIN: No.
BRAD: How does that work?
PIPPIN: It is using ajax. It uses some JavaScript, and it basically ends up doing a redirect, so you trigger the upgrade routine, and it goes through steps. After each step, it does a redirect to a page, which then that page triggers a new redirect with JavaScript.
BRAD: Right.
PIPPIN: And it goes back. It does step two. Then it goes back to that page, triggers a redirect with JavaScript, does step three. It can keep doing that, and it can go through thousands of steps without ever timing out.
BRAD: Right.
PIPPIN: We have had a couple of instances where it has timed out, but I don’t know why.
BRAD: It’s not a big deal anyway because you can just start it again.
PIPPIN: Exactly. If you reload the upgrade URL, basically with the step parameter, it just restarts exactly where it was before, which is really handy.
BRAD: Yeah.
PIPPIN: The actual timeout that we’ve seen, I don’t think it has to do with being too many redirects because that’s what the JavaScript is there for is to prevent that redirect loop. What’s happening is I think when it actually does a query, it finally, like the database is just tired of writing and reading, and so it just finally says, no, I’m done.
BRAD: Oh, really? Yeah.
PIPPIN: Yeah, I think that’s what it is. I’ve only had it happen twice so far, but I haven’t been able to go in and actually diagnose why it happened.
BRAD: Right. We’ve been having — there’s an issue we have with the media files add-on right now where it times out if you have a lot of media files. It’s the request where it’s trying to determine what media files are going to be downloaded and which ones aren’t.
PIPPIN: Right.
BRAD: That one times out if you have a lot, and we’ve been brainstorming ways, and we’ve been thinking about using a timer, so basically track how long the script has been executing. And, after a certain point, return and then start again, so we could actually get around any timeout by tweaking that time limit.
PIPPIN: Yeah, that’s clever.
BRAD: Yeah, so I don’t know if it’s going to work yet because we haven’t tried it, but that’s currently the winning solution so far.
PIPPIN: Very cool.
BRAD: Yeah.
PIPPIN: Well, shall we jump in and talk about WordPress 4.0?
BRAD: Sure. Why not? What’s new?
PIPPIN: Well, there are a couple of things that are pretty cool that at least I really like. I love the new plugins installer and the new plugin icons.
BRAD: Yeah.
PIPPIN: If you go install a plugin now, you go to the add new screen. Instead of seeing the list table like you’re used to, you actually now see plugin cards that show their header images, show the reviews, shows more information. It’s a really nice visual feel for the plugin installer. It just looks great.
BRAD: Yeah. It’s much more like an app store kind of.
PIPPIN: Yeah. I think it gives a better representation of what people are actually installing.
BRAD: Some people are going to hate that I compared it to the app store.
PIPPIN: Probably, but that’s okay. Then with those new plugin cards, there’s also plugin icons, so just like plugins can have headers, plugins can now have icons as well, which is just basically a smaller version of the header for most people. That makes it look — it gives it that actual visual flare that’s really nice.
BRAD: Yeah. Yeah, they did a great job.
PIPPIN: A little personality to each plugin.
BRAD: Do you know who the design or who is kind of leading the design end of this? Do you know?
PIPPIN: I did at one point. I forget whose name it is now. If you look up the main issue in WordPress Trac, it’s definitely listed there. I think it was mostly one person did the majority of it.
BRAD: Yeah, it’s hard. It’s tough to design by committee.
PIPPIN: Oh, yeah, for sure.
BRAD: Yeah. This looks great though.
PIPPIN: Yeah. I really like that reviews now get shown in the plugin installer directly, like on the plugin card.
BRAD: Yeah.
PIPPIN: It just gives you a really quick idea of how well a plugin is doing. But also then when you go to click the more details, you can actually see the reviews right there in the popup as well, so you don’t have to go to WordPress.org to read the actual reviews as opposed to just the rating, which is really slick.
BRAD: Right, because before when you went to more details, it just didn’t have that reviews tab at all, right?
PIPPIN: Right. I think it might have had a rating, but then you had to actually click on the rating to go to WordPress.org to see the reviews.
BRAD: Right, so now there’s no reason to leave your dashboard, really.
PIPPIN: Yeah.
BRAD: Unless you wanted to browse support issues, I guess, would be —
PIPPIN: Right, you can’t see the support in the installer yet, which would be kind of cool to see the recent support tickets.
BRAD: Yeah. Yeah, it would. It’d kind of give you more of a sense for how active the plugin is and stuff. Yeah.
PIPPIN: Yeah, definitely. Let’s see. What else is new in WordPress 4.0? The media grid is pretty cool.
BRAD: Yeah. I guess we should mention the icons too.
PIPPIN: Oh, yeah, in the plugin installers.
BRAD: Yeah, because the UI has been updated, but also they added the icons for each plugin.
PIPPIN: Right.
BRAD: Now if a plugin doesn’t have an icon, it’s just kind of like a, I don’t know, fractal design.
PIPPIN: Yeah, but did you see how that’s generated? It’s actually pretty cool.
BRAD: Oh, yeah? Some kind of nerdy thing?
PIPPIN: They have a script that actually goes and looks at the plugin’s header image, I think, and then detects the primary color there.
BRAD: Oh, that’s cool.
PIPPIN: And it sets the icon based upon the primary color used in the header.
BRAD: Oh, that is cool.
PIPPIN: Then if there’s no header, I think it just picks a random one.
BRAD: I thought you were going to say something like it does a hash of the author’s email address and then computes.
PIPPIN: Oh, no. That might be kind of cool though.
BRAD: Yeah, who knows? Yeah, I don’t know. It’s pretty cool that —
PIPPIN: There is a nice guide on make.WordPress.org that tells about how to add the icons for your plugin. It’s super simple. It’s very similar to registering a header image.
BRAD: Yeah.
PIPPIN: Have you gone through and updated any of yours yet?
BRAD: I have updated just Migrate DB Pro.
PIPPIN: I did EDD, and that was it.
BRAD: Yeah, the same.
PIPPIN: Just the main one.
BRAD: Yeah. Yeah. It looks really good. Then on .org, if you’re searching plugins on .org, you can also see them there as well.
PIPPIN: Oh, that’s right.
BRAD: But that one needs a little bit of designer love.
PIPPIN: It still needs a little love, but that’s okay. It’s getting there.
BRAD: First step.
PIPPIN: Yep. So then the media grid is pretty cool.
BRAD: Yeah.
PIPPIN: I don’t know if anyone had played with that before WordPress 4.0, but now the media library defaults to showing all the images and other media files directly as a grid.
BRAD: Yeah, just like in the model popup.
PIPPIN: Yep.
BRAD: If you’re on the post screen, and you go to upload a photo, or you go to insert a photo into a post, you’d get a grid display. Well, they’ve really just ported that UI to the media section.
PIPPIN: Yeah, and now when you actually click onto one of the images in the grid, it gives you all of the details for that image directly in the new media manager UI as well in a really slick UI. It’s definitely a lot better than going to whatever, like the attachment editor page was before, which still exists, but it’s not the default one that you go to. And you can edit the image directly in the popup, which is pretty slick too.
BRAD: Right. Yeah, it’s just a lot zippier than the old UI where it was the page refresh each time because now when you click on an image, it’s just – BAM.
PIPPIN: It’s just like right there.
BRAD: Yeah.
PIPPIN: Also, if you want to go through an edit captions, descriptions, alternate text, or anything like that, you can do that. It just saves immediately. You click the arrow to go to the next one, and you can just click through really quickly.
BRAD: Yeah. Anyone that spends a lot of time in the media library, they’re going to be pretty happy now, I think.
PIPPIN: Yeah. Also related to media is the new live previews for media embed. That’s frickin’ cool!
BRAD: I haven’t played with this.
PIPPIN: Okay, so here’s what you do. Go to a post or a page. Go to the editor, and just paste a YouTube video in. If you haven’t done it, do it just to try and see what it does. It’s amazing.
BRAD: Oh, I did! I totally did do this.
PIPPIN: Anything that can be — any oEmbed that’s supported, it just immediately takes it and renders the oEmbed right there in the post editor, and it takes like half a second to do it. There’s hardly any delay at all. And it’s cool because it gives you a really great idea of exactly what your post is going to look like when you publish it.
The new intro video for WordPress 4.0 explained it really, really well and gave a really nice demo. Basically, there are no surprises anymore. You don’t write a post and then publish it and find out it doesn’t look like what you want. It looks the way it does when you write it after you publish it, and that’s really cool. Scott Taylor did an awesome job on that.
BRAD: Yeah, really great job. Very cool. What’s next?
PIPPIN: What else?
BRAD: Oh, yeah, Scott Taylor’s stuff. Yeah, we’re going to link up this article in the show notes. It’s pretty awesome, his write-up. What’s the title? It’s called WordPress 4.0 Under the Hood, and it just goes into detail about what’s under the hood of 4.0.
PIPPIN: I really liked it because it was from a core contributor explaining like here’s some of the technical things that changed, which a lot of people don’t usually see unless they’re following Trac.
BRAD: Yeah.
PIPPIN: And so it was really cool to see this. I loved his — one of the things they talked about was Scrutinizer CI integration.
BRAD: Yeah.
PIPPIN: If anybody is not familiar with Scrutinizer CI, it’s a really cool tool that integrates directly with plugins, not just plugins, but PHP and other scripts on GitHub. It scrutinizes your code base and looks for simple problems. It looks for variable names that are not used or misspelled, or code duplication and things like that. Careful the first time you run it because it can be a little intimidating because it will tell you there’s 5,000 problems with this code base.
BRAD: Yep.
PIPPIN: I ran it with EDD and it told me there’s 5,000 problems. I was like, oh, ouch!
BRAD: Yeah.
PIPPIN: It’s just because it’s looking at every single little detail, and a lot of them aren’t even necessarily problems. It’s just saying, oh, this is something that might be an issue.
BRAD: Yeah. It’s probably good in the long run, though, to go through and clean those up.
PIPPIN: Absolutely.
BRAD: Yeah.
PIPPIN: It tells you about code duplications, variables, and other things like that, but it also tells you, like any time you do a commit, it’ll tell you if you fixed issues or if you introduced new ones.
BRAD: Yeah.
PIPPIN: It actually caught me the other day because I committed something and accidentally missed, like renamed a variable, like as a typo.
BRAD: Oh!
PIPPIN: And it said, “Hey, you introduced a new issue.” I looked and, oh, sure enough. And so it actually fixed that bug for me. It didn’t fix the bug, but it told me there was a bug before I ever figured it out in the wild, which is pretty cool.
BRAD: We use Scrutinizer as well, and it’s really cool. What happens when you open a pull request, it integrates with GitHub, and so it shows you, kind of in the pull request status, basically how many issues were introduced and how many kind of outstanding, I guess, so that’s pretty cool.
PIPPIN: Yeah. After I set it up, I was really happy that I did. I spent about an hour or two kind of going through and doing a bunch of little fixes here and there. After I did that, now it’s just kind of an ongoing thing that gives me an idea of are we cleaning up the code base over time.
BRAD: Yeah.
PIPPIN: Scott actually linked to a specific commit for WordPress where he used it, and it was basically there was a variable that was just sitting there never used, and it had been there for years. Scrutinizer found it, and it allowed him to quickly remove it.
BRAD: Right. When you set up Scrutinizer, it’s super easy. You just point it at your GitHub repo, pretty much, and then it just picks up. It emails you every time you make a commit, pretty much, I think.
PIPPIN: Yep. Yeah, it took, what, like five minutes to set up, if that.
BRAD: Yeah. But what you can do is you can add a .scrutizer.yml file to the route of your project, and you can actually configure it for WordPress, so it’ll actually complain about any WordPress coding standard issues. For example, if you don’t put spaces after your parentheses, it’ll complain about that.
PIPPIN: I didn’t realize that.
BRAD: Yeah, yeah.
PIPPIN: That’s cool. I need to do that.
BRAD: Yeah, because now you’re going to have 10,000 issues.
PIPPIN: Oh, yea, so many to go through and fix.
BRAD: Yeah. There are some of those, like there’s some WordPress coding standard things that we don’t agree with, that we don’t abide by.
PIPPIN: Yeah.
BRAD: There was one.
PIPPIN: The main one that I don’t like, and this is super nitpicky. I cannot — in an array, the official coding standards say that you should have a comma after the last item in the array.
BRAD: Really? Oh, man! I didn’t see that one.
PIPPIN: And I disagree.
BRAD: Yeah.
PIPPIN: To me, it irks me. No, I don’t want a comma. To me it’s like improper grammar almost.
BRAD: You know why I don’t like it? Because it’s like, oh, no, Internet Explorer is going to break, right?
PIPPIN: In JavaScript it does.
BRAD: I know! That’s why I’ve always never done it, right?
PIPPIN: Yeah. Actually, I remember a very specific problem that I had one time where Internet Explorer just didn’t like my JavaScript. I was like, what is going on? This is perfect. And it was because of that last comma in the variables, and I had no idea.
BRAD: Yeah.
PIPPIN: I’m pretty sure that’s just carried over to me in PHP.
BRAD: Yeah. Yeah, the one we just debated was the self-explanatory flag values for function arguments. There’s a block in the PHP coding standards for WordPress that talks about this. For example, if you have a function called “eat”, and the parameters are “what” and “slowly=true”, that’s bad. What you want is “speed=”, and then string “slowly” so that when you’re calling “eat” later on, you could do something like “eat mushrooms slowly”. Right? So that when you’re calling the functions, it’s not going to be “eat mushrooms true”. It’s going to be “eat mushrooms slowly”.
PIPPIN: I totally agree with that.
BRAD: You would agree with it? Oh, man.
PIPPIN: Well, here’s the thing. I think there are certain use cases where you’ll find it just doesn’t make sense because you want a bullion value.
BRAD: Yeah.
PIPPIN: You want true or false. But if you have one that might end up having multiple values, for example for your example: slowly, moderately, quickly.
BRAD: Right.
PIPPIN: But you can’t do that in bullion. You have to do a variable like string.
BRAD: I agree. I agree with that point.
PIPPIN: And so there it makes sense.
BRAD: Yeah, I agree with that point, but that’s not what it’s saying. It’s saying specifically for true/false.
PIPPIN: It’s saying that the function call itself, you should be able to read the function call and the parameters without knowing, without looking at the function definition.
BRAD: Yeah, but it’s specifically saying that for parameters that are true/false parameters that it should be a string.
PIPPIN: Yeah, I don’t necessarily agree with that.
BRAD: Yeah.
PIPPIN: I agree with being able to understand exactly what it does.
BRAD: Yeah. But, I mean, here’s the thing. Here’s what it came down to for us is what kind of won the argument is that we all have editors and IDs that you right click on the function name and jump right to the function declaration instantly, and you can see the parameters. It doesn’t really — the readability is not that critical.
PIPPIN: No.
BRAD: Also, the likelihood that you’re going to typo those strings, like if you put in “slowly” and swap the W and O by accident or something, then your code will have a bug in it, and you’ll never know. If you spell true or false wrong, your PHP is going to fail, right?
PIPPIN: That’s true, yep.
BRAD: And it’s going to let you know. We went over a few different points, and it was an interesting conversation. I love having these conversations with the team.
PIPPIN: One of the other big changes in WordPress 4.0 that actually has no impact whatsoever on users, and actually has very — no, it does have impact on developers, but it’s one of my favorite changes, and that is another one that Scott Taylor championed. That was removing the usage of the extract function from WordPress Core.
BRAD: Yep.
PIPPIN: WordPress Core used to use extract in 100 locations maybe, maybe a little under. Somewhere between 50 and 100, and he has removed every single one of them except one.
BRAD: Yes.
PIPPIN: I applaud that effort. I actually recently did the same thing in EDD. We removed every single instance of extract. Brad, are you for or against the usage of extract?
BRAD: Pretty much against, and the reason is because of pretty much what I just said about the strings. It’s bad for debugging, right?
PIPPIN: It’s horrible for debugging, and Scrutinizer will yell and scream at you.
BRAD: Yeah. Yeah, Scrutinizer does not like extract at all.
PIPPIN: For anybody who isn’t familiar with extract that much, extract basically allows you to pass in an array, or I think it also takes an object of variables, say an array of key value pairs, and it will take every single key and create a new variable based on that key name and then set its value to the value of the key in the array. If you have an array that says “color blue”, then you’ll have a new variable called “color” that will have a value of “blue”. It could be really handy because it can allow you to take a big array and just make the variables available.
BRAD: Yeah.
PIPPIN: But it’s also, I think, really dangerous because, when you’re reading through code, all of a sudden you see all of these different variables that magically appeared out of nowhere, and you have no idea where.
BRAD: Yeah.
PIPPIN: And there’s no way to backtrack them until you find that usage of extract. And so it’s really easy to get lost when you’re trying to debug code if there’s an extract.
BRAD: Yeah, and it’s dangerous for introducing bugs when you’re editing code or you’re working on a new feature or something because, if you’re using a variable below extract and then all of a sudden the array gains a new key with that variable with the same name as the variable you’re using down below extract, it’s going to overwrite that variable, right?
PIPPIN: Yep. It’s kind of a nasty function. It’s very useful, but it’s one that I think, when you first get into development, you play with, and you’re like oh, this is so cool, especially once you figure out what the heck extract does. But then later on you realize that it’s really dangerous.
BRAD: Yeah. Luckily, like most of the instances I’ve seen extract used is usually at the very top of a function, so the dangers are a little less. It’s a little less dangerous than if you’re just running extract half way down the function somewhere.
PIPPIN: Yeah. Outside of it possibly being difficult to debug and things like that, it also just freaks out code analyzers like Scrutinizer that we mentioned earlier, freak out with it because it sees all these variables that were never defined that are being used. And so if you’re using a code analyzer tool, whether it’s Scrutinizer or something else, it’s going to yell at you if you use extract. Honestly, I think it’s with good reasons. You could ignore it, but I think it’s better just to avoid using it all together.
BRAD: Yeah, I agree. Your code is going to be more verbose, but in this instance I think it’s a good thing.
PIPPIN: Tell you what. If you’ve ever spent an hour and a half debugging an issue trying to figure out where the heck a variable is coming from, only to, after an hour or two, discover it’s coming from extract, you’ll understand the pain.
BRAD: Yeah, exactly. Cool. What else is new in 4.0?
PIPPIN: There are two other new, little changes that Scott included in his Under the Hood stuff that I like. One is that WP Insert Post and WP Insert Attachment, which used to be separate functions, are now the same thing. I think WP Insert Attachment just calls WP Insert Post, so the code got a little lighter. You have uniform hooks set up that they all call the same hooks, the same filters, etc.
BRAD: That’s cool.
PIPPIN: Then the same thing happened with WP Handle Upload and WP Handle Side Load are now also the same function, if you’ve ever used either of those.
BRAD: Yeah, I always found that odd, the Side Load thing.
PIPPIN: I always thought it was the goofiest function name. I never understood what Side Load meant.
BRAD: Yeah.
PIPPIN: But it is a cool function.
BRAD: It’s totally a goofy name because isn’t side loading when it’s downloading a file from a URL?
PIPPIN: Yep.
BRAD: And then inserting it into the media library.
PIPPIN: Yep.
BRAD: Right, right. Yeah, isn’t that more of a download to me?
PIPPIN: Yeah, that’s what I always thought. I was like, why isn’t it maybe like Retrieve File or Copy File or something.
BRAD: Yeah, yeah, yeah.
PIPPIN: Side Load never made sense to me, but anyway, if you use those, it might be important to you to know that they are now the same. There’s one other change that, Brad, I don’t know if you’ve experienced this one yet, but honestly I think it downright magical. It’s the way that the post editor now scrolls with you is beautiful.
BRAD: Oh, yeah. Yeah.
PIPPIN: I’ve seen some people say they don’t like it, but I think it’s amazing.
BRAD: They don’t like it because it’s different.
PIPPIN: Yeah, that’s true. Once they get used to it, they’ll just assume it’s always been there, and they’ll love it.
BRAD: Yeah, they are going to get used to it because, I mean, it’s better.
PIPPIN: I saw somebody on Reddit in the WordPress sub Reddit after somebody — they put up the 4.0 release and it was basically like, hey, everybody; what do you think? What do you like that’s new? And one person said the auto scrolling with the post editor is practically orgasmic.
BRAD: Wow!
PIPPIN: …agree with that, but it’s awesome though. But if you’ve ever been affected by what that fixes, you’ll really appreciate it. That’s basically where, like, if you — I think it’s more important on smaller screens. But as you’re scrolling down, you’re trying to scroll in the editor. You get to the bottom of your content, and then suddenly your page starts scrolling. It’s kind of annoying.
BRAD: Yeah. Yeah.
PIPPIN: That’s a big change that I like a lot.
BRAD: Yeah. It wasn’t great the other way. I don’t know how people can criticize it, to be honest. Do you know what people are complaining about specifically?
PIPPIN: I saw a comment where somebody was criticizing it, but I don’t remember what it was. Honestly, it seemed to be such a little thing that I didn’t understand why it was a problem for them.
BRAD: Ah, yeah.
PIPPIN: They also added additional embed supports, including YouTube play list, College Humor, and Ted Talks are now all supported by oEmbed.
BRAD: Neat.
PIPPIN: Yeah. Is there anything else that you’ve noticed or that you liked, Brad?
BRAD: No. I like that they didn’t break anything, that it’s backwards compatible.
PIPPIN: I was about to ask this. How about this? Have you experienced any issues in your plugins related to WordPress 4.0?
BRAD: I don’t think so. No, I think everything is — yeah. We’ve been testing with the nightly releases, so basically trunk, right? Yeah.
PIPPIN: Nothing unexpected for sure.
BRAD: No, no, just our own bugs.
PIPPIN: Nice. Very cool. If anybody has anything else that they like about 4.0 or anything they want to throw out that was changed, added, or removed, feel free to drop it in the comments. Let us know. Obviously with over 300 or 400 changes, we didn’t even get close to covering everything. The list of contributors for 4.0 was huge. I think it was around 250 people are in the contributions credit list this time, which is awesome.
BRAD: Yeah.
PIPPIN: Also, 4.0 was led by Helen Hou-Sandi, who we had on as a guest in Episode 23. If you want to hear her talk a little bit more about the experience of leading 4.0, that would be a good episode to go back and listen to.
BRAD: Yeah, for sure. Yeah, so I just want to say thanks to Helen and everyone else who worked on 4.0. You hear a lot of people criticizing, oh, there’s barely anything new or anything. But you just have to spend two seconds in Trac to see how much work these people put into this.
PIPPIN: Yeah.
BRAD: It’s staggering.
PIPPIN: There’s so much work going on behind the scenes that people don’t see.
BRAD: Yeah.
PIPPIN: 4.0, a lot of people I’ve seen criticize that there’s not enough new features. First of all, whatever, but the amount of work that’s gone in, the number of code changes and improvements that have gone into 4.0 are awesome.
BRAD: Yeah.
PIPPIN: Yeah. Thank you to Helen and everyone else that was involved with it.
BRAD: For sure.
PIPPIN: Anything else you want to throw out there, Brad, before we wrap up here?
BRAD: Yeah. I might as well mention Big Snow Tiny Conf again, so BigSnowTinyConf.com. Check it out and sign up to our email list. We are going to be releasing tickets for sale this month, so in the next few weeks.
PIPPIN: How many people are you looking to get there?
BRAD: We’re not capping it yet. We’re going to see what happens.
PIPPIN: Very cool. How many did you have last year?
BRAD: We had seven sign up, and then there were flight cancellations. Only five made it. That was a good number of people. They really enjoyed the kind of small atmosphere. They kind of felt like a family, almost, by the end of it.
PIPPIN: Yeah, that’s awesome.
BRAD: We’re kind of thinking of recreating that, even if we have a bigger turnout, by just grouping houses, so grouping people, like five, six people in a house.
PIPPIN: Very cool.
BRAD: That’s just an idea. We haven’t decided on anything yet. We might get a big house for everyone. It depends how many people we get, so we’ll see what happens.
PIPPIN: Very cool.
BRAD: Yeah.
PIPPIN: Awesome.
BRAD: Yeah. I guess, review us on iTunes is the other thing.
PIPPIN: Yeah, definitely. We had somebody review us the other day, and that was awesome, and they got a nice, little review of their plugin out of the deal as well, so that offer still stands. I’ll be more than happy to review your plugin or your theme, give you a little feedback on it, write you a review on WordPress.org, etc. Make a little trade.
BRAD: For sure.
PIPPIN: I want to throw out one more note for our thanks to our sponsor. This is Sprout Apps, which is SproutApps.co online. The lead developer is Dan Cameron, who we had on last episode. If you want to hear a little bit more about his business and his venture with Sprout Apps, go check it out. Thanks to him for sponsoring.
BRAD: Yeah, thanks, Dan.
PIPPIN: Awesome. And to everybody – two weeks.
BRAD: Yeah, for sure. See you, everybody.
Leave a Reply