Detecting a Large Multisite Network in WordPress

If you have ever worked on a very large Multisite network in WordPress, you probably understand the challenges of working with large sets of data. WordPress contains a function to help you detect a large network, wp_is_large_network(). This function accepts a single parameter $using, which sets whether to count users or sites. If your network is either more than 10,000 users or more than 10,000 sites, the function will return true. Let’s look at an example:

<?php
if ( wp_is_large_network( 'users' ) ) {

    //this network has over 10,000 users

}elseif ( wp_is_large_network( 'sites' ) ) {

    //this network has over 10,000 sites

}
?>

This function is extremely handy if you are trying to work with large sets of data. When working with Multisite, and WordPress in general, you should always write code that can scale. You can also easily alter the large network criteria using the wp_is_large_network filter.

WordPress Multisite is an extremely powerful feature of WordPress. Understanding the tools available when working with Multisite will help you build amazing, and stable, WordPress networks.

PressNomics 2015

Current status: On an airplane flying to sunny Phoenix, Arizona for PressNomics 3! PressNomics is an awesome event that focuses on the commercial side of WordPress. The event is self-described as “The conference for those that power the WordPress Economy” and that statement couldn’t be more true. PressNomics is a who’s who of respected professionals and companies making a living from WordPress.

pressnomics-logo
The event has been one of my favorites to attend since the first PressNomics. The presentations are always top-notch, but what I really enjoy the most are the hallway conversations. I love talking shop, so to have the opportunity to brush shoulders with so many like minded people in our industry is an insanely valuable experience.

I’ll be attending this year with Lisa Sabin-Wilson and Dre Armeda representing WebDevStudios and Maintainn. If you are attending this year make sure you track me down and say hi! A good spot to start looking is at SanTan Brewery. :)

If you have not had the opportunity to attend PressNomics, and are involved in the commercial side of WordPress, I strongly recommend you plan on attending. After all, do you really need an excuse to visit Phoenix in the Winter?

A Brief History of WordPress News and Podcasts

There has been a lot of discussion around the future of WordPress news and podcasts. The Professional WordPress book series spans 5 years (crazy!), so I thought it would be fun to take a look back at what WordPress news sites and podcasts were featured in each edition and which ones still exist today.


Professional WordPress 1st Edition

(Released April 5th, 2010)

