Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Welcome to the WordPress Multisite Environment

Welcome to the WordPress Multisite Environment

Multisite is a powerful tool used to expand the capacity of WordPress while still maintaining all the things you know and love. Multisite allows site mangers to share a core codebase of themes and plugins but deliver different experiences to each website. With multisite domain mapper a company can white label their product for multiple clients while still using one main WordPress engine. Learn how a multisite works, how to set up a multisite, how it can benefit your business and how to development a WordPress multisite platform.

Adam Smith

June 03, 2017
Tweet

More Decks by Adam Smith

Other Decks in Technology

Transcript

  1. WORDPRESS
    MULTISITE
    ENVIRONMENT

    View full-size slide

  2. GREETINGS EARTHLINGS
    @acodesmith | acodesmith.com | Adam Smith

    View full-size slide

  3. WORDPRESS
    AS A SINGLE BLOG

    View full-size slide

  4. SINGLE BLOG
    ★User roles are set for the entire
    site.
    ★One theme is activated at a
    time.
    ★Plugins are managed on a case
    by case basis.
    ★All tables share the same
    prefix. 

    For example: wp_posts

    View full-size slide

  5. HOW WORDPRESS
    WORKS AS A MULTISITE

    View full-size slide

  6. A queen bees pheromones affects social behavior, maintenance of
    the hive, swarming, and mating behavior.

    View full-size slide

  7. MULTISITE
    ★User roles are set on a site by
    site basis.
    ★Themes are approved by the site
    admin then activated per site.
    ★Plugins can either be Network
    Activated or on a site by site
    basis.
    ★Each site has it’s own set of
    tables prefixed by the site ID.

    For example wp_2_posts
    ★Site IDs are auto incremented
    primary keys in the wp_blogs
    table

    View full-size slide

  8. USER ROLES
    ★The super admin can access
    each different site dashboard.
    ★The super admin can approve
    which themes can be activated.
    ★The super admin can Network
    Activate plugins.
    ★The super admin can create a
    new site and add users to that
    site.
    ★A user for one site can only
    access their site dashboard.

    View full-size slide

  9. THEMES
    ★The super admin approves
    which themes can be used by
    other sites.
    ★Each site selects a theme.
    ★All themes live in the themes
    folder.
    ★Multiple sites can use the same
    theme.
    ★Make changes to one theme,
    updates all site using that
    theme.

    View full-size slide

  10. PLUGINS
    ★The super admin can Network
    Active a plugin.
    ★A Network Activated plugin is
    used by all sites and can not be
    excluded by one site.
    ★A single site can activate a
    plugin, just like normal, for
    that site only.
    ★Plugins which generate custom
    tables use the site prefix.

    For example:

    wp_2_woocommerce_sessions

    View full-size slide

  11. TABLES
    ★WordPress creates a new table
    called wp_blogs
    ★The blog_id field in wp_blogs is
    used as a prefix for each site.

    For example: blog_id 2 is used
    to create wp_2_posts
    ★WordPress creates new post,
    postmeta, taxonomy, terms,
    options, comments, etc..
    ★Each site does NOT get a new
    users table. All sites share a
    common wp_users table.

    View full-size slide

  12. TURN ANY WORDPRESS
    SITE INTO A MULTISITE

    View full-size slide

  13. /* Multisite */
    define( 'WP_ALLOW_MULTISITE', true );

    View full-size slide

  14. DOUBLE CHECK AND BACK UP EVERYTHING
    ★ Installation and Server Requirements
    ★ mod_rewrite must be enabled.
    ★ site can’t be hosted on an IP
    ★ site can’t be hosted on a special port; mysite.com:8080
    ★ site can’t be hosted on a localhost url, must use vhost for local install.
    ★ Backup all tables!
    ★ Deactivate all your plugins!
    ★ Subdomain install can’t be ran out of a subfolder, only the root;

    mysite.com/wordpress-installed-here/ 

    mysite.com/wordpress-installed-here/site2

    View full-size slide

  15. TALES OF WOE
    AND VICTORY

    View full-size slide

  16. WOE
    ★If the main site goes down they
    all go down.
    ★If one site is hacked all sites can
    be affected.
    ★One database password for all
    the sites.
    ★A bug in a plugin or a theme
    can affect multiple sites.

    View full-size slide

  17. VICTORY
    ★New features can be rolled out
    to all the sites at once.
    ★Backup one database!
    ★Fix a bug in one place, you fix a
    bug for multiple sites.
    ★Easier to support a large client
    base.

    View full-size slide

  18. BUILDING A
    MULTISITE PLUGIN

    View full-size slide

  19. FUNCTIONS FOR VALIDATING THE MAIN SITE
    FUNCTIONS FOR GETTING THE CURRENT SITE
    FUNCTIONS FOR SWITCHING TO ANOTHER SITE

    View full-size slide

  20. CHECK IF THE USER HAS ACCESS TO A CERTAIN SITE
    Could be used to show beta features to special users for certain blogs.

    View full-size slide

  21. GET DETAILS ABOUT A BLOG BASED ON THE BLOG_ID

    View full-size slide

  22. TABLE PREFIX
    ★Using the global $wpdb object
    to obtain the prefix.

    For example: $wpdb->prefix
    ★Use the prefix when building
    custom tables.
    ★Use the prefix when writing
    raw SQL queries.

    View full-size slide

  23. HOOK FIRES WHEN A NEW SITE IS CREATED
    HOOK FIRES WHEN A SITE IS REMOVED
    HOOK FIRE WHEN A SITE IS ARCHIVED
    https://core.trac.wordpress.org/browser/tags/4.7.3/src/wp-admin/includes/ms.php

    View full-size slide

  24. WHY
    MULTISITE

    View full-size slide

  25. WHY MULTISITE
    ★Software as a service platform
    ★Managing multiple clients in
    one controlled space
    ★Repeatable service model
    ★Whitelabel products

    View full-size slide

  26. QUICK DEMO AND QUESTIONS

    View full-size slide