WordPress.com Teams Up with Rebrand Cities to Bring Local Businesses Online | The WordPress.com Blog

Cities are collections of neighborhoods — and neighborhoods are powered by small business. From coffee shop owners to fitness instructors, therapists to thrift stores, it’s the people we see in the storefronts next door who build and reinforce the unique character of our cities.

At WordPress.com, we want to support local businesses as they grow their own communities (and their revenue!) on the open web. That’s why we’ve teamed up with Rebrand Cities, a project founded by Hajj Flemings to bring small businesses online, in pursuit of an audacious goal: 10,000 new websites for 10,000 small businesses and to tell their stories.

Read the full article: WordPress.com Teams Up with Rebrand Cities to Bring Local Businesses Online — The WordPress.com Blog

Changing Things Up

This past weekend, I decided to change things up a little bit on my blog. Nothing extreme – I’m still using WordPress but I moved my blog from WordPress.com to Pressable, a self-hosted solution. My main reason was so that I could be more helpful in testing out other Automattic products, such as Jetpack, as well as some new Core features, such as the beta Gutenberg editor. Additionally, a self-hosted solution will allow me to customize things a bit further that I would be able to on WordPress.com … but I don’t really plan to do a whole lot of that at the moment.

You may have also noticed that this blog has a new look. After a pretty decent stretch using the theme Revelar, I decided to switch to the default them from 2016 – Twenty Sixteen. I still think Revelar is a great theme. The main reason I switched is because I felt like Revelar is set up great for photography but, if I wanted to post a quick blurb or a standard blog post, I always felt pressured to come up with a good featured image. After exploring a few other themes, I found that Twenty Sixteen was exactly what I was looking for (after making a few very slight visual customizations). It looks great for photo posts with nice featured images, yet it still looks very nice for posts that don’t have/need one.

I’m hoping that this switch prompts me to blog a little bit more, since I don’t have to spend additional time worrying about imagery for non-photography posts. That being said, if you are looking for a more photo-based blog, Revelar is still a great theme!

Dot Blog

To ring in the new year (and thanks to some wonderful colleagues of mine), I just activated dan.robert.blog, replacing my previous site address. Initially, I had set this domain up as a separate photo blog but I changed my mind. I think it will be much more sensible to combine and maintain one site, instead of two.

I’m really proud of the work the .blog folks have done on the new TLD and I’m excited to see where it goes from here.

Head on over to: get.blog if you would like your very own .blog domain!

Yoda Conditional Statements

Here’s a little gem on conditional statements that I saw for the first time in the WordPress Coding Standards a few months ago. When writing out a conditional logic, it is recommended to place the variable on the right side of the comparison operator and the constants or literals on the left. Appropriately named “Yoda Conditions”, as the statement then reads backwards to how we would typically speak or think. I’ve never really thought about this before but it really is a handy little tip.

Take the following example (from the handbook):

[code language=”php”]
if ( true == $the_force ) {
$victorious = you_will( $be );
}
[/code]

Despite that it reads backwards, this makes sense programatically. If you were to accidentally omit a part of the comparison operator (an equals sign, for example) when writing out your statement, your code would fail because you can’t assign to a constant. Writing your conditional the other way around (non-Yoda) would evaluate to true via an accidental assignment operator. This would result in perfectly valid code and a bug that is much more difficult to track down.

Note that this only applies to ==, !=, ===, and !== comparisons. As stated in the handbook, “Yoda conditions for <, >, <= or >= are significantly more difficult to read and are best avoided.”

WordPress Post Revisions

As of version 2.6, WordPress introduced a feature which autosaves your posts as revisions while you are editing them in the dashboard. While this functionality can be very useful, it can also be a bit of an annoyance. If a single post ends up going through multiple edits or simply takes a while to get finished, those revisions can add up. I personally don’t see the need to have billions upon billions (ok, slight exaggeration) of revisions saved for every one of my posts. Additionally, that is just extra information that is getting stored in your database, which you may not need. Disabling this feature or limiting the amount of allowed revisions (which is what I opted for) is actually quite simple. It only takes one line of code in your wp-config.php file.

[code language=bash]
/** Disables WordPress automatic post revisions. **/
define(‘WP_POST_REVISIONS’, false);

/** Limits revisions to specified number (second parameter). **/
define(‘WP_POST_REVISIONS’, 5);
[/code]

Continue reading “WordPress Post Revisions”