WordPress News Sites

  • WordPress Tavern – ACTIVE (http://wptavern.com) – The grand old man of the WordPress news industry, the WordPress Tavern is going stronger than ever.
  • WPVibe.com – DEAD (http://wpvibe.com) – The WordPress Vibe had a short lifespan and stopped publishing content in the Spring of 2011.
  • Weblog Tools Collection – DEAD (http://WeblogToolsCollection.com) – An older site dedicated to WordPress and blogging in general. The site was purchased by Matt Mullenweg in 2013 and is kept online as an archive only.
  • WPEngineer.com – DEAD (http://WPEngineer.com) – Not as active as it once was, the WPEngineer.com site contains some good coding tips and tricks around WordPress.
  • WordPress Podcasts

    • WordPress Weekly – ACTIVE (http://wptavern.com/wordpress-weekly) – The official WordPress podcast of the WordPress Tavern.
    • WordCast Podcast – DEAD – A WordPress podcast that was hosted by Dave Moyer and Kym Huynh. The archive has since been removed and is no longer available online.
    • The WordPress Podcast – DEAD (http://www2.webmasterradio.fm/wordpress-community-podcast/) – A podcast hosted through WebmasterRadio.fm featuring Joost de Valk and Frederick Townes. The last episode aired in February 2011.
    • Plugins: The WordPress Plugins Podcast – DEAD (http://www.pluginspodcast.com) – The original WordPress podcast dedicated to plugins. The podcast ended in May of 2010.


    Professional WordPress 2nd Edition

    (Released January 4th, 2013)

    WordPress News Sites

    • WPCandy – DEAD (http://wpcandy.com) – One of the largest and most successful WordPress news sites, WPCandy stopped publishing new content in 2013.
    • WP Realm – DEAD (http://wprealm.com) – A WordPress news site with a prominent WordPress community member staff of writers. Publishing ended in 2013.
    • WP Force – DEAD (http://wpforce.com) – The WP Force is a WordPress news site that was actively publishing fresh content through early 2014.
  • WPEngineer.com – DEAD (http://WPEngineer.com) – Not as active as it once was, the WPEngineer.com site contains some good coding tips and tricks around WordPress.
  • WordPress Podcasts

    • WP Late Night – DEAD – A WordPress focused podcast hosted by Ryan Imel, Dre Armeda, and me! WP Late Night was the precursor to the DradCast.
    • WPCandy.com Shows – DEAD (http://wpcandy.com/shows/) – WP Candy produced a number of different WordPress focused podcasts. All WP Candy podcasts ended in 2013.


    Professional WordPress 3rd Edition

    (Released January 12th, 2015)

    WordPress News Sites

    • WordPress Tavern – ACTIVE (http://wptavern.com) – Only one of two WordPress news site to make two editions of Professional WordPress, WP Tavern saw a rebirth when the website was purchased by Matt Mullenweg in 2013.
    • Post Status – ACTIVE (https://poststatus.com) – Post Status is a WordPress news site ran by Brian Krogsgard. The site has traditional focused on long-form news articles, but has recently expanded with more news options.
    • ManageWP.org – ACTIVE (https://managewp.org) – A social news aggregator, ManageWP.org features WordPress related news that is up voted by the community.
    • Torque Mag – ACTIVE (http://torquemag.io) – Debuting in 2013, Torque Mag is a WP Engine publication that focuses on WordPress news.

    WordPress Podcasts

    • DradCast – ACTIVE (http://dradcast.com) – The #1 late night WordPress podcast, hosted by Dre Armeda and myself. The show is recorded live every Wednesday evening at 8pm EST.
    • WordPress Weekly – ACTIVE (http://wptavern.com/wordpress-weekly) – The only WordPress podcast to make two editions of Professional WordPress, the WordPress Weekly podcast is back with regular weekly episodes.
    • WP Water Cooler – ACTIVE (http://www.wpwatercooler.com) – A round-table style podcast feature prominent WordPress community members discussing hot topics of the week.
    • Matt Report – ACTIVE (http://mattreport.com) – A WordPress podcast focused on topics including business, startups, and entrepreneurs.
    • Apply Filters – ACTIVE (http://applyfilters.fm) – The only active WordPress development focused podcast, hosted by Pippin Williamson and Brad Touesnard.


    It’s pretty amazing to see how many WordPress news sites and podcasts have come and gone over the years. WP Tavern and WPEngineer.com are the only news websites that made two editions of Professional WordPress. WordPress Weekly is the only podcast to make two editions. WordPress news and podcasts are a vital part of our community and have been since well before Professional WordPress was released.

    Here’s hoping to many more repeats, and new entries, in future editions of Professional WordPress!

WordPress Checked and Selected Functions

Two of my favorite functions in WordPress are the checked() and selected() functions. Both of these functions are extremely useful whenever you are working with form elements in your plugins and themes so it helps to understand both of these little nuggets of goodness. These two functions are used the same way, but output different results.

The selected() function compares two values in a select list and if they are identical will set the current option value to selected. This is useful when displaying form fields (an options page for example) and want to determine whether an option is set or not. Lets look at an example:

<select>
    <option value="red" <?php selected( $option_value, 'red' ); ?>>Red</option>
    <option value="orange" <?php selected( $option_value, 'orange' ); ?>>Orange</option>
    <option value="blue" <?php selected( $option_value, 'blue' ); ?>>Blue</option>
</select>

Assuming the $option_value variable is equal to the value of “orange”, the following HTML would be generated

<select>
    <option value="red">Red</option>
    <option value="orange" selected="selected">Orange</option>
    <option value="blue">Blue</option>
</select>

The checked() function works exactly the same, in that it compares the two values and if they are identical it sets the current checkbox form element to be checked.

<input type="checkbox" name="rage_mode" <?php checked( $rage_mode, 'on' ); ?>/> Rage Mode<br /> 
<input type="checkbox" name="ninja_mode" <?php checked( $ninja_mode, 'on' ); ?> /> Ninja Mode<br /> 
<input type="checkbox" name="zombie_mode" <?php checked( $zombie_mode, 'on' ); ?> /> Zombie Mode<br /> 

Let’s assume that Rage mode and Zombie mode are activated. The following HTML would be generated:

<input type="checkbox" name="rage_mode" checked="checked"/> Rage Mode<br /> 
<input type="checkbox" name="ninja_mode"/> Ninja Mode<br /> 
<input type="checkbox" name="zombie_mode" checked="checked"/> Zombie Mode<br /> 

There is also a lesser know function in WordPress called disabled(). This function checks two values and if identical returns the disabled attribute for any HTML element.

For more information on these functions, and many more useful WordPress functions, check out my newest book: Professional WordPress Third Edition.

Pre-Order Professional WordPress Third Edition

Professional WordPress Third Edition has been officially completed and is available for pre-order on Amazon!

Professional WordPress 3rd editionEvery chapter in this new edition of the book has been completely updated for WordPress 4.1. The book also features two brand new chapters: WordPress as an Application Framework and Migrating to WordPress.

I couldn’t be happier to hear the response we’ve received from the previous two editions. This book has truly helped people around the world learn and understand WordPress development and design. If you are just starting to learn WordPress, or are an experienced developer or designer, this book has something for you. The Professional WordPress series is the highest rated advanced WordPress book on the market.

The book is scheduled to be released on January 26th, 2015. Make sure you pre-order your copy of Professional WordPress Third Edition today!

Understanding WordPress Taxonomy Table Relationships

When working with taxonomies in WordPress, it’s helpful to understand the taxonomy database schema. The WordPress database contains three tables for storing taxonomy data:

  • wp_terms – stores all of your taxonomy terms
  • wp_term_taxonomy – defines what taxonomy each term belongs to
  • wp_term_relationships – cross-reference table that joins taxonomy terms with your content

Let’s look at an example database query joining the taxonomy tables. The below query will return all posts with all taxonomy terms assigned to each post:

SELECT wt.name, p.post_title, p.post_date 
FROM wp_terms wt
INNER JOIN wp_term_taxonomy wtt ON wt.term_id = wtt.term_id
INNER JOIN wp_term_relationships wtr ON wtt.term_taxonomy_id = wtr.term_taxonomy_id
INNER JOIN wp_posts p ON wtr.object_id = p.ID
WHERE p.post_type = 'post'

Using joins you can start to understand the relationship between the three taxonomy tables. I’m a visual person, so I created the below graphic to illustrate the taxonomy table relationships.

987247c07f002

Taxonomies are an extremely powerful component of WordPress. Understanding the taxonomy database schema can be very helpful when building more complex WordPress websites. If you are interested in learning more about taxonomies in WordPress, check out my Professional WordPress book.

Professional WordPress Third Edition is Coming!

That’s right, the highest rated WordPress development book on the market is back with an all new third edition! The writing has begun and Professional WordPress 3E has officially passed the halfway mark. Just like the previous edition, this version will be written by David Damstra and myself.

Professional WordPress 3E will be fully updated for WordPress 4.1. The new edition will feature two completely new chapters:

  • Migrating to WordPress – Covers understanding the migration process, generating data mapping guides, and utilizing WP-CLI with migration scripts.
  • Application Framework – Covers using WordPress as an application framework, integrating APIs, external libraries, and web services. Will also touch on native app development on iOS and Android.

As an extra special bonus, we have THE Lisa Sabin-Wilson on board as the Technical Editor for this edition! Lisa is the For Dummies brand franchise author on all things WordPress. She has been working with WordPress since 2003 and writing about WordPress since 2006. Lisa is an amazing asset to have on Professional WordPress and will help make this edition the best one yet!

The book is targeting an end of year release. You can follow our progress and any Professional WordPress Third Edition news with the hash tag #prowp3.

WordSesh 2 Is Live Right Now

WordPress Online ConferenceHave you heard of WordSesh? The online streaming WordPress conference (which is totally free) is currently streaming live right now for WordSesh 2!

WordSesh has two tracks with 58 amazing speakers:

Don’t miss out enjoying this event live. The sessions are recorded, so you could watch them later, but joining in on the chat room and tweet conversations make WordSesh a very special event.

Writing Secure WordPress Code

A few weeks ago I gave a presentation at WordCamp Europe on writing secure WordPress code. The methods I described in my presentation are extremely important when writing code for WordPress. Whether you are a theme designer or a hardcore plugin developer, you should follow all of these security measures to verify your code is as secure as possible. My presentation slides are below:

WordCamp Europe Is Next Week!

Next week I will be attending and speaking at the first ever WordCamp Europe! The event takes place October 5th-7th in Leiden, Netherlands. WordCamp Europe is going to be an amazing event with a insane amount of awesome presentations.

WordCamp Europe 2013 SpeakerI will be presenting on Writing Secure WordPress Code. I’m scheduled to be the last presentation on Saturday at 17:15. I’ll be covering tips and functions available in WordPress that can help you keep your code as secure as possible. Whether you’re a plugin developer or build themes, it’s extremely important to understand how to secure your code from hacks and exploits.

As awesome as this event is going to be, I’m just as excited to see many of my friends at the event. The Attendees list is a who’s who of WordPress awesomeness. I have so many European friends in the WordPress community that will be in attendance so I can’t wait to hang out!

If you’re attending WordCamp Europe make sure you track me down and say hi!