Today was the launch of WordPress 4.0, led by my friend, Helen Hou-Sandí. Helen was a great lead and easy to collaborate with. She had her hands in everything – I was hiding in the shadows dealing with tickets and architecture.
Way to go @wonderboymusic for having just shy of 40% of the commits made to WordPress 4.0. WordPress is #blessed to have you.
— Aaron Jorbin (@aaronjorbin) September 4, 2014
It seems like just 4.5 months ago I was celebrating the release of WordPress 3.9, probably because I was … “Some people, when they ship code, this is how they celebrate”:
[OLD INSTAGRAM POST]
WordPress 4.0 has an ominous-sounding name, but it was really just like any other release. I had one secret ambition: sweep out as many cobwebs as I could from the codebase and make some changes for the future. LOTS of people contribute to WordPress, so me committing changes to WordPress isn’t a solo tour, but there were a few things I was singularly focused on architecturally. I also contributed to 2 of the banner features in the release.
Cleanup from 3.9
- Fixed RTL for playlists
<track>s when used as the body of a video shortcode
- You can now upload
- Added code to allow the
loopattribute to work when MediaElement is playing your audio/video with Flash
- MediaElement players now have the flat aesthetic and new offical colors
You can now overide all MediaElement instance settings instead of just
- Bring the list of
upload_filetypesfor multisite into modernity based on .com upgrades and supported extensions for audio and video.
- In the media modal, you can now set artist and album for your audio files inline
- Gallery JS defaults are easier to override now: https://core.trac.wordpress.org/changeset/29284
Scrutinizer CI is a tool that analyzes your codebase for mistakes, sloppiness, complexity, duplication, and test coverage. If you work at a big fancy company that employs continous delivery methodologies, you may already have tools and instrumentation running on your code each time you commit, or scheduled throughout the day. I set up Scrutinizer to run everytime I updated my fork of WordPress on GitHub.
Scrutinizer is especially great at identifying unused/dead code cruft. My first tornado of commits in 4.0 were removing dead code all over WordPress core. Start here: https://core.trac.wordpress.org/changeset/28263
A good example of dead code: https://core.trac.wordpress.org/changeset/28292
extract() sucks. Here is a post about it: https://josephscott.org/archives/2009/02/i-dont-like-phps-extract-function/
Long story short: I eliminated all* of them in core. A good example: https://core.trac.wordpress.org/changeset/28469
* There is one left: here
Hack and HHVM
Facebook has done a lot of work to make PHP magically fast through HipHop, Hack, and HHVM. HHVM ships with a tool called
hackificator that will convert your
.php files to
.hh files, unless you have some code that doesn’t jive with Hack’s stricter requirements.
While I see no path forward to be 100% compatible with the requirements for
.hh files, we can get close. So I combed the hackificator output for things we COULD change and did.
WordPress has always dipped its toes in the OOP waters, but for a long time didn’t go all the way, because for a long time it had to support aspects of PHP4. There are still some files that need to be PHP4-compatible for install. For a lot of the classes in WordPress, now was a great time to upgrade them to PHP5 and use proper access modifiers (Hack also requires them).
I broke list tables several times along the way, but we cleaned them up and eventually got there.
wp_insert_post()/wp_insert_attachment() are now one
These two functions were very similar, but it was hard to see where they diverged, ESPECIALLY because of
extract(). Once I removed the
extract() code from them, it was easier to annotate their differences, however esoteric.
- Done here: https://core.trac.wordpress.org/changeset/28579
- Reverted because I blew up wordpress.com here: https://core.trac.wordpress.org/changeset/28601
- Made whole again here: https://core.trac.wordpress.org/changeset/28788
wp_handle_upload() and wp_handle_sideload() are now one
Similar to the above, these functions were almost identical. They diverged in esoteric ways. A new function exists,
_wp_handle_upload(), that they both now wrap.
Done here: https://core.trac.wordpress.org/changeset/29209
wp_script_is() now recurses properly
Dependencies are a tree, not flat, so checking if a script is enqueued should recurse its tree and its tree dependencies. This previously only checked its immediate dependencies and didn’t recurse. I added a new method,
And oops: https://core.trac.wordpress.org/changeset/29253
Make/Core post about it: A more powerful ORDER BY in WordPress 4.0
LIKE escape sanity
I helped @miqrogroove shepherd this: https://core.trac.wordpress.org/changeset/28711 and https://core.trac.wordpress.org/changeset/28712
Make/Core post: like_escape() is Deprecated in WordPress 4.0
This was all @miqrogroove, I just supported him. He crushed a lot of tickets and made the function a whole lot faster. We need people like him to dig deep in areas like this.
Potential roadmap for taxonomy meta and post relationships: there is one
We cleared one of the major tickets: #17689. Here: https://core.trac.wordpress.org/changeset/28733
Variable variables are weird and are disallowed by Hack. Allows you to do this:
$woo = 'hoo'; $$woo = 'yeah'; echo $hoo; // yeah!
I removed all(?) of these from core … some 3rd-party libraries might still contain them.
Started that tornado here: https://core.trac.wordpress.org/changeset/28734
One of my favorite commits: https://core.trac.wordpress.org/changeset/28743
I did a lot of cleanup to Unit Tests along the way. Unit tests are our only way to stay sane while committing mountains of new code to WordPress.
- Fixed spillage across Testcase instances based on rewrite: https://core.trac.wordpress.org/changeset/28964 and https://core.trac.wordpress.org/changeset/28966
- This took me 3-4 hours late one Friday night: https://core.trac.wordpress.org/changeset/29120
In 3.9, I worked with Gregory Cornelius and Andrew Ozz to implement TinyMCE previews for audio, video, playlists, and galleries. We didn’t get to previews for 3rd-party embeds (like YouTube) in time, so I threw them into my Audio/Video Bonus Pack plugin as an extra feature. Once 4.0 started, Janneke Van Dorpe suggested we throw that code into core, so we did. From there, she and Andrew Ozz did many iterations of making embed previews of YouTube, Twitter, and the like possible.
Other improvements I worked on:
- When using Insert From URL in the media modal, your embeds will appear as a preview inline.
- Added oEmbed support for Issuu, Mixcloud, Animoto, and YouTube Playlist URLs.
- You can use a
embedshortcodes now, instead of using the shortcode’s body (still works, but you can’t use both at the same time)
- I added an embed handler for YouTube URLs like:
http://youtube.com/embed/acb1233(the YouTube iframe embed URLs) – those are now converted into proper urls like:
- This is fucking insane, I forgot I did this – if you select a poster image for a video shortcode in the media modal, and the video is confirmed to be an attachment that doesn’t have a poster image (videos are URLs so that external URLs don’t have to be attachments), the association will be made in the background via AJAX: https://core.trac.wordpress.org/changeset/29029
While we were working on embeds, we/I decided to COMPLETELY CHANGE MCE VIEWS FOR AUDIO/VIDEO:
In 3.9, we were checking the browser to see what audio/video files could be played natively and only showed those in the TinyMCE previews. Now we show all of them. This is due to the great work that @avryl and @azaozz did with implementing iframe sandboxes for embeds. I took their work and ran with it – completely changed the way audio/video/playlists render in the editor. The advantage is that the code that generates the shortcode only has to be in PHP, needs no JS equivalent.
@ericandrewlewis drove this train for most of the release. I came in towards beta to make sure all of the code-churn was up to Koop-like standards and dealt with some esoteric issues as they arose. It was great having my co-worker dive so deep into media, another asset to the core team who greatly needs people what knowledge of that domain.
As an example of the things I worked on – I stayed up til 6am one night chatting with Koop to figure out how to attack
media-models.js. Once I filled my brain, I got to places like:
So many contributors
There are too many people, features, and commits to mention in one blog post. This is just a journal of my time spent. You all rocked. Let’s keep going.
Pingback: WordPress 4.0: Under the Hood | The WordPress C(h)ronicle
Thanks man…. ~40% of the commits? I’ll buy you a beer if/when we ever meet. Cheers sir, and thanks again for helping WP and everybody that uses it.
I’m in love with that code
This is why I’ve always wanted to contribute to core 😀
Thanks for all the hard work!
Pingback: WordPress 4.0 „Benny“ | Separatista
Pingback: This Week In WordPress: Sep 8, 2014 - Max Foundry
Awesome job Scott. I love the commentary on all the milestones you worked through. Love your work.
A huge THANK YOU for all that you do, all your hard work, time commitment and dedication. You are so appreciated!
Wow! Thank you very much!
Great work on WordPress and thank you for explaining the changes under the hood.
Waw! Where was all the other guys? 😀
Pingback: This Week In WordPress: Sep 8, 2014
Pingback: MadGlory Interactive | WordPress Focused WordCamp Saratoga Arrives This October
Pingback: “Benny” maakt werken met WordPress nóg makkelijker - Vevida
Great job Scott!
The “Benny” would not be better without your great touch, Scott! You are a Taylor and you have successfully tailored many incremental yet critical updates.
Well, WordPress 4.0 is being acknowledged on many, many sites for being one of the most … ‘meh’ versions ever released, it doesn’t deserve a ‘4.0’ version bump. Hope 4.1 brings something really ‘new’ this time.