Today I Learned - Rocky Kev

TIL about joke variables names in WordPress

POSTED ON:

TAGS:

The vast majority of users are likely unaware of this joke unless they enjoy trawling through the 6,000+ lines of code in /wp-includes/formatting.php. There is a good chance that any developer who has looked up the wpautop() function has stumbled upon it.

What is a $pee, exactly? It is text. Therefore, $text makes sense as a variable name, which is one of recent code changes. Other modifications include:

$pee_parts to $text_parts
$last_pee to $last_part
$pees to $paragraphs
$tinkle to $paragraph

That complex wpautop() function and its 150+ lines of code start making a bit more sense when things are named for clarity.

As a dev who uses the placeholder $butt everywhere, I get it. Any named variable that forces a user to 'think' about its intention should be scrutinized.

Write code for your future devs.

(As for naming, there's some good examples of how to name things here and how to name things here)

REFERENCE:
https://wptavern.co
m/wordpress-ditches-pee-and-tinkle-jokes-in-favor-of-more-inclusive-language-and-clearer-code


Related TILs

Tagged:

TIL Static Blocks vs Dynamic Blocks

A static block is a piece of content whose markup is known when the page is saved. The block saves its content and markup directly in the post content. A dynamic block is a piece of content whose markup and exact content are not known when the page is saved.

TIL how to convert a shortcode to a WP block

Traditionally, shortcodes were a way that plugin developers could provide users the ability to add specific plugin functionality anwhere on their site. But shortcodes are not very user friendly, nor was hunting down the relevant data you needed to render the correct data for the shortcode. Converting existing shortcodes to blocks provides a much greater user experience in all aspects.

TIL how WordPress does serverside

This isn't fully accurate, but for the means of describing server-side rendering, it's a good start